QElectroTech  0.8-dev
crossrefitem.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef CROSSREFITEM_H
19 #define CROSSREFITEM_H
20 
21 #include <QGraphicsObject>
22 #include <QPicture>
23 #include <QMultiMap>
24 
26 
27 class Element;
30 
46 class CrossRefItem : public QGraphicsObject
47 {
48  Q_OBJECT
49 
50  //Methods
51  public:
52  explicit CrossRefItem(Element *elmt);
53  explicit CrossRefItem(Element *elmt,
55  explicit CrossRefItem(Element *elmt,
56  ElementTextItemGroup *group);
57  ~CrossRefItem() override;
58  private:
59  void init();
60  void setUpConnection();
61 
62  public:
63  enum { Type = UserType + 1009 };
64  int type() const override { return Type; }
65 
69  enum CONTACTS {
70  NO = 1,
71  NC = 2,
72  NOC = 3,
73  SW = 4,
74  Power = 8,
75  DelayOn = 16,
76  DelayOff = 32,
77  DelayOnOff = 64,
78  Delay = 112
79  };
80 
81  QRectF boundingRect() const override;
82  QPainterPath shape() const override;
83  QString elementPositionText(
84  const Element *elmt,
85  const bool &add_prefix = false) const;
86 
87  public slots:
88  void updateProperties();
89  void updateLabel();
90  void autoPos();
91 
92  protected:
93  bool sceneEvent(QEvent *event) override;
94  void paint(QPainter *painter,
95  const QStyleOptionGraphicsItem *option,
96  QWidget *widget) override;
98  QGraphicsSceneMouseEvent * event ) override;
99  void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
100  void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
101  void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
102 
103  private:
104  void linkedChanged();
105  void buildHeaderContact();
106  void setUpCrossBoundingRect(QPainter &painter);
107  void drawAsCross(QPainter &painter);
108  void drawAsContacts(QPainter &painter);
109  QRectF drawContact(QPainter &painter, int flags, Element *elmt);
110  void fillCrossRef(QPainter &painter);
111  void AddExtraInfo(QPainter &painter, const QString&);
112  QList<Element *> NOElements() const;
113  QList<Element *> NCElements() const;
114 
115  //Attributes
116  private:
117  Element *m_element; //element to display the cross reference
120  QPainterPath m_shape_path;
123  QMultiMap <Element *, QRectF> m_hovered_contacts_map;
127  QList <QMetaObject::Connection> m_slave_connection;
128  QList <QMetaObject::Connection> m_update_connection;
129 };
130 
131 #endif // CROSSREFITEM_H
132 
CrossRefItem::NOElements
QList< Element * > NOElements() const
CrossRefItem::NOElements.
Definition: crossrefitem.cpp:935
CrossRefItem::drawAsContacts
void drawAsContacts(QPainter &painter)
CrossRefItem::drawAsContacts Draw this crossref with symbolic contacts.
Definition: crossrefitem.cpp:575
CrossRefItem::init
void init()
CrossRefItem::init init this Xref.
Definition: crossrefitem.cpp:74
CrossRefItem::type
int type() const override
Definition: crossrefitem.h:64
DynamicElementTextItem
The DynamicElementTextItem class This class provide a simple text field of element who can be added o...
Definition: dynamicelementtextitem.h:39
autonum::sequentialNumbers
Definition: assignvariables.h:35
CrossRefItem::autoPos
void autoPos()
CrossRefItem::autoPos Calculate and set position automaticaly.
Definition: crossrefitem.cpp:235
QETProject::projectDiagramsOrderChanged
void projectDiagramsOrderChanged(QETProject *, int, int)
Element::linkedElements
QList< Element * > linkedElements()
Element::linkedElements.
Definition: element.h:258
Element::elementInformations
DiagramContext elementInformations() const
Definition: element.h:97
QetGraphicsItem::diagram
Diagram * diagram() const
Definition: qetgraphicsitem.cpp:40
CrossRefItem::AddExtraInfo
void AddExtraInfo(QPainter &painter, const QString &)
CrossRefItem::AddExtraInfo Add the comment info of the parent item if needed.
Definition: crossrefitem.cpp:882
CrossRefItem::setUpCrossBoundingRect
void setUpCrossBoundingRect(QPainter &painter)
CrossRefItem::setUpCrossBoundingRect Get the numbers of slaves elements linked to this parent element...
Definition: crossrefitem.cpp:484
diagramposition.h
XRefProperties::Cross
@ Cross
Definition: xrefproperties.h:34
CrossRefItem::boundingRect
QRectF boundingRect() const override
CrossRefItem::boundingRect.
Definition: crossrefitem.cpp:129
CrossRefItem::setUpConnection
void setUpConnection()
CrossRefItem::setUpConnection Set up several connection to keep up to date the Xref.
Definition: crossrefitem.cpp:97
CrossRefItem::updateProperties
void updateProperties()
CrossRefItem::updateProperties update the curent properties.
Definition: crossrefitem.cpp:178
centerToParentBottom
bool centerToParentBottom(QGraphicsItem *item)
centerToParentBottom Center the item at the bottom of is parent.
Definition: qgraphicsitemutility.cpp:30
QETProject::diagramRemoved
void diagramRemoved(QETProject *, Diagram *)
Diagram::showMe
void showMe()
Definition: diagram.h:161
elementtextitemgroup.h
CrossRefItem::Type
@ Type
Definition: crossrefitem.h:63
CrossRefItem::mouseDoubleClickEvent
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
CrossRefItem::mouseDoubleClickEvent.
Definition: crossrefitem.cpp:300
CrossRefItem::CONTACTS
CONTACTS
The CONTACTS enum.
Definition: crossrefitem.h:69
CrossRefItem::Delay
@ Delay
Definition: crossrefitem.h:78
CrossRefItem::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
CrossRefItem::paint Paint this item.
Definition: crossrefitem.cpp:288
CrossRefItem::drawAsCross
void drawAsCross(QPainter &painter)
CrossRefItem::drawAsCross Draw this crossref with a cross.
Definition: crossrefitem.cpp:545
Element::linkedElementChanged
void linkedElementChanged()
centerToBottomDiagram
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...
Definition: qgraphicsitemutility.cpp:54
assignvariables.h
CrossRefItem::buildHeaderContact
void buildHeaderContact()
CrossRefItem::buildHeaderContact Draw the QPicture of m_hdr_no_ctc and m_hdr_nc_ctc.
Definition: crossrefitem.cpp:434
CrossRefItem::linkedChanged
void linkedChanged()
CrossRefItem::linkedChanged.
Definition: crossrefitem.cpp:405
XRefProperties::Label
@ Label
Definition: xrefproperties.h:40
Diagram::project
QETProject * project() const
Diagram::project.
Definition: diagram.cpp:2326
qetapp.h
CrossRefItem::NCElements
QList< Element * > NCElements() const
CrossRefItem::NCElements.
Definition: crossrefitem.cpp:968
CrossRefItem::m_bounding_rect
QRectF m_bounding_rect
Definition: crossrefitem.h:118
CrossRefItem::m_hdr_nc_ctc
QPicture m_hdr_nc_ctc
Definition: crossrefitem.h:119
XRefProperties::offset
int offset() const
Definition: xrefproperties.h:76
CrossRefItem::drawContact
QRectF drawContact(QPainter &painter, int flags, Element *elmt)
CrossRefItem::drawContact Draw one contact, the type of contact to draw is define in flags.
Definition: crossrefitem.cpp:623
XRefProperties
The XRefProperties class this class store properties used by XrefItem.
Definition: xrefproperties.h:29
Element::kindInformations
DiagramContext kindInformations() const
Definition: element.h:100
XRefProperties::masterLabel
QString masterLabel() const
Definition: xrefproperties.h:70
CrossRefItem::hoverMoveEvent
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override
CrossRefItem::hoverMoveEvent.
Definition: crossrefitem.cpp:337
CrossRefItem::DelayOff
@ DelayOff
Definition: crossrefitem.h:76
xrefproperties.h
CrossRefItem::m_slave_connection
QList< QMetaObject::Connection > m_slave_connection
Definition: crossrefitem.h:127
CrossRefItem::SW
@ SW
Definition: crossrefitem.h:73
CrossRefItem::updateLabel
void updateLabel()
CrossRefItem::updateLabel Update the content of the item.
Definition: crossrefitem.cpp:200
CrossRefItem::m_hovered_contact
Element * m_hovered_contact
Definition: crossrefitem.h:124
XRefProperties::Contacts
@ Contacts
Definition: xrefproperties.h:35
CrossRefItem::m_update_connection
QList< QMetaObject::Connection > m_update_connection
Definition: crossrefitem.h:128
crossrefitem.h
CrossRefItem::m_drawing
QPicture m_drawing
Definition: crossrefitem.h:119
CrossRefItem::m_drawed_contacts
int m_drawed_contacts
Definition: crossrefitem.h:122
CrossRefItem::NOC
@ NOC
Definition: crossrefitem.h:72
element.h
CrossRefItem::CrossRefItem
CrossRefItem(Element *elmt)
CrossRefItem::CrossRefItem.
Definition: crossrefitem.cpp:37
CrossRefItem::m_element
Element * m_element
Definition: crossrefitem.h:117
XRefProperties::DisplayHas
DisplayHas
Definition: xrefproperties.h:33
Element
Definition: element.h:41
Element::isFree
bool isFree() const
Definition: element.h:230
CrossRefItem::fillCrossRef
void fillCrossRef(QPainter &painter)
CrossRefItem::fillCrossRef Fill the content of the cross ref.
Definition: crossrefitem.cpp:812
autonum::AssignVariables::formulaToLabel
static QString formulaToLabel(QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt=nullptr)
AssignVariables::formulaToLabel Return the formula with variable assigned (ready to be displayed)
Definition: assignvariables.cpp:187
CrossRefItem::m_group
ElementTextItemGroup * m_group
Definition: crossrefitem.h:126
CrossRefItem::DelayOnOff
@ DelayOnOff
Definition: crossrefitem.h:77
CrossRefItem::elementPositionText
QString elementPositionText(const Element *elmt, const bool &add_prefix=false) const
CrossRefItem::elementPositionText.
Definition: crossrefitem.cpp:149
CrossRefItem::~CrossRefItem
~CrossRefItem() override
CrossRefItem::~CrossRefItem Default destructor.
Definition: crossrefitem.cpp:68
CrossRefItem::shape
QPainterPath shape() const override
CrossRefItem::shape.
Definition: crossrefitem.cpp:137
QETProject
Definition: qetproject.h:51
CrossRefItem::m_hdr_no_ctc
QPicture m_hdr_no_ctc
Definition: crossrefitem.h:119
CrossRefItem::Power
@ Power
Definition: crossrefitem.h:74
XRefProperties::showPowerContact
bool showPowerContact() const
Definition: xrefproperties.h:56
ElementTextItemGroup
The ElementTextItemGroup class This class represent a group of element text Texts in the group can be...
Definition: elementtextitemgroup.h:36
CrossRefItem::hoverEnterEvent
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override
CrossRefItem::hoverEnterEvent.
Definition: crossrefitem.cpp:327
XRefProperties::prefix
QString prefix(const QString &key) const
Definition: xrefproperties.h:67
CrossRefItem::sceneEvent
bool sceneEvent(QEvent *event) override
CrossRefItem::sceneEvent.
Definition: crossrefitem.cpp:252
CrossRefItem::m_properties
XRefProperties m_properties
Definition: crossrefitem.h:121
QETApp::diagramTextsFont
static QFont diagramTextsFont(qreal=-1.0)
QETApp::diagramTextsFont The font to use By default the font is "sans Serif" and size 9.
Definition: qetapp.cpp:1111
XRefProperties::Bottom
@ Bottom
Definition: xrefproperties.h:39
CrossRefItem::hoverLeaveEvent
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
CrossRefItem::hoverLeaveEvent.
Definition: crossrefitem.cpp:395
DiagramContext::contains
bool contains(const QString &) const
Definition: diagramcontext.cpp:70
XRefProperties::displayHas
DisplayHas displayHas() const
Definition: xrefproperties.h:59
QETProject::XRefPropertiesChanged
void XRefPropertiesChanged()
dynamicelementtextitem.h
qgraphicsitemutility.h
CrossRefItem::m_hovered_contacts_map
QMultiMap< Element *, QRectF > m_hovered_contacts_map
Definition: crossrefitem.h:123
CrossRefItem::NO
@ NO
Definition: crossrefitem.h:70
XRefProperties::snapTo
SnapTo snapTo() const
Definition: xrefproperties.h:62
CrossRefItem::NC
@ NC
Definition: crossrefitem.h:71
QET::Icons::br
QIcon br
Definition: qeticons.cpp:185
Element::rSequenceStruct
autonum::sequentialNumbers & rSequenceStruct()
Definition: element.h:108
QETProject::defaultXRefProperties
XRefProperties defaultXRefProperties(const QString &type) const
Definition: qetproject.h:106
CrossRefItem::m_text
DynamicElementTextItem * m_text
Definition: crossrefitem.h:125
CrossRefItem::DelayOn
@ DelayOn
Definition: crossrefitem.h:75
DiagramContext
Definition: diagramcontext.h:56
diagram.h
CrossRefItem
The CrossRefItem class This clas provide an item, for show the cross reference, like the contacts lin...
Definition: crossrefitem.h:47
CrossRefItem::m_shape_path
QPainterPath m_shape_path
Definition: crossrefitem.h:120