QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
Terminal Class Reference

The Terminal class This class represents a terminal of an electrical element, i.e. a possible plug point for conductors. This class handles all mouse events for connecting conductors. More...

#include <terminal.h>

Inherits QGraphicsObject.

Collaboration diagram for Terminal:
Collaboration graph

Public Types

enum  { Type = UserType + 1002 }

Signals

void conductorWasAdded (Conductor *conductor)
void conductorWasRemoved (Conductor *conductor)

Public Member Functions

 Terminal (TerminalData *data, Element *e=nullptr)
 ~Terminal () override
 Terminal::~Terminal Destruction of the terminal, and also docked conductor.
int type () const override
 type Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a Terminal
void paint (QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
 Terminal::paint Fonction de dessin des bornes.
void drawHelpLine (bool draw=true)
 Terminal::drawHelpLine.
QLineF HelpLine () const
 Terminal::HelpLine.
QRectF boundingRect () const override
 Terminal::boundingRect.
TerminalalignedWithTerminal () const
 Terminal::alignedWithTerminal If this terminal is aligned with an other terminal and is orientation is opposed return the other terminal else return nullptr.
bool addConductor (Conductor *conductor)
 Terminal::addConductor Add a conductor to this terminal.
void removeConductor (Conductor *conductor)
 Terminal::removeConductor Remove a conductor from this terminal.
int conductorsCount () const
 Terminal::conductorsCount.
Diagramdiagram () const
 Terminal::diagram.
ElementparentElement () const
 Terminal::parentElement.
QUuid uuid () const
QUuid stableUuid () const
 Terminal::stableUuid An identity for this terminal that exists on every element, not only on those saved by a uuid-aware element editor.
QString name () const
QString baseName () const
 Terminal::baseName Return the original terminal name (T1, T2...) without master label override. Used for sorting when linking.
TerminalData::Type terminalType () const
 Terminal::terminalType.
bool useMasterLabel () const
void setUseMasterLabel (bool use)
 Terminal::setUseMasterLabel Set whether this terminal uses a label from the master's contact group.
int masterLabelIndex () const
void setMasterLabelIndex (int index)
 Terminal::setMasterLabelIndex Set the index into the master's contact group labels.
QList< Conductor * > conductors () const
 Terminal::conductors.
Qet::Orientation orientation () const
QPointF dockConductor () const
 Terminal::dockConductor.
void updateConductor ()
 Terminal::updateConductor Update the path of conductor docked to this terminal.
bool isLinkedTo (Terminal *)
 Terminal::isLinkedTo.
bool canBeLinkedTo (Terminal *)
 Terminal::canBeLinkedTo Checking if the terminal can be linked to other_terminal or not Reasons for not linable:
bool fromXml (QDomElement &)
 Terminal::fromXml Enables you to find out whether an XML element represents this terminal. Warning, the XML element is not checked Permet de savoir si un element XML represente cette borne. Attention, l'element XML n'est pas verifie.
QDomElement toXml (QDomDocument &) const
 Terminal::toXml Methode d'export en XML.

Static Public Member Functions

static bool valideXml (QDomElement &)
 Terminal::valideXml Permet de savoir si un element XML represente une borne.

Public Attributes

QPointF dock_elmt_
 docking point for parent element

Static Public Attributes

static const qreal terminalSize = 4.0
static const qreal Z = 1000
static QColor neutralColor = QColor(Qt::blue)
 default color
static QColor allowedColor = QColor(Qt::darkGreen)
 color for legal actions
static QColor warningColor = QColor("#ff8000")
 color for allowed but fuzzy or not recommended actions
static QColor forbiddenColor = QColor(Qt::red)
 color for forbidden actions

Protected Member Functions

void hoverEnterEvent (QGraphicsSceneHoverEvent *) override
 Terminal::hoverEnterEvent Gere l'entree de la souris sur la zone de la Borne.
void hoverMoveEvent (QGraphicsSceneHoverEvent *) override
 Terminal::hoverMoveEvent Gere les mouvements de la souris sur la zone de la Borne.
void hoverLeaveEvent (QGraphicsSceneHoverEvent *) override
 Terminal::hoverLeaveEvent Gere le fait que la souris sorte de la zone de la Borne.
void mousePressEvent (QGraphicsSceneMouseEvent *) override
 Terminal::mousePressEvent Gere le fait qu'on enfonce un bouton de la souris sur la Borne.
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override
 Terminal::mouseMoveEvent Gere le fait qu'on bouge la souris sur la Borne.
void mouseReleaseEvent (QGraphicsSceneMouseEvent *) override
 Terminal::mouseReleaseEvent.

Private Member Functions

 Terminal (const Terminal &)
void init ()
 Terminal::init Methode privee pour initialiser la borne. Private method to initialize the terminal.
void init (QPointF pf, Qet::Orientation o)

Private Attributes

bool m_draw_help_line {false}
QGraphicsLineItem * m_help_line {nullptr}
QGraphicsLineItem * m_help_line_a {nullptr}
TerminalDatad
Elementparent_element_ {nullptr}
 Parent electrical element.
QList< Conductor * > m_conductors_list
 List of conductors attached to the terminal.
QRectF m_br
Terminalm_previous_terminal = nullptr
 Last terminal seen through an attached conductor.
bool m_hovered = false
 Whether the mouse pointer is hovering the terminal.
QColor m_hovered_color = Terminal::neutralColor
 Color used for the hover effect.

Detailed Description

The Terminal class This class represents a terminal of an electrical element, i.e. a possible plug point for conductors. This class handles all mouse events for connecting conductors.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Constructor & Destructor Documentation

◆ Terminal() [1/2]

Terminal::Terminal ( TerminalData * data,
Element * e = nullptr )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Terminal()

Terminal::~Terminal ( )
override

Terminal::~Terminal Destruction of the terminal, and also docked conductor.

◆ Terminal() [2/2]

Terminal::Terminal ( const Terminal & )
private
Here is the call graph for this function:

Member Function Documentation

◆ addConductor()

bool Terminal::addConductor ( Conductor * conductor)

Terminal::addConductor Add a conductor to this terminal.

Parameters
conductor: the conductor to add.
Returns
true if the conductor was successfully added
Here is the call graph for this function:
Here is the caller graph for this function:

◆ alignedWithTerminal()

Terminal * Terminal::alignedWithTerminal ( ) const

Terminal::alignedWithTerminal If this terminal is aligned with an other terminal and is orientation is opposed return the other terminal else return nullptr.

Returns
Here is the call graph for this function:
Here is the caller graph for this function:

◆ baseName()

QString Terminal::baseName ( ) const

Terminal::baseName Return the original terminal name (T1, T2...) without master label override. Used for sorting when linking.

◆ boundingRect()

QRectF Terminal::boundingRect ( ) const
override

Terminal::boundingRect.

Returns
Le rectangle (en precision flottante) delimitant la borne et ses alentours.
Here is the call graph for this function:

◆ canBeLinkedTo()

bool Terminal::canBeLinkedTo ( Terminal * other_terminal)

Terminal::canBeLinkedTo Checking if the terminal can be linked to other_terminal or not Reasons for not linable:

  • other_terminal is this terminal
  • this terminal is already connected to other_terminal
    Parameters
    other_terminal
    Returns
    true if this terminal can be linked to other_terminal, otherwise false
Here is the call graph for this function:
Here is the caller graph for this function:

◆ conductors()

QList< Conductor * > Terminal::conductors ( ) const

Terminal::conductors.

Returns
La liste des conducteurs lies a cette borne
Here is the caller graph for this function:

◆ conductorsCount()

int Terminal::conductorsCount ( ) const
inline

Terminal::conductorsCount.

Returns
the number of conductors attached to the terminal.
Here is the caller graph for this function:

◆ conductorWasAdded

void Terminal::conductorWasAdded ( Conductor * conductor)
signal
Here is the caller graph for this function:

◆ conductorWasRemoved

void Terminal::conductorWasRemoved ( Conductor * conductor)
signal
Here is the caller graph for this function:

◆ diagram()

Diagram * Terminal::diagram ( ) const

Terminal::diagram.

Returns
le Diagram auquel cette borne appartient, ou 0 si cette borne est independant
Here is the caller graph for this function:

◆ dockConductor()

QPointF Terminal::dockConductor ( ) const

Terminal::dockConductor.

Returns
the position, relative to the scene, of the docking point for conductors.
Here is the caller graph for this function:

◆ drawHelpLine()

void Terminal::drawHelpLine ( bool draw = true)

Terminal::drawHelpLine.

Parameters
draw: true, display the help line false, hide it.
Here is the caller graph for this function:

◆ fromXml()

bool Terminal::fromXml ( QDomElement & terminal)

Terminal::fromXml Enables you to find out whether an XML element represents this terminal. Warning, the XML element is not checked Permet de savoir si un element XML represente cette borne. Attention, l'element XML n'est pas verifie.

Parameters
terminalLe QDomElement a analyser / QDomElement to check
Returns
true si la borne "se reconnait" (memes coordonnes, meme orientation), false sinon true, if the terminal ‘recognises’ itself (same coordinates, same orientation), false otherwise

◆ HelpLine()

QLineF Terminal::HelpLine ( ) const

Terminal::HelpLine.

Returns
a line with coordinate P1 the dock point of conductor and P2 the border of diagram, according to the orientation of terminal The line is in scene coordinate;
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hoverEnterEvent()

void Terminal::hoverEnterEvent ( QGraphicsSceneHoverEvent * )
overrideprotected

Terminal::hoverEnterEvent Gere l'entree de la souris sur la zone de la Borne.

◆ hoverLeaveEvent()

void Terminal::hoverLeaveEvent ( QGraphicsSceneHoverEvent * )
overrideprotected

Terminal::hoverLeaveEvent Gere le fait que la souris sorte de la zone de la Borne.

◆ hoverMoveEvent()

void Terminal::hoverMoveEvent ( QGraphicsSceneHoverEvent * )
overrideprotected

Terminal::hoverMoveEvent Gere les mouvements de la souris sur la zone de la Borne.

◆ init() [1/2]

void Terminal::init ( )
private

Terminal::init Methode privee pour initialiser la borne. Private method to initialize the terminal.

Parameters
numberof terminal
nameof terminal
hiddenName
Here is the caller graph for this function:

◆ init() [2/2]

void Terminal::init ( QPointF pf,
Qet::Orientation o )
private

◆ isLinkedTo()

bool Terminal::isLinkedTo ( Terminal * other_terminal)

Terminal::isLinkedTo.

Parameters
other_terminalAutre borne
Returns
true si cette borne est reliee a other_terminal, false sion
Here is the call graph for this function:
Here is the caller graph for this function:

◆ masterLabelIndex()

int Terminal::masterLabelIndex ( ) const
inline

◆ mouseMoveEvent()

void Terminal::mouseMoveEvent ( QGraphicsSceneMouseEvent * e)
overrideprotected

Terminal::mouseMoveEvent Gere le fait qu'on bouge la souris sur la Borne.

Parameters
eL'evenement souris correspondant
Here is the call graph for this function:

◆ mousePressEvent()

void Terminal::mousePressEvent ( QGraphicsSceneMouseEvent * e)
overrideprotected

Terminal::mousePressEvent Gere le fait qu'on enfonce un bouton de la souris sur la Borne.

Parameters
eL'evenement souris correspondant
Here is the call graph for this function:

◆ mouseReleaseEvent()

void Terminal::mouseReleaseEvent ( QGraphicsSceneMouseEvent * e)
overrideprotected

Terminal::mouseReleaseEvent.

Parameters
e
Here is the call graph for this function:

◆ name()

QString Terminal::name ( ) const
Here is the caller graph for this function:

◆ orientation()

Qet::Orientation Terminal::orientation ( ) const

Permet de connaitre l'orientation de la borne. Si le parent de la borne est bien un Element, cette fonction renvoie l'orientation par rapport a la scene de la borne, en tenant compte du fait que l'element ait pu etre pivote. Sinon elle renvoie son sens normal. Used to find out the orientation of the terminal. If the terminal's parent is in fact an Element, this function returns the orientation of the terminal with respect to the scene, taking into account the angle of rotation. scene, taking into account the fact that the element may have been rotated. Otherwise it returns its normal direction.

Returns
L'orientation actuelle de la Terminal.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ paint()

void Terminal::paint ( QPainter * painter,
const QStyleOptionGraphicsItem * options,
QWidget *  )
override

Terminal::paint Fonction de dessin des bornes.

Parameters
painterLe QPainter a utiliser
optionsLes options de dessin
Here is the call graph for this function:

◆ parentElement()

Element * Terminal::parentElement ( ) const

Terminal::parentElement.

Returns
L'element auquel cette borne est rattachee
Here is the caller graph for this function:

◆ removeConductor()

void Terminal::removeConductor ( Conductor * conductor)

Terminal::removeConductor Remove a conductor from this terminal.

Parameters
conductor: conductor to remove
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMasterLabelIndex()

void Terminal::setMasterLabelIndex ( int index)

Terminal::setMasterLabelIndex Set the index into the master's contact group labels.

Parameters
indexthe label index (0-based)

◆ setUseMasterLabel()

void Terminal::setUseMasterLabel ( bool use)

Terminal::setUseMasterLabel Set whether this terminal uses a label from the master's contact group.

Parameters
usetrue to use master label

◆ stableUuid()

QUuid Terminal::stableUuid ( ) const

Terminal::stableUuid An identity for this terminal that exists on every element, not only on those saved by a uuid-aware element editor.

uuid() comes from the catalog .elmt definition and is empty for every element authored before that field existed – which is most of the installed base. Anything keyed on uuid() alone therefore cannot see those elements at all.

When there is no uuid, derive one from the terminal's local position and orientation inside its element. That is not an arbitrary choice: it is the same thing the project format itself uses to match a conductor back to a terminal ("each connection is made by using the local position of the terminal and a dynamic id" – TerminalData::m_uuid). m_pos is the position read from the definition and is not touched by moving the element on the folio, so the result is stable across loads, saves and folio moves, and it is unique within an element except where a definition genuinely declares two terminals at the same point – three cases in the whole example corpus, and harmless, because two terminals sharing a position and orientation are indistinguishable in every observable respect: they merge to one terminal row and every conductor on either of them still resolves to the right element and name.

Derived values are UUID v5 in a fixed namespace, so they are reproducible without being written to the file, and cannot collide with the v4 uuids the element editor generates.

Returns
the terminal's own uuid when it has one, otherwise a derived one
Here is the caller graph for this function:

◆ terminalType()

TerminalData::Type Terminal::terminalType ( ) const

Terminal::terminalType.

Returns
the type of this terminal (Generic, Inner, Outer, No, Nc, Common)

◆ toXml()

QDomElement Terminal::toXml ( QDomDocument & doc) const

Terminal::toXml Methode d'export en XML.

Parameters
docLe Document XML a utiliser pour creer l'element XML
Returns
un QDomElement representant cette borne

◆ type()

int Terminal::type ( ) const
inlineoverride

type Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a Terminal

Returns
the QGraphicsItem type

◆ updateConductor()

void Terminal::updateConductor ( )

Terminal::updateConductor Update the path of conductor docked to this terminal.

Here is the call graph for this function:

◆ useMasterLabel()

bool Terminal::useMasterLabel ( ) const
inline

◆ uuid()

QUuid Terminal::uuid ( ) const

◆ valideXml()

bool Terminal::valideXml ( QDomElement & terminal)
static

Terminal::valideXml Permet de savoir si un element XML represente une borne.

Parameters
terminalLe QDomElement a analyser
Returns
true si le QDomElement passe en parametre est une borne, false sinon
Here is the caller graph for this function:

Member Data Documentation

◆ allowedColor

QColor Terminal::allowedColor = QColor(Qt::darkGreen)
static

color for legal actions

◆ d

TerminalData* Terminal::d
private

◆ dock_elmt_

QPointF Terminal::dock_elmt_

docking point for parent element

◆ forbiddenColor

QColor Terminal::forbiddenColor = QColor(Qt::red)
static

color for forbidden actions

◆ m_br

QRectF Terminal::m_br
private

◆ m_conductors_list

QList<Conductor *> Terminal::m_conductors_list
private

List of conductors attached to the terminal.

◆ m_draw_help_line

bool Terminal::m_draw_help_line {false}
private

◆ m_help_line

QGraphicsLineItem* Terminal::m_help_line {nullptr}
private

◆ m_help_line_a

QGraphicsLineItem* Terminal::m_help_line_a {nullptr}
private

◆ m_hovered

bool Terminal::m_hovered = false
private

Whether the mouse pointer is hovering the terminal.

◆ m_hovered_color

QColor Terminal::m_hovered_color = Terminal::neutralColor
private

Color used for the hover effect.

◆ m_previous_terminal

Terminal* Terminal::m_previous_terminal = nullptr
private

Last terminal seen through an attached conductor.

◆ neutralColor

QColor Terminal::neutralColor = QColor(Qt::blue)
static

default color

◆ parent_element_

Element* Terminal::parent_element_ {nullptr}
private

Parent electrical element.

◆ terminalSize

const qreal Terminal::terminalSize = 4.0
static

◆ warningColor

QColor Terminal::warningColor = QColor("#ff8000")
static

color for allowed but fuzzy or not recommended actions

◆ Z

const qreal Terminal::Z = 1000
static

The documentation for this class was generated from the following files: