QElectroTech  0.70
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

#include <terminal.h>

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 (QPointF, Qet::Orientation, QString number, QString name, bool hiddenName, Element *=nullptr)
 
 ~Terminal () override
 
int type () const override
 
void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override
 
void drawHelpLine (bool draw=true)
 Terminal::drawHelpLine. More...
 
QLineF HelpLine () const
 Terminal::HelpLine. More...
 
QRectF boundingRect () const override
 
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
 
Diagramdiagram () const
 
ElementparentElement () const
 
QList< Conductor * > conductors () const
 
Qet::Orientation orientation () const
 
QPointF dockConductor () const
 
QString number () const
 
QString name () const
 
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 *)
 
bool canBeLinkedTo (Terminal *)
 Terminal::canBeLinkedTo. More...
 
bool fromXml (QDomElement &)
 
QDomElement toXml (QDomDocument &) const
 

Static Public Member Functions

static bool valideXml (QDomElement &)
 

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
 
void hoverMoveEvent (QGraphicsSceneHoverEvent *) override
 
void hoverLeaveEvent (QGraphicsSceneHoverEvent *) override
 
void mousePressEvent (QGraphicsSceneMouseEvent *) override
 
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *) override
 Terminal::mouseReleaseEvent. More...
 

Private Member Functions

 Terminal (const Terminal &)
 
void init (QPointF, Qet::Orientation, QString number, QString name, bool hiddenName)
 

Private Attributes

bool m_draw_help_line
 
QGraphicsLineItem * m_help_line
 
QGraphicsLineItem * m_help_line_a
 
Elementparent_element_
 Parent electrical element. More...
 
QPointF dock_conductor_
 docking point for conductors More...
 
QPointF dock_elmt_
 docking point for parent element More...
 
Qet::Orientation ori_
 terminal orientation More...
 
QList< Conductor * > conductors_
 List of conductors attached to the terminal. More...
 
QRectF * br_
 
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

This class represents a terminal of an electrical element, i.e. a possible plug point for conductors.

Definition at line 30 of file terminal.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Definition at line 94 of file terminal.h.

Constructor & Destructor Documentation

◆ Terminal() [1/4]

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
sScene sur laquelle figure cette borne

Definition at line 84 of file terminal.cpp.

References init().

◆ Terminal() [2/4]

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
sScene sur laquelle figure cette borne

Definition at line 103 of file terminal.cpp.

References init().

◆ Terminal() [3/4]

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
sScene sur laquelle figure cette borne

Definition at line 124 of file terminal.cpp.

References init(), and name().

◆ ~Terminal()

Terminal::~Terminal ( )
override

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

Definition at line 140 of file terminal.cpp.

References br_, and conductors_.

◆ Terminal() [4/4]

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

Definition at line 191 of file terminal.cpp.

References conductors_, conductorWasAdded(), Conductor::terminal1, and Conductor::terminal2.

Referenced by Diagram::addItem(), and NewConductorPotentialSelector::NewConductorPotentialSelector().

◆ 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

Definition at line 413 of file terminal.cpp.

References diagram(), dockConductor(), HelpLine(), Qet::isOpposed(), QET::lineContainsPoint(), orientation(), and parent_element_.

Referenced by paint().

◆ boundingRect()

QRectF Terminal::boundingRect ( ) const
override
Returns
Le rectangle (en precision flottante) delimitant la borne et ses alentours.

Definition at line 391 of file terminal.cpp.

References br_, dock_conductor_, and dock_elmt_.

◆ canBeLinkedTo()

bool Terminal::canBeLinkedTo ( Terminal other_terminal)

Terminal::canBeLinkedTo.

Parameters
other_terminal
Returns
true if this terminal can be linked to , otherwise false

Definition at line 666 of file terminal.cpp.

References isLinkedTo().

Referenced by mouseMoveEvent(), and mouseReleaseEvent().

◆ conductors()

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

◆ conductorsCount()

int Terminal::conductorsCount ( ) const
inline
Returns
the number of conductors attached to the terminal.

Definition at line 146 of file terminal.h.

References conductors_.

Referenced by mouseMoveEvent().

◆ conductorWasAdded

void Terminal::conductorWasAdded ( Conductor conductor)
signal

◆ conductorWasRemoved

void Terminal::conductorWasRemoved ( Conductor conductor)
signal

◆ diagram()

Diagram * Terminal::diagram ( ) const
Returns
le Diagram auquel cette borne appartient, ou 0 si cette borne est independant

Definition at line 752 of file terminal.cpp.

Referenced by alignedWithTerminal(), Conductor::Conductor(), HelpLine(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and paint().

◆ dockConductor()

QPointF Terminal::dockConductor ( ) const
inline
Returns
the position, relative to the scene, of the docking point for conductors.

Definition at line 154 of file terminal.h.

References dock_conductor_.

Referenced by alignedWithTerminal(), HelpLine(), paint(), and Element::parseTerminal().

◆ drawHelpLine()

void Terminal::drawHelpLine ( bool  draw = true)

Terminal::drawHelpLine.

Parameters
draw: true, display the help line false, hide it.

Definition at line 333 of file terminal.cpp.

References m_draw_help_line, m_help_line, and m_help_line_a.

Referenced by Element::displayHelpLine().

◆ fromXml()

bool Terminal::fromXml ( QDomElement &  terminal)

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

Definition at line 738 of file terminal.cpp.

References dock_elmt_, name_terminal_, name_terminal_hidden, number_terminal_, and ori_.

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

Definition at line 360 of file terminal.cpp.

References diagram(), dockConductor(), Qet::East, Qet::North, orientation(), Qet::South, and Qet::West.

Referenced by alignedWithTerminal(), and paint().

◆ hoverEnterEvent()

void Terminal::hoverEnterEvent ( QGraphicsSceneHoverEvent *  )
overrideprotected

Gere l'entree de la souris sur la zone de la Borne.

Definition at line 471 of file terminal.cpp.

References hovered_.

◆ hoverLeaveEvent()

void Terminal::hoverLeaveEvent ( QGraphicsSceneHoverEvent *  )
overrideprotected

Gere le fait que la souris sorte de la zone de la Borne.

Definition at line 485 of file terminal.cpp.

References hovered_.

◆ hoverMoveEvent()

void Terminal::hoverMoveEvent ( QGraphicsSceneHoverEvent *  )
overrideprotected

Gere les mouvements de la souris sur la zone de la Borne.

Definition at line 479 of file terminal.cpp.

◆ init()

void Terminal::init ( QPointF  pf,
Qet::Orientation  o,
QString  number,
QString  name,
bool  hiddenName 
)
private

Methode privee pour initialiser la borne.

Parameters
pfposition du point d'amarrage pour un conducteur
oorientation de la borne : Qt::Horizontal ou Qt::Vertical
numberof terminal
nameof terminal

Definition at line 42 of file terminal.cpp.

References br_, dock_conductor_, dock_elmt_, Qet::East, hovered_, name(), name_terminal_, name_terminal_hidden, Qet::North, number(), number_terminal_, ori_, previous_terminal_, Qet::South, terminalSize, QET::Icons::tr, Qet::West, and Z.

Referenced by Terminal().

◆ isLinkedTo()

bool Terminal::isLinkedTo ( Terminal other_terminal)
Parameters
other_terminalAutre borne
Returns
true si cette borne est reliee a other_terminal, false sion

Definition at line 647 of file terminal.cpp.

References conductors_.

Referenced by canBeLinkedTo().

◆ mouseMoveEvent()

void Terminal::mouseMoveEvent ( QGraphicsSceneMouseEvent *  e)
overrideprotected

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

Parameters
eL'evenement souris correspondant

Definition at line 507 of file terminal.cpp.

References allowedColor, canBeLinkedTo(), conductorsCount(), diagram(), forbiddenColor, hovered_, hovered_color_, neutralColor, previous_terminal_, and warningColor.

◆ mousePressEvent()

void Terminal::mousePressEvent ( QGraphicsSceneMouseEvent *  e)
overrideprotected

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

Parameters
eL'evenement souris correspondant

Definition at line 494 of file terminal.cpp.

References diagram(), and dock_conductor_.

◆ mouseReleaseEvent()

void Terminal::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  e)
overrideprotected

◆ name()

QString Terminal::name ( ) const
inline
Returns
the name of terminal.

Definition at line 168 of file terminal.h.

References name_terminal_.

Referenced by init(), setName(), and Terminal().

◆ number()

QString Terminal::number ( ) const
inline
Returns
the number of terminal.

Definition at line 161 of file terminal.h.

References number_terminal_.

Referenced by init(), and setNumber().

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

Definition at line 152 of file terminal.cpp.

References ori_.

Referenced by alignedWithTerminal(), HelpLine(), and paint().

◆ paint()

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

Fonction de dessin des bornes

Parameters
pLe QPainter a utiliser
optionsLes options de dessin
widgetLe widget sur lequel on dessine

Definition at line 229 of file terminal.cpp.

References alignedWithTerminal(), Diagram::background_color, conductors(), diagram(), dock_conductor_, dock_elmt_, dockConductor(), HelpLine(), hovered_, hovered_color_, Qet::isHorizontal(), m_draw_help_line, m_help_line, m_help_line_a, and orientation().

◆ parentElement()

Element * Terminal::parentElement ( ) const

◆ removeConductor()

void Terminal::removeConductor ( Conductor conductor)

Terminal::removeConductor Remove a conductor from this terminal.

Parameters
conductor: conductor to remove

Definition at line 215 of file terminal.cpp.

References conductors_, and conductorWasRemoved().

Referenced by NewConductorPotentialSelector::NewConductorPotentialSelector(), Diagram::removeItem(), and Conductor::~Conductor().

◆ setName()

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

Terminal::setName.

Parameters
name

Definition at line 180 of file terminal.cpp.

References name(), name_terminal_, and name_terminal_hidden.

◆ setNumber()

void Terminal::setNumber ( QString  number)

Terminal::setNumber.

Parameters
number

Definition at line 172 of file terminal.cpp.

References number(), and number_terminal_.

◆ toXml()

QDomElement Terminal::toXml ( QDomDocument &  doc) const

Methode d'export en XML

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

Definition at line 686 of file terminal.cpp.

References dock_elmt_, name_terminal_, name_terminal_hidden, number_terminal_, and ori_.

◆ type()

int Terminal::type ( ) const
inlineoverride

Definition at line 52 of file terminal.h.

References Type.

◆ updateConductor()

void Terminal::updateConductor ( )

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

Definition at line 638 of file terminal.cpp.

References conductors_, and Conductor::updatePath().

◆ valideXml()

bool Terminal::valideXml ( QDomElement &  terminal)
static

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

Definition at line 702 of file terminal.cpp.

References Qet::East, Qet::North, Qet::South, and Qet::West.

Referenced by Element::fromXml().

Member Data Documentation

◆ allowedColor

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

color for legal actions

Definition at line 102 of file terminal.h.

Referenced by mouseMoveEvent().

◆ br_

QRectF* Terminal::br_
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.

Definition at line 126 of file terminal.h.

Referenced by boundingRect(), init(), and ~Terminal().

◆ conductors_

QList<Conductor *> Terminal::conductors_
private

List of conductors attached to the terminal.

Definition at line 122 of file terminal.h.

Referenced by addConductor(), conductors(), conductorsCount(), isLinkedTo(), removeConductor(), updateConductor(), and ~Terminal().

◆ dock_conductor_

QPointF Terminal::dock_conductor_
private

docking point for conductors

Definition at line 116 of file terminal.h.

Referenced by boundingRect(), dockConductor(), init(), mousePressEvent(), and paint().

◆ dock_elmt_

QPointF Terminal::dock_elmt_
private

docking point for parent element

Definition at line 118 of file terminal.h.

Referenced by boundingRect(), fromXml(), init(), paint(), and toXml().

◆ forbiddenColor

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

color for forbidden actions

Definition at line 106 of file terminal.h.

Referenced by mouseMoveEvent().

◆ hovered_

bool Terminal::hovered_
private

Whether the mouse pointer is hovering the terminal.

Definition at line 130 of file terminal.h.

Referenced by hoverEnterEvent(), hoverLeaveEvent(), init(), mouseMoveEvent(), mouseReleaseEvent(), and paint().

◆ hovered_color_

QColor Terminal::hovered_color_
private

Color used for the hover effect.

Definition at line 132 of file terminal.h.

Referenced by mouseMoveEvent(), mouseReleaseEvent(), and paint().

◆ m_draw_help_line

bool Terminal::m_draw_help_line
private

Definition at line 109 of file terminal.h.

Referenced by drawHelpLine(), and paint().

◆ m_help_line

QGraphicsLineItem* Terminal::m_help_line
private

Definition at line 110 of file terminal.h.

Referenced by drawHelpLine(), and paint().

◆ m_help_line_a

QGraphicsLineItem* Terminal::m_help_line_a
private

Definition at line 111 of file terminal.h.

Referenced by drawHelpLine(), and paint().

◆ name_terminal_

QString Terminal::name_terminal_
private

Name of Terminal.

Definition at line 136 of file terminal.h.

Referenced by fromXml(), init(), name(), setName(), and toXml().

◆ name_terminal_hidden

bool Terminal::name_terminal_hidden
private

Definition at line 137 of file terminal.h.

Referenced by fromXml(), init(), setName(), and toXml().

◆ neutralColor

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

default color

Definition at line 100 of file terminal.h.

Referenced by mouseMoveEvent(), mouseReleaseEvent(), and PartTerminal::paint().

◆ number_terminal_

QString Terminal::number_terminal_
private

Number of Terminal.

Definition at line 134 of file terminal.h.

Referenced by fromXml(), init(), number(), setNumber(), and toXml().

◆ ori_

Qet::Orientation Terminal::ori_
private

terminal orientation

Definition at line 120 of file terminal.h.

Referenced by fromXml(), init(), orientation(), and toXml().

◆ parent_element_

Element* Terminal::parent_element_
private

Parent electrical element.

Definition at line 114 of file terminal.h.

Referenced by alignedWithTerminal(), and parentElement().

◆ previous_terminal_

Terminal* Terminal::previous_terminal_
private

Last terminal seen through an attached conductor.

Definition at line 128 of file terminal.h.

Referenced by init(), mouseMoveEvent(), and mouseReleaseEvent().

◆ terminalSize

const qreal Terminal::terminalSize = 4.0
static

Definition at line 96 of file terminal.h.

Referenced by init().

◆ warningColor

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

color for allowed but fuzzy or not recommended actions

Definition at line 104 of file terminal.h.

Referenced by mouseMoveEvent().

◆ Z

const qreal Terminal::Z = 1000
static

Definition at line 97 of file terminal.h.

Referenced by Diagram::changeZValue(), and init().


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