QElectroTech
0.70
|
#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 |
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. 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 |
Diagram * | diagram () const |
Element * | parentElement () 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 |
Element * | parent_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_ |
Terminal * | previous_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 |
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.
anonymous enum |
Enumerator | |
---|---|
Type |
Definition at line 94 of file terminal.h.
Terminal::Terminal | ( | QPointF | pf, |
Qet::Orientation | o, | ||
Element * | e = nullptr |
||
) |
initialise une borne
pf | position du point d'amarrage pour un conducteur |
o | orientation de la borne : Qt::Horizontal ou Qt::Vertical |
e | Element auquel cette borne appartient |
s | Scene sur laquelle figure cette borne |
Definition at line 84 of file terminal.cpp.
References init().
Terminal::Terminal | ( | qreal | pf_x, |
qreal | pf_y, | ||
Qet::Orientation | o, | ||
Element * | e = nullptr |
||
) |
initialise une borne
pf_x | Abscisse du point d'amarrage pour un conducteur |
pf_y | Ordonnee du point d'amarrage pour un conducteur |
o | orientation de la borne : Qt::Horizontal ou Qt::Vertical |
e | Element auquel cette borne appartient |
s | Scene sur laquelle figure cette borne |
Definition at line 103 of file terminal.cpp.
References init().
Terminal::Terminal | ( | QPointF | pf, |
Qet::Orientation | o, | ||
QString | num, | ||
QString | name, | ||
bool | hiddenName, | ||
Element * | e = nullptr |
||
) |
initialise une borne
pf | position du point d'amarrage pour un conducteur |
o | orientation de la borne : Qt::Horizontal ou Qt::Vertical |
num | number of terminal (ex 3 - 4 for NO) |
name | of terminal |
hiddenName | hide or show the name |
e | Element auquel cette borne appartient |
s | Scene sur laquelle figure cette borne |
Definition at line 124 of file terminal.cpp.
|
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_.
|
private |
bool Terminal::addConductor | ( | Conductor * | conductor | ) |
Terminal::addConductor Add a conductor to this terminal.
conductor | : the conductor to add. |
Definition at line 191 of file terminal.cpp.
References conductors_, conductorWasAdded(), Conductor::terminal1, and Conductor::terminal2.
Referenced by Diagram::addItem(), and NewConductorPotentialSelector::NewConductorPotentialSelector().
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.
Definition at line 413 of file terminal.cpp.
References diagram(), dockConductor(), HelpLine(), Qet::isOpposed(), QET::lineContainsPoint(), orientation(), and parent_element_.
Referenced by paint().
|
override |
Definition at line 391 of file terminal.cpp.
References br_, dock_conductor_, and dock_elmt_.
bool Terminal::canBeLinkedTo | ( | Terminal * | other_terminal | ) |
other_terminal |
Definition at line 666 of file terminal.cpp.
References isLinkedTo().
Referenced by mouseMoveEvent(), and mouseReleaseEvent().
QList< Conductor * > Terminal::conductors | ( | ) | const |
Definition at line 677 of file terminal.cpp.
References conductors_.
Referenced by Element::AlignedFreeTerminals(), NewConductorPotentialSelector::getPotential(), paint(), relatedConductors(), Conductor::relatedPotentialConductors(), DeleteQGraphicsItemCommand::setPotentialsOfRemovedElements(), and DeleteQGraphicsItemCommand::terminalInSamePotential().
|
inline |
Definition at line 146 of file terminal.h.
References conductors_.
Referenced by mouseMoveEvent().
|
signal |
Referenced by addConductor(), and DynamicElementTextItem::itemChange().
|
signal |
Referenced by DynamicElementTextItem::itemChange(), and removeConductor().
Diagram * Terminal::diagram | ( | ) | const |
Definition at line 752 of file terminal.cpp.
Referenced by alignedWithTerminal(), Conductor::Conductor(), HelpLine(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and paint().
|
inline |
Definition at line 154 of file terminal.h.
References dock_conductor_.
Referenced by alignedWithTerminal(), HelpLine(), paint(), and Element::parseTerminal().
void Terminal::drawHelpLine | ( | bool | draw = true | ) |
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().
bool Terminal::fromXml | ( | QDomElement & | terminal | ) |
Permet de savoir si un element XML represente cette borne. Attention, l'element XML n'est pas verifie
terminal | Le QDomElement a analyser |
Definition at line 738 of file terminal.cpp.
References dock_elmt_, name_terminal_, name_terminal_hidden, number_terminal_, and ori_.
QLineF Terminal::HelpLine | ( | ) | const |
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().
|
overrideprotected |
Gere l'entree de la souris sur la zone de la Borne.
Definition at line 471 of file terminal.cpp.
References hovered_.
|
overrideprotected |
Gere le fait que la souris sorte de la zone de la Borne.
Definition at line 485 of file terminal.cpp.
References hovered_.
|
overrideprotected |
Gere les mouvements de la souris sur la zone de la Borne.
Definition at line 479 of file terminal.cpp.
|
private |
Methode privee pour initialiser la borne.
pf | position du point d'amarrage pour un conducteur |
o | orientation de la borne : Qt::Horizontal ou Qt::Vertical |
number | of terminal |
name | of 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().
bool Terminal::isLinkedTo | ( | Terminal * | other_terminal | ) |
other_terminal | Autre borne |
Definition at line 647 of file terminal.cpp.
References conductors_.
Referenced by canBeLinkedTo().
|
overrideprotected |
Gere le fait qu'on bouge la souris sur la Borne.
e | L'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.
|
overrideprotected |
Gere le fait qu'on enfonce un bouton de la souris sur la Borne.
e | L'evenement souris correspondant |
Definition at line 494 of file terminal.cpp.
References diagram(), and dock_conductor_.
|
overrideprotected |
e |
Definition at line 564 of file terminal.cpp.
References canBeLinkedTo(), QET::Icons::Conductor, diagram(), hovered_, hovered_color_, neutralColor, ConductorAutoNumerotation::numerate(), previous_terminal_, Conductor::properties, Conductor::relatedPotentialConductors(), and Conductor::sequenceNum.
|
inline |
Definition at line 168 of file terminal.h.
References name_terminal_.
Referenced by init(), setName(), and Terminal().
|
inline |
Definition at line 161 of file terminal.h.
References number_terminal_.
Referenced by init(), and setNumber().
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.
Definition at line 152 of file terminal.cpp.
References ori_.
Referenced by alignedWithTerminal(), HelpLine(), and paint().
|
override |
Fonction de dessin des bornes
p | Le QPainter a utiliser |
options | Les options de dessin |
widget | Le 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().
Element * Terminal::parentElement | ( | ) | const |
Definition at line 759 of file terminal.cpp.
References parent_element_.
Referenced by NewConductorPotentialSelector::getPotential(), relatedPotentialTerminal(), DeleteQGraphicsItemCommand::setPotentialsOfRemovedElements(), and DeleteQGraphicsItemCommand::terminalInSamePotential().
void Terminal::removeConductor | ( | Conductor * | conductor | ) |
Terminal::removeConductor Remove a conductor from this terminal.
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().
void Terminal::setName | ( | QString | name, |
bool | hiddenName | ||
) |
name |
Definition at line 180 of file terminal.cpp.
References name(), name_terminal_, and name_terminal_hidden.
void Terminal::setNumber | ( | QString | number | ) |
number |
Definition at line 172 of file terminal.cpp.
References number(), and number_terminal_.
QDomElement Terminal::toXml | ( | QDomDocument & | doc | ) | const |
Methode d'export en XML
doc | Le Document XML a utiliser pour creer l'element XML |
Definition at line 686 of file terminal.cpp.
References dock_elmt_, name_terminal_, name_terminal_hidden, number_terminal_, and ori_.
|
inlineoverride |
Definition at line 52 of file terminal.h.
References Type.
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().
|
static |
Permet de savoir si un element XML represente une borne
terminal | Le QDomElement a analyser |
Definition at line 702 of file terminal.cpp.
References Qet::East, Qet::North, Qet::South, and Qet::West.
Referenced by Element::fromXml().
|
static |
|
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().
|
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().
|
private |
docking point for conductors
Definition at line 116 of file terminal.h.
Referenced by boundingRect(), dockConductor(), init(), mousePressEvent(), and paint().
|
private |
docking point for parent element
Definition at line 118 of file terminal.h.
Referenced by boundingRect(), fromXml(), init(), paint(), and toXml().
|
static |
color for forbidden actions
Definition at line 106 of file terminal.h.
Referenced by mouseMoveEvent().
|
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().
|
private |
Color used for the hover effect.
Definition at line 132 of file terminal.h.
Referenced by mouseMoveEvent(), mouseReleaseEvent(), and paint().
|
private |
Definition at line 109 of file terminal.h.
Referenced by drawHelpLine(), and paint().
|
private |
Definition at line 110 of file terminal.h.
Referenced by drawHelpLine(), and paint().
|
private |
Definition at line 111 of file terminal.h.
Referenced by drawHelpLine(), and paint().
|
private |
|
private |
|
static |
default color
Definition at line 100 of file terminal.h.
Referenced by mouseMoveEvent(), mouseReleaseEvent(), and PartTerminal::paint().
|
private |
Number of Terminal.
Definition at line 134 of file terminal.h.
Referenced by fromXml(), init(), number(), setNumber(), and toXml().
|
private |
terminal orientation
Definition at line 120 of file terminal.h.
Referenced by fromXml(), init(), orientation(), and toXml().
|
private |
Parent electrical element.
Definition at line 114 of file terminal.h.
Referenced by alignedWithTerminal(), and parentElement().
|
private |
Last terminal seen through an attached conductor.
Definition at line 128 of file terminal.h.
Referenced by init(), mouseMoveEvent(), and mouseReleaseEvent().
|
static |
Definition at line 96 of file terminal.h.
Referenced by init().
|
static |
color for allowed but fuzzy or not recommended actions
Definition at line 104 of file terminal.h.
Referenced by mouseMoveEvent().
|
static |
Definition at line 97 of file terminal.h.
Referenced by Diagram::changeZValue(), and init().