QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
Public Types | Signals | Public Member Functions | Static Public Member Functions | Public Attributes | 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 (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
 
QString name () const
 
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 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.
 
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:

◆ ~Terminal()

Terminal::~Terminal ( )
override

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

◆ Terminal() [2/2]

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

◆ 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 ( )
private

Terminal::init Methode privee pour initialiser la borne.

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

◆ 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

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