QElectroTech  0.8-dev
Public Types | Signals | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
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 (QPointF, Qet::Orientation, Element *=nullptr)
 
 Terminal (qreal, qreal, Qet::Orientation, Element *=nullptr)
 
 Terminal (TerminalData *data, Element *e=nullptr)
 
 Terminal (QPointF, Qet::Orientation, QString number, QString name, bool hiddenName, Element *=nullptr)
 
 ~Terminal () override
 
int type () const override
 type Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a Terminal More...
 
void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override
 Terminal::paint Fonction de dessin des bornes. More...
 
void drawHelpLine (bool draw=true)
 Terminal::drawHelpLine. More...
 
QLineF HelpLine () const
 Terminal::HelpLine. More...
 
QRectF boundingRect () const override
 Terminal::boundingRect. More...
 
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. More...
 
bool addConductor (Conductor *conductor)
 Terminal::addConductor Add a conductor to this terminal. More...
 
void removeConductor (Conductor *conductor)
 Terminal::removeConductor Remove a conductor from this terminal. More...
 
int conductorsCount () const
 Terminal::conductorsCount. More...
 
Diagramdiagram () const
 Terminal::diagram. More...
 
ElementparentElement () const
 Terminal::parentElement. More...
 
QUuid uuid () const
 
QList< Conductor * > conductors () const
 Terminal::conductors. More...
 
Qet::Orientation orientation () const
 
QPointF dockConductor () const
 Terminal::dockConductor. More...
 
QString number () const
 Terminal::number. More...
 
QString name () const
 Terminal::name. More...
 
void setNumber (QString number)
 Terminal::setNumber. More...
 
void setName (QString name, bool hiddenName)
 Terminal::setName. More...
 
void updateConductor ()
 Terminal::updateConductor Update the path of conductor docked to this terminal. More...
 
bool isLinkedTo (Terminal *)
 Terminal::isLinkedTo. More...
 
bool canBeLinkedTo (Terminal *)
 Terminal::canBeLinkedTo Checking if the terminal can be linked to other_terminal or not Reasons for not linable: More...
 
bool fromXml (QDomElement &)
 Terminal::fromXml Permet de savoir si un element XML represente cette borne. Attention, l'element XML n'est pas verifie. More...
 
QDomElement toXml (QDomDocument &) const
 Terminal::toXml Methode d'export en XML. More...
 

Static Public Member Functions

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

Static Public Attributes

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

Protected Member Functions

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

Private Member Functions

 Terminal (const Terminal &)
 
void init (QString number, QString name, bool hiddenName)
 Terminal::init Methode privee pour initialiser la borne. More...
 
void init (QPointF pf, Qet::Orientation o, QString number, QString name, bool hiddenName)
 Terminal::init Additionaly to the init above, this method stores position and orientation into the data class. More...
 

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. More...
 
QPointF dock_elmt_
 docking point for parent element More...
 
QList< Conductor * > conductors_
 List of conductors attached to the terminal. More...
 
QRectF * br_ {nullptr}
 
Terminalprevious_terminal_
 Last terminal seen through an attached conductor. More...
 
bool hovered_
 Whether the mouse pointer is hovering the terminal. More...
 
QColor hovered_color_
 Color used for the hover effect. More...
 
QString number_terminal_
 Number of Terminal. More...
 
QString name_terminal_
 Name of Terminal. More...
 
bool name_terminal_hidden
 

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/5]

Terminal::Terminal ( QPointF  pf,
Qet::Orientation  o,
Element e = nullptr 
)

initialise une borne

Parameters
pfposition du point d'amarrage pour un conducteur
oorientation de la borne : Qt::Horizontal ou Qt::Vertical
eElement auquel cette borne appartient
Here is the call graph for this function:

◆ Terminal() [2/5]

Terminal::Terminal ( qreal  pf_x,
qreal  pf_y,
Qet::Orientation  o,
Element e = nullptr 
)

initialise une borne

Parameters
pf_xAbscisse du point d'amarrage pour un conducteur
pf_yOrdonnee du point d'amarrage pour un conducteur
oorientation de la borne : Qt::Horizontal ou Qt::Vertical
eElement auquel cette borne appartient
Here is the call graph for this function:

◆ Terminal() [3/5]

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

◆ Terminal() [4/5]

Terminal::Terminal ( QPointF  pf,
Qet::Orientation  o,
QString  num,
QString  name,
bool  hiddenName,
Element e = nullptr 
)

initialise une borne

Parameters
pfposition du point d'amarrage pour un conducteur
oorientation de la borne : Qt::Horizontal ou Qt::Vertical
numnumber of terminal (ex 3 - 4 for NO)
nameof terminal
hiddenNamehide or show the name
eElement auquel cette borne appartient
Here is the call graph for this function:

◆ ~Terminal()

Terminal::~Terminal ( )
override

Destructeur La destruction de la borne entraine la destruction des conducteurs associes.

◆ Terminal() [5/5]

Terminal::Terminal ( const Terminal )
private

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 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:

◆ boundingRect()

QRectF Terminal::boundingRect ( ) const
override

Terminal::boundingRect.

Returns
Le rectangle (en precision flottante) delimitant la borne et ses alentours.

◆ 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 Permet de savoir si un element XML represente cette borne. Attention, l'element XML n'est pas verifie.

Parameters
terminalLe QDomElement a analyser
Returns
true si la borne "se reconnait" (memes coordonnes, meme orientation), false sinon

◆ 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 ( QPointF  pf,
Qet::Orientation  o,
QString  number,
QString  name,
bool  hiddenName 
)
private

Terminal::init Additionaly to the init above, this method stores position and orientation into the data class.

Parameters
pf
o
number
name
hiddenName
Here is the call graph for this function:

◆ init() [2/2]

void Terminal::init ( QString  number,
QString  name,
bool  hiddenName 
)
private

Terminal::init Methode privee pour initialiser la borne.

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

◆ 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 caller graph for this function:

◆ 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
inline

Terminal::name.

Returns
the name of terminal.
Here is the caller graph for this function:

◆ number()

QString Terminal::number ( ) const
inline

Terminal::number.

Returns
the number of terminal.
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.

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

◆ paint()

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

Terminal::paint Fonction de dessin des bornes.

Parameters
pLe 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 caller graph for this function:

◆ setName()

void Terminal::setName ( QString  name,
bool  hiddenName 
)

Terminal::setName.

Parameters
name: QString
hiddenName: bool
Here is the call graph for this function:

◆ setNumber()

void Terminal::setNumber ( QString  number)

Terminal::setNumber.

Parameters
number
Here is the call graph for this function:

◆ 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:

◆ uuid()

QUuid Terminal::uuid ( ) const
Here is the caller graph for this function:

◆ 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

◆ br_

QRectF* Terminal::br_ {nullptr}
private

Pointer to a rectangle representing the terminal bounding rect; used to calculate the bounding rect once only; used a pointer because boundingRect() is supposed to be const.

◆ conductors_

QList<Conductor *> Terminal::conductors_
private

List of conductors attached to the terminal.

◆ d

TerminalData* Terminal::d
private

◆ dock_elmt_

QPointF Terminal::dock_elmt_
private

docking point for parent element

◆ forbiddenColor

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

color for forbidden actions

◆ hovered_

bool Terminal::hovered_
private

Whether the mouse pointer is hovering the terminal.

◆ hovered_color_

QColor Terminal::hovered_color_
private

Color used for the hover effect.

◆ 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

◆ name_terminal_

QString Terminal::name_terminal_
private

Name of Terminal.

◆ name_terminal_hidden

bool Terminal::name_terminal_hidden
private

◆ neutralColor

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

default color

◆ number_terminal_

QString Terminal::number_terminal_
private

Number of Terminal.

◆ parent_element_

Element* Terminal::parent_element_ {nullptr}
private

Parent electrical element.

◆ previous_terminal_

Terminal* Terminal::previous_terminal_
private

Last terminal seen through an attached conductor.

◆ 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: