mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 22:00:35 +01:00
Merge branch 'XMLPropertiesNew'
This commit is contained in:
@@ -53,7 +53,7 @@ class QetGraphicsHandlerItem : public QGraphicsItem
|
|||||||
QRectF m_handler_rect,
|
QRectF m_handler_rect,
|
||||||
m_br;
|
m_br;
|
||||||
qreal m_size;
|
qreal m_size;
|
||||||
QColor m_color;
|
QColor m_color{Qt::black};
|
||||||
QPen m_pen;
|
QPen m_pen;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "borderproperties.h"
|
#include "borderproperties.h"
|
||||||
|
#include "qetxml.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief BorderProperties::BorderProperties
|
@brief BorderProperties::BorderProperties
|
||||||
@@ -32,15 +33,7 @@
|
|||||||
- 17 colonnes affichees de 60.0 px de large pour 20.0px de haut
|
- 17 colonnes affichees de 60.0 px de large pour 20.0px de haut
|
||||||
- 8 lignes affichees de 80.0 px de haut pour 20.0px de large
|
- 8 lignes affichees de 80.0 px de haut pour 20.0px de large
|
||||||
*/
|
*/
|
||||||
BorderProperties::BorderProperties() :
|
BorderProperties::BorderProperties(): PropertiesInterface("border")
|
||||||
columns_count(17),
|
|
||||||
columns_width(60.0),
|
|
||||||
columns_header_height(20.0),
|
|
||||||
display_columns(true),
|
|
||||||
rows_count(8),
|
|
||||||
rows_height(80.0),
|
|
||||||
rows_header_width(20.0),
|
|
||||||
display_rows(true)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +81,7 @@ bool BorderProperties::operator!=(const BorderProperties &bp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief BorderProperties::toXml
|
@brief BorderProperties::toXmlPriv
|
||||||
Exports dimensions as XML attributes added to element e.
|
Exports dimensions as XML attributes added to element e.
|
||||||
\~French Exporte les dimensions sous formes d'attributs XML ajoutes a l'element e.
|
\~French Exporte les dimensions sous formes d'attributs XML ajoutes a l'element e.
|
||||||
|
|
||||||
@@ -96,8 +89,7 @@ bool BorderProperties::operator!=(const BorderProperties &bp) {
|
|||||||
XML element to which attributes will be added
|
XML element to which attributes will be added
|
||||||
\~French Element XML auquel seront ajoutes des attributs
|
\~French Element XML auquel seront ajoutes des attributs
|
||||||
*/
|
*/
|
||||||
void BorderProperties::toXml(QDomElement &e) const
|
void BorderProperties::toXmlPriv(QDomElement& e) const {
|
||||||
{
|
|
||||||
e.setAttribute("cols", columns_count);
|
e.setAttribute("cols", columns_count);
|
||||||
e.setAttribute("colsize", QString("%1").arg(columns_width));
|
e.setAttribute("colsize", QString("%1").arg(columns_width));
|
||||||
e.setAttribute("rows", rows_count);
|
e.setAttribute("rows", rows_count);
|
||||||
@@ -106,8 +98,8 @@ void BorderProperties::toXml(QDomElement &e) const
|
|||||||
e.setAttribute("displayrows", display_rows ? "true" : "false");
|
e.setAttribute("displayrows", display_rows ? "true" : "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*!RETURNS True
|
||||||
@brief BorderProperties::fromXml
|
@brief BorderProperties::fromXmlPriv
|
||||||
Import dimensions from XML attributes of element e
|
Import dimensions from XML attributes of element e
|
||||||
\~French Importe les dimensions a partir des attributs XML de l'element e
|
\~French Importe les dimensions a partir des attributs XML de l'element e
|
||||||
|
|
||||||
@@ -115,13 +107,29 @@ void BorderProperties::toXml(QDomElement &e) const
|
|||||||
XML element whose attributes will be read
|
XML element whose attributes will be read
|
||||||
\~French Element XML dont les attributs seront lus
|
\~French Element XML dont les attributs seront lus
|
||||||
*/
|
*/
|
||||||
void BorderProperties::fromXml(QDomElement &e) {
|
bool BorderProperties::fromXmlPriv(const QDomElement &e) {
|
||||||
if (e.hasAttribute("cols")) columns_count = e.attribute("cols").toInt();
|
|
||||||
if (e.hasAttribute("colsize")) columns_width = e.attribute("colsize").toInt();
|
if (QETXML::propertyInteger(e, "cols", &columns_count) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
if (e.hasAttribute("rows")) rows_count = e.attribute("rows").toInt();
|
QETXML::propertyDouble(e, "colsize", &columns_width) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
if (e.hasAttribute("rowsize")) rows_height = e.attribute("rowsize").toInt();
|
QETXML::propertyInteger(e, "rows", &rows_count) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
if (e.hasAttribute("displaycols")) display_columns = e.attribute("displaycols") == "true";
|
QETXML::propertyDouble(e, "rowsize", &rows_height) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
if (e.hasAttribute("displayrows")) display_rows = e.attribute("displayrows") == "true";
|
QETXML::propertyBool(e, "displaycols", &display_columns) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyBool(e, "displayrows", &display_rows) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BorderProperties::valideXml(QDomElement& e) {
|
||||||
|
|
||||||
|
if (QETXML::propertyInteger(e, "cols") == QETXML::PropertyFlags::Success ||
|
||||||
|
QETXML::propertyDouble(e, "colsize") == QETXML::PropertyFlags::Success ||
|
||||||
|
QETXML::propertyInteger(e, "rows") == QETXML::PropertyFlags::Success ||
|
||||||
|
QETXML::propertyDouble(e, "rowsize") == QETXML::PropertyFlags::Success ||
|
||||||
|
QETXML::propertyBool(e, "displaycols") == QETXML::PropertyFlags::Success ||
|
||||||
|
QETXML::propertyBool(e, "displayrows") == QETXML::PropertyFlags::Success)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,13 +20,15 @@
|
|||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
|
|
||||||
|
#include "properties/propertiesinterface.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The BorderProperties class
|
@brief The BorderProperties class
|
||||||
This class is a container for dimensions and display properties of a
|
This class is a container for dimensions and display properties of a
|
||||||
diagram.
|
diagram.
|
||||||
@remark Attributes are public
|
@remark Attributes are public
|
||||||
*/
|
*/
|
||||||
class BorderProperties {
|
class BorderProperties : public PropertiesInterface {
|
||||||
public:
|
public:
|
||||||
// constructor, destructor, operators
|
// constructor, destructor, operators
|
||||||
BorderProperties();
|
BorderProperties();
|
||||||
@@ -35,22 +37,23 @@ class BorderProperties {
|
|||||||
bool operator==(const BorderProperties &);
|
bool operator==(const BorderProperties &);
|
||||||
bool operator!=(const BorderProperties &);
|
bool operator!=(const BorderProperties &);
|
||||||
|
|
||||||
void toXml(QDomElement &) const;
|
void toXmlPriv(QDomElement&) const override;
|
||||||
void fromXml(QDomElement &);
|
bool fromXmlPriv(const QDomElement &) override;
|
||||||
void toSettings(QSettings &, const QString & = QString()) const;
|
static bool valideXml(QDomElement& e);
|
||||||
void fromSettings(QSettings &, const QString & = QString());
|
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||||
|
void fromSettings(QSettings &, const QString & = QString()) override;
|
||||||
|
|
||||||
static BorderProperties defaultProperties();
|
static BorderProperties defaultProperties();
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
int columns_count; ///< Columns count
|
int columns_count{17}; ///< Columns count
|
||||||
qreal columns_width; ///< Columns width
|
qreal columns_width{60.0}; ///< Columns width
|
||||||
qreal columns_header_height; ///< Column headers height
|
qreal columns_header_height{20.0}; ///< Column headers height
|
||||||
bool display_columns; ///< Whether to display column headers
|
bool display_columns{true}; ///< Whether to display column headers
|
||||||
|
|
||||||
int rows_count; ///< Rows count
|
int rows_count{8}; ///< Rows count
|
||||||
qreal rows_height; ///< Rows height
|
qreal rows_height{80.0}; ///< Rows height
|
||||||
qreal rows_header_width; ///< Row headers width
|
qreal rows_header_width{20.0}; ///< Row headers width
|
||||||
bool display_rows; ///< Whether to display row headers
|
bool display_rows{true}; ///< Whether to display row headers
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -65,8 +65,6 @@ BorderTitleBlock::BorderTitleBlock(QObject *parent) :
|
|||||||
// contenu par defaut du cartouche
|
// contenu par defaut du cartouche
|
||||||
importTitleBlock(TitleBlockProperties());
|
importTitleBlock(TitleBlockProperties());
|
||||||
|
|
||||||
display_titleblock_ = true;
|
|
||||||
display_border_ = true;
|
|
||||||
setFolioData(1, 1);
|
setFolioData(1, 1);
|
||||||
updateRectangles();
|
updateRectangles();
|
||||||
}
|
}
|
||||||
@@ -207,8 +205,8 @@ QRectF BorderTitleBlock::insideBorderRect() const
|
|||||||
Exports the title block current values to XML.
|
Exports the title block current values to XML.
|
||||||
@param xml_elmt the XML element attributes will be added to
|
@param xml_elmt the XML element attributes will be added to
|
||||||
*/
|
*/
|
||||||
void BorderTitleBlock::titleBlockToXml(QDomElement &xml_elmt) {
|
QDomElement BorderTitleBlock::titleBlockToXml(QDomDocument& doc) {
|
||||||
exportTitleBlock().toXml(xml_elmt);
|
return exportTitleBlock().toXml(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -217,10 +215,24 @@ void BorderTitleBlock::titleBlockToXml(QDomElement &xml_elmt) {
|
|||||||
@param xml_elmt the XML element values will be read from
|
@param xml_elmt the XML element values will be read from
|
||||||
*/
|
*/
|
||||||
void BorderTitleBlock::titleBlockFromXml(const QDomElement &xml_elmt) {
|
void BorderTitleBlock::titleBlockFromXml(const QDomElement &xml_elmt) {
|
||||||
|
|
||||||
TitleBlockProperties tbp;
|
TitleBlockProperties tbp;
|
||||||
|
QString tagname = tbp.tagName();
|
||||||
|
QDomElement titleBlockProperties = xml_elmt.firstChildElement(tagname);
|
||||||
|
|
||||||
|
if (!titleBlockProperties.isNull())
|
||||||
|
{
|
||||||
|
tbp.fromXml(titleBlockProperties);
|
||||||
|
importTitleBlock(tbp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// legacy
|
||||||
|
// Remove this part in a later step
|
||||||
tbp.fromXml(xml_elmt);
|
tbp.fromXml(xml_elmt);
|
||||||
importTitleBlock(tbp);
|
importTitleBlock(tbp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief BorderTitleBlock::borderToXml
|
@brief BorderTitleBlock::borderToXml
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ class BorderTitleBlock : public QObject
|
|||||||
void setPreviousFolioNum(const QString &previous);
|
void setPreviousFolioNum(const QString &previous);
|
||||||
void setNextFolioNum(const QString &next);
|
void setNextFolioNum(const QString &next);
|
||||||
|
|
||||||
void titleBlockToXml(QDomElement &);
|
QDomElement titleBlockToXml(QDomDocument &doc);
|
||||||
void titleBlockFromXml(const QDomElement &);
|
void titleBlockFromXml(const QDomElement &);
|
||||||
void borderToXml(QDomElement &);
|
void borderToXml(QDomElement &);
|
||||||
void borderFromXml(const QDomElement &);
|
void borderFromXml(const QDomElement &);
|
||||||
@@ -286,10 +286,10 @@ class BorderTitleBlock : public QObject
|
|||||||
QRectF diagram_rect_;
|
QRectF diagram_rect_;
|
||||||
|
|
||||||
// display options
|
// display options
|
||||||
bool display_titleblock_;
|
bool display_titleblock_{true};
|
||||||
bool display_columns_;
|
bool display_columns_;
|
||||||
bool display_rows_;
|
bool display_rows_;
|
||||||
bool display_border_;
|
bool display_border_{true};
|
||||||
TitleBlockTemplateRenderer *m_titleblock_template_renderer;
|
TitleBlockTemplateRenderer *m_titleblock_template_renderer;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -20,14 +20,16 @@
|
|||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include "qetxml.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
const QString conductorPropertiesXmlName = "conductorProperties";
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
Constructeur par defaut
|
Constructeur par defaut
|
||||||
*/
|
*/
|
||||||
SingleLineProperties::SingleLineProperties() :
|
SingleLineProperties::SingleLineProperties(): PropertiesInterface("SingleLine")
|
||||||
hasGround(true),
|
|
||||||
hasNeutral(true),
|
|
||||||
is_pen(false),
|
|
||||||
phases(1)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,8 +217,8 @@ void SingleLineProperties::drawPen(QPainter *painter,
|
|||||||
ajoutes a l'element e.
|
ajoutes a l'element e.
|
||||||
@param e Element XML auquel seront ajoutes des attributs
|
@param e Element XML auquel seront ajoutes des attributs
|
||||||
*/
|
*/
|
||||||
void SingleLineProperties::toXml(QDomElement &e) const
|
void SingleLineProperties::toXmlPriv(QDomElement& e) const {
|
||||||
{
|
|
||||||
e.setAttribute("ground", hasGround ? "true" : "false");
|
e.setAttribute("ground", hasGround ? "true" : "false");
|
||||||
e.setAttribute("neutral", hasNeutral ? "true" : "false");
|
e.setAttribute("neutral", hasNeutral ? "true" : "false");
|
||||||
e.setAttribute("phase", phases);
|
e.setAttribute("phase", phases);
|
||||||
@@ -228,11 +230,36 @@ void SingleLineProperties::toXml(QDomElement &e) const
|
|||||||
de l'element e
|
de l'element e
|
||||||
@param e Element XML dont les attributs seront lus
|
@param e Element XML dont les attributs seront lus
|
||||||
*/
|
*/
|
||||||
void SingleLineProperties::fromXml(QDomElement &e) {
|
bool SingleLineProperties::fromXmlPriv(const QDomElement &e) {
|
||||||
hasGround = e.attribute("ground") == "true";
|
if (QETXML::propertyBool(e, "ground", &hasGround) != QETXML::PropertyFlags::Success ||
|
||||||
hasNeutral = e.attribute("neutral") == "true";
|
QETXML::propertyBool(e, "neutral", &hasNeutral) != QETXML::PropertyFlags::Success)
|
||||||
setPhasesCount(e.attribute("phase").toInt());
|
return false;
|
||||||
is_pen = (hasGround && hasNeutral && e.attribute("pen", "false") == "true");
|
|
||||||
|
int phase;
|
||||||
|
if (QETXML::propertyInteger(e, "phase", &phase) != QETXML::PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
setPhasesCount(phase);
|
||||||
|
|
||||||
|
bool pen;
|
||||||
|
if (QETXML::propertyBool(e, "pen", &pen) != QETXML::PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
is_pen = (hasGround && hasNeutral && pen);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SingleLineProperties::valideXml(QDomElement& e) {
|
||||||
|
if (QETXML::propertyBool(e, "ground") != QETXML::PropertyFlags::Success ||
|
||||||
|
QETXML::propertyBool(e, "neutral") != QETXML::PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (QETXML::propertyInteger(e, "phase") != QETXML::PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (QETXML::propertyBool(e, "pen") != QETXML::PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -240,17 +267,7 @@ void SingleLineProperties::fromXml(QDomElement &e) {
|
|||||||
multifilaire noir dont le texte est "_"
|
multifilaire noir dont le texte est "_"
|
||||||
*/
|
*/
|
||||||
ConductorProperties::ConductorProperties() :
|
ConductorProperties::ConductorProperties() :
|
||||||
type(Multi),
|
PropertiesInterface(xmlTagName())
|
||||||
color(Qt::black),
|
|
||||||
text_color(Qt::black),
|
|
||||||
text("_"),
|
|
||||||
text_size(9),
|
|
||||||
cond_size(1),
|
|
||||||
verti_rotate_text(270),
|
|
||||||
horiz_rotate_text(0),
|
|
||||||
m_show_text(true),
|
|
||||||
m_one_text_per_folio(false),
|
|
||||||
style(Qt::SolidLine)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -266,8 +283,9 @@ ConductorProperties::~ConductorProperties()
|
|||||||
Export conductor propertie, in the XML element 'e'
|
Export conductor propertie, in the XML element 'e'
|
||||||
@param e the xml element
|
@param e the xml element
|
||||||
*/
|
*/
|
||||||
void ConductorProperties::toXml(QDomElement &e) const
|
void ConductorProperties::toXmlPriv(QDomElement& e) const
|
||||||
{
|
{
|
||||||
|
|
||||||
e.setAttribute("type", typeToString(type));
|
e.setAttribute("type", typeToString(type));
|
||||||
|
|
||||||
if (color != QColor(Qt::black))
|
if (color != QColor(Qt::black))
|
||||||
@@ -278,7 +296,10 @@ void ConductorProperties::toXml(QDomElement &e) const
|
|||||||
e.setAttribute("dash-size", QString::number(m_dash_size));
|
e.setAttribute("dash-size", QString::number(m_dash_size));
|
||||||
|
|
||||||
if (type == Single)
|
if (type == Single)
|
||||||
singleLineProperties.toXml(e);
|
{
|
||||||
|
QDomDocument doc = e.ownerDocument();
|
||||||
|
singleLineProperties.toXml(doc);
|
||||||
|
}
|
||||||
|
|
||||||
e.setAttribute("num", text);
|
e.setAttribute("num", text);
|
||||||
e.setAttribute("text_color", text_color.name());
|
e.setAttribute("text_color", text_color.name());
|
||||||
@@ -306,68 +327,99 @@ void ConductorProperties::toXml(QDomElement &e) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** RETURNS True
|
||||||
@brief ConductorProperties::fromXml
|
@brief ConductorProperties::fromXml
|
||||||
Import conductor propertie, from the attribute of the xml element 'e'
|
Import conductor propertie, from the attribute of the xml element 'e'
|
||||||
@param e the xml document
|
@param e the xml document
|
||||||
*/
|
*/
|
||||||
void ConductorProperties::fromXml(QDomElement &e)
|
bool ConductorProperties::fromXmlPriv(const QDomElement &e)
|
||||||
{
|
{
|
||||||
// get conductor color
|
// get conductor color
|
||||||
QColor xml_color= QColor(e.attribute("color"));
|
QETXML::propertyColor(e, "color", &color);
|
||||||
color = (xml_color.isValid()? xml_color : QColor(Qt::black));
|
QETXML::propertyBool(e, "bicolor", &m_bicolor);
|
||||||
|
QETXML::propertyColor(e, "color2", &m_color_2);
|
||||||
QString bicolor_str = e.attribute("bicolor", "false");
|
QETXML::propertyInteger(e, "dash-size", &m_dash_size);
|
||||||
m_bicolor = bicolor_str == "true"? true : false;
|
|
||||||
|
|
||||||
QColor xml_color_2 = QColor(e.attribute("color2"));
|
|
||||||
m_color_2 = xml_color_2.isValid()? xml_color_2 : QColor(Qt::black);
|
|
||||||
|
|
||||||
m_dash_size = e.attribute("dash-size", QString::number(1)).toInt();
|
|
||||||
|
|
||||||
// read style of conductor
|
// read style of conductor
|
||||||
readStyle(e.attribute("style"));
|
QString style_string;
|
||||||
|
QETXML::propertyString(e, "style", &style_string);
|
||||||
|
readStyle(style_string);
|
||||||
|
|
||||||
if (e.attribute("type") == typeToString(Single))
|
QString type_t;
|
||||||
|
if (QETXML::propertyString(e, "type", &type_t) == QETXML::PropertyFlags::Success) {
|
||||||
|
if (type_t == typeToString(Single))
|
||||||
{
|
{
|
||||||
// get specific properties for single conductor
|
// get specific properties for single conductor
|
||||||
singleLineProperties.fromXml(e);
|
singleLineProperties.fromXml(e);
|
||||||
type = Single;
|
type = Single;
|
||||||
}
|
}
|
||||||
else
|
else if (type_t == typeToString(Multi))
|
||||||
type = Multi;
|
type = Multi;
|
||||||
|
else {
|
||||||
|
//Keep retrocompatible with version older than 0,4
|
||||||
|
//If the propertie @type is simple (removed since QET 0,4), we set text no visible.
|
||||||
|
//@TODO remove this code for qet 0.6 or later
|
||||||
|
|
||||||
text = e.attribute("num");
|
if (type_t == "simple") m_show_text = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QETXML::propertyString(e, "num", &text);
|
||||||
|
// TODO: implement:
|
||||||
|
//m_cable = e.attribute("cable");
|
||||||
|
//m_bus = e.attribute("bus");
|
||||||
// get text color
|
// get text color
|
||||||
QColor xml_text_color= QColor(e.attribute("text_color"));
|
QETXML::propertyColor(e, "text_color", &text_color);
|
||||||
text_color = (xml_text_color.isValid()? xml_text_color : QColor(Qt::black));
|
QETXML::propertyString(e, "formula", &m_formula);
|
||||||
m_formula = e.attribute("formula");
|
QETXML::propertyString(e, "function", &m_function);
|
||||||
m_cable = e.attribute("cable");
|
QETXML::propertyString(e, "tension_protocol", &m_tension_protocol);
|
||||||
m_bus = e.attribute("bus");
|
QETXML::propertyString(e, "conductor_color", &m_wire_color);
|
||||||
m_function = e.attribute("function");
|
QETXML::propertyString(e, "conductor_section", &m_wire_section);
|
||||||
m_tension_protocol = e.attribute("tension_protocol");
|
QETXML::propertyInteger(e, "numsize", &text_size);
|
||||||
m_wire_color = e.attribute("conductor_color");
|
QETXML::propertyDouble(e, "condsize", &cond_size);
|
||||||
m_wire_section = e.attribute("conductor_section");
|
QETXML::propertyBool(e, "displaytext", &m_show_text);
|
||||||
text_size = e.attribute("numsize", QString::number(9)).toInt();
|
QETXML::propertyBool(e, "onetextperfolio", &m_one_text_per_folio);
|
||||||
cond_size = e.attribute("condsize", QString::number(1)).toDouble();
|
QETXML::propertyDouble(e, "vertirotatetext", &verti_rotate_text);
|
||||||
m_show_text = e.attribute("displaytext", QString::number(1)).toInt();
|
QETXML::propertyDouble(e, "horizrotatetext", &horiz_rotate_text);
|
||||||
m_one_text_per_folio = e.attribute("onetextperfolio", QString::number(0)).toInt();
|
|
||||||
verti_rotate_text = e.attribute("vertirotatetext").toDouble();
|
|
||||||
horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
|
|
||||||
|
|
||||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
m_horizontal_alignment = Qt::Alignment(
|
QString alinment_temp;
|
||||||
me.keyToValue(
|
if (QETXML::propertyString(e, "horizontal-alignment", &alinment_temp) == QETXML::PropertyFlags::Success)
|
||||||
e.attribute(
|
m_horizontal_alignment = Qt::Alignment(me.keyToValue(alinment_temp.toStdString().data()));
|
||||||
"horizontal-alignment",
|
if (QETXML::propertyString(e, "vertical-alignment", &alinment_temp) == QETXML::PropertyFlags::Success)
|
||||||
"AlignBottom"
|
m_vertical_alignment = Qt::Alignment(me.keyToValue(alinment_temp.toStdString().data()));
|
||||||
).toStdString().data()));
|
|
||||||
m_vertical_alignment = Qt::Alignment(
|
return true;
|
||||||
me.keyToValue(
|
}
|
||||||
e.attribute(
|
|
||||||
"vertical-alignment",
|
bool ConductorProperties::valideXml(QDomElement& e) {
|
||||||
"AlignRight"
|
if (QETXML::propertyColor(e, "color") ||
|
||||||
).toStdString().data()));
|
QETXML::propertyBool(e, "bicolor") ||
|
||||||
|
QETXML::propertyColor(e, "color2") ||
|
||||||
|
QETXML::propertyInteger(e, "dash-size") ||
|
||||||
|
QETXML::propertyString(e, "type") ||
|
||||||
|
QETXML::propertyString(e, "num") ||
|
||||||
|
QETXML::propertyColor(e, "text_color") ||
|
||||||
|
QETXML::propertyString(e, "formula") ||
|
||||||
|
QETXML::propertyString(e, "function") ||
|
||||||
|
QETXML::propertyString(e, "tension_protocol") ||
|
||||||
|
QETXML::propertyString(e, "conductor_color") ||
|
||||||
|
QETXML::propertyString(e, "conductor_section") ||
|
||||||
|
QETXML::propertyInteger(e, "numsize") ||
|
||||||
|
QETXML::propertyDouble(e, "condsize") ||
|
||||||
|
QETXML::propertyBool(e, "displaytext") ||
|
||||||
|
QETXML::propertyBool(e, "onetextperfolio") ||
|
||||||
|
QETXML::propertyDouble(e, "vertirotatetext") ||
|
||||||
|
QETXML::propertyDouble(e, "horizrotatetext") ||
|
||||||
|
QETXML::propertyString(e, "horizontal-alignment") ||
|
||||||
|
QETXML::propertyString(e, "vertical-alignment"))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ConductorProperties::xmlTagName()
|
||||||
|
{
|
||||||
|
return conductorPropertiesXmlName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,13 +22,15 @@
|
|||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
#include "properties/propertiesinterface.h"
|
||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The SingleLineProperties class
|
@brief The SingleLineProperties class
|
||||||
This class represents the properties of a singleline conductor.
|
This class represents the properties of a singleline conductor.
|
||||||
*/
|
*/
|
||||||
class SingleLineProperties {
|
class SingleLineProperties: public PropertiesInterface {
|
||||||
public:
|
public:
|
||||||
SingleLineProperties();
|
SingleLineProperties();
|
||||||
virtual ~SingleLineProperties();
|
virtual ~SingleLineProperties();
|
||||||
@@ -37,23 +39,24 @@ class SingleLineProperties {
|
|||||||
unsigned short int phasesCount();
|
unsigned short int phasesCount();
|
||||||
bool isPen() const;
|
bool isPen() const;
|
||||||
void draw(QPainter *, QET::ConductorSegmentType, const QRectF &);
|
void draw(QPainter *, QET::ConductorSegmentType, const QRectF &);
|
||||||
void toXml(QDomElement &) const;
|
void toXmlPriv(QDomElement&) const override;
|
||||||
void fromXml(QDomElement &);
|
bool fromXmlPriv(const QDomElement &) override;
|
||||||
|
static bool valideXml(QDomElement& element);
|
||||||
void toSettings(QSettings &, const QString & = QString()) const;
|
void toSettings(QSettings &, const QString & = QString()) const;
|
||||||
void fromSettings(QSettings &, const QString & = QString());
|
void fromSettings(QSettings &, const QString & = QString());
|
||||||
|
|
||||||
/// Whether the singleline conductor should display the ground symbol
|
/// Whether the singleline conductor should display the ground symbol
|
||||||
bool hasGround;
|
bool hasGround{true};
|
||||||
/// Whether the singleline conductor should display the neutral symbol
|
/// Whether the singleline conductor should display the neutral symbol
|
||||||
bool hasNeutral;
|
bool hasNeutral{true};
|
||||||
/// Protective Earth Neutral: visually merge neutral and ground
|
/// Protective Earth Neutral: visually merge neutral and ground
|
||||||
bool is_pen;
|
bool is_pen{false};
|
||||||
|
|
||||||
int operator==(const SingleLineProperties &) const;
|
int operator==(const SingleLineProperties &) const;
|
||||||
int operator!=(const SingleLineProperties &) const;
|
int operator!=(const SingleLineProperties &) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned short int phases;
|
unsigned short int phases{1};
|
||||||
void drawGround (QPainter *, QET::ConductorSegmentType, QPointF, qreal);
|
void drawGround (QPainter *, QET::ConductorSegmentType, QPointF, qreal);
|
||||||
void drawNeutral(QPainter *, QPointF, qreal);
|
void drawNeutral(QPainter *, QPointF, qreal);
|
||||||
void drawPen(QPainter *, QET::ConductorSegmentType, QPointF, qreal);
|
void drawPen(QPainter *, QET::ConductorSegmentType, QPointF, qreal);
|
||||||
@@ -64,7 +67,7 @@ class SingleLineProperties {
|
|||||||
This class represents the functional properties of a particular conductor,
|
This class represents the functional properties of a particular conductor,
|
||||||
i.e. properties other than path and terminals.
|
i.e. properties other than path and terminals.
|
||||||
*/
|
*/
|
||||||
class ConductorProperties
|
class ConductorProperties: public PropertiesInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConductorProperties();
|
ConductorProperties();
|
||||||
@@ -80,15 +83,15 @@ class ConductorProperties
|
|||||||
|
|
||||||
|
|
||||||
//Attributes
|
//Attributes
|
||||||
ConductorType type;
|
ConductorType type{ConductorType::Multi};
|
||||||
|
|
||||||
QColor
|
// TODO: set default values!
|
||||||
color,
|
QColor color{QColor(Qt::black)},
|
||||||
m_color_2,
|
m_color_2{QColor(Qt::black)},
|
||||||
text_color;
|
text_color{QColor(Qt::black)};
|
||||||
|
|
||||||
QString
|
QString
|
||||||
text,
|
text{"_"},
|
||||||
m_function,
|
m_function,
|
||||||
m_tension_protocol,
|
m_tension_protocol,
|
||||||
m_wire_color,
|
m_wire_color,
|
||||||
@@ -97,33 +100,31 @@ class ConductorProperties
|
|||||||
m_bus,
|
m_bus,
|
||||||
m_cable;
|
m_cable;
|
||||||
|
|
||||||
int
|
int text_size{9},
|
||||||
text_size,
|
|
||||||
m_dash_size = 1;
|
m_dash_size = 1;
|
||||||
|
|
||||||
double
|
double
|
||||||
cond_size,
|
cond_size{1},
|
||||||
verti_rotate_text,
|
verti_rotate_text{270},
|
||||||
horiz_rotate_text;
|
horiz_rotate_text{0};
|
||||||
|
|
||||||
bool
|
bool m_show_text{true},
|
||||||
m_show_text,
|
m_one_text_per_folio{false},
|
||||||
m_one_text_per_folio,
|
|
||||||
m_bicolor = false;
|
m_bicolor = false;
|
||||||
|
|
||||||
Qt::Alignment
|
Qt::Alignment
|
||||||
m_horizontal_alignment = Qt::AlignBottom,
|
m_horizontal_alignment = Qt::AlignBottom,
|
||||||
m_vertical_alignment = Qt::AlignRight;
|
m_vertical_alignment = Qt::AlignRight;
|
||||||
|
|
||||||
Qt::PenStyle style;
|
Qt::PenStyle style{Qt::PenStyle::SolidLine};
|
||||||
|
|
||||||
SingleLineProperties singleLineProperties;
|
SingleLineProperties singleLineProperties;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
void toXml(QDomElement &) const;
|
static bool valideXml(QDomElement& element);
|
||||||
void fromXml(QDomElement &);
|
static QString xmlTagName();
|
||||||
void toSettings(QSettings &, const QString & = QString()) const;
|
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||||
void fromSettings(QSettings &, const QString & = QString());
|
void fromSettings(QSettings &, const QString & = QString()) override;
|
||||||
static QString typeToString(ConductorType);
|
static QString typeToString(ConductorType);
|
||||||
void applyForEqualAttributes(QList<ConductorProperties> list);
|
void applyForEqualAttributes(QList<ConductorProperties> list);
|
||||||
|
|
||||||
@@ -133,6 +134,10 @@ class ConductorProperties
|
|||||||
bool operator==(const ConductorProperties &) const;
|
bool operator==(const ConductorProperties &) const;
|
||||||
bool operator!=(const ConductorProperties &) const;
|
bool operator!=(const ConductorProperties &) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void toXmlPriv(QDomElement&) const override;
|
||||||
|
bool fromXmlPriv(const QDomElement &) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void readStyle(const QString &);
|
void readStyle(const QString &);
|
||||||
QString writeStyle() const;
|
QString writeStyle() const;
|
||||||
|
|||||||
@@ -44,6 +44,8 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "qetxml.h"
|
||||||
|
|
||||||
int Diagram::xGrid = 10;
|
int Diagram::xGrid = 10;
|
||||||
int Diagram::yGrid = 10;
|
int Diagram::yGrid = 10;
|
||||||
int Diagram::xKeyGrid = 10;
|
int Diagram::xKeyGrid = 10;
|
||||||
@@ -737,14 +739,13 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
// schema properties
|
// schema properties
|
||||||
// proprietes du schema
|
// proprietes du schema
|
||||||
if (whole_content) {
|
if (whole_content) {
|
||||||
border_and_titleblock.titleBlockToXml(dom_root);
|
// TODO: compare with old version
|
||||||
|
dom_root.appendChild(border_and_titleblock.titleBlockToXml(document));
|
||||||
border_and_titleblock.borderToXml(dom_root);
|
border_and_titleblock.borderToXml(dom_root);
|
||||||
|
|
||||||
// Default conductor properties
|
// Default conductor properties
|
||||||
QDomElement default_conductor =
|
defaultConductorProperties.setTagName("defaultconductor");
|
||||||
document.createElement("defaultconductor");
|
dom_root.appendChild(defaultConductorProperties.toXml(document));
|
||||||
defaultConductorProperties.toXml(default_conductor);
|
|
||||||
dom_root.appendChild(default_conductor);
|
|
||||||
|
|
||||||
// Conductor autonum
|
// Conductor autonum
|
||||||
if (!m_conductors_autonum_name.isEmpty()) {
|
if (!m_conductors_autonum_name.isEmpty()) {
|
||||||
@@ -918,13 +919,11 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
|
|
||||||
// correspondence table between the addresses of the terminals and their ids
|
// correspondence table between the addresses of the terminals and their ids
|
||||||
// table de correspondance entre les adresses des bornes et leurs ids
|
// table de correspondance entre les adresses des bornes et leurs ids
|
||||||
QHash<Terminal *, int> table_adr_id;
|
|
||||||
|
|
||||||
if (!list_elements.isEmpty()) {
|
if (!list_elements.isEmpty()) {
|
||||||
auto dom_elements = document.createElement("elements");
|
auto dom_elements = document.createElement("elements");
|
||||||
for (auto elmt : list_elements) {
|
for (auto elmt : list_elements) {
|
||||||
dom_elements.appendChild(elmt->toXml(document,
|
dom_elements.appendChild(elmt->toXml(document));
|
||||||
table_adr_id));
|
|
||||||
}
|
}
|
||||||
dom_root.appendChild(dom_elements);
|
dom_root.appendChild(dom_elements);
|
||||||
}
|
}
|
||||||
@@ -932,8 +931,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
if (!list_conductors.isEmpty()) {
|
if (!list_conductors.isEmpty()) {
|
||||||
auto dom_conductors = document.createElement("conductors");
|
auto dom_conductors = document.createElement("conductors");
|
||||||
for (auto cond : list_conductors) {
|
for (auto cond : list_conductors) {
|
||||||
dom_conductors.appendChild(cond->toXml(document,
|
dom_conductors.appendChild(cond->toXml(document));
|
||||||
table_adr_id));
|
|
||||||
}
|
}
|
||||||
dom_root.appendChild(dom_conductors);
|
dom_root.appendChild(dom_conductors);
|
||||||
}
|
}
|
||||||
@@ -1096,7 +1094,7 @@ bool Diagram::initFromXml(QDomElement &document,
|
|||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
Terminal* findTerminal(int conductor_index,
|
Terminal* findTerminal(int conductor_index,
|
||||||
QDomElement& f,
|
QDomElement& conductor,
|
||||||
QHash<int,
|
QHash<int,
|
||||||
Terminal *>& table_adr_id,
|
Terminal *>& table_adr_id,
|
||||||
QList<Element *>& added_elements) {
|
QList<Element *>& added_elements) {
|
||||||
@@ -1105,8 +1103,8 @@ Terminal* findTerminal(int conductor_index,
|
|||||||
QString element_index = "element" + QString::number(conductor_index);
|
QString element_index = "element" + QString::number(conductor_index);
|
||||||
QString terminal_index = "terminal" + QString::number(conductor_index);
|
QString terminal_index = "terminal" + QString::number(conductor_index);
|
||||||
|
|
||||||
if (f.hasAttribute(element_index)) {
|
QUuid element_uuid;
|
||||||
QUuid element_uuid = QUuid(f.attribute(element_index));
|
if (QETXML::propertyUuid(conductor, element_index, &element_uuid) == QETXML::PropertyFlags::Success) {
|
||||||
// element1 did not exist in the conductor part of the xml until prior 0.7
|
// element1 did not exist in the conductor part of the xml until prior 0.7
|
||||||
// It is used as an indicator that uuid's are used to identify terminals
|
// It is used as an indicator that uuid's are used to identify terminals
|
||||||
bool element_found = false;
|
bool element_found = false;
|
||||||
@@ -1114,7 +1112,8 @@ Terminal* findTerminal(int conductor_index,
|
|||||||
if (element->uuid() != element_uuid)
|
if (element->uuid() != element_uuid)
|
||||||
continue;
|
continue;
|
||||||
element_found = true;
|
element_found = true;
|
||||||
QUuid terminal_uuid = QUuid(f.attribute(terminal_index));
|
QUuid terminal_uuid;
|
||||||
|
QETXML::propertyUuid(conductor, terminal_index, &terminal_uuid);
|
||||||
for (auto terminal: element->terminals()) {
|
for (auto terminal: element->terminals()) {
|
||||||
if (terminal->uuid() != terminal_uuid)
|
if (terminal->uuid() != terminal_uuid)
|
||||||
continue;
|
continue;
|
||||||
@@ -1138,9 +1137,11 @@ Terminal* findTerminal(int conductor_index,
|
|||||||
<< element_uuid
|
<< element_uuid
|
||||||
<< "not found";
|
<< "not found";
|
||||||
} else {
|
} else {
|
||||||
// Backward compatibility.
|
// Backward compatibility. Until version 0.7 a generated id is used to link the terminal.
|
||||||
// Until version 0.7 a generated id is used to link the terminal.
|
int id_p1 = -1;
|
||||||
int id_p1 = f.attribute(terminal_index).toInt();
|
if (QETXML::propertyInteger(conductor, terminal_index, &id_p1) != QETXML::PropertyFlags::Success) {
|
||||||
|
qDebug() << "diagramm.cpp:findTerminal(): Reading Id was not successfull";
|
||||||
|
}
|
||||||
if (!table_adr_id.contains(id_p1)) {
|
if (!table_adr_id.contains(id_p1)) {
|
||||||
qDebug() << "Diagram::fromXml() : terminal id "
|
qDebug() << "Diagram::fromXml() : terminal id "
|
||||||
<< id_p1
|
<< id_p1
|
||||||
@@ -1148,6 +1149,7 @@ Terminal* findTerminal(int conductor_index,
|
|||||||
} else
|
} else
|
||||||
return table_adr_id.value(id_p1);
|
return table_adr_id.value(id_p1);
|
||||||
}
|
}
|
||||||
|
qDebug() << "Diagram::findTerminal(): No terminal found.";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1190,10 +1192,13 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
// The first element must be a diagram
|
// The first element must be a diagram
|
||||||
if (root.tagName() != "diagram") return(false);
|
if (root.tagName() != "diagram") return(false);
|
||||||
|
|
||||||
|
qDebug() << "Diagram::fromXml; Diagram: " << root.attribute("title");
|
||||||
|
|
||||||
// Read attributes of this diagram
|
// Read attributes of this diagram
|
||||||
if (consider_informations)
|
if (consider_informations)
|
||||||
{
|
{
|
||||||
// Load border and titleblock
|
// Load border and titleblock
|
||||||
|
|
||||||
border_and_titleblock.titleBlockFromXml(root);
|
border_and_titleblock.titleBlockFromXml(root);
|
||||||
border_and_titleblock.borderFromXml(root);
|
border_and_titleblock.borderFromXml(root);
|
||||||
|
|
||||||
@@ -1205,6 +1210,7 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
defaultConductorProperties.fromXml(default_conductor_elmt);
|
defaultConductorProperties.fromXml(default_conductor_elmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Load the autonum
|
// Load the autonum
|
||||||
m_conductors_autonum_name = root.attribute("conductorAutonum");
|
m_conductors_autonum_name = root.attribute("conductorAutonum");
|
||||||
|
|
||||||
@@ -1379,7 +1385,7 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
Terminal* p1 = findTerminal(1, f, table_adr_id, added_elements);
|
Terminal* p1 = findTerminal(1, f, table_adr_id, added_elements);
|
||||||
Terminal* p2 = findTerminal(2, f, table_adr_id, added_elements);
|
Terminal* p2 = findTerminal(2, f, table_adr_id, added_elements);
|
||||||
|
|
||||||
if (p1 && p2 && p1 != p2)
|
if (p1 && p2 && p1 != p2)// TODO: why the condition for unequal is required?
|
||||||
{
|
{
|
||||||
Conductor *c = new Conductor(p1, p2);
|
Conductor *c = new Conductor(p1, p2);
|
||||||
if (c->isValid())
|
if (c->isValid())
|
||||||
@@ -1390,6 +1396,8 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
delete c;
|
delete c;
|
||||||
|
} else {
|
||||||
|
qDebug() << "Diagramm::fromXML(): No matching terminals found.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1529,7 +1537,7 @@ void Diagram::refreshContents()
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Diagram::addItem
|
@brief Diagram::addItem
|
||||||
Réimplemented from QGraphicsScene::addItem(QGraphicsItem *item)
|
R??implemented from QGraphicsScene::addItem(QGraphicsItem *item)
|
||||||
Do some specific operation if item need it (for exemple an element)
|
Do some specific operation if item need it (for exemple an element)
|
||||||
@param item
|
@param item
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class Diagram : public QGraphicsScene
|
|||||||
/// margin around the diagram
|
/// margin around the diagram
|
||||||
static const qreal margin;
|
static const qreal margin;
|
||||||
/// background color of diagram
|
/// background color of diagram
|
||||||
static QColor background_color;
|
static QColor background_color; // default value set in cpp file
|
||||||
/// Hash containing max values for folio sequential autonums in this diagram
|
/// Hash containing max values for folio sequential autonums in this diagram
|
||||||
QHash <QString, QStringList> m_elmt_unitfolio_max;
|
QHash <QString, QStringList> m_elmt_unitfolio_max;
|
||||||
QHash <QString, QStringList> m_elmt_tenfolio_max;
|
QHash <QString, QStringList> m_elmt_tenfolio_max;
|
||||||
@@ -282,6 +282,8 @@ class Diagram : public QGraphicsScene
|
|||||||
/// from the diagram within elements collection
|
/// from the diagram within elements collection
|
||||||
void findElementRequired(const ElementsLocation &);
|
void findElementRequired(const ElementsLocation &);
|
||||||
|
|
||||||
|
/// Signal emitted when users wish to edit an element from the diagram
|
||||||
|
void editElementRequired(const ElementsLocation &);
|
||||||
void diagramActivated();
|
void diagramActivated();
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(Diagram *)
|
Q_DECLARE_METATYPE(Diagram *)
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ void ArcEditor::updateArcA()
|
|||||||
@brief ArcEditor::updateForm
|
@brief ArcEditor::updateForm
|
||||||
Update the value of the widgets
|
Update the value of the widgets
|
||||||
*/
|
*/
|
||||||
void ArcEditor::updateForm()
|
void ArcEditor::updateFormPriv()
|
||||||
{
|
{
|
||||||
if (!m_part) return;
|
if (!m_part) return;
|
||||||
activeConnections(false);
|
activeConnections(false);
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ class ArcEditor : public ElementItemEditor
|
|||||||
QSpinBox *angle, *start_angle;
|
QSpinBox *angle, *start_angle;
|
||||||
bool m_locked;
|
bool m_locked;
|
||||||
|
|
||||||
QList <QMetaObject::Connection> m_change_connections;
|
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
bool setPart(CustomElementPart *) override;
|
bool setPart(CustomElementPart *) override;
|
||||||
@@ -59,7 +57,7 @@ class ArcEditor : public ElementItemEditor
|
|||||||
public slots:
|
public slots:
|
||||||
void updateArcS();
|
void updateArcS();
|
||||||
void updateArcA();
|
void updateArcA();
|
||||||
void updateForm() override;
|
void updateFormPriv() override;
|
||||||
void updateRect();
|
void updateRect();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ ElementScene *ElementItemEditor::elementScene() const
|
|||||||
return(element_editor -> elementScene());
|
return(element_editor -> elementScene());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ElementItemEditor::updateForm()
|
||||||
|
{
|
||||||
|
updateFormPriv();
|
||||||
|
}
|
||||||
|
|
||||||
/// @return la QUndoStack a utiliser pour les annulations
|
/// @return la QUndoStack a utiliser pour les annulations
|
||||||
QUndoStack &ElementItemEditor::undoStack() const
|
QUndoStack &ElementItemEditor::undoStack() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,8 +55,16 @@ class ElementItemEditor : public QWidget
|
|||||||
|
|
||||||
virtual CustomElementPart *currentPart() const = 0;
|
virtual CustomElementPart *currentPart() const = 0;
|
||||||
virtual QList<CustomElementPart*> currentParts() const = 0;
|
virtual QList<CustomElementPart*> currentParts() const = 0;
|
||||||
virtual void updateForm() = 0;
|
/*!
|
||||||
|
* \brief updateForm
|
||||||
|
* update the values of the widget
|
||||||
|
*/
|
||||||
|
virtual void updateForm();
|
||||||
|
private:
|
||||||
|
virtual void updateFormPriv() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QList<QMetaObject::Connection> m_change_connections;
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
QETElementEditor *element_editor;
|
QETElementEditor *element_editor;
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ class AbstractPartEllipse : public CustomElementGraphicPart
|
|||||||
protected:
|
protected:
|
||||||
QList<QPointF> saved_points_;
|
QList<QPointF> saved_points_;
|
||||||
QRectF m_rect;
|
QRectF m_rect;
|
||||||
qreal m_start_angle;
|
qreal m_start_angle{0};
|
||||||
qreal m_span_angle;
|
qreal m_span_angle{-1440};
|
||||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
|
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
|
||||||
#include "../elementscene.h"
|
#include "../elementscene.h"
|
||||||
|
|
||||||
|
#include "../../qetxml.h"
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -497,7 +499,6 @@ void CustomElementGraphicPart::stylesToXml(QDomElement &qde) const
|
|||||||
else if (_color == HTMLGrayBlackColor) css_like_styles += "HTMLGrayBlack";
|
else if (_color == HTMLGrayBlackColor) css_like_styles += "HTMLGrayBlack";
|
||||||
else if (_color == NoneColor) css_like_styles += "none";
|
else if (_color == NoneColor) css_like_styles += "none";
|
||||||
|
|
||||||
|
|
||||||
qde.setAttribute("style", css_like_styles);
|
qde.setAttribute("style", css_like_styles);
|
||||||
qde.setAttribute("antialias", _antialiased ? "true" : "false");
|
qde.setAttribute("antialias", _antialiased ? "true" : "false");
|
||||||
}
|
}
|
||||||
@@ -512,6 +513,9 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
|||||||
{
|
{
|
||||||
resetStyles();
|
resetStyles();
|
||||||
|
|
||||||
|
QString style_string;
|
||||||
|
QETXML::propertyString(qde, "style", &style_string);
|
||||||
|
|
||||||
//Get the list of pair style/value
|
//Get the list of pair style/value
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||||
QStringList styles = qde.attribute("style").split(";", QString::SkipEmptyParts);
|
QStringList styles = qde.attribute("style").split(";", QString::SkipEmptyParts);
|
||||||
@@ -1312,7 +1316,7 @@ void CustomElementGraphicPart::mouseReleaseEvent(QGraphicsSceneMouseEvent *event
|
|||||||
if((event->button() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable) && m_origin_pos != pos())
|
if((event->button() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable) && m_origin_pos != pos())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "pos", QVariant(m_origin_pos), QVariant(pos()));
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "pos", QVariant(m_origin_pos), QVariant(pos()));
|
||||||
undo->setText(tr("Déplacer une primitive"));
|
undo->setText(tr("D??placer une primitive"));
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#define CUSTOM_ELEMENT_PART_H
|
#define CUSTOM_ELEMENT_PART_H
|
||||||
|
|
||||||
#include "../../qet.h"
|
#include "../../qet.h"
|
||||||
|
#include "../../properties/propertiesinterface.h"
|
||||||
|
|
||||||
class CustomElement;
|
class CustomElement;
|
||||||
class ElementPrimitiveDecorator;
|
class ElementPrimitiveDecorator;
|
||||||
@@ -37,7 +38,7 @@ class QGraphicsSceneMouseEvent;
|
|||||||
there is no point for those classes to store their visual representation
|
there is no point for those classes to store their visual representation
|
||||||
with anything more complex than a QImage.
|
with anything more complex than a QImage.
|
||||||
*/
|
*/
|
||||||
class CustomElementPart {
|
class CustomElementPart: public PropertiesInterface {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@@ -61,14 +62,6 @@ class CustomElementPart {
|
|||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
Load the primitive from an XML element that describes it
|
|
||||||
*/
|
|
||||||
virtual void fromXml(const QDomElement &) = 0;
|
|
||||||
/**
|
|
||||||
Export the primitive as an XML element
|
|
||||||
*/
|
|
||||||
virtual const QDomElement toXml(QDomDocument &) const = 0;
|
|
||||||
/**
|
/**
|
||||||
Set a specific property of the primitive
|
Set a specific property of the primitive
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
|
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
|
||||||
#include "../elementscene.h"
|
#include "../elementscene.h"
|
||||||
|
|
||||||
|
#include "../../qetxml.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::PartArc
|
@brief PartArc::PartArc
|
||||||
Constructor
|
Constructor
|
||||||
@@ -31,8 +33,7 @@
|
|||||||
PartArc::PartArc(QETElementEditor *editor, QGraphicsItem *parent) :
|
PartArc::PartArc(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||||
AbstractPartEllipse(editor, parent)
|
AbstractPartEllipse(editor, parent)
|
||||||
{
|
{
|
||||||
m_start_angle = 0;
|
setTagName("arc");
|
||||||
m_span_angle = -1440;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,9 +103,9 @@ void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
|||||||
@param xml_document : Xml document to use for create the xml element.
|
@param xml_document : Xml document to use for create the xml element.
|
||||||
@return : an xml element that describe this arc
|
@return : an xml element that describe this arc
|
||||||
*/
|
*/
|
||||||
const QDomElement PartArc::toXml(QDomDocument &xml_document) const
|
void PartArc::toXmlPriv(QDomElement& xml_element) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement("arc");
|
xml_element.setTagName("arc");
|
||||||
QPointF top_left(sceneTopLeft());
|
QPointF top_left(sceneTopLeft());
|
||||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||||
@@ -114,7 +115,6 @@ const QDomElement PartArc::toXml(QDomDocument &xml_document) const
|
|||||||
xml_element.setAttribute("start", QString("%1").arg(m_start_angle / 16));
|
xml_element.setAttribute("start", QString("%1").arg(m_start_angle / 16));
|
||||||
xml_element.setAttribute("angle", QString("%1").arg(m_span_angle / 16));
|
xml_element.setAttribute("angle", QString("%1").arg(m_span_angle / 16));
|
||||||
stylesToXml(xml_element);
|
stylesToXml(xml_element);
|
||||||
return(xml_element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,15 +122,41 @@ const QDomElement PartArc::toXml(QDomDocument &xml_document) const
|
|||||||
Import the properties of this arc from a xml element.
|
Import the properties of this arc from a xml element.
|
||||||
@param qde : Xml document to use.
|
@param qde : Xml document to use.
|
||||||
*/
|
*/
|
||||||
void PartArc::fromXml(const QDomElement &qde) {
|
bool PartArc::fromXmlPriv(const QDomElement &qde) {
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
m_rect = QRectF(mapFromScene(qde.attribute("x", "0").toDouble(),
|
|
||||||
qde.attribute("y", "0").toDouble()),
|
|
||||||
QSizeF(qde.attribute("width", "0").toDouble(),
|
|
||||||
qde.attribute("height", "0").toDouble()) );
|
|
||||||
|
|
||||||
m_start_angle = qde.attribute("start", "0").toDouble() * 16;
|
double x=0, y=0, w=0, h=0;
|
||||||
m_span_angle = qde.attribute("angle", "-1440").toDouble() * 16;
|
if (QETXML::propertyDouble(qde, "x", &x) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(qde, "y", &y) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(qde, "width", &w) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(qde, "height", &h) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_rect = QRectF(mapFromScene(x, y), QSizeF(w, h) );
|
||||||
|
|
||||||
|
m_start_angle = 0;
|
||||||
|
if (QETXML::propertyDouble(qde, "start", &m_start_angle) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
m_start_angle *= 16;
|
||||||
|
|
||||||
|
m_span_angle = -1440;
|
||||||
|
if (QETXML::propertyDouble(qde, "angle", &m_span_angle) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
m_span_angle *= 16;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PartArc::valideXml(QDomElement& element) {
|
||||||
|
|
||||||
|
if (QETXML::propertyDouble(element, "x") == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(element, "y") == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(element, "width") == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(element, "height") == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(element, "start") == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(element, "angle") == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -51,8 +51,11 @@ class PartArc : public AbstractPartEllipse
|
|||||||
//Name and XML
|
//Name and XML
|
||||||
QString name() const override { return(QObject::tr("arc", "element part name")); }
|
QString name() const override { return(QObject::tr("arc", "element part name")); }
|
||||||
QString xmlName() const override { return(QString("arc")); }
|
QString xmlName() const override { return(QString("arc")); }
|
||||||
const QDomElement toXml (QDomDocument &) const override;
|
void toXmlPriv(QDomElement&xml_element) const override;
|
||||||
void fromXml (const QDomElement &) override;
|
bool fromXmlPriv (const QDomElement &) override;
|
||||||
|
static bool valideXml(QDomElement& element);
|
||||||
|
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||||
|
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||||
|
|
||||||
QPainterPath shape() const override;
|
QPainterPath shape() const override;
|
||||||
QPainterPath shadowShape() const override;
|
QPainterPath shadowShape() const override;
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#include "../../qetapp.h"
|
#include "../../qetapp.h"
|
||||||
#include "../elementscene.h"
|
#include "../elementscene.h"
|
||||||
|
|
||||||
|
#include "../../qetxml.h"
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
@@ -30,6 +32,7 @@ PartDynamicTextField::PartDynamicTextField(QETElementEditor *editor, QGraphicsIt
|
|||||||
CustomElementPart(editor),
|
CustomElementPart(editor),
|
||||||
m_uuid(QUuid::createUuid())
|
m_uuid(QUuid::createUuid())
|
||||||
{
|
{
|
||||||
|
setTagName(xmlName());
|
||||||
setDefaultTextColor(Qt::black);
|
setDefaultTextColor(Qt::black);
|
||||||
setFont(QETApp::dynamicTextsItemFont());
|
setFont(QETApp::dynamicTextsItemFont());
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
@@ -93,9 +96,8 @@ void PartDynamicTextField::handleUserTransformation(
|
|||||||
@param dom_doc
|
@param dom_doc
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
void PartDynamicTextField::toXmlPriv(QDomElement& root_element) const
|
||||||
{
|
{
|
||||||
QDomElement root_element = dom_doc.createElement(xmlName());
|
|
||||||
|
|
||||||
root_element.setAttribute("x", QString::number(pos().x()));
|
root_element.setAttribute("x", QString::number(pos().x()));
|
||||||
root_element.setAttribute("y", QString::number(pos().y()));
|
root_element.setAttribute("y", QString::number(pos().y()));
|
||||||
@@ -124,57 +126,61 @@ const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
|||||||
else if(this -> alignment() &Qt::AlignVCenter)
|
else if(this -> alignment() &Qt::AlignVCenter)
|
||||||
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignVCenter));
|
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignVCenter));
|
||||||
|
|
||||||
QDomElement dom_text = dom_doc.createElement("text");
|
QDomElement dom_text = root_element.ownerDocument().createElement("text");
|
||||||
dom_text.appendChild(dom_doc.createTextNode(toPlainText()));
|
dom_text.appendChild(root_element.ownerDocument().createTextNode(toPlainText()));
|
||||||
root_element.appendChild(dom_text);
|
root_element.appendChild(dom_text);
|
||||||
|
|
||||||
//Info name
|
//Info name
|
||||||
if(!m_info_name.isEmpty()) {
|
if(!m_info_name.isEmpty()) {
|
||||||
QDomElement dom_info_name = dom_doc.createElement("info_name");
|
QDomElement dom_info_name = root_element.ownerDocument().createElement("info_name");
|
||||||
dom_info_name.appendChild(dom_doc.createTextNode(m_info_name));
|
dom_info_name.appendChild(root_element.ownerDocument().createTextNode(m_info_name));
|
||||||
root_element.appendChild(dom_info_name);
|
root_element.appendChild(dom_info_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Composite text
|
//Composite text
|
||||||
if(!m_composite_text.isEmpty()) {
|
if(!m_composite_text.isEmpty()) {
|
||||||
QDomElement dom_comp_text = dom_doc.createElement("composite_text");
|
QDomElement dom_comp_text = root_element.ownerDocument().createElement("composite_text");
|
||||||
dom_comp_text.appendChild(dom_doc.createTextNode(m_composite_text));
|
dom_comp_text.appendChild(root_element.ownerDocument().createTextNode(m_composite_text));
|
||||||
root_element.appendChild(dom_comp_text);
|
root_element.appendChild(dom_comp_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Color
|
//Color
|
||||||
if(color() != QColor(Qt::black)) {
|
if(color() != QColor(Qt::black)) {
|
||||||
QDomElement dom_color = dom_doc.createElement("color");
|
QDomElement dom_color = root_element.ownerDocument().createElement("color");
|
||||||
dom_color.appendChild(dom_doc.createTextNode(color().name()));
|
dom_color.appendChild(root_element.ownerDocument().createTextNode(color().name()));
|
||||||
root_element.appendChild(dom_color);
|
root_element.appendChild(dom_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
return root_element;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartDynamicTextField::fromXml
|
@brief PartDynamicTextField::fromXml
|
||||||
@param dom_elmt
|
@param dom_elmt
|
||||||
*/
|
*/
|
||||||
void PartDynamicTextField::fromXml(const QDomElement &dom_elmt) {
|
bool PartDynamicTextField::fromXmlPriv(const QDomElement &dom_elmt)
|
||||||
|
{
|
||||||
if (dom_elmt.tagName() != xmlName()) {
|
if (dom_elmt.tagName() != xmlName()) {
|
||||||
qDebug() << "PartDynamicTextField::fromXml : Wrong tagg name";
|
qDebug() << "PartDynamicTextField::fromXml : Wrong tagg name";
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsTextItem::setPos(
|
double x=0, y=0, z=0, rot=0;
|
||||||
dom_elmt.attribute("x", QString::number(0)).toDouble(),
|
if (QETXML::propertyDouble(dom_elmt, "x", &x) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
dom_elmt.attribute("y", QString::number(0)).toDouble()
|
QETXML::propertyDouble(dom_elmt, "y", &y) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
);
|
QETXML::propertyDouble(dom_elmt, "z", &z) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
setZValue(dom_elmt.attribute("z", QString::number(zValue())).toDouble());
|
QETXML::propertyDouble(dom_elmt, "rotation", &rot) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
QGraphicsTextItem::setRotation(dom_elmt.attribute("rotation", QString::number(0)).toDouble());
|
return false;
|
||||||
|
|
||||||
if (dom_elmt.hasAttribute("font")) {
|
QGraphicsTextItem::setPos(x, y);
|
||||||
|
setZValue(z);
|
||||||
|
QGraphicsTextItem::setRotation(rot);
|
||||||
|
|
||||||
|
QString font;
|
||||||
|
if (QETXML::propertyString(dom_elmt, "font", &font) == QETXML::PropertyFlags::Success)
|
||||||
|
{
|
||||||
QFont font_;
|
QFont font_;
|
||||||
font_.fromString(dom_elmt.attribute("font"));
|
font_.fromString(font);
|
||||||
setFont(font_);
|
setFont(font_);
|
||||||
}
|
} else { //Keep compatibility TODO remove in futur
|
||||||
else {
|
|
||||||
#if TODO_LIST
|
#if TODO_LIST
|
||||||
#pragma message("@TODO remove in futur")
|
#pragma message("@TODO remove in futur")
|
||||||
#endif
|
#endif
|
||||||
@@ -182,19 +188,24 @@ void PartDynamicTextField::fromXml(const QDomElement &dom_elmt) {
|
|||||||
setFont(QETApp::dynamicTextsItemFont(9));
|
setFont(QETApp::dynamicTextsItemFont(9));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_uuid = QUuid(dom_elmt.attribute("uuid", QUuid::createUuid().toString()));
|
QETXML::propertyUuid(dom_elmt, "uuid", &m_uuid);
|
||||||
setFrame(dom_elmt.attribute("frame", "false") == "true"? true : false);
|
bool frame;
|
||||||
setTextWidth(dom_elmt.attribute("text_width", QString::number(-1)).toDouble());
|
QETXML::propertyBool(dom_elmt, "frame", &frame);
|
||||||
|
|
||||||
|
double text_width=-1;
|
||||||
|
QETXML::propertyDouble(dom_elmt, "text_width", &text_width);
|
||||||
|
setTextWidth(text_width);
|
||||||
|
|
||||||
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
||||||
m_text_from = DynamicElementTextItem::TextFrom(
|
QString text_from;
|
||||||
me.keyToValue(dom_elmt.attribute("text_from").toStdString().data()));
|
QETXML::propertyString(dom_elmt, "text_from", &text_from);
|
||||||
|
m_text_from = DynamicElementTextItem::TextFrom(me.keyToValue(text_from.toStdString().data()));
|
||||||
|
|
||||||
me = QMetaEnum::fromType<Qt::Alignment>();
|
me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
if(dom_elmt.hasAttribute("Halignment"))
|
QString alignment;
|
||||||
setAlignment(Qt::Alignment(
|
if(QETXML::propertyString(dom_elmt, "Halignment", &alignment) != QETXML::PropertyFlags::NotFound)
|
||||||
me.keyToValue(dom_elmt.attribute("Halignment").toStdString().data())));
|
setAlignment(Qt::Alignment(me.keyToValue(alignment.toStdString().data())));
|
||||||
if(dom_elmt.hasAttribute(("Valignment")))
|
if(QETXML::propertyString(dom_elmt, "Valignment", &alignment) != QETXML::PropertyFlags::NotFound)
|
||||||
setAlignment(Qt::Alignment(
|
setAlignment(Qt::Alignment(
|
||||||
me.keyToValue(dom_elmt.attribute("Valignment").toStdString().data())) | this -> alignment());
|
me.keyToValue(dom_elmt.attribute("Valignment").toStdString().data())) | this -> alignment());
|
||||||
|
|
||||||
@@ -221,6 +232,29 @@ void PartDynamicTextField::fromXml(const QDomElement &dom_elmt) {
|
|||||||
QDomElement dom_color = dom_elmt.firstChildElement("color");
|
QDomElement dom_color = dom_elmt.firstChildElement("color");
|
||||||
if(!dom_color.isNull())
|
if(!dom_color.isNull())
|
||||||
setColor(QColor(dom_color.text()));
|
setColor(QColor(dom_color.text()));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PartDynamicTextField::valideXml(QDomElement& dom_elmt) {
|
||||||
|
if (QETXML::propertyDouble(dom_elmt, "x") == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(dom_elmt, "y") == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(dom_elmt, "z") == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(dom_elmt, "rotation") == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (QETXML::propertyUuid(dom_elmt, "uuid") == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (QETXML::propertyString(dom_elmt, "text_from"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(QETXML::propertyString(dom_elmt, "Halignment") == QETXML::PropertyFlags::NotFound)
|
||||||
|
return false;
|
||||||
|
if(QETXML::propertyString(dom_elmt, "Valignment") == QETXML::PropertyFlags::NotFound)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -464,7 +498,7 @@ void PartDynamicTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
|||||||
m_origine_pos != pos()) {
|
m_origine_pos != pos()) {
|
||||||
QPropertyUndoCommand *undo =\
|
QPropertyUndoCommand *undo =\
|
||||||
new QPropertyUndoCommand(this, "pos", QVariant(m_origine_pos), QVariant(pos()));
|
new QPropertyUndoCommand(this, "pos", QVariant(m_origine_pos), QVariant(pos()));
|
||||||
undo -> setText(tr("Déplacer un champ texte"));
|
undo -> setText(tr("D??placer un champ texte"));
|
||||||
undo -> enableAnimation();
|
undo -> enableAnimation();
|
||||||
elementScene() -> undoStack().push(undo);
|
elementScene() -> undoStack().push(undo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,9 +75,12 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
|||||||
void startUserTransformation(const QRectF &initial_selection_rect) override;
|
void startUserTransformation(const QRectF &initial_selection_rect) override;
|
||||||
void handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) override;
|
void handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) override;
|
||||||
|
|
||||||
const QDomElement toXml(QDomDocument &dom_doc) const override;
|
void toXmlPriv(QDomElement&root_element) const override;
|
||||||
void fromXml(const QDomElement &dom_elmt) override;
|
bool fromXmlPriv(const QDomElement &dom_elmt) override;
|
||||||
void fromTextFieldXml(const QDomElement &dom_element);
|
void fromTextFieldXml(const QDomElement &dom_element);
|
||||||
|
static bool valideXml(QDomElement& dom_elmt);
|
||||||
|
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||||
|
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||||
|
|
||||||
DynamicElementTextItem::TextFrom textFrom() const;
|
DynamicElementTextItem::TextFrom textFrom() const;
|
||||||
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
||||||
@@ -116,7 +119,7 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
|||||||
m_info_name,
|
m_info_name,
|
||||||
m_composite_text;
|
m_composite_text;
|
||||||
DynamicElementTextItem::TextFrom m_text_from = DynamicElementTextItem::UserText;
|
DynamicElementTextItem::TextFrom m_text_from = DynamicElementTextItem::UserText;
|
||||||
QUuid m_uuid;
|
QUuid m_uuid{QUuid::createUuid()};
|
||||||
bool m_frame = false,
|
bool m_frame = false,
|
||||||
m_first_add = true,
|
m_first_add = true,
|
||||||
m_block_alignment = false;
|
m_block_alignment = false;
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
|
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
|
||||||
#include "../elementscene.h"
|
#include "../elementscene.h"
|
||||||
|
|
||||||
|
#include "../../qetxml.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::PartEllipse
|
@brief PartEllipse::PartEllipse
|
||||||
Constructor
|
Constructor
|
||||||
@@ -79,22 +81,20 @@ void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::toXml
|
@brief PartEllipse::toXmlPriv
|
||||||
Export this ellipse in xml
|
Export this ellipse in xml
|
||||||
@param xml_document : Xml document to use for create the xml element.
|
|
||||||
@return : an xml element that describe this ellipse
|
@return : an xml element that describe this ellipse
|
||||||
*/
|
*/
|
||||||
const QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
void PartEllipse::toXmlPriv(QDomElement& xml_element) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element;
|
|
||||||
if (qFuzzyCompare(rect().width(), rect().height()))
|
if (qFuzzyCompare(rect().width(), rect().height()))
|
||||||
{
|
{
|
||||||
xml_element = xml_document.createElement("circle");
|
xml_element.setTagName("circle");
|
||||||
xml_element.setAttribute("diameter", QString("%1").arg(rect().width()));
|
xml_element.setAttribute("diameter", QString("%1").arg(rect().width()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xml_element = xml_document.createElement("ellipse");
|
xml_element.setTagName("ellipse");
|
||||||
xml_element.setAttribute("width", QString("%1").arg(rect().width()));
|
xml_element.setAttribute("width", QString("%1").arg(rect().width()));
|
||||||
xml_element.setAttribute("height", QString("%1").arg(rect().height()));
|
xml_element.setAttribute("height", QString("%1").arg(rect().height()));
|
||||||
}
|
}
|
||||||
@@ -104,31 +104,58 @@ const QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
|||||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||||
|
|
||||||
stylesToXml(xml_element);
|
stylesToXml(xml_element);
|
||||||
|
|
||||||
return(xml_element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::fromXml
|
@brief PartEllipse::fromXmlPriv
|
||||||
Import the properties of this ellipse from a xml element.
|
Import the properties of this ellipse from a xml element.
|
||||||
@param qde : Xml document to use.
|
@param qde : Xml document to use.
|
||||||
*/
|
*/
|
||||||
void PartEllipse::fromXml(const QDomElement &qde)
|
bool PartEllipse::fromXmlPriv(const QDomElement &qde)
|
||||||
{
|
{
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
qreal width, height;
|
double x=0, y=0, width=0, height=0;
|
||||||
|
|
||||||
if (qde.tagName() == "ellipse")
|
if (qde.tagName() == "ellipse")
|
||||||
{
|
{
|
||||||
width = qde.attribute("width", "0").toDouble();
|
if (QETXML::propertyDouble(qde, "width", &width) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
height = qde.attribute("height", "0").toDouble();
|
QETXML::propertyDouble(qde, "height", &height) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (QETXML::propertyDouble(qde, "diameter", &width) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
height = width;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
width = height = qde.attribute("diameter", "0").toDouble();
|
|
||||||
|
|
||||||
m_rect = QRectF(mapFromScene(qde.attribute("x", "0").toDouble(),
|
|
||||||
qde.attribute("y", "0").toDouble()),
|
if (QETXML::propertyDouble(qde, "x", &x) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
QSizeF(width, height));
|
QETXML::propertyDouble(qde, "y", &y) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_rect = QRectF(mapFromScene(x, y), QSizeF(width, height));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PartEllipse::valideXml(QDomElement& element) {
|
||||||
|
if (element.tagName() == "ellipse")
|
||||||
|
{
|
||||||
|
if (QETXML::propertyDouble(element, "width") & QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(element, "height") & QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (QETXML::propertyDouble(element, "diameter") & QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ((QETXML::propertyDouble(element, "x") & QETXML::PropertyFlags::NoValidConversion) ||
|
||||||
|
(QETXML::propertyDouble(element, "y") & QETXML::PropertyFlags::NoValidConversion))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -52,8 +52,11 @@ class PartEllipse : public AbstractPartEllipse
|
|||||||
//Name and XML
|
//Name and XML
|
||||||
QString name() const override { return(QObject::tr("ellipse", "element part name")); }
|
QString name() const override { return(QObject::tr("ellipse", "element part name")); }
|
||||||
QString xmlName() const override { return(QString("ellipse")); }
|
QString xmlName() const override { return(QString("ellipse")); }
|
||||||
const QDomElement toXml (QDomDocument &) const override;
|
void toXmlPriv(QDomElement&xml_element) const override;
|
||||||
void fromXml (const QDomElement &) override;
|
bool fromXmlPriv(const QDomElement &) override;
|
||||||
|
static bool valideXml(QDomElement& element);
|
||||||
|
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||||
|
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||||
QPainterPath shape() const override;
|
QPainterPath shape() const override;
|
||||||
QPainterPath shadowShape() const override;
|
QPainterPath shadowShape() const override;
|
||||||
void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
|
void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#include "../../QetGraphicsItemModeler/qetgraphicshandleritem.h"
|
#include "../../QetGraphicsItemModeler/qetgraphicshandleritem.h"
|
||||||
#include "../elementscene.h"
|
#include "../elementscene.h"
|
||||||
|
|
||||||
|
#include "../../qetxml.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,13 +32,10 @@
|
|||||||
@param parent : parent item
|
@param parent : parent item
|
||||||
*/
|
*/
|
||||||
PartLine::PartLine(QETElementEditor *editor, QGraphicsItem *parent) :
|
PartLine::PartLine(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||||
CustomElementGraphicPart(editor, parent),
|
CustomElementGraphicPart(editor, parent)
|
||||||
first_end(Qet::None),
|
{
|
||||||
first_length(1.5),
|
setTagName("line");
|
||||||
second_end(Qet::None),
|
}
|
||||||
second_length(1.5),
|
|
||||||
m_undo_command(nullptr)
|
|
||||||
{}
|
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
PartLine::~PartLine()
|
PartLine::~PartLine()
|
||||||
@@ -105,17 +104,16 @@ void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartLine::toXml
|
@brief PartLine::toXmlPriv
|
||||||
Export this line in xml
|
Export this line in xml
|
||||||
@param xml_document : Xml document to use for create the xml element.
|
@param xml_document : Xml document to use for create the xml element.
|
||||||
@return an xml element that describe this line
|
@return an xml element that describe this line
|
||||||
*/
|
*/
|
||||||
const QDomElement PartLine::toXml(QDomDocument &xml_document) const
|
void PartLine::toXmlPriv(QDomElement& xml_element) const
|
||||||
{
|
{
|
||||||
QPointF p1(sceneP1());
|
QPointF p1(sceneP1());
|
||||||
QPointF p2(sceneP2());
|
QPointF p2(sceneP2());
|
||||||
|
|
||||||
QDomElement xml_element = xml_document.createElement("line");
|
|
||||||
xml_element.setAttribute("x1", QString("%1").arg(p1.x()));
|
xml_element.setAttribute("x1", QString("%1").arg(p1.x()));
|
||||||
xml_element.setAttribute("y1", QString("%1").arg(p1.y()));
|
xml_element.setAttribute("y1", QString("%1").arg(p1.y()));
|
||||||
xml_element.setAttribute("x2", QString("%1").arg(p2.x()));
|
xml_element.setAttribute("x2", QString("%1").arg(p2.x()));
|
||||||
@@ -126,7 +124,6 @@ const QDomElement PartLine::toXml(QDomDocument &xml_document) const
|
|||||||
xml_element.setAttribute("length2", QString("%1").arg(second_length));
|
xml_element.setAttribute("length2", QString("%1").arg(second_length));
|
||||||
|
|
||||||
stylesToXml(xml_element);
|
stylesToXml(xml_element);
|
||||||
return(xml_element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,17 +131,48 @@ const QDomElement PartLine::toXml(QDomDocument &xml_document) const
|
|||||||
Import the properties of this line from a xml element.
|
Import the properties of this line from a xml element.
|
||||||
@param qde : Xml document to use
|
@param qde : Xml document to use
|
||||||
*/
|
*/
|
||||||
void PartLine::fromXml(const QDomElement &qde) {
|
bool PartLine::fromXmlPriv(const QDomElement &qde) {
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
m_line = QLineF(mapFromScene(qde.attribute("x1", "0").toDouble(),
|
|
||||||
qde.attribute("y1", "0").toDouble()),
|
|
||||||
mapFromScene(qde.attribute("x2", "0").toDouble(),
|
|
||||||
qde.attribute("y2", "0").toDouble()));
|
|
||||||
|
|
||||||
first_end = Qet::endTypeFromString(qde.attribute("end1"));
|
double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
|
||||||
first_length = qde.attribute("length1", "1.5").toDouble();
|
if (QETXML::propertyDouble(qde, "x1", &x1) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
second_end = Qet::endTypeFromString(qde.attribute("end2"));
|
QETXML::propertyDouble(qde, "y1", &y1) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
second_length = qde.attribute("length2", "1.5").toDouble();
|
QETXML::propertyDouble(qde, "x2", &x2) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(qde, "y2", &y2) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_line = QLineF(mapFromScene(x1, y1),
|
||||||
|
mapFromScene(x2, y2));
|
||||||
|
|
||||||
|
QString s;
|
||||||
|
if (QETXML::propertyString(qde, "end1", &s) != QETXML::PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
first_end = Qet::endTypeFromString(s);
|
||||||
|
|
||||||
|
if (QETXML::propertyString(qde, "end2", &s) != QETXML::PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
first_end = Qet::endTypeFromString(s);
|
||||||
|
|
||||||
|
if (QETXML::propertyDouble(qde, "length1", &first_length) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(qde, "length2", &second_length) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PartLine::valideXml(QDomElement& element) const {
|
||||||
|
if (QETXML::propertyDouble(element, "x1") ||
|
||||||
|
QETXML::propertyDouble(element, "y1") ||
|
||||||
|
QETXML::propertyDouble(element, "x2") ||
|
||||||
|
QETXML::propertyDouble(element, "y2") ||
|
||||||
|
QETXML::propertyString(element, "end1") ||
|
||||||
|
QETXML::propertyString(element, "end2") ||
|
||||||
|
QETXML::propertyDouble(element, "length1") ||
|
||||||
|
QETXML::propertyDouble(element, "length2") )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -70,8 +70,11 @@ class PartLine : public CustomElementGraphicPart
|
|||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||||
QString name() const override { return(QObject::tr("ligne", "element part name")); }
|
QString name() const override { return(QObject::tr("ligne", "element part name")); }
|
||||||
QString xmlName() const override { return(QString("line")); }
|
QString xmlName() const override { return(QString("line")); }
|
||||||
const QDomElement toXml(QDomDocument &) const override;
|
void toXmlPriv(QDomElement&xml_element) const override;
|
||||||
void fromXml(const QDomElement &) override;
|
bool fromXmlPriv(const QDomElement &) override;
|
||||||
|
bool valideXml(QDomElement& element) const;
|
||||||
|
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||||
|
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||||
virtual QPointF sceneP1() const;
|
virtual QPointF sceneP1() const;
|
||||||
virtual QPointF sceneP2() const;
|
virtual QPointF sceneP2() const;
|
||||||
QPainterPath shape() const override;
|
QPainterPath shape() const override;
|
||||||
@@ -114,15 +117,15 @@ class PartLine : public CustomElementGraphicPart
|
|||||||
QRectF secondEndCircleRect() const;
|
QRectF secondEndCircleRect() const;
|
||||||
|
|
||||||
/*****************/
|
/*****************/
|
||||||
Qet::EndType first_end;
|
Qet::EndType first_end{Qet::EndType::None};
|
||||||
qreal first_length;
|
qreal first_length{1.5};
|
||||||
|
|
||||||
Qet::EndType second_end;
|
Qet::EndType second_end{Qet::EndType::None};
|
||||||
qreal second_length;
|
qreal second_length{1.5};
|
||||||
QList<QPointF> saved_points_;
|
QList<QPointF> saved_points_;
|
||||||
QLineF m_line;
|
QLineF m_line;
|
||||||
int m_vector_index = -1;
|
int m_vector_index = -1;
|
||||||
QPropertyUndoCommand *m_undo_command;
|
QPropertyUndoCommand *m_undo_command{nullptr};
|
||||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
#include "../elementscene.h"
|
#include "../elementscene.h"
|
||||||
#include "../ui/qetelementeditor.h"
|
#include "../ui/qetelementeditor.h"
|
||||||
|
|
||||||
|
#include "../../qetxml.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartPolygon::PartPolygon
|
@brief PartPolygon::PartPolygon
|
||||||
Constructor
|
Constructor
|
||||||
@@ -35,6 +37,7 @@ PartPolygon::PartPolygon(QETElementEditor *editor, QGraphicsItem *parent) :
|
|||||||
m_closed(false),
|
m_closed(false),
|
||||||
m_undo_command(nullptr)
|
m_undo_command(nullptr)
|
||||||
{
|
{
|
||||||
|
setTagName("polygon");
|
||||||
m_insert_point = new QAction(tr("Ajouter un point"), this);
|
m_insert_point = new QAction(tr("Ajouter un point"), this);
|
||||||
m_insert_point->setIcon(QET::Icons::Add);
|
m_insert_point->setIcon(QET::Icons::Add);
|
||||||
connect(m_insert_point, &QAction::triggered, this, &PartPolygon::insertPoint);
|
connect(m_insert_point, &QAction::triggered, this, &PartPolygon::insertPoint);
|
||||||
@@ -89,40 +92,46 @@ void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
|||||||
Import the properties of this polygon from a xml element
|
Import the properties of this polygon from a xml element
|
||||||
@param qde : Xml document to use
|
@param qde : Xml document to use
|
||||||
*/
|
*/
|
||||||
void PartPolygon::fromXml(const QDomElement &qde)
|
bool PartPolygon::fromXmlPriv(const QDomElement &qde)
|
||||||
{
|
{
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
|
|
||||||
|
int error_counter = 0;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
if (QET::attributeIsAReal(qde, QString("x%1").arg(i)) &&\
|
if (QETXML::propertyDouble(qde, QString("x%1").arg(i)) == QETXML::PropertyFlags::Success &&
|
||||||
QET::attributeIsAReal(qde, QString("y%1").arg(i)))
|
QETXML::propertyDouble(qde, QString("y%1").arg(i)) == QETXML::PropertyFlags::Success)
|
||||||
++ i;
|
i++;
|
||||||
|
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPolygonF temp_polygon;
|
QPolygonF temp_polygon;
|
||||||
|
double x, y;
|
||||||
for (int j = 1 ; j < i ; ++ j)
|
for (int j = 1 ; j < i ; ++ j)
|
||||||
{
|
{
|
||||||
temp_polygon << QPointF(qde.attribute(QString("x%1").arg(j)).toDouble(),
|
error_counter += QETXML::propertyDouble(qde, QString("x%1").arg(j), &x);
|
||||||
qde.attribute(QString("y%1").arg(j)).toDouble());
|
error_counter += QETXML::propertyDouble(qde, QString("y%1").arg(j), &y);
|
||||||
|
if (error_counter)
|
||||||
|
return false;
|
||||||
|
temp_polygon << QPointF(x, y);
|
||||||
}
|
}
|
||||||
m_polygon = temp_polygon;
|
m_polygon = temp_polygon;
|
||||||
|
|
||||||
m_closed = qde.attribute("closed") != "false";
|
if (QETXML::propertyBool(qde, "closed", &m_closed) != QETXML::PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartPolygon::toXml
|
@brief PartPolygon::toXmlPriv
|
||||||
Export this polygin in xml
|
Export this polygin in xml
|
||||||
@param xml_document : Xml document to use for create the xml element
|
@param e: properties get part of this DomElement
|
||||||
@return an xml element that describe this polygon
|
|
||||||
*/
|
*/
|
||||||
const QDomElement PartPolygon::toXml(QDomDocument &xml_document) const
|
void PartPolygon::toXmlPriv(QDomElement& xml_element) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement("polygon");
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
foreach(QPointF point, m_polygon) {
|
foreach(QPointF point, m_polygon) {
|
||||||
point = mapToScene(point);
|
point = mapToScene(point);
|
||||||
@@ -132,7 +141,11 @@ const QDomElement PartPolygon::toXml(QDomDocument &xml_document) const
|
|||||||
}
|
}
|
||||||
if (!m_closed) xml_element.setAttribute("closed", "false");
|
if (!m_closed) xml_element.setAttribute("closed", "false");
|
||||||
stylesToXml(xml_element);
|
stylesToXml(xml_element);
|
||||||
return(xml_element);
|
}
|
||||||
|
|
||||||
|
bool PartPolygon::valideXml(QDomElement& element) {
|
||||||
|
// TODO: implement
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -525,7 +538,7 @@ void PartPolygon::insertPoint()
|
|||||||
if(new_polygon != m_polygon)
|
if(new_polygon != m_polygon)
|
||||||
{
|
{
|
||||||
//Wrap the undo for avoid to merge the undo commands when user add several points.
|
//Wrap the undo for avoid to merge the undo commands when user add several points.
|
||||||
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point à un polygone"));
|
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point ?? un polygone"));
|
||||||
new QPropertyUndoCommand(this, "polygon", m_polygon, new_polygon, undo);
|
new QPropertyUndoCommand(this, "polygon", m_polygon, new_polygon, undo);
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,8 +61,12 @@ class PartPolygon : public CustomElementGraphicPart
|
|||||||
|
|
||||||
QString name() const override { return(QObject::tr("polygone", "element part name")); }
|
QString name() const override { return(QObject::tr("polygone", "element part name")); }
|
||||||
QString xmlName() const override { return(QString("polygon")); }
|
QString xmlName() const override { return(QString("polygon")); }
|
||||||
void fromXml(const QDomElement &) override;
|
bool fromXmlPriv(const QDomElement &) override;
|
||||||
const QDomElement toXml(QDomDocument &) const override;
|
void toXmlPriv(QDomElement&xml_element) const override;
|
||||||
|
static bool valideXml(QDomElement& element);
|
||||||
|
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||||
|
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||||
|
|
||||||
|
|
||||||
QPainterPath shape () const override;
|
QPainterPath shape () const override;
|
||||||
QPainterPath shadowShape() const override;
|
QPainterPath shadowShape() const override;
|
||||||
@@ -105,7 +109,7 @@ class PartPolygon : public CustomElementGraphicPart
|
|||||||
void removePoint();
|
void removePoint();
|
||||||
|
|
||||||
|
|
||||||
bool m_closed;
|
bool m_closed{false};
|
||||||
QList<QPointF> saved_points_;
|
QList<QPointF> saved_points_;
|
||||||
QPolygonF m_polygon;
|
QPolygonF m_polygon;
|
||||||
QPropertyUndoCommand *m_undo_command;
|
QPropertyUndoCommand *m_undo_command;
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
|
#include "../../QetGraphicsItemModeler/qetgraphicshandlerutility.h"
|
||||||
#include "../elementscene.h"
|
#include "../elementscene.h"
|
||||||
|
|
||||||
|
#include "../../qetxml.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::PartRectangle
|
@brief PartRectangle::PartRectangle
|
||||||
Constructor
|
Constructor
|
||||||
@@ -30,7 +32,9 @@
|
|||||||
*/
|
*/
|
||||||
PartRectangle::PartRectangle(QETElementEditor *editor, QGraphicsItem *parent) :
|
PartRectangle::PartRectangle(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||||
CustomElementGraphicPart(editor, parent)
|
CustomElementGraphicPart(editor, parent)
|
||||||
{}
|
{
|
||||||
|
setTagName("rect");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::~PartRectangle
|
@brief PartRectangle::~PartRectangle
|
||||||
@@ -80,14 +84,13 @@ void PartRectangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::toXml
|
@brief PartRectangle::toXmlPriv
|
||||||
Export this rectangle in xml
|
Export this rectangle in xml
|
||||||
@param xml_document : Xml document to use for create the xml element.
|
@param xml_document : Xml document to use for create the xml element.
|
||||||
@return an xml element that describe this ellipse
|
@return an xml element that describe this ellipse
|
||||||
*/
|
*/
|
||||||
const QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
void PartRectangle::toXmlPriv(QDomElement& xml_element) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement("rect");
|
|
||||||
QPointF top_left(sceneTopLeft());
|
QPointF top_left(sceneTopLeft());
|
||||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||||
@@ -108,7 +111,6 @@ const QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
|||||||
xml_element.setAttribute("ry", QString::number(m_yRadius));
|
xml_element.setAttribute("ry", QString::number(m_yRadius));
|
||||||
|
|
||||||
stylesToXml(xml_element);
|
stylesToXml(xml_element);
|
||||||
return(xml_element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,18 +118,45 @@ const QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
|||||||
Import the properties of this rectangle from a xml element.
|
Import the properties of this rectangle from a xml element.
|
||||||
@param qde : Xml document to use.
|
@param qde : Xml document to use.
|
||||||
*/
|
*/
|
||||||
void PartRectangle::fromXml(const QDomElement &qde)
|
bool PartRectangle::fromXmlPriv(const QDomElement &qde)
|
||||||
{
|
{
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
setPos(mapFromScene(qde.attribute("x", "0").toDouble(),
|
|
||||||
qde.attribute("y", "0").toDouble()));
|
|
||||||
|
|
||||||
QRectF rect(QPointF(0,0), QSizeF(qde.attribute("width", "0").toDouble(),
|
double x=0, y=0, w=0, h=0, rx=0, ry=0;
|
||||||
qde.attribute("height", "0").toDouble()));
|
if (QETXML::propertyDouble(qde, "x", &x) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(qde, "y", &y) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
setPos(mapFromScene(x, y));
|
||||||
|
|
||||||
|
if (QETXML::propertyDouble(qde, "width", &w) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(qde, "height", &h) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QRectF rect(QPointF(0,0), QSizeF(w, h));
|
||||||
|
|
||||||
setRect(rect.normalized());
|
setRect(rect.normalized());
|
||||||
setXRadius(qde.attribute("rx", "0").toDouble());
|
|
||||||
setYRadius(qde.attribute("ry", "0").toDouble());
|
if (QETXML::propertyDouble(qde, "rx", &rx) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(qde, "ry", &ry) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
setXRadius(rx);
|
||||||
|
setYRadius(ry);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PartRectangle::valideXml(QDomElement& element) {
|
||||||
|
// parameters have default values so no value is not a non valid xml element
|
||||||
|
if ((QETXML::propertyDouble(element, "x") & QETXML::PropertyFlags::NoValidConversion) |
|
||||||
|
(QETXML::propertyDouble(element, "y") & QETXML::PropertyFlags::NoValidConversion) |
|
||||||
|
(QETXML::propertyDouble(element, "width") & QETXML::PropertyFlags::NoValidConversion) |
|
||||||
|
(QETXML::propertyDouble(element, "height") & QETXML::PropertyFlags::NoValidConversion) |
|
||||||
|
(QETXML::propertyDouble(element, "rx") & QETXML::PropertyFlags::NoValidConversion) |
|
||||||
|
(QETXML::propertyDouble(element, "ry") & QETXML::PropertyFlags::NoValidConversion))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -60,8 +60,11 @@ class PartRectangle : public CustomElementGraphicPart
|
|||||||
QString name () const override { return(QObject::tr("rectangle", "element part name")); }
|
QString name () const override { return(QObject::tr("rectangle", "element part name")); }
|
||||||
|
|
||||||
QString xmlName () const override { return(QString("rect")); }
|
QString xmlName () const override { return(QString("rect")); }
|
||||||
const QDomElement toXml (QDomDocument &) const override;
|
void toXmlPriv(QDomElement&xml_element) const override;
|
||||||
void fromXml (const QDomElement &) override;
|
bool fromXmlPriv (const QDomElement &) override;
|
||||||
|
static bool valideXml(QDomElement& element);
|
||||||
|
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||||
|
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||||
|
|
||||||
QRectF rect() const;
|
QRectF rect() const;
|
||||||
void setRect(const QRectF &rect);
|
void setRect(const QRectF &rect);
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include "../../qetgraphicsitem/terminal.h"
|
#include "../../qetgraphicsitem/terminal.h"
|
||||||
|
|
||||||
|
#include "../../qetxml.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartTerminal::PartTerminal
|
@brief PartTerminal::PartTerminal
|
||||||
@param editor :
|
@param editor :
|
||||||
@@ -29,7 +31,9 @@
|
|||||||
PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent) :
|
PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||||
CustomElementGraphicPart(editor, parent)
|
CustomElementGraphicPart(editor, parent)
|
||||||
{
|
{
|
||||||
|
setTagName("terminal");
|
||||||
d = new TerminalData(this);
|
d = new TerminalData(this);
|
||||||
|
d->m_name = tr("terminal");
|
||||||
d -> m_orientation = Qet::North;
|
d -> m_orientation = Qet::North;
|
||||||
d -> m_uuid = QUuid::createUuid(); // if part is loaded this uuid will be overwritten, but being sure that terminal has a uuid
|
d -> m_uuid = QUuid::createUuid(); // if part is loaded this uuid will be overwritten, but being sure that terminal has a uuid
|
||||||
updateSecondPoint();
|
updateSecondPoint();
|
||||||
@@ -45,10 +49,20 @@ PartTerminal::~PartTerminal()
|
|||||||
Importe les proprietes d'une borne depuis un element XML
|
Importe les proprietes d'une borne depuis un element XML
|
||||||
@param xml_elmt Element XML a lire
|
@param xml_elmt Element XML a lire
|
||||||
*/
|
*/
|
||||||
void PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
bool PartTerminal::fromXmlPriv(const QDomElement &xml_elmt) {
|
||||||
d -> fromXml(xml_elmt);
|
|
||||||
|
// 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
|
||||||
|
QETXML::propertyUuid(xml_elmt, "uuid", &d->m_uuid);
|
||||||
|
|
||||||
|
if (!d->fromXml(xml_elmt))
|
||||||
|
return false;
|
||||||
|
|
||||||
setPos(d -> m_pos);
|
setPos(d -> m_pos);
|
||||||
updateSecondPoint();
|
updateSecondPoint();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,9 +70,19 @@ void PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
|||||||
@param xml_document Document XML a utiliser pour creer l'element XML
|
@param xml_document Document XML a utiliser pour creer l'element XML
|
||||||
@return un element XML decrivant la borne
|
@return un element XML decrivant la borne
|
||||||
*/
|
*/
|
||||||
const QDomElement PartTerminal::toXml(QDomDocument &xml_document) const
|
void PartTerminal::toXmlPriv(QDomElement& e) const {
|
||||||
{
|
|
||||||
return d -> toXml(xml_document);
|
e.setAttribute("uuid", d->m_uuid.toString());
|
||||||
|
|
||||||
|
d->m_pos = pos();
|
||||||
|
|
||||||
|
QDomDocument doc = e.ownerDocument();
|
||||||
|
e.appendChild(d -> toXml(doc));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PartTerminal::valideXml(QDomElement& element) {
|
||||||
|
return TerminalData::valideXml(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -223,7 +247,7 @@ QRectF PartTerminal::sceneGeometricRect() const
|
|||||||
*/
|
*/
|
||||||
void PartTerminal::startUserTransformation(const QRectF &initial_selection_rect) {
|
void PartTerminal::startUserTransformation(const QRectF &initial_selection_rect) {
|
||||||
Q_UNUSED(initial_selection_rect)
|
Q_UNUSED(initial_selection_rect)
|
||||||
saved_position_ = scenePos();
|
m_saved_position = scenePos();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -231,6 +255,6 @@ void PartTerminal::startUserTransformation(const QRectF &initial_selection_rect)
|
|||||||
*/
|
*/
|
||||||
void PartTerminal::handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) {
|
void PartTerminal::handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) {
|
||||||
QPointF mapped_point = mapPoints(
|
QPointF mapped_point = mapPoints(
|
||||||
initial_selection_rect, new_selection_rect, QList<QPointF>() << saved_position_).first();
|
initial_selection_rect, new_selection_rect, QList<QPointF>() << m_saved_position).first();
|
||||||
setPos(mapped_point);
|
setPos(mapped_point);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,8 +56,11 @@ class PartTerminal : public CustomElementGraphicPart
|
|||||||
*/
|
*/
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
QString xmlName() const override { return(QString("terminal")); }
|
QString xmlName() const override { return(QString("terminal")); }
|
||||||
void fromXml(const QDomElement &) override;
|
bool fromXmlPriv(const QDomElement &) override;
|
||||||
const QDomElement toXml(QDomDocument &) const override;
|
void toXmlPriv(QDomElement&xml_element) const override;
|
||||||
|
static bool valideXml(QDomElement& element);
|
||||||
|
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||||
|
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||||
void paint(
|
void paint(
|
||||||
QPainter *painter,
|
QPainter *painter,
|
||||||
const QStyleOptionGraphicsItem *,
|
const QStyleOptionGraphicsItem *,
|
||||||
@@ -84,9 +87,9 @@ class PartTerminal : public CustomElementGraphicPart
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void updateSecondPoint();
|
void updateSecondPoint();
|
||||||
TerminalData* d; // pointer to the terminal data
|
TerminalData* d{nullptr}; // pointer to the terminal data
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointF saved_position_;
|
QPointF m_saved_position;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
#include "../elementscene.h"
|
#include "../elementscene.h"
|
||||||
#include "../ui/texteditor.h"
|
#include "../ui/texteditor.h"
|
||||||
|
|
||||||
|
#include "../../qetxml.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@param editor L'editeur d'element concerne
|
@param editor L'editeur d'element concerne
|
||||||
@@ -67,29 +69,49 @@ PartText::~PartText()
|
|||||||
Importe les proprietes d'un texte statique depuis un element XML
|
Importe les proprietes d'un texte statique depuis un element XML
|
||||||
@param xml_element Element XML a lire
|
@param xml_element Element XML a lire
|
||||||
*/
|
*/
|
||||||
void PartText::fromXml(const QDomElement &xml_element) {
|
bool PartText::fromXmlPriv(const QDomElement &xml_element)
|
||||||
bool ok;
|
{
|
||||||
|
int size;
|
||||||
|
QString font;
|
||||||
|
|
||||||
if (xml_element.hasAttribute("size")) {
|
if (QETXML::propertyInteger(xml_element, "size", &size) != QETXML::PropertyFlags::NotFound)
|
||||||
int font_size = xml_element.attribute("size").toInt(&ok);
|
{
|
||||||
if (!ok || font_size < 1) {
|
if (size < 1) {
|
||||||
font_size = 20;
|
size = 20;
|
||||||
}
|
}
|
||||||
QFont font_ = this -> font();
|
QFont font_ = this -> font();
|
||||||
font_.setPointSize(font_size);
|
font_.setPointSize(size);
|
||||||
setFont(font_);
|
setFont(font_);
|
||||||
}
|
}
|
||||||
else if (xml_element.hasAttribute("font")) {
|
else if (QETXML::propertyString(xml_element, "font", &font) != QETXML::PropertyFlags::NotFound)
|
||||||
|
{
|
||||||
QFont font_;
|
QFont font_;
|
||||||
font_.fromString(xml_element.attribute("font"));
|
font_.fromString(font);
|
||||||
setFont(font_);
|
setFont(font_);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
setDefaultTextColor(QColor(xml_element.attribute("color", "#000000")));
|
QColor color;
|
||||||
setPlainText(xml_element.attribute("text"));
|
QString text;
|
||||||
setPos(xml_element.attribute("x").toDouble(),
|
QETXML::propertyColor(xml_element, "color", &color);
|
||||||
xml_element.attribute("y").toDouble());
|
setDefaultTextColor(color);
|
||||||
setRotation(xml_element.attribute("rotation", QString::number(0)).toDouble());
|
|
||||||
|
|
||||||
|
QETXML::propertyString(xml_element, "text", &text);
|
||||||
|
setPlainText(text);
|
||||||
|
|
||||||
|
double x=0, y=0, rot=0;
|
||||||
|
if (QETXML::propertyDouble(xml_element, "x", &x) == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(xml_element, "y", &y) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
setPos(x, y);
|
||||||
|
|
||||||
|
if (QETXML::propertyDouble(xml_element, "rotation", &rot) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
setRotation(rot);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,18 +119,38 @@ void PartText::fromXml(const QDomElement &xml_element) {
|
|||||||
@param xml_document Document XML a utiliser pour creer l'element XML
|
@param xml_document Document XML a utiliser pour creer l'element XML
|
||||||
@return un element XML decrivant le texte statique
|
@return un element XML decrivant le texte statique
|
||||||
*/
|
*/
|
||||||
const QDomElement PartText::toXml(QDomDocument &xml_document) const
|
void PartText::toXmlPriv(QDomElement& xml_element) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement(xmlName());
|
|
||||||
|
|
||||||
xml_element.setAttribute("x", QString::number(pos().x()));
|
xml_element.setAttribute("x", QString::number(pos().x()));
|
||||||
xml_element.setAttribute("y", QString::number(pos().y()));
|
xml_element.setAttribute("y", QString::number(pos().y()));
|
||||||
xml_element.setAttribute("text", toPlainText());
|
xml_element.setAttribute("text", toPlainText());
|
||||||
xml_element.setAttribute("font", font().toString());
|
xml_element.setAttribute("font", font().toString());
|
||||||
xml_element.setAttribute("rotation", QString::number(rotation()));
|
xml_element.setAttribute("rotation", QString::number(rotation()));
|
||||||
xml_element.setAttribute("color", defaultTextColor().name());
|
xml_element.setAttribute("color", defaultTextColor().name());
|
||||||
|
}
|
||||||
|
|
||||||
return(xml_element);
|
bool PartText::valideXml(QDomElement& element) {
|
||||||
|
|
||||||
|
if (QETXML::propertyInteger(element, "size") == QETXML::PropertyFlags::NotFound ||
|
||||||
|
QETXML::propertyString(element, "font") == QETXML::PropertyFlags::NotFound) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (QETXML::propertyString(element, "color") == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
if (QETXML::propertyString(element, "text"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (QETXML::propertyDouble(element, "x") == QETXML::PropertyFlags::NoValidConversion ||
|
||||||
|
QETXML::propertyDouble(element, "y") == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (QETXML::propertyDouble(element, "rotation", 0) == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -59,8 +59,11 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
QString name() const override { return(QObject::tr("texte", "element part name")); }
|
QString name() const override { return(QObject::tr("texte", "element part name")); }
|
||||||
QString xmlName() const override { return(QString("text")); }
|
QString xmlName() const override { return(QString("text")); }
|
||||||
void fromXml(const QDomElement &) override;
|
bool fromXmlPriv(const QDomElement &) override;
|
||||||
const QDomElement toXml(QDomDocument &) const override;
|
static bool valideXml(QDomElement& element);
|
||||||
|
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||||
|
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||||
|
void toXmlPriv(QDomElement&xml_element) const override;
|
||||||
void setRotation(qreal angle) {(QGraphicsObject::setRotation(QET::correctAngle(angle)));}
|
void setRotation(qreal angle) {(QGraphicsObject::setRotation(QET::correctAngle(angle)));}
|
||||||
bool isUseless() const override;
|
bool isUseless() const override;
|
||||||
QRectF sceneGeometricRect() const override;
|
QRectF sceneGeometricRect() const override;
|
||||||
|
|||||||
@@ -440,10 +440,10 @@ void StyleEditor::updatePartFilling()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief StyleEditor::updateForm
|
@brief StyleEditor::updateFormPriv
|
||||||
Update the edition form according to the value of edited part(s)
|
Update the edition form according to the value of edited part(s)
|
||||||
*/
|
*/
|
||||||
void StyleEditor::updateForm()
|
void StyleEditor::updateFormPriv()
|
||||||
{
|
{
|
||||||
if (!part && m_part_list.isEmpty()) return;
|
if (!part && m_part_list.isEmpty()) return;
|
||||||
activeConnections(false);
|
activeConnections(false);
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class StyleEditor : public ElementItemEditor
|
|||||||
static bool isStyleEditable (QList <CustomElementPart *> cep_list);
|
static bool isStyleEditable (QList <CustomElementPart *> cep_list);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateForm() override;
|
void updateFormPriv() override;
|
||||||
void updatePartAntialiasing();
|
void updatePartAntialiasing();
|
||||||
void updatePartColor();
|
void updatePartColor();
|
||||||
void updatePartLineStyle();
|
void updatePartLineStyle();
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ DynamicTextFieldEditor::DynamicTextFieldEditor(QETElementEditor *editor,
|
|||||||
DynamicTextFieldEditor::~DynamicTextFieldEditor()
|
DynamicTextFieldEditor::~DynamicTextFieldEditor()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
if(!m_connection_list.isEmpty()) {
|
if(!m_change_connections.isEmpty()) {
|
||||||
for(const QMetaObject::Connection& con : m_connection_list) {
|
for(const QMetaObject::Connection& con : m_change_connections) {
|
||||||
disconnect(con);
|
disconnect(con);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ QList<CustomElementPart*> DynamicTextFieldEditor::currentParts() const
|
|||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::updateForm()
|
void DynamicTextFieldEditor::updateFormPriv()
|
||||||
{
|
{
|
||||||
if(m_text_field) {
|
if(m_text_field) {
|
||||||
ui -> m_x_sb -> setValue(m_text_field.data() -> x());
|
ui -> m_x_sb -> setValue(m_text_field.data() -> x());
|
||||||
@@ -182,38 +182,38 @@ void DynamicTextFieldEditor::setupWidget()
|
|||||||
|
|
||||||
void DynamicTextFieldEditor::setUpConnections()
|
void DynamicTextFieldEditor::setUpConnections()
|
||||||
{
|
{
|
||||||
assert(m_connection_list.isEmpty());
|
assert(m_change_connections.isEmpty());
|
||||||
//Setup the connection
|
//Setup the connection
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::colorChanged,
|
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::colorChanged,
|
||||||
[this](){this -> updateForm();});
|
[this](){this -> updateForm();});
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::fontChanged,
|
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::fontChanged,
|
||||||
[this](){this -> updateForm();});
|
[this](){this -> updateForm();});
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::taggChanged,
|
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::taggChanged,
|
||||||
[this](){this -> updateForm();});
|
[this](){this -> updateForm();});
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textFromChanged,
|
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::textFromChanged,
|
||||||
[this](){this -> updateForm();});
|
[this](){this -> updateForm();});
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textChanged,
|
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::textChanged,
|
||||||
[this](){this -> updateForm();});
|
[this](){this -> updateForm();});
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::infoNameChanged,
|
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::infoNameChanged,
|
||||||
[this](){this -> updateForm();});
|
[this](){this -> updateForm();});
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::rotationChanged,
|
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::rotationChanged,
|
||||||
[this](){this -> updateForm();});
|
[this](){this -> updateForm();});
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::frameChanged,
|
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::frameChanged,
|
||||||
[this](){this -> updateForm();});
|
[this](){this -> updateForm();});
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textWidthChanged,
|
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::textWidthChanged,
|
||||||
[this](){this -> updateForm();});
|
[this](){this -> updateForm();});
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::compositeTextChanged,
|
m_change_connections << connect(m_text_field.data(), &PartDynamicTextField::compositeTextChanged,
|
||||||
[this](){this -> updateForm();});
|
[this](){this -> updateForm();});
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::disconnectConnections()
|
void DynamicTextFieldEditor::disconnectConnections()
|
||||||
{
|
{
|
||||||
//Remove previous connection
|
//Remove previous connection
|
||||||
if(!m_connection_list.isEmpty())
|
if(!m_change_connections.isEmpty())
|
||||||
for(const QMetaObject::Connection& con : m_connection_list) {
|
for(const QMetaObject::Connection& con : m_change_connections) {
|
||||||
disconnect(con);
|
disconnect(con);
|
||||||
}
|
}
|
||||||
m_connection_list.clear();
|
m_change_connections.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class DynamicTextFieldEditor : public ElementItemEditor {
|
|||||||
bool setParts(QList <CustomElementPart *>) override;
|
bool setParts(QList <CustomElementPart *>) override;
|
||||||
CustomElementPart *currentPart() const override;
|
CustomElementPart *currentPart() const override;
|
||||||
QList<CustomElementPart*> currentParts() const override;
|
QList<CustomElementPart*> currentParts() const override;
|
||||||
void updateForm() override;
|
void updateFormPriv() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupWidget();
|
void setupWidget();
|
||||||
@@ -73,7 +73,6 @@ class DynamicTextFieldEditor : public ElementItemEditor {
|
|||||||
Ui::DynamicTextFieldEditor *ui;
|
Ui::DynamicTextFieldEditor *ui;
|
||||||
QPointer<PartDynamicTextField> m_text_field;
|
QPointer<PartDynamicTextField> m_text_field;
|
||||||
QList<PartDynamicTextField*> m_parts;
|
QList<PartDynamicTextField*> m_parts;
|
||||||
QList<QMetaObject::Connection> m_connection_list;
|
|
||||||
|
|
||||||
#ifdef BUILD_WITHOUT_KF5
|
#ifdef BUILD_WITHOUT_KF5
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -110,9 +110,9 @@ QList<CustomElementPart *> EllipseEditor::currentParts() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief EllipseEditor::updateForm
|
* @brief EllipseEditor::updateFormPriv
|
||||||
*/
|
*/
|
||||||
void EllipseEditor::updateForm()
|
void EllipseEditor::updateFormPriv()
|
||||||
{
|
{
|
||||||
if (!m_part) {
|
if (!m_part) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class EllipseEditor : public ElementItemEditor
|
|||||||
bool setParts(QList<CustomElementPart *> parts) override;
|
bool setParts(QList<CustomElementPart *> parts) override;
|
||||||
CustomElementPart *currentPart() const override;
|
CustomElementPart *currentPart() const override;
|
||||||
QList<CustomElementPart*> currentParts() const override;
|
QList<CustomElementPart*> currentParts() const override;
|
||||||
void updateForm() override;
|
void updateFormPriv() override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_x_sb_editingFinished();
|
void on_m_x_sb_editingFinished();
|
||||||
@@ -60,7 +60,6 @@ class EllipseEditor : public ElementItemEditor
|
|||||||
Ui::EllipseEditor *ui;
|
Ui::EllipseEditor *ui;
|
||||||
PartEllipse *m_part = nullptr;
|
PartEllipse *m_part = nullptr;
|
||||||
StyleEditor *m_style = nullptr;
|
StyleEditor *m_style = nullptr;
|
||||||
QList <QMetaObject::Connection> m_change_connections;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -176,10 +176,10 @@ QList<CustomElementPart *> LineEditor::currentParts() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief LineEditor::updateForm
|
@brief LineEditor::updateFormPriv
|
||||||
Reimplemented from ElementItemEditor
|
Reimplemented from ElementItemEditor
|
||||||
*/
|
*/
|
||||||
void LineEditor::updateForm()
|
void LineEditor::updateFormPriv()
|
||||||
{
|
{
|
||||||
if (!m_part) {
|
if (!m_part) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class LineEditor : public ElementItemEditor
|
|||||||
bool setParts(QList <CustomElementPart *> parts) override;
|
bool setParts(QList <CustomElementPart *> parts) override;
|
||||||
CustomElementPart *currentPart() const override;
|
CustomElementPart *currentPart() const override;
|
||||||
QList<CustomElementPart *> currentParts() const override;
|
QList<CustomElementPart *> currentParts() const override;
|
||||||
void updateForm() override;
|
void updateFormPriv() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setUpChangeConnections();
|
void setUpChangeConnections();
|
||||||
@@ -60,7 +60,6 @@ class LineEditor : public ElementItemEditor
|
|||||||
PartLine *m_part = nullptr;
|
PartLine *m_part = nullptr;
|
||||||
Ui::LineEditor *ui;
|
Ui::LineEditor *ui;
|
||||||
StyleEditor *m_style = nullptr;
|
StyleEditor *m_style = nullptr;
|
||||||
QList <QMetaObject::Connection> m_change_connections;
|
|
||||||
bool m_locked = false;
|
bool m_locked = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -130,10 +130,10 @@ QList<CustomElementPart*> PolygonEditor::currentParts() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PolygonEditor::updateForm
|
@brief PolygonEditor::updateFormPriv
|
||||||
Update the widget
|
Update the widget
|
||||||
*/
|
*/
|
||||||
void PolygonEditor::updateForm()
|
void PolygonEditor::updateFormPriv()
|
||||||
{
|
{
|
||||||
if (!m_part) {
|
if (!m_part) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class PolygonEditor : public ElementItemEditor
|
|||||||
bool setPart(CustomElementPart *part) override;
|
bool setPart(CustomElementPart *part) override;
|
||||||
CustomElementPart *currentPart() const override;
|
CustomElementPart *currentPart() const override;
|
||||||
QList<CustomElementPart*> currentParts() const override;
|
QList<CustomElementPart*> currentParts() const override;
|
||||||
void updateForm() override;
|
void updateFormPriv() override;
|
||||||
QVector<QPointF> pointsFromTree();
|
QVector<QPointF> pointsFromTree();
|
||||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
|
|
||||||
@@ -63,7 +63,6 @@ class PolygonEditor : public ElementItemEditor
|
|||||||
Ui::PolygonEditor *ui;
|
Ui::PolygonEditor *ui;
|
||||||
StyleEditor *m_style = nullptr;
|
StyleEditor *m_style = nullptr;
|
||||||
PartPolygon *m_part = nullptr;
|
PartPolygon *m_part = nullptr;
|
||||||
QList <QMetaObject::Connection> m_change_connections;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // POLYGONEDITOR_H
|
#endif // POLYGONEDITOR_H
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ QPointF RectangleEditor::editedTopLeft() const
|
|||||||
/**
|
/**
|
||||||
@brief RectangleEditor::updateForm
|
@brief RectangleEditor::updateForm
|
||||||
*/
|
*/
|
||||||
void RectangleEditor::updateForm()
|
void RectangleEditor::updateFormPriv()
|
||||||
{
|
{
|
||||||
if (!m_part) {
|
if (!m_part) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class RectangleEditor : public ElementItemEditor
|
|||||||
QPointF editedTopLeft () const;
|
QPointF editedTopLeft () const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateForm() override;
|
void updateFormPriv() override;
|
||||||
private:
|
private:
|
||||||
void editingFinished();
|
void editingFinished();
|
||||||
void activeConnections(bool active);
|
void activeConnections(bool active);
|
||||||
@@ -70,7 +70,6 @@ class RectangleEditor : public ElementItemEditor
|
|||||||
StyleEditor *m_style;
|
StyleEditor *m_style;
|
||||||
PartRectangle *m_part;
|
PartRectangle *m_part;
|
||||||
Ui::RectangleEditor *ui;
|
Ui::RectangleEditor *ui;
|
||||||
QList <QMetaObject::Connection> m_change_connections;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RECTANGLEEDITOR_H
|
#endif // RECTANGLEEDITOR_H
|
||||||
|
|||||||
@@ -46,11 +46,11 @@ TerminalEditor::~TerminalEditor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TerminalEditor::updateForm
|
* @brief TerminalEditor::updateFormPriv
|
||||||
* Reimplemented from ElementItemEditor
|
* Reimplemented from ElementItemEditor
|
||||||
* Update the content of this widget
|
* Update the content of this widget
|
||||||
*/
|
*/
|
||||||
void TerminalEditor::updateForm()
|
void TerminalEditor::updateFormPriv()
|
||||||
{
|
{
|
||||||
if (!m_part) {
|
if (!m_part) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class TerminalEditor : public ElementItemEditor
|
|||||||
TerminalEditor(QETElementEditor *editor, QWidget *parent = nullptr);
|
TerminalEditor(QETElementEditor *editor, QWidget *parent = nullptr);
|
||||||
~TerminalEditor() override;
|
~TerminalEditor() override;
|
||||||
|
|
||||||
void updateForm() override;
|
void updateFormPriv() override;
|
||||||
bool setPart(CustomElementPart *new_part) override;
|
bool setPart(CustomElementPart *new_part) override;
|
||||||
CustomElementPart *currentPart() const override;
|
CustomElementPart *currentPart() const override;
|
||||||
QList<CustomElementPart *> currentParts() const override {return QList<CustomElementPart *>();}
|
QList<CustomElementPart *> currentParts() const override {return QList<CustomElementPart *>();}
|
||||||
@@ -55,8 +55,7 @@ class TerminalEditor : public ElementItemEditor
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::TerminalEditor *ui;
|
Ui::TerminalEditor *ui;
|
||||||
QVector<QMetaObject::Connection> m_editor_connections,
|
QVector<QMetaObject::Connection> m_editor_connections;
|
||||||
m_change_connections;
|
|
||||||
PartTerminal *m_part = nullptr;
|
PartTerminal *m_part = nullptr;
|
||||||
bool m_locked = false;
|
bool m_locked = false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ TextEditor::~TextEditor() {}
|
|||||||
@brief TextEditor::updateForm
|
@brief TextEditor::updateForm
|
||||||
Update the gui
|
Update the gui
|
||||||
*/
|
*/
|
||||||
void TextEditor::updateForm()
|
void TextEditor::updateFormPriv()
|
||||||
{
|
{
|
||||||
if (m_text.isNull()) {
|
if (m_text.isNull()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class TextEditor : public ElementItemEditor {
|
|||||||
explicit TextEditor(QETElementEditor *editor, PartText *text = nullptr, QWidget *parent = nullptr);
|
explicit TextEditor(QETElementEditor *editor, PartText *text = nullptr, QWidget *parent = nullptr);
|
||||||
~TextEditor() override;
|
~TextEditor() override;
|
||||||
|
|
||||||
void updateForm() override;
|
void updateFormPriv() override;
|
||||||
bool setPart(CustomElementPart *part) override;
|
bool setPart(CustomElementPart *part) override;
|
||||||
bool setParts(QList <CustomElementPart *>) override;
|
bool setParts(QList <CustomElementPart *>) override;
|
||||||
CustomElementPart *currentPart() const override;
|
CustomElementPart *currentPart() const override;
|
||||||
|
|||||||
@@ -109,8 +109,7 @@ QDomDocument ExportElementTextPattern::xmlConf() const
|
|||||||
root.setAttribute("name", m_name);
|
root.setAttribute("name", m_name);
|
||||||
doc.appendChild(root);
|
doc.appendChild(root);
|
||||||
|
|
||||||
QHash<Terminal *, int> H;
|
QDomElement elmt = m_element->toXml(doc);
|
||||||
QDomElement elmt = m_element->toXml(doc, H);
|
|
||||||
QDomElement texts = elmt.firstChildElement("dynamic_texts");
|
QDomElement texts = elmt.firstChildElement("dynamic_texts");
|
||||||
QDomElement groups = elmt.firstChildElement("texts_groups");
|
QDomElement groups = elmt.firstChildElement("texts_groups");
|
||||||
|
|
||||||
|
|||||||
@@ -150,6 +150,14 @@ void Machine_info::send_info_to_debug()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Machine_info::~Machine_info
|
||||||
|
destructor
|
||||||
|
*/
|
||||||
|
Machine_info::~Machine_info()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Machine_info::init_get_Screen_info
|
@brief Machine_info::init_get_Screen_info
|
||||||
Finds the largest screen and saves the values
|
Finds the largest screen and saves the values
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public:
|
|||||||
int32_t i_max_screen_height();
|
int32_t i_max_screen_height();
|
||||||
QString compilation_info();
|
QString compilation_info();
|
||||||
void send_info_to_debug();
|
void send_info_to_debug();
|
||||||
|
~Machine_info();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|||||||
@@ -19,19 +19,18 @@
|
|||||||
#include "../qetxml.h"
|
#include "../qetxml.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
void ElementData::toSettings(QSettings &settings, const QString prefix) const {
|
void ElementData::toSettings(QSettings &settings, const QString& prefix) const {
|
||||||
Q_UNUSED(settings)
|
Q_UNUSED(settings)
|
||||||
Q_UNUSED(prefix)
|
Q_UNUSED(prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElementData::fromSettings(const QSettings &settings, const QString prefix) {
|
void ElementData::fromSettings(QSettings &settings, const QString& prefix) {
|
||||||
Q_UNUSED(settings)
|
Q_UNUSED(settings)
|
||||||
Q_UNUSED(prefix)
|
Q_UNUSED(prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement ElementData::toXml(QDomDocument &xml_element) const {
|
void ElementData::toXmlPriv(QDomElement& e) const {
|
||||||
Q_UNUSED(xml_element)
|
Q_UNUSED(e)
|
||||||
return QDomElement();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,7 +41,7 @@ QDomElement ElementData::toXml(QDomDocument &xml_element) const {
|
|||||||
* @param xml_element : tagName must be 'definition'
|
* @param xml_element : tagName must be 'definition'
|
||||||
* @return true is successfuly loaded
|
* @return true is successfuly loaded
|
||||||
*/
|
*/
|
||||||
bool ElementData::fromXml(const QDomElement &xml_element)
|
bool ElementData::fromXmlPriv(const QDomElement &xml_element)
|
||||||
{
|
{
|
||||||
if(xml_element.tagName() != "definition" ||
|
if(xml_element.tagName() != "definition" ||
|
||||||
xml_element.attribute("type") != "element") {
|
xml_element.attribute("type") != "element") {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#ifndef ELEMENTDATA_H
|
#ifndef ELEMENTDATA_H
|
||||||
#define ELEMENTDATA_H
|
#define ELEMENTDATA_H
|
||||||
|
|
||||||
#include "propertiesinterface.h"
|
#include "../properties/propertiesinterface.h"
|
||||||
#include "../diagramcontext.h"
|
#include "../diagramcontext.h"
|
||||||
#include "../NameList/nameslist.h"
|
#include "../NameList/nameslist.h"
|
||||||
|
|
||||||
@@ -85,10 +85,10 @@ class ElementData : public PropertiesInterface
|
|||||||
ElementData() {}
|
ElementData() {}
|
||||||
~ElementData() override {}
|
~ElementData() override {}
|
||||||
|
|
||||||
void toSettings(QSettings &settings, const QString prefix = QString()) const override;
|
void toSettings(QSettings &settings, const QString& prefix = QString()) const override;
|
||||||
void fromSettings(const QSettings &settings, const QString prefix = QString()) override;
|
void fromSettings(QSettings &settings, const QString& prefix = QString()) override;
|
||||||
QDomElement toXml(QDomDocument &xml_element) const override;
|
void toXmlPriv(QDomElement &) const override;
|
||||||
bool fromXml(const QDomElement &xml_element) override;
|
bool fromXmlPriv(const QDomElement &xml_element) override;
|
||||||
QDomElement kindInfoToXml(QDomDocument &document);
|
QDomElement kindInfoToXml(QDomDocument &document);
|
||||||
|
|
||||||
bool operator==(const ElementData &data) const;
|
bool operator==(const ElementData &data) const;
|
||||||
|
|||||||
@@ -16,17 +16,230 @@
|
|||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "propertiesinterface.h"
|
#include "propertiesinterface.h"
|
||||||
|
#include <QDebug>
|
||||||
|
#include "../qetxml.h"
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Available property types
|
||||||
|
*/
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
const QString userPropertiesS = "userProperties";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PropertiesInterface::PropertiesInterface
|
@brief PropertiesInterface::PropertiesInterface
|
||||||
*/
|
*/
|
||||||
PropertiesInterface::PropertiesInterface()
|
PropertiesInterface::PropertiesInterface(const QString &tagname):
|
||||||
|
mTagName(tagname)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PropertiesInterface::~PropertiesInterface
|
@brief PropertiesInterface::~PropertiesInterface
|
||||||
*/
|
*/
|
||||||
PropertiesInterface::~PropertiesInterface()
|
PropertiesInterface::~PropertiesInterface()
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertiesInterface::setTagName(const QString& tagname)
|
||||||
|
{
|
||||||
|
mTagName = tagname;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PropertiesInterface::tagName() const
|
||||||
|
{
|
||||||
|
return mTagName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement PropertiesInterface::toXml (QDomDocument &xml_document) const
|
||||||
|
{
|
||||||
|
QDomElement element = xml_document.createElement(mTagName);
|
||||||
|
toXmlPriv(element);
|
||||||
|
propertiesToXml(element);
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PropertiesInterface::fromXml (const QDomElement &xml_element)
|
||||||
|
{
|
||||||
|
if (!fromXmlPriv(xml_element))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!propertiesFromXml(xml_element))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PropertiesInterface::valideXml(QDomElement& element) {
|
||||||
|
qDebug(QString("ValideXml() is not implemented. File: %1, Line: %2").arg(__FILE__).arg(__LINE__).toStdString().data());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
||||||
|
en orientation. Si la chaine fait plusieurs caracteres, seul le
|
||||||
|
premier est pris en compte. En cas d'incoherence, Qet::North est
|
||||||
|
retourne.
|
||||||
|
@param s Chaine de caractere cense representer une orientation
|
||||||
|
@return l'orientation designee par la chaine de caractere
|
||||||
|
*/
|
||||||
|
Qet::Orientation PropertiesInterface::orientationFromString(const QString &s) {
|
||||||
|
QChar c = s[0];
|
||||||
|
// in some cases/ old projects? (affuteuse_250h.qet) numbers instead of characters are
|
||||||
|
// used for the orientation
|
||||||
|
if (c == 'e' || c == '1') return(Qet::East);
|
||||||
|
else if (c == 's' || c == '2') return(Qet::South);
|
||||||
|
else if (c == 'w' || c == '3') return (Qet::West);
|
||||||
|
else return(Qet::North); // c == '0'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param o une orientation
|
||||||
|
@return une chaine de caractere representant l'orientation
|
||||||
|
*/
|
||||||
|
QString PropertiesInterface::orientationToString(Qet::Orientation o) {
|
||||||
|
QString ret;
|
||||||
|
switch(o) {
|
||||||
|
case Qet::North: ret = "n"; break;
|
||||||
|
case Qet::East : ret = "e"; break;
|
||||||
|
case Qet::South: ret = "s"; break;
|
||||||
|
case Qet::West : ret = "w"; break;
|
||||||
|
}
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertiesInterface::deleteUserProperties()
|
||||||
|
{
|
||||||
|
properties.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int PropertiesInterface::userPropertiesCount() const
|
||||||
|
{
|
||||||
|
return properties.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertiesInterface::setUserProperty(const QString& key, const QVariant& value)
|
||||||
|
{
|
||||||
|
properties[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PropertiesInterface::existUserProperty(const QString& key) const
|
||||||
|
{
|
||||||
|
return properties.contains(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant PropertiesInterface::userPropertyValue(const QString& key)
|
||||||
|
{
|
||||||
|
if (!existUserProperty(key))
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
return properties[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertiesInterface::propertiesToXml(QDomElement& e) const
|
||||||
|
{
|
||||||
|
if (properties.count() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QDomDocument doc = e.ownerDocument();
|
||||||
|
auto up = doc.createElement(userPropertiesS);
|
||||||
|
for (auto i = properties.begin(); i != properties.end(); ++i)
|
||||||
|
{
|
||||||
|
auto type = i.value().type();
|
||||||
|
switch(type) {
|
||||||
|
case QVariant::Type::String:
|
||||||
|
up.appendChild(QETXML::createXmlProperty(i.key(), i.value().toString())); break;
|
||||||
|
case QVariant::Type::Int:
|
||||||
|
up.appendChild(QETXML::createXmlProperty(i.key(), i.value().toInt())); break;
|
||||||
|
case QVariant::Type::Double:
|
||||||
|
up.appendChild(QETXML::createXmlProperty(i.key(), i.value().toDouble())); break;
|
||||||
|
case QVariant::Type::Bool:
|
||||||
|
up.appendChild(QETXML::createXmlProperty(i.key(), i.value().toBool())); break;
|
||||||
|
case QVariant::Type::Color:
|
||||||
|
up.appendChild(QETXML::createXmlProperty(i.key(), QColor(i.value().value<QColor>()))); break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
e.appendChild(up);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief PropertiesInterface::propertiesFromXml
|
||||||
|
* Read all user properties from the DomElement& e
|
||||||
|
* \param e
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool PropertiesInterface::propertiesFromXml(const QDomElement& e)
|
||||||
|
{
|
||||||
|
QDomNodeList l = e.childNodes();
|
||||||
|
for (int i=0; i < l.count(); i++)
|
||||||
|
{
|
||||||
|
QDomElement userProperties = l.at(i).toElement();
|
||||||
|
if (userProperties.tagName() != userPropertiesS)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QDomElement userProperty;
|
||||||
|
for (int up_index = 0; up_index < userProperties.childNodes().length(); up_index++)
|
||||||
|
{
|
||||||
|
userProperty = userProperties.childNodes().at(up_index).toElement();
|
||||||
|
|
||||||
|
QString name = userProperty.attribute("name");
|
||||||
|
QString type = userProperty.attribute("type");
|
||||||
|
QString value = userProperty.attribute("value");
|
||||||
|
|
||||||
|
if (type == QETXML::integerS)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
if (QETXML::propertyInteger(value, &i) == QETXML::PropertyFlags::Success)
|
||||||
|
properties[name] = QVariant(i);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (type == QETXML::doubleS)
|
||||||
|
{
|
||||||
|
double d;
|
||||||
|
if (QETXML::propertyDouble(value, &d) == QETXML::PropertyFlags::Success)
|
||||||
|
properties[name] = QVariant(d);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (type == QETXML::boolS)
|
||||||
|
{
|
||||||
|
bool b;
|
||||||
|
if (QETXML::propertyBool(value, &b) == QETXML::PropertyFlags::Success)
|
||||||
|
properties[name] = QVariant(b);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (type == QETXML::uuidS)
|
||||||
|
{
|
||||||
|
QUuid u;
|
||||||
|
if (QETXML::propertyUuid(value, &u) == QETXML::PropertyFlags::Success)
|
||||||
|
properties[name] = QVariant(u);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (type == QETXML::colorS)
|
||||||
|
{
|
||||||
|
QColor c;
|
||||||
|
if (QETXML::propertyColor(value, &c) == QETXML::PropertyFlags::Success)
|
||||||
|
properties[name] = QVariant(c);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (type == QETXML::stringS)
|
||||||
|
{
|
||||||
|
properties[name] = QVariant(value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "Not a valid property type!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,11 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QColor>
|
||||||
#include <QDomElement>
|
#include <QDomElement>
|
||||||
|
#include <limits>
|
||||||
|
#include "sources/qet.h"
|
||||||
|
#include <QUuid>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The PropertiesInterface class
|
@brief The PropertiesInterface class
|
||||||
@@ -30,7 +34,7 @@
|
|||||||
class PropertiesInterface
|
class PropertiesInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PropertiesInterface();
|
PropertiesInterface(const QString& tagname = "Properties");
|
||||||
virtual ~PropertiesInterface();
|
virtual ~PropertiesInterface();
|
||||||
/**
|
/**
|
||||||
@brief toSettings
|
@brief toSettings
|
||||||
@@ -39,8 +43,8 @@ class PropertiesInterface
|
|||||||
befor the name of each paramètre
|
befor the name of each paramètre
|
||||||
@param QString
|
@param QString
|
||||||
*/
|
*/
|
||||||
virtual void toSettings (QSettings &settings,
|
virtual void toSettings(QSettings &,
|
||||||
const QString = QString()) const =0;
|
const QString & = QString()) const =0;
|
||||||
/**
|
/**
|
||||||
@brief fromSettings
|
@brief fromSettings
|
||||||
load properties to setting file.
|
load properties to setting file.
|
||||||
@@ -48,22 +52,98 @@ class PropertiesInterface
|
|||||||
befor the name of each paramètre
|
befor the name of each paramètre
|
||||||
@param QString
|
@param QString
|
||||||
*/
|
*/
|
||||||
virtual void fromSettings (const QSettings &settings,
|
virtual void fromSettings(QSettings &,
|
||||||
const QString = QString()) =0;
|
const QString & = QString()) = 0;
|
||||||
/**
|
/**
|
||||||
@brief toXml
|
@brief toXml
|
||||||
Save properties to xml element
|
Save properties to xml element
|
||||||
@param xml_document
|
@param xml_document
|
||||||
@return QDomElement
|
@return QDomElement
|
||||||
*/
|
*/
|
||||||
virtual QDomElement toXml (QDomDocument &xml_document) const =0;
|
virtual QDomElement toXml (QDomDocument &xml_document) const;
|
||||||
/**
|
/**
|
||||||
@brief fromXml
|
@brief fromXml
|
||||||
load properties to xml element
|
load properties to xml element
|
||||||
@param xml_element
|
@param xml_element
|
||||||
@return true / false
|
@return true / false
|
||||||
*/
|
*/
|
||||||
virtual bool fromXml (const QDomElement &xml_element) =0;
|
virtual bool fromXml (const QDomElement &xml_element);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief deleteUserProperties
|
||||||
|
* Delete all userproperties
|
||||||
|
*/
|
||||||
|
void deleteUserProperties();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief userPropertiesCount
|
||||||
|
* Returns the number of user properties
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
int userPropertiesCount() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief setUserProperty
|
||||||
|
* Adds a new property if \p key does not exist in the \p properties member,
|
||||||
|
* otherwise overwrite the value
|
||||||
|
* \param key
|
||||||
|
* \param value
|
||||||
|
*/
|
||||||
|
void setUserProperty(const QString& key, const QVariant& value);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief existUserProperty
|
||||||
|
* Checks if a user property with key \p key is available or not
|
||||||
|
* \param key
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool existUserProperty(const QString& key) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief userProperty
|
||||||
|
* Returns the value of a user property with key \p key
|
||||||
|
* If \p key is not found, an invalid QVariant is returned.
|
||||||
|
* Use QVariant::type() to get the type of the vale
|
||||||
|
* \param key
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
QVariant userPropertyValue(const QString& key);
|
||||||
|
|
||||||
|
|
||||||
|
static bool valideXml(QDomElement& element);
|
||||||
|
|
||||||
|
void setTagName(const QString& tagname);
|
||||||
|
QString tagName() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
||||||
|
en orientation. Si la chaine fait plusieurs caracteres, seul le
|
||||||
|
premier est pris en compte. En cas d'incoherence, Qet::North est
|
||||||
|
retourne.
|
||||||
|
@param s Chaine de caractere cense representer une orientation
|
||||||
|
@return l'orientation designee par la chaine de caractere
|
||||||
|
*/
|
||||||
|
static Qet::Orientation orientationFromString(const QString &s);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param o une orientation
|
||||||
|
@return une chaine de caractere representant l'orientation
|
||||||
|
*/
|
||||||
|
static QString orientationToString(Qet::Orientation o);
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual void toXmlPriv (QDomElement &e) const =0;
|
||||||
|
virtual bool fromXmlPriv (const QDomElement &e) =0;
|
||||||
|
/*!
|
||||||
|
* \brief PropertiesInterface::propertiesToXml
|
||||||
|
* Write all user properties to the DomElement \p e
|
||||||
|
* \param e
|
||||||
|
*/
|
||||||
|
void propertiesToXml(QDomElement& e) const;
|
||||||
|
bool propertiesFromXml (const QDomElement &e);
|
||||||
|
|
||||||
|
QHash<QString, QVariant> properties;
|
||||||
|
QString mTagName{""};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROPERTIESINTERFACE_H
|
#endif // PROPERTIESINTERFACE_H
|
||||||
|
|||||||
@@ -20,14 +20,16 @@
|
|||||||
#include <QGraphicsObject>
|
#include <QGraphicsObject>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "../qetxml.h"
|
||||||
|
|
||||||
TerminalData::TerminalData():
|
TerminalData::TerminalData():
|
||||||
PropertiesInterface()
|
PropertiesInterface("terminaldata")
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminalData::TerminalData(QGraphicsObject *parent):
|
TerminalData::TerminalData(QGraphicsObject *parent):
|
||||||
PropertiesInterface(),
|
PropertiesInterface("terminaldata"),
|
||||||
q(parent)
|
q(parent)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
@@ -59,7 +61,7 @@ void TerminalData::setParent(QGraphicsObject* parent)
|
|||||||
@param settings UNUSED
|
@param settings UNUSED
|
||||||
@param prefix UNUSED
|
@param prefix UNUSED
|
||||||
*/
|
*/
|
||||||
void TerminalData::toSettings(QSettings &settings, const QString prefix) const
|
void TerminalData::toSettings(QSettings &settings, const QString &prefix) const
|
||||||
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(settings)
|
Q_UNUSED(settings)
|
||||||
@@ -74,28 +76,25 @@ void TerminalData::toSettings(QSettings &settings, const QString prefix) const
|
|||||||
@param settings UNUSED
|
@param settings UNUSED
|
||||||
@param prefix UNUSED
|
@param prefix UNUSED
|
||||||
*/
|
*/
|
||||||
void TerminalData::fromSettings(const QSettings &settings, const QString prefix)
|
void TerminalData::fromSettings(QSettings &settings, const QString& prefix)
|
||||||
{
|
{
|
||||||
Q_UNUSED(settings)
|
Q_UNUSED(settings)
|
||||||
Q_UNUSED(prefix)
|
Q_UNUSED(prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief TerminalData::toXml
|
@brief TerminalData::toXmlPriv
|
||||||
Save properties to xml element
|
Save properties to xml element
|
||||||
write the name, number, position and orientation of the terminal
|
write the name, number, position and orientation of the terminal
|
||||||
to xml_element
|
to xml_element
|
||||||
|
|
||||||
@note This method is only called from the PartTerminal
|
@note This method is only called from the PartTerminal
|
||||||
and should never called from the Terminal class
|
and should never called from the Terminal class
|
||||||
@param xml_document
|
@param e: element to store the properties
|
||||||
@return xml_element : DomElement with
|
|
||||||
the name, number, position and orientation of the terminal
|
the name, number, position and orientation of the terminal
|
||||||
*/
|
*/
|
||||||
QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
void TerminalData::toXmlPriv(QDomElement& xml_element) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement("terminal");
|
|
||||||
|
|
||||||
xml_element.setAttribute("x", QString("%1").arg(q->scenePos().x()));
|
xml_element.setAttribute("x", QString("%1").arg(q->scenePos().x()));
|
||||||
xml_element.setAttribute("y", QString("%1").arg(q->scenePos().y()));
|
xml_element.setAttribute("y", QString("%1").arg(q->scenePos().y()));
|
||||||
|
|
||||||
@@ -103,15 +102,13 @@ QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
|||||||
xml_element.setAttribute("name", m_name);
|
xml_element.setAttribute("name", m_name);
|
||||||
|
|
||||||
xml_element.setAttribute("orientation",
|
xml_element.setAttribute("orientation",
|
||||||
Qet::orientationToString(m_orientation));
|
orientationToString(m_orientation));
|
||||||
|
|
||||||
xml_element.setAttribute("type", typeToString(m_type));
|
xml_element.setAttribute("type", typeToString(m_type));
|
||||||
|
|
||||||
return(xml_element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
@brief TerminalData::fromXml
|
@brief TerminalData::fromXmlPriv
|
||||||
load properties to xml element
|
load properties to xml element
|
||||||
|
|
||||||
@note This method is only called from the PartTerminal
|
@note This method is only called from the PartTerminal
|
||||||
@@ -119,44 +116,70 @@ QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
|||||||
@param xml_element
|
@param xml_element
|
||||||
@return true if succeeded / false if the attribute is not real
|
@return true if succeeded / false if the attribute is not real
|
||||||
*/
|
*/
|
||||||
bool TerminalData::fromXml (const QDomElement &xml_element)
|
bool TerminalData::fromXmlPriv(const QDomElement &xml_element)
|
||||||
{
|
{
|
||||||
qreal term_x = 0.0;
|
qreal term_x = 0.0;
|
||||||
qreal term_y = 0.0;
|
qreal term_y = 0.0;
|
||||||
|
|
||||||
// reads the position of the terminal
|
// reads the position of the terminal
|
||||||
// lit la position de la borne
|
// lit la position de la borne
|
||||||
if (!QET::attributeIsAReal(xml_element, "x", &term_x))
|
|
||||||
|
if (QETXML::propertyDouble(xml_element, "x", &term_x))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!QET::attributeIsAReal(xml_element, "y", &term_y))
|
if (QETXML::propertyDouble(xml_element, "y", &term_y))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_pos = QPointF(term_x, term_y);
|
m_pos = QPointF(term_x, term_y);
|
||||||
|
|
||||||
// emit posFromXML(QPointF(term_x, term_y));
|
// emit posFromXML(QPointF(term_x, term_y));
|
||||||
|
|
||||||
QString uuid = xml_element.attribute("uuid");
|
// do not write uuid from this class, because only PartTerminal::fromXml need
|
||||||
// update part and add uuid, which is used in the new version
|
// to write it to xml file. Terminal::fromXml does not need.
|
||||||
// to connect terminals together
|
|
||||||
// if the attribute not exists, means, the element is created with an
|
// if the attribute not exists, means, the element is created with an
|
||||||
// older version of qet. So use the legacy approach
|
// 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");
|
|
||||||
|
//if (QETXML::propertyString(xml_element, "name", &m_name))
|
||||||
|
// return false;
|
||||||
|
QETXML::propertyString(xml_element, "name", &m_name); // some parts do not have a name. Example: affuteuse_250h.qet, Terminal at x="0" y="-20"
|
||||||
|
|
||||||
|
QString o;
|
||||||
|
if (QETXML::propertyString(xml_element, "orientation", &o))
|
||||||
|
return false;
|
||||||
|
|
||||||
// read the orientation of the terminal
|
// read the orientation of the terminal
|
||||||
// lit l'orientation de la borne
|
// lit l'orientation de la borne
|
||||||
m_orientation = Qet::orientationFromString(
|
m_orientation = orientationFromString(o);
|
||||||
xml_element.attribute("orientation"));
|
|
||||||
|
|
||||||
m_type = typeFromString(xml_element.attribute("type"));
|
QString type;
|
||||||
|
if (QETXML::propertyString(xml_element, "type", &type) == QETXML::PropertyFlags::Success)
|
||||||
|
m_type = typeFromString(type);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TerminalData::valideXml(const QDomElement& xml_element) {
|
||||||
|
if (QETXML::propertyDouble(xml_element, "x"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Old projects do not have this property.
|
||||||
|
// if (QETXML::propertyString(xml_element, "type"))
|
||||||
|
// return false;
|
||||||
|
|
||||||
|
|
||||||
|
// legacy elements do not have an uuid
|
||||||
|
// if (QETXML::propertyUuid(xml_element, "uuid"))
|
||||||
|
// return false;
|
||||||
|
|
||||||
|
//if (QETXML::propertyString(xml_element, "name")) // some parts do not have a name. Example: affuteuse_250h.qet, Terminal at x="0" y="-20"
|
||||||
|
// return false;
|
||||||
|
|
||||||
|
if (QETXML::propertyString(xml_element, "orientation"))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TerminalData::typeToString
|
* @brief TerminalData::typeToString
|
||||||
* @param type
|
* @param type
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#define TERMINALDATA_H
|
#define TERMINALDATA_H
|
||||||
|
|
||||||
#include "../qet.h"
|
#include "../qet.h"
|
||||||
#include "propertiesinterface.h"
|
#include "../properties/propertiesinterface.h"
|
||||||
|
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
@@ -53,11 +53,13 @@ class TerminalData : public PropertiesInterface
|
|||||||
|
|
||||||
void setParent(QGraphicsObject* parent);
|
void setParent(QGraphicsObject* parent);
|
||||||
void toSettings(QSettings &settings,
|
void toSettings(QSettings &settings,
|
||||||
const QString prefix = QString()) const override;
|
const QString& prefix = QString()) const override;
|
||||||
void fromSettings(const QSettings &settings,
|
void fromSettings(QSettings &settings,
|
||||||
const QString prefix = QString()) override;
|
const QString& = QString()) override;
|
||||||
QDomElement toXml(QDomDocument &xml_element) const override;
|
void toXmlPriv(QDomElement &xml_element) const override;
|
||||||
bool fromXml(const QDomElement &xml_element) override;
|
bool fromXmlPriv(const QDomElement &xml_element) override;
|
||||||
|
|
||||||
|
static bool valideXml(const QDomElement &xml_element);
|
||||||
|
|
||||||
static QString typeToString(TerminalData::Type type);
|
static QString typeToString(TerminalData::Type type);
|
||||||
static TerminalData::Type typeFromString(const QString &string);
|
static TerminalData::Type typeFromString(const QString &string);
|
||||||
@@ -69,13 +71,13 @@ class TerminalData : public PropertiesInterface
|
|||||||
@brief m_orientation
|
@brief m_orientation
|
||||||
Orientation of the terminal
|
Orientation of the terminal
|
||||||
*/
|
*/
|
||||||
Qet::Orientation m_orientation;
|
Qet::Orientation m_orientation{Qet::Orientation::North};
|
||||||
/**
|
/**
|
||||||
@brief second_point
|
@brief m_second_point
|
||||||
Position of the second point of the terminal
|
Position of the second point of the terminal
|
||||||
in scene coordinates
|
in scene coordinates
|
||||||
*/
|
*/
|
||||||
QPointF m_second_point;
|
QPointF m_second_point{0,0};
|
||||||
/**
|
/**
|
||||||
@brief m_uuid
|
@brief m_uuid
|
||||||
Uuid of the terminal.
|
Uuid of the terminal.
|
||||||
@@ -90,7 +92,7 @@ class TerminalData : public PropertiesInterface
|
|||||||
valid. So if in the loaded document a uuid exists,
|
valid. So if in the loaded document a uuid exists,
|
||||||
use this one and don't create a new one.
|
use this one and don't create a new one.
|
||||||
*/
|
*/
|
||||||
QUuid m_uuid;
|
QUuid m_uuid; // default is an invalid uuid.
|
||||||
/**
|
/**
|
||||||
@brief m_name
|
@brief m_name
|
||||||
Name of the element.
|
Name of the element.
|
||||||
@@ -108,10 +110,8 @@ class TerminalData : public PropertiesInterface
|
|||||||
It is used to store the initial position so that
|
It is used to store the initial position so that
|
||||||
PartTerminal and Terminal have access to it.
|
PartTerminal and Terminal have access to it.
|
||||||
*/
|
*/
|
||||||
QPointF m_pos;
|
QPointF m_pos{0,0};
|
||||||
|
|
||||||
TerminalData::Type m_type = TerminalData::Generic;
|
TerminalData::Type m_type = TerminalData::Generic;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGraphicsObject* q{nullptr};
|
QGraphicsObject* q{nullptr};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,20 +22,15 @@
|
|||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
|
#include "../qetxml.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief XRefProperties::XRefProperties
|
@brief XRefProperties::XRefProperties
|
||||||
Default Constructor
|
Default Constructor
|
||||||
*/
|
*/
|
||||||
XRefProperties::XRefProperties()
|
XRefProperties::XRefProperties()
|
||||||
{
|
{
|
||||||
m_show_power_ctc = true;
|
setTagName("xref");
|
||||||
m_display = Cross;
|
|
||||||
m_snap_to = Bottom;
|
|
||||||
m_prefix_keys << "power" << "delay" << "switch";
|
|
||||||
m_master_label = "%f-%l%c";
|
|
||||||
m_slave_label = "(%f-%l%c)";
|
|
||||||
m_offset = 0;
|
|
||||||
m_xref_pos = Qt::AlignBottom;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,7 +40,7 @@ XRefProperties::XRefProperties()
|
|||||||
@param prefix: prefix before properties name
|
@param prefix: prefix before properties name
|
||||||
*/
|
*/
|
||||||
void XRefProperties::toSettings(QSettings &settings,
|
void XRefProperties::toSettings(QSettings &settings,
|
||||||
const QString prefix) const
|
const QString &prefix) const
|
||||||
{
|
{
|
||||||
settings.setValue(prefix + "showpowerctc", m_show_power_ctc);
|
settings.setValue(prefix + "showpowerctc", m_show_power_ctc);
|
||||||
QString display = m_display == Cross? "cross" : "contacts";
|
QString display = m_display == Cross? "cross" : "contacts";
|
||||||
@@ -74,8 +69,8 @@ void XRefProperties::toSettings(QSettings &settings,
|
|||||||
@param settings: QSettings to use
|
@param settings: QSettings to use
|
||||||
@param prefix: prefix before properties name
|
@param prefix: prefix before properties name
|
||||||
*/
|
*/
|
||||||
void XRefProperties::fromSettings(const QSettings &settings,
|
void XRefProperties::fromSettings(QSettings &settings,
|
||||||
const QString prefix)
|
const QString &prefix)
|
||||||
{
|
{
|
||||||
m_show_power_ctc = settings.value(prefix + "showpowerctc", true).toBool();
|
m_show_power_ctc = settings.value(prefix + "showpowerctc", true).toBool();
|
||||||
QString display = settings.value(prefix + "displayhas", "cross").toString();
|
QString display = settings.value(prefix + "displayhas", "cross").toString();
|
||||||
@@ -100,10 +95,8 @@ void XRefProperties::fromSettings(const QSettings &settings,
|
|||||||
@param xml_document : QDomElement to use for saving
|
@param xml_document : QDomElement to use for saving
|
||||||
@return QDomElement
|
@return QDomElement
|
||||||
*/
|
*/
|
||||||
QDomElement XRefProperties::toXml(QDomDocument &xml_document) const
|
void XRefProperties::toXmlPriv(QDomElement& xml_element) const
|
||||||
{
|
{
|
||||||
|
|
||||||
QDomElement xml_element = xml_document.createElement("xref");
|
|
||||||
xml_element.setAttribute("type", m_key);
|
xml_element.setAttribute("type", m_key);
|
||||||
|
|
||||||
xml_element.setAttribute("showpowerctc", m_show_power_ctc? "true" : "false");
|
xml_element.setAttribute("showpowerctc", m_show_power_ctc? "true" : "false");
|
||||||
@@ -126,36 +119,42 @@ QDomElement XRefProperties::toXml(QDomDocument &xml_document) const
|
|||||||
foreach (QString key, m_prefix.keys()) {
|
foreach (QString key, m_prefix.keys()) {
|
||||||
xml_element.setAttribute(key + "prefix", m_prefix.value(key));
|
xml_element.setAttribute(key + "prefix", m_prefix.value(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
return xml_element;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** RETURNS True
|
||||||
@brief XRefProperties::fromXml
|
@brief XRefProperties::fromXmlPriv
|
||||||
Load from xml
|
Load from xml
|
||||||
@param xml_element: QDomElement to use for load
|
@param xml_element: QDomElement to use for load
|
||||||
*/
|
*/
|
||||||
bool XRefProperties::fromXml(const QDomElement &xml_element) {
|
bool XRefProperties::fromXmlPriv(const QDomElement &xml_element) {
|
||||||
m_show_power_ctc = xml_element.attribute("showpowerctc") == "true";
|
|
||||||
QString display = xml_element.attribute("displayhas", "cross");
|
if (QETXML::propertyBool(xml_element, "showpowerctc", &m_show_power_ctc))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QString display;
|
||||||
|
if (QETXML::propertyString(xml_element, "displayhas", &display) != QETXML::PropertyFlags::NotFound) {
|
||||||
display == "cross"? m_display = Cross : m_display = Contacts;
|
display == "cross"? m_display = Cross : m_display = Contacts;
|
||||||
QString snap = xml_element.attribute("snapto", "label");
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString snap;
|
||||||
|
if (QETXML::propertyString(xml_element, "snapto", &snap) != QETXML::PropertyFlags::NotFound) {
|
||||||
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
|
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
|
||||||
|
}
|
||||||
|
|
||||||
QString xrefpos = xml_element.attribute("xrefpos","Left");
|
QString xrefpos;
|
||||||
|
if (QETXML::propertyString(xml_element, "xrefpos", &xrefpos) != QETXML::PropertyFlags::NotFound) {
|
||||||
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
|
m_xref_pos = Qt::AlignmentFlag(var.keyToValue(xrefpos.toStdString().data()));
|
||||||
if(xml_element.hasAttribute("xrefpos"))
|
}
|
||||||
m_xref_pos = Qt::AlignmentFlag(var.keyToValue(xml_element.attribute("xrefpos").toStdString().data()));
|
// TODO: why it compiles without this true??
|
||||||
else
|
QETXML::propertyInteger(xml_element, "offset", &m_offset);
|
||||||
m_xref_pos = Qt::AlignBottom;
|
QETXML::propertyString(xml_element, "master_label", &m_master_label);
|
||||||
|
QETXML::propertyString(xml_element, "slave_label", &m_slave_label);
|
||||||
m_offset = xml_element.attribute("offset", "0").toInt();
|
QString value;
|
||||||
m_master_label = xml_element.attribute("master_label", "%f-%l%c");
|
|
||||||
m_slave_label = xml_element.attribute("slave_label","(%f-%l%c)");
|
|
||||||
foreach (QString key, m_prefix_keys) {
|
foreach (QString key, m_prefix_keys) {
|
||||||
m_prefix.insert(key, xml_element.attribute(key + "prefix"));
|
if (!QETXML::propertyString(xml_element, key + "prefix", &value))
|
||||||
|
m_prefix.insert(key, value);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,11 @@ class XRefProperties : public PropertiesInterface
|
|||||||
Label
|
Label
|
||||||
};
|
};
|
||||||
|
|
||||||
void toSettings (QSettings &settings,
|
void toSettings (QSettings &settings, const QString& = QString()) const override;
|
||||||
const QString = QString()) const override;
|
void fromSettings (QSettings &settings,
|
||||||
void fromSettings (const QSettings &settings,
|
const QString& = QString()) override;
|
||||||
const QString = QString()) override;
|
void toXmlPriv(QDomElement&xml_element) const override;
|
||||||
QDomElement toXml (QDomDocument &xml_document) const override;
|
bool fromXmlPriv(const QDomElement &xml_element) override;
|
||||||
bool fromXml(const QDomElement &xml_element) override;
|
|
||||||
|
|
||||||
static QHash<QString, XRefProperties> defaultProperties();
|
static QHash<QString, XRefProperties> defaultProperties();
|
||||||
|
|
||||||
@@ -80,15 +79,15 @@ class XRefProperties : public PropertiesInterface
|
|||||||
void setKey(QString& key) {m_key = key;}
|
void setKey(QString& key) {m_key = key;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_show_power_ctc;
|
bool m_show_power_ctc{true};
|
||||||
DisplayHas m_display;
|
DisplayHas m_display{Cross};
|
||||||
SnapTo m_snap_to;
|
SnapTo m_snap_to{Bottom};
|
||||||
Qt::AlignmentFlag m_xref_pos;
|
Qt::AlignmentFlag m_xref_pos{Qt::AlignBottom};
|
||||||
QHash <QString, QString> m_prefix;
|
QHash <QString, QString> m_prefix;
|
||||||
QStringList m_prefix_keys;
|
QStringList m_prefix_keys{"power","delay","switch"};
|
||||||
QString m_master_label;
|
QString m_master_label{"%f-%l%c"};
|
||||||
QString m_slave_label;
|
QString m_slave_label{"(%f-%l%c)"};
|
||||||
int m_offset;
|
int m_offset{0};
|
||||||
QString m_key;
|
QString m_key;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -34,31 +34,6 @@
|
|||||||
retourne.
|
retourne.
|
||||||
@param s Chaine de caractere cense representer une orientation
|
@param s Chaine de caractere cense representer une orientation
|
||||||
@return l'orientation designee par la chaine de caractere
|
@return l'orientation designee par la chaine de caractere
|
||||||
*/
|
|
||||||
Qet::Orientation Qet::orientationFromString(const QString &s) {
|
|
||||||
QChar c = s[0];
|
|
||||||
if (c == 'e') return(Qet::East);
|
|
||||||
else if (c == 's') return(Qet::South);
|
|
||||||
else if (c == 'w') return (Qet::West);
|
|
||||||
else return(Qet::North);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param o une orientation
|
|
||||||
@return une chaine de caractere representant l'orientation
|
|
||||||
*/
|
|
||||||
QString Qet::orientationToString(Qet::Orientation o) {
|
|
||||||
QString ret;
|
|
||||||
switch(o) {
|
|
||||||
case Qet::North: ret = "n"; break;
|
|
||||||
case Qet::East : ret = "e"; break;
|
|
||||||
case Qet::South: ret = "s"; break;
|
|
||||||
case Qet::West : ret = "w"; break;
|
|
||||||
}
|
|
||||||
return(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Indique si deux orientations de Borne sont sur le meme axe (Vertical / Horizontal).
|
Indique si deux orientations de Borne sont sur le meme axe (Vertical / Horizontal).
|
||||||
@param a La premiere orientation de Borne
|
@param a La premiere orientation de Borne
|
||||||
@param b La seconde orientation de Borne
|
@param b La seconde orientation de Borne
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
#include "element.h"
|
#include "element.h"
|
||||||
#include "../QetGraphicsItemModeler/qetgraphicshandleritem.h"
|
#include "../QetGraphicsItemModeler/qetgraphicshandleritem.h"
|
||||||
|
|
||||||
|
#include "../qetxml.h"
|
||||||
|
|
||||||
#include <QMultiHash>
|
#include <QMultiHash>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
@@ -78,15 +80,9 @@ class ConductorXmlRetroCompatibility
|
|||||||
*/
|
*/
|
||||||
Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
||||||
terminal1(p1),
|
terminal1(p1),
|
||||||
terminal2(p2),
|
terminal2(p2)
|
||||||
m_mouse_over(false),
|
|
||||||
m_text_item(nullptr),
|
|
||||||
segments(nullptr),
|
|
||||||
m_moving_segment(false),
|
|
||||||
modified_path(false),
|
|
||||||
has_to_save_profile(false),
|
|
||||||
must_highlight_(Conductor::None)
|
|
||||||
{
|
{
|
||||||
|
setTagName("conductor");
|
||||||
//set Zvalue at 11 to be upper than the DiagramImageItem and element
|
//set Zvalue at 11 to be upper than the DiagramImageItem and element
|
||||||
setZValue(11);
|
setZValue(11);
|
||||||
m_previous_z_value = zValue();
|
m_previous_z_value = zValue();
|
||||||
@@ -587,36 +583,16 @@ ConductorTextItem *Conductor::textItem() const
|
|||||||
@return true si l'element XML represente bien un Conducteur ; false sinon
|
@return true si l'element XML represente bien un Conducteur ; false sinon
|
||||||
*/
|
*/
|
||||||
bool Conductor::valideXml(QDomElement &e){
|
bool Conductor::valideXml(QDomElement &e){
|
||||||
// verifie le nom du tag
|
|
||||||
if (e.tagName() != "conductor") return(false);
|
|
||||||
|
|
||||||
// verifie la presence des attributs minimaux
|
// // TODO: seems to short! (see fromXML)
|
||||||
if (!e.hasAttribute("terminal1")) return(false);
|
// if (QETXML::propertyDouble(e, "x") ||
|
||||||
if (!e.hasAttribute("terminal2")) return(false);
|
// QETXML::propertyDouble(e, "y"))
|
||||||
|
// return false;
|
||||||
|
|
||||||
bool conv_ok;
|
// if (QETXML::propertyBool(e, "freezeLabel"))
|
||||||
// parse l'abscisse
|
// return false;
|
||||||
if (e.hasAttribute("element1")) {
|
|
||||||
if (QUuid(e.attribute("element1")).isNull())
|
|
||||||
return false;
|
|
||||||
if (QUuid(e.attribute("terminal1")).isNull())
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
e.attribute("terminal1").toInt(&conv_ok);
|
|
||||||
if (!conv_ok) return(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse l'ordonnee
|
return true;
|
||||||
if (e.hasAttribute("element2")) {
|
|
||||||
if (QUuid(e.attribute("element2")).isNull())
|
|
||||||
return false;
|
|
||||||
if (QUuid(e.attribute("terminal2")).isNull())
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
e.attribute("terminal2").toInt(&conv_ok);
|
|
||||||
if (!conv_ok) return(false);
|
|
||||||
}
|
|
||||||
return(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -989,16 +965,26 @@ void Conductor::pointsToSegments(const QList<QPointF>& points_list) {
|
|||||||
@param dom_element
|
@param dom_element
|
||||||
@return true is loading success else return false
|
@return true is loading success else return false
|
||||||
*/
|
*/
|
||||||
bool Conductor::fromXml(QDomElement &dom_element)
|
bool Conductor::fromXmlPriv(const QDomElement &dom_element)
|
||||||
{
|
{
|
||||||
setPos(dom_element.attribute("x", nullptr).toDouble(),
|
double x=0, y=0;
|
||||||
dom_element.attribute("y", nullptr).toDouble());
|
QETXML::propertyDouble(dom_element, "x", &x);
|
||||||
|
QETXML::propertyDouble(dom_element, "y", &y);
|
||||||
|
setPos(x, y);
|
||||||
|
|
||||||
bool return_ = pathFromXml(dom_element);
|
bool return_ = pathFromXml(dom_element);
|
||||||
|
|
||||||
m_text_item -> fromXml(dom_element);
|
m_text_item -> fromXml(dom_element);
|
||||||
|
|
||||||
|
auto prs = QETXML::findInDomElement(dom_element, ConductorProperties::xmlTagName());
|
||||||
ConductorProperties pr;
|
ConductorProperties pr;
|
||||||
|
if (!prs.isEmpty()) {
|
||||||
|
pr.fromXml(prs.first());
|
||||||
|
} else {
|
||||||
|
// legacy
|
||||||
|
// added in 0.9 remove in later version!
|
||||||
pr.fromXml(dom_element);
|
pr.fromXml(dom_element);
|
||||||
|
}
|
||||||
|
|
||||||
//Load Sequential Values
|
//Load Sequential Values
|
||||||
if (dom_element.hasAttribute("sequ_1") || dom_element.hasAttribute("sequf_1") || dom_element.hasAttribute("seqt_1") || dom_element.hasAttribute("seqtf_1") || dom_element.hasAttribute("seqh_1") || dom_element.hasAttribute("sequf_1"))
|
if (dom_element.hasAttribute("sequ_1") || dom_element.hasAttribute("sequf_1") || dom_element.hasAttribute("seqt_1") || dom_element.hasAttribute("seqtf_1") || dom_element.hasAttribute("seqh_1") || dom_element.hasAttribute("sequf_1"))
|
||||||
@@ -1006,15 +992,15 @@ bool Conductor::fromXml(QDomElement &dom_element)
|
|||||||
else
|
else
|
||||||
m_autoNum_seq.fromXml(dom_element.firstChildElement("sequentialNumbers"));
|
m_autoNum_seq.fromXml(dom_element.firstChildElement("sequentialNumbers"));
|
||||||
|
|
||||||
m_freeze_label = dom_element.attribute("freezeLabel") == "true"? true : false;
|
QETXML::propertyBool(dom_element, "freezeLabel", &m_freeze_label);
|
||||||
|
|
||||||
setProperties(pr);
|
setProperties(pr);
|
||||||
|
|
||||||
return return_;
|
return return_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// does not support legacy method
|
||||||
@brief Conductor::toXml
|
/*!
|
||||||
|
@brief Conductor::toXmlPriv
|
||||||
Exporte les caracteristiques du conducteur sous forme d'une element XML.
|
Exporte les caracteristiques du conducteur sous forme d'une element XML.
|
||||||
@param dom_document :
|
@param dom_document :
|
||||||
Le document XML a utiliser pour creer l'element XML
|
Le document XML a utiliser pour creer l'element XML
|
||||||
@@ -1023,11 +1009,7 @@ bool Conductor::fromXml(QDomElement &dom_element)
|
|||||||
bornes dans le document XML et leur adresse en memoire
|
bornes dans le document XML et leur adresse en memoire
|
||||||
@return Un element XML representant le conducteur
|
@return Un element XML representant le conducteur
|
||||||
*/
|
*/
|
||||||
QDomElement Conductor::toXml(QDomDocument &dom_document,
|
void Conductor::toXmlPriv(QDomElement& dom_element) const {
|
||||||
QHash<Terminal *,
|
|
||||||
int> &table_adr_id) const
|
|
||||||
{
|
|
||||||
QDomElement dom_element = dom_document.createElement("conductor");
|
|
||||||
|
|
||||||
dom_element.setAttribute("x", QString::number(pos().x()));
|
dom_element.setAttribute("x", QString::number(pos().x()));
|
||||||
dom_element.setAttribute("y", QString::number(pos().y()));
|
dom_element.setAttribute("y", QString::number(pos().y()));
|
||||||
@@ -1035,7 +1017,7 @@ QDomElement Conductor::toXml(QDomDocument &dom_document,
|
|||||||
// Terminal is uniquely identified by the uuid of the terminal and the element
|
// Terminal is uniquely identified by the uuid of the terminal and the element
|
||||||
if (terminal1->uuid().isNull()) {
|
if (terminal1->uuid().isNull()) {
|
||||||
// legacy method to identify the terminal
|
// legacy method to identify the terminal
|
||||||
dom_element.setAttribute("terminal1", table_adr_id.value(terminal1)); // for backward compability
|
dom_element.setAttribute("terminal1", terminal1->ID()); // for backward compability
|
||||||
} else {
|
} else {
|
||||||
dom_element.setAttribute("element1", terminal1->parentElement()->uuid().toString());
|
dom_element.setAttribute("element1", terminal1->parentElement()->uuid().toString());
|
||||||
dom_element.setAttribute("terminal1", terminal1->uuid().toString());
|
dom_element.setAttribute("terminal1", terminal1->uuid().toString());
|
||||||
@@ -1043,7 +1025,7 @@ QDomElement Conductor::toXml(QDomDocument &dom_document,
|
|||||||
|
|
||||||
if (terminal2->uuid().isNull()) {
|
if (terminal2->uuid().isNull()) {
|
||||||
// legacy method to identify the terminal
|
// legacy method to identify the terminal
|
||||||
dom_element.setAttribute("terminal2", table_adr_id.value(terminal2)); // for backward compability
|
dom_element.setAttribute("terminal2", terminal2->ID()); // for backward compability
|
||||||
} else {
|
} else {
|
||||||
dom_element.setAttribute("element2", terminal2->parentElement()->uuid().toString());
|
dom_element.setAttribute("element2", terminal2->parentElement()->uuid().toString());
|
||||||
dom_element.setAttribute("terminal2", terminal2->uuid().toString());
|
dom_element.setAttribute("terminal2", terminal2->uuid().toString());
|
||||||
@@ -1058,18 +1040,18 @@ QDomElement Conductor::toXml(QDomDocument &dom_document,
|
|||||||
QDomElement current_segment;
|
QDomElement current_segment;
|
||||||
foreach(ConductorSegment *segment, segmentsList())
|
foreach(ConductorSegment *segment, segmentsList())
|
||||||
{
|
{
|
||||||
current_segment = dom_document.createElement("segment");
|
current_segment = dom_element.ownerDocument().createElement("segment");
|
||||||
current_segment.setAttribute("orientation", segment -> isHorizontal() ? "horizontal" : "vertical");
|
current_segment.setAttribute("orientation", segment -> isHorizontal() ? "horizontal" : "vertical");
|
||||||
current_segment.setAttribute("length", QString("%1").arg(segment -> length()));
|
current_segment.setAttribute("length", QString("%1").arg(segment -> length()));
|
||||||
dom_element.appendChild(current_segment);
|
dom_element.appendChild(current_segment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QDomDocument doc = dom_element.ownerDocument();
|
||||||
QDomElement dom_seq = m_autoNum_seq.toXml(dom_document);
|
QDomElement dom_seq = m_autoNum_seq.toXml(doc);
|
||||||
dom_element.appendChild(dom_seq);
|
dom_element.appendChild(dom_seq);
|
||||||
|
|
||||||
// Export the properties and text
|
// Export the properties and text
|
||||||
m_properties. toXml(dom_element);
|
dom_element.appendChild(m_properties. toXml(doc));
|
||||||
if(m_text_item->wasMovedByUser())
|
if(m_text_item->wasMovedByUser())
|
||||||
{
|
{
|
||||||
dom_element.setAttribute("userx", QString::number(m_text_item->pos().x()));
|
dom_element.setAttribute("userx", QString::number(m_text_item->pos().x()));
|
||||||
@@ -1077,16 +1059,72 @@ QDomElement Conductor::toXml(QDomDocument &dom_document,
|
|||||||
}
|
}
|
||||||
if(m_text_item->wasRotateByUser())
|
if(m_text_item->wasRotateByUser())
|
||||||
dom_element.setAttribute("rotation", QString::number(m_text_item->rotation()));
|
dom_element.setAttribute("rotation", QString::number(m_text_item->rotation()));
|
||||||
|
|
||||||
return(dom_element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Conductor::pathFromXml
|
Exporte les caracteristiques du conducteur sous forme d'une element XML.
|
||||||
Generate the path (of the line) from xml file by checking the segments in the xml
|
@param d Le document XML a utiliser pour creer l'element XML
|
||||||
file
|
@param table_adr_id Hash stockant les correspondances entre les ids des
|
||||||
@param e
|
bornes dans le document XML et leur adresse en memoire
|
||||||
@return true if generate path success else return false
|
@return Un element XML representant le conducteur
|
||||||
|
*/
|
||||||
|
//QDomElement Conductor::toXml(QDomDocument &dom_document, QHash<Terminal *, int> &table_adr_id) const
|
||||||
|
//{
|
||||||
|
// QDomElement dom_element = dom_document.createElement("conductor");
|
||||||
|
|
||||||
|
// dom_element.setAttribute("x", QString::number(pos().x()));
|
||||||
|
// dom_element.setAttribute("y", QString::number(pos().y()));
|
||||||
|
|
||||||
|
// // Terminal is uniquely identified by the uuid of the terminal and the element
|
||||||
|
// if (terminal1->uuid().isNull()) {
|
||||||
|
// // legacy method to identify the terminal
|
||||||
|
// dom_element.setAttribute("terminal1", table_adr_id.value(terminal1)); // for backward compability
|
||||||
|
// } else {
|
||||||
|
// dom_element.setAttribute("element1", terminal1->parentElement()->uuid().toString());
|
||||||
|
// dom_element.setAttribute("terminal1", terminal1->uuid().toString());
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (terminal2->uuid().isNull()) {
|
||||||
|
// // legacy method to identify the terminal
|
||||||
|
// dom_element.setAttribute("terminal2", table_adr_id.value(terminal2)); // for backward compability
|
||||||
|
// } else {
|
||||||
|
// dom_element.setAttribute("element2", terminal2->parentElement()->uuid().toString());
|
||||||
|
// dom_element.setAttribute("terminal2", terminal2->uuid().toString());
|
||||||
|
// }
|
||||||
|
// dom_element.setAttribute("freezeLabel", m_freeze_label? "true" : "false");
|
||||||
|
|
||||||
|
// // on n'exporte les segments du conducteur que si ceux-ci ont
|
||||||
|
// // ete modifies par l'utilisateur
|
||||||
|
// if (modified_path)
|
||||||
|
// {
|
||||||
|
// // parcours et export des segments
|
||||||
|
// QDomElement current_segment;
|
||||||
|
// foreach(ConductorSegment *segment, segmentsList())
|
||||||
|
// {
|
||||||
|
// current_segment = dom_document.createElement("segment");
|
||||||
|
// current_segment.setAttribute("orientation", segment -> isHorizontal() ? "horizontal" : "vertical");
|
||||||
|
// current_segment.setAttribute("length", QString("%1").arg(segment -> length()));
|
||||||
|
// dom_element.appendChild(current_segment);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// QDomElement dom_seq = m_autoNum_seq.toXml(dom_document);
|
||||||
|
// dom_element.appendChild(dom_seq);
|
||||||
|
|
||||||
|
// // Export the properties and text
|
||||||
|
// m_properties.toXml(dom_document);
|
||||||
|
// if(m_text_item->wasMovedByUser())
|
||||||
|
// {
|
||||||
|
// dom_element.setAttribute("userx", QString::number(m_text_item->pos().x()));
|
||||||
|
// dom_element.setAttribute("usery", QString::number(m_text_item->pos().y()));
|
||||||
|
// }
|
||||||
|
// if(m_text_item->wasRotateByUser())
|
||||||
|
// dom_element.setAttribute("rotation", QString::number(m_text_item->rotation()));
|
||||||
|
|
||||||
|
// return(dom_element);
|
||||||
|
//}
|
||||||
|
|
||||||
|
/**
|
||||||
*/
|
*/
|
||||||
bool Conductor::pathFromXml(const QDomElement &e) {
|
bool Conductor::pathFromXml(const QDomElement &e) {
|
||||||
// parcourt les elements XML "segment" et en extrait deux listes de longueurs
|
// parcourt les elements XML "segment" et en extrait deux listes de longueurs
|
||||||
@@ -1098,14 +1136,21 @@ bool Conductor::pathFromXml(const QDomElement &e) {
|
|||||||
if (current_segment.isNull() || current_segment.tagName() != "segment") continue;
|
if (current_segment.isNull() || current_segment.tagName() != "segment") continue;
|
||||||
|
|
||||||
// le segment doit avoir une longueur
|
// le segment doit avoir une longueur
|
||||||
if (!current_segment.hasAttribute("length")) continue;
|
qreal segment_length;
|
||||||
|
if (QETXML::propertyDouble(current_segment, "length", & segment_length))
|
||||||
|
continue;
|
||||||
|
|
||||||
// cette longueur doit etre un reel
|
bool isHorizontal = false;
|
||||||
bool ok;
|
QString orientation;
|
||||||
qreal segment_length = current_segment.attribute("length").toDouble(&ok);
|
if (QETXML::propertyString(current_segment, "orientation", &orientation) == QETXML::PropertyFlags::Success) {
|
||||||
if (!ok) continue;
|
if (orientation == "horizontal")
|
||||||
|
isHorizontal = true;
|
||||||
|
} else {
|
||||||
|
qDebug() << "PathFromXML failed";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (current_segment.attribute("orientation") == "horizontal") {
|
if (isHorizontal) {
|
||||||
segments_x << segment_length;
|
segments_x << segment_length;
|
||||||
segments_y << 0.0;
|
segments_y << 0.0;
|
||||||
} else {
|
} else {
|
||||||
@@ -1356,7 +1401,7 @@ void Conductor::calculateTextItemPosition()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Adjust the position of text if his rotation
|
//Adjust the position of text if his rotation
|
||||||
//is 0° or 270°, to be exactly centered to the conductor
|
//is 0?? or 270??, to be exactly centered to the conductor
|
||||||
if (m_text_item -> rotation() == 0)
|
if (m_text_item -> rotation() == 0)
|
||||||
{
|
{
|
||||||
text_pos.rx() -= m_text_item -> boundingRect().width()/2;
|
text_pos.rx() -= m_text_item -> boundingRect().width()/2;
|
||||||
@@ -1633,12 +1678,12 @@ void Conductor::displayedTextChanged()
|
|||||||
new_value.setValue(new_properties);
|
new_value.setValue(new_properties);
|
||||||
|
|
||||||
|
|
||||||
QUndoCommand *undo = new QUndoCommand(tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
QUndoCommand *undo = new QUndoCommand(tr("Modifier les propri??t??s d'un conducteur", "undo caption"));
|
||||||
new QPropertyUndoCommand(this, "properties", old_value, new_value, undo);
|
new QPropertyUndoCommand(this, "properties", old_value, new_value, undo);
|
||||||
|
|
||||||
if (!relatedPotentialConductors().isEmpty())
|
if (!relatedPotentialConductors().isEmpty())
|
||||||
{
|
{
|
||||||
undo->setText(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
|
undo->setText(tr("Modifier les propri??t??s de plusieurs conducteurs", "undo caption"));
|
||||||
|
|
||||||
foreach (Conductor *potential_conductor, relatedPotentialConductors())
|
foreach (Conductor *potential_conductor, relatedPotentialConductors())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#include "../autoNum/assignvariables.h"
|
#include "../autoNum/assignvariables.h"
|
||||||
#include "../conductorproperties.h"
|
#include "../conductorproperties.h"
|
||||||
|
|
||||||
|
#include "../conductorproperties.h"
|
||||||
|
#include "../properties/propertiesinterface.h"
|
||||||
#include <QGraphicsPathItem>
|
#include <QGraphicsPathItem>
|
||||||
|
|
||||||
class ConductorProfile;
|
class ConductorProfile;
|
||||||
@@ -39,7 +41,7 @@ typedef QHash<Qt::Corner, ConductorProfile> ConductorProfilesGroup;
|
|||||||
This class represents a conductor, i.e. a wire between two element
|
This class represents a conductor, i.e. a wire between two element
|
||||||
terminals.
|
terminals.
|
||||||
*/
|
*/
|
||||||
class Conductor : public QGraphicsObject
|
class Conductor : public QGraphicsObject, public PropertiesInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -100,11 +102,10 @@ class Conductor : public QGraphicsObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static bool valideXml (QDomElement &);
|
static bool valideXml (QDomElement &);
|
||||||
bool fromXml (QDomElement &);
|
bool fromXmlPriv(const QDomElement &) override;
|
||||||
QDomElement toXml (
|
void toXmlPriv(QDomElement&dom_element) const override;
|
||||||
QDomDocument &,
|
void toSettings(QSettings &, const QString & = QString()) const override {}
|
||||||
QHash<Terminal *,
|
void fromSettings(QSettings &, const QString & = QString()) override {}
|
||||||
int> &) const;
|
|
||||||
private:
|
private:
|
||||||
bool pathFromXml(const QDomElement &);
|
bool pathFromXml(const QDomElement &);
|
||||||
|
|
||||||
@@ -181,28 +182,28 @@ class Conductor : public QGraphicsObject
|
|||||||
|
|
||||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||||
int m_vector_index = -1;
|
int m_vector_index = -1;
|
||||||
bool m_mouse_over;
|
bool m_mouse_over{false};
|
||||||
/// Functional properties
|
/// Functional properties
|
||||||
ConductorProperties m_properties;
|
ConductorProperties m_properties;
|
||||||
/// Text input for non simple, non-singleline conductors
|
/// Text input for non simple, non-singleline conductors
|
||||||
ConductorTextItem *m_text_item;
|
ConductorTextItem *m_text_item{nullptr};
|
||||||
/// Segments composing the conductor
|
/// Segments composing the conductor
|
||||||
ConductorSegment *segments;
|
ConductorSegment *segments{nullptr};
|
||||||
/// Attributs related to mouse interaction
|
/// Attributs related to mouse interaction
|
||||||
bool m_moving_segment;
|
bool m_moving_segment{false};
|
||||||
int moved_point;
|
int moved_point;
|
||||||
qreal m_previous_z_value;
|
qreal m_previous_z_value;
|
||||||
ConductorSegment *m_moved_segment;
|
ConductorSegment *m_moved_segment;
|
||||||
QPointF before_mov_text_pos_;
|
QPointF before_mov_text_pos_;
|
||||||
/// Whether the conductor was manually modified by users
|
/// Whether the conductor was manually modified by users
|
||||||
bool modified_path;
|
bool modified_path{false};
|
||||||
/// Whether the current profile should be saved as soon as possible
|
/// Whether the current profile should be saved as soon as possible
|
||||||
bool has_to_save_profile;
|
bool has_to_save_profile{false};
|
||||||
/// conductor profile: "photography" of what the conductor is supposed to look
|
/// conductor profile: "photography" of what the conductor is supposed to look
|
||||||
/// like - there is one profile per kind of traject
|
/// like - there is one profile per kind of traject
|
||||||
ConductorProfilesGroup conductor_profiles;
|
ConductorProfilesGroup conductor_profiles;
|
||||||
/// Define whether and how the conductor should be highlighted
|
/// Define whether and how the conductor should be highlighted
|
||||||
Highlight must_highlight_;
|
Highlight must_highlight_{Conductor::None};
|
||||||
bool m_valid;
|
bool m_valid;
|
||||||
bool m_freeze_label = false;
|
bool m_freeze_label = false;
|
||||||
|
|
||||||
|
|||||||
@@ -21,15 +21,15 @@
|
|||||||
#include "../diagramcommands.h"
|
#include "../diagramcommands.h"
|
||||||
#include "../qetgraphicsitem/conductor.h"
|
#include "../qetgraphicsitem/conductor.h"
|
||||||
|
|
||||||
|
#include "../qetxml.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@param parent_conductor Conducteur auquel ce texte est rattache
|
@param parent_conductor Conducteur auquel ce texte est rattache
|
||||||
*/
|
*/
|
||||||
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
|
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
|
||||||
DiagramTextItem(parent_conductor),
|
DiagramTextItem(parent_conductor),
|
||||||
parent_conductor_(parent_conductor),
|
parent_conductor_(parent_conductor)
|
||||||
moved_by_user_(false),
|
|
||||||
rotate_by_user_(false)
|
|
||||||
{
|
{
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
@@ -69,13 +69,17 @@ Conductor *ConductorTextItem::parentConductor() const
|
|||||||
@param e
|
@param e
|
||||||
*/
|
*/
|
||||||
void ConductorTextItem::fromXml(const QDomElement &e) {
|
void ConductorTextItem::fromXml(const QDomElement &e) {
|
||||||
if (e.hasAttribute("userx")) {
|
|
||||||
setPos(e.attribute("userx").toDouble(),
|
double userx=0, usery=0;
|
||||||
e.attribute("usery").toDouble());
|
if (QETXML::propertyDouble(e, "userx", &userx) == QETXML::PropertyFlags::Success &&
|
||||||
|
QETXML::propertyDouble(e, "usery", &usery) == QETXML::PropertyFlags::Success) {
|
||||||
|
setPos(userx, usery);
|
||||||
moved_by_user_ = true;
|
moved_by_user_ = true;
|
||||||
}
|
}
|
||||||
if (e.hasAttribute("rotation")) {
|
|
||||||
setRotation(e.attribute("rotation").toDouble());
|
double rotation;
|
||||||
|
if (QETXML::propertyDouble(e, "rotation", &rotation) == QETXML::PropertyFlags::Success) {
|
||||||
|
setRotation(rotation);
|
||||||
rotate_by_user_ = true;
|
rotate_by_user_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ class ConductorTextItem : public DiagramTextItem
|
|||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
Conductor *parent_conductor_;
|
Conductor *parent_conductor_;
|
||||||
bool moved_by_user_;
|
bool moved_by_user_{false};
|
||||||
bool rotate_by_user_;
|
bool rotate_by_user_{false};
|
||||||
QPointF before_mov_pos_;
|
QPointF before_mov_pos_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ void DynamicElementTextItem::fromXml(const QDomElement &dom_elmt)
|
|||||||
setColor(QColor(dom_color.text()));
|
setColor(QColor(dom_color.text()));
|
||||||
|
|
||||||
//Force the update of the displayed text
|
//Force the update of the displayed text
|
||||||
setTextFrom(m_text_from);
|
setTextFrom(m_text_from); // TODO: does not update because there is a retrun inside if the textfrom argument is the same as m_text_from
|
||||||
|
|
||||||
QGraphicsTextItem::setPos(dom_elmt.attribute("x", QString::number(0)).toDouble(),
|
QGraphicsTextItem::setPos(dom_elmt.attribute("x", QString::number(0)).toDouble(),
|
||||||
dom_elmt.attribute("y", QString::number(0)).toDouble());
|
dom_elmt.attribute("y", QString::number(0)).toDouble());
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
|||||||
DynamicElementTextItem(const DynamicElementTextItem &);
|
DynamicElementTextItem(const DynamicElementTextItem &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QDomElement toXml(QDomDocument &dom_doc) const override;
|
QDomElement toXml(QDomDocument&) const override;
|
||||||
void fromXml(const QDomElement &dom_elmt) override;
|
void fromXml(const QDomElement &dom_elmt) override;
|
||||||
|
|
||||||
Element *parentElement() const;
|
Element *parentElement() const;
|
||||||
@@ -160,7 +160,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
|||||||
QList<QMetaObject::Connection>
|
QList<QMetaObject::Connection>
|
||||||
m_formula_connection,
|
m_formula_connection,
|
||||||
m_update_slave_Xref_connection;
|
m_update_slave_Xref_connection;
|
||||||
QColor m_user_color;
|
QColor m_user_color{QColor()};
|
||||||
bool
|
bool
|
||||||
m_frame = false,
|
m_frame = false,
|
||||||
m_first_scene_change = true;
|
m_first_scene_change = true;
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ Element::Element(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int elmt_state;
|
int elmt_state;
|
||||||
buildFromXml(location.xml(), &elmt_state);
|
qDebug() << "\tCollection Path: " << location.collectionPath();
|
||||||
|
buildFromXml(location.xml(), &elmt_state); // build from the collection definition
|
||||||
if (state) {
|
if (state) {
|
||||||
*state = elmt_state;
|
*state = elmt_state;
|
||||||
}
|
}
|
||||||
@@ -401,7 +402,7 @@ void Element::drawHighlight(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Element::buildFromXml
|
@brief Element::buildFromXml
|
||||||
Build this element from an xml description
|
Build this element from an xml description (from the collection)
|
||||||
@param xml_def_elmt
|
@param xml_def_elmt
|
||||||
@param state
|
@param state
|
||||||
Optional pointer which define the status of build
|
Optional pointer which define the status of build
|
||||||
@@ -434,9 +435,9 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
|||||||
if (conv_ok && QET::version.toDouble() < element_version)
|
if (conv_ok && QET::version.toDouble() < element_version)
|
||||||
{
|
{
|
||||||
std::cerr << qPrintable(
|
std::cerr << qPrintable(
|
||||||
QObject::tr("Avertissement : l'élément "
|
QObject::tr("Avertissement : l'??l??ment "
|
||||||
" a été enregistré avec une version"
|
" a ??t?? enregistr?? avec une version"
|
||||||
" ultérieure de QElectroTech.")
|
" ult??rieure de QElectroTech.")
|
||||||
) << std::endl;
|
) << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -518,11 +519,15 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
|||||||
if (qde.isNull())
|
if (qde.isNull())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (parseElement(qde)) {
|
qDebug() << "\t\tElement.cpp:buildFromXml;parseElement: " << qde.tagName();
|
||||||
|
|
||||||
|
if (parseElement(qde)) { // TODO: why lines are not parsed here?
|
||||||
|
qDebug() << "\t\t\tParsing Element success";
|
||||||
++ parsed_elements_count;
|
++ parsed_elements_count;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
qDebug() << "\t\t\tParsing Element no success";
|
||||||
if (state)
|
if (state)
|
||||||
*state = 7;
|
*state = 7;
|
||||||
m_state = QET::GIOK;
|
m_state = QET::GIOK;
|
||||||
@@ -548,14 +553,12 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
|||||||
m_state = QET::GIOK;
|
m_state = QET::GIOK;
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (state)
|
if (state)
|
||||||
*state = 0;
|
*state = 0;
|
||||||
m_state = QET::GIOK;
|
m_state = QET::GIOK;
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Element::parseElement
|
@brief Element::parseElement
|
||||||
@@ -658,13 +661,11 @@ DynamicElementTextItem *Element::parseDynamicText(
|
|||||||
*/
|
*/
|
||||||
Terminal *Element::parseTerminal(const QDomElement &dom_element)
|
Terminal *Element::parseTerminal(const QDomElement &dom_element)
|
||||||
{
|
{
|
||||||
TerminalData* data = new TerminalData();
|
if (!Terminal::valideXml(dom_element))
|
||||||
if (!data->fromXml(dom_element)) {
|
|
||||||
delete data;
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
Terminal *new_terminal = new Terminal(data, this);
|
Terminal *new_terminal = new Terminal(0, 0, Qet::Orientation::North, this); // does not matter which values are typed in here, because they get overwritten by the fromXML() function
|
||||||
|
new_terminal->fromXml(dom_element);
|
||||||
m_terminals << new_terminal;
|
m_terminals << new_terminal;
|
||||||
|
|
||||||
//Sort from top to bottom and left to rigth
|
//Sort from top to bottom and left to rigth
|
||||||
@@ -679,7 +680,7 @@ Terminal *Element::parseTerminal(const QDomElement &dom_element)
|
|||||||
return (a->dockConductor().y() < b->dockConductor().y());
|
return (a->dockConductor().y() < b->dockConductor().y());
|
||||||
});
|
});
|
||||||
|
|
||||||
return(new_terminal);
|
return(new_terminal); // TODO: makes no sense
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -721,15 +722,14 @@ bool Element::valideXml(QDomElement &e) {
|
|||||||
*/
|
*/
|
||||||
bool Element::fromXml(
|
bool Element::fromXml(
|
||||||
QDomElement &e,
|
QDomElement &e,
|
||||||
QHash<int,
|
QHash<int, Terminal *> &table_id_adr)
|
||||||
Terminal *> &table_id_adr)
|
|
||||||
{
|
{
|
||||||
m_state = QET::GILoadingFromXml;
|
m_state = QET::GILoadingFromXml;
|
||||||
/*
|
/*
|
||||||
les bornes vont maintenant etre recensees pour associer leurs id a leur adresse reelle
|
les bornes vont maintenant etre recensees pour associer leurs id a leur adresse reelle
|
||||||
ce recensement servira lors de la mise en place des fils
|
ce recensement servira lors de la mise en place des fils
|
||||||
*/
|
*/
|
||||||
QList<QDomElement> liste_terminals;
|
QList<QDomElement> liste_terminals; // terminals in the element in the diagram
|
||||||
foreach(QDomElement qde,
|
foreach(QDomElement qde,
|
||||||
QET::findInDomElement(e, "terminals", "terminal")) {
|
QET::findInDomElement(e, "terminals", "terminal")) {
|
||||||
if (Terminal::valideXml(qde)) liste_terminals << qde;
|
if (Terminal::valideXml(qde)) liste_terminals << qde;
|
||||||
@@ -737,15 +737,29 @@ bool Element::fromXml(
|
|||||||
|
|
||||||
QHash<int, Terminal *> priv_id_adr;
|
QHash<int, Terminal *> priv_id_adr;
|
||||||
int terminals_non_trouvees = 0;
|
int terminals_non_trouvees = 0;
|
||||||
foreach(QGraphicsItem *qgi, childItems()) {
|
// The added childs from the collection now must match with the terminals from the diagram. Iterate through
|
||||||
|
// all Terminals in the collection and in the diagram to link them together
|
||||||
|
for(QGraphicsItem *qgi: childItems()) { // TODO: Where the Terminals are added as childs?
|
||||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) {
|
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) {
|
||||||
bool terminal_trouvee = false;
|
bool terminal_trouvee = false;
|
||||||
foreach(QDomElement qde, liste_terminals) {
|
for(QDomElement qde: liste_terminals) {
|
||||||
if (p -> fromXml(qde)) {
|
// The position in the collection element definition is the origin position (originPos).
|
||||||
priv_id_adr.insert(
|
// The position in the diagram element definition is the position where the conductor is connected (dock position)
|
||||||
qde.attribute(
|
// Therefore a simple operator overloading is not possible.
|
||||||
"id").toInt(),
|
Terminal diagramTerminal(0,0, Qet::Orientation::East);
|
||||||
p);
|
diagramTerminal.fromXml(qde);
|
||||||
|
QPointF dockPos1 = diagramTerminal.originPos(); // position here is directly the dock_elmt_ position (stored in the diagram)
|
||||||
|
QPointF dockPos2 = p->dockPos();
|
||||||
|
if (qFuzzyCompare(dockPos1.x(), dockPos2.x()) &&
|
||||||
|
qFuzzyCompare(dockPos1.y(), dockPos2.y()) &&
|
||||||
|
p->orientation() == diagramTerminal.orientation()) { // check if the part in the collection is the same as in the diagram stored
|
||||||
|
qDebug() << "Matching Terminal found.";
|
||||||
|
// store id for legacy purpose, because when opening a old project in the collection the terminal does not have an uuid. Therefore the id must be used
|
||||||
|
if (p->uuid().isNull()) {
|
||||||
|
p->setID(qde.attribute("id").toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
priv_id_adr.insert(qde.attribute("id").toInt(), p);
|
||||||
terminal_trouvee = true;
|
terminal_trouvee = true;
|
||||||
// We used to break here, because we did not expect
|
// We used to break here, because we did not expect
|
||||||
// several terminals to share the same position.
|
// several terminals to share the same position.
|
||||||
@@ -758,6 +772,7 @@ bool Element::fromXml(
|
|||||||
|
|
||||||
if (terminals_non_trouvees > 0)
|
if (terminals_non_trouvees > 0)
|
||||||
{
|
{
|
||||||
|
qDebug() << "element.cpp: Element::fromXML; Elements not found: " << terminals_non_trouvees;
|
||||||
m_state = QET::GIOK;
|
m_state = QET::GIOK;
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
@@ -781,9 +796,9 @@ bool Element::fromXml(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//load uuid of connected elements
|
//load uuid of connected elements
|
||||||
QList <QDomElement> uuid_list = QET::findInDomElement(e,
|
QList <QDomElement> uuid_list = QET::findInDomElement(e, "links_uuids", "link_uuid");
|
||||||
"links_uuids",
|
foreach (QDomElement qdo, uuid_list) tmp_uuids_link << qdo.attribute("uuid");
|
||||||
"link_uuid");
|
|
||||||
foreach (QDomElement qdo, uuid_list)
|
foreach (QDomElement qdo, uuid_list)
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||||
tmp_uuids_link << qdo.attribute("uuid");
|
tmp_uuids_link << qdo.attribute("uuid");
|
||||||
@@ -837,7 +852,7 @@ bool Element::fromXml(
|
|||||||
|
|
||||||
//************************//
|
//************************//
|
||||||
//***Dynamic texts item***//
|
//***Dynamic texts item***//
|
||||||
//************************//
|
//************************// read from the diagram section
|
||||||
for (const QDomElement& qde : QET::findInDomElement(
|
for (const QDomElement& qde : QET::findInDomElement(
|
||||||
e,
|
e,
|
||||||
"dynamic_texts",
|
"dynamic_texts",
|
||||||
@@ -892,9 +907,7 @@ bool Element::fromXml(
|
|||||||
\~French L'element XML representant cet element electrique
|
\~French L'element XML representant cet element electrique
|
||||||
*/
|
*/
|
||||||
QDomElement Element::toXml(
|
QDomElement Element::toXml(
|
||||||
QDomDocument &document,
|
QDomDocument &document) const
|
||||||
QHash<Terminal *,
|
|
||||||
int> &table_adr_id) const
|
|
||||||
{
|
{
|
||||||
QDomElement element = document.createElement("element");
|
QDomElement element = document.createElement("element");
|
||||||
|
|
||||||
@@ -921,18 +934,6 @@ QDomElement Element::toXml(
|
|||||||
element.setAttribute("z", QString::number(this->zValue()));
|
element.setAttribute("z", QString::number(this->zValue()));
|
||||||
element.setAttribute("orientation", QString::number(orientation()));
|
element.setAttribute("orientation", QString::number(orientation()));
|
||||||
|
|
||||||
/* get the first id to use for the bounds of this element
|
|
||||||
* recupere le premier id a utiliser pour les bornes de cet element */
|
|
||||||
int id_terminal = 0;
|
|
||||||
if (!table_adr_id.isEmpty()) {
|
|
||||||
// trouve le plus grand id
|
|
||||||
int max_id_t = -1;
|
|
||||||
foreach (int id_t, table_adr_id.values()) {
|
|
||||||
if (id_t > max_id_t) max_id_t = id_t;
|
|
||||||
}
|
|
||||||
id_terminal = max_id_t + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// registration of device terminals
|
// registration of device terminals
|
||||||
// enregistrement des bornes de l'appareil
|
// enregistrement des bornes de l'appareil
|
||||||
QDomElement xml_terminals = document.createElement("terminals");
|
QDomElement xml_terminals = document.createElement("terminals");
|
||||||
@@ -941,8 +942,10 @@ QDomElement Element::toXml(
|
|||||||
foreach(Terminal *t, terminals()) {
|
foreach(Terminal *t, terminals()) {
|
||||||
// alors on enregistre la borne
|
// alors on enregistre la borne
|
||||||
QDomElement terminal = t -> toXml(document);
|
QDomElement terminal = t -> toXml(document);
|
||||||
terminal.setAttribute("id", id_terminal); // for backward compatibility
|
if (t->ID() > 0) {
|
||||||
table_adr_id.insert(t, id_terminal ++);
|
// for backward compatibility
|
||||||
|
terminal.setAttribute("id", t->ID()); // for backward compatibility
|
||||||
|
}
|
||||||
xml_terminals.appendChild(terminal);
|
xml_terminals.appendChild(terminal);
|
||||||
}
|
}
|
||||||
element.appendChild(xml_terminals);
|
element.appendChild(xml_terminals);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2021 The QElectroTech Team
|
Copyright 2006-2021 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ class ElementTextItemGroup;
|
|||||||
/**
|
/**
|
||||||
This is the base class for electrical elements.
|
This is the base class for electrical elements.
|
||||||
*/
|
*/
|
||||||
class Element : public QetGraphicsItem
|
class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
|
||||||
{
|
{
|
||||||
friend class DiagramEventAddElement;
|
friend class DiagramEventAddElement;
|
||||||
|
|
||||||
@@ -140,14 +140,8 @@ class Element : public QetGraphicsItem
|
|||||||
QPoint hotspot() const;
|
QPoint hotspot() const;
|
||||||
void editProperty() override;
|
void editProperty() override;
|
||||||
static bool valideXml(QDomElement &);
|
static bool valideXml(QDomElement &);
|
||||||
virtual bool fromXml(
|
virtual bool fromXml(QDomElement &, QHash<int, Terminal *> &);
|
||||||
QDomElement &,
|
virtual QDomElement toXml(QDomDocument &) const;
|
||||||
QHash<int,
|
|
||||||
Terminal *> &);
|
|
||||||
virtual QDomElement toXml(
|
|
||||||
QDomDocument &,
|
|
||||||
QHash<Terminal *,
|
|
||||||
int> &) const;
|
|
||||||
QUuid uuid() const;
|
QUuid uuid() const;
|
||||||
int orientation() const;
|
int orientation() const;
|
||||||
|
|
||||||
|
|||||||
@@ -438,6 +438,7 @@ QDomElement ElementTextItemGroup::toXml(QDomDocument &dom_document) const
|
|||||||
return dom_element;
|
return dom_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TOOD: inherit from propertiesinterface
|
||||||
/**
|
/**
|
||||||
@brief ElementTextItemGroup::fromXml
|
@brief ElementTextItemGroup::fromXml
|
||||||
Import data of this group from xml
|
Import data of this group from xml
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class CrossRefItem;
|
|||||||
This class represent a group of element text
|
This class represent a group of element text
|
||||||
Texts in the group can be aligned left / center /right
|
Texts in the group can be aligned left / center /right
|
||||||
*/
|
*/
|
||||||
class ElementTextItemGroup : public QObject, public QGraphicsItemGroup
|
class ElementTextItemGroup : public QObject, public QGraphicsItemGroup // TODO: derive from PropertiesInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup
|
|||||||
m_hold_to_bottom_of_page = false,
|
m_hold_to_bottom_of_page = false,
|
||||||
m_block_alignment_update = false,
|
m_block_alignment_update = false,
|
||||||
m_frame = false;
|
m_frame = false;
|
||||||
QPointF m_initial_position;
|
QPointF m_initial_position{QPointF(0,0)};
|
||||||
int m_vertical_adjustment = 0;
|
int m_vertical_adjustment = 0;
|
||||||
CrossRefItem *m_Xref_item = nullptr;
|
CrossRefItem *m_Xref_item = nullptr;
|
||||||
Element *m_parent_element = nullptr;
|
Element *m_parent_element = nullptr;
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ IndependentTextItem::~IndependentTextItem()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: inherit from PropertiesInterface
|
||||||
/**
|
/**
|
||||||
Permet de lire le texte a mettre dans le champ a partir d'un element XML.
|
Permet de lire le texte a mettre dans le champ a partir d'un element XML.
|
||||||
Cette methode se base sur la position du champ pour assigner ou non la
|
Cette methode se base sur la position du champ pour assigner ou non la
|
||||||
|
|||||||
@@ -25,10 +25,7 @@
|
|||||||
@param parent : Parent Item
|
@param parent : Parent Item
|
||||||
*/
|
*/
|
||||||
QetGraphicsItem::QetGraphicsItem(QGraphicsItem *parent):
|
QetGraphicsItem::QetGraphicsItem(QGraphicsItem *parent):
|
||||||
QGraphicsObject(parent),
|
QGraphicsObject(parent)
|
||||||
is_movable_(true),
|
|
||||||
m_first_move(true),
|
|
||||||
snap_to_grid_(true)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QetGraphicsItem::~QetGraphicsItem()
|
QetGraphicsItem::~QetGraphicsItem()
|
||||||
|
|||||||
@@ -56,10 +56,10 @@ class QetGraphicsItem : public QGraphicsObject
|
|||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool is_movable_;
|
bool is_movable_{true};
|
||||||
bool m_first_move;
|
bool m_first_move{true};
|
||||||
bool snap_to_grid_;
|
bool snap_to_grid_{true};
|
||||||
QPointF m_mouse_to_origin_movement;
|
QPointF m_mouse_to_origin_movement{QPointF(0,0)};
|
||||||
QET::GraphicsItemState m_state = QET:: GIOK;
|
QET::GraphicsItemState m_state = QET:: GIOK;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -663,7 +663,7 @@ void QetShapeItem::insertPoint()
|
|||||||
if(new_polygon != m_polygon)
|
if(new_polygon != m_polygon)
|
||||||
{
|
{
|
||||||
//Wrap the undo for avoid to merge the undo commands when user add several points.
|
//Wrap the undo for avoid to merge the undo commands when user add several points.
|
||||||
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point à un polygone"));
|
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point ?? un polygone"));
|
||||||
new QPropertyUndoCommand(this, "polygon", m_polygon, new_polygon, undo);
|
new QPropertyUndoCommand(this, "polygon", m_polygon, new_polygon, undo);
|
||||||
diagram()->undoStack().push(undo);
|
diagram()->undoStack().push(undo);
|
||||||
}
|
}
|
||||||
@@ -836,6 +836,7 @@ void QetShapeItem::handlerMouseReleaseEvent()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: inherit from Propertiesinterface!
|
||||||
/**
|
/**
|
||||||
@brief QetShapeItem::fromXml
|
@brief QetShapeItem::fromXml
|
||||||
Build this item from the xml description
|
Build this item from the xml description
|
||||||
@@ -997,7 +998,7 @@ QString QetShapeItem::name() const
|
|||||||
switch (m_shapeType) {
|
switch (m_shapeType) {
|
||||||
case Line: return tr("une ligne");
|
case Line: return tr("une ligne");
|
||||||
case Rectangle: return tr("un rectangle");
|
case Rectangle: return tr("un rectangle");
|
||||||
case Ellipse: return tr("une éllipse");
|
case Ellipse: return tr("une ??llipse");
|
||||||
case Polygon: return tr("une polyligne");
|
case Polygon: return tr("une polyligne");
|
||||||
default: return tr("une shape");
|
default: return tr("une shape");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class SlaveElement : public Element
|
|||||||
void unlinkElement(Element *elmt) override;
|
void unlinkElement(Element *elmt) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGraphicsTextItem *m_xref_item;
|
QGraphicsTextItem *m_xref_item{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SLAVEELEMENT_H
|
#endif // SLAVEELEMENT_H
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
#include "../qetgraphicsitem/element.h"
|
#include "../qetgraphicsitem/element.h"
|
||||||
#include "conductortextitem.h"
|
#include "conductortextitem.h"
|
||||||
|
|
||||||
|
#include "../qetxml.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
QColor Terminal::neutralColor = QColor(Qt::blue);
|
QColor Terminal::neutralColor = QColor(Qt::blue);
|
||||||
@@ -41,7 +43,7 @@ const qreal Terminal::Z = 1000;
|
|||||||
@param name of terminal
|
@param name of terminal
|
||||||
@param hiddenName
|
@param hiddenName
|
||||||
*/
|
*/
|
||||||
void Terminal::init()
|
void Terminal::init(QString number, QString name, bool hiddenName)
|
||||||
{
|
{
|
||||||
//Calcul the docking point of the element
|
//Calcul the docking point of the element
|
||||||
//m_pos of d is the docking point of conductor
|
//m_pos of d is the docking point of conductor
|
||||||
@@ -64,19 +66,104 @@ void Terminal::init()
|
|||||||
qreal h = qAbs(dcy - dey) + 7;
|
qreal h = qAbs(dcy - dey) + 7;
|
||||||
m_br = QRectF(origin, QSizeF(w, h));
|
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;
|
||||||
|
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
setToolTip(QObject::tr("Borne", "tooltip"));
|
setToolTip(QObject::tr("Borne", "tooltip"));
|
||||||
setZValue(Z);
|
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) :
|
Terminal::Terminal(TerminalData* data, Element* e) :
|
||||||
QGraphicsObject(e),
|
QGraphicsObject(e),
|
||||||
d(data),
|
d(data),
|
||||||
parent_element_(e)
|
parent_element_(e)
|
||||||
{
|
{
|
||||||
d->setParent(this);
|
d->setParent(this);
|
||||||
init();
|
init("_", "_", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,6 +197,34 @@ Qet::Orientation Terminal::orientation() const
|
|||||||
} else return(d->m_orientation);
|
} 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
|
@brief Terminal::addConductor
|
||||||
Add a conductor to this terminal
|
Add a conductor to this terminal
|
||||||
@@ -624,6 +739,10 @@ bool Terminal::canBeLinkedTo(Terminal *other_terminal)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Terminal::setID(int id) {
|
||||||
|
m_id = id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Terminal::conductors
|
@brief Terminal::conductors
|
||||||
@return La liste des conducteurs lies a cette borne
|
@return La liste des conducteurs lies a cette borne
|
||||||
@@ -634,22 +753,19 @@ QList<Conductor *> Terminal::conductors() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Terminal::toXml
|
@brief Terminal::toXmlPriv
|
||||||
Methode d'export en XML
|
Methode d'export en XML
|
||||||
@param doc Le Document XML a utiliser pour creer l'element XML
|
@param doc Le Document XML a utiliser pour creer l'element XML
|
||||||
@return un QDomElement representant cette borne
|
@return un QDomElement representant cette borne
|
||||||
*/
|
*/
|
||||||
QDomElement Terminal::toXml(QDomDocument &doc) const
|
void Terminal::toXmlPriv(QDomElement &qdo) const
|
||||||
{
|
{
|
||||||
QDomElement qdo = doc.createElement("terminal");
|
|
||||||
|
|
||||||
// for backward compatibility
|
// for backward compatibility
|
||||||
qdo.setAttribute("x", QString("%1").arg(dock_elmt_.x()));
|
qdo.setAttribute("x", QString("%1").arg(dock_elmt_.x()));
|
||||||
qdo.setAttribute("y", QString("%1").arg(dock_elmt_.y()));
|
qdo.setAttribute("y", QString("%1").arg(dock_elmt_.y()));
|
||||||
// end for backward compatibility
|
// end for backward compatibility
|
||||||
|
|
||||||
qdo.setAttribute("orientation", d->m_orientation);
|
qdo.setAttribute("orientation", d->m_orientation);
|
||||||
return(qdo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -658,42 +774,25 @@ QDomElement Terminal::toXml(QDomDocument &doc) const
|
|||||||
@param terminal Le QDomElement a analyser
|
@param terminal Le QDomElement a analyser
|
||||||
@return true si le QDomElement passe en parametre est une borne, false sinon
|
@return true si le QDomElement passe en parametre est une borne, false sinon
|
||||||
*/
|
*/
|
||||||
bool Terminal::valideXml(QDomElement &terminal)
|
bool Terminal::valideXml(const QDomElement &terminal)
|
||||||
{
|
{
|
||||||
// verifie le nom du tag
|
|
||||||
if (terminal.tagName() != "terminal") return(false);
|
if (terminal.tagName() != "terminal") return(false);
|
||||||
|
|
||||||
// verifie la presence des attributs minimaux
|
// affuteuse_250h.qet contains in line 8398 terminals which do not have this
|
||||||
if (!terminal.hasAttribute("x")) return(false);
|
// if (QETXML::propertyString(terminal, "number"))
|
||||||
if (!terminal.hasAttribute("y")) return(false);
|
// return false;
|
||||||
if (!terminal.hasAttribute("orientation")) return(false);
|
// affuteuse_250h.qet contains in line 8398 terminals which do not have this
|
||||||
|
// if (QETXML::propertyBool(terminal, "nameHidden"))
|
||||||
|
// return false;
|
||||||
|
|
||||||
bool conv_ok;
|
if (!TerminalData::valideXml(terminal))
|
||||||
// parse l'abscisse
|
return false;
|
||||||
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
|
// a ce stade, la borne est syntaxiquement correcte
|
||||||
return(true);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** RETURNS True
|
||||||
@brief Terminal::fromXml
|
@brief Terminal::fromXml
|
||||||
Permet de savoir si un element XML represente cette borne. Attention,
|
Permet de savoir si un element XML represente cette borne. Attention,
|
||||||
l'element XML n'est pas verifie
|
l'element XML n'est pas verifie
|
||||||
@@ -701,13 +800,17 @@ bool Terminal::valideXml(QDomElement &terminal)
|
|||||||
@return true si la borne "se reconnait"
|
@return true si la borne "se reconnait"
|
||||||
(memes coordonnes, meme orientation), false sinon
|
(memes coordonnes, meme orientation), false sinon
|
||||||
*/
|
*/
|
||||||
bool Terminal::fromXml(QDomElement &terminal)
|
bool Terminal::fromXmlPriv(const QDomElement &terminal) {
|
||||||
{
|
QETXML::propertyString(terminal, "number", &number_terminal_);
|
||||||
return (
|
|
||||||
qFuzzyCompare(terminal.attribute("x").toDouble(), dock_elmt_.x()) &&
|
QETXML::propertyBool(terminal, "nameHidden", &name_terminal_hidden);
|
||||||
qFuzzyCompare(terminal.attribute("y").toDouble(), dock_elmt_.y()) &&
|
|
||||||
(terminal.attribute("orientation").toInt() == d->m_orientation)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -744,6 +847,18 @@ QUuid Terminal::uuid() const
|
|||||||
return d->m_uuid;
|
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
|
@brief Conductor::relatedPotentialTerminal
|
||||||
Return terminal at the same potential from the same
|
Return terminal at the same potential from the same
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
|
#include "../qet.h"
|
||||||
|
#include "../properties/propertiesinterface.h"
|
||||||
|
|
||||||
class Conductor;
|
class Conductor;
|
||||||
class Diagram;
|
class Diagram;
|
||||||
class Element;
|
class Element;
|
||||||
@@ -32,7 +35,7 @@ class TerminalData;
|
|||||||
plug point for conductors.
|
plug point for conductors.
|
||||||
This class handles all mouse events for connecting conductors
|
This class handles all mouse events for connecting conductors
|
||||||
*/
|
*/
|
||||||
class Terminal : public QGraphicsObject
|
class Terminal : public QGraphicsObject, public PropertiesInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -42,7 +45,11 @@ class Terminal : public QGraphicsObject
|
|||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
|
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
|
||||||
|
Terminal(qreal, qreal, Qet::Orientation, Element * = nullptr);
|
||||||
Terminal(TerminalData* data, Element *e = nullptr);
|
Terminal(TerminalData* data, Element *e = nullptr);
|
||||||
|
Terminal(QPointF, Qet::Orientation, QString number,
|
||||||
|
QString name, bool hiddenName, Element * = nullptr);
|
||||||
~Terminal() override;
|
~Terminal() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -74,6 +81,14 @@ class Terminal : public QGraphicsObject
|
|||||||
Diagram *diagram () const;
|
Diagram *diagram () const;
|
||||||
Element *parentElement () const;
|
Element *parentElement () const;
|
||||||
QUuid uuid () const;
|
QUuid uuid () const;
|
||||||
|
int ID() const;
|
||||||
|
QPointF dockPos();
|
||||||
|
QPointF originPos();
|
||||||
|
QString number() const;
|
||||||
|
void setNumber(QString number);
|
||||||
|
void setName(QString name, bool hiddenName);
|
||||||
|
QString name() const;
|
||||||
|
|
||||||
|
|
||||||
QList<Conductor *> conductors() const;
|
QList<Conductor *> conductors() const;
|
||||||
Qet::Orientation orientation() const;
|
Qet::Orientation orientation() const;
|
||||||
@@ -81,11 +96,15 @@ class Terminal : public QGraphicsObject
|
|||||||
void updateConductor();
|
void updateConductor();
|
||||||
bool isLinkedTo(Terminal *);
|
bool isLinkedTo(Terminal *);
|
||||||
bool canBeLinkedTo(Terminal *);
|
bool canBeLinkedTo(Terminal *);
|
||||||
|
void setID(int id);
|
||||||
|
|
||||||
// methods related to XML import/export
|
// methods related to XML import/export
|
||||||
static bool valideXml(QDomElement &);
|
static bool valideXml(const QDomElement &);
|
||||||
bool fromXml (QDomElement &);
|
bool fromXmlPriv (const QDomElement &) override;
|
||||||
QDomElement toXml (QDomDocument &) const;
|
void toXmlPriv(QDomElement &) const override;
|
||||||
|
|
||||||
|
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||||
|
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// methods related to events management
|
// methods related to events management
|
||||||
@@ -103,6 +122,7 @@ class Terminal : public QGraphicsObject
|
|||||||
static const qreal terminalSize;
|
static const qreal terminalSize;
|
||||||
static const qreal Z;
|
static const qreal Z;
|
||||||
// Various static colors used for hover effects
|
// Various static colors used for hover effects
|
||||||
|
// The assignement is in the cpp file
|
||||||
/// default color
|
/// default color
|
||||||
static QColor neutralColor;
|
static QColor neutralColor;
|
||||||
/// color for legal actions
|
/// color for legal actions
|
||||||
@@ -118,7 +138,7 @@ class Terminal : public QGraphicsObject
|
|||||||
QGraphicsLineItem *m_help_line_a{nullptr};
|
QGraphicsLineItem *m_help_line_a{nullptr};
|
||||||
|
|
||||||
|
|
||||||
TerminalData* d;
|
TerminalData* d{nullptr};
|
||||||
|
|
||||||
/// Parent electrical element
|
/// Parent electrical element
|
||||||
Element *parent_element_{nullptr};
|
Element *parent_element_{nullptr};
|
||||||
@@ -128,17 +148,28 @@ class Terminal : public QGraphicsObject
|
|||||||
private:
|
private:
|
||||||
/// List of conductors attached to the terminal
|
/// List of conductors attached to the terminal
|
||||||
QList<Conductor *> m_conductors_list;
|
QList<Conductor *> m_conductors_list;
|
||||||
|
/**
|
||||||
|
Pointer to a rectangle representing the terminal bounding rect;
|
||||||
|
used to calculate the bounding rect once only;
|
||||||
|
used a pointer because boundingRect() is supposed to be const.
|
||||||
|
*/
|
||||||
QRectF m_br;
|
QRectF m_br;
|
||||||
/// Last terminal seen through an attached conductor
|
/// Last terminal seen through an attached conductor
|
||||||
Terminal *m_previous_terminal = nullptr;
|
Terminal *m_previous_terminal{nullptr};
|
||||||
/// Whether the mouse pointer is hovering the terminal
|
/// Whether the mouse pointer is hovering the terminal
|
||||||
bool m_hovered = false;
|
bool m_hovered{false};
|
||||||
/// Color used for the hover effect
|
/// Color used for the hover effect
|
||||||
QColor m_hovered_color = Terminal::neutralColor;
|
QColor m_hovered_color{Terminal::neutralColor};
|
||||||
|
/// Number of Terminal
|
||||||
|
QString number_terminal_;
|
||||||
|
bool name_terminal_hidden{true};
|
||||||
|
|
||||||
|
/// legacy id used by the conductor to find the terminal. From 0.8x on the uuid is used instead.
|
||||||
|
int m_id{-1};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init(QString number, QString name, bool hiddenName);
|
||||||
void init(QPointF pf, Qet::Orientation o);
|
void init(QPointF pf, Qet::Orientation o,QString number, QString name, bool hiddenName);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,6 +181,16 @@ inline int Terminal::conductorsCount() const
|
|||||||
return(m_conductors_list.size());
|
return(m_conductors_list.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Terminal::number
|
||||||
|
@return the number of terminal.
|
||||||
|
*/
|
||||||
|
inline QString Terminal::number() const
|
||||||
|
{
|
||||||
|
return(number_terminal_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
|
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
|
||||||
const bool all_diagram = true);
|
const bool all_diagram = true);
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,8 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "qetxml.h"
|
||||||
|
|
||||||
static int BACKUP_INTERVAL = 120000; //interval in ms of backup = 2min
|
static int BACKUP_INTERVAL = 120000; //interval in ms of backup = 2min
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1532,7 +1534,11 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
|
|||||||
{
|
{
|
||||||
XRefProperties xrp;
|
XRefProperties xrp;
|
||||||
xrp.fromXml(elmt);
|
xrp.fromXml(elmt);
|
||||||
m_default_xref_properties.insert(elmt.attribute("type"), xrp);
|
QString type;
|
||||||
|
if (QETXML::propertyString(elmt, "type", &type) == QETXML::PropertyFlags::Success)
|
||||||
|
m_default_xref_properties.insert(type, xrp);
|
||||||
|
else
|
||||||
|
qDebug() << "xref Property was not added to m_default_xref_properties.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!conds_autonums.isNull())
|
if (!conds_autonums.isNull())
|
||||||
@@ -1590,19 +1596,13 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element)
|
|||||||
QDomDocument xml_document = xml_element.ownerDocument();
|
QDomDocument xml_document = xml_element.ownerDocument();
|
||||||
|
|
||||||
// export size of border
|
// export size of border
|
||||||
QDomElement border_elmt = xml_document.createElement("border");
|
xml_element.appendChild(default_border_properties_.toXml(xml_document));
|
||||||
default_border_properties_.toXml(border_elmt);
|
|
||||||
xml_element.appendChild(border_elmt);
|
|
||||||
|
|
||||||
// export content of titleblock
|
// export content of titleblock
|
||||||
QDomElement titleblock_elmt = xml_document.createElement("inset");
|
xml_element.appendChild(default_titleblock_properties_.toXml(xml_document));
|
||||||
default_titleblock_properties_.toXml(titleblock_elmt);
|
|
||||||
xml_element.appendChild(titleblock_elmt);
|
|
||||||
|
|
||||||
// exporte default conductor
|
// exporte default conductor
|
||||||
QDomElement conductor_elmt = xml_document.createElement("conductors");
|
xml_element.appendChild(default_conductor_properties_.toXml(xml_document));
|
||||||
default_conductor_properties_.toXml(conductor_elmt);
|
|
||||||
xml_element.appendChild(conductor_elmt);
|
|
||||||
|
|
||||||
// export default report properties
|
// export default report properties
|
||||||
QDomElement report_elmt = xml_document.createElement("report");
|
QDomElement report_elmt = xml_document.createElement("report");
|
||||||
|
|||||||
@@ -581,3 +581,299 @@ QVector<QDomElement> QETXML::findInDomElement(const QDomElement &dom_elmt, const
|
|||||||
}
|
}
|
||||||
return(return_list);
|
return(return_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace QETXML {
|
||||||
|
|
||||||
|
PropertyFlags debugReadXml(PropertyFlags flag, const QDomElement &e, const QString& attribute_name, const QString& attr, const QString& type)
|
||||||
|
{
|
||||||
|
if (flag == QETXML::PropertyFlags::NoValidConversion)
|
||||||
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << type << ". value: " << attr;
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement createXmlProperty(const QString& name, const QString value) {
|
||||||
|
QDomDocument doc;
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", stringS);
|
||||||
|
p.setAttribute("value", value);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement createXmlProperty(const QString& name, const char* value) {
|
||||||
|
QDomDocument doc;
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", stringS);
|
||||||
|
p.setAttribute("value", value);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief propertyInteger
|
||||||
|
* Reads an interger from the XML element.
|
||||||
|
* \param e DomElement which contains the property attribute
|
||||||
|
* \param attribute_name Name of the attribute
|
||||||
|
* \param entier Return value if success
|
||||||
|
* \return True if reading an integer was successful, else False. If the attribute was not found,
|
||||||
|
* \p entier is not valid and the return value is False
|
||||||
|
*/
|
||||||
|
QDomElement createXmlProperty(const QString& name, const int value) {
|
||||||
|
QDomDocument doc;
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", integerS);
|
||||||
|
p.setAttribute("value", QString::number(value));
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement createXmlProperty(const QString& name, const double value) {
|
||||||
|
QDomDocument doc;
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", doubleS);
|
||||||
|
p.setAttribute("value", QString::number(value));
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement createXmlProperty(const QString& name, const bool value) {
|
||||||
|
QDomDocument doc;
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", boolS);
|
||||||
|
p.setAttribute("value", QString::number(value));
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement createXmlProperty(const QString& name, const QUuid value) {
|
||||||
|
QDomDocument doc;
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", uuidS);
|
||||||
|
p.setAttribute("value", value.toString());
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement createXmlProperty(const QString& name, const QColor value) {
|
||||||
|
QDomDocument doc;
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", colorS);
|
||||||
|
p.setAttribute("value", value.name());
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief PropertiesInterface::propertyInteger
|
||||||
|
* Reads an interger from the XML element.
|
||||||
|
* \param e DomElement which contains the property attribute
|
||||||
|
* \param attribute_name Name of the attribute
|
||||||
|
* \param entier Return value if success
|
||||||
|
* \return True if reading an integer was successful, else False. If the attribute was not found,
|
||||||
|
* \p entier is not valid and the return value is False
|
||||||
|
*/
|
||||||
|
PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier) {
|
||||||
|
|
||||||
|
QString attr;
|
||||||
|
|
||||||
|
if (!attribute(e, attribute_name, integerS, &attr)) {
|
||||||
|
return PropertyFlags::NotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
return debugReadXml(propertyInteger(attr, entier), e, attribute_name, attr, integerS);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyFlags propertyInteger(const QString& value, int* entier) {
|
||||||
|
// verifie la validite de l'attribut
|
||||||
|
bool ok;
|
||||||
|
int tmp = value.toInt(&ok);
|
||||||
|
if (!ok) {
|
||||||
|
return QETXML::PropertyFlags::NoValidConversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entier != nullptr)
|
||||||
|
*entier = tmp;
|
||||||
|
|
||||||
|
return PropertyFlags::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double* reel) {
|
||||||
|
|
||||||
|
QString attr;
|
||||||
|
|
||||||
|
if (!attribute(e, attribute_name, doubleS, &attr)) {
|
||||||
|
return PropertyFlags::NotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
return debugReadXml(propertyDouble(attr, reel), e, attribute_name, attr, doubleS);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyFlags propertyDouble(const QString& value, double* reel)
|
||||||
|
{
|
||||||
|
// verifie la validite de l'attribut
|
||||||
|
bool ok;
|
||||||
|
double tmp = value.toDouble(&ok);
|
||||||
|
if (!ok) {
|
||||||
|
return QETXML::PropertyFlags::NoValidConversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reel != nullptr)
|
||||||
|
*reel = tmp;
|
||||||
|
|
||||||
|
return PropertyFlags::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean) {
|
||||||
|
|
||||||
|
QString attr;
|
||||||
|
|
||||||
|
if (!attribute(e, attribute_name, boolS, &attr)) {
|
||||||
|
return PropertyFlags::NotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
return debugReadXml(propertyBool(attr, boolean), e, attribute_name, attr, boolS);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyFlags propertyBool(const QString& value, bool* boolean)
|
||||||
|
{
|
||||||
|
// verifie la validite de l'attribut
|
||||||
|
bool ok;
|
||||||
|
bool tmp = value.toInt(&ok);
|
||||||
|
if (!ok) {
|
||||||
|
if (value == "true" || value == "1")
|
||||||
|
tmp = true;
|
||||||
|
else if (value == "false" || value == "0")
|
||||||
|
tmp = false;
|
||||||
|
else {
|
||||||
|
return QETXML::PropertyFlags::NoValidConversion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (boolean != nullptr)
|
||||||
|
*boolean = tmp;
|
||||||
|
|
||||||
|
return PropertyFlags::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color) {
|
||||||
|
|
||||||
|
QString attr;
|
||||||
|
|
||||||
|
if (!attribute(e, attribute_name, colorS, &attr)) {
|
||||||
|
return PropertyFlags::NotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
return debugReadXml(propertyColor(attr, color), e, attribute_name, attr, colorS);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyFlags propertyColor(const QString& value, QColor* color)
|
||||||
|
{
|
||||||
|
// verifie la validite de l'attribut
|
||||||
|
QColor tmp = QColor(value);
|
||||||
|
if (!tmp.isValid()) {
|
||||||
|
return QETXML::PropertyFlags::NoValidConversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (color != nullptr)
|
||||||
|
*color = tmp;
|
||||||
|
|
||||||
|
return PropertyFlags::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid) {
|
||||||
|
QString attr;
|
||||||
|
|
||||||
|
if (!attribute(e, attribute_name, uuidS, &attr)) {
|
||||||
|
return PropertyFlags::NotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
return debugReadXml(propertyUuid(attr, uuid), e, attribute_name, attr, uuidS);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyFlags propertyUuid(const QString& value, QUuid* uuid)
|
||||||
|
{
|
||||||
|
if (QUuid(value).isNull()){
|
||||||
|
return QETXML::PropertyFlags::NoValidConversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (uuid != nullptr)
|
||||||
|
*uuid = QUuid(value);
|
||||||
|
|
||||||
|
return PropertyFlags::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string) {
|
||||||
|
|
||||||
|
QString attr;
|
||||||
|
if (!attribute(e, attribute_name, stringS, &attr)) {
|
||||||
|
return PropertyFlags::NotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
// verifie la validite de l'attribut
|
||||||
|
if (string != nullptr)
|
||||||
|
*string = attr;
|
||||||
|
|
||||||
|
return PropertyFlags::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement property(const QDomElement& e, const QString& name) {
|
||||||
|
for (int i=0; i < e.childNodes().count(); i++) {
|
||||||
|
QDomElement child = e.childNodes().at(i).toElement();
|
||||||
|
if (!validXmlProperty(child))
|
||||||
|
continue; // there might also non property childs
|
||||||
|
|
||||||
|
if (child.attribute("name") == name)
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
return QDomElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief PropertiesInterface::attribute
|
||||||
|
* Returns the property with the name \p attribute_name and type \p type
|
||||||
|
* \param e Xml element which contains the property
|
||||||
|
* \param attribute_name
|
||||||
|
* \param type Type of the property
|
||||||
|
* \param attr
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
bool attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr) {
|
||||||
|
QDomElement p = property(e, attribute_name);
|
||||||
|
if (p.isNull()) {
|
||||||
|
// check if legacy property is available,
|
||||||
|
// where the property is inside the element as attribute
|
||||||
|
if (!e.hasAttribute(attribute_name)) {
|
||||||
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "Property " << attribute_name << "is not available";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*attr = e.attribute(attribute_name);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (p.attribute("type") != type) {
|
||||||
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ", Property: " << attribute_name << "(" << p.attribute("type") << ") has not type: " << type;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*attr = p.attribute("value");
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool validXmlProperty(const QDomElement& e) {
|
||||||
|
if (!e.hasAttribute("name"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!e.hasAttribute("type"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!e.hasAttribute("value"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -89,6 +89,54 @@ namespace QETXML
|
|||||||
|
|
||||||
QVector<QDomElement> findInDomElement(const QDomElement &dom_elmt,
|
QVector<QDomElement> findInDomElement(const QDomElement &dom_elmt,
|
||||||
const QString &tag_name);
|
const QString &tag_name);
|
||||||
|
|
||||||
|
const QString integerS = "int";
|
||||||
|
const QString doubleS = "double";
|
||||||
|
const QString boolS = "bool";
|
||||||
|
const QString stringS = "string";
|
||||||
|
const QString uuidS = "uuid";
|
||||||
|
const QString colorS = "color";
|
||||||
|
|
||||||
|
enum PropertyFlags {
|
||||||
|
Success = 0,
|
||||||
|
NotFound = 1,
|
||||||
|
NoValidConversion = 2,
|
||||||
|
// = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Use this functions to add properties to the xml document
|
||||||
|
*/
|
||||||
|
QDomElement createXmlProperty(const QString& name, const QString value);
|
||||||
|
QDomElement createXmlProperty(const QString& name, const char* value);
|
||||||
|
QDomElement createXmlProperty(const QString& name, const int value);
|
||||||
|
QDomElement createXmlProperty(const QString& name, const double value);
|
||||||
|
QDomElement createXmlProperty(const QString& name, const bool value);
|
||||||
|
QDomElement createXmlProperty(const QString& name, const QUuid value);
|
||||||
|
QDomElement createXmlProperty(const QString& name, const QColor value);
|
||||||
|
|
||||||
|
PropertyFlags propertyInteger(const QString& value, int* entry = nullptr);
|
||||||
|
PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr);
|
||||||
|
PropertyFlags propertyDouble(const QString& value, double* entry = nullptr);
|
||||||
|
PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr);
|
||||||
|
PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr);
|
||||||
|
PropertyFlags propertyBool(const QString& value, bool* entry = nullptr);
|
||||||
|
PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr);
|
||||||
|
PropertyFlags propertyUuid(const QString& value, QUuid* entry = nullptr);
|
||||||
|
PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr);
|
||||||
|
PropertyFlags propertyColor(const QString& value, QColor* entry = nullptr);
|
||||||
|
PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr);
|
||||||
|
|
||||||
|
QDomElement property(const QDomElement& e, const QString& name);
|
||||||
|
bool attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief PropertiesInterface::validXmlProperty
|
||||||
|
* Check if the Xml element contains the needed fields
|
||||||
|
* \param e Xml Property
|
||||||
|
* \return True if name, type, value attribute are available, else false
|
||||||
|
*/
|
||||||
|
bool validXmlProperty(const QDomElement& e);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // QETXML_H
|
#endif // QETXML_H
|
||||||
|
|||||||
@@ -38,11 +38,11 @@ class HelperCell : public QGraphicsObject, public QGraphicsLayoutItem {
|
|||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
public:
|
public:
|
||||||
QColor background_color; ///< Background color when rendering this cell
|
QColor background_color{Qt::white}; ///< Background color when rendering this cell
|
||||||
QColor foreground_color; ///< Text color when rendering this cell
|
QColor foreground_color{Qt::black}; ///< Text color when rendering this cell
|
||||||
QString label; ///< Label displayed in this cell
|
QString label; ///< Label displayed in this cell
|
||||||
Qt::Orientation orientation; ///< Orientation of this cell
|
Qt::Orientation orientation{Qt::Horizontal}; ///< Orientation of this cell
|
||||||
int index; ///< Index of this cell
|
int index{-1}; ///< Index of this cell
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class SplittedHelperCell : public HelperCell {
|
|||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
|
// colors are set in the constructor
|
||||||
QColor split_background_color; ///< Background color on the split side
|
QColor split_background_color; ///< Background color on the split side
|
||||||
QColor split_foreground_color; ///< Text color on the split side
|
QColor split_foreground_color; ///< Text color on the split side
|
||||||
QString split_label; ///< Text displayed on the split side
|
QString split_label; ///< Text displayed on the split side
|
||||||
|
|||||||
@@ -19,16 +19,15 @@
|
|||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
|
|
||||||
|
#include "qetxml.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur. Initialise un objet TitleBlockProperties avec tous les champs
|
Constructeur. Initialise un objet TitleBlockProperties avec tous les champs
|
||||||
vides (date vide + useDate a UseDateValue).
|
vides (date vide + useDate a UseDateValue).
|
||||||
*/
|
*/
|
||||||
TitleBlockProperties::TitleBlockProperties() :
|
TitleBlockProperties::TitleBlockProperties()
|
||||||
date(),
|
|
||||||
useDate(UseDateValue),
|
|
||||||
display_at(Qt::BottomEdge),
|
|
||||||
collection (QET::QetCollection::Common)
|
|
||||||
{
|
{
|
||||||
|
setTagName("titleblock");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,13 +68,11 @@ bool TitleBlockProperties::operator!=(const TitleBlockProperties &ip) {
|
|||||||
return(!(*this == ip));
|
return(!(*this == ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Exporte le cartouche sous formes d'attributs XML ajoutes a l'element e.
|
Exporte le cartouche sous formes d'attributs XML ajoutes a l'element e.
|
||||||
@param e Element XML auquel seront ajoutes des attributs
|
@param e Element XML auquel seront ajoutes des attributs
|
||||||
*/
|
*/
|
||||||
void TitleBlockProperties::toXml(QDomElement &e) const
|
void TitleBlockProperties::toXmlPriv(QDomElement& e) const {
|
||||||
{
|
|
||||||
e.setAttribute("author", author);
|
e.setAttribute("author", author);
|
||||||
e.setAttribute("title", title);
|
e.setAttribute("title", title);
|
||||||
e.setAttribute("filename", filename);
|
e.setAttribute("filename", filename);
|
||||||
@@ -100,29 +97,36 @@ void TitleBlockProperties::toXml(QDomElement &e) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** RETURNS True
|
||||||
Importe le cartouche a partir des attributs XML de l'element e
|
Importe le cartouche a partir des attributs XML de l'element e
|
||||||
@param e Element XML dont les attributs seront lus
|
@param e Element XML dont les attributs seront lus
|
||||||
*/
|
*/
|
||||||
void TitleBlockProperties::fromXml(const QDomElement &e) {
|
bool TitleBlockProperties::fromXmlPriv(const QDomElement &e) {
|
||||||
|
|
||||||
|
|
||||||
// reads the historical fields
|
// reads the historical fields
|
||||||
if (e.hasAttribute("author")) author = e.attribute("author");
|
QETXML::propertyString(e, "author", &author);
|
||||||
if (e.hasAttribute("title")) title = e.attribute("title");
|
QETXML::propertyString(e, "title", &title);
|
||||||
if (e.hasAttribute("filename")) filename = e.attribute("filename");
|
QETXML::propertyString(e, "filename", &filename);
|
||||||
if (e.hasAttribute("plant")) plant = e.attribute("plant");
|
QETXML::propertyString(e, "plant", &plant);
|
||||||
if (e.hasAttribute("locmach")) locmach = e.attribute("locmach");
|
QETXML::propertyString(e, "locmach", &locmach);
|
||||||
if (e.hasAttribute("indexrev")) indexrev = e.attribute("indexrev");
|
QETXML::propertyString(e, "indexrev", &indexrev);
|
||||||
if (e.hasAttribute("version")) version = e.attribute("version");
|
QETXML::propertyString(e, "version", &version);
|
||||||
if (e.hasAttribute("folio")) folio = e.attribute("folio");
|
QETXML::propertyString(e, "folio", &folio);
|
||||||
if (e.hasAttribute("auto_page_num")) auto_page_num = e.attribute("auto_page_num");
|
QETXML::propertyString(e, "auto_page_num", &auto_page_num);
|
||||||
if (e.hasAttribute("date")) setDateFromString(e.attribute("date"));
|
QString date;
|
||||||
if (e.hasAttribute("displayAt")) display_at = (e.attribute("displayAt") == "bottom" ? Qt::BottomEdge : Qt::RightEdge);
|
QETXML::propertyString(e, "date", &date);
|
||||||
|
setDateFromString(date);
|
||||||
|
|
||||||
|
QString display_at_temp;
|
||||||
|
if (QETXML::propertyString(e, "displayAt", &display_at_temp) == QETXML::PropertyFlags::Success)
|
||||||
|
display_at = (display_at_temp == "bottom" ? Qt::BottomEdge : Qt::RightEdge); // otherwise it gets default in header file
|
||||||
|
|
||||||
// reads the template used to render the title block
|
// reads the template used to render the title block
|
||||||
if (e.hasAttribute("titleblocktemplate"))
|
if (QETXML::propertyString(e, "titleblocktemplate", &template_name) == QETXML::PropertyFlags::Success) {
|
||||||
{
|
QString tbc;
|
||||||
template_name = e.attribute("titleblocktemplate");
|
if (QETXML::propertyString(e, "titleblocktemplateCollection", &tbc) == QETXML::PropertyFlags::Success)
|
||||||
collection = QET::qetCollectionFromString(e.attribute("titleblocktemplateCollection"));
|
collection = QET::qetCollectionFromString(tbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reads the additional fields used to fill the title block
|
// reads the additional fields used to fill the title block
|
||||||
@@ -130,6 +134,7 @@ void TitleBlockProperties::fromXml(const QDomElement &e) {
|
|||||||
foreach (QDomElement e, QET::findInDomElement(e, "properties")) {
|
foreach (QDomElement e, QET::findInDomElement(e, "properties")) {
|
||||||
context.fromXml(e);
|
context.fromXml(e);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,12 +21,14 @@
|
|||||||
#include "diagramcontext.h"
|
#include "diagramcontext.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
|
|
||||||
|
#include "properties/propertiesinterface.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class provides a container for the properties of a particular title
|
This class provides a container for the properties of a particular title
|
||||||
block, i.e. title, author, date, filename, folio, template, custom
|
block, i.e. title, author, date, filename, folio, template, custom
|
||||||
properties, ...
|
properties, ...
|
||||||
*/
|
*/
|
||||||
class TitleBlockProperties {
|
class TitleBlockProperties: public PropertiesInterface {
|
||||||
public:
|
public:
|
||||||
TitleBlockProperties();
|
TitleBlockProperties();
|
||||||
virtual ~TitleBlockProperties();
|
virtual ~TitleBlockProperties();
|
||||||
@@ -39,10 +41,10 @@ class TitleBlockProperties {
|
|||||||
bool operator==(const TitleBlockProperties &);
|
bool operator==(const TitleBlockProperties &);
|
||||||
bool operator!=(const TitleBlockProperties &);
|
bool operator!=(const TitleBlockProperties &);
|
||||||
|
|
||||||
void toXml(QDomElement &) const;
|
void toXmlPriv(QDomElement &e) const override;
|
||||||
void fromXml(const QDomElement &);
|
bool fromXmlPriv(const QDomElement &) override;
|
||||||
void toSettings(QSettings &, const QString & = QString()) const;
|
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||||
void fromSettings(QSettings &, const QString & = QString());
|
void fromSettings(QSettings &, const QString & = QString()) override;
|
||||||
|
|
||||||
void setAutoPageNum(QString autonum) {auto_page_num = autonum;}
|
void setAutoPageNum(QString autonum) {auto_page_num = autonum;}
|
||||||
|
|
||||||
@@ -61,11 +63,11 @@ class TitleBlockProperties {
|
|||||||
QString version; ///< Version (displayed by the default template)
|
QString version; ///< Version (displayed by the default template)
|
||||||
QString folio; ///< Folio information (displayed by the default template)
|
QString folio; ///< Folio information (displayed by the default template)
|
||||||
QString auto_page_num;
|
QString auto_page_num;
|
||||||
DateManagement useDate; ///< Wheter to use the date attribute
|
DateManagement useDate{UseDateValue}; ///< Wheter to use the date attribute
|
||||||
QString template_name; ///< Name of the template used to render the title block - an empty string means "the default template provided by the application"
|
QString template_name; ///< Name of the template used to render the title block - an empty string means "the default template provided by the application"
|
||||||
DiagramContext context; ///< Container for the additional, user-defined fields
|
DiagramContext context; ///< Container for the additional, user-defined fields
|
||||||
Qt::Edge display_at; ///< Edge to display the titleblock
|
Qt::Edge display_at{Qt::Edge::BottomEdge}; ///< Edge to display the titleblock
|
||||||
QET::QetCollection collection; ///<Specify the location of the title block
|
QET::QetCollection collection{QET::QetCollection::Common}; ///<Specify the location of the title block
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString exportDate() const;
|
QString exportDate() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user