mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 22:00:35 +01:00
Depoussierage de la classe Terminal
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@957 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -77,7 +77,7 @@ Conductor::Conductor(Terminal *p1, Terminal* p2, Diagram *parent_diagram) :
|
|||||||
conductor_profiles.insert(Qt::BottomRightCorner, ConductorProfile());
|
conductor_profiles.insert(Qt::BottomRightCorner, ConductorProfile());
|
||||||
|
|
||||||
// calcul du rendu du conducteur
|
// calcul du rendu du conducteur
|
||||||
priv_calculeConductor(terminal1 -> amarrageConductor(), terminal1 -> orientation(), terminal2 -> amarrageConductor(), terminal2 -> orientation());
|
priv_calculeConductor(terminal1 -> dockConductor(), terminal1 -> orientation(), terminal2 -> dockConductor(), terminal2 -> orientation());
|
||||||
setFlags(QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsSelectable);
|
||||||
setAcceptsHoverEvents(true);
|
setAcceptsHoverEvents(true);
|
||||||
|
|
||||||
@@ -113,13 +113,13 @@ void Conductor::update(const QRectF &rect) {
|
|||||||
// appelle la bonne fonction pour calculer l'aspect du conducteur
|
// appelle la bonne fonction pour calculer l'aspect du conducteur
|
||||||
if (nbSegments() && !conductor_profiles[currentPathType()].isNull()) {
|
if (nbSegments() && !conductor_profiles[currentPathType()].isNull()) {
|
||||||
priv_modifieConductor(
|
priv_modifieConductor(
|
||||||
terminal1 -> amarrageConductor(), terminal1 -> orientation(),
|
terminal1 -> dockConductor(), terminal1 -> orientation(),
|
||||||
terminal2 -> amarrageConductor(), terminal2 -> orientation()
|
terminal2 -> dockConductor(), terminal2 -> orientation()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
priv_calculeConductor(
|
priv_calculeConductor(
|
||||||
terminal1 -> amarrageConductor(), terminal1 -> orientation(),
|
terminal1 -> dockConductor(), terminal1 -> orientation(),
|
||||||
terminal2 -> amarrageConductor(), terminal2 -> orientation()
|
terminal2 -> dockConductor(), terminal2 -> orientation()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,13 +139,13 @@ void Conductor::updateWithNewPos(const QRectF &rect, const Terminal *b, const QP
|
|||||||
QPointF p1, p2;
|
QPointF p1, p2;
|
||||||
if (b == terminal1) {
|
if (b == terminal1) {
|
||||||
p1 = newpos;
|
p1 = newpos;
|
||||||
p2 = terminal2 -> amarrageConductor();
|
p2 = terminal2 -> dockConductor();
|
||||||
} else if (b == terminal2) {
|
} else if (b == terminal2) {
|
||||||
p1 = terminal1 -> amarrageConductor();
|
p1 = terminal1 -> dockConductor();
|
||||||
p2 = newpos;
|
p2 = newpos;
|
||||||
} else {
|
} else {
|
||||||
p1 = terminal1 -> amarrageConductor();
|
p1 = terminal1 -> dockConductor();
|
||||||
p2 = terminal2 -> amarrageConductor();
|
p2 = terminal2 -> dockConductor();
|
||||||
}
|
}
|
||||||
if (nbSegments() && !conductor_profiles[currentPathType()].isNull())
|
if (nbSegments() && !conductor_profiles[currentPathType()].isNull())
|
||||||
priv_modifieConductor(p1, terminal1 -> orientation(), p2, terminal2 -> orientation());
|
priv_modifieConductor(p1, terminal1 -> orientation(), p2, terminal2 -> orientation());
|
||||||
@@ -955,8 +955,8 @@ bool Conductor::fromXml(QDomElement &e) {
|
|||||||
qreal width = 0.0, height = 0.0;
|
qreal width = 0.0, height = 0.0;
|
||||||
foreach (qreal t, segments_x) width += t;
|
foreach (qreal t, segments_x) width += t;
|
||||||
foreach (qreal t, segments_y) height += t;
|
foreach (qreal t, segments_y) height += t;
|
||||||
QPointF t1 = terminal1 -> amarrageConductor();
|
QPointF t1 = terminal1 -> dockConductor();
|
||||||
QPointF t2 = terminal2 -> amarrageConductor();
|
QPointF t2 = terminal2 -> dockConductor();
|
||||||
qreal expected_width = t2.x() - t1.x();
|
qreal expected_width = t2.x() - t1.x();
|
||||||
qreal expected_height = t2.y() - t1.y();
|
qreal expected_height = t2.y() - t1.y();
|
||||||
|
|
||||||
@@ -1126,10 +1126,10 @@ void Conductor::setProfile(const ConductorProfile &cp, Qt::Corner path_type) {
|
|||||||
// si le type de trajet correspond a l'actuel
|
// si le type de trajet correspond a l'actuel
|
||||||
if (currentPathType() == path_type) {
|
if (currentPathType() == path_type) {
|
||||||
if (conductor_profiles[path_type].isNull()) {
|
if (conductor_profiles[path_type].isNull()) {
|
||||||
priv_calculeConductor(terminal1 -> amarrageConductor(), terminal1 -> orientation(), terminal2 -> amarrageConductor(), terminal2 -> orientation());
|
priv_calculeConductor(terminal1 -> dockConductor(), terminal1 -> orientation(), terminal2 -> dockConductor(), terminal2 -> orientation());
|
||||||
modified_path = false;
|
modified_path = false;
|
||||||
} else {
|
} else {
|
||||||
priv_modifieConductor(terminal1 -> amarrageConductor(), terminal1 -> orientation(), terminal2 -> amarrageConductor(), terminal2 -> orientation());
|
priv_modifieConductor(terminal1 -> dockConductor(), terminal1 -> orientation(), terminal2 -> dockConductor(), terminal2 -> orientation());
|
||||||
modified_path = true;
|
modified_path = true;
|
||||||
}
|
}
|
||||||
if (type() == ConductorProperties::Multi) {
|
if (type() == ConductorProperties::Multi) {
|
||||||
@@ -1383,7 +1383,7 @@ Qt::Corner Conductor::movementType(const QPointF &start, const QPointF &end) {
|
|||||||
|
|
||||||
/// @return le type de trajet actuel de ce conducteur
|
/// @return le type de trajet actuel de ce conducteur
|
||||||
Qt::Corner Conductor::currentPathType() const {
|
Qt::Corner Conductor::currentPathType() const {
|
||||||
return(movementType(terminal1 -> amarrageConductor(), terminal2 -> amarrageConductor()));
|
return(movementType(terminal1 -> dockConductor(), terminal2 -> dockConductor()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return les profils de ce conducteur
|
/// @return les profils de ce conducteur
|
||||||
@@ -1397,10 +1397,10 @@ ConductorProfilesGroup Conductor::profiles() const {
|
|||||||
void Conductor::setProfiles(const ConductorProfilesGroup &cpg) {
|
void Conductor::setProfiles(const ConductorProfilesGroup &cpg) {
|
||||||
conductor_profiles = cpg;
|
conductor_profiles = cpg;
|
||||||
if (conductor_profiles[currentPathType()].isNull()) {
|
if (conductor_profiles[currentPathType()].isNull()) {
|
||||||
priv_calculeConductor(terminal1 -> amarrageConductor(), terminal1 -> orientation(), terminal2 -> amarrageConductor(), terminal2 -> orientation());
|
priv_calculeConductor(terminal1 -> dockConductor(), terminal1 -> orientation(), terminal2 -> dockConductor(), terminal2 -> orientation());
|
||||||
modified_path = false;
|
modified_path = false;
|
||||||
} else {
|
} else {
|
||||||
priv_modifieConductor(terminal1 -> amarrageConductor(), terminal1 -> orientation(), terminal2 -> amarrageConductor(), terminal2 -> orientation());
|
priv_modifieConductor(terminal1 -> dockConductor(), terminal1 -> orientation(), terminal2 -> dockConductor(), terminal2 -> orientation());
|
||||||
modified_path = true;
|
modified_path = true;
|
||||||
}
|
}
|
||||||
if (type() == ConductorProperties::Multi) {
|
if (type() == ConductorProperties::Multi) {
|
||||||
|
|||||||
@@ -839,7 +839,7 @@ void Diagram::fetchMovedElements() {
|
|||||||
other_terminal = conductor -> terminal1;
|
other_terminal = conductor -> terminal1;
|
||||||
}
|
}
|
||||||
// si les deux elements du conducteur sont deplaces
|
// si les deux elements du conducteur sont deplaces
|
||||||
if (elements_to_move.contains(static_cast<Element *>(other_terminal -> parentItem()))) {
|
if (elements_to_move.contains(other_terminal -> parentElement())) {
|
||||||
conductors_to_move << conductor;
|
conductors_to_move << conductor;
|
||||||
} else {
|
} else {
|
||||||
conductors_to_update.insert(conductor, terminal);
|
conductors_to_update.insert(conductor, terminal);
|
||||||
@@ -877,7 +877,7 @@ void Diagram::moveElements(const QPointF &diff, QGraphicsItem *dontmove) {
|
|||||||
// recalcule les autres conducteurs
|
// recalcule les autres conducteurs
|
||||||
const QHash<Conductor *, Terminal *> &conductors_modify = conductorsToUpdate();
|
const QHash<Conductor *, Terminal *> &conductors_modify = conductorsToUpdate();
|
||||||
foreach(Conductor *conductor, conductors_modify.keys()) {
|
foreach(Conductor *conductor, conductors_modify.keys()) {
|
||||||
conductor -> updateWithNewPos(QRectF(), conductors_modify[conductor], conductors_modify[conductor] -> amarrageConductor());
|
conductor -> updateWithNewPos(QRectF(), conductors_modify[conductor], conductors_modify[conductor] -> dockConductor());
|
||||||
}
|
}
|
||||||
|
|
||||||
// deplace les champs de texte
|
// deplace les champs de texte
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ void MoveElementsCommand::move(const QPointF &actual_movement) {
|
|||||||
conductor -> updateWithNewPos(
|
conductor -> updateWithNewPos(
|
||||||
QRectF(),
|
QRectF(),
|
||||||
content_to_move.conductorsToUpdate[conductor],
|
content_to_move.conductorsToUpdate[conductor],
|
||||||
content_to_move.conductorsToUpdate[conductor] -> amarrageConductor()
|
content_to_move.conductorsToUpdate[conductor] -> dockConductor()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,14 +95,14 @@ void PartTerminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, Q
|
|||||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
||||||
|
|
||||||
// dessin de la borne en rouge
|
// dessin de la borne en rouge
|
||||||
t.setColor(isSelected() ? Terminal::couleur_neutre : Qt::red);
|
t.setColor(isSelected() ? Terminal::neutralColor : Qt::red);
|
||||||
p -> setPen(t);
|
p -> setPen(t);
|
||||||
p -> drawLine(QPointF(0.0, 0.0), second_point);
|
p -> drawLine(QPointF(0.0, 0.0), second_point);
|
||||||
|
|
||||||
// dessin du point d'amarrage au conducteur en bleu
|
// dessin du point d'amarrage au conducteur en bleu
|
||||||
t.setColor(isSelected() ? Qt::red : Terminal::couleur_neutre);
|
t.setColor(isSelected() ? Qt::red : Terminal::neutralColor);
|
||||||
p -> setPen(t);
|
p -> setPen(t);
|
||||||
p -> setBrush(Terminal::couleur_neutre);
|
p -> setBrush(Terminal::neutralColor);
|
||||||
p -> drawPoint(QPointF(0.0, 0.0));
|
p -> drawPoint(QPointF(0.0, 0.0));
|
||||||
p -> restore();
|
p -> restore();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,57 +22,47 @@
|
|||||||
#include "diagramcommands.h"
|
#include "diagramcommands.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
|
|
||||||
QColor Terminal::couleur_neutre = QColor(Qt::blue);
|
QColor Terminal::neutralColor = QColor(Qt::blue);
|
||||||
QColor Terminal::couleur_autorise = QColor(Qt::darkGreen);
|
QColor Terminal::allowedColor = QColor(Qt::darkGreen);
|
||||||
QColor Terminal::couleur_prudence = QColor("#ff8000");
|
QColor Terminal::warningColor = QColor("#ff8000");
|
||||||
QColor Terminal::couleur_interdit = QColor(Qt::red);
|
QColor Terminal::forbiddenColor = QColor(Qt::red);
|
||||||
const qreal Terminal::terminalSize = 4.0;
|
const qreal Terminal::terminalSize = 4.0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fonction privee pour initialiser la borne.
|
Methode privee pour initialiser la borne.
|
||||||
@param pf position du point d'amarrage pour un conducteur
|
@param pf position du point d'amarrage pour un conducteur
|
||||||
@param o orientation de la borne : Qt::Horizontal ou Qt::Vertical
|
@param o orientation de la borne : Qt::Horizontal ou Qt::Vertical
|
||||||
*/
|
*/
|
||||||
void Terminal::initialise(QPointF pf, QET::Orientation o) {
|
void Terminal::init(QPointF pf, QET::Orientation o) {
|
||||||
// definition du pount d'amarrage pour un conducteur
|
// definition du pount d'amarrage pour un conducteur
|
||||||
amarrage_conductor = pf;
|
dock_conductor_ = pf;
|
||||||
|
|
||||||
// definition de l'orientation de la terminal (par defaut : sud)
|
// definition de l'orientation de la borne (par defaut : sud)
|
||||||
if (o < QET::North || o > QET::West) sens = QET::South;
|
if (o < QET::North || o > QET::West) ori_ = QET::South;
|
||||||
else sens = o;
|
else ori_ = o;
|
||||||
|
|
||||||
// calcul de la position du point d'amarrage a l'element
|
// calcul de la position du point d'amarrage a l'element
|
||||||
amarrage_elmt = amarrage_conductor;
|
dock_elmt_ = dock_conductor_;
|
||||||
switch(sens) {
|
switch(ori_) {
|
||||||
case QET::North: amarrage_elmt += QPointF(0, Terminal::terminalSize); break;
|
case QET::North: dock_elmt_ += QPointF(0, Terminal::terminalSize); break;
|
||||||
case QET::East : amarrage_elmt += QPointF(-Terminal::terminalSize, 0); break;
|
case QET::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
|
||||||
case QET::West : amarrage_elmt += QPointF(Terminal::terminalSize, 0); break;
|
case QET::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
|
||||||
case QET::South:
|
case QET::South:
|
||||||
default : amarrage_elmt += QPointF(0, -Terminal::terminalSize);
|
default : dock_elmt_ += QPointF(0, -Terminal::terminalSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// par defaut : pas de conducteur
|
// par defaut : pas de conducteur
|
||||||
|
|
||||||
// QRectF null
|
// QRectF null
|
||||||
br = new QRectF();
|
br_ = new QRectF();
|
||||||
terminal_precedente = NULL;
|
previous_terminal_ = 0;
|
||||||
// divers
|
// divers
|
||||||
setAcceptsHoverEvents(true);
|
setAcceptsHoverEvents(true);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
hovered = false;
|
hovered_ = false;
|
||||||
setToolTip(QObject::tr("Borne", "tooltip"));
|
setToolTip(QObject::tr("Borne", "tooltip"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Constructeur par defaut
|
|
||||||
*/
|
|
||||||
Terminal::Terminal() :
|
|
||||||
QGraphicsItem(0, 0),
|
|
||||||
couleur_hovered(Terminal::couleur_neutre)
|
|
||||||
{
|
|
||||||
initialise(QPointF(0.0, 0.0), QET::South);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
initialise une borne
|
initialise une borne
|
||||||
@param pf position du point d'amarrage pour un conducteur
|
@param pf position du point d'amarrage pour un conducteur
|
||||||
@@ -82,9 +72,10 @@ Terminal::Terminal() :
|
|||||||
*/
|
*/
|
||||||
Terminal::Terminal(QPointF pf, QET::Orientation o, Element *e, Diagram *s) :
|
Terminal::Terminal(QPointF pf, QET::Orientation o, Element *e, Diagram *s) :
|
||||||
QGraphicsItem(e, s),
|
QGraphicsItem(e, s),
|
||||||
couleur_hovered(Terminal::couleur_neutre)
|
parent_element_(e),
|
||||||
|
hovered_color_(Terminal::neutralColor)
|
||||||
{
|
{
|
||||||
initialise(pf, o);
|
init(pf, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,9 +88,10 @@ Terminal::Terminal(QPointF pf, QET::Orientation o, Element *e, Diagram *s) :
|
|||||||
*/
|
*/
|
||||||
Terminal::Terminal(qreal pf_x, qreal pf_y, QET::Orientation o, Element *e, Diagram *s) :
|
Terminal::Terminal(qreal pf_x, qreal pf_y, QET::Orientation o, Element *e, Diagram *s) :
|
||||||
QGraphicsItem(e, s),
|
QGraphicsItem(e, s),
|
||||||
couleur_hovered(Terminal::couleur_neutre)
|
parent_element_(e),
|
||||||
|
hovered_color_(Terminal::neutralColor)
|
||||||
{
|
{
|
||||||
initialise(QPointF(pf_x, pf_y), o);
|
init(QPointF(pf_x, pf_y), o);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,9 +100,8 @@ Terminal::Terminal(qreal pf_x, qreal pf_y, QET::Orientation o, Element *e, Diagr
|
|||||||
associes.
|
associes.
|
||||||
*/
|
*/
|
||||||
Terminal::~Terminal() {
|
Terminal::~Terminal() {
|
||||||
//qDebug() << "Terminal::~Terminal" << (void *)this;
|
foreach(Conductor *c, conductors_) delete c;
|
||||||
foreach(Conductor *c, liste_conductors) delete c;
|
delete br_;
|
||||||
delete br;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -125,15 +116,15 @@ QET::Orientation Terminal::orientation() const {
|
|||||||
// orientations actuelle et par defaut de l'element
|
// orientations actuelle et par defaut de l'element
|
||||||
QET::Orientation ori_cur = elt -> orientation().current();
|
QET::Orientation ori_cur = elt -> orientation().current();
|
||||||
QET::Orientation ori_def = elt -> orientation().defaultOrientation();
|
QET::Orientation ori_def = elt -> orientation().defaultOrientation();
|
||||||
if (ori_cur == ori_def) return(sens);
|
if (ori_cur == ori_def) return(ori_);
|
||||||
else {
|
else {
|
||||||
// calcul l'angle de rotation implique par l'orientation de l'element parent
|
// calcul l'angle de rotation implique par l'orientation de l'element parent
|
||||||
// angle de rotation de la borne sur la scene, divise par 90
|
// angle de rotation de la borne sur la scene, divise par 90
|
||||||
int angle = ori_cur - ori_def + sens;
|
int angle = ori_cur - ori_def + ori_;
|
||||||
while (angle >= 4) angle -= 4;
|
while (angle >= 4) angle -= 4;
|
||||||
return((QET::Orientation)angle);
|
return((QET::Orientation)angle);
|
||||||
}
|
}
|
||||||
} else return(sens);
|
} else return(ori_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,7 +143,7 @@ bool Terminal::addConductor(Conductor *f) {
|
|||||||
|
|
||||||
// verifie que la borne n'est pas deja reliee avec l'autre borne
|
// verifie que la borne n'est pas deja reliee avec l'autre borne
|
||||||
bool deja_liees = false;
|
bool deja_liees = false;
|
||||||
foreach (Conductor* conductor, liste_conductors) {
|
foreach (Conductor* conductor, conductors_) {
|
||||||
if (conductor -> terminal1 == autre_terminal || conductor -> terminal2 == autre_terminal) deja_liees = true;
|
if (conductor -> terminal1 == autre_terminal || conductor -> terminal2 == autre_terminal) deja_liees = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +151,7 @@ bool Terminal::addConductor(Conductor *f) {
|
|||||||
if (deja_liees) return(false);
|
if (deja_liees) return(false);
|
||||||
|
|
||||||
// sinon on ajoute le conducteur
|
// sinon on ajoute le conducteur
|
||||||
liste_conductors.append(f);
|
conductors_.append(f);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,10 +160,9 @@ bool Terminal::addConductor(Conductor *f) {
|
|||||||
@param f Conducteur a enlever
|
@param f Conducteur a enlever
|
||||||
*/
|
*/
|
||||||
void Terminal::removeConductor(Conductor *f) {
|
void Terminal::removeConductor(Conductor *f) {
|
||||||
//qDebug() << "Terminal::removeConductor" << (void *)this;
|
int index = conductors_.indexOf(f);
|
||||||
int index = liste_conductors.indexOf(f);
|
|
||||||
if (index == -1) return;
|
if (index == -1) return;
|
||||||
liste_conductors.removeAt(index);
|
conductors_.removeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,8 +204,8 @@ void Terminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, QWidg
|
|||||||
p -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
p -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||||
|
|
||||||
// on travaille avec les coordonnees de l'element parent
|
// on travaille avec les coordonnees de l'element parent
|
||||||
QPointF f = mapFromParent(amarrage_conductor);
|
QPointF c = mapFromParent(dock_conductor_);
|
||||||
QPointF e = mapFromParent(amarrage_elmt);
|
QPointF e = mapFromParent(dock_elmt_);
|
||||||
|
|
||||||
QPen t;
|
QPen t;
|
||||||
t.setWidthF(1.0);
|
t.setWidthF(1.0);
|
||||||
@@ -227,16 +217,16 @@ void Terminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, QWidg
|
|||||||
// dessin de la borne en rouge
|
// dessin de la borne en rouge
|
||||||
t.setColor(Qt::red);
|
t.setColor(Qt::red);
|
||||||
p -> setPen(t);
|
p -> setPen(t);
|
||||||
p -> drawLine(f, e);
|
p -> drawLine(c, e);
|
||||||
|
|
||||||
// dessin du point d'amarrage au conducteur en bleu
|
// dessin du point d'amarrage au conducteur en bleu
|
||||||
t.setColor(couleur_hovered);
|
t.setColor(hovered_color_);
|
||||||
p -> setPen(t);
|
p -> setPen(t);
|
||||||
p -> setBrush(couleur_hovered);
|
p -> setBrush(hovered_color_);
|
||||||
if (hovered) {
|
if (hovered_) {
|
||||||
p -> setRenderHint(QPainter::Antialiasing, true);
|
p -> setRenderHint(QPainter::Antialiasing, true);
|
||||||
p -> drawEllipse(QRectF(f.x() - 2.5, f.y() - 2.5, 5.0, 5.0));
|
p -> drawEllipse(QRectF(c.x() - 2.5, c.y() - 2.5, 5.0, 5.0));
|
||||||
} else p -> drawPoint(f);
|
} else p -> drawPoint(c);
|
||||||
|
|
||||||
p -> restore();
|
p -> restore();
|
||||||
}
|
}
|
||||||
@@ -245,26 +235,25 @@ void Terminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, QWidg
|
|||||||
@return Le rectangle (en precision flottante) delimitant la borne et ses alentours.
|
@return Le rectangle (en precision flottante) delimitant la borne et ses alentours.
|
||||||
*/
|
*/
|
||||||
QRectF Terminal::boundingRect() const {
|
QRectF Terminal::boundingRect() const {
|
||||||
if (br -> isNull()) {
|
if (br_ -> isNull()) {
|
||||||
qreal afx = amarrage_conductor.x();
|
qreal dcx = dock_conductor_.x();
|
||||||
qreal afy = amarrage_conductor.y();
|
qreal dcy = dock_conductor_.y();
|
||||||
qreal aex = amarrage_elmt.x();
|
qreal dex = dock_elmt_.x();
|
||||||
qreal aey = amarrage_elmt.y();
|
qreal dey = dock_elmt_.y();
|
||||||
QPointF origine;
|
QPointF origin = (dcx <= dex && dcy <= dey ? dock_conductor_ : dock_elmt_);
|
||||||
origine = (afx <= aex && afy <= aey ? amarrage_conductor : amarrage_elmt);
|
origin += QPointF(-3.0, -3.0);
|
||||||
origine += QPointF(-3.0, -3.0);
|
qreal w = qAbs((int)(dcx - dex)) + 7;
|
||||||
qreal w = qAbs((int)(afx - aex)) + 7;
|
qreal h = qAbs((int)(dcy - dey)) + 7;
|
||||||
qreal h = qAbs((int)(afy - aey)) + 7;
|
*br_ = QRectF(origin, QSizeF(w, h));
|
||||||
*br = QRectF(origine, QSizeF(w, h));
|
|
||||||
}
|
}
|
||||||
return(*br);
|
return(*br_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gere l'entree de la souris sur la zone de la Borne.
|
Gere l'entree de la souris sur la zone de la Borne.
|
||||||
*/
|
*/
|
||||||
void Terminal::hoverEnterEvent(QGraphicsSceneHoverEvent *) {
|
void Terminal::hoverEnterEvent(QGraphicsSceneHoverEvent *) {
|
||||||
hovered = true;
|
hovered_ = true;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +267,7 @@ void Terminal::hoverMoveEvent(QGraphicsSceneHoverEvent *) {
|
|||||||
Gere le fait que la souris sorte de la zone de la Borne.
|
Gere le fait que la souris sorte de la zone de la Borne.
|
||||||
*/
|
*/
|
||||||
void Terminal::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
|
void Terminal::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
|
||||||
hovered = false;
|
hovered_ = false;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,10 +276,10 @@ void Terminal::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
|
|||||||
@param e L'evenement souris correspondant
|
@param e L'evenement souris correspondant
|
||||||
*/
|
*/
|
||||||
void Terminal::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
void Terminal::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
||||||
if (Diagram *s = diagram()) {
|
if (Diagram *d = diagram()) {
|
||||||
s -> setConductorStart(mapToScene(QPointF(amarrage_conductor)));
|
d -> setConductorStart(mapToScene(QPointF(dock_conductor_)));
|
||||||
s -> setConductorStop(e -> scenePos());
|
d -> setConductorStop(e -> scenePos());
|
||||||
s -> setConductor(true);
|
d -> setConductor(true);
|
||||||
//setCursor(Qt::CrossCursor);
|
//setCursor(Qt::CrossCursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -304,21 +293,21 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
//setCursor(Qt::CrossCursor);
|
//setCursor(Qt::CrossCursor);
|
||||||
|
|
||||||
// d'un mouvement a l'autre, il faut retirer l'effet hover de la borne precedente
|
// d'un mouvement a l'autre, il faut retirer l'effet hover de la borne precedente
|
||||||
if (terminal_precedente != NULL) {
|
if (previous_terminal_) {
|
||||||
if (terminal_precedente == this) hovered = true;
|
if (previous_terminal_ == this) hovered_ = true;
|
||||||
else terminal_precedente -> hovered = false;
|
else previous_terminal_ -> hovered_ = false;
|
||||||
terminal_precedente -> couleur_hovered = terminal_precedente -> couleur_neutre;
|
previous_terminal_ -> hovered_color_ = previous_terminal_ -> neutralColor;
|
||||||
terminal_precedente -> update();
|
previous_terminal_ -> update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Diagram *s = diagram();
|
Diagram *d = diagram();
|
||||||
if (!s) return;
|
if (!d) return;
|
||||||
// si la scene est un Diagram, on actualise le poseur de conducteur
|
// si la scene est un Diagram, on actualise le poseur de conducteur
|
||||||
s -> setConductorStop(e -> scenePos());
|
d -> setConductorStop(e -> scenePos());
|
||||||
|
|
||||||
// on recupere la liste des qgi sous le pointeur
|
// on recupere la liste des qgi sous le pointeur
|
||||||
QList<QGraphicsItem *> qgis = s -> items(e -> scenePos());
|
QList<QGraphicsItem *> qgis = d -> items(e -> scenePos());
|
||||||
|
|
||||||
/* le qgi le plus haut
|
/* le qgi le plus haut
|
||||||
= le poseur de conductor
|
= le poseur de conductor
|
||||||
@@ -328,42 +317,27 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
*/
|
*/
|
||||||
Q_ASSERT_X(!(qgis.isEmpty()), "Terminal::mouseMoveEvent", "La liste d'items ne devrait pas etre vide");
|
Q_ASSERT_X(!(qgis.isEmpty()), "Terminal::mouseMoveEvent", "La liste d'items ne devrait pas etre vide");
|
||||||
|
|
||||||
// s'il y a autre chose que le poseur de conducteur dans la liste
|
// s'il n'y rien d'autre que le poseur de conducteur dans la liste, on arrete la
|
||||||
if (qgis.size() > 1) {
|
if (qgis.size() <= 1) return;
|
||||||
// on prend le deuxieme element de la liste
|
|
||||||
|
// sinon on prend le deuxieme element de la liste et on verifie s'il s'agit d'une borne
|
||||||
QGraphicsItem *qgi = qgis.at(1);
|
QGraphicsItem *qgi = qgis.at(1);
|
||||||
// si le qgi est une borne...
|
// si le qgi est une borne...
|
||||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) {
|
Terminal *other_terminal = qgraphicsitem_cast<Terminal *>(qgi);
|
||||||
// ...on lui applique l'effet hover approprie
|
if (!other_terminal) return;
|
||||||
if (p == this) {
|
previous_terminal_ = other_terminal;
|
||||||
// effet si l'on hover sur la borne de depart
|
|
||||||
couleur_hovered = couleur_interdit;
|
// s'il s'agit d'une borne, on lui applique l'effet hover approprie
|
||||||
} else if (p -> parentItem() == parentItem()) {
|
if (!canBeLinkedTo(other_terminal)) {
|
||||||
// effet si l'on hover sur une borne du meme appareil
|
other_terminal -> hovered_color_ = forbiddenColor;
|
||||||
if (((Element *)parentItem()) -> internalConnections())
|
} else if (other_terminal -> conductorsCount()) {
|
||||||
p -> couleur_hovered = p -> couleur_autorise;
|
other_terminal -> hovered_color_ = warningColor;
|
||||||
else p -> couleur_hovered = p -> couleur_interdit;
|
|
||||||
} else if (p -> nbConductors()) {
|
|
||||||
// si la borne a deja un conducteur
|
|
||||||
// verifie que cette borne n'est pas deja reliee a l'autre borne
|
|
||||||
bool deja_reliee = false;
|
|
||||||
foreach (Conductor *f, liste_conductors) {
|
|
||||||
if (f -> terminal1 == p || f -> terminal2 == p) {
|
|
||||||
deja_reliee = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// interdit si les bornes sont deja reliees, prudence sinon
|
|
||||||
p -> couleur_hovered = deja_reliee ? p -> couleur_interdit : p -> couleur_prudence;
|
|
||||||
} else {
|
} else {
|
||||||
// effet si on peut poser le conducteur
|
other_terminal -> hovered_color_ = allowedColor;
|
||||||
p -> couleur_hovered = p -> couleur_autorise;
|
|
||||||
}
|
|
||||||
terminal_precedente = p;
|
|
||||||
p -> hovered = true;
|
|
||||||
p -> update();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
other_terminal -> hovered_ = true;
|
||||||
|
other_terminal -> update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -372,32 +346,28 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
*/
|
*/
|
||||||
void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
||||||
//setCursor(Qt::ArrowCursor);
|
//setCursor(Qt::ArrowCursor);
|
||||||
terminal_precedente = NULL;
|
previous_terminal_ = 0;
|
||||||
couleur_hovered = couleur_neutre;
|
hovered_color_ = neutralColor;
|
||||||
// verifie que la scene est bien un Diagram
|
// verifie que la scene est bien un Diagram
|
||||||
if (Diagram *s = diagram()) {
|
if (Diagram *d = diagram()) {
|
||||||
// on arrete de dessiner l'apercu du conducteur
|
// on arrete de dessiner l'apercu du conducteur
|
||||||
s -> setConductor(false);
|
d -> setConductor(false);
|
||||||
// on recupere l'element sous le pointeur lors du MouseReleaseEvent
|
// on recupere l'element sous le pointeur lors du MouseReleaseEvent
|
||||||
QGraphicsItem *qgi = s -> itemAt(e -> scenePos());
|
QGraphicsItem *qgi = d -> itemAt(e -> scenePos());
|
||||||
// s'il n'y a rien, on arrete la
|
// s'il n'y a rien, on arrete la
|
||||||
if (!qgi) return;
|
if (!qgi) return;
|
||||||
// idem si l'element obtenu n'est pas une borne
|
// idem si l'element obtenu n'est pas une borne
|
||||||
Terminal *p = qgraphicsitem_cast<Terminal *>(qgi);
|
Terminal *other_terminal = qgraphicsitem_cast<Terminal *>(qgi);
|
||||||
if (!p) return;
|
if (!other_terminal) return;
|
||||||
// on remet la couleur de hover a sa valeur par defaut
|
// on remet la couleur de hover a sa valeur par defaut
|
||||||
p -> couleur_hovered = p -> couleur_neutre;
|
other_terminal -> hovered_color_ = neutralColor;
|
||||||
// idem s'il s'agit de la borne actuelle
|
other_terminal -> hovered_ = false;
|
||||||
if (p == this) return;
|
// on s'arrete la s'il n'est pas possible de relier les bornes
|
||||||
// idem s'il s'agit d'une borne de l'element actuel et que l'element n'a pas le droit de relier ses propres bornes
|
if (!canBeLinkedTo(other_terminal)) return;
|
||||||
bool cia = ((Element *)parentItem()) -> internalConnections();
|
|
||||||
if (!cia) foreach(QGraphicsItem *item, parentItem() -> children()) if (item == p) return;
|
|
||||||
// derniere verification : verifier que cette borne n'est pas deja reliee a l'autre borne
|
|
||||||
foreach (Conductor *f, liste_conductors) if (f -> terminal1 == p || f -> terminal2 == p) return;
|
|
||||||
// autrement, on pose un conducteur
|
// autrement, on pose un conducteur
|
||||||
Conductor * new_conductor = new Conductor(this, p);
|
Conductor *new_conductor = new Conductor(this, other_terminal);
|
||||||
new_conductor -> setProperties(s -> defaultConductorProperties);
|
new_conductor -> setProperties(d -> defaultConductorProperties);
|
||||||
s -> undoStack().push(new AddConductorCommand(s, new_conductor));
|
d -> undoStack().push(new AddConductorCommand(d, new_conductor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,23 +377,59 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
*/
|
*/
|
||||||
void Terminal::updateConductor(QPointF newpos) {
|
void Terminal::updateConductor(QPointF newpos) {
|
||||||
if (!scene() || !parentItem()) return;
|
if (!scene() || !parentItem()) return;
|
||||||
foreach (Conductor *conductor, liste_conductors) {
|
foreach (Conductor *conductor, conductors_) {
|
||||||
if (conductor -> isDestroyed()) continue;
|
if (conductor -> isDestroyed()) continue;
|
||||||
if (newpos == QPointF()) conductor -> update(QRectF());
|
if (newpos == QPointF()) conductor -> update(QRectF());
|
||||||
else {
|
else {
|
||||||
// determine la translation subie par l'element parent
|
// determine la translation subie par l'element parent
|
||||||
QPointF translation = newpos - parentItem() -> pos();
|
QPointF translation = newpos - parentItem() -> pos();
|
||||||
// rafraichit le conducteur en tenant compte de la translation
|
// rafraichit le conducteur en tenant compte de la translation
|
||||||
conductor -> updateWithNewPos(QRectF(), this, amarrageConductor() + translation);
|
conductor -> updateWithNewPos(QRectF(), this, dockConductor() + translation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param other_terminal Autre borne
|
||||||
|
@return true si cette borne est reliee a other_terminal, false sion
|
||||||
|
*/
|
||||||
|
bool Terminal::isLinkedTo(Terminal *other_terminal) {
|
||||||
|
if (other_terminal == this) return(false);
|
||||||
|
|
||||||
|
bool already_linked = false;
|
||||||
|
foreach (Conductor *c, conductors_) {
|
||||||
|
if (c -> terminal1 == other_terminal || c -> terminal2 == other_terminal) {
|
||||||
|
already_linked = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(already_linked);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param other_terminal Autre borne
|
||||||
|
@return true si cette borne peut etre reliee a other_terminal, false sion
|
||||||
|
*/
|
||||||
|
bool Terminal::canBeLinkedTo(Terminal *other_terminal) {
|
||||||
|
if (other_terminal == this) return(false);
|
||||||
|
|
||||||
|
// l'autre borne appartient-elle au meme element ?
|
||||||
|
bool same_element = other_terminal -> parentElement() == parentElement();
|
||||||
|
// les connexions internes sont-elles autorisees ?
|
||||||
|
bool internal_connections_allowed = parentElement() -> internalConnections();
|
||||||
|
// les deux bornes sont-elles deja liees ?
|
||||||
|
bool already_linked = isLinkedTo(other_terminal);
|
||||||
|
// la liaison des deux bornes est-elle interdite ?
|
||||||
|
bool link_forbidden = (same_element && !internal_connections_allowed) || already_linked;
|
||||||
|
|
||||||
|
return(!link_forbidden);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return La liste des conducteurs lies a cette borne
|
@return La liste des conducteurs lies a cette borne
|
||||||
*/
|
*/
|
||||||
QList<Conductor *> Terminal::conductors() const {
|
QList<Conductor *> Terminal::conductors() const {
|
||||||
return(liste_conductors);
|
return(conductors_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -433,9 +439,9 @@ QList<Conductor *> Terminal::conductors() const {
|
|||||||
*/
|
*/
|
||||||
QDomElement Terminal::toXml(QDomDocument &doc) const {
|
QDomElement Terminal::toXml(QDomDocument &doc) const {
|
||||||
QDomElement qdo = doc.createElement("terminal");
|
QDomElement qdo = doc.createElement("terminal");
|
||||||
qdo.setAttribute("x", QString("%1").arg(amarrage_elmt.x()));
|
qdo.setAttribute("x", QString("%1").arg(dock_elmt_.x()));
|
||||||
qdo.setAttribute("y", QString("%1").arg(amarrage_elmt.y()));
|
qdo.setAttribute("y", QString("%1").arg(dock_elmt_.y()));
|
||||||
qdo.setAttribute("orientation", sens);
|
qdo.setAttribute("orientation", ori_);
|
||||||
return(qdo);
|
return(qdo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,13 +488,22 @@ bool Terminal::valideXml(QDomElement &terminal) {
|
|||||||
*/
|
*/
|
||||||
bool Terminal::fromXml(QDomElement &terminal) {
|
bool Terminal::fromXml(QDomElement &terminal) {
|
||||||
return (
|
return (
|
||||||
qFuzzyCompare(terminal.attribute("x").toDouble(), amarrage_elmt.x()) &&
|
qFuzzyCompare(terminal.attribute("x").toDouble(), dock_elmt_.x()) &&
|
||||||
qFuzzyCompare(terminal.attribute("y").toDouble(), amarrage_elmt.y()) &&
|
qFuzzyCompare(terminal.attribute("y").toDouble(), dock_elmt_.y()) &&
|
||||||
terminal.attribute("orientation").toInt() == sens
|
terminal.attribute("orientation").toInt() == ori_
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return le Diagram auquel cette borne appartient, ou 0 si cette borne est independant
|
/**
|
||||||
|
@return le Diagram auquel cette borne appartient, ou 0 si cette borne est independant
|
||||||
|
*/
|
||||||
Diagram *Terminal::diagram() const {
|
Diagram *Terminal::diagram() const {
|
||||||
return(qobject_cast<Diagram *>(scene()));
|
return(qobject_cast<Diagram *>(scene()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return L'element auquel cette borne est rattachee
|
||||||
|
*/
|
||||||
|
Element *Terminal::parentElement() const {
|
||||||
|
return(parent_element_);
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,9 +15,8 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef BORNE_H
|
#ifndef TERMINAL_H
|
||||||
#define BORNE_H
|
#define TERMINAL_H
|
||||||
#define TAILLE_BORNE 4
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
@@ -25,14 +24,13 @@ class Conductor;
|
|||||||
class Diagram;
|
class Diagram;
|
||||||
class Element;
|
class Element;
|
||||||
/**
|
/**
|
||||||
Classe modelisant la "borne" d'un appareil, c'est-a-dire un
|
Cette classe represente une borne d'un element, c'est-a-dire un
|
||||||
branchement possible pour un Conducteur.
|
branchement possible pour un conducteur.
|
||||||
*/
|
*/
|
||||||
class Terminal : public QGraphicsItem {
|
class Terminal : public QGraphicsItem {
|
||||||
|
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
Terminal();
|
|
||||||
Terminal(QPointF, QET::Orientation, Element * = 0, Diagram * = 0);
|
Terminal(QPointF, QET::Orientation, Element * = 0, Diagram * = 0);
|
||||||
Terminal(qreal, qreal, QET::Orientation, Element * = 0, Diagram * = 0);
|
Terminal(qreal, qreal, QET::Orientation, Element * = 0, Diagram * = 0);
|
||||||
virtual ~Terminal();
|
virtual ~Terminal();
|
||||||
@@ -55,14 +53,17 @@ class Terminal : public QGraphicsItem {
|
|||||||
// methodes de manipulation des conducteurs lies a cette borne
|
// methodes de manipulation des conducteurs lies a cette borne
|
||||||
bool addConductor(Conductor *);
|
bool addConductor(Conductor *);
|
||||||
void removeConductor(Conductor *);
|
void removeConductor(Conductor *);
|
||||||
int nbConductors() const;
|
int conductorsCount() const;
|
||||||
Diagram *diagram() const;
|
Diagram *diagram() const;
|
||||||
|
Element *parentElement() const;
|
||||||
|
|
||||||
// methodes de lecture
|
// methodes de lecture
|
||||||
QList<Conductor *> conductors() const;
|
QList<Conductor *> conductors() const;
|
||||||
QET::Orientation orientation() const;
|
QET::Orientation orientation() const;
|
||||||
QPointF amarrageConductor() const;
|
QPointF dockConductor() const;
|
||||||
void updateConductor(QPointF = QPointF());
|
void updateConductor(QPointF = QPointF());
|
||||||
|
bool isLinkedTo(Terminal *);
|
||||||
|
bool canBeLinkedTo(Terminal *);
|
||||||
|
|
||||||
// methodes relatives a l'import/export au format XML
|
// methodes relatives a l'import/export au format XML
|
||||||
static bool valideXml(QDomElement &);
|
static bool valideXml(QDomElement &);
|
||||||
@@ -86,44 +87,55 @@ class Terminal : public QGraphicsItem {
|
|||||||
|
|
||||||
// differentes couleurs statiques utilisables pour l'effet "hover"
|
// differentes couleurs statiques utilisables pour l'effet "hover"
|
||||||
/// couleur par defaut
|
/// couleur par defaut
|
||||||
static QColor couleur_neutre;
|
static QColor neutralColor;
|
||||||
/// couleur indiquant une action autorisee
|
/// couleur indiquant une action autorisee
|
||||||
static QColor couleur_autorise;
|
static QColor allowedColor;
|
||||||
/// couleur indiquant une action autorisee mais pas forcement recommandee
|
/// couleur indiquant une action autorisee mais pas forcement recommandee
|
||||||
static QColor couleur_prudence;
|
static QColor warningColor;
|
||||||
/// couleur indiquant une action interdite
|
/// couleur indiquant une action interdite
|
||||||
static QColor couleur_interdit;
|
static QColor forbiddenColor;
|
||||||
|
|
||||||
|
// attributs prives
|
||||||
|
private:
|
||||||
|
/// Pointeur vers l'element parent
|
||||||
|
Element *parent_element_;
|
||||||
|
/// coordonnees du point d'amarrage du conducteur
|
||||||
|
QPointF dock_conductor_;
|
||||||
|
/// coordonnees du point d'amarrage de l'element
|
||||||
|
QPointF dock_elmt_;
|
||||||
|
/// orientation de la borne
|
||||||
|
QET::Orientation ori_;
|
||||||
|
/// liste des conductors lies a cette borne
|
||||||
|
QList<Conductor *> conductors_;
|
||||||
|
/// pointeur vers un rectangle correspondant au bounding rect
|
||||||
|
/// permet de ne calculer le bounding rect qu'une seule fois
|
||||||
|
/// le pointeur c'est parce que le compilo exige une methode const
|
||||||
|
QRectF *br_;
|
||||||
|
/// Derniere borne mise en contact avec celle-ci
|
||||||
|
Terminal *previous_terminal_;
|
||||||
|
/// Booleen indiquant si le pointeur est au-dessus de la borne ou non
|
||||||
|
bool hovered_;
|
||||||
|
/// couleur de l'effet hover de la borne
|
||||||
|
QColor hovered_color_;
|
||||||
|
|
||||||
|
// methodes privees
|
||||||
private:
|
private:
|
||||||
// coordonnees des points d'amarrage
|
|
||||||
QPointF amarrage_conductor;
|
|
||||||
QPointF amarrage_elmt;
|
|
||||||
// orientation de la borne
|
|
||||||
QET::Orientation sens;
|
|
||||||
// liste des conductors lies a cette borne
|
|
||||||
QList<Conductor *> liste_conductors;
|
|
||||||
// pointeur vers un rectangle correspondant au bounding rect ; permet de ne calculer le bounding rect qu'une seule fois ; le pointeur c'est parce que le compilo exige une methode const
|
|
||||||
QRectF *br;
|
|
||||||
Terminal *terminal_precedente;
|
|
||||||
bool hovered;
|
|
||||||
// methode initialisant les differents membres de la borne
|
// methode initialisant les differents membres de la borne
|
||||||
void initialise(QPointF, QET::Orientation);
|
void init(QPointF, QET::Orientation);
|
||||||
// couleur de l'effet hover de la patte
|
|
||||||
QColor couleur_hovered;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return Le nombre de conducteurs associes a la borne
|
@return Le nombre de conducteurs associes a la borne
|
||||||
*/
|
*/
|
||||||
inline int Terminal::nbConductors() const {
|
inline int Terminal::conductorsCount() const {
|
||||||
return(liste_conductors.size());
|
return(conductors_.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return La position du point d'amarrage de la borne
|
@return La position du point d'amarrage de la borne
|
||||||
*/
|
*/
|
||||||
inline QPointF Terminal::amarrageConductor() const {
|
inline QPointF Terminal::dockConductor() const {
|
||||||
return(mapToScene(amarrage_conductor));
|
return(mapToScene(dock_conductor_));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user