QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
terminal.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2026 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 TERMINAL_H
19#define TERMINAL_H
20#include "../qet.h"
22
23#include <QtWidgets>
24#include <QtXml>
25class Conductor;
26class Diagram;
27class Element;
28
29
36class Terminal : public QGraphicsObject
37{
38 Q_OBJECT
39
40 signals:
41 void conductorWasAdded(Conductor *conductor);
43
44 // constructors, destructor
45 public:
46 Terminal(TerminalData* data, Element *e = nullptr);
47 ~Terminal() override;
48
49 private:
51
52 // methods
53 public:
60 int type() const override { return Type; }
61
62 void paint(
63 QPainter *painter,
64 const QStyleOptionGraphicsItem *,
65 QWidget *) override;
66 void drawHelpLine (bool draw = true);
67 QLineF HelpLine () const;
68 QRectF boundingRect () const override;
69
70 // methods to manage conductors attached to the terminal
72 bool addConductor (Conductor *conductor);
73 void removeConductor (Conductor *conductor);
74 int conductorsCount () const;
75 Diagram *diagram () const;
76 Element *parentElement () const;
77 QUuid uuid () const;
78 QUuid stableUuid () const;
79 QString name () const;
80 QString baseName () const;
82 bool useMasterLabel() const { return d->m_use_master_label; }
83 void setUseMasterLabel(bool use);
84 int masterLabelIndex() const { return d->m_master_label_index; }
85 void setMasterLabelIndex(int index);
86
87 QList<Conductor *> conductors() const;
89 QPointF dockConductor() const;
90 void updateConductor();
91 bool isLinkedTo(Terminal *);
92 bool canBeLinkedTo(Terminal *);
93
94 // methods related to XML import/export
95 static bool valideXml(QDomElement &);
96 bool fromXml (QDomElement &);
97 QDomElement toXml (QDomDocument &) const;
98
99 protected:
100 // methods related to events management
101 void hoverEnterEvent (QGraphicsSceneHoverEvent *) override;
102 void hoverMoveEvent (QGraphicsSceneHoverEvent *) override;
103 void hoverLeaveEvent (QGraphicsSceneHoverEvent *) override;
104 void mousePressEvent (QGraphicsSceneMouseEvent *) override;
105 void mouseMoveEvent (QGraphicsSceneMouseEvent *) override;
106 void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
107
108 // attributes
109 public:
110 enum { Type = UserType + 1002 };
111
112 static const qreal terminalSize;
113 static const qreal Z;
114 // Various static colors used for hover effects
116 static QColor neutralColor;
118 static QColor allowedColor;
120 static QColor warningColor;
122 static QColor forbiddenColor;
123
124 private:
125 bool m_draw_help_line{false};
126 QGraphicsLineItem *m_help_line{nullptr};
127 QGraphicsLineItem *m_help_line_a{nullptr};
128
129
131
134 public:
136 QPointF dock_elmt_;
137 private:
139 QList<Conductor *> m_conductors_list;
140 QRectF m_br;
144 bool m_hovered = false;
147
148 private:
149 void init();
150 void init(QPointF pf, Qet::Orientation o);
151};
152
158{
159 return(m_conductors_list.size());
160}
161
162QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
163 const bool all_diagram = true);
164
165#endif
Definition conductor.h:44
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition diagram.h:54
Definition element.h:44
Orientation
Orientation (used for electrical elements and their terminals).
Definition qet.h:211
The TerminalData class Data of the terminal. Stored in extra class so it can be used by PartTerminal ...
Definition terminaldata.h:39
Type
Definition terminaldata.h:43
The Terminal class This class represents a terminal of an electrical element, i.e....
Definition terminal.h:37
int conductorsCount() const
Terminal::conductorsCount.
Definition terminal.h:157
static QColor neutralColor
default color
Definition terminal.h:116
QGraphicsLineItem * m_help_line_a
Definition terminal.h:127
static const qreal terminalSize
Definition terminal.h:112
TerminalData * d
Definition terminal.h:130
bool m_draw_help_line
Definition terminal.h:125
bool useMasterLabel() const
Definition terminal.h:82
int masterLabelIndex() const
Definition terminal.h:84
QDomElement toXml(QDomDocument &) const
Terminal::toXml Methode d'export en XML.
Definition terminal.cpp:714
QList< Conductor * > m_conductors_list
List of conductors attached to the terminal.
Definition terminal.h:139
static bool valideXml(QDomElement &)
Terminal::valideXml Permet de savoir si un element XML represente une borne.
Definition terminal.cpp:733
QList< Conductor * > conductors() const
Terminal::conductors.
Definition terminal.cpp:703
void init(QPointF pf, Qet::Orientation o)
void removeConductor(Conductor *conductor)
Terminal::removeConductor Remove a conductor from this terminal.
Definition terminal.cpp:156
QPointF dock_elmt_
docking point for parent element
Definition terminal.h:136
bool addConductor(Conductor *conductor)
Terminal::addConductor Add a conductor to this terminal.
Definition terminal.cpp:129
QUuid stableUuid() const
Terminal::stableUuid An identity for this terminal that exists on every element, not only on those sa...
Definition terminal.cpp:853
void setMasterLabelIndex(int index)
Terminal::setMasterLabelIndex Set the index into the master's contact group labels.
Definition terminal.cpp:946
QString name() const
Definition terminal.cpp:877
static const qreal Z
Definition terminal.h:113
TerminalData::Type terminalType() const
Terminal::terminalType.
Definition terminal.cpp:925
void hoverMoveEvent(QGraphicsSceneHoverEvent *) override
Terminal::hoverMoveEvent Gere les mouvements de la souris sur la zone de la Borne.
Definition terminal.cpp:494
void conductorWasRemoved(Conductor *conductor)
void setUseMasterLabel(bool use)
Terminal::setUseMasterLabel Set whether this terminal uses a label from the master's contact group.
Definition terminal.cpp:935
Terminal * alignedWithTerminal() const
Terminal::alignedWithTerminal If this terminal is aligned with an other terminal and is orientation i...
Definition terminal.cpp:425
QColor m_hovered_color
Color used for the hover effect.
Definition terminal.h:146
QRectF m_br
Definition terminal.h:140
Diagram * diagram() const
Terminal::diagram.
Definition terminal.cpp:804
bool isLinkedTo(Terminal *)
Terminal::isLinkedTo.
Definition terminal.cpp:668
Terminal(const Terminal &)
static QColor allowedColor
color for legal actions
Definition terminal.h:118
Qet::Orientation orientation() const
Definition terminal.cpp:104
QString baseName() const
Terminal::baseName Return the original terminal name (T1, T2...) without master label override....
Definition terminal.cpp:916
int type() const override
type Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a Terminal
Definition terminal.h:60
static QColor forbiddenColor
color for forbidden actions
Definition terminal.h:122
QRectF boundingRect() const override
Terminal::boundingRect.
Definition terminal.cpp:393
Element * parentElement() const
Terminal::parentElement.
Definition terminal.cpp:813
void mousePressEvent(QGraphicsSceneMouseEvent *) override
Terminal::mousePressEvent Gere le fait qu'on enfonce un bouton de la souris sur la Borne.
Definition terminal.cpp:511
void drawHelpLine(bool draw=true)
Terminal::drawHelpLine.
Definition terminal.cpp:334
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override
Terminal::mouseReleaseEvent.
Definition terminal.cpp:583
bool fromXml(QDomElement &)
Terminal::fromXml Enables you to find out whether an XML element represents this terminal....
Definition terminal.cpp:780
void updateConductor()
Terminal::updateConductor Update the path of conductor docked to this terminal.
Definition terminal.cpp:657
QGraphicsLineItem * m_help_line
Definition terminal.h:126
QUuid uuid() const
Definition terminal.cpp:818
@ Type
Definition terminal.h:110
QLineF HelpLine() const
Terminal::HelpLine.
Definition terminal.cpp:361
static QColor warningColor
color for allowed but fuzzy or not recommended actions
Definition terminal.h:120
QPointF dockConductor() const
Terminal::dockConductor.
Definition terminal.cpp:794
bool canBeLinkedTo(Terminal *)
Terminal::canBeLinkedTo Checking if the terminal can be linked to other_terminal or not Reasons for n...
Definition terminal.cpp:691
~Terminal() override
Terminal::~Terminal Destruction of the terminal, and also docked conductor.
Definition terminal.cpp:87
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override
Terminal::hoverEnterEvent Gere l'entree de la souris sur la zone de la Borne.
Definition terminal.cpp:484
void init()
Terminal::init Methode privee pour initialiser la borne. Private method to initialize the terminal.
Definition terminal.cpp:45
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override
Terminal::hoverLeaveEvent Gere le fait que la souris sorte de la zone de la Borne.
Definition terminal.cpp:500
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
Terminal::paint Fonction de dessin des bornes.
Definition terminal.cpp:170
bool m_hovered
Whether the mouse pointer is hovering the terminal.
Definition terminal.h:144
Element * parent_element_
Parent electrical element.
Definition terminal.h:133
void conductorWasAdded(Conductor *conductor)
Terminal(TerminalData *data, Element *e=nullptr)
Definition terminal.cpp:74
void mouseMoveEvent(QGraphicsSceneMouseEvent *) override
Terminal::mouseMoveEvent Gere le fait qu'on bouge la souris sur la Borne.
Definition terminal.cpp:526
Terminal * m_previous_terminal
Last terminal seen through an attached conductor.
Definition terminal.h:142
QList< Terminal * > relatedPotentialTerminal(const Terminal *terminal, const bool all_diagram=true)
Conductor::relatedPotentialTerminal Return terminal at the same potential from the same parent elemen...
Definition terminal.cpp:963