QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
crossrefitem.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 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 "../properties/xrefproperties.h"
22
23#include <QGraphicsObject>
24#include <QMultiMap>
25#include <QPicture>
26
27class Element;
30
46class CrossRefItem : public QGraphicsObject
47{
48 Q_OBJECT
49
50 //Methods
51 public:
52 explicit CrossRefItem(Element *elmt);
53 explicit CrossRefItem(
54 Element *elmt, DynamicElementTextItem *text);
55 explicit CrossRefItem(
56 Element *elmt, 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,
78 Delay = 112,
79 Other = 128
80 };
81
82 QRectF boundingRect() const override;
83 QPainterPath shape() const override;
84 QString elementPositionText(
85 const Element *elmt,
86 const bool &add_prefix = false) const;
87
88 public slots:
89 void updateProperties();
90 void updateLabel();
91 void autoPos();
92
93 protected:
94 bool sceneEvent(QEvent *event) override;
95 void paint(QPainter *painter,
96 const QStyleOptionGraphicsItem *option,
97 QWidget *widget) override;
99 QGraphicsSceneMouseEvent * event ) override;
100 void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
101 void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
102 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
103
104 private:
105 void linkedChanged();
106 void buildHeaderContact();
107 void setUpCrossBoundingRect(QPainter &painter);
108 void drawAsCross(QPainter &painter);
109 void drawAsContacts(QPainter &painter);
110 QRectF drawContact(QPainter &painter, int flags, Element *elmt);
111 void fillCrossRef(QPainter &painter);
112 void AddExtraInfo(QPainter &painter, const QString&);
113 QList<Element *> NOElements() const;
114 QList<Element *> NCElements() const;
115
116 //Attributes
117 private:
118 Element *m_element; //element to display the cross reference
121 QPainterPath m_shape_path;
124 QMultiMap <Element *, QRectF> m_hovered_contacts_map;
128 QList <QMetaObject::Connection> m_slave_connection;
129 QList <QMetaObject::Connection> m_update_connection;
130};
131
132#endif // CROSSREFITEM_H
133
The CrossRefItem class This clas provide an item, for show the cross reference, like the contacts lin...
Definition crossrefitem.h:47
void drawAsCross(QPainter &painter)
CrossRefItem::drawAsCross Draw this crossref with a cross.
Definition crossrefitem.cpp:565
void buildHeaderContact()
CrossRefItem::buildHeaderContact Draw the QPicture of m_hdr_no_ctc and m_hdr_nc_ctc.
Definition crossrefitem.cpp:454
void updateProperties()
CrossRefItem::updateProperties update the current properties.
Definition crossrefitem.cpp:195
QPicture m_drawing
Definition crossrefitem.h:120
QPicture m_hdr_nc_ctc
Definition crossrefitem.h:120
void AddExtraInfo(QPainter &painter, const QString &)
CrossRefItem::AddExtraInfo Add the comment info of the parent item if needed.
Definition crossrefitem.cpp:942
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override
CrossRefItem::hoverEnterEvent.
Definition crossrefitem.cpp:347
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
CrossRefItem::hoverLeaveEvent.
Definition crossrefitem.cpp:415
void init()
CrossRefItem::init init this Xref.
Definition crossrefitem.cpp:76
QList< QMetaObject::Connection > m_slave_connection
Definition crossrefitem.h:128
void autoPos()
CrossRefItem::autoPos Calculate and set position automatically.
Definition crossrefitem.cpp:252
QPicture m_hdr_no_ctc
Definition crossrefitem.h:120
QString elementPositionText(const Element *elmt, const bool &add_prefix=false) const
CrossRefItem::elementPositionText.
Definition crossrefitem.cpp:170
CONTACTS
The CONTACTS enum.
Definition crossrefitem.h:69
@ NC
Definition crossrefitem.h:71
@ DelayOn
Definition crossrefitem.h:75
@ DelayOnOff
Definition crossrefitem.h:77
@ NO
Definition crossrefitem.h:70
@ NOC
Definition crossrefitem.h:72
@ Power
Definition crossrefitem.h:74
@ Delay
Definition crossrefitem.h:78
@ DelayOff
Definition crossrefitem.h:76
@ Other
Definition crossrefitem.h:79
@ SW
Definition crossrefitem.h:73
~CrossRefItem() override
CrossRefItem::~CrossRefItem Default destructor.
Definition crossrefitem.cpp:69
DynamicElementTextItem * m_text
Definition crossrefitem.h:126
Element * m_hovered_contact
Definition crossrefitem.h:125
Element * m_element
Definition crossrefitem.h:118
bool sceneEvent(QEvent *event) override
CrossRefItem::sceneEvent.
Definition crossrefitem.cpp:270
void fillCrossRef(QPainter &painter)
CrossRefItem::fillCrossRef Fill the content of the cross ref.
Definition crossrefitem.cpp:872
QRectF boundingRect() const override
CrossRefItem::boundingRect.
Definition crossrefitem.cpp:149
QMultiMap< Element *, QRectF > m_hovered_contacts_map
Definition crossrefitem.h:124
void linkedChanged()
CrossRefItem::linkedChanged.
Definition crossrefitem.cpp:425
ElementTextItemGroup * m_group
Definition crossrefitem.h:127
XRefProperties m_properties
Definition crossrefitem.h:122
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
CrossRefItem::mouseDoubleClickEvent.
Definition crossrefitem.cpp:320
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:644
void drawAsContacts(QPainter &painter)
CrossRefItem::drawAsContacts Draw this crossref with symbolic contacts.
Definition crossrefitem.cpp:595
void updateLabel()
CrossRefItem::updateLabel Update the content of the item.
Definition crossrefitem.cpp:217
void setUpConnection()
CrossRefItem::setUpConnection Set up several connection to keep up to date the Xref.
Definition crossrefitem.cpp:99
void setUpCrossBoundingRect(QPainter &painter)
CrossRefItem::setUpCrossBoundingRect Get the numbers of slaves elements linked to this parent element...
Definition crossrefitem.cpp:505
@ Type
Definition crossrefitem.h:63
QList< QMetaObject::Connection > m_update_connection
Definition crossrefitem.h:129
QRectF m_bounding_rect
Definition crossrefitem.h:119
QList< Element * > NOElements() const
CrossRefItem::NOElements.
Definition crossrefitem.cpp:995
int type() const override
Definition crossrefitem.h:64
int m_drawed_contacts
Definition crossrefitem.h:123
QPainterPath m_shape_path
Definition crossrefitem.h:121
QPainterPath shape() const override
CrossRefItem::shape.
Definition crossrefitem.cpp:158
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override
CrossRefItem::hoverMoveEvent.
Definition crossrefitem.cpp:357
QList< Element * > NCElements() const
CrossRefItem::NCElements.
Definition crossrefitem.cpp:1028
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
CrossRefItem::paint Paint this item.
Definition crossrefitem.cpp:306
The DynamicElementTextItem class This class provide a simple text field of element who can be added o...
Definition dynamicelementtextitem.h:40
Definition element.h:43
The ElementTextItemGroup class This class represent a group of element text Texts in the group can be...
Definition elementtextitemgroup.h:36
The XRefProperties class this class store properties used by XrefItem.
Definition xrefproperties.h:31