mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-09 07:09:59 +01:00
Fix indentation code + Mod doc
This commit is contained in:
@@ -3,16 +3,16 @@
|
|||||||
#include <QGraphicsObject>
|
#include <QGraphicsObject>
|
||||||
|
|
||||||
TerminalData::TerminalData():
|
TerminalData::TerminalData():
|
||||||
PropertiesInterface()
|
PropertiesInterface()
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminalData::TerminalData(QGraphicsObject *parent):
|
TerminalData::TerminalData(QGraphicsObject *parent):
|
||||||
PropertiesInterface(),
|
PropertiesInterface(),
|
||||||
q(parent)
|
q(parent)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerminalData::init() {
|
void TerminalData::init() {
|
||||||
@@ -23,65 +23,114 @@ TerminalData::~TerminalData()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief TerminalData::setParent
|
||||||
|
@param parent
|
||||||
|
*/
|
||||||
void TerminalData::setParent(QGraphicsObject* parent)
|
void TerminalData::setParent(QGraphicsObject* parent)
|
||||||
{
|
{
|
||||||
q = parent;
|
q = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief TerminalData::toSettings
|
||||||
|
Save properties to setting file.
|
||||||
|
|
||||||
|
QString is use for prefix a word befor the name of each paramètre
|
||||||
|
@param settings UNUSED
|
||||||
|
*/
|
||||||
void TerminalData::toSettings(QSettings &settings, const QString) const
|
void TerminalData::toSettings(QSettings &settings, const QString) const
|
||||||
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(settings);
|
Q_UNUSED(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief TerminalData::fromSettings
|
||||||
|
load properties to setting file.
|
||||||
|
|
||||||
|
QString is use for prefix a word befor the name of each paramètre
|
||||||
|
@param settings UNUSED
|
||||||
|
*/
|
||||||
void TerminalData::fromSettings(const QSettings &settings, const QString)
|
void TerminalData::fromSettings(const QSettings &settings, const QString)
|
||||||
{
|
{
|
||||||
Q_UNUSED(settings);
|
Q_UNUSED(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief TerminalData::toXml
|
||||||
|
Save properties to xml element
|
||||||
|
write the name, number, position and orientation of the terminal
|
||||||
|
to xml_element
|
||||||
|
|
||||||
|
@note This method is only called from the PartTerminal
|
||||||
|
and should never called from the Terminal class
|
||||||
|
@param xml_document
|
||||||
|
@return xml_element : DomElement with
|
||||||
|
the name, number, position and orientation of the terminal
|
||||||
|
*/
|
||||||
QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement("terminal");
|
QDomElement xml_element = xml_document.createElement("terminal");
|
||||||
|
|
||||||
// ecrit la position de la borne
|
// write the position of the terminal
|
||||||
xml_element.setAttribute("x", QString("%1").arg(q->scenePos().x()));
|
// ecrit la position de la borne
|
||||||
xml_element.setAttribute("y", QString("%1").arg(q->scenePos().y()));
|
xml_element.setAttribute("x", QString("%1").arg(q->scenePos().x()));
|
||||||
|
xml_element.setAttribute("y", QString("%1").arg(q->scenePos().y()));
|
||||||
|
|
||||||
|
// Write name and number to XML
|
||||||
|
xml_element.setAttribute("uuid", m_uuid.toString());
|
||||||
|
xml_element.setAttribute("name", m_name);
|
||||||
|
|
||||||
xml_element.setAttribute("uuid", m_uuid.toString());
|
// write the orientation of the terminal
|
||||||
xml_element.setAttribute("name", m_name);
|
// ecrit l'orientation de la borne
|
||||||
|
xml_element.setAttribute("orientation",
|
||||||
|
Qet::orientationToString(m_orientation));
|
||||||
|
|
||||||
// ecrit l'orientation de la borne
|
return(xml_element);
|
||||||
xml_element.setAttribute("orientation", Qet::orientationToString(m_orientation));
|
|
||||||
// Write name and number to XML
|
|
||||||
|
|
||||||
return(xml_element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief TerminalData::fromXml
|
||||||
|
load properties to xml element
|
||||||
|
|
||||||
|
@note This method is only called from the PartTerminal
|
||||||
|
and should never called from the Terminal class
|
||||||
|
@param xml_element
|
||||||
|
@return true if succeeded / false if the attribute is not real
|
||||||
|
*/
|
||||||
bool TerminalData::fromXml (const QDomElement &xml_element)
|
bool TerminalData::fromXml (const QDomElement &xml_element)
|
||||||
{
|
{
|
||||||
// lit la position de la borne
|
qreal term_x = 0.0;
|
||||||
qreal term_x = 0.0, term_y = 0.0;
|
qreal term_y = 0.0;
|
||||||
if (!QET::attributeIsAReal(xml_element, "x", &term_x))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!QET::attributeIsAReal(xml_element, "y", &term_y))
|
// reads the position of the terminal
|
||||||
return false;
|
// lit la position de la borne
|
||||||
|
if (!QET::attributeIsAReal(xml_element, "x", &term_x))
|
||||||
|
return false;
|
||||||
|
|
||||||
m_pos = QPointF(term_x, term_y);
|
if (!QET::attributeIsAReal(xml_element, "y", &term_y))
|
||||||
|
return false;
|
||||||
|
|
||||||
//emit posFromXML(QPointF(term_x, term_y));
|
m_pos = QPointF(term_x, term_y);
|
||||||
|
|
||||||
QString uuid = xml_element.attribute("uuid");
|
//emit posFromXML(QPointF(term_x, term_y));
|
||||||
// update part and add uuid, which is used in the new version to connect terminals together
|
|
||||||
// if the attribute not exists, means, the element is created with an older version of qet. So use the legacy approach
|
|
||||||
// to identify terminals
|
|
||||||
if (!uuid.isEmpty())
|
|
||||||
m_uuid = QUuid(uuid);
|
|
||||||
|
|
||||||
m_name = xml_element.attribute("name");
|
QString uuid = xml_element.attribute("uuid");
|
||||||
|
// update part and add uuid, which is used in the new version
|
||||||
|
// to connect terminals together
|
||||||
|
// if the attribute not exists, means, the element is created with an
|
||||||
|
// older version of qet. So use the legacy approach
|
||||||
|
// to identify terminals
|
||||||
|
if (!uuid.isEmpty())
|
||||||
|
m_uuid = QUuid(uuid);
|
||||||
|
|
||||||
// lit l'orientation de la borne
|
m_name = xml_element.attribute("name");
|
||||||
m_orientation = Qet::orientationFromString(xml_element.attribute("orientation"));
|
|
||||||
|
|
||||||
return true;
|
// read the orientation of the terminal
|
||||||
|
// lit l'orientation de la borne
|
||||||
|
m_orientation = Qet::orientationFromString(
|
||||||
|
xml_element.attribute("orientation"));
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,62 +18,70 @@ class QGraphicsObject;
|
|||||||
*/
|
*/
|
||||||
class TerminalData : public PropertiesInterface
|
class TerminalData : public PropertiesInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TerminalData();
|
TerminalData();
|
||||||
TerminalData(QGraphicsObject* parent);
|
TerminalData(QGraphicsObject* parent);
|
||||||
~TerminalData();
|
~TerminalData();
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void setParent(QGraphicsObject* parent);
|
void setParent(QGraphicsObject* parent);
|
||||||
|
void toSettings(QSettings &settings,
|
||||||
|
const QString = QString()) const override;
|
||||||
|
void fromSettings(const QSettings &settings,
|
||||||
|
const QString = QString()) override;
|
||||||
|
QDomElement toXml(QDomDocument &xml_element) const override;
|
||||||
|
bool fromXml(const QDomElement &xml_element) override;
|
||||||
|
|
||||||
// Save/load properties to setting file. QString is use for prefix a word befor the name of each paramètre
|
// must be public, because this class is a private member
|
||||||
void toSettings(QSettings &settings, const QString = QString()) const override;
|
// of PartTerminal/Terminal and they must access this data
|
||||||
void fromSettings(const QSettings &settings, const QString = QString()) override;
|
public:
|
||||||
// Save/load properties to xml element
|
/**
|
||||||
// This method is only called from the PartTerminal and should never called from the Terminal class
|
@brief m_orientation
|
||||||
QDomElement toXml(QDomDocument &xml_element) const override;
|
Orientation of the terminal
|
||||||
bool fromXml(const QDomElement &xml_element) override;
|
*/
|
||||||
|
Qet::Orientation m_orientation;
|
||||||
|
/**
|
||||||
|
@brief second_point
|
||||||
|
Position of the second point of the terminal
|
||||||
|
in scene coordinates
|
||||||
|
*/
|
||||||
|
QPointF second_point;
|
||||||
|
/**
|
||||||
|
@brief m_uuid
|
||||||
|
Uuid of the terminal.
|
||||||
|
|
||||||
// must be public, because this class is a private member of PartTerminal/Terminal and they must
|
In elementscene.cpp an element gets a new uuid when
|
||||||
// access this data
|
saving the element. In the current state
|
||||||
public:
|
each connection is made by using the local position
|
||||||
/*!
|
of the terminal and a dynamic id. In the new
|
||||||
* \brief m_orientation
|
case, each terminal should have it's own uuid to
|
||||||
* Orientation of the terminal
|
identify it uniquely. When changing each time this
|
||||||
*/
|
uuid, the conductor after updating the part is anymore
|
||||||
Qet::Orientation m_orientation;
|
valid. So if in the loaded document a uuid exists,
|
||||||
/*!
|
use this one and don't create a new one.
|
||||||
* \brief second_point
|
*/
|
||||||
* Position of the second point of the terminal in scene coordinates
|
QUuid m_uuid;
|
||||||
*/
|
/**
|
||||||
QPointF second_point;
|
@brief m_name
|
||||||
/*!
|
Name of the element.
|
||||||
* \brief m_uuid
|
It can be used to create wiring harness tables
|
||||||
* Uuid of the terminal.
|
*/
|
||||||
*
|
QString m_name;
|
||||||
* In elementscene.cpp an element gets a new uuid when saving the element. In the current state
|
|
||||||
* each connection is made by using the local position of the terminal and a dynamic id. In the new
|
|
||||||
* case, each terminal should have it's own uuid to identify it uniquely. When changing each time this
|
|
||||||
* uuid, the conductor after updating the part is anymore valid. So if in the loaded document a uuid exists,
|
|
||||||
* use this one and don't create a new one.
|
|
||||||
*/
|
|
||||||
QUuid m_uuid;
|
|
||||||
/*!
|
|
||||||
* \brief m_name
|
|
||||||
* Name of the element. It can be used to create wiring harness tables
|
|
||||||
*/
|
|
||||||
QString m_name;
|
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
* \brief m_pos
|
@brief m_pos
|
||||||
* Position of the terminal. The second point is calculated from this position and the orientation
|
Position of the terminal. The second point is calculated
|
||||||
* Important: this variable is only updated during read from xml and not during mouse move!
|
from this position and the orientation
|
||||||
* It is used to store the initial position so that PartTerminal and Terminal have access to it.
|
@note
|
||||||
*/
|
Important: this variable is only updated during read
|
||||||
QPointF m_pos;
|
from xml and not during mouse move!
|
||||||
private:
|
It is used to store the initial position so that
|
||||||
QGraphicsObject* q{nullptr};
|
PartTerminal and Terminal have access to it.
|
||||||
|
*/
|
||||||
|
QPointF m_pos;
|
||||||
|
private:
|
||||||
|
QGraphicsObject* q{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TERMINALDATA_H
|
#endif // TERMINALDATA_H
|
||||||
|
|||||||
Reference in New Issue
Block a user