38 QGraphicsObject(elmt),
48 QGraphicsObject(text),
59 QGraphicsObject(group),
78 qDebug() <<
"CrossRefItem constructor" <<
"element is not in a diagram";
86 setAcceptHoverEvents(
true);
193 prepareGeometryChange();
242 switch (event->type())
244 case QEvent::GraphicsSceneHoverEnter:
247 case QEvent::GraphicsSceneHoverMove:
250 case QEvent::GraphicsSceneHoverLeave:
253 case QEvent::GraphicsSceneMouseDoubleClick:
261 return QGraphicsObject::sceneEvent(event);
297 fit.adjust(-200, -200, 200, 200);
298 view->fitInView(fit, Qt::KeepAspectRatioByExpanding);
306 QGraphicsObject::hoverEnterEvent(event);
311 QPointF pos =
event->pos();
318 if (rect.contains(pos))
320 QGraphicsObject::hoverMoveEvent(event);
333 if (rect.contains(pos))
341 QGraphicsObject::hoverMoveEvent(event);
351 if (rect.contains(pos))
355 QGraphicsObject::hoverMoveEvent(event);
367 QGraphicsObject::hoverLeaveEvent(event);
405 qp.drawLine(0, 3, 5, 3);
411 qp.drawPolyline(p1,3);
424 qp.drawPolyline(p2,3);
430 qp.drawPolyline(p3,3);
446 QStringList no_str, nc_str;
455 if (no_str.isEmpty() && nc_str.isEmpty())
return;
462 foreach(QString str, no_str)
464 QRectF bounding = painter.boundingRect(QRectF (), Qt::AlignCenter, str);
465 no_bounding = no_bounding.united(bounding);
468 if (no_bounding.height() > default_bounding.height() -
header)
469 default_bounding.setHeight(no_bounding.height() +
header);
470 if (no_bounding.width() > default_bounding.width()/2)
471 default_bounding.setWidth(no_bounding.width()*2);
475 foreach(QString str, nc_str)
477 QRectF bounding = painter.boundingRect(QRectF (), Qt::AlignCenter, str);
478 nc_bounding = nc_bounding.united(bounding);
481 if (nc_bounding.height() > default_bounding.height() -
header)
482 default_bounding.setHeight(nc_bounding.height() +
header);
483 if (nc_bounding.width() > default_bounding.width()/2)
484 default_bounding.setWidth(nc_bounding.width()*2);
487 default_bounding.adjust(0, 0, 4, 0);
489 prepareGeometryChange();
509 painter.drawLine(
br.width()/2, 0,
br.width()/2,
br.height());
535 QRectF bounding_rect;
542 for (
int i=0; i<info[
"number"].toInt(); i++)
546 QString state = info[
"state"].toString();
547 if (state ==
"NO") option =
NO;
548 else if (state ==
"NC") option =
NC;
549 else if (state ==
"SW") option =
SW;
551 QString
type = info[
"type"].toString();
558 bounding_rect = bounding_rect.united(
br);
562 bounding_rect.adjust(-4, -4, 4, 4);
563 prepareGeometryChange();
580 QRectF bounding_rect;
582 QPen pen = painter.pen();
589 bounding_rect = QRectF(0, offset, 24, 10);
592 painter.drawLine(0, offset+6, 8, offset+6);
593 painter.drawLine(16, offset+6, 24, offset+6);
607 painter.drawLine(8, offset+9, 16, offset+6);
612 QPointF(8, offset+6),
613 QPointF(9, offset+6),
614 QPointF(9, offset+2.5)
616 painter.drawPolyline(p1,3);
617 painter.drawLine(8, offset+3, 16, offset+6);
622 QRectF arc(4, offset+4, 4, 4);
624 painter.drawArc(arc, 180*16, 180*16);
626 painter.drawArc(arc, 0, 180*16);
634 painter.drawLine(12, offset+8, 12, offset+11);
635 QRectF r(9.5, offset+9, 5, 3);
636 painter.drawArc(r, 180*16, 180*16);
639 painter.drawLine(QPointF(12.5, offset+5), QPointF(12.5, offset+8));
640 QRectF r(10, offset+6, 5, 3);
641 painter.drawArc(r, 180*16, 180*16);
647 painter.drawLine(12, offset+8, 12, offset+9.5);
648 QRectF r(9.5, offset+9.5, 5, 3);
649 painter.drawArc(r, 0, 180*16);
652 painter.drawLine(QPointF(12.5, offset+5), QPointF(12.5, offset+7));
653 QRectF r(10, offset+7.5, 5, 3);
654 painter.drawArc(r, 0, 180*16);
661 painter.drawLine(12, offset+8, 12, offset+11);
662 QRectF r(9.5, offset+11.7, 5, 3);
663 painter.drawArc(r, 0, 180*16);
664 QRectF rl(9.5, offset+9, 5, 3);
665 painter.drawArc(rl, 180*16, 180*16);
668 painter.drawLine(QPointF(12.5, offset+5), QPointF(12.5, offset+8));
669 QRectF r(9.5, offset+10.7, 5, 3);
670 painter.drawArc(r, 0, 180*16);
671 QRectF rl(9.5, offset+8, 5, 3);
672 painter.drawArc(rl, 180*16, 180*16);
677 QRectF text_rect = painter.boundingRect(QRectF(30, offset, 5, 10), Qt::AlignLeft | Qt::AlignVCenter, str);
678 painter.drawText(text_rect, Qt::AlignLeft | Qt::AlignVCenter, str);
679 bounding_rect = bounding_rect.united(text_rect);
696 bounding_rect = QRectF(0, offset, 24, 20);
699 painter.drawLine(0, offset+6, 8, offset+6);
702 QPointF(0, offset+16),
703 QPointF(8, offset+16),
704 QPointF(8, offset+12)
706 painter.drawPolyline(p1, 3);
710 QPointF(7, offset+14),
711 QPointF(16, offset+11),
712 QPointF(24, offset+11),
714 painter.drawPolyline(p2, 3);
719 painter.drawLine(12, offset+13, 12, offset+16);
721 QRectF r(9.5, offset+14, 5, 3);
722 painter.drawArc(r, 180*16, 180*16);
725 QRectF r(9.5, offset+16.5, 5, 3);
726 painter.drawArc(r, 0, 180*16);
729 QRectF r(9.5, offset+14, 5, 3);
730 painter.drawArc(r, 180*16, 180*16);
731 QRectF rr(9.5, offset+17, 5, 3);
732 painter.drawArc(rr, 0, 180*16);
737 QRectF text_rect = painter.boundingRect(QRectF(30, offset+5, 5, 10), Qt::AlignLeft | Qt::AlignVCenter, str);
738 painter.drawText(text_rect, Qt::AlignLeft | Qt::AlignVCenter, str);
739 bounding_rect = bounding_rect.united(text_rect);
752 return bounding_rect;
767 QPointF no_top_left(0,
header);
770 QPen pen = painter.pen();
775 QRectF bounding = painter.boundingRect(QRectF(no_top_left, QSize(middle_cross, 1)), Qt::AlignLeft, str);
776 painter.drawText(bounding, Qt::AlignLeft, str);
787 no_top_left.ry() += bounding.height();
791 QPointF nc_top_left(middle_cross,
header);
794 QPen pen = painter.pen();
799 QRectF bounding = painter.boundingRect(QRectF(nc_top_left, QSize(middle_cross, 1)), Qt::AlignRight, str);
800 painter.drawText(bounding, Qt::AlignRight, str);
811 nc_top_left.ry() += bounding.height();
824 bool must_show =
m_element -> elementInformations().keyMustShow(
type);
826 if (!text.isEmpty() && must_show)
831 QRectF r, text_bounding;
835 r = QRectF(QPointF(center - width,
boundingRect().bottom()),
838 text_bounding = painter.boundingRect(r, Qt::TextWordWrap | Qt::AlignHCenter, text);
839 painter.drawText(text_bounding, Qt::TextWordWrap | Qt::AlignHCenter, text);
841 text_bounding.adjust(-1,0,1,0);
844 prepareGeometryChange();
846 if (
type ==
"comment") painter.drawRoundedRect(text_bounding, 2, 2);
859 QList<Element *> no_list;
867 elmt -> kindInformations()[
"type"].toString() ==
"power")
872 if (state ==
"NO" || state ==
"SW")
874 no_list.append(elmt);
889 QList<Element *> nc_list;
897 elmt -> kindInformations()[
"type"].toString() ==
"power")
902 if (state ==
"NC" || state ==
"SW")
904 nc_list.append(elmt);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
CrossRefItem::paint Paint this item.
QList< Element * > linkedElements()
Element::linkedElements.
static QString formulaToLabel(QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt=nullptr)
AssignVariables::formulaToLabel Return the with variable assigned (ready to be displayed) ...
The DynamicElementTextItem class This class provide a simple text field of element who can be added o...
ElementTextItemGroup * m_group
QString prefix(const QString &key) const
The XRefProperties class this class store properties used by XrefItem.
DisplayHas displayHas() const
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
CrossRefItem::mouseDoubleClickEvent.
CrossRefItem(Element *elmt)
CrossRefItem::CrossRefItem.
Diagram * diagram() const
QetGraphicsItem::diagram return the diagram of this item.
autonum::sequentialNumbers & rSequenceStruct()
void updateLabel()
CrossRefItem::updateLabel Update the content of the item.
QList< QMetaObject::Connection > m_slave_connection
QRectF drawContact(QPainter &painter, int flags, Element *elmt)
CrossRefItem::drawContact Draw one contact, the type of contact to draw is define in ...
void fillCrossRef(QPainter &painter)
CrossRefItem::fillCrossRef Fill the content of the cross ref.
QPainterPath shape() const override
CrossRefItem::shape.
void linkedElementChanged()
bool showPowerContact() const
Element * m_hovered_contact
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
bool centerToBottomDiagram(QGraphicsItem *item_to_center, Element *element_to_follow, qreal offset)
centerToBottomDiagram Set item pos to the bottom of diagram and centered vertically to element_to_fol...
void buildHeaderContact()
CrossRefItem::buildHeaderContact Draw the QPicture of m_hdr_no_ctc and m_hdr_nc_ctc.
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override
bool centerToParentBottom(QGraphicsItem *item)
centerToParentBottom Center the item at the bottom of is parent.
bool contains(const QString &) const
void setUpCrossBoundingRect(QPainter &painter)
CrossRefItem::setUpCrossBoundingRect Get the numbers of slaves elements linked to this parent element...
QPainterPath m_shape_path
QList< QMetaObject::Connection > m_update_connection
static int cross_min_heigth
bool sceneEvent(QEvent *event) override
QString masterLabel() const
void AddExtraInfo(QPainter &painter, const QString &)
CrossRefItem::AddExtraInfo Add the comment info of the parent item if needed.
void updateProperties()
CrossRefItem::updateProperties update the curent properties.
int type() const override
QRectF boundingRect() const override
CrossRefItem::boundingRect.
The ElementTextItemGroup class This class represent a group of element text Texts in the group can be...
QString elementPositionText(const Element *elmt, const bool &add_prefix=false) const
CrossRefItem::elementPositionText.
~CrossRefItem() override
CrossRefItem::~CrossRefItem Default destructor.
QMap< Element *, QRectF > m_hovered_contacts_map
void projectDiagramsOrderChanged(QETProject *, int, int)
void init()
CrossRefItem::init init this Xref.
XRefProperties m_properties
void drawAsContacts(QPainter &painter)
CrossRefItem::drawAsContacts Draw this crossref with symbolic contacts.
static QFont diagramTextsFont(qreal=-1.0)
QETApp::diagramTextsFont The font to use By default the font is "sans Serif" and size 9...
DynamicElementTextItem * m_text
XRefProperties defaultXRefProperties(const QString &type) const
DiagramContext kindInformations() const
void setUpConnection()
CrossRefItem::setUpConnection Set up several connection to keep up to date the Xref.
QList< Element * > NOElements() const
CrossRefItem::NOElements.
void XRefPropertiesChanged()
QETProject * project() const
QList< Element * > NCElements() const
CrossRefItem::NCElements.
void autoPos()
CrossRefItem::autoPos Calculate and set position automaticaly.
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override
void drawAsCross(QPainter &painter)
CrossRefItem::drawAsCross Draw this crossref with a cross.
void diagramRemoved(QETProject *, Diagram *)