QT6: QStyleOptionGraphicsItem

This commit is contained in:
Simon De Backer
2020-10-03 15:48:40 +02:00
parent 2e2a652343
commit c1e93fc442
9 changed files with 261 additions and 192 deletions

View File

@@ -1,17 +1,17 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -61,9 +61,16 @@ void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
//Always remove the brush //Always remove the brush
painter -> setBrush(Qt::NoBrush); painter -> setBrush(Qt::NoBrush);
QPen t = painter -> pen(); QPen t = painter -> pen();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
t.setCosmetic(options && options -> levelOfDetail < 1.0); t.setCosmetic(options && options -> levelOfDetail < 1.0);
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
#endif
painter -> setPen(t); painter -> setPen(t);
if (isSelected()) if (isSelected())
{ {
painter->save(); painter->save();
@@ -79,7 +86,7 @@ void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
t.setColor(Qt::red); t.setColor(Qt::red);
painter -> setPen(t); painter -> setPen(t);
} }
painter->drawArc(m_rect, m_start_angle, m_span_angle); painter->drawArc(m_rect, m_start_angle, m_span_angle);
if (m_hovered) if (m_hovered)
@@ -196,8 +203,8 @@ QVariant PartArc::itemChange(QGraphicsItem::GraphicsItemChange change, const QVa
{ {
//When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler, //When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler,
//according to the number of selected items. //according to the number of selected items.
connect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged); connect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged);
if (scene()->selectedItems().size() == 1) if (scene()->selectedItems().size() == 1)
addHandler(); addHandler();
} }
@@ -215,10 +222,10 @@ QVariant PartArc::itemChange(QGraphicsItem::GraphicsItemChange change, const QVa
{ {
if(scene()) if(scene())
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged); disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged);
setSelected(false); //This is item removed from scene, then we deselect this, and so, the handlers is also removed. setSelected(false); //This is item removed from scene, then we deselect this, and so, the handlers is also removed.
} }
return QGraphicsItem::itemChange(change, value); return QGraphicsItem::itemChange(change, value);
} }
@@ -234,7 +241,7 @@ bool PartArc::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
if(watched->type() == QetGraphicsHandlerItem::Type) if(watched->type() == QetGraphicsHandlerItem::Type)
{ {
QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched); QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched);
if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
{ {
m_vector_index = m_handler_vector.indexOf(qghi); m_vector_index = m_handler_vector.indexOf(qghi);
@@ -258,7 +265,7 @@ bool PartArc::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
} }
} }
} }
return false; return false;
} }
@@ -266,7 +273,7 @@ bool PartArc::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
@brief PartArc::switchResizeMode @brief PartArc::switchResizeMode
*/ */
void PartArc::switchResizeMode() void PartArc::switchResizeMode()
{ {
if (m_resize_mode == 1) if (m_resize_mode == 1)
{ {
m_resize_mode = 2; m_resize_mode = 2;
@@ -274,24 +281,24 @@ void PartArc::switchResizeMode()
qghi->setColor(Qt::darkGreen); qghi->setColor(Qt::darkGreen);
} }
else if (m_resize_mode == 2) else if (m_resize_mode == 2)
{ {
m_resize_mode = 3; m_resize_mode = 3;
//From rect mode to angle mode, then numbers of handlers change //From rect mode to angle mode, then numbers of handlers change
removeHandler(); removeHandler();
addHandler(); addHandler();
for (QetGraphicsHandlerItem *qghi : m_handler_vector) for (QetGraphicsHandlerItem *qghi : m_handler_vector)
qghi->setColor(Qt::magenta); qghi->setColor(Qt::magenta);
} }
else else
{ {
m_resize_mode = 1; m_resize_mode = 1;
//From angle mode to rect mode, then numbers of handlers change //From angle mode to rect mode, then numbers of handlers change
removeHandler(); removeHandler();
addHandler(); addHandler();
for (QetGraphicsHandlerItem *qghi : m_handler_vector) for (QetGraphicsHandlerItem *qghi : m_handler_vector)
qghi->setColor(Qt::blue); qghi->setColor(Qt::blue);
} }
@@ -304,21 +311,21 @@ void PartArc::adjusteHandlerPos()
{ {
if (m_handler_vector.isEmpty()) if (m_handler_vector.isEmpty())
return; return;
QVector <QPointF> points_vector; QVector <QPointF> points_vector;
if(m_resize_mode == 3) if(m_resize_mode == 3)
points_vector = QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16); points_vector = QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16);
else else
points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect); points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect);
if (m_handler_vector.size() == points_vector.size()) if (m_handler_vector.size() == points_vector.size())
{ {
points_vector = mapToScene(points_vector); points_vector = mapToScene(points_vector);
for (int i = 0 ; i < points_vector.size() ; ++i) for (int i = 0 ; i < points_vector.size() ; ++i)
m_handler_vector.at(i)->setPos(points_vector.at(i)); m_handler_vector.at(i)->setPos(points_vector.at(i));
} }
} }
/** /**
@@ -330,7 +337,7 @@ void PartArc::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsScen
{ {
Q_UNUSED(qghi) Q_UNUSED(qghi)
Q_UNUSED(event) Q_UNUSED(event)
if (m_resize_mode == 3) //Resize angle if (m_resize_mode == 3) //Resize angle
{ {
if (m_vector_index == 0) if (m_vector_index == 0)
@@ -368,12 +375,12 @@ void PartArc::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsScen
void PartArc::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event) void PartArc::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
{ {
Q_UNUSED(qghi) Q_UNUSED(qghi)
QPointF new_pos = event->scenePos(); QPointF new_pos = event->scenePos();
if (event->modifiers() != Qt::ControlModifier) if (event->modifiers() != Qt::ControlModifier)
new_pos = elementScene()->snapToGrid(event->scenePos()); new_pos = elementScene()->snapToGrid(event->scenePos());
new_pos = mapFromScene(new_pos); new_pos = mapFromScene(new_pos);
if (m_resize_mode == 1) if (m_resize_mode == 1)
setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index)); setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index));
else if (m_resize_mode == 2) else if (m_resize_mode == 2)
@@ -403,7 +410,7 @@ void PartArc::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSc
{ {
Q_UNUSED(qghi) Q_UNUSED(qghi)
Q_UNUSED(event) Q_UNUSED(event)
if (m_resize_mode == 3) if (m_resize_mode == 3)
{ {
if (m_vector_index == 0) if (m_vector_index == 0)
@@ -461,7 +468,7 @@ void PartArc::addHandler()
} }
else else
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect))); m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
for(QetGraphicsHandlerItem *handler : m_handler_vector) for(QetGraphicsHandlerItem *handler : m_handler_vector)
{ {
QColor color = Qt::blue; QColor color = Qt::blue;
@@ -469,7 +476,7 @@ void PartArc::addHandler()
color = Qt::darkGreen; color = Qt::darkGreen;
else if (m_resize_mode == 3) else if (m_resize_mode == 3)
color = Qt::magenta; color = Qt::magenta;
handler->setColor(color); handler->setColor(color);
scene()->addItem(handler); scene()->addItem(handler);
handler->installSceneEventFilter(this); handler->installSceneEventFilter(this);

View File

@@ -1,17 +1,17 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -55,8 +55,15 @@ void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
applyStylesToQPainter(*painter); applyStylesToQPainter(*painter);
QPen t = painter -> pen(); QPen t = painter -> pen();
t.setCosmetic(options && options -> levelOfDetail < 1.0);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
t.setCosmetic(options && options -> levelOfDetail < 1.0);
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
#endif
if (isSelected()) if (isSelected())
t.setColor(Qt::red); t.setColor(Qt::red);
@@ -159,7 +166,7 @@ void PartEllipse::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton && event->buttonDownPos(Qt::LeftButton) == event->pos()) if (event->button() == Qt::LeftButton && event->buttonDownPos(Qt::LeftButton) == event->pos())
switchResizeMode(); switchResizeMode();
CustomElementGraphicPart::mouseReleaseEvent(event); CustomElementGraphicPart::mouseReleaseEvent(event);
} }
@@ -177,8 +184,8 @@ QVariant PartEllipse::itemChange(QGraphicsItem::GraphicsItemChange change, const
{ {
//When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler, //When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler,
//according to the number of selected items. //according to the number of selected items.
connect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged); connect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged);
if (scene()->selectedItems().size() == 1) if (scene()->selectedItems().size() == 1)
addHandler(); addHandler();
} }
@@ -196,10 +203,10 @@ QVariant PartEllipse::itemChange(QGraphicsItem::GraphicsItemChange change, const
{ {
if(scene()) if(scene())
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged); disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged);
setSelected(false); //This item is removed from scene, then we deselect this, and so, the handlers is also removed. setSelected(false); //This item is removed from scene, then we deselect this, and so, the handlers is also removed.
} }
return QGraphicsItem::itemChange(change, value); return QGraphicsItem::itemChange(change, value);
} }
@@ -215,7 +222,7 @@ bool PartEllipse::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
if(watched->type() == QetGraphicsHandlerItem::Type) if(watched->type() == QetGraphicsHandlerItem::Type)
{ {
QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched); QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched);
if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
{ {
m_vector_index = m_handler_vector.indexOf(qghi); m_vector_index = m_handler_vector.indexOf(qghi);
@@ -239,7 +246,7 @@ bool PartEllipse::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
} }
} }
} }
return false; return false;
} }
@@ -266,9 +273,9 @@ void PartEllipse::adjusteHandlerPos()
{ {
if (m_handler_vector.isEmpty()) if (m_handler_vector.isEmpty())
return; return;
QVector <QPointF> points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect); QVector <QPointF> points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect);
if (m_handler_vector.size() == points_vector.size()) if (m_handler_vector.size() == points_vector.size())
{ {
points_vector = mapToScene(points_vector); points_vector = mapToScene(points_vector);
@@ -290,7 +297,7 @@ void PartEllipse::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphics
m_undo_command = new QPropertyUndoCommand(this, "rect", QVariant(m_rect)); m_undo_command = new QPropertyUndoCommand(this, "rect", QVariant(m_rect));
m_undo_command->setText(tr("Modifier un rectangle")); m_undo_command->setText(tr("Modifier un rectangle"));
m_undo_command->enableAnimation(); m_undo_command->enableAnimation();
return; return;
} }
/** /**
@@ -301,17 +308,17 @@ void PartEllipse::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphics
void PartEllipse::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event) void PartEllipse::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
{ {
Q_UNUSED(qghi); Q_UNUSED(qghi);
QPointF new_pos = event->scenePos(); QPointF new_pos = event->scenePos();
if (event->modifiers() != Qt::ControlModifier) if (event->modifiers() != Qt::ControlModifier)
new_pos = elementScene()->snapToGrid(event->scenePos()); new_pos = elementScene()->snapToGrid(event->scenePos());
new_pos = mapFromScene(new_pos); new_pos = mapFromScene(new_pos);
if (m_resize_mode == 1) if (m_resize_mode == 1)
setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index)); setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index));
else else
setRect(QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(m_rect, new_pos, m_vector_index)); setRect(QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(m_rect, new_pos, m_vector_index));
adjusteHandlerPos(); adjusteHandlerPos();
} }
@@ -324,7 +331,7 @@ void PartEllipse::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphi
{ {
Q_UNUSED(qghi); Q_UNUSED(qghi);
Q_UNUSED(event); Q_UNUSED(event);
m_undo_command->setNewValue(QVariant(m_rect)); m_undo_command->setNewValue(QVariant(m_rect));
elementScene()->undoStack().push(m_undo_command); elementScene()->undoStack().push(m_undo_command);
m_undo_command = nullptr; m_undo_command = nullptr;
@@ -350,15 +357,15 @@ void PartEllipse::sceneSelectionChanged()
void PartEllipse::addHandler() void PartEllipse::addHandler()
{ {
if (m_handler_vector.isEmpty() && scene()) if (m_handler_vector.isEmpty() && scene())
{ {
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect))); m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
for(QetGraphicsHandlerItem *handler : m_handler_vector) for(QetGraphicsHandlerItem *handler : m_handler_vector)
{ {
QColor color = Qt::blue; QColor color = Qt::blue;
if (m_resize_mode == 2) if (m_resize_mode == 2)
color = Qt::darkGreen; color = Qt::darkGreen;
handler->setColor(color); handler->setColor(color);
scene()->addItem(handler); scene()->addItem(handler);
handler->installSceneEventFilter(this); handler->installSceneEventFilter(this);

View File

@@ -1,17 +1,17 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -42,7 +42,7 @@ PartLine::~PartLine()
{ {
if(m_undo_command) if(m_undo_command)
delete m_undo_command; delete m_undo_command;
removeHandler(); removeHandler();
} }
@@ -79,12 +79,19 @@ void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
applyStylesToQPainter(*painter); applyStylesToQPainter(*painter);
QPen t = painter -> pen(); QPen t = painter -> pen();
t.setJoinStyle(Qt::MiterJoin); t.setJoinStyle(Qt::MiterJoin);
t.setCosmetic(options && options -> levelOfDetail < 1.0);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
t.setCosmetic(options && options -> levelOfDetail < 1.0);
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
#endif
if (isSelected()) t.setColor(Qt::red); if (isSelected()) t.setColor(Qt::red);
painter -> setPen(t); painter -> setPen(t);
if (first_end || second_end) if (first_end || second_end)
painter -> drawPath(path()); painter -> drawPath(path());
else else
@@ -106,7 +113,7 @@ const QDomElement PartLine::toXml(QDomDocument &xml_document) const
{ {
QPointF p1(sceneP1()); QPointF p1(sceneP1());
QPointF p2(sceneP2()); QPointF p2(sceneP2());
QDomElement xml_element = xml_document.createElement("line"); QDomElement xml_element = xml_document.createElement("line");
xml_element.setAttribute("x1", QString("%1").arg(p1.x())); xml_element.setAttribute("x1", QString("%1").arg(p1.x()));
xml_element.setAttribute("y1", QString("%1").arg(p1.y())); xml_element.setAttribute("y1", QString("%1").arg(p1.y()));
@@ -116,7 +123,7 @@ const QDomElement PartLine::toXml(QDomDocument &xml_document) const
xml_element.setAttribute("length1", QString("%1").arg(first_length)); xml_element.setAttribute("length1", QString("%1").arg(first_length));
xml_element.setAttribute("end2", Qet::endTypeToString(second_end)); xml_element.setAttribute("end2", Qet::endTypeToString(second_end));
xml_element.setAttribute("length2", QString("%1").arg(second_length)); xml_element.setAttribute("length2", QString("%1").arg(second_length));
stylesToXml(xml_element); stylesToXml(xml_element);
return(xml_element); return(xml_element);
} }
@@ -153,8 +160,8 @@ QVariant PartLine::itemChange(QGraphicsItem::GraphicsItemChange change, const QV
{ {
//When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler, //When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler,
//according to the number of selected items. //according to the number of selected items.
connect(scene(), &QGraphicsScene::selectionChanged, this, &PartLine::sceneSelectionChanged); connect(scene(), &QGraphicsScene::selectionChanged, this, &PartLine::sceneSelectionChanged);
if (scene()->selectedItems().size() == 1) if (scene()->selectedItems().size() == 1)
addHandler(); addHandler();
} }
@@ -172,10 +179,10 @@ QVariant PartLine::itemChange(QGraphicsItem::GraphicsItemChange change, const QV
{ {
if(scene()) if(scene())
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartLine::sceneSelectionChanged); disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartLine::sceneSelectionChanged);
setSelected(false); //This is item removed from scene, then we deselect this, and so, the handlers is also removed. setSelected(false); //This is item removed from scene, then we deselect this, and so, the handlers is also removed.
} }
return QGraphicsItem::itemChange(change, value); return QGraphicsItem::itemChange(change, value);
} }
@@ -191,7 +198,7 @@ bool PartLine::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
if(watched->type() == QetGraphicsHandlerItem::Type) if(watched->type() == QetGraphicsHandlerItem::Type)
{ {
QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched); QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched);
if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
{ {
m_vector_index = m_handler_vector.indexOf(qghi); m_vector_index = m_handler_vector.indexOf(qghi);
@@ -215,7 +222,7 @@ bool PartLine::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
} }
} }
} }
return false; return false;
} }
@@ -227,10 +234,10 @@ void PartLine::adjusteHandlerPos()
{ {
if(m_handler_vector.isEmpty()) if(m_handler_vector.isEmpty())
return; return;
QVector<QPointF> points_vector; QVector<QPointF> points_vector;
points_vector << m_line.p1() << m_line.p2(); points_vector << m_line.p1() << m_line.p2();
if (m_handler_vector.size() == points_vector.size()) if (m_handler_vector.size() == points_vector.size())
{ {
points_vector = mapToScene(points_vector); points_vector = mapToScene(points_vector);
@@ -248,7 +255,7 @@ void PartLine::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSce
{ {
Q_UNUSED(qghi) Q_UNUSED(qghi)
Q_UNUSED(event) Q_UNUSED(event)
m_undo_command = new QPropertyUndoCommand(this, "line", QVariant(m_line)); m_undo_command = new QPropertyUndoCommand(this, "line", QVariant(m_line));
m_undo_command->setText(tr("Modifier une ligne")); m_undo_command->setText(tr("Modifier une ligne"));
m_undo_command->enableAnimation(); m_undo_command->enableAnimation();
@@ -263,12 +270,12 @@ void PartLine::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSce
void PartLine::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event) void PartLine::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
{ {
Q_UNUSED(qghi) Q_UNUSED(qghi)
QPointF new_pos = event->scenePos(); QPointF new_pos = event->scenePos();
if (event->modifiers() != Qt::ControlModifier) if (event->modifiers() != Qt::ControlModifier)
new_pos = elementScene()->snapToGrid(event->scenePos()); new_pos = elementScene()->snapToGrid(event->scenePos());
new_pos = mapFromScene(new_pos); new_pos = mapFromScene(new_pos);
prepareGeometryChange(); prepareGeometryChange();
if (m_vector_index == 0) if (m_vector_index == 0)
m_line.setP1(new_pos); m_line.setP1(new_pos);
@@ -276,7 +283,7 @@ void PartLine::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsScen
m_line.setP2(new_pos); m_line.setP2(new_pos);
emit lineChanged(); emit lineChanged();
adjusteHandlerPos(); adjusteHandlerPos();
} }
@@ -289,7 +296,7 @@ void PartLine::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsS
{ {
Q_UNUSED(qghi) Q_UNUSED(qghi)
Q_UNUSED(event) Q_UNUSED(event)
m_undo_command->setNewValue(QVariant(m_line)); m_undo_command->setNewValue(QVariant(m_line));
elementScene()->undoStack().push(m_undo_command); elementScene()->undoStack().push(m_undo_command);
m_undo_command = nullptr; m_undo_command = nullptr;
@@ -318,9 +325,9 @@ void PartLine::addHandler()
{ {
QVector<QPointF> points_vector; QVector<QPointF> points_vector;
points_vector << m_line.p1() << m_line.p2(); points_vector << m_line.p1() << m_line.p2();
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(points_vector)); m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(points_vector));
for(QetGraphicsHandlerItem *handler : m_handler_vector) for(QetGraphicsHandlerItem *handler : m_handler_vector)
{ {
handler->setColor(Qt::blue); handler->setColor(Qt::blue);
@@ -416,12 +423,12 @@ QRectF PartLine::firstEndCircleRect() const
QList<QPointF> interesting_points = fourEndPoints(m_line.p1(), QList<QPointF> interesting_points = fourEndPoints(m_line.p1(),
m_line.p2(), m_line.p2(),
first_length); first_length);
QRectF end_rect( QRectF end_rect(
interesting_points[0] - QPointF(first_length, first_length), interesting_points[0] - QPointF(first_length, first_length),
QSizeF(2.0 * first_length, 2.0 * first_length) QSizeF(2.0 * first_length, 2.0 * first_length)
); );
return(end_rect); return(end_rect);
} }
@@ -434,12 +441,12 @@ QRectF PartLine::secondEndCircleRect() const
QList<QPointF> interesting_points = fourEndPoints(m_line.p2(), QList<QPointF> interesting_points = fourEndPoints(m_line.p2(),
m_line.p1(), m_line.p1(),
second_length); second_length);
QRectF end_rect( QRectF end_rect(
interesting_points[0] - QPointF(second_length, second_length), interesting_points[0] - QPointF(second_length, second_length),
QSizeF(2.0 * second_length, 2.0 * second_length) QSizeF(2.0 * second_length, 2.0 * second_length)
); );
return(end_rect); return(end_rect);
} }
@@ -448,7 +455,7 @@ QRectF PartLine::secondEndCircleRect() const
@return the bounding rect of this part @return the bounding rect of this part
*/ */
QRectF PartLine::boundingRect() const QRectF PartLine::boundingRect() const
{ {
QRectF bound; QRectF bound;
if (first_end || second_end) if (first_end || second_end)
bound = path().boundingRect(); bound = path().boundingRect();
@@ -537,13 +544,13 @@ QList<QPointF> PartLine::fourEndPoints(const QPointF &end_point, const QPointF &
//Unitary vector and perpendicular vector //Unitary vector and perpendicular vector
QPointF u(line_vector / line_length * length); QPointF u(line_vector / line_length * length);
QPointF v(-u.y(), u.x()); QPointF v(-u.y(), u.x());
// points O, A, B, C // points O, A, B, C
QPointF o(end_point - u); QPointF o(end_point - u);
QPointF a(o - u); QPointF a(o - u);
QPointF b(o + v); QPointF b(o + v);
QPointF c(o - v); QPointF c(o - v);
return(QList<QPointF>() << o << a << b << c); return(QList<QPointF>() << o << a << b << c);
} }

View File

@@ -1,17 +1,17 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -66,7 +66,14 @@ void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
applyStylesToQPainter(*painter); applyStylesToQPainter(*painter);
QPen t = painter -> pen(); QPen t = painter -> pen();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
t.setCosmetic(options && options -> levelOfDetail < 1.0); t.setCosmetic(options && options -> levelOfDetail < 1.0);
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
#endif
if (isSelected()) t.setColor(Qt::red); if (isSelected()) t.setColor(Qt::red);
painter -> setPen(t); painter -> setPen(t);
@@ -95,7 +102,7 @@ void PartPolygon::fromXml(const QDomElement &qde)
else break; else break;
} }
QPolygonF temp_polygon; QPolygonF temp_polygon;
for (int j = 1 ; j < i ; ++ j) for (int j = 1 ; j < i ; ++ j)
{ {
@@ -103,7 +110,7 @@ void PartPolygon::fromXml(const QDomElement &qde)
qde.attribute(QString("y%1").arg(j)).toDouble()); qde.attribute(QString("y%1").arg(j)).toDouble());
} }
m_polygon = temp_polygon; m_polygon = temp_polygon;
m_closed = qde.attribute("closed") != "false"; m_closed = qde.attribute("closed") != "false";
} }
@@ -290,7 +297,7 @@ void PartPolygon::resetAllHandlerColor()
@brief PartPolygon::itemChange @brief PartPolygon::itemChange
@param change @param change
@param value @param value
@return @return
*/ */
QVariant PartPolygon::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) QVariant PartPolygon::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{ {
@@ -300,8 +307,8 @@ QVariant PartPolygon::itemChange(QGraphicsItem::GraphicsItemChange change, const
{ {
//When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler, //When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler,
//according to the number of selected items. //according to the number of selected items.
connect(scene(), &QGraphicsScene::selectionChanged, this, &PartPolygon::sceneSelectionChanged); connect(scene(), &QGraphicsScene::selectionChanged, this, &PartPolygon::sceneSelectionChanged);
if (scene()->selectedItems().size() == 1) if (scene()->selectedItems().size() == 1)
addHandler(); addHandler();
} }
@@ -319,10 +326,10 @@ QVariant PartPolygon::itemChange(QGraphicsItem::GraphicsItemChange change, const
{ {
if(scene()) if(scene())
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartPolygon::sceneSelectionChanged); disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartPolygon::sceneSelectionChanged);
setSelected(false); //This is item removed from scene, then we deselect this, and so, the handlers is also removed. setSelected(false); //This is item removed from scene, then we deselect this, and so, the handlers is also removed.
} }
return QGraphicsItem::itemChange(change, value); return QGraphicsItem::itemChange(change, value);
} }
@@ -330,7 +337,7 @@ QVariant PartPolygon::itemChange(QGraphicsItem::GraphicsItemChange change, const
@brief PartPolygon::sceneEventFilter @brief PartPolygon::sceneEventFilter
@param watched @param watched
@param event @param event
@return @return
*/ */
bool PartPolygon::sceneEventFilter(QGraphicsItem *watched, QEvent *event) bool PartPolygon::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
{ {
@@ -338,7 +345,7 @@ bool PartPolygon::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
if(watched->type() == QetGraphicsHandlerItem::Type) if(watched->type() == QetGraphicsHandlerItem::Type)
{ {
QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched); QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched);
if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
{ {
m_vector_index = m_handler_vector.indexOf(qghi); m_vector_index = m_handler_vector.indexOf(qghi);
@@ -362,7 +369,7 @@ bool PartPolygon::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
} }
} }
} }
return false; return false;
} }
@@ -397,7 +404,7 @@ void PartPolygon::adjusteHandlerPos()
{ {
if(m_handler_vector.isEmpty()) if(m_handler_vector.isEmpty())
return; return;
if (m_handler_vector.size() == m_polygon.size()) if (m_handler_vector.size() == m_polygon.size())
{ {
QVector <QPointF> points_vector = mapToScene(m_polygon); QVector <QPointF> points_vector = mapToScene(m_polygon);
@@ -421,7 +428,7 @@ void PartPolygon::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphics
{ {
Q_UNUSED(qghi); Q_UNUSED(qghi);
Q_UNUSED(event); Q_UNUSED(event);
m_undo_command = new QPropertyUndoCommand(this, "polygon", QVariant(m_polygon)); m_undo_command = new QPropertyUndoCommand(this, "polygon", QVariant(m_polygon));
m_undo_command->setText(tr("Modifier un polygone")); m_undo_command->setText(tr("Modifier un polygone"));
} }
@@ -434,12 +441,12 @@ void PartPolygon::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphics
void PartPolygon::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event) void PartPolygon::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
{ {
Q_UNUSED(qghi); Q_UNUSED(qghi);
QPointF new_pos = event->scenePos(); QPointF new_pos = event->scenePos();
if (event->modifiers() != Qt::ControlModifier) if (event->modifiers() != Qt::ControlModifier)
new_pos = elementScene()->snapToGrid(event->scenePos()); new_pos = elementScene()->snapToGrid(event->scenePos());
new_pos = mapFromScene(new_pos); new_pos = mapFromScene(new_pos);
prepareGeometryChange(); prepareGeometryChange();
m_polygon.replace(m_vector_index, new_pos); m_polygon.replace(m_vector_index, new_pos);
adjusteHandlerPos(); adjusteHandlerPos();
@@ -455,7 +462,7 @@ void PartPolygon::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphi
{ {
Q_UNUSED(qghi); Q_UNUSED(qghi);
Q_UNUSED(event); Q_UNUSED(event);
m_undo_command->setNewValue(QVariant(m_polygon)); m_undo_command->setNewValue(QVariant(m_polygon));
elementScene()->undoStack().push(m_undo_command); elementScene()->undoStack().push(m_undo_command);
m_undo_command = nullptr; m_undo_command = nullptr;
@@ -481,9 +488,9 @@ void PartPolygon::sceneSelectionChanged()
void PartPolygon::addHandler() void PartPolygon::addHandler()
{ {
if (m_handler_vector.isEmpty() && scene()) if (m_handler_vector.isEmpty() && scene())
{ {
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(m_polygon)); m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(m_polygon));
for(QetGraphicsHandlerItem *handler : m_handler_vector) for(QetGraphicsHandlerItem *handler : m_handler_vector)
{ {
handler->setColor(Qt::blue); handler->setColor(Qt::blue);
@@ -514,7 +521,7 @@ void PartPolygon::removeHandler()
void PartPolygon::insertPoint() void PartPolygon::insertPoint()
{ {
QPolygonF new_polygon = QetGraphicsHandlerUtility::polygonForInsertPoint(m_polygon, m_closed, elementScene()->snapToGrid(m_context_menu_pos)); QPolygonF new_polygon = QetGraphicsHandlerUtility::polygonForInsertPoint(m_polygon, m_closed, elementScene()->snapToGrid(m_context_menu_pos));
if(new_polygon != m_polygon) if(new_polygon != m_polygon)
{ {
//Wrap the undo for avoid to merge the undo commands when user add several points. //Wrap the undo for avoid to merge the undo commands when user add several points.
@@ -532,7 +539,7 @@ void PartPolygon::removePoint()
{ {
if (m_handler_vector.size() == 2) if (m_handler_vector.size() == 2)
return; return;
QPointF point = mapToScene(m_context_menu_pos); QPointF point = mapToScene(m_context_menu_pos);
int index = -1; int index = -1;
for (int i=0 ; i<m_handler_vector.size() ; i++) for (int i=0 ; i<m_handler_vector.size() ; i++)
@@ -549,13 +556,13 @@ void PartPolygon::removePoint()
QPolygonF polygon = this->polygon(); QPolygonF polygon = this->polygon();
qDebug() << index; qDebug() << index;
polygon.removeAt(index); polygon.removeAt(index);
//Wrap the undo for avoid to merge the undo commands when user add several points. //Wrap the undo for avoid to merge the undo commands when user add several points.
QUndoCommand *undo = new QUndoCommand(tr("Supprimer un point d'un polygone")); QUndoCommand *undo = new QUndoCommand(tr("Supprimer un point d'un polygone"));
new QPropertyUndoCommand(this, "polygon", this->polygon(), polygon, undo); new QPropertyUndoCommand(this, "polygon", this->polygon(), polygon, undo);
elementScene()->undoStack().push(undo); elementScene()->undoStack().push(undo);
} }
} }
/** /**

View File

@@ -1,17 +1,17 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -51,17 +51,23 @@ void PartRectangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
Q_UNUSED(widget); Q_UNUSED(widget);
applyStylesToQPainter(*painter); applyStylesToQPainter(*painter);
QPen t = painter -> pen(); QPen t = painter -> pen();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
t.setCosmetic(options && options -> levelOfDetail < 1.0); t.setCosmetic(options && options -> levelOfDetail < 1.0);
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
#endif
if (isSelected()) if (isSelected())
t.setColor(Qt::red); t.setColor(Qt::red);
t.setJoinStyle(Qt::MiterJoin); t.setJoinStyle(Qt::MiterJoin);
//Force the pen to width 0 if one of dimension is null //Force the pen to width 0 if one of dimension is null
if (!rect().width() || !rect().height()) if (!rect().width() || !rect().height())
t.setWidth(0); t.setWidth(0);
painter->setPen(t); painter->setPen(t);
painter->drawRoundedRect(m_rect, m_xRadius, m_yRadius); painter->drawRoundedRect(m_rect, m_xRadius, m_yRadius);
@@ -86,7 +92,7 @@ const QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
xml_element.setAttribute("y", QString("%1").arg(top_left.y())); xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
xml_element.setAttribute("width", QString("%1").arg(m_rect.width())); xml_element.setAttribute("width", QString("%1").arg(m_rect.width()));
xml_element.setAttribute("height", QString("%1").arg(m_rect.height())); xml_element.setAttribute("height", QString("%1").arg(m_rect.height()));
QRectF rect = m_rect.normalized(); QRectF rect = m_rect.normalized();
qreal x = m_xRadius; qreal x = m_xRadius;
if (x > rect.width()/2) { if (x > rect.width()/2) {
@@ -96,10 +102,10 @@ const QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
if (y > rect.height()/2) { if (y > rect.height()/2) {
y = rect.height()/2; y = rect.height()/2;
} }
xml_element.setAttribute("rx", QString::number(m_xRadius)); xml_element.setAttribute("rx", QString::number(m_xRadius));
xml_element.setAttribute("ry", QString::number(m_yRadius)); xml_element.setAttribute("ry", QString::number(m_yRadius));
stylesToXml(xml_element); stylesToXml(xml_element);
return(xml_element); return(xml_element);
} }
@@ -272,7 +278,7 @@ void PartRectangle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton && event->buttonDownPos(Qt::LeftButton) == event->pos()) if (event->button() == Qt::LeftButton && event->buttonDownPos(Qt::LeftButton) == event->pos())
switchResizeMode(); switchResizeMode();
CustomElementGraphicPart::mouseReleaseEvent(event); CustomElementGraphicPart::mouseReleaseEvent(event);
} }
@@ -280,7 +286,7 @@ void PartRectangle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
@brief PartRectangle::itemChange @brief PartRectangle::itemChange
@param change @param change
@param value @param value
@return @return
*/ */
QVariant PartRectangle::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) QVariant PartRectangle::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{ {
@@ -290,8 +296,8 @@ QVariant PartRectangle::itemChange(QGraphicsItem::GraphicsItemChange change, con
{ {
//When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler, //When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler,
//according to the number of selected items. //according to the number of selected items.
connect(scene(), &QGraphicsScene::selectionChanged, this, &PartRectangle::sceneSelectionChanged); connect(scene(), &QGraphicsScene::selectionChanged, this, &PartRectangle::sceneSelectionChanged);
if (scene()->selectedItems().size() == 1) if (scene()->selectedItems().size() == 1)
addHandler(); addHandler();
} }
@@ -309,10 +315,10 @@ QVariant PartRectangle::itemChange(QGraphicsItem::GraphicsItemChange change, con
{ {
if(scene()) if(scene())
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartRectangle::sceneSelectionChanged); disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartRectangle::sceneSelectionChanged);
setSelected(false); //This item is removed from scene, then we deselect this, and so, the handlers is also removed. setSelected(false); //This item is removed from scene, then we deselect this, and so, the handlers is also removed.
} }
return QGraphicsItem::itemChange(change, value); return QGraphicsItem::itemChange(change, value);
} }
@@ -320,7 +326,7 @@ QVariant PartRectangle::itemChange(QGraphicsItem::GraphicsItemChange change, con
@brief PartRectangle::sceneEventFilter @brief PartRectangle::sceneEventFilter
@param watched @param watched
@param event @param event
@return @return
*/ */
bool PartRectangle::sceneEventFilter(QGraphicsItem *watched, QEvent *event) bool PartRectangle::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
{ {
@@ -328,7 +334,7 @@ bool PartRectangle::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
if(watched->type() == QetGraphicsHandlerItem::Type) if(watched->type() == QetGraphicsHandlerItem::Type)
{ {
QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched); QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched);
if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
{ {
m_vector_index = m_handler_vector.indexOf(qghi); m_vector_index = m_handler_vector.indexOf(qghi);
@@ -352,7 +358,7 @@ bool PartRectangle::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
} }
} }
} }
return false; return false;
} }
@@ -397,16 +403,16 @@ void PartRectangle::adjusteHandlerPos()
if (m_handler_vector.isEmpty()) { if (m_handler_vector.isEmpty()) {
return; return;
} }
QVector <QPointF> points_vector; QVector <QPointF> points_vector;
if(m_resize_mode != 3) { if(m_resize_mode != 3) {
points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect); points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect);
} }
else { else {
points_vector = QetGraphicsHandlerUtility::pointForRadiusRect(m_rect, m_xRadius, m_yRadius); points_vector = QetGraphicsHandlerUtility::pointForRadiusRect(m_rect, m_xRadius, m_yRadius);
} }
if (m_handler_vector.size() == points_vector.size()) if (m_handler_vector.size() == points_vector.size())
{ {
points_vector = mapToScene(points_vector); points_vector = mapToScene(points_vector);
@@ -430,7 +436,7 @@ void PartRectangle::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphi
{ {
Q_UNUSED(qghi) Q_UNUSED(qghi)
Q_UNUSED(event) Q_UNUSED(event)
m_old_rect = m_rect; m_old_rect = m_rect;
m_old_xRadius = m_xRadius; m_old_xRadius = m_xRadius;
m_old_yRadius = m_yRadius; m_old_yRadius = m_yRadius;
@@ -447,12 +453,12 @@ void PartRectangle::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphi
void PartRectangle::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event) void PartRectangle::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
{ {
Q_UNUSED(qghi) Q_UNUSED(qghi)
QPointF new_pos = event->scenePos(); QPointF new_pos = event->scenePos();
if (event->modifiers() != Qt::ControlModifier) if (event->modifiers() != Qt::ControlModifier)
new_pos = elementScene()->snapToGrid(event->scenePos()); new_pos = elementScene()->snapToGrid(event->scenePos());
new_pos = mapFromScene(new_pos); new_pos = mapFromScene(new_pos);
if (m_resize_mode == 1) if (m_resize_mode == 1)
setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index)); setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index));
else if (m_resize_mode == 2) else if (m_resize_mode == 2)
@@ -471,7 +477,7 @@ void PartRectangle::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphic
setYRadius(radius); setYRadius(radius);
} }
} }
adjusteHandlerPos(); adjusteHandlerPos();
} }
@@ -479,9 +485,9 @@ void PartRectangle::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGrap
{ {
Q_UNUSED(qghi) Q_UNUSED(qghi)
Q_UNUSED(event) Q_UNUSED(event)
m_modifie_radius_equaly = false; m_modifie_radius_equaly = false;
QUndoCommand *undo = new QUndoCommand("Modifier un rectangle"); QUndoCommand *undo = new QUndoCommand("Modifier un rectangle");
if (m_old_rect != m_rect) { if (m_old_rect != m_rect) {
QPropertyUndoCommand *u = new QPropertyUndoCommand(this, "rect", QVariant(m_old_rect.normalized()), QVariant(m_rect.normalized()), undo); QPropertyUndoCommand *u = new QPropertyUndoCommand(this, "rect", QVariant(m_old_rect.normalized()), QVariant(m_rect.normalized()), undo);
@@ -495,7 +501,7 @@ void PartRectangle::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGrap
QPropertyUndoCommand *u = new QPropertyUndoCommand(this, "yRadius", QVariant(m_old_yRadius), QVariant(m_yRadius), undo); QPropertyUndoCommand *u = new QPropertyUndoCommand(this, "yRadius", QVariant(m_old_yRadius), QVariant(m_yRadius), undo);
u->setAnimated(); u->setAnimated();
} }
elementScene()->undoStack().push(undo); elementScene()->undoStack().push(undo);
m_vector_index = -1; m_vector_index = -1;
} }
@@ -519,21 +525,21 @@ void PartRectangle::sceneSelectionChanged()
void PartRectangle::addHandler() void PartRectangle::addHandler()
{ {
if (m_handler_vector.isEmpty() && scene()) if (m_handler_vector.isEmpty() && scene())
{ {
if (m_resize_mode != 3) { if (m_resize_mode != 3) {
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect))); m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
} }
else { else {
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointForRadiusRect(m_rect, m_xRadius, m_yRadius))); m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointForRadiusRect(m_rect, m_xRadius, m_yRadius)));
} }
for (QetGraphicsHandlerItem *handler : m_handler_vector) for (QetGraphicsHandlerItem *handler : m_handler_vector)
{ {
QColor color; QColor color;
if(m_resize_mode == 1) {color = Qt::blue;} if(m_resize_mode == 1) {color = Qt::blue;}
else if (m_resize_mode == 2) {color = Qt::darkGreen;} else if (m_resize_mode == 2) {color = Qt::darkGreen;}
else {color = Qt::magenta;} else {color = Qt::magenta;}
handler->setColor(color); handler->setColor(color);
scene()->addItem(handler); scene()->addItem(handler);
handler->installSceneEventFilter(this); handler->installSceneEventFilter(this);

View File

@@ -1,17 +1,17 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -62,37 +62,52 @@ const QDomElement PartTerminal::toXml(QDomDocument &xml_document) const
/** /**
Dessine la borne Dessine la borne
@param p QPainter a utiliser pour rendre le dessin @param painter QPainter a utiliser pour rendre le dessin
@param options Options pour affiner le rendu @param options Options pour affiner le rendu
@param widget Widget sur lequel le rendu est effectue @param widget Widget sur lequel le rendu est effectue
*/ */
void PartTerminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, QWidget *widget) { void PartTerminal::paint(
QPainter *painter,
const QStyleOptionGraphicsItem *options,
QWidget *widget)
{
Q_UNUSED(widget); Q_UNUSED(widget);
p -> save(); painter -> save();
// annulation des renderhints // annulation des renderhints
p -> setRenderHint(QPainter::Antialiasing, false); painter -> setRenderHint(QPainter::Antialiasing, false);
p -> setRenderHint(QPainter::TextAntialiasing, false); painter -> setRenderHint(QPainter::TextAntialiasing, false);
p -> setRenderHint(QPainter::SmoothPixmapTransform, false); painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
QPen t; QPen t;
t.setWidthF(1.0); t.setWidthF(1.0);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
t.setCosmetic(options && options -> levelOfDetail < 1.0); t.setCosmetic(options && options -> levelOfDetail < 1.0);
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
t.setCosmetic(
options
&& options->levelOfDetailFromTransform(
painter->worldTransform())
< 1.0);
#endif
// dessin de la borne en rouge // dessin de la borne en rouge
t.setColor(isSelected() ? Terminal::neutralColor : Qt::red); t.setColor(isSelected() ? Terminal::neutralColor : Qt::red);
p -> setPen(t); painter -> setPen(t);
p -> drawLine(QPointF(0.0, 0.0), d -> second_point); painter -> drawLine(QPointF(0.0, 0.0), d -> second_point);
// dessin du point d'amarrage au conducteur en bleu // dessin du point d'amarrage au conducteur en bleu
t.setColor(isSelected() ? Qt::red : Terminal::neutralColor); t.setColor(isSelected() ? Qt::red : Terminal::neutralColor);
p -> setPen(t); painter -> setPen(t);
p -> setBrush(Terminal::neutralColor); painter -> setBrush(Terminal::neutralColor);
p -> drawPoint(QPointF(0.0, 0.0)); painter -> drawPoint(QPointF(0.0, 0.0));
p -> restore(); painter -> restore();
if (m_hovered) if (m_hovered)
drawShadowShape(p); drawShadowShape(painter);
} }
/** /**

View File

@@ -1,17 +1,17 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -55,7 +55,10 @@ class PartTerminal : public CustomElementGraphicPart {
QString xmlName() const override { return(QString("terminal")); } QString xmlName() const override { return(QString("terminal")); }
void fromXml(const QDomElement &) override; void fromXml(const QDomElement &) override;
const QDomElement toXml(QDomDocument &) const override; const QDomElement toXml(QDomDocument &) const override;
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override; void paint(
QPainter *painter,
const QStyleOptionGraphicsItem *,
QWidget *) override;
QPainterPath shape() const override; QPainterPath shape() const override;
QPainterPath shadowShape() const override {return shape();} QPainterPath shadowShape() const override {return shape();}
@@ -70,7 +73,7 @@ class PartTerminal : public CustomElementGraphicPart {
void setName(QString& name); void setName(QString& name);
void setNewUuid(); void setNewUuid();
private: private:
void updateSecondPoint(); void updateSecondPoint();
TerminalData* d; // pointer to the terminal data TerminalData* d; // pointer to the terminal data

View File

@@ -262,23 +262,30 @@ void Terminal::removeConductor(Conductor *conductor)
/** /**
@brief Terminal::paint @brief Terminal::paint
Fonction de dessin des bornes Fonction de dessin des bornes
@param p Le QPainter a utiliser @param painter Le QPainter a utiliser
@param options Les options de dessin @param options Les options de dessin
*/ */
void Terminal::paint( void Terminal::paint(
QPainter *p, QPainter *painter,
const QStyleOptionGraphicsItem *options, const QStyleOptionGraphicsItem *options,
QWidget *) QWidget *)
{ {
// en dessous d'un certain zoom, les bornes ne sont plus dessinees // en dessous d'un certain zoom, les bornes ne sont plus dessinees
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
if (options && options -> levelOfDetail < 0.5) return; if (options && options -> levelOfDetail < 0.5) return;
#else
p -> save(); #if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
if (options && options->levelOfDetailFromTransform(painter->worldTransform()) < 0.5)
return;
#endif
painter -> save();
//annulation des renderhints //annulation des renderhints
p -> setRenderHint(QPainter::Antialiasing, false); painter -> setRenderHint(QPainter::Antialiasing, false);
p -> setRenderHint(QPainter::TextAntialiasing, false); painter -> setRenderHint(QPainter::TextAntialiasing, false);
p -> setRenderHint(QPainter::SmoothPixmapTransform, false); painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
// on travaille avec les coordonnees de l'element parent // on travaille avec les coordonnees de l'element parent
QPointF c = mapFromParent(d->m_pos); QPointF c = mapFromParent(d->m_pos);
@@ -287,23 +294,31 @@ void Terminal::paint(
QPen t; QPen t;
t.setWidthF(1.0); t.setWidthF(1.0);
if (options && options -> levelOfDetail < 1.0) { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
if (options && options -> levelOfDetail < 1.0)
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
if (options && options->levelOfDetailFromTransform(painter->worldTransform()) < 1.0)
#endif
{
t.setCosmetic(true); t.setCosmetic(true);
} }
// dessin de la borne en rouge // dessin de la borne en rouge
t.setColor(Qt::red); t.setColor(Qt::red);
p -> setPen(t); painter -> setPen(t);
p -> drawLine(c, e); painter -> drawLine(c, e);
// dessin du point d'amarrage au conducteur en bleu // dessin du point d'amarrage au conducteur en bleu
t.setColor(hovered_color_); t.setColor(hovered_color_);
p -> setPen(t); painter -> setPen(t);
p -> setBrush(hovered_color_); painter -> setBrush(hovered_color_);
if (hovered_) { if (hovered_) {
p -> setRenderHint(QPainter::Antialiasing, true); painter -> setRenderHint(QPainter::Antialiasing, true);
p -> drawEllipse(QRectF(c.x() - 2.5, c.y() - 2.5, 5.0, 5.0)); painter -> drawEllipse(QRectF(c.x() - 2.5, c.y() - 2.5, 5.0, 5.0));
} else p -> drawPoint(c); } else painter -> drawPoint(c);
//Draw help line if needed, //Draw help line if needed,
if (diagram() && m_draw_help_line) if (diagram() && m_draw_help_line)
@@ -365,7 +380,7 @@ void Terminal::paint(
m_help_line_a -> setLine(line); m_help_line_a -> setLine(line);
} }
p -> restore(); painter -> restore();
} }
/** /**

View File

@@ -1,17 +1,17 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -38,7 +38,7 @@ class Terminal : public QGraphicsObject
signals: signals:
void conductorWasAdded(Conductor *conductor); void conductorWasAdded(Conductor *conductor);
void conductorWasRemoved(Conductor *conductor); void conductorWasRemoved(Conductor *conductor);
// constructors, destructor // constructors, destructor
public: public:
Terminal(QPointF, Qet::Orientation, Element * = nullptr); Terminal(QPointF, Qet::Orientation, Element * = nullptr);
@@ -47,10 +47,10 @@ class Terminal : public QGraphicsObject
Terminal(QPointF, Qet::Orientation, QString number, Terminal(QPointF, Qet::Orientation, QString number,
QString name, bool hiddenName, Element * = nullptr); QString name, bool hiddenName, Element * = nullptr);
~Terminal() override; ~Terminal() override;
private: private:
Terminal(const Terminal &); Terminal(const Terminal &);
// methods // methods
public: public:
/** /**
@@ -60,13 +60,15 @@ class Terminal : public QGraphicsObject
@return the QGraphicsItem type @return the QGraphicsItem type
*/ */
int type() const override { return Type; } int type() const override { return Type; }
void paint (QPainter *,const QStyleOptionGraphicsItem *, void paint(
QWidget *) override; QPainter *painter,
const QStyleOptionGraphicsItem *,
QWidget *) override;
void drawHelpLine (bool draw = true); void drawHelpLine (bool draw = true);
QLineF HelpLine () const; QLineF HelpLine () const;
QRectF boundingRect () const override; QRectF boundingRect () const override;
// methods to manage conductors attached to the terminal // methods to manage conductors attached to the terminal
Terminal* alignedWithTerminal () const; Terminal* alignedWithTerminal () const;
bool addConductor (Conductor *conductor); bool addConductor (Conductor *conductor);
@@ -75,7 +77,7 @@ class Terminal : public QGraphicsObject
Diagram *diagram () const; Diagram *diagram () const;
Element *parentElement () const; Element *parentElement () const;
QUuid uuid () const; QUuid uuid () const;
QList<Conductor *> conductors() const; QList<Conductor *> conductors() const;
Qet::Orientation orientation() const; Qet::Orientation orientation() const;
QPointF dockConductor() const; QPointF dockConductor() const;
@@ -86,12 +88,12 @@ class Terminal : public QGraphicsObject
void updateConductor(); void updateConductor();
bool isLinkedTo(Terminal *); bool isLinkedTo(Terminal *);
bool canBeLinkedTo(Terminal *); bool canBeLinkedTo(Terminal *);
// methods related to XML import/export // methods related to XML import/export
static bool valideXml(QDomElement &); static bool valideXml(QDomElement &);
bool fromXml (QDomElement &); bool fromXml (QDomElement &);
QDomElement toXml (QDomDocument &) const; QDomElement toXml (QDomDocument &) const;
protected: protected:
// methods related to events management // methods related to events management
void hoverEnterEvent (QGraphicsSceneHoverEvent *) override; void hoverEnterEvent (QGraphicsSceneHoverEvent *) override;
@@ -100,7 +102,7 @@ class Terminal : public QGraphicsObject
void mousePressEvent (QGraphicsSceneMouseEvent *) override; void mousePressEvent (QGraphicsSceneMouseEvent *) override;
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override; void mouseMoveEvent (QGraphicsSceneMouseEvent *) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
// attributes // attributes
public: public:
enum { Type = UserType + 1002 }; enum { Type = UserType + 1002 };
@@ -116,7 +118,7 @@ class Terminal : public QGraphicsObject
static QColor warningColor; static QColor warningColor;
/// color for forbidden actions /// color for forbidden actions
static QColor forbiddenColor; static QColor forbiddenColor;
private: private:
bool m_draw_help_line{false}; bool m_draw_help_line{false};
QGraphicsLineItem *m_help_line{nullptr}; QGraphicsLineItem *m_help_line{nullptr};
@@ -127,10 +129,10 @@ class Terminal : public QGraphicsObject
/// Parent electrical element /// Parent electrical element
Element *parent_element_{nullptr}; Element *parent_element_{nullptr};
public: public:
/// docking point for parent element /// docking point for parent element
QPointF dock_elmt_; QPointF dock_elmt_;
private: private:
/// List of conductors attached to the terminal /// List of conductors attached to the terminal
QList<Conductor *> conductors_; QList<Conductor *> conductors_;
/** /**
@@ -150,7 +152,7 @@ class Terminal : public QGraphicsObject
/// Name of Terminal /// Name of Terminal
QString name_terminal_; QString name_terminal_;
bool name_terminal_hidden; bool name_terminal_hidden;
private: private:
void init(QString number, QString name, bool hiddenName); void init(QString number, QString name, bool hiddenName);
void init(QPointF pf, Qet::Orientation o, QString number, void init(QPointF pf, Qet::Orientation o, QString number,
@@ -185,6 +187,6 @@ inline QString Terminal::name() const
} }
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal, QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
const bool all_diagram = true); const bool all_diagram = true);
#endif #endif