mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 08:10:52 +01:00
Revert "Merge branch 'XMLPropertiesNew'"
**Break a lot of thing.** This reverts commit1db1800572, reversing changes made to4c563821e8.
This commit is contained in:
@@ -25,8 +25,6 @@
|
||||
#include "../qetgraphicsitem/element.h"
|
||||
#include "conductortextitem.h"
|
||||
|
||||
#include "../qetxml.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
QColor Terminal::neutralColor = QColor(Qt::blue);
|
||||
@@ -43,7 +41,7 @@ const qreal Terminal::Z = 1000;
|
||||
@param name of terminal
|
||||
@param hiddenName
|
||||
*/
|
||||
void Terminal::init(QString number, QString name, bool hiddenName)
|
||||
void Terminal::init()
|
||||
{
|
||||
//Calcul the docking point of the element
|
||||
//m_pos of d is the docking point of conductor
|
||||
@@ -64,13 +62,7 @@ void Terminal::init(QString number, QString name, bool hiddenName)
|
||||
origin += QPointF(-3.0, -3.0);
|
||||
qreal w = qAbs(dcx - dex) + 7;
|
||||
qreal h = qAbs(dcy - dey) + 7;
|
||||
m_br = QRectF(origin, QSizeF(w, h));
|
||||
|
||||
// Number of terminal
|
||||
number_terminal_ = std::move(number);
|
||||
// Name of terminal
|
||||
d->m_name = std::move(name);
|
||||
name_terminal_hidden = hiddenName;
|
||||
m_br = QRectF(origin, QSizeF(w, h));
|
||||
|
||||
setAcceptHoverEvents(true);
|
||||
setAcceptedMouseButtons(Qt::LeftButton);
|
||||
@@ -78,92 +70,13 @@ void Terminal::init(QString number, QString name, bool hiddenName)
|
||||
setZValue(Z);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Terminal::init
|
||||
Additionaly to the init above, this method stores position and orientation into the data class
|
||||
\param pf
|
||||
\param o
|
||||
\param number
|
||||
\param name
|
||||
\param hiddenName
|
||||
*/
|
||||
void Terminal::init(
|
||||
QPointF pf,
|
||||
Qet::Orientation o,
|
||||
QString number,
|
||||
QString name,
|
||||
bool hiddenName)
|
||||
{
|
||||
setTagName("terminal");
|
||||
// definition du pount d'amarrage pour un conducteur
|
||||
d->m_pos = pf;
|
||||
|
||||
// definition de l'orientation de la borne (par defaut : sud)
|
||||
if (o < Qet::North || o > Qet::West) d->m_orientation = Qet::South;
|
||||
else d->m_orientation = o;
|
||||
|
||||
init(number, name, hiddenName);
|
||||
}
|
||||
|
||||
/**
|
||||
initialise une borne
|
||||
@param pf position du point d'amarrage pour un conducteur
|
||||
@param o orientation de la borne : Qt::Horizontal ou Qt::Vertical
|
||||
@param e Element auquel cette borne appartient
|
||||
*/
|
||||
Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e) :
|
||||
QGraphicsObject(e),
|
||||
d(new TerminalData(this)),
|
||||
parent_element_ (e)
|
||||
{
|
||||
init(pf, o, "_", "_", false);
|
||||
}
|
||||
|
||||
/**
|
||||
initialise une borne
|
||||
@param pf_x Abscisse du point d'amarrage pour un conducteur
|
||||
@param pf_y Ordonnee du point d'amarrage pour un conducteur
|
||||
@param o orientation de la borne : Qt::Horizontal ou Qt::Vertical
|
||||
@param e Element auquel cette borne appartient
|
||||
*/
|
||||
Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e) :
|
||||
QGraphicsObject(e),
|
||||
d(new TerminalData(this)),
|
||||
parent_element_ (e)
|
||||
{
|
||||
init(QPointF(pf_x, pf_y), o, "_", "_", false);
|
||||
}
|
||||
|
||||
/**
|
||||
initialise une borne
|
||||
@param pf position du point d'amarrage pour un conducteur
|
||||
@param o orientation de la borne : Qt::Horizontal ou Qt::Vertical
|
||||
@param num number of terminal (ex 3 - 4 for NO)
|
||||
@param name of terminal
|
||||
@param hiddenName hide or show the name
|
||||
@param e Element auquel cette borne appartient
|
||||
*/
|
||||
Terminal::Terminal(
|
||||
QPointF pf,
|
||||
Qet::Orientation o,
|
||||
QString num,
|
||||
QString name,
|
||||
bool hiddenName,
|
||||
Element *e) :
|
||||
QGraphicsObject (e),
|
||||
d(new TerminalData(this)),
|
||||
parent_element_ (e)
|
||||
{
|
||||
init(pf, o, std::move(num), std::move(name), hiddenName);
|
||||
}
|
||||
|
||||
Terminal::Terminal(TerminalData* data, Element* e) :
|
||||
QGraphicsObject(e),
|
||||
d(data),
|
||||
parent_element_(e)
|
||||
{
|
||||
d->setParent(this);
|
||||
init("_", "_", false);
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,7 +84,7 @@ Terminal::Terminal(TerminalData* data, Element* e) :
|
||||
* Destruction of the terminal, and also docked conductor
|
||||
*/
|
||||
Terminal::~Terminal() {
|
||||
qDeleteAll(m_conductors_list);
|
||||
qDeleteAll(m_conductors_list);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,34 +110,6 @@ Qet::Orientation Terminal::orientation() const
|
||||
} else return(d->m_orientation);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Terminal::setNumber
|
||||
@param number
|
||||
*/
|
||||
void Terminal::setNumber(QString number)
|
||||
{
|
||||
number_terminal_ = std::move(number);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Terminal::setName
|
||||
@param name : QString
|
||||
@param hiddenName : bool
|
||||
*/
|
||||
void Terminal::setName(QString name, bool hiddenName)
|
||||
{
|
||||
d->m_name = std::move(name);
|
||||
name_terminal_hidden = hiddenName;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Terminal::name
|
||||
@return the name of terminal.
|
||||
*/
|
||||
inline QString Terminal::name() const {
|
||||
return(d->m_name);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Terminal::addConductor
|
||||
Add a conductor to this terminal
|
||||
@@ -290,8 +175,8 @@ void Terminal::paint(
|
||||
painter -> save();
|
||||
|
||||
//annulation des renderhints
|
||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||
|
||||
// on travaille avec les coordonnees de l'element parent
|
||||
@@ -425,7 +310,7 @@ void Terminal::drawHelpLine(bool draw)
|
||||
QLineF Terminal::HelpLine() const
|
||||
{
|
||||
QPointF scene_dock = dockConductor();
|
||||
QRectF rect = diagram() -> border_and_titleblock.insideBorderRect();
|
||||
QRectF rect = diagram() -> border_and_titleblock.insideBorderRect();
|
||||
|
||||
QLineF line(scene_dock , QPointF());
|
||||
|
||||
@@ -503,7 +388,7 @@ Terminal* Terminal::alignedWithTerminal() const
|
||||
|
||||
//Available_terminals have several terminals, we get the nearest terminal
|
||||
line.setP2(available_terminals.first() -> dockConductor());
|
||||
qreal current_lenght = line.length();
|
||||
qreal current_lenght = line.length();
|
||||
Terminal *nearest_terminal = available_terminals.takeFirst();
|
||||
|
||||
//Search the nearest terminal to this one
|
||||
@@ -572,7 +457,7 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
|
||||
//setCursor(Qt::CrossCursor);
|
||||
|
||||
// d'un mouvement a l'autre, il faut retirer l'effet hover de la borne precedente
|
||||
if (m_previous_terminal) {
|
||||
if (m_previous_terminal) {
|
||||
if (m_previous_terminal == this) m_hovered = true;
|
||||
else m_previous_terminal -> m_hovered = false;
|
||||
m_previous_terminal -> m_hovered_color = m_previous_terminal -> neutralColor;
|
||||
@@ -739,10 +624,6 @@ bool Terminal::canBeLinkedTo(Terminal *other_terminal)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Terminal::setID(int id) {
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Terminal::conductors
|
||||
@return La liste des conducteurs lies a cette borne
|
||||
@@ -753,19 +634,22 @@ QList<Conductor *> Terminal::conductors() const
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Terminal::toXmlPriv
|
||||
@brief Terminal::toXml
|
||||
Methode d'export en XML
|
||||
@param doc Le Document XML a utiliser pour creer l'element XML
|
||||
@return un QDomElement representant cette borne
|
||||
*/
|
||||
void Terminal::toXmlPriv(QDomElement &qdo) const
|
||||
QDomElement Terminal::toXml(QDomDocument &doc) const
|
||||
{
|
||||
// for backward compatibility
|
||||
qdo.setAttribute("x", QString("%1").arg(dock_elmt_.x()));
|
||||
qdo.setAttribute("y", QString("%1").arg(dock_elmt_.y()));
|
||||
// end for backward compatibility
|
||||
QDomElement qdo = doc.createElement("terminal");
|
||||
|
||||
qdo.setAttribute("orientation", d->m_orientation);
|
||||
// for backward compatibility
|
||||
qdo.setAttribute("x", QString("%1").arg(dock_elmt_.x()));
|
||||
qdo.setAttribute("y", QString("%1").arg(dock_elmt_.y()));
|
||||
// end for backward compatibility
|
||||
|
||||
qdo.setAttribute("orientation", d->m_orientation);
|
||||
return(qdo);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -774,25 +658,42 @@ void Terminal::toXmlPriv(QDomElement &qdo) const
|
||||
@param terminal Le QDomElement a analyser
|
||||
@return true si le QDomElement passe en parametre est une borne, false sinon
|
||||
*/
|
||||
bool Terminal::valideXml(const QDomElement &terminal)
|
||||
bool Terminal::valideXml(QDomElement &terminal)
|
||||
{
|
||||
// verifie le nom du tag
|
||||
if (terminal.tagName() != "terminal") return(false);
|
||||
|
||||
// affuteuse_250h.qet contains in line 8398 terminals which do not have this
|
||||
// if (QETXML::propertyString(terminal, "number"))
|
||||
// return false;
|
||||
// affuteuse_250h.qet contains in line 8398 terminals which do not have this
|
||||
// if (QETXML::propertyBool(terminal, "nameHidden"))
|
||||
// return false;
|
||||
// verifie la presence des attributs minimaux
|
||||
if (!terminal.hasAttribute("x")) return(false);
|
||||
if (!terminal.hasAttribute("y")) return(false);
|
||||
if (!terminal.hasAttribute("orientation")) return(false);
|
||||
|
||||
if (!TerminalData::valideXml(terminal))
|
||||
return false;
|
||||
bool conv_ok;
|
||||
// parse l'abscisse
|
||||
terminal.attribute("x").toDouble(&conv_ok);
|
||||
if (!conv_ok) return(false);
|
||||
|
||||
// parse l'ordonnee
|
||||
terminal.attribute("y").toDouble(&conv_ok);
|
||||
if (!conv_ok) return(false);
|
||||
|
||||
// parse l'id
|
||||
terminal.attribute("id").toInt(&conv_ok);
|
||||
if (!conv_ok) return(false);
|
||||
|
||||
// parse l'orientation
|
||||
int terminal_or = terminal.attribute("orientation").toInt(&conv_ok);
|
||||
if (!conv_ok) return(false);
|
||||
if (terminal_or != Qet::North
|
||||
&& terminal_or != Qet::South
|
||||
&& terminal_or != Qet::East
|
||||
&& terminal_or != Qet::West) return(false);
|
||||
|
||||
// a ce stade, la borne est syntaxiquement correcte
|
||||
return true;
|
||||
return(true);
|
||||
}
|
||||
|
||||
/** RETURNS True
|
||||
/**
|
||||
@brief Terminal::fromXml
|
||||
Permet de savoir si un element XML represente cette borne. Attention,
|
||||
l'element XML n'est pas verifie
|
||||
@@ -800,17 +701,13 @@ bool Terminal::valideXml(const QDomElement &terminal)
|
||||
@return true si la borne "se reconnait"
|
||||
(memes coordonnes, meme orientation), false sinon
|
||||
*/
|
||||
bool Terminal::fromXmlPriv(const QDomElement &terminal) {
|
||||
QETXML::propertyString(terminal, "number", &number_terminal_);
|
||||
|
||||
QETXML::propertyBool(terminal, "nameHidden", &name_terminal_hidden);
|
||||
|
||||
if(!d->fromXml(terminal))
|
||||
return false;
|
||||
|
||||
|
||||
init(number_terminal_, d->m_name, name_terminal_hidden); // initialize dock_elmt_. This must be done after Terminal data is initialized
|
||||
return true;
|
||||
bool Terminal::fromXml(QDomElement &terminal)
|
||||
{
|
||||
return (
|
||||
qFuzzyCompare(terminal.attribute("x").toDouble(), dock_elmt_.x()) &&
|
||||
qFuzzyCompare(terminal.attribute("y").toDouble(), dock_elmt_.y()) &&
|
||||
(terminal.attribute("orientation").toInt() == d->m_orientation)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -847,18 +744,6 @@ QUuid Terminal::uuid() const
|
||||
return d->m_uuid;
|
||||
}
|
||||
|
||||
int Terminal::ID() const {
|
||||
return m_id;
|
||||
}
|
||||
|
||||
QPointF Terminal::dockPos() {
|
||||
return dock_elmt_;
|
||||
}
|
||||
|
||||
QPointF Terminal::originPos() {
|
||||
return d->m_pos;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Conductor::relatedPotentialTerminal
|
||||
Return terminal at the same potential from the same
|
||||
|
||||
Reference in New Issue
Block a user