mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 08:10:52 +01:00
Element editor : Add new tagg for text field (function and tension/protocol).
Report element : text field tagged function or tension/protocol display the function tension/protocol of the potential. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4195 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -72,6 +72,8 @@ TextFieldEditor::TextFieldEditor(QETElementEditor *editor, PartTextField *textfi
|
|||||||
tagg_layout -> addWidget(m_tagg_cb = new QComboBox());
|
tagg_layout -> addWidget(m_tagg_cb = new QComboBox());
|
||||||
m_tagg_cb -> addItem(tr("Aucun"), QVariant("none"));
|
m_tagg_cb -> addItem(tr("Aucun"), QVariant("none"));
|
||||||
m_tagg_cb -> addItem(tr("label"), QVariant("label"));
|
m_tagg_cb -> addItem(tr("label"), QVariant("label"));
|
||||||
|
m_tagg_cb -> addItem(tr("Fonction"), QVariant("function"));
|
||||||
|
m_tagg_cb -> addItem(tr("Tension/protocole"), QVariant("tension-protocol"));
|
||||||
main_layout -> addLayout(tagg_layout);
|
main_layout -> addLayout(tagg_layout);
|
||||||
|
|
||||||
QHBoxLayout *rotation_angle_layout = new QHBoxLayout();
|
QHBoxLayout *rotation_angle_layout = new QHBoxLayout();
|
||||||
@@ -184,6 +186,12 @@ void TextFieldEditor::updateTextFieldRotationAngle()
|
|||||||
}
|
}
|
||||||
m_locked= false;
|
m_locked= false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TextFieldEditor::updateTagg
|
||||||
|
* Change the tagg of the text field.
|
||||||
|
* Change is apply with a QUndoCommand
|
||||||
|
*/
|
||||||
void TextFieldEditor::updateTagg()
|
void TextFieldEditor::updateTagg()
|
||||||
{
|
{
|
||||||
if(m_locked) return;
|
if(m_locked) return;
|
||||||
|
|||||||
@@ -1366,6 +1366,7 @@ void Conductor::setProperties(const ConductorProperties &properties)
|
|||||||
}
|
}
|
||||||
|
|
||||||
readProperties();
|
readProperties();
|
||||||
|
emit propertiesChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ class Conductor : public QObject, public QGraphicsPathItem
|
|||||||
Q_PROPERTY(int animPath READ fakePath WRITE updatePathAnimate)
|
Q_PROPERTY(int animPath READ fakePath WRITE updatePathAnimate)
|
||||||
Q_PROPERTY(ConductorProperties properties READ properties WRITE setProperties)
|
Q_PROPERTY(ConductorProperties properties READ properties WRITE setProperties)
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void propertiesChange();
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
Conductor(Terminal *, Terminal *);
|
Conductor(Terminal *, Terminal *);
|
||||||
|
|||||||
@@ -20,10 +20,13 @@
|
|||||||
#include "diagramposition.h"
|
#include "diagramposition.h"
|
||||||
#include "qetproject.h"
|
#include "qetproject.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
|
#include "terminal.h"
|
||||||
|
#include "conductor.h"
|
||||||
|
|
||||||
ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, int *state) :
|
ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, int *state) :
|
||||||
CustomElement(location, qgi, state),
|
CustomElement(location, qgi, state),
|
||||||
m_text_field (nullptr)
|
m_text_field (nullptr),
|
||||||
|
m_watched_conductor(nullptr)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Get text tagged label. This is work for report
|
* Get text tagged label. This is work for report
|
||||||
@@ -39,10 +42,22 @@ ReportElement::ReportElement(const ElementsLocation &location, QString link_type
|
|||||||
|
|
||||||
link_type == "next_report"? link_type_=NextReport : link_type_=PreviousReport;
|
link_type == "next_report"? link_type_=NextReport : link_type_=PreviousReport;
|
||||||
link_type == "next_report"? inverse_report=PreviousReport : inverse_report=NextReport;
|
link_type == "next_report"? inverse_report=PreviousReport : inverse_report=NextReport;
|
||||||
|
|
||||||
|
//We make these connections, to be always aware about the conductor properties
|
||||||
|
connect (terminals().first(), &Terminal::conductorWasAdded, this, &ReportElement::conductorWasAdded);
|
||||||
|
connect (terminals().first(), &Terminal::conductorWasRemoved, this, &ReportElement::conductorWasRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReportElement::~ReportElement() {
|
/**
|
||||||
|
* @brief ReportElement::~ReportElement
|
||||||
|
* Destructor
|
||||||
|
*/
|
||||||
|
ReportElement::~ReportElement()
|
||||||
|
{
|
||||||
unlinkAllElements();
|
unlinkAllElements();
|
||||||
|
disconnect(terminals().first(), 0, 0, 0);
|
||||||
|
if (m_watched_conductor)
|
||||||
|
disconnect(m_watched_conductor, &Conductor::propertiesChange, this, &ReportElement::updateLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,10 +76,8 @@ void ReportElement::linkToElement(Element * elmt)
|
|||||||
|
|
||||||
//ensure elmt isn't already linked
|
//ensure elmt isn't already linked
|
||||||
bool i = true;
|
bool i = true;
|
||||||
if (!this -> isFree())
|
if (!this -> isFree() && (connected_elements.first() == elmt))
|
||||||
{
|
i = false;
|
||||||
if (connected_elements.first() == elmt) i = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//ensure elmt is an inverse report of this element
|
//ensure elmt is an inverse report of this element
|
||||||
if ((elmt->linkType() == inverse_report) && i)
|
if ((elmt->linkType() == inverse_report) && i)
|
||||||
@@ -76,11 +89,18 @@ void ReportElement::linkToElement(Element * elmt)
|
|||||||
connect(elmt, SIGNAL( yChanged() ), this, SLOT( updateLabel() ));
|
connect(elmt, SIGNAL( yChanged() ), this, SLOT( updateLabel() ));
|
||||||
connect(diagram(), SIGNAL( reportPropertiesChanged(QString) ), this, SLOT( setLabel(QString) ));
|
connect(diagram(), SIGNAL( reportPropertiesChanged(QString) ), this, SLOT( setLabel(QString) ));
|
||||||
connect(diagram() -> project(), SIGNAL( projectDiagramsOrderChanged(QETProject*,int,int) ), this, SLOT( updateLabel() ));
|
connect(diagram() -> project(), SIGNAL( projectDiagramsOrderChanged(QETProject*,int,int) ), this, SLOT( updateLabel() ));
|
||||||
|
connect(elmt->terminals().first(), &Terminal::conductorWasAdded, this, &ReportElement::conductorWasAdded);
|
||||||
|
connect(elmt->terminals().first(), &Terminal::conductorWasRemoved, this, &ReportElement::conductorWasRemoved);
|
||||||
|
|
||||||
label_ = diagram() -> defaultReportProperties();
|
label_ = diagram() -> defaultReportProperties();
|
||||||
|
|
||||||
|
if (!m_watched_conductor && elmt->conductors().size())
|
||||||
|
conductorWasAdded(elmt->conductors().first());
|
||||||
|
else
|
||||||
updateLabel();
|
updateLabel();
|
||||||
|
|
||||||
elmt -> linkToElement(this);
|
elmt -> linkToElement(this);
|
||||||
|
|
||||||
emit linkedElementChanged();
|
emit linkedElementChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,8 +111,8 @@ void ReportElement::linkToElement(Element * elmt)
|
|||||||
*/
|
*/
|
||||||
void ReportElement::unlinkAllElements()
|
void ReportElement::unlinkAllElements()
|
||||||
{
|
{
|
||||||
if (!isFree())
|
if (isFree()) return;
|
||||||
{
|
|
||||||
QList <Element *> tmp_elmt = connected_elements;
|
QList <Element *> tmp_elmt = connected_elements;
|
||||||
|
|
||||||
foreach(Element *elmt, connected_elements)
|
foreach(Element *elmt, connected_elements)
|
||||||
@@ -100,8 +120,13 @@ void ReportElement::unlinkAllElements()
|
|||||||
disconnect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
|
disconnect(elmt, SIGNAL(xChanged()), this, SLOT(updateLabel()));
|
||||||
disconnect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
|
disconnect(elmt, SIGNAL(yChanged()), this, SLOT(updateLabel()));
|
||||||
disconnect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
|
disconnect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
|
||||||
|
disconnect(elmt->terminals().first(), &Terminal::conductorWasAdded, this, &ReportElement::conductorWasAdded);
|
||||||
|
disconnect(elmt->terminals().first(), &Terminal::conductorWasRemoved, this, &ReportElement::conductorWasRemoved);
|
||||||
|
connected_elements.removeAll(elmt);
|
||||||
|
//if elmt is the owner of m_watched_conductor, we remove it
|
||||||
|
if (elmt->conductors().contains(m_watched_conductor))
|
||||||
|
conductorWasRemoved(m_watched_conductor);
|
||||||
}
|
}
|
||||||
connected_elements.clear();
|
|
||||||
updateLabel();
|
updateLabel();
|
||||||
|
|
||||||
foreach(Element *elmt, tmp_elmt)
|
foreach(Element *elmt, tmp_elmt)
|
||||||
@@ -111,7 +136,6 @@ void ReportElement::unlinkAllElements()
|
|||||||
}
|
}
|
||||||
emit linkedElementChanged();
|
emit linkedElementChanged();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @brief ReportElement::unlinkElement
|
* @brief ReportElement::unlinkElement
|
||||||
*unlink the specified element.
|
*unlink the specified element.
|
||||||
@@ -124,6 +148,44 @@ void ReportElement::unlinkElement(Element *elmt) {
|
|||||||
unlinkAllElements();
|
unlinkAllElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ReportElement::conductorWasAdded
|
||||||
|
* This method is called when a conduxtor is added to the potential
|
||||||
|
* @param conductor : added conductor
|
||||||
|
*/
|
||||||
|
void ReportElement::conductorWasAdded(Conductor *conductor)
|
||||||
|
{
|
||||||
|
if (m_watched_conductor) return;
|
||||||
|
|
||||||
|
m_watched_conductor = conductor;
|
||||||
|
connect(m_watched_conductor, &Conductor::propertiesChange, this, &ReportElement::updateLabel);
|
||||||
|
updateLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ReportElement::conductorWasRemoved
|
||||||
|
* This method is called when a conductor is removed to the potential
|
||||||
|
* @param conductor : removed conductor
|
||||||
|
*/
|
||||||
|
void ReportElement::conductorWasRemoved(Conductor *conductor)
|
||||||
|
{
|
||||||
|
if (m_watched_conductor != conductor) return;
|
||||||
|
|
||||||
|
disconnect(m_watched_conductor, &Conductor::propertiesChange, this, &ReportElement::updateLabel);
|
||||||
|
m_watched_conductor = nullptr;
|
||||||
|
|
||||||
|
//Get another conductor to be always up to date about the properties of the potential.
|
||||||
|
|
||||||
|
//Get a conducteur docked to this report
|
||||||
|
if (conductors().size())
|
||||||
|
conductorWasAdded(conductors().first());
|
||||||
|
//Else we get a conductor of the linked report (if any)
|
||||||
|
else if (linkedElements().size() && linkedElements().first()->conductors().size())
|
||||||
|
conductorWasAdded(linkedElements().first()->conductors().first());
|
||||||
|
else
|
||||||
|
updateLabel();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ReportElement::setLabel
|
* @brief ReportElement::setLabel
|
||||||
* Set new label and call updatelabel
|
* Set new label and call updatelabel
|
||||||
@@ -153,7 +215,8 @@ void ReportElement::updateLabel()
|
|||||||
m_text_field -> setPlainText(label);
|
m_text_field -> setPlainText(label);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
m_text_field -> setPlainText("/");
|
m_text_field -> setPlainText("/");
|
||||||
}
|
|
||||||
|
setTaggedText("function", (m_watched_conductor? m_watched_conductor->properties().m_function : ""));
|
||||||
|
setTaggedText("tension-protocol", (m_watched_conductor? m_watched_conductor->properties().m_tension_protocol : ""));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ class ElementTextItem;
|
|||||||
*this class represent an element that can be linked to an other ReportElement
|
*this class represent an element that can be linked to an other ReportElement
|
||||||
* a folio report in a diagram is a element that show a wire go on an other folio
|
* a folio report in a diagram is a element that show a wire go on an other folio
|
||||||
*/
|
*/
|
||||||
class ReportElement : public CustomElement {
|
class ReportElement : public CustomElement
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public :
|
public :
|
||||||
@@ -42,8 +42,11 @@ class ReportElement : public CustomElement {
|
|||||||
int inverse_report;
|
int inverse_report;
|
||||||
QString label_;
|
QString label_;
|
||||||
ElementTextItem *m_text_field;
|
ElementTextItem *m_text_field;
|
||||||
|
Conductor *m_watched_conductor;
|
||||||
|
|
||||||
signals:
|
private:
|
||||||
|
void conductorWasAdded(Conductor *conductor);
|
||||||
|
void conductorWasRemoved(Conductor *conductor);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setLabel (QString label);
|
void setLabel (QString label);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ void Terminal::init(QPointF pf, Qet::Orientation o, QString number, QString name
|
|||||||
@param s Scene sur laquelle figure cette borne
|
@param s Scene sur laquelle figure cette borne
|
||||||
*/
|
*/
|
||||||
Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e) :
|
Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e) :
|
||||||
QGraphicsItem(e),
|
QGraphicsObject(e),
|
||||||
m_draw_help_line(false),
|
m_draw_help_line(false),
|
||||||
m_help_line (nullptr),
|
m_help_line (nullptr),
|
||||||
m_help_line_a (nullptr),
|
m_help_line_a (nullptr),
|
||||||
@@ -97,7 +97,7 @@ Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e) :
|
|||||||
@param s Scene sur laquelle figure cette borne
|
@param s Scene sur laquelle figure cette borne
|
||||||
*/
|
*/
|
||||||
Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e) :
|
Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e) :
|
||||||
QGraphicsItem(e),
|
QGraphicsObject(e),
|
||||||
m_draw_help_line (false),
|
m_draw_help_line (false),
|
||||||
m_help_line (nullptr),
|
m_help_line (nullptr),
|
||||||
m_help_line_a (nullptr),
|
m_help_line_a (nullptr),
|
||||||
@@ -118,7 +118,7 @@ Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e) :
|
|||||||
@param s Scene sur laquelle figure cette borne
|
@param s Scene sur laquelle figure cette borne
|
||||||
*/
|
*/
|
||||||
Terminal::Terminal(QPointF pf, Qet::Orientation o, QString num, QString name, bool hiddenName, Element *e) :
|
Terminal::Terminal(QPointF pf, Qet::Orientation o, QString num, QString name, bool hiddenName, Element *e) :
|
||||||
QGraphicsItem (e),
|
QGraphicsObject (e),
|
||||||
m_draw_help_line (false),
|
m_draw_help_line (false),
|
||||||
m_help_line (nullptr),
|
m_help_line (nullptr),
|
||||||
m_help_line_a (nullptr),
|
m_help_line_a (nullptr),
|
||||||
@@ -179,41 +179,41 @@ void Terminal::setName(QString name, bool hiddenName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Attribue un conductor a la borne
|
* @brief Terminal::addConductor
|
||||||
@param f Le conducteur a rattacher a cette borne
|
* Add a conductor to this terminal
|
||||||
|
* @param conductor : the conductor to add.
|
||||||
|
* @return true if the conductor was successfully added
|
||||||
*/
|
*/
|
||||||
bool Terminal::addConductor(Conductor *f) {
|
bool Terminal::addConductor(Conductor *conductor)
|
||||||
// pointeur 0 refuse
|
{
|
||||||
if (!f) return(false);
|
if (!conductor) return(false);
|
||||||
|
|
||||||
// une seule des deux bornes du conducteur doit etre this
|
Q_ASSERT_X(((conductor -> terminal1 == this) ^ (conductor -> terminal2 == this)), "Terminal::addConductor", "The conductor must be linked exactly once to this terminal");
|
||||||
Q_ASSERT_X(((f -> terminal1 == this) ^ (f -> terminal2 == this)), "Terminal::addConductor", "Le conductor devrait etre relie exactement une fois a la terminal en cours");
|
|
||||||
|
|
||||||
// determine l'autre borne a laquelle cette borne va etre relie grace au conducteur
|
//Get the other terminal where the conductor must be linked
|
||||||
Terminal *autre_terminal = (f -> terminal1 == this) ? f -> terminal2 : f -> terminal1;
|
Terminal *other_terminal = (conductor -> terminal1 == this) ? conductor->terminal2 : conductor->terminal1;
|
||||||
|
|
||||||
// verifie que la borne n'est pas deja reliee avec l'autre borne
|
//Check if this terminal isn't already linked with other_terminal
|
||||||
bool deja_liees = false;
|
foreach (Conductor* cond, conductors_)
|
||||||
foreach (Conductor* conductor, conductors_) {
|
if (cond -> terminal1 == other_terminal || cond -> terminal2 == other_terminal)
|
||||||
if (conductor -> terminal1 == autre_terminal || conductor -> terminal2 == autre_terminal) deja_liees = true;
|
return false; //They already a conductor linked to this and other_terminal
|
||||||
}
|
|
||||||
|
|
||||||
// si les deux bornes sont deja reliees, on refuse d'ajouter le conducteur
|
conductors_.append(conductor);
|
||||||
if (deja_liees) return(false);
|
emit conductorWasAdded(conductor);
|
||||||
|
|
||||||
// sinon on ajoute le conducteur
|
|
||||||
conductors_.append(f);
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Enleve un conducteur donne a la borne
|
* @brief Terminal::removeConductor
|
||||||
@param f Conducteur a enlever
|
* Remove a conductor from this terminal
|
||||||
|
* @param conductor : conductor to remove
|
||||||
*/
|
*/
|
||||||
void Terminal::removeConductor(Conductor *f) {
|
void Terminal::removeConductor(Conductor *conductor)
|
||||||
int index = conductors_.indexOf(f);
|
{
|
||||||
|
int index = conductors_.indexOf(conductor);
|
||||||
if (index == -1) return;
|
if (index == -1) return;
|
||||||
conductors_.removeAt(index);
|
conductors_.removeAt(index);
|
||||||
|
emit conductorWasRemoved(conductor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,7 +27,13 @@ class Element;
|
|||||||
This class represents a terminal of an electrical element, i.e. a possible
|
This class represents a terminal of an electrical element, i.e. a possible
|
||||||
plug point for conductors.
|
plug point for conductors.
|
||||||
*/
|
*/
|
||||||
class Terminal : public QGraphicsItem {
|
class Terminal : public QGraphicsObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void conductorWasAdded(Conductor *conductor);
|
||||||
|
void conductorWasRemoved(Conductor *conductor);
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
@@ -52,8 +58,8 @@ class Terminal : public QGraphicsItem {
|
|||||||
|
|
||||||
// methods to manage conductors attached to the terminal
|
// methods to manage conductors attached to the terminal
|
||||||
Terminal* alignedWithTerminal () const;
|
Terminal* alignedWithTerminal () const;
|
||||||
bool addConductor (Conductor *);
|
bool addConductor (Conductor *conductor);
|
||||||
void removeConductor (Conductor *);
|
void removeConductor (Conductor *conductor);
|
||||||
int conductorsCount () const;
|
int conductorsCount () const;
|
||||||
Diagram *diagram () const;
|
Diagram *diagram () const;
|
||||||
Element *parentElement () const;
|
Element *parentElement () const;
|
||||||
|
|||||||
Reference in New Issue
Block a user