QElectroTech  0.70
terminal.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "terminal.h"
19 
20 #include <utility>
21 #include "diagram.h"
24 #include "diagramcommands.h"
26 #include "conductortextitem.h"
27 
28 QColor Terminal::neutralColor = QColor(Qt::blue);
29 QColor Terminal::allowedColor = QColor(Qt::darkGreen);
30 QColor Terminal::warningColor = QColor("#ff8000");
31 QColor Terminal::forbiddenColor = QColor(Qt::red);
32 const qreal Terminal::terminalSize = 4.0;
33 const qreal Terminal::Z = 1000;
34 
42 void Terminal::init(QPointF pf, Qet::Orientation o, QString number, QString name, bool hiddenName) {
43  // definition du pount d'amarrage pour un conducteur
44  dock_conductor_ = pf;
45 
46  // definition de l'orientation de la borne (par defaut : sud)
47  if (o < Qet::North || o > Qet::West) ori_ = Qet::South;
48  else ori_ = o;
49 
50  // calcul de la position du point d'amarrage a l'element
52  switch(ori_) {
53  case Qet::North: dock_elmt_ += QPointF(0, Terminal::terminalSize); break;
54  case Qet::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
55  case Qet::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
56  case Qet::South:
57  default : dock_elmt_ += QPointF(0, -Terminal::terminalSize);
58  }
59  // Number of terminal
60  number_terminal_ = std::move(number);
61  // Name of terminal
62  name_terminal_ = std::move(name);
63  name_terminal_hidden = hiddenName;
64  // par defaut : pas de conducteur
65 
66  // QRectF null
67  br_ = new QRectF();
68  previous_terminal_ = nullptr;
69  // divers
70  setAcceptHoverEvents(true);
71  setAcceptedMouseButtons(Qt::LeftButton);
72  hovered_ = false;
73  setToolTip(QObject::tr("Borne", "tooltip"));
74  setZValue(Z);
75 }
76 
85  QGraphicsObject(e),
86  m_draw_help_line(false),
87  m_help_line (nullptr),
88  m_help_line_a (nullptr),
89  parent_element_ (e),
90  hovered_color_ (Terminal::neutralColor)
91 {
92  init(pf, o, "_", "_", false);
93 }
94 
103 Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e) :
104  QGraphicsObject(e),
105  m_draw_help_line (false),
106  m_help_line (nullptr),
107  m_help_line_a (nullptr),
108  parent_element_ (e),
109  hovered_color_ (Terminal::neutralColor)
110 {
111  init(QPointF(pf_x, pf_y), o, "_", "_", false);
112 }
113 
124 Terminal::Terminal(QPointF pf, Qet::Orientation o, QString num, QString name, bool hiddenName, Element *e) :
125  QGraphicsObject (e),
126  m_draw_help_line (false),
127  m_help_line (nullptr),
128  m_help_line_a (nullptr),
129  parent_element_ (e),
130  hovered_color_ (Terminal::neutralColor)
131 {
132  init(pf, o, std::move(num), std::move(name), hiddenName);
133 }
134 
141  foreach(Conductor *c, conductors_) delete c;
142  delete br_;
143 }
144 
153  if (Element *elt = qgraphicsitem_cast<Element *>(parentItem())) {
154  // orientations actuelle et par defaut de l'element
155  int ori_cur = elt -> orientation();
156  if (ori_cur == 0) return(ori_);
157  else {
158  // calcul l'angle de rotation implique par l'orientation de l'element parent
159  // angle de rotation de la borne sur la scene, divise par 90
160  int angle = ori_cur + ori_;
161  while (angle >= 4) angle -= 4;
162  return((Qet::Orientation)angle);
163  }
164  } else return(ori_);
165 }
166 
167 
172 void Terminal::setNumber(QString number) {
173  number_terminal_ = std::move(number);
174 }
175 
180 void Terminal::setName(QString name, bool hiddenName) {
181  name_terminal_ = std::move(name);
182  name_terminal_hidden = hiddenName;
183 }
184 
192 {
193  if (!conductor) return(false);
194 
195  Q_ASSERT_X(((conductor -> terminal1 == this) ^ (conductor -> terminal2 == this)), "Terminal::addConductor", "The conductor must be linked exactly once to this terminal");
196 
197  //Get the other terminal where the conductor must be linked
198  Terminal *other_terminal = (conductor -> terminal1 == this) ? conductor->terminal2 : conductor->terminal1;
199 
200  //Check if this terminal isn't already linked with other_terminal
201  foreach (Conductor* cond, conductors_)
202  if (cond -> terminal1 == other_terminal || cond -> terminal2 == other_terminal)
203  return false; //They already a conductor linked to this and other_terminal
204 
205  conductors_.append(conductor);
206  emit conductorWasAdded(conductor);
207  return(true);
208 }
209 
216 {
217  int index = conductors_.indexOf(conductor);
218  if (index == -1) return;
219  conductors_.removeAt(index);
220  emit conductorWasRemoved(conductor);
221 }
222 
229 void Terminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, QWidget *) {
230  // en dessous d'un certain zoom, les bornes ne sont plus dessinees
231  if (options && options -> levelOfDetail < 0.5) return;
232 
233  p -> save();
234 
235  //annulation des renderhints
236  p -> setRenderHint(QPainter::Antialiasing, false);
237  p -> setRenderHint(QPainter::TextAntialiasing, false);
238  p -> setRenderHint(QPainter::SmoothPixmapTransform, false);
239 
240  // on travaille avec les coordonnees de l'element parent
241  QPointF c = mapFromParent(dock_conductor_);
242  QPointF e = mapFromParent(dock_elmt_);
243 
244  QPen t;
245  t.setWidthF(1.0);
246 
247  if (options && options -> levelOfDetail < 1.0) {
248  t.setCosmetic(true);
249  }
250 
251  // dessin de la borne en rouge
252  t.setColor(Qt::red);
253  p -> setPen(t);
254  p -> drawLine(c, e);
255 
256  // dessin du point d'amarrage au conducteur en bleu
257  t.setColor(hovered_color_);
258  p -> setPen(t);
259  p -> setBrush(hovered_color_);
260  if (hovered_) {
261  p -> setRenderHint(QPainter::Antialiasing, true);
262  p -> drawEllipse(QRectF(c.x() - 2.5, c.y() - 2.5, 5.0, 5.0));
263  } else p -> drawPoint(c);
264 
265  //Draw help line if needed,
266  if (diagram() && m_draw_help_line)
267  {
268  //Draw the help line with same orientation of terminal
269  //Only if there isn't docked conductor
270  if (conductors().isEmpty())
271  {
272  if (!m_help_line)
273  m_help_line = new QGraphicsLineItem(this);
274  QPen pen;
275  pen.setColor(Qt::darkBlue);
276 
277  QLineF line(HelpLine());
278 
279  if (diagram() -> project() -> autoConductor())
280  {
282  if (t)
283  {
284  line.setP2(t -> dockConductor());
285  pen.setColor(Qt::darkGreen);
286  }
287  }
288 
289  //Map the line (in scene coordinate) to m_help_line coordinate
290  line.setP1(m_help_line -> mapFromScene(line.p1()));
291  line.setP2(m_help_line -> mapFromScene(line.p2()));
292  m_help_line -> setPen(pen);
293  m_help_line -> setLine(line);
294  }
295 
296  //Draw the help line perpendicular to the terminal
297  if (!m_help_line_a)
298  {
299  m_help_line_a = new QGraphicsLineItem(this);
300  QPen pen;
301  pen.setColor(Diagram::background_color == Qt::darkGray ? Qt::lightGray : Qt::darkGray);
302  m_help_line_a -> setPen(pen);
303  }
304 
305  QRectF rect = diagram() -> border_and_titleblock.insideBorderRect();
306  QLineF line;
307 
309  {
310  line.setP1(QPointF(dockConductor().x(), rect.topLeft().y()));
311  line.setP2(QPointF(dockConductor().x(), rect.bottomLeft().y()));
312  }
313  else
314  {
315  line.setP1(QPointF(rect.topLeft().x(), dockConductor().y()));
316  line.setP2(QPointF(rect.topRight().x(), dockConductor().y()));
317  }
318 
319  //Map the line (in scene coordinate) to m_help_line_a coordinate
320  line.setP1(m_help_line_a -> mapFromScene(line.p1()));
321  line.setP2(m_help_line_a -> mapFromScene(line.p2()));
322  m_help_line_a -> setLine(line);
323  }
324 
325  p -> restore();
326 }
327 
333 void Terminal::drawHelpLine(bool draw)
334 {
335  if (m_draw_help_line == draw) return;
336 
337  m_draw_help_line = draw;
338 
339  if (!draw)
340  {
341  if (m_help_line)
342  {
343  delete m_help_line;
344  m_help_line = nullptr;
345  }
346  if (m_help_line_a)
347  {
348  delete m_help_line_a;
349  m_help_line_a = nullptr;
350  }
351  }
352 }
353 
360 QLineF Terminal::HelpLine() const
361 {
362  QPointF scene_dock = dockConductor();
363  QRectF rect = diagram() -> border_and_titleblock.insideBorderRect();
364 
365  QLineF line(scene_dock , QPointF());
366 
367  //Set te second point of line to the edge of diagram,
368  //according with the orientation of this terminal
369  switch (orientation())
370  {
371  case Qet::North:
372  line.setP2(QPointF(scene_dock.x(), rect.top()));
373  break;
374  case Qet::East:
375  line.setP2(QPointF(rect.right() , scene_dock.y()));
376  break;
377  case Qet::South:
378  line.setP2(QPointF(scene_dock.x(), rect.bottom()));
379  break;
380  case Qet::West:
381  line.setP2(QPointF(rect.left(), scene_dock.y()));
382  break;
383  }
384 
385  return line;
386 }
387 
391 QRectF Terminal::boundingRect() const {
392  if (br_ -> isNull()) {
393  qreal dcx = dock_conductor_.x();
394  qreal dcy = dock_conductor_.y();
395  qreal dex = dock_elmt_.x();
396  qreal dey = dock_elmt_.y();
397  QPointF origin = (dcx <= dex && dcy <= dey ? dock_conductor_ : dock_elmt_);
398  origin += QPointF(-3.0, -3.0);
399  qreal w = qAbs((int)(dcx - dex)) + 7;
400  qreal h = qAbs((int)(dcy - dey)) + 7;
401  *br_ = QRectF(origin, QSizeF(w, h));
402  }
403  return(*br_);
404 }
405 
414 {
415  QLineF line(HelpLine());
416 
417  QPainterPath path;
418  path.moveTo(line.p1());
419  path.lineTo(line.p2());
420 
421  //Get all QGraphicsItem in the alignement of this terminal
422  QList <QGraphicsItem *> qgi_list = diagram() -> items(path);
423 
424  //Remove all terminals of the parent element
425  foreach (Terminal *t, parent_element_ -> terminals())
426  qgi_list.removeAll(t);
427 
428  if (qgi_list.isEmpty()) return nullptr;
429 
430  //Get terminals only if orientation is opposed with this terminal
431  QList <Terminal *> available_terminals;
432  foreach (QGraphicsItem *qgi, qgi_list)
433  {
434  if (Terminal *tt = qgraphicsitem_cast <Terminal *> (qgi))
435  {
436  //Call QET::lineContainsPoint to be sure the line intersect
437  //the dock point and not an other part of terminal
438  if (Qet::isOpposed(orientation(), tt -> orientation()) &&
439  QET::lineContainsPoint(line, tt -> dockConductor()))
440  {
441  available_terminals << tt;
442  }
443  }
444  }
445 
446  if (available_terminals.isEmpty()) return nullptr;
447  if (available_terminals.size() == 1) return (available_terminals.first());
448 
449  //Available_terminals have several terminals, we get the nearest terminal
450  line.setP2(available_terminals.first() -> dockConductor());
451  qreal current_lenght = line.length();
452  Terminal *nearest_terminal = available_terminals.takeFirst();
453 
454  //Search the nearest terminal to this one
455  foreach (Terminal *terminal, available_terminals)
456  {
457  line.setP2(terminal -> dockConductor());
458  if (line.length() < current_lenght)
459  {
460  current_lenght = line.length();
461  nearest_terminal = terminal;
462  }
463  }
464 
465  return nearest_terminal;
466 }
467 
471 void Terminal::hoverEnterEvent(QGraphicsSceneHoverEvent *) {
472  hovered_ = true;
473  update();
474 }
475 
479 void Terminal::hoverMoveEvent(QGraphicsSceneHoverEvent *) {
480 }
481 
485 void Terminal::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
486  hovered_ = false;
487  update();
488 }
489 
494 void Terminal::mousePressEvent(QGraphicsSceneMouseEvent *e) {
495  if (Diagram *d = diagram()) {
496  d -> setConductorStart(mapToScene(QPointF(dock_conductor_)));
497  d -> setConductorStop(e -> scenePos());
498  d -> setConductor(true);
499  //setCursor(Qt::CrossCursor);
500  }
501 }
502 
507 void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
508  // pendant la pose d'un conducteur, on adopte un autre curseur
509  //setCursor(Qt::CrossCursor);
510 
511  // d'un mouvement a l'autre, il faut retirer l'effet hover de la borne precedente
512  if (previous_terminal_) {
513  if (previous_terminal_ == this) hovered_ = true;
514  else previous_terminal_ -> hovered_ = false;
516  previous_terminal_ -> update();
517  }
518 
519 
520  Diagram *d = diagram();
521  if (!d) return;
522  // si la scene est un Diagram, on actualise le poseur de conducteur
523  d -> setConductorStop(e -> scenePos());
524 
525  // on recupere la liste des qgi sous le pointeur
526  QList<QGraphicsItem *> qgis = d -> items(e -> scenePos());
527 
528  /* le qgi le plus haut
529  = le poseur de conductor
530  = le premier element de la liste
531  = la liste ne peut etre vide
532  = on prend le deuxieme element de la liste
533  */
534  Q_ASSERT_X(!(qgis.isEmpty()), "Terminal::mouseMoveEvent", "La liste d'items ne devrait pas etre vide");
535 
536  // s'il n'y rien d'autre que le poseur de conducteur dans la liste, on arrete la
537  if (qgis.size() <= 1) return;
538 
539  // sinon on prend le deuxieme element de la liste et on verifie s'il s'agit d'une borne
540  QGraphicsItem *qgi = qgis.at(1);
541  // si le qgi est une borne...
542  Terminal *other_terminal = qgraphicsitem_cast<Terminal *>(qgi);
543  if (!other_terminal) return;
544  previous_terminal_ = other_terminal;
545 
546  // s'il s'agit d'une borne, on lui applique l'effet hover approprie
547  if (!canBeLinkedTo(other_terminal)) {
548  other_terminal -> hovered_color_ = forbiddenColor;
549  } else if (other_terminal -> conductorsCount()) {
550  other_terminal -> hovered_color_ = warningColor;
551  } else {
552  other_terminal -> hovered_color_ = allowedColor;
553  }
554 
555  other_terminal -> hovered_ = true;
556  other_terminal -> update();
557 }
558 
559 
564 void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
565 {
566  previous_terminal_ = nullptr;
568 
569  if (!diagram()) return;
570 
571  //Stop conductor preview
572  diagram() -> setConductor(false);
573 
574  //Get item under cursor
575  QGraphicsItem *qgi = diagram() -> itemAt(e -> scenePos(), QTransform());
576  if (!qgi) return;
577 
578  //Element must be a terminal
579  Terminal *other_terminal = qgraphicsitem_cast<Terminal *>(qgi);
580  if (!other_terminal) return;
581 
582  other_terminal -> hovered_color_ = neutralColor;
583  other_terminal -> hovered_ = false;
584 
585  //We stop her if we can't link this terminal with other terminal
586  if (!canBeLinkedTo(other_terminal)) return;
587 
588  //Create conductor
589  Conductor *new_conductor = new Conductor(this, other_terminal);
590 
591  //Get all conductors at the same potential of new conductors
592  QSet <Conductor *> conductors_list = new_conductor->relatedPotentialConductors();
593 
594  //Compare the properties of every conductors stored in conductors_list,
595  //if every conductors properties is equal, we use this properties for the new conductor.
596  ConductorProperties others_properties;
597  bool use_properties = false;
598  if (!conductors_list.isEmpty())
599  {
600  use_properties = true;
601  others_properties = (*conductors_list.begin())->properties();
602  foreach (Conductor *conductor, conductors_list) {
603  if (conductor->properties() != others_properties)
604  use_properties = false;
605  }
606  }
607 
608 
609  QUndoCommand *undo = new QUndoCommand();
610  QUndoCommand *aic = new AddItemCommand<Conductor *>(new_conductor, diagram(), QPointF(), undo);
611  undo->setText(aic->text());
612 
613  if (use_properties)
614  {
615  Conductor *other = conductors_list.toList().first();
616  new_conductor->rSequenceNum() = other->sequenceNum();
617  new_conductor->setProperties(others_properties);
618  }
619  else
620  {
621  //Autonum it
622  ConductorAutoNumerotation can (new_conductor, diagram(), undo);
623  can.numerate();
624  }
625  //Add undo command to the parent diagram
626  diagram() -> undoStack().push(undo);
627  if (use_properties)
628  {
629  Conductor *other = conductors_list.toList().first();
630  new_conductor->setProperties(other->properties());
631  }
632 }
633 
639  foreach (Conductor *conductor, conductors_)
640  conductor->updatePath();
641 }
642 
647 bool Terminal::isLinkedTo(Terminal *other_terminal) {
648  if (other_terminal == this) return(false);
649 
650  bool already_linked = false;
651  foreach (Conductor *c, conductors_) {
652  if (c -> terminal1 == other_terminal || c -> terminal2 == other_terminal) {
653  already_linked = true;
654  break;
655  }
656  }
657  return(already_linked);
658 }
659 
666 bool Terminal::canBeLinkedTo(Terminal *other_terminal)
667 {
668  if (other_terminal == this || isLinkedTo(other_terminal))
669  return false;
670 
671  return true;
672 }
673 
677 QList<Conductor *> Terminal::conductors() const {
678  return(conductors_);
679 }
680 
686 QDomElement Terminal::toXml(QDomDocument &doc) const {
687  QDomElement qdo = doc.createElement("terminal");
688  qdo.setAttribute("x", QString("%1").arg(dock_elmt_.x()));
689  qdo.setAttribute("y", QString("%1").arg(dock_elmt_.y()));
690  qdo.setAttribute("orientation", ori_);
691  qdo.setAttribute("number", number_terminal_);
692  qdo.setAttribute("name", name_terminal_);
693  qdo.setAttribute("nameHidden", name_terminal_hidden);
694  return(qdo);
695 }
696 
702 bool Terminal::valideXml(QDomElement &terminal) {
703  // verifie le nom du tag
704  if (terminal.tagName() != "terminal") return(false);
705 
706  // verifie la presence des attributs minimaux
707  if (!terminal.hasAttribute("x")) return(false);
708  if (!terminal.hasAttribute("y")) return(false);
709  if (!terminal.hasAttribute("orientation")) return(false);
710 
711  bool conv_ok;
712  // parse l'abscisse
713  terminal.attribute("x").toDouble(&conv_ok);
714  if (!conv_ok) return(false);
715 
716  // parse l'ordonnee
717  terminal.attribute("y").toDouble(&conv_ok);
718  if (!conv_ok) return(false);
719 
720  // parse l'id
721  terminal.attribute("id").toInt(&conv_ok);
722  if (!conv_ok) return(false);
723 
724  // parse l'orientation
725  int terminal_or = terminal.attribute("orientation").toInt(&conv_ok);
726  if (!conv_ok) return(false);
727  if (terminal_or != Qet::North && terminal_or != Qet::South && terminal_or != Qet::East && terminal_or != Qet::West) return(false);
728 
729  // a ce stade, la borne est syntaxiquement correcte
730  return(true);
731 }
732 
738 bool Terminal::fromXml(QDomElement &terminal) {
739  number_terminal_ = terminal.attribute("number");
740  name_terminal_ = terminal.attribute("name");
741  name_terminal_hidden = terminal.attribute("nameHidden").toInt();
742  return (
743  qFuzzyCompare(terminal.attribute("x").toDouble(), dock_elmt_.x()) &&
744  qFuzzyCompare(terminal.attribute("y").toDouble(), dock_elmt_.y()) &&
745  (terminal.attribute("orientation").toInt() == ori_)
746  );
747 }
748 
753  return(qobject_cast<Diagram *>(scene()));
754 }
755 
760  return(parent_element_);
761 }
762 
774 QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal, const bool all_diagram)
775 {
776  // If terminal parent element is a folio report.
777  if (all_diagram && terminal -> parentElement() -> linkType() & Element::AllReport)
778  {
779  QList <Element *> elmt_list = terminal -> parentElement() -> linkedElements();
780  if (!elmt_list.isEmpty())
781  {
782  return (elmt_list.first()->terminals());
783  }
784  }
785  // If terminal parent element is a Terminal element.
786  else if (terminal -> parentElement() -> linkType() & Element::Terminale)
787  {
788  QList <Terminal *> terminals = terminal->parentElement()->terminals();
789  terminals.removeAll(const_cast<Terminal *>(terminal));
790  return terminals;
791  }
792 
793  return QList<Terminal *>();
794 }
795 
bool m_draw_help_line
Definition: terminal.h:109
static QColor forbiddenColor
color for forbidden actions
Definition: terminal.h:106
QList< Conductor * > conductors() const
Definition: terminal.cpp:677
ConductorProperties properties
Conductor::properties.
Definition: conductor.h:48
static QColor allowedColor
color for legal actions
Definition: terminal.h:102
QPointF dock_elmt_
docking point for parent element
Definition: terminal.h:118
bool addConductor(Conductor *conductor)
Terminal::addConductor Add a conductor to this terminal.
Definition: terminal.cpp:191
bool isLinkedTo(Terminal *)
Definition: terminal.cpp:647
QColor hovered_color_
Color used for the hover effect.
Definition: terminal.h:132
int conductorsCount() const
Definition: terminal.h:146
Definition: qet.h:207
Terminal(QPointF, Qet::Orientation, Element *=nullptr)
Definition: terminal.cpp:84
static bool isHorizontal(Qet::Orientation)
Qet::isHorizontal.
Definition: qet.cpp:106
QSet< Conductor * > relatedPotentialConductors(const bool all_diagram=true, QList< Terminal *> *t_list=nullptr)
Conductor::relatedPotentialConductors Return all conductors at the same potential of this conductor...
Definition: conductor.cpp:1603
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override
Terminal::mouseReleaseEvent.
Definition: terminal.cpp:564
void mousePressEvent(QGraphicsSceneMouseEvent *) override
Definition: terminal.cpp:494
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override
Definition: terminal.cpp:471
static const qreal terminalSize
Definition: terminal.h:96
Terminal * alignedWithTerminal() const
Terminal::alignedWithTerminal If this terminal is aligned with an other terminal and is orientation i...
Definition: terminal.cpp:413
void init(QPointF, Qet::Orientation, QString number, QString name, bool hiddenName)
Definition: terminal.cpp:42
QList< Terminal * > relatedPotentialTerminal(const Terminal *terminal, const bool all_diagram)
Conductor::relatedPotentialTerminal Return terminal at the same potential from the same parent elemen...
Definition: terminal.cpp:774
autonum::sequentialNumbers sequenceNum
Definition: conductor.h:49
The AddItemCommand class This command add an item in a diagram The item to add is template...
static const qreal Z
Definition: terminal.h:97
void conductorWasAdded(Conductor *conductor)
QDomElement toXml(QDomDocument &) const
Definition: terminal.cpp:686
QString number_terminal_
Number of Terminal.
Definition: terminal.h:134
static bool valideXml(QDomElement &)
Definition: terminal.cpp:702
Terminal * terminal2
Definition: conductor.h:68
Element * parentElement() const
Definition: terminal.cpp:759
QIcon Conductor
Definition: qeticons.cpp:35
QString number() const
Definition: terminal.h:161
bool hovered_
Whether the mouse pointer is hovering the terminal.
Definition: terminal.h:130
QRectF boundingRect() const override
Definition: terminal.cpp:391
void setNumber(QString number)
Terminal::setNumber.
Definition: terminal.cpp:172
QList< Terminal * > terminals() const
Element::terminals.
Definition: element.cpp:124
QLineF HelpLine() const
Terminal::HelpLine.
Definition: terminal.cpp:360
Terminal * previous_terminal_
Last terminal seen through an attached conductor.
Definition: terminal.h:128
static bool isOpposed(Qet::Orientation a, Qet::Orientation b)
Qet::isOpposed.
Definition: qet.cpp:76
QRectF * br_
Definition: terminal.h:126
Terminal * terminal1
Definition: conductor.h:67
QPointF dockConductor() const
Definition: terminal.h:154
void numerate()
ConductorAutoNumerotation::numerate execute the automatic numerotation.
QIcon tr
Definition: qeticons.cpp:204
Qet::Orientation ori_
terminal orientation
Definition: terminal.h:120
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override
Definition: terminal.cpp:229
bool canBeLinkedTo(Terminal *)
Terminal::canBeLinkedTo.
Definition: terminal.cpp:666
bool name_terminal_hidden
Definition: terminal.h:137
QGraphicsLineItem * m_help_line_a
Definition: terminal.h:111
Definition: qet.h:205
static QColor neutralColor
default color
Definition: terminal.h:100
QGraphicsLineItem * m_help_line
Definition: terminal.h:110
QString name() const
Definition: terminal.h:168
static QColor background_color
background color of diagram
Definition: diagram.h:91
QList< Conductor * > conductors_
List of conductors attached to the terminal.
Definition: terminal.h:122
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override
Definition: terminal.cpp:485
~Terminal() override
Definition: terminal.cpp:140
void updateConductor()
Terminal::updateConductor Update the path of conductor docked to this terminal.
Definition: terminal.cpp:638
bool fromXml(QDomElement &)
Definition: terminal.cpp:738
void removeConductor(Conductor *conductor)
Terminal::removeConductor Remove a conductor from this terminal.
Definition: terminal.cpp:215
Element * parent_element_
Parent electrical element.
Definition: terminal.h:114
bool lineContainsPoint(const QLineF &, const QPointF &)
Definition: qet.cpp:149
void conductorWasRemoved(Conductor *conductor)
QPointF dock_conductor_
docking point for conductors
Definition: terminal.h:116
QString name_terminal_
Name of Terminal.
Definition: terminal.h:136
Qet::Orientation orientation() const
Definition: terminal.cpp:152
static QColor warningColor
color for allowed but fuzzy or not recommended actions
Definition: terminal.h:104
void mouseMoveEvent(QGraphicsSceneMouseEvent *) override
Definition: terminal.cpp:507
void setName(QString name, bool hiddenName)
Terminal::setName.
Definition: terminal.cpp:180
void updatePath(const QRectF &=QRectF())
Definition: conductor.cpp:159
Diagram * diagram() const
Definition: terminal.cpp:752
void drawHelpLine(bool draw=true)
Terminal::drawHelpLine.
Definition: terminal.cpp:333
void hoverMoveEvent(QGraphicsSceneHoverEvent *) override
Definition: terminal.cpp:479
Orientation
Orientation (used for electrical elements and their terminals)
Definition: qet.h:204