mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 22:00:35 +01:00
Compare commits
10 Commits
element_pi
...
XMLPropert
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ada65f10e7 | ||
|
|
33328b30cd | ||
|
|
b0a6b8fd05 | ||
|
|
af83e8bf1b | ||
|
|
4a7772b003 | ||
|
|
253ac4d816 | ||
|
|
a54b6192d0 | ||
|
|
0873904598 | ||
|
|
229bc2f9d9 | ||
|
|
31f05c58b9 |
@@ -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:
|
||||||
|
|||||||
@@ -25,22 +25,14 @@
|
|||||||
Initializes a BorderProperties object
|
Initializes a BorderProperties object
|
||||||
with the following default properties:
|
with the following default properties:
|
||||||
- 17 columns of 60.0 px wide by 20.0px high
|
- 17 columns of 60.0 px wide by 20.0px high
|
||||||
- 8 lines of 80.0 px high by 20.0px wide
|
- 8 lines of 80.0 px high by 20.0px wide
|
||||||
|
|
||||||
\~French Initialise un objet BorderProperties avec les proprietes par
|
\~French Initialise un objet BorderProperties avec les proprietes par
|
||||||
defaut suivantes :
|
defaut suivantes :
|
||||||
- 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()
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,17 +88,21 @@ 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
|
QDomElement BorderProperties::toXml(QDomDocument &dom_doc) const {
|
||||||
{
|
|
||||||
e.setAttribute("cols", columns_count);
|
QDomElement e = dom_doc.createElement("border");
|
||||||
e.setAttribute("colsize", QString("%1").arg(columns_width));
|
|
||||||
e.setAttribute("rows", rows_count);
|
e.appendChild(createXmlProperty(dom_doc, "cols", columns_count));
|
||||||
e.setAttribute("rowsize", QString("%1").arg(rows_height));
|
e.appendChild(createXmlProperty(dom_doc, "colsize", columns_width));
|
||||||
e.setAttribute("displaycols", display_columns ? "true" : "false");
|
e.appendChild(createXmlProperty(dom_doc, "rows", rows_count));
|
||||||
e.setAttribute("displayrows", display_rows ? "true" : "false");
|
e.appendChild(createXmlProperty(dom_doc, "rowsize", rows_height));
|
||||||
|
e.appendChild(createXmlProperty(dom_doc, "displayrows", display_rows));
|
||||||
|
e.appendChild(createXmlProperty(dom_doc, "displaycols", display_columns));
|
||||||
|
|
||||||
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**RETURNS True
|
||||||
@brief BorderProperties::fromXml
|
@brief BorderProperties::fromXml
|
||||||
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 +111,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::fromXml(const QDomElement &e) {
|
||||||
if (e.hasAttribute("cols")) columns_count = e.attribute("cols").toInt();
|
|
||||||
if (e.hasAttribute("colsize")) columns_width = e.attribute("colsize").toInt();
|
if (propertyInteger(e, "cols", &columns_count) == PropertyFlags::NoValidConversion ||
|
||||||
if (e.hasAttribute("rows")) rows_count = e.attribute("rows").toInt();
|
propertyDouble(e, "colsize", &columns_width) == PropertyFlags::NoValidConversion ||
|
||||||
if (e.hasAttribute("rowsize")) rows_height = e.attribute("rowsize").toInt();
|
propertyInteger(e, "rows", &rows_count) == PropertyFlags::NoValidConversion ||
|
||||||
if (e.hasAttribute("displaycols")) display_columns = e.attribute("displaycols") == "true";
|
propertyDouble(e, "rowsize", &rows_height) == PropertyFlags::NoValidConversion ||
|
||||||
if (e.hasAttribute("displayrows")) display_rows = e.attribute("displayrows") == "true";
|
propertyBool(e, "displaycols", &display_columns) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyBool(e, "displayrows", &display_rows) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BorderProperties::valideXml(QDomElement& e) {
|
||||||
|
|
||||||
|
if (propertyInteger(e, "cols") == PropertyFlags::Success ||
|
||||||
|
propertyDouble(e, "colsize") == PropertyFlags::Success ||
|
||||||
|
propertyInteger(e, "rows") == PropertyFlags::Success ||
|
||||||
|
propertyDouble(e, "rowsize") == PropertyFlags::Success ||
|
||||||
|
propertyBool(e, "displaycols") == PropertyFlags::Success ||
|
||||||
|
propertyBool(e, "displayrows") == PropertyFlags::Success)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,11 +150,11 @@ void BorderProperties::fromXml(QDomElement &e) {
|
|||||||
*/
|
*/
|
||||||
void BorderProperties::toSettings(QSettings &settings, const QString &prefix) const
|
void BorderProperties::toSettings(QSettings &settings, const QString &prefix) const
|
||||||
{
|
{
|
||||||
settings.setValue(prefix + "cols", columns_count);
|
settings.setValue(prefix + "cols", columns_count);
|
||||||
settings.setValue(prefix + "colsize", columns_width);
|
settings.setValue(prefix + "colsize", columns_width);
|
||||||
settings.setValue(prefix + "displaycols", display_columns);
|
settings.setValue(prefix + "displaycols", display_columns);
|
||||||
settings.setValue(prefix + "rows", rows_count);
|
settings.setValue(prefix + "rows", rows_count);
|
||||||
settings.setValue(prefix + "rowsize", rows_height);
|
settings.setValue(prefix + "rowsize", rows_height);
|
||||||
settings.setValue(prefix + "displayrows", display_rows);
|
settings.setValue(prefix + "displayrows", display_rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,13 +168,13 @@ void BorderProperties::toSettings(QSettings &settings, const QString &prefix) co
|
|||||||
\~French prefixe a ajouter devant les noms des parametres
|
\~French prefixe a ajouter devant les noms des parametres
|
||||||
*/
|
*/
|
||||||
void BorderProperties::fromSettings(QSettings &settings, const QString &prefix) {
|
void BorderProperties::fromSettings(QSettings &settings, const QString &prefix) {
|
||||||
columns_count = settings.value(prefix + "cols", columns_count).toInt();
|
columns_count = settings.value(prefix + "cols", columns_count).toInt();
|
||||||
columns_width = qRound(settings.value(prefix + "colsize", columns_width).toDouble());
|
columns_width = qRound(settings.value(prefix + "colsize", columns_width).toDouble());
|
||||||
display_columns = settings.value(prefix + "displaycols", display_columns).toBool();
|
display_columns = settings.value(prefix + "displaycols", display_columns).toBool();
|
||||||
|
|
||||||
rows_count = settings.value(prefix + "rows", rows_count).toInt();
|
rows_count = settings.value(prefix + "rows", rows_count).toInt();
|
||||||
rows_height = qRound(settings.value(prefix + "rowsize", rows_height).toDouble());
|
rows_height = qRound(settings.value(prefix + "rowsize", rows_height).toDouble());
|
||||||
display_rows = settings.value(prefix + "displayrows", display_rows).toBool();
|
display_rows = settings.value(prefix + "displayrows", display_rows).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,13 +20,15 @@
|
|||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
|
|
||||||
|
#include "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;
|
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||||
void fromXml(QDomElement &);
|
bool fromXml(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
|
||||||
|
|||||||
@@ -86,14 +86,14 @@ QRectF BorderTitleBlock::titleBlockRect() const
|
|||||||
{
|
{
|
||||||
if (m_edge == Qt::BottomEdge)
|
if (m_edge == Qt::BottomEdge)
|
||||||
return QRectF(diagram_rect_.bottomLeft(),
|
return QRectF(diagram_rect_.bottomLeft(),
|
||||||
QSize(diagram_rect_.width(),
|
QSize(diagram_rect_.width(),
|
||||||
m_titleblock_template_renderer -> height()
|
m_titleblock_template_renderer -> height()
|
||||||
));
|
));
|
||||||
else
|
else
|
||||||
return QRectF(diagram_rect_.topRight(),
|
return QRectF(diagram_rect_.topRight(),
|
||||||
QSize(m_titleblock_template_renderer -> height(),
|
QSize(m_titleblock_template_renderer -> height(),
|
||||||
diagram_rect_.height()
|
diagram_rect_.height()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -124,9 +124,9 @@ QRectF BorderTitleBlock::titleBlockRectForQPainter() const
|
|||||||
return titleBlockRect();
|
return titleBlockRect();
|
||||||
else
|
else
|
||||||
return QRectF (diagram_rect_.bottomRight(),
|
return QRectF (diagram_rect_.bottomRight(),
|
||||||
QSize(diagram_rect_.height(),
|
QSize(diagram_rect_.height(),
|
||||||
m_titleblock_template_renderer -> height()
|
m_titleblock_template_renderer -> height()
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,9 +150,9 @@ QRectF BorderTitleBlock::columnsRect() const
|
|||||||
{
|
{
|
||||||
if (!display_columns_) return QRectF();
|
if (!display_columns_) return QRectF();
|
||||||
return QRectF (Diagram::margin,
|
return QRectF (Diagram::margin,
|
||||||
Diagram::margin,
|
Diagram::margin,
|
||||||
(columns_count_*columns_width_) + rows_header_width_,
|
(columns_count_*columns_width_) + rows_header_width_,
|
||||||
columns_header_height_);
|
columns_header_height_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,9 +164,9 @@ QRectF BorderTitleBlock::rowsRect() const
|
|||||||
{
|
{
|
||||||
if (!display_rows_) return QRectF();
|
if (!display_rows_) return QRectF();
|
||||||
return QRectF (Diagram::margin,
|
return QRectF (Diagram::margin,
|
||||||
Diagram::margin,
|
Diagram::margin,
|
||||||
rows_header_width_,
|
rows_header_width_,
|
||||||
(rows_count_*rows_height_) + columns_header_height_);
|
(rows_count_*rows_height_) + columns_header_height_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -177,9 +177,9 @@ QRectF BorderTitleBlock::rowsRect() const
|
|||||||
QRectF BorderTitleBlock::outsideBorderRect() const
|
QRectF BorderTitleBlock::outsideBorderRect() const
|
||||||
{
|
{
|
||||||
return QRectF (Diagram::margin,
|
return QRectF (Diagram::margin,
|
||||||
Diagram::margin,
|
Diagram::margin,
|
||||||
(columns_width_*columns_count_) + rows_header_width_,
|
(columns_width_*columns_count_) + rows_header_width_,
|
||||||
(rows_height_*rows_count_) + columns_header_height_);
|
(rows_height_*rows_count_) + columns_header_height_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -206,8 +206,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) {
|
void BorderTitleBlock::titleBlockToXml(QDomElement& doc) {
|
||||||
exportTitleBlock().toXml(xml_elmt);
|
exportTitleBlock().toXml(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -227,12 +227,12 @@ void BorderTitleBlock::titleBlockFromXml(const QDomElement &xml_elmt) {
|
|||||||
@param xml_elmt the XML element attributes will be added to
|
@param xml_elmt the XML element attributes will be added to
|
||||||
*/
|
*/
|
||||||
void BorderTitleBlock::borderToXml(QDomElement &xml_elmt) {
|
void BorderTitleBlock::borderToXml(QDomElement &xml_elmt) {
|
||||||
xml_elmt.setAttribute("cols", columnsCount());
|
xml_elmt.setAttribute("cols", columnsCount());
|
||||||
xml_elmt.setAttribute("colsize", QString("%1").arg(columnsWidth()));
|
xml_elmt.setAttribute("colsize", QString("%1").arg(columnsWidth()));
|
||||||
xml_elmt.setAttribute("displaycols", columnsAreDisplayed() ? "true" : "false");
|
xml_elmt.setAttribute("displaycols", columnsAreDisplayed() ? "true" : "false");
|
||||||
|
|
||||||
xml_elmt.setAttribute("rows", rowsCount());
|
xml_elmt.setAttribute("rows", rowsCount());
|
||||||
xml_elmt.setAttribute("rowsize", QString("%1").arg(rowsHeight()));
|
xml_elmt.setAttribute("rowsize", QString("%1").arg(rowsHeight()));
|
||||||
xml_elmt.setAttribute("displayrows", rowsAreDisplayed() ? "true" : "false");
|
xml_elmt.setAttribute("displayrows", rowsAreDisplayed() ? "true" : "false");
|
||||||
|
|
||||||
// attribut datant de la version 0.1 - laisse pour retrocompatibilite
|
// attribut datant de la version 0.1 - laisse pour retrocompatibilite
|
||||||
@@ -499,9 +499,9 @@ void BorderTitleBlock::updateRectangles()
|
|||||||
{
|
{
|
||||||
QRectF previous_diagram = diagram_rect_;
|
QRectF previous_diagram = diagram_rect_;
|
||||||
diagram_rect_ = QRectF(Diagram::margin,
|
diagram_rect_ = QRectF(Diagram::margin,
|
||||||
Diagram::margin,
|
Diagram::margin,
|
||||||
diagramWidth(),
|
diagramWidth(),
|
||||||
diagramHeight());
|
diagramHeight());
|
||||||
if (diagram_rect_ != previous_diagram)
|
if (diagram_rect_ != previous_diagram)
|
||||||
emit(borderChanged(previous_diagram, diagram_rect_));
|
emit(borderChanged(previous_diagram, diagram_rect_));
|
||||||
}
|
}
|
||||||
@@ -553,14 +553,14 @@ void BorderTitleBlock::draw(QPainter *painter)
|
|||||||
painter -> drawRect(numbered_rectangle);
|
painter -> drawRect(numbered_rectangle);
|
||||||
if (settings.value("border-columns_0", true).toBool()){
|
if (settings.value("border-columns_0", true).toBool()){
|
||||||
painter -> drawText(numbered_rectangle,
|
painter -> drawText(numbered_rectangle,
|
||||||
Qt::AlignVCenter
|
Qt::AlignVCenter
|
||||||
| Qt::AlignCenter,
|
| Qt::AlignCenter,
|
||||||
QString("%1").arg(i - 1));
|
QString("%1").arg(i - 1));
|
||||||
}else{
|
}else{
|
||||||
painter -> drawText(numbered_rectangle,
|
painter -> drawText(numbered_rectangle,
|
||||||
Qt::AlignVCenter
|
Qt::AlignVCenter
|
||||||
| Qt::AlignCenter,
|
| Qt::AlignCenter,
|
||||||
QString("%1").arg(i));
|
QString("%1").arg(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -581,9 +581,9 @@ void BorderTitleBlock::draw(QPainter *painter)
|
|||||||
);
|
);
|
||||||
painter -> drawRect(lettered_rectangle);
|
painter -> drawRect(lettered_rectangle);
|
||||||
painter -> drawText(lettered_rectangle,
|
painter -> drawText(lettered_rectangle,
|
||||||
Qt::AlignVCenter
|
Qt::AlignVCenter
|
||||||
| Qt::AlignCenter,
|
| Qt::AlignCenter,
|
||||||
row_string);
|
row_string);
|
||||||
row_string = incrementLetters(row_string);
|
row_string = incrementLetters(row_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -625,9 +625,9 @@ void BorderTitleBlock::drawDxf(
|
|||||||
{
|
{
|
||||||
// Transform to DXF scale.
|
// Transform to DXF scale.
|
||||||
columns_header_height_ *= Createdxf::yScale;
|
columns_header_height_ *= Createdxf::yScale;
|
||||||
rows_height_ *= Createdxf::yScale;
|
rows_height_ *= Createdxf::yScale;
|
||||||
rows_header_width_ *= Createdxf::xScale;
|
rows_header_width_ *= Createdxf::xScale;
|
||||||
columns_width_ *= Createdxf::xScale;
|
columns_width_ *= Createdxf::xScale;
|
||||||
|
|
||||||
// draw the empty box that appears as soon as there is a header
|
// draw the empty box that appears as soon as there is a header
|
||||||
// dessine la case vide qui apparait des qu'il y a un entete
|
// dessine la case vide qui apparait des qu'il y a un entete
|
||||||
@@ -656,11 +656,11 @@ void BorderTitleBlock::drawDxf(
|
|||||||
display_columns_) {
|
display_columns_) {
|
||||||
int offset = settings.value("border-columns_0", true).toBool() ? -1 : 0;
|
int offset = settings.value("border-columns_0", true).toBool() ? -1 : 0;
|
||||||
for (int i = 1 ; i <= columns_count_ ; ++ i) {
|
for (int i = 1 ; i <= columns_count_ ; ++ i) {
|
||||||
double xCoord = diagram_rect_.topLeft().x() * Createdxf::xScale +
|
double xCoord = diagram_rect_.topLeft().x() * Createdxf::xScale +
|
||||||
(rows_header_width_ + ((i - 1) *
|
(rows_header_width_ + ((i - 1) *
|
||||||
columns_width_));
|
columns_width_));
|
||||||
double yCoord = Createdxf::sheetHeight
|
double yCoord = Createdxf::sheetHeight
|
||||||
- diagram_rect_.topLeft().y()*Createdxf::yScale
|
- diagram_rect_.topLeft().y()*Createdxf::yScale
|
||||||
- columns_header_height_;
|
- columns_header_height_;
|
||||||
double recWidth = columns_width_;
|
double recWidth = columns_width_;
|
||||||
double recHeight = columns_header_height_;
|
double recHeight = columns_header_height_;
|
||||||
@@ -689,8 +689,8 @@ void BorderTitleBlock::drawDxf(
|
|||||||
for (int i = 1 ; i <= rows_count_ ; ++ i) {
|
for (int i = 1 ; i <= rows_count_ ; ++ i) {
|
||||||
double xCoord = diagram_rect_.topLeft().x()
|
double xCoord = diagram_rect_.topLeft().x()
|
||||||
* Createdxf::xScale;
|
* Createdxf::xScale;
|
||||||
double yCoord = Createdxf::sheetHeight
|
double yCoord = Createdxf::sheetHeight
|
||||||
- diagram_rect_.topLeft().y()
|
- diagram_rect_.topLeft().y()
|
||||||
*Createdxf::yScale
|
*Createdxf::yScale
|
||||||
- (
|
- (
|
||||||
columns_header_height_
|
columns_header_height_
|
||||||
@@ -722,17 +722,17 @@ void BorderTitleBlock::drawDxf(
|
|||||||
//qp -> translate(titleblock_rect_.topLeft());
|
//qp -> translate(titleblock_rect_.topLeft());
|
||||||
QRectF rect = titleBlockRect();
|
QRectF rect = titleBlockRect();
|
||||||
m_titleblock_template_renderer -> renderDxf(rect,
|
m_titleblock_template_renderer -> renderDxf(rect,
|
||||||
rect.width(),
|
rect.width(),
|
||||||
file_path,
|
file_path,
|
||||||
color);
|
color);
|
||||||
//qp -> translate(-titleblock_rect_.topLeft());
|
//qp -> translate(-titleblock_rect_.topLeft());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transform back to QET scale
|
// Transform back to QET scale
|
||||||
columns_header_height_ /= Createdxf::yScale;
|
columns_header_height_ /= Createdxf::yScale;
|
||||||
rows_height_ /= Createdxf::yScale;
|
rows_height_ /= Createdxf::yScale;
|
||||||
rows_header_width_ /= Createdxf::xScale;
|
rows_header_width_ /= Createdxf::xScale;
|
||||||
columns_width_ /= Createdxf::xScale;
|
columns_width_ /= Createdxf::xScale;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -852,7 +852,7 @@ void BorderTitleBlock::setRowsHeaderWidth(const qreal &new_rhw) {
|
|||||||
\~ @param height :
|
\~ @param height :
|
||||||
*/
|
*/
|
||||||
void BorderTitleBlock::setDiagramHeight(const qreal &height) {
|
void BorderTitleBlock::setDiagramHeight(const qreal &height) {
|
||||||
// size of rows to use = rows_height
|
// size of rows to use = rows_height
|
||||||
// taille des lignes a utiliser = rows_height
|
// taille des lignes a utiliser = rows_height
|
||||||
setRowsCount(qRound(ceil(height / rows_height_)));
|
setRowsCount(qRound(ceil(height / rows_height_)));
|
||||||
}
|
}
|
||||||
@@ -870,7 +870,7 @@ DiagramPosition BorderTitleBlock::convertPosition(const QPointF &pos)
|
|||||||
return (DiagramPosition("", 0));
|
return (DiagramPosition("", 0));
|
||||||
|
|
||||||
QPointF relative_pos = pos - insideBorderRect().topLeft();
|
QPointF relative_pos = pos - insideBorderRect().topLeft();
|
||||||
int row_number = int(ceil(relative_pos.x() / columnsWidth()));
|
int row_number = int(ceil(relative_pos.x() / columnsWidth()));
|
||||||
int column_number = int(ceil(relative_pos.y() / rowsHeight()));
|
int column_number = int(ceil(relative_pos.y() / rowsHeight()));
|
||||||
|
|
||||||
QString letter = "A";
|
QString letter = "A";
|
||||||
@@ -938,18 +938,18 @@ void BorderTitleBlock::updateDiagramContextForTitleBlock(
|
|||||||
// ... overridden by the historical and/or dynamically generated fields
|
// ... overridden by the historical and/or dynamically generated fields
|
||||||
QLocale var;
|
QLocale var;
|
||||||
var.dateFormat(QLocale::ShortFormat);
|
var.dateFormat(QLocale::ShortFormat);
|
||||||
context.addValue("author", btb_author_);
|
context.addValue("author", btb_author_);
|
||||||
context.addValue(
|
context.addValue(
|
||||||
"date",
|
"date",
|
||||||
QLocale::system().toString(btb_date_, QLocale::ShortFormat));
|
QLocale::system().toString(btb_date_, QLocale::ShortFormat));
|
||||||
context.addValue("title", btb_title_);
|
context.addValue("title", btb_title_);
|
||||||
context.addValue("filename", btb_filename_);
|
context.addValue("filename", btb_filename_);
|
||||||
context.addValue("plant", btb_plant_);
|
context.addValue("plant", btb_plant_);
|
||||||
context.addValue("locmach", btb_locmach_);
|
context.addValue("locmach", btb_locmach_);
|
||||||
context.addValue("indexrev", btb_indexrev_);
|
context.addValue("indexrev", btb_indexrev_);
|
||||||
context.addValue("version", btb_version_);
|
context.addValue("version", btb_version_);
|
||||||
context.addValue("folio", btb_final_folio_);
|
context.addValue("folio", btb_final_folio_);
|
||||||
context.addValue("folio-id", folio_index_);
|
context.addValue("folio-id", folio_index_);
|
||||||
context.addValue("folio-total", folio_total_);
|
context.addValue("folio-total", folio_total_);
|
||||||
context.addValue("auto_page_num", btb_auto_page_num_);
|
context.addValue("auto_page_num", btb_auto_page_num_);
|
||||||
context.addValue("previous-folio-num", m_previous_folio_num);
|
context.addValue("previous-folio-num", m_previous_folio_num);
|
||||||
@@ -1020,7 +1020,7 @@ void BorderTitleBlock::setFolioData(
|
|||||||
btb_final_folio_.replace("%autonum", autonum);
|
btb_final_folio_.replace("%autonum", autonum);
|
||||||
btb_folio_ = btb_final_folio_;
|
btb_folio_ = btb_final_folio_;
|
||||||
}
|
}
|
||||||
btb_final_folio_.replace("%id", QString::number(folio_index_));
|
btb_final_folio_.replace("%id", QString::number(folio_index_));
|
||||||
btb_final_folio_.replace("%total", QString::number(folio_total_));
|
btb_final_folio_.replace("%total", QString::number(folio_total_));
|
||||||
|
|
||||||
updateDiagramContextForTitleBlock(project_properties);
|
updateDiagramContextForTitleBlock(project_properties);
|
||||||
|
|||||||
@@ -173,7 +173,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 &);
|
void titleBlockToXml(QDomElement &doc);
|
||||||
void titleBlockFromXml(const QDomElement &);
|
void titleBlockFromXml(const QDomElement &);
|
||||||
void borderToXml(QDomElement &);
|
void borderToXml(QDomElement &);
|
||||||
void borderFromXml(const QDomElement &);
|
void borderFromXml(const QDomElement &);
|
||||||
@@ -248,34 +248,34 @@ class BorderTitleBlock : public QObject
|
|||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
// titleblock basic data
|
// titleblock basic data
|
||||||
QString btb_author_; ///< titleblock author
|
QString btb_author_; ///< titleblock author
|
||||||
QDate btb_date_; ///< titleblock date
|
QDate btb_date_; ///< titleblock date
|
||||||
QString btb_title_; ///< titleblock title
|
QString btb_title_; ///< titleblock title
|
||||||
QString btb_folio_; ///< titleblock folio
|
QString btb_folio_; ///< titleblock folio
|
||||||
QString btb_plant_; ///< titleblock plant
|
QString btb_plant_; ///< titleblock plant
|
||||||
QString btb_locmach_; ///< titleblock locmach
|
QString btb_locmach_; ///< titleblock locmach
|
||||||
QString btb_indexrev_; ///< titleblock index rev
|
QString btb_indexrev_; ///< titleblock index rev
|
||||||
QString btb_final_folio_; ///< titleblock final folio
|
QString btb_final_folio_; ///< titleblock final folio
|
||||||
QString btb_auto_page_num_; ///< titleblock auto page num
|
QString btb_auto_page_num_; ///< titleblock auto page num
|
||||||
int folio_index_; ///< titleblock index
|
int folio_index_; ///< titleblock index
|
||||||
int folio_total_; ///< titleblock total
|
int folio_total_; ///< titleblock total
|
||||||
QString btb_filename_; ///< titleblock filename
|
QString btb_filename_; ///< titleblock filename
|
||||||
QString btb_version_; ///< titleblock version
|
QString btb_version_; ///< titleblock version
|
||||||
/// titleblock additional fields
|
/// titleblock additional fields
|
||||||
DiagramContext additional_fields_;
|
DiagramContext additional_fields_;
|
||||||
Qt::Edge m_edge; ///< titleblock edge
|
Qt::Edge m_edge; ///< titleblock edge
|
||||||
QString m_next_folio_num; ///< titleblock next folio num
|
QString m_next_folio_num; ///< titleblock next folio num
|
||||||
QString m_previous_folio_num; ///< titleblock previous folio num
|
QString m_previous_folio_num; ///< titleblock previous folio num
|
||||||
|
|
||||||
// border dimensions (rows and columns)
|
// border dimensions (rows and columns)
|
||||||
// columns: number and dimensions
|
// columns: number and dimensions
|
||||||
int columns_count_; ///< columns count
|
int columns_count_; ///< columns count
|
||||||
qreal columns_width_; ///< columns width
|
qreal columns_width_; ///< columns width
|
||||||
qreal columns_header_height_; ///< columns header height
|
qreal columns_header_height_; ///< columns header height
|
||||||
|
|
||||||
// rows: number and dimensions
|
// rows: number and dimensions
|
||||||
int rows_count_; ///< rows count
|
int rows_count_; ///< rows count
|
||||||
qreal rows_height_; ///< rows height
|
qreal rows_height_; ///< rows height
|
||||||
qreal rows_header_width_; ///< rows header width
|
qreal rows_header_width_; ///< rows header width
|
||||||
|
|
||||||
// title block dimensions
|
// title block dimensions
|
||||||
|
|||||||
@@ -23,11 +23,7 @@
|
|||||||
/**
|
/**
|
||||||
Constructeur par defaut
|
Constructeur par defaut
|
||||||
*/
|
*/
|
||||||
SingleLineProperties::SingleLineProperties() :
|
SingleLineProperties::SingleLineProperties()
|
||||||
hasGround(true),
|
|
||||||
hasNeutral(true),
|
|
||||||
is_pen(false),
|
|
||||||
phases(1)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,9 +119,9 @@ void SingleLineProperties::draw(QPainter *painter,
|
|||||||
@param size taille du segment
|
@param size taille du segment
|
||||||
*/
|
*/
|
||||||
void SingleLineProperties::drawGround(QPainter *painter,
|
void SingleLineProperties::drawGround(QPainter *painter,
|
||||||
QET::ConductorSegmentType direction,
|
QET::ConductorSegmentType direction,
|
||||||
QPointF center,
|
QPointF center,
|
||||||
qreal size) {
|
qreal size) {
|
||||||
painter -> save();
|
painter -> save();
|
||||||
|
|
||||||
// prepare le QPainter
|
// prepare le QPainter
|
||||||
@@ -215,12 +211,17 @@ 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
|
QDomElement SingleLineProperties::toXml(QDomDocument &doc) const {
|
||||||
{
|
|
||||||
e.setAttribute("ground", hasGround ? "true" : "false");
|
QDomElement e = doc.createElement("SingleLine");
|
||||||
e.setAttribute("neutral", hasNeutral ? "true" : "false");
|
e.appendChild(createXmlProperty(doc, "ground", hasGround));
|
||||||
e.setAttribute("phase", phases);
|
e.appendChild(createXmlProperty(doc, "neutral", hasNeutral));
|
||||||
if (isPen()) e.setAttribute("pen", "true");
|
e.appendChild(createXmlProperty(doc, "phase", phases));
|
||||||
|
|
||||||
|
if (isPen())
|
||||||
|
e.appendChild(createXmlProperty(doc, "pen", true));
|
||||||
|
|
||||||
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -228,11 +229,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::fromXml(const QDomElement &e) {
|
||||||
hasGround = e.attribute("ground") == "true";
|
if (propertyBool(e, "ground", &hasGround) != PropertyFlags::Success ||
|
||||||
hasNeutral = e.attribute("neutral") == "true";
|
propertyBool(e, "neutral", &hasNeutral) != PropertyFlags::Success)
|
||||||
setPhasesCount(e.attribute("phase").toInt());
|
return false;
|
||||||
is_pen = (hasGround && hasNeutral && e.attribute("pen", "false") == "true");
|
|
||||||
|
int phase;
|
||||||
|
if (propertyInteger(e, "phase", &phase) != PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
setPhasesCount(phase);
|
||||||
|
|
||||||
|
bool pen;
|
||||||
|
if (propertyBool(e, "pen", &pen) != PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
is_pen = (hasGround && hasNeutral && pen);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SingleLineProperties::valideXml(QDomElement& e) {
|
||||||
|
if (propertyBool(e, "ground") != PropertyFlags::Success ||
|
||||||
|
propertyBool(e, "neutral") != PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (propertyInteger(e, "phase") != PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (propertyBool(e, "pen") != PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -266,116 +292,138 @@ 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
|
QDomElement ConductorProperties::toXml(QDomDocument& doc) const
|
||||||
{
|
{
|
||||||
e.setAttribute("type", typeToString(type));
|
|
||||||
|
|
||||||
if (color != QColor(Qt::black))
|
QDomElement e = doc.createElement("defaultconductor");
|
||||||
e.setAttribute("color", color.name());
|
|
||||||
|
|
||||||
e.setAttribute("bicolor", m_bicolor? "true" : "false");
|
e.appendChild(createXmlProperty(doc, "type", typeToString(type)));
|
||||||
e.setAttribute("color2", m_color_2.name());
|
e.appendChild(createXmlProperty(doc, "color", color));
|
||||||
e.setAttribute("dash-size", QString::number(m_dash_size));
|
|
||||||
|
e.appendChild(createXmlProperty(doc, "bicolor", m_bicolor));
|
||||||
|
e.appendChild(createXmlProperty(doc, "color2", m_color_2));
|
||||||
|
e.appendChild(createXmlProperty(doc, "dash-size", m_dash_size));
|
||||||
|
|
||||||
if (type == Single)
|
if (type == Single)
|
||||||
singleLineProperties.toXml(e);
|
e.appendChild(singleLineProperties.toXml(doc));
|
||||||
|
|
||||||
e.setAttribute("num", text);
|
|
||||||
e.setAttribute("text_color", text_color.name());
|
|
||||||
e.setAttribute("formula", m_formula);
|
|
||||||
e.setAttribute("cable", m_cable);
|
|
||||||
e.setAttribute("bus", m_bus);
|
|
||||||
e.setAttribute("function", m_function);
|
|
||||||
e.setAttribute("tension_protocol", m_tension_protocol);
|
|
||||||
e.setAttribute("conductor_color", m_wire_color);
|
|
||||||
e.setAttribute("conductor_section", m_wire_section);
|
|
||||||
e.setAttribute("numsize", QString::number(text_size));
|
|
||||||
e.setAttribute("condsize", QString::number(cond_size));
|
|
||||||
e.setAttribute("displaytext", m_show_text);
|
|
||||||
e.setAttribute("onetextperfolio", m_one_text_per_folio);
|
|
||||||
e.setAttribute("vertirotatetext", QString::number(verti_rotate_text));
|
|
||||||
e.setAttribute("horizrotatetext", QString::number(horiz_rotate_text));
|
|
||||||
|
|
||||||
|
e.appendChild(createXmlProperty(doc, "num", text));
|
||||||
|
e.appendChild(createXmlProperty(doc, "text_color", text_color));
|
||||||
|
e.appendChild(createXmlProperty(doc, "formula", m_formula));
|
||||||
|
e.appendChild(createXmlProperty(doc, "function", m_function));
|
||||||
|
e.appendChild(createXmlProperty(doc, "tension_protocol", m_tension_protocol));
|
||||||
|
e.appendChild(createXmlProperty(doc, "conductor_color", m_wire_color));
|
||||||
|
e.appendChild(createXmlProperty(doc, "conductor_section", m_wire_section));
|
||||||
|
e.appendChild(createXmlProperty(doc, "numsize", text_size));
|
||||||
|
e.appendChild(createXmlProperty(doc, "condsize", cond_size));
|
||||||
|
e.appendChild(createXmlProperty(doc, "displaytext", m_show_text));
|
||||||
|
e.appendChild(createXmlProperty(doc, "onetextperfolio", m_one_text_per_folio));
|
||||||
|
e.appendChild(createXmlProperty(doc, "onetextperfolio", verti_rotate_text));
|
||||||
|
e.appendChild(createXmlProperty(doc, "horizrotatetext", horiz_rotate_text));
|
||||||
|
// TODO: implement
|
||||||
|
//e.setAttribute("cable", m_cable);
|
||||||
|
// e.setAttribute("bus", m_bus);
|
||||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
e.setAttribute("horizontal-alignment", me.valueToKey(m_horizontal_alignment));
|
e.appendChild(createXmlProperty(doc, "horizontal-alignment", me.valueToKey(m_horizontal_alignment)));
|
||||||
e.setAttribute("vertical-alignment", me.valueToKey(m_vertical_alignment));
|
e.appendChild(createXmlProperty(doc, "vertical-alignment", me.valueToKey(m_vertical_alignment)));
|
||||||
|
|
||||||
QString conductor_style = writeStyle();
|
QString conductor_style = writeStyle();
|
||||||
if (!conductor_style.isEmpty())
|
if (!conductor_style.isEmpty())
|
||||||
e.setAttribute("style", conductor_style);
|
e.appendChild(createXmlProperty(doc, "style", conductor_style));
|
||||||
|
|
||||||
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** 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::fromXml(const QDomElement &e)
|
||||||
{
|
{
|
||||||
// get conductor color
|
// get conductor color
|
||||||
QColor xml_color= QColor(e.attribute("color"));
|
propertyColor(e, "color", &color);
|
||||||
color = (xml_color.isValid()? xml_color : QColor(Qt::black));
|
propertyBool(e, "bicolor", &m_bicolor);
|
||||||
|
propertyColor(e, "color2", &m_color_2);
|
||||||
QString bicolor_str = e.attribute("bicolor", "false");
|
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;
|
||||||
|
propertyString(e, "style", &style_string);
|
||||||
|
readStyle(style_string);
|
||||||
|
|
||||||
if (e.attribute("type") == typeToString(Single))
|
QString type_t;
|
||||||
|
if (propertyString(e, "type", &type_t) == 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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"));
|
propertyColor(e, "text_color", &text_color);
|
||||||
text_color = (xml_text_color.isValid()? xml_text_color : QColor(Qt::black));
|
propertyString(e, "formula", &m_formula);
|
||||||
m_formula = e.attribute("formula");
|
propertyString(e, "function", &m_function);
|
||||||
m_cable = e.attribute("cable");
|
propertyString(e, "tension_protocol", &m_tension_protocol);
|
||||||
m_bus = e.attribute("bus");
|
propertyString(e, "conductor_color", &m_wire_color);
|
||||||
m_function = e.attribute("function");
|
propertyString(e, "conductor_section", &m_wire_section);
|
||||||
m_tension_protocol = e.attribute("tension_protocol");
|
propertyInteger(e, "numsize", &text_size);
|
||||||
m_wire_color = e.attribute("conductor_color");
|
propertyDouble(e, "condsize", &cond_size);
|
||||||
m_wire_section = e.attribute("conductor_section");
|
propertyBool(e, "displaytext", &m_show_text);
|
||||||
text_size = e.attribute("numsize", QString::number(9)).toInt();
|
propertyBool(e, "onetextperfolio", &m_one_text_per_folio);
|
||||||
cond_size = e.attribute("condsize", QString::number(1)).toDouble();
|
propertyDouble(e, "vertirotatetext", &verti_rotate_text);
|
||||||
m_show_text = e.attribute("displaytext", QString::number(1)).toInt();
|
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(
|
|
||||||
me.keyToValue(
|
|
||||||
e.attribute(
|
|
||||||
"horizontal-alignment",
|
|
||||||
"AlignBottom"
|
|
||||||
).toStdString().data()));
|
|
||||||
m_vertical_alignment = Qt::Alignment(
|
|
||||||
me.keyToValue(
|
|
||||||
e.attribute(
|
|
||||||
"vertical-alignment",
|
|
||||||
"AlignRight"
|
|
||||||
).toStdString().data()));
|
|
||||||
|
|
||||||
//Keep retrocompatible with version older than 0,4
|
QString alinment_temp;
|
||||||
//If the propertie @type is simple (removed since QET 0,4), we set text no visible.
|
if (propertyString(e, "horizontal-alignment", &alinment_temp) == PropertyFlags::Success)
|
||||||
//@TODO remove this code for qet 0.6 or later
|
m_horizontal_alignment = Qt::Alignment(me.keyToValue(alinment_temp.toStdString().data()));
|
||||||
#if TODO_LIST
|
if (propertyString(e, "vertical-alignment", &alinment_temp) == PropertyFlags::Success)
|
||||||
#pragma message("@TODO remove this code for qet 0.6 or later")
|
m_vertical_alignment = Qt::Alignment(me.keyToValue(alinment_temp.toStdString().data()));
|
||||||
#endif
|
|
||||||
if (e.attribute("type") == "simple") m_show_text = false;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ConductorProperties::valideXml(QDomElement& e) {
|
||||||
|
if (propertyColor(e, "color") ||
|
||||||
|
propertyBool(e, "bicolor") ||
|
||||||
|
propertyColor(e, "color2") ||
|
||||||
|
propertyInteger(e, "dash-size") ||
|
||||||
|
propertyString(e, "type") ||
|
||||||
|
propertyString(e, "num") ||
|
||||||
|
propertyColor(e, "text_color") ||
|
||||||
|
propertyString(e, "formula") ||
|
||||||
|
propertyString(e, "function") ||
|
||||||
|
propertyString(e, "tension_protocol") ||
|
||||||
|
propertyString(e, "conductor_color") ||
|
||||||
|
propertyString(e, "conductor_section") ||
|
||||||
|
propertyInteger(e, "numsize") ||
|
||||||
|
propertyDouble(e, "condsize") ||
|
||||||
|
propertyBool(e, "displaytext") ||
|
||||||
|
propertyBool(e, "onetextperfolio") ||
|
||||||
|
propertyDouble(e, "vertirotatetext") ||
|
||||||
|
propertyDouble(e, "horizrotatetext") ||
|
||||||
|
propertyString(e, "horizontal-alignment") ||
|
||||||
|
propertyString(e, "vertical-alignment"))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -433,22 +481,22 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
|
|||||||
|
|
||||||
singleLineProperties.fromSettings(settings, prefix);
|
singleLineProperties.fromSettings(settings, prefix);
|
||||||
|
|
||||||
text = settings.value(prefix + "text", "_").toString();
|
text = settings.value(prefix + "text", "_").toString();
|
||||||
QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString());
|
QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString());
|
||||||
text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black));
|
text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black));
|
||||||
m_formula = settings.value(prefix + "formula", "").toString();
|
m_formula = settings.value(prefix + "formula", "").toString();
|
||||||
m_cable = settings.value(prefix + "cable", "").toString();
|
m_cable = settings.value(prefix + "cable", "").toString();
|
||||||
m_bus = settings.value(prefix + "bus", "").toString();
|
m_bus = settings.value(prefix + "bus", "").toString();
|
||||||
m_function = settings.value(prefix + "function", "").toString();
|
m_function = settings.value(prefix + "function", "").toString();
|
||||||
m_tension_protocol = settings.value(prefix + "tension_protocol", "").toString();
|
m_tension_protocol = settings.value(prefix + "tension_protocol", "").toString();
|
||||||
m_wire_color = settings.value(prefix + "conductor_color", "").toString();
|
m_wire_color = settings.value(prefix + "conductor_color", "").toString();
|
||||||
m_wire_section = settings.value(prefix + "conductor_section", "").toString();
|
m_wire_section = settings.value(prefix + "conductor_section", "").toString();
|
||||||
text_size = settings.value(prefix + "textsize", "7").toInt();
|
text_size = settings.value(prefix + "textsize", "7").toInt();
|
||||||
cond_size = settings.value(prefix + "size", "1").toInt();
|
cond_size = settings.value(prefix + "size", "1").toInt();
|
||||||
m_show_text = settings.value(prefix + "displaytext", true).toBool();
|
m_show_text = settings.value(prefix + "displaytext", true).toBool();
|
||||||
m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
|
m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
|
||||||
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
||||||
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
||||||
|
|
||||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "horizontal-alignment", "AlignBottom").toString().toStdString().data()));
|
m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "horizontal-alignment", "AlignBottom").toString().toStdString().data()));
|
||||||
@@ -486,25 +534,25 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
|
|||||||
if (clist.size() == 1)
|
if (clist.size() == 1)
|
||||||
{
|
{
|
||||||
ConductorProperties cp = clist.first();
|
ConductorProperties cp = clist.first();
|
||||||
color = cp.color;
|
color = cp.color;
|
||||||
m_bicolor = cp.m_bicolor;
|
m_bicolor = cp.m_bicolor;
|
||||||
m_color_2 = cp.m_color_2;
|
m_color_2 = cp.m_color_2;
|
||||||
m_dash_size = cp.m_dash_size;
|
m_dash_size = cp.m_dash_size;
|
||||||
text = cp.text;
|
text = cp.text;
|
||||||
text_color = cp.text_color;
|
text_color = cp.text_color;
|
||||||
m_formula = cp.m_formula;
|
m_formula = cp.m_formula;
|
||||||
m_cable = cp.m_cable;
|
m_cable = cp.m_cable;
|
||||||
m_bus = cp.m_bus;
|
m_bus = cp.m_bus;
|
||||||
m_function = cp.m_function;
|
m_function = cp.m_function;
|
||||||
m_tension_protocol = cp.m_tension_protocol;
|
m_tension_protocol = cp.m_tension_protocol;
|
||||||
m_wire_color = cp.m_wire_color;
|
m_wire_color = cp.m_wire_color;
|
||||||
m_wire_section = cp.m_wire_section;
|
m_wire_section = cp.m_wire_section;
|
||||||
text_size = cp.text_size;
|
text_size = cp.text_size;
|
||||||
cond_size = cp.cond_size;
|
cond_size = cp.cond_size;
|
||||||
m_show_text = cp.m_show_text;
|
m_show_text = cp.m_show_text;
|
||||||
m_one_text_per_folio = cp.m_one_text_per_folio;
|
m_one_text_per_folio = cp.m_one_text_per_folio;
|
||||||
verti_rotate_text = cp.verti_rotate_text;
|
verti_rotate_text = cp.verti_rotate_text;
|
||||||
horiz_rotate_text = cp.horiz_rotate_text;
|
horiz_rotate_text = cp.horiz_rotate_text;
|
||||||
m_vertical_alignment = cp.m_vertical_alignment;
|
m_vertical_alignment = cp.m_vertical_alignment;
|
||||||
m_horizontal_alignment = cp.m_horizontal_alignment;
|
m_horizontal_alignment = cp.m_horizontal_alignment;
|
||||||
|
|
||||||
@@ -842,7 +890,7 @@ void ConductorProperties::readStyle(const QString &style_string) {
|
|||||||
if (!match.hasMatch())
|
if (!match.hasMatch())
|
||||||
{
|
{
|
||||||
qDebug()<<"no Match"
|
qDebug()<<"no Match"
|
||||||
<<style_str;
|
<<style_str;
|
||||||
} else {
|
} else {
|
||||||
QString style_name = match.captured("name");
|
QString style_name = match.captured("name");
|
||||||
QString style_value = match.captured("value");
|
QString style_value = match.captured("value");
|
||||||
@@ -902,12 +950,12 @@ int SingleLineProperties::operator!=(const SingleLineProperties &other) const
|
|||||||
@param prefix prefix a ajouter devant les noms des parametres
|
@param prefix prefix a ajouter devant les noms des parametres
|
||||||
*/
|
*/
|
||||||
void SingleLineProperties::toSettings(QSettings &settings,
|
void SingleLineProperties::toSettings(QSettings &settings,
|
||||||
const QString &prefix) const
|
const QString &prefix) const
|
||||||
{
|
{
|
||||||
settings.setValue(prefix + "hasGround", hasGround);
|
settings.setValue(prefix + "hasGround", hasGround);
|
||||||
settings.setValue(prefix + "hasNeutral", hasNeutral);
|
settings.setValue(prefix + "hasNeutral", hasNeutral);
|
||||||
settings.setValue(prefix + "phases", phases);
|
settings.setValue(prefix + "phases", phases);
|
||||||
settings.setValue(prefix + "pen", is_pen);
|
settings.setValue(prefix + "pen", is_pen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -918,6 +966,6 @@ void SingleLineProperties::fromSettings(QSettings &settings,
|
|||||||
const QString &prefix) {
|
const QString &prefix) {
|
||||||
hasGround = settings.value(prefix + "hasGround", true).toBool();
|
hasGround = settings.value(prefix + "hasGround", true).toBool();
|
||||||
hasNeutral = settings.value(prefix + "hasNeutral", true).toBool();
|
hasNeutral = settings.value(prefix + "hasNeutral", true).toBool();
|
||||||
phases = settings.value(prefix + "phases", 1).toInt();
|
phases = settings.value(prefix + "phases", 1).toInt();
|
||||||
is_pen = settings.value(prefix + "pen", false).toBool();
|
is_pen = settings.value(prefix + "pen", false).toBool();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,13 +22,15 @@
|
|||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
#include "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;
|
QDomElement toXml(QDomDocument& doc) const override;
|
||||||
void fromXml(QDomElement &);
|
bool fromXml(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,12 +83,12 @@ class ConductorProperties
|
|||||||
|
|
||||||
|
|
||||||
//Attributes
|
//Attributes
|
||||||
ConductorType type;
|
ConductorType type{ConductorType::Single};
|
||||||
|
|
||||||
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,
|
||||||
@@ -97,33 +100,32 @@ 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,
|
||||||
horiz_rotate_text;
|
horiz_rotate_text;
|
||||||
|
|
||||||
bool
|
bool m_show_text{true},
|
||||||
m_show_text,
|
m_one_text_per_folio{true},
|
||||||
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;
|
QDomElement toXml(QDomDocument &doc) const override;
|
||||||
void fromXml(QDomElement &);
|
bool fromXml(const QDomElement &) override;
|
||||||
void toSettings(QSettings &, const QString & = QString()) const;
|
static bool valideXml(QDomElement& element);
|
||||||
void fromSettings(QSettings &, const QString & = QString());
|
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||||
|
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);
|
||||||
|
|
||||||
|
|||||||
@@ -62,11 +62,11 @@ QColor Diagram::background_color = Qt::white;
|
|||||||
@param project : The project of this diagram and also parent QObject
|
@param project : The project of this diagram and also parent QObject
|
||||||
*/
|
*/
|
||||||
Diagram::Diagram(QETProject *project) :
|
Diagram::Diagram(QETProject *project) :
|
||||||
QGraphicsScene (project),
|
QGraphicsScene (project),
|
||||||
m_project (project),
|
m_project (project),
|
||||||
draw_grid_ (true),
|
draw_grid_ (true),
|
||||||
use_border_ (true),
|
use_border_ (true),
|
||||||
draw_terminals_ (true),
|
draw_terminals_ (true),
|
||||||
draw_colored_conductors_ (true),
|
draw_colored_conductors_ (true),
|
||||||
m_event_interface (nullptr),
|
m_event_interface (nullptr),
|
||||||
m_freeze_new_elements (false),
|
m_freeze_new_elements (false),
|
||||||
@@ -178,7 +178,7 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
|||||||
*/
|
*/
|
||||||
QPen pen;
|
QPen pen;
|
||||||
Diagram::background_color == Qt::black? pen.setColor(Qt::white)
|
Diagram::background_color == Qt::black? pen.setColor(Qt::white)
|
||||||
: pen.setColor(Qt::black);
|
: pen.setColor(Qt::black);
|
||||||
pen.setCosmetic(true);
|
pen.setCosmetic(true);
|
||||||
p->setPen(pen);
|
p->setPen(pen);
|
||||||
|
|
||||||
@@ -324,9 +324,9 @@ void Diagram::keyPressEvent(QKeyEvent *event)
|
|||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
int xKeyGrid = settings.value("diagrameditor/key_Xgrid",
|
int xKeyGrid = settings.value("diagrameditor/key_Xgrid",
|
||||||
Diagram::xKeyGrid).toInt();
|
Diagram::xKeyGrid).toInt();
|
||||||
int yKeyGrid = settings.value("diagrameditor/key_Ygrid",
|
int yKeyGrid = settings.value("diagrameditor/key_Ygrid",
|
||||||
Diagram::yKeyGrid).toInt();
|
Diagram::yKeyGrid).toInt();
|
||||||
int xKeyGridFine = settings.value("diagrameditor/key_fine_Xgrid",
|
int xKeyGridFine = settings.value("diagrameditor/key_fine_Xgrid",
|
||||||
Diagram::xKeyGridFine).toInt();
|
Diagram::xKeyGridFine).toInt();
|
||||||
int yKeyGridFine = settings.value("diagrameditor/key_fine_Ygrid",
|
int yKeyGridFine = settings.value("diagrameditor/key_fine_Ygrid",
|
||||||
@@ -581,9 +581,9 @@ void Diagram::setConductorsAutonumName(const QString &name) {
|
|||||||
@return Une QImage representant le schema
|
@return Une QImage representant le schema
|
||||||
*/
|
*/
|
||||||
bool Diagram::toPaintDevice(QPaintDevice &pix,
|
bool Diagram::toPaintDevice(QPaintDevice &pix,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
Qt::AspectRatioMode aspectRatioMode) {
|
Qt::AspectRatioMode aspectRatioMode) {
|
||||||
// determine the source area = schema content + margins
|
// determine the source area = schema content + margins
|
||||||
// determine la zone source = contenu du schema + marges
|
// determine la zone source = contenu du schema + marges
|
||||||
QRectF source_area;
|
QRectF source_area;
|
||||||
@@ -630,9 +630,9 @@ bool Diagram::toPaintDevice(QPaintDevice &pix,
|
|||||||
// renders itself
|
// renders itself
|
||||||
// effectue le rendu lui-meme
|
// effectue le rendu lui-meme
|
||||||
render(&p,
|
render(&p,
|
||||||
QRect(QPoint(0, 0),image_size),
|
QRect(QPoint(0, 0),image_size),
|
||||||
source_area,
|
source_area,
|
||||||
aspectRatioMode);
|
aspectRatioMode);
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
// restore selected items
|
// restore selected items
|
||||||
@@ -735,29 +735,28 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
// schema properties
|
// schema properties
|
||||||
// proprietes du schema
|
// proprietes du schema
|
||||||
if (whole_content) {
|
if (whole_content) {
|
||||||
|
// TODO: compare with old version
|
||||||
border_and_titleblock.titleBlockToXml(dom_root);
|
border_and_titleblock.titleBlockToXml(dom_root);
|
||||||
border_and_titleblock.borderToXml(dom_root);
|
border_and_titleblock.borderToXml(dom_root);
|
||||||
|
|
||||||
// Default conductor properties
|
// Default conductor properties
|
||||||
QDomElement default_conductor =
|
dom_root.appendChild(defaultConductorProperties.toXml(document));
|
||||||
document.createElement("defaultconductor");
|
document.createElement("defaultconductor");
|
||||||
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()) {
|
||||||
dom_root.setAttribute("conductorAutonum",
|
dom_root.setAttribute("conductorAutonum",
|
||||||
m_conductors_autonum_name);
|
m_conductors_autonum_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Default New Element
|
//Default New Element
|
||||||
dom_root.setAttribute("freezeNewElement",
|
dom_root.setAttribute("freezeNewElement",
|
||||||
m_freeze_new_elements ? "true" : "false");
|
m_freeze_new_elements ? "true" : "false");
|
||||||
|
|
||||||
//Default New Conductor
|
//Default New Conductor
|
||||||
dom_root.setAttribute("freezeNewConductor",
|
dom_root.setAttribute("freezeNewConductor",
|
||||||
m_freeze_new_conductors_
|
m_freeze_new_conductors_
|
||||||
? "true" : "false");
|
? "true" : "false");
|
||||||
|
|
||||||
//Element Folio Sequential Variables
|
//Element Folio Sequential Variables
|
||||||
if (!m_elmt_unitfolio_max.isEmpty()
|
if (!m_elmt_unitfolio_max.isEmpty()
|
||||||
@@ -771,10 +770,10 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
document.createElement(
|
document.createElement(
|
||||||
"elementunitfolioseq");
|
"elementunitfolioseq");
|
||||||
folioSequentialsToXml(&m_elmt_unitfolio_max,
|
folioSequentialsToXml(&m_elmt_unitfolio_max,
|
||||||
&elmtfolioseq,
|
&elmtfolioseq,
|
||||||
"sequf_",
|
"sequf_",
|
||||||
"unitfolioseq",
|
"unitfolioseq",
|
||||||
&document);
|
&document);
|
||||||
elmtfoliosequential.appendChild(elmtfolioseq);
|
elmtfoliosequential.appendChild(elmtfolioseq);
|
||||||
}
|
}
|
||||||
if (!m_elmt_tenfolio_max.isEmpty()) {
|
if (!m_elmt_tenfolio_max.isEmpty()) {
|
||||||
@@ -782,10 +781,10 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
document.createElement(
|
document.createElement(
|
||||||
"elementtenfolioseq");
|
"elementtenfolioseq");
|
||||||
folioSequentialsToXml(&m_elmt_tenfolio_max,
|
folioSequentialsToXml(&m_elmt_tenfolio_max,
|
||||||
&elmtfolioseq,
|
&elmtfolioseq,
|
||||||
"seqtf_",
|
"seqtf_",
|
||||||
"tenfolioseq",
|
"tenfolioseq",
|
||||||
&document);
|
&document);
|
||||||
elmtfoliosequential.appendChild(elmtfolioseq);
|
elmtfoliosequential.appendChild(elmtfolioseq);
|
||||||
}
|
}
|
||||||
if (!m_elmt_hundredfolio_max.isEmpty()) {
|
if (!m_elmt_hundredfolio_max.isEmpty()) {
|
||||||
@@ -793,10 +792,10 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
document.createElement(
|
document.createElement(
|
||||||
"elementhundredfolioseq");
|
"elementhundredfolioseq");
|
||||||
folioSequentialsToXml(&m_elmt_hundredfolio_max,
|
folioSequentialsToXml(&m_elmt_hundredfolio_max,
|
||||||
&elmtfolioseq,
|
&elmtfolioseq,
|
||||||
"seqhf_",
|
"seqhf_",
|
||||||
"hundredfolioseq",
|
"hundredfolioseq",
|
||||||
&document);
|
&document);
|
||||||
elmtfoliosequential.appendChild(elmtfolioseq);
|
elmtfoliosequential.appendChild(elmtfolioseq);
|
||||||
}
|
}
|
||||||
dom_root.appendChild(elmtfoliosequential);
|
dom_root.appendChild(elmtfoliosequential);
|
||||||
@@ -814,10 +813,10 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
document.createElement(
|
document.createElement(
|
||||||
"conductorunitfolioseq");
|
"conductorunitfolioseq");
|
||||||
folioSequentialsToXml(&m_cnd_unitfolio_max,
|
folioSequentialsToXml(&m_cnd_unitfolio_max,
|
||||||
&cndfolioseq,
|
&cndfolioseq,
|
||||||
"sequf_",
|
"sequf_",
|
||||||
"unitfolioseq",
|
"unitfolioseq",
|
||||||
&document);
|
&document);
|
||||||
cndfoliosequential.appendChild(cndfolioseq);
|
cndfoliosequential.appendChild(cndfolioseq);
|
||||||
}
|
}
|
||||||
if (!m_cnd_tenfolio_max.isEmpty()) {
|
if (!m_cnd_tenfolio_max.isEmpty()) {
|
||||||
@@ -825,10 +824,10 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
document.createElement(
|
document.createElement(
|
||||||
"conductortenfolioseq");
|
"conductortenfolioseq");
|
||||||
folioSequentialsToXml(&m_cnd_tenfolio_max,
|
folioSequentialsToXml(&m_cnd_tenfolio_max,
|
||||||
&cndfolioseq,
|
&cndfolioseq,
|
||||||
"seqtf_",
|
"seqtf_",
|
||||||
"tenfolioseq",
|
"tenfolioseq",
|
||||||
&document);
|
&document);
|
||||||
cndfoliosequential.appendChild(cndfolioseq);
|
cndfoliosequential.appendChild(cndfolioseq);
|
||||||
}
|
}
|
||||||
if (!m_cnd_hundredfolio_max.isEmpty()) {
|
if (!m_cnd_hundredfolio_max.isEmpty()) {
|
||||||
@@ -836,10 +835,10 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
document.createElement(
|
document.createElement(
|
||||||
"conductorhundredfolioseq");
|
"conductorhundredfolioseq");
|
||||||
folioSequentialsToXml(&m_cnd_hundredfolio_max,
|
folioSequentialsToXml(&m_cnd_hundredfolio_max,
|
||||||
&cndfolioseq,
|
&cndfolioseq,
|
||||||
"seqhf_",
|
"seqhf_",
|
||||||
"hundredfolioseq",
|
"hundredfolioseq",
|
||||||
&document);
|
&document);
|
||||||
cndfoliosequential.appendChild(cndfolioseq);
|
cndfoliosequential.appendChild(cndfolioseq);
|
||||||
}
|
}
|
||||||
dom_root.appendChild(cndfoliosequential);
|
dom_root.appendChild(cndfoliosequential);
|
||||||
@@ -916,13 +915,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);
|
||||||
}
|
}
|
||||||
@@ -930,8 +927,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);
|
||||||
}
|
}
|
||||||
@@ -981,18 +977,18 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
|||||||
@param doc
|
@param doc
|
||||||
*/
|
*/
|
||||||
void Diagram::folioSequentialsToXml(QHash<QString,
|
void Diagram::folioSequentialsToXml(QHash<QString,
|
||||||
QStringList> *hash,
|
QStringList> *hash,
|
||||||
QDomElement *domElement,
|
QDomElement *domElement,
|
||||||
const QString& seq_type,
|
const QString& seq_type,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
QDomDocument *doc) {
|
QDomDocument *doc) {
|
||||||
QHash<QString, QStringList>::iterator i;
|
QHash<QString, QStringList>::iterator i;
|
||||||
for (i = hash->begin(); i != hash->end(); i++) {
|
for (i = hash->begin(); i != hash->end(); i++) {
|
||||||
QDomElement folioseq = doc->createElement(type);
|
QDomElement folioseq = doc->createElement(type);
|
||||||
folioseq.setAttribute("title", i.key());
|
folioseq.setAttribute("title", i.key());
|
||||||
for (int j = 0; j < i.value().size(); j++) {
|
for (int j = 0; j < i.value().size(); j++) {
|
||||||
folioseq.setAttribute(seq_type + QString::number(j+1),
|
folioseq.setAttribute(seq_type + QString::number(j+1),
|
||||||
i.value().at(j));
|
i.value().at(j));
|
||||||
}
|
}
|
||||||
domElement->appendChild(folioseq);
|
domElement->appendChild(folioseq);
|
||||||
}
|
}
|
||||||
@@ -1030,9 +1026,9 @@ void Diagram::folioSequentialsToXml(QHash<QString,
|
|||||||
\~French true si l'import a reussi, false sinon
|
\~French true si l'import a reussi, false sinon
|
||||||
*/
|
*/
|
||||||
bool Diagram::fromXml(QDomDocument &document,
|
bool Diagram::fromXml(QDomDocument &document,
|
||||||
QPointF position,
|
QPointF position,
|
||||||
bool consider_informations,
|
bool consider_informations,
|
||||||
DiagramContent *content_ptr) {
|
DiagramContent *content_ptr) {
|
||||||
QDomElement root = document.documentElement();
|
QDomElement root = document.documentElement();
|
||||||
return(fromXml(root, position, consider_informations, content_ptr));
|
return(fromXml(root, position, consider_informations, content_ptr));
|
||||||
}
|
}
|
||||||
@@ -1094,17 +1090,17 @@ 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) {
|
||||||
assert(conductor_index == 1 || conductor_index == 2);
|
assert(conductor_index == 1 || conductor_index == 2);
|
||||||
|
|
||||||
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 (PropertiesInterface::propertyUuid(conductor, element_index, &element_uuid) == PropertiesInterface::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;
|
||||||
@@ -1112,7 +1108,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;
|
||||||
|
PropertiesInterface::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;
|
||||||
@@ -1136,9 +1133,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 (PropertiesInterface::propertyInteger(conductor, terminal_index, &id_p1) != PropertiesInterface::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
|
||||||
@@ -1146,6 +1145,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1181,13 +1181,15 @@ Terminal* findTerminal(int conductor_index,
|
|||||||
\~French true si l'import a reussi, false sinon
|
\~French true si l'import a reussi, false sinon
|
||||||
*/
|
*/
|
||||||
bool Diagram::fromXml(QDomElement &document,
|
bool Diagram::fromXml(QDomElement &document,
|
||||||
QPointF position,
|
QPointF position,
|
||||||
bool consider_informations,
|
bool consider_informations,
|
||||||
DiagramContent *content_ptr) {
|
DiagramContent *content_ptr) {
|
||||||
const QDomElement& root = document;
|
const QDomElement& root = 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)
|
||||||
{
|
{
|
||||||
@@ -1203,6 +1205,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");
|
||||||
|
|
||||||
@@ -1256,7 +1259,7 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
if (root.hasAttribute("projectId")) {
|
if (root.hasAttribute("projectId")) {
|
||||||
QETProject *other_project = QETApp::project(
|
QETProject *other_project = QETApp::project(
|
||||||
root.attribute("projectId",
|
root.attribute("projectId",
|
||||||
"-1").toInt());
|
"-1").toInt());
|
||||||
|
|
||||||
/* We try to paste from another project,
|
/* We try to paste from another project,
|
||||||
* then befor paste elements,
|
* then befor paste elements,
|
||||||
@@ -1268,8 +1271,8 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
ElementCollectionHandler ech;
|
ElementCollectionHandler ech;
|
||||||
foreach (QDomElement element_xml,
|
foreach (QDomElement element_xml,
|
||||||
QET::findInDomElement(root,
|
QET::findInDomElement(root,
|
||||||
"elements",
|
"elements",
|
||||||
"element")) {
|
"element")) {
|
||||||
if (!Element::valideXml(element_xml)) continue;
|
if (!Element::valideXml(element_xml)) continue;
|
||||||
|
|
||||||
QString type_id = element_xml.attribute("type");
|
QString type_id = element_xml.attribute("type");
|
||||||
@@ -1279,7 +1282,7 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
type_id,
|
type_id,
|
||||||
other_project);
|
other_project);
|
||||||
ech.importFromProject(m_project,
|
ech.importFromProject(m_project,
|
||||||
location);
|
location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1325,7 +1328,7 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
removeItem(nvel_elmt);
|
removeItem(nvel_elmt);
|
||||||
delete nvel_elmt;
|
delete nvel_elmt;
|
||||||
qDebug() << "Diagram::fromXml() : Le chargement des "
|
qDebug() << "Diagram::fromXml() : Le chargement des "
|
||||||
"parametres d'un element a echoue";
|
"parametres d'un element a echoue";
|
||||||
} else {
|
} else {
|
||||||
added_elements << nvel_elmt;
|
added_elements << nvel_elmt;
|
||||||
}
|
}
|
||||||
@@ -1334,8 +1337,8 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
// Load text
|
// Load text
|
||||||
QList<IndependentTextItem *> added_texts;
|
QList<IndependentTextItem *> added_texts;
|
||||||
foreach (QDomElement text_xml, QET::findInDomElement(root,
|
foreach (QDomElement text_xml, QET::findInDomElement(root,
|
||||||
"inputs",
|
"inputs",
|
||||||
"input")) {
|
"input")) {
|
||||||
IndependentTextItem *iti = new IndependentTextItem();
|
IndependentTextItem *iti = new IndependentTextItem();
|
||||||
iti -> fromXml(text_xml);
|
iti -> fromXml(text_xml);
|
||||||
addItem(iti);
|
addItem(iti);
|
||||||
@@ -1345,8 +1348,8 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
// Load image
|
// Load image
|
||||||
QList<DiagramImageItem *> added_images;
|
QList<DiagramImageItem *> added_images;
|
||||||
foreach (QDomElement image_xml, QET::findInDomElement(root,
|
foreach (QDomElement image_xml, QET::findInDomElement(root,
|
||||||
"images",
|
"images",
|
||||||
"image")) {
|
"image")) {
|
||||||
DiagramImageItem *dii = new DiagramImageItem ();
|
DiagramImageItem *dii = new DiagramImageItem ();
|
||||||
dii -> fromXml(image_xml);
|
dii -> fromXml(image_xml);
|
||||||
addItem(dii);
|
addItem(dii);
|
||||||
@@ -1356,8 +1359,8 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
// Load shape
|
// Load shape
|
||||||
QList<QetShapeItem *> added_shapes;
|
QList<QetShapeItem *> added_shapes;
|
||||||
foreach (QDomElement shape_xml, QET::findInDomElement(root,
|
foreach (QDomElement shape_xml, QET::findInDomElement(root,
|
||||||
"shapes",
|
"shapes",
|
||||||
"shape")) {
|
"shape")) {
|
||||||
QetShapeItem *dii = new QetShapeItem (QPointF(0,0));
|
QetShapeItem *dii = new QetShapeItem (QPointF(0,0));
|
||||||
dii -> fromXml(shape_xml);
|
dii -> fromXml(shape_xml);
|
||||||
addItem(dii);
|
addItem(dii);
|
||||||
@@ -1367,8 +1370,8 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
// Load conductor
|
// Load conductor
|
||||||
QList<Conductor *> added_conductors;
|
QList<Conductor *> added_conductors;
|
||||||
foreach (QDomElement f, QET::findInDomElement(root,
|
foreach (QDomElement f, QET::findInDomElement(root,
|
||||||
"conductors",
|
"conductors",
|
||||||
"conductor"))
|
"conductor"))
|
||||||
{
|
{
|
||||||
if (!Conductor::valideXml(f)) continue;
|
if (!Conductor::valideXml(f)) continue;
|
||||||
|
|
||||||
@@ -1377,7 +1380,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())
|
||||||
@@ -1388,13 +1391,15 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
delete c;
|
delete c;
|
||||||
|
} else {
|
||||||
|
qDebug() << "Diagramm::fromXML(): No matching terminals found.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load tables
|
//Load tables
|
||||||
QVector<QetGraphicsTableItem *> added_tables;
|
QVector<QetGraphicsTableItem *> added_tables;
|
||||||
for (auto dom_table
|
for (auto dom_table
|
||||||
: QETXML::subChild(root,
|
: QETXML::subChild(root,
|
||||||
"tables",
|
"tables",
|
||||||
QetGraphicsTableItem::xmlTagName()))
|
QetGraphicsTableItem::xmlTagName()))
|
||||||
{
|
{
|
||||||
@@ -1409,11 +1414,11 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
{
|
{
|
||||||
QVector <QGraphicsItem *> added_items;
|
QVector <QGraphicsItem *> added_items;
|
||||||
for (auto element : added_elements ) added_items << element;
|
for (auto element : added_elements ) added_items << element;
|
||||||
for (auto cond : added_conductors) added_items << cond;
|
for (auto cond : added_conductors) added_items << cond;
|
||||||
for (auto shape : added_shapes ) added_items << shape;
|
for (auto shape : added_shapes ) added_items << shape;
|
||||||
for (auto text : added_texts ) added_items << text;
|
for (auto text : added_texts ) added_items << text;
|
||||||
for (auto image : added_images ) added_items << image;
|
for (auto image : added_images ) added_items << image;
|
||||||
for (auto table : added_tables ) added_items << table;
|
for (auto table : added_tables ) added_items << table;
|
||||||
|
|
||||||
//Get the top left corner of the rectangle that contain all added items
|
//Get the top left corner of the rectangle that contain all added items
|
||||||
QRectF items_rect;
|
QRectF items_rect;
|
||||||
@@ -1435,12 +1440,12 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
|
|
||||||
//Filling of falculatory lists
|
//Filling of falculatory lists
|
||||||
if (content_ptr) {
|
if (content_ptr) {
|
||||||
content_ptr -> m_elements = added_elements;
|
content_ptr -> m_elements = added_elements;
|
||||||
content_ptr -> m_conductors_to_move = added_conductors;
|
content_ptr -> m_conductors_to_move = added_conductors;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||||
content_ptr -> m_text_fields = added_texts.toSet();
|
content_ptr -> m_text_fields = added_texts.toSet();
|
||||||
content_ptr -> m_images = added_images.toSet();
|
content_ptr -> m_images = added_images.toSet();
|
||||||
content_ptr -> m_shapes = added_shapes.toSet();
|
content_ptr -> m_shapes = added_shapes.toSet();
|
||||||
#else
|
#else
|
||||||
#if TODO_LIST
|
#if TODO_LIST
|
||||||
#pragma message("@TODO remove code for QT 5.14 or later")
|
#pragma message("@TODO remove code for QT 5.14 or later")
|
||||||
@@ -1455,7 +1460,7 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
added_shapes.begin(),
|
added_shapes.begin(),
|
||||||
added_shapes.end());
|
added_shapes.end());
|
||||||
#endif
|
#endif
|
||||||
content_ptr -> m_tables = added_tables;
|
content_ptr -> m_tables = added_tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
adjustSceneRect();
|
adjustSceneRect();
|
||||||
@@ -1473,23 +1478,23 @@ bool Diagram::fromXml(QDomElement &document,
|
|||||||
@param autonumFolioSeqType
|
@param autonumFolioSeqType
|
||||||
*/
|
*/
|
||||||
void Diagram::folioSequentialsFromXml(const QDomElement &root,
|
void Diagram::folioSequentialsFromXml(const QDomElement &root,
|
||||||
QHash<QString,
|
QHash<QString,
|
||||||
QStringList>* hash,
|
QStringList>* hash,
|
||||||
const QString& folioSeq,
|
const QString& folioSeq,
|
||||||
const QString& seq,
|
const QString& seq,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
const QString& autonumFolioSeqType) {
|
const QString& autonumFolioSeqType) {
|
||||||
foreach (QDomElement folioSeqAutoNum,
|
foreach (QDomElement folioSeqAutoNum,
|
||||||
QET::findInDomElement(root, autonumFolioSeqType, folioSeq)) {
|
QET::findInDomElement(root, autonumFolioSeqType, folioSeq)) {
|
||||||
for(QDomElement folioseq
|
for(QDomElement folioseq
|
||||||
= folioSeqAutoNum.firstChildElement(type);
|
= folioSeqAutoNum.firstChildElement(type);
|
||||||
!folioseq.isNull();
|
!folioseq.isNull();
|
||||||
folioseq = folioseq.nextSiblingElement(type)) {
|
folioseq = folioseq.nextSiblingElement(type)) {
|
||||||
QString title = folioseq.attribute("title");
|
QString title = folioseq.attribute("title");
|
||||||
QStringList list;
|
QStringList list;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while (folioseq.hasAttribute(seq
|
while (folioseq.hasAttribute(seq
|
||||||
+ QString::number(i))) {
|
+ QString::number(i))) {
|
||||||
list << folioseq.attribute(
|
list << folioseq.attribute(
|
||||||
seq + QString::number(i));
|
seq + QString::number(i));
|
||||||
i++;
|
i++;
|
||||||
@@ -1527,7 +1532,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
|
||||||
*/
|
*/
|
||||||
@@ -1745,10 +1750,10 @@ void Diagram::insertFolioSeqHash(QHash<QString,
|
|||||||
@param nc : Context to be manipulated
|
@param nc : Context to be manipulated
|
||||||
*/
|
*/
|
||||||
void Diagram::loadFolioSeqHash(QHash<QString,
|
void Diagram::loadFolioSeqHash(QHash<QString,
|
||||||
QStringList> *hash,
|
QStringList> *hash,
|
||||||
const QString& title,
|
const QString& title,
|
||||||
const QString& type,
|
const QString& type,
|
||||||
NumerotationContext *nc) {
|
NumerotationContext *nc) {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = 0; i < nc->size(); i++) {
|
for (int i = 0; i < nc->size(); i++) {
|
||||||
if (nc->itemAt(i).at(0) == type) {
|
if (nc->itemAt(i).at(0) == type) {
|
||||||
@@ -1773,9 +1778,9 @@ void Diagram::changeZValue(QET::DepthOption option)
|
|||||||
DiagramContent dc(this);
|
DiagramContent dc(this);
|
||||||
QUndoCommand *undo = new QUndoCommand(tr("Modifier la profondeur"));
|
QUndoCommand *undo = new QUndoCommand(tr("Modifier la profondeur"));
|
||||||
QList<QGraphicsItem *> l = dc.items(DiagramContent::SelectedOnly | \
|
QList<QGraphicsItem *> l = dc.items(DiagramContent::SelectedOnly | \
|
||||||
DiagramContent::Elements | \
|
DiagramContent::Elements | \
|
||||||
DiagramContent::Shapes | \
|
DiagramContent::Shapes | \
|
||||||
DiagramContent::Images);
|
DiagramContent::Images);
|
||||||
QList<QGraphicsObject *> list;
|
QList<QGraphicsObject *> list;
|
||||||
for(QGraphicsItem *item : l)
|
for(QGraphicsItem *item : l)
|
||||||
list << item->toGraphicsObject();
|
list << item->toGraphicsObject();
|
||||||
@@ -2164,7 +2169,7 @@ void Diagram::adjustSceneRect()
|
|||||||
{
|
{
|
||||||
QRectF old_rect = sceneRect();
|
QRectF old_rect = sceneRect();
|
||||||
setSceneRect(border_and_titleblock.borderAndTitleBlockRect().united(
|
setSceneRect(border_and_titleblock.borderAndTitleBlockRect().united(
|
||||||
itemsBoundingRect()));
|
itemsBoundingRect()));
|
||||||
update(old_rect.united(sceneRect()));
|
update(old_rect.united(sceneRect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2185,20 +2190,20 @@ ExportProperties Diagram::applyProperties(
|
|||||||
// exports current rendering options
|
// exports current rendering options
|
||||||
// exporte les options de rendu en cours
|
// exporte les options de rendu en cours
|
||||||
ExportProperties old_properties;
|
ExportProperties old_properties;
|
||||||
old_properties.draw_grid = displayGrid();
|
old_properties.draw_grid = displayGrid();
|
||||||
old_properties.draw_border = border_and_titleblock.borderIsDisplayed();
|
old_properties.draw_border = border_and_titleblock.borderIsDisplayed();
|
||||||
old_properties.draw_titleblock = border_and_titleblock.titleBlockIsDisplayed();
|
old_properties.draw_titleblock = border_and_titleblock.titleBlockIsDisplayed();
|
||||||
old_properties.draw_terminals = drawTerminals();
|
old_properties.draw_terminals = drawTerminals();
|
||||||
old_properties.draw_colored_conductors = drawColoredConductors();
|
old_properties.draw_colored_conductors = drawColoredConductors();
|
||||||
old_properties.exported_area = useBorder() ? QET::BorderArea
|
old_properties.exported_area = useBorder() ? QET::BorderArea
|
||||||
: QET::ElementsArea;
|
: QET::ElementsArea;
|
||||||
|
|
||||||
// apply the new rendering options
|
// apply the new rendering options
|
||||||
// applique les nouvelles options de rendu
|
// applique les nouvelles options de rendu
|
||||||
setUseBorder (new_properties.exported_area == QET::BorderArea);
|
setUseBorder (new_properties.exported_area == QET::BorderArea);
|
||||||
setDrawTerminals (new_properties.draw_terminals);
|
setDrawTerminals (new_properties.draw_terminals);
|
||||||
setDrawColoredConductors (new_properties.draw_colored_conductors);
|
setDrawColoredConductors (new_properties.draw_colored_conductors);
|
||||||
setDisplayGrid (new_properties.draw_grid);
|
setDisplayGrid (new_properties.draw_grid);
|
||||||
border_and_titleblock.displayBorder(new_properties.draw_border);
|
border_and_titleblock.displayBorder(new_properties.draw_border);
|
||||||
border_and_titleblock.displayTitleBlock (new_properties.draw_titleblock);
|
border_and_titleblock.displayTitleBlock (new_properties.draw_titleblock);
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -108,10 +108,10 @@ class Diagram : public QGraphicsScene
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QGraphicsLineItem *conductor_setter_;
|
QGraphicsLineItem *conductor_setter_;
|
||||||
ElementsMover m_elements_mover;
|
ElementsMover m_elements_mover;
|
||||||
ElementTextsMover m_element_texts_mover;
|
ElementTextsMover m_element_texts_mover;
|
||||||
QGIManager *qgi_manager_;
|
QGIManager *qgi_manager_;
|
||||||
QETProject *m_project;
|
QETProject *m_project;
|
||||||
|
|
||||||
QDomDocument xml_document_;
|
QDomDocument xml_document_;
|
||||||
|
|
||||||
@@ -156,9 +156,9 @@ class Diagram : public QGraphicsScene
|
|||||||
|
|
||||||
// methods related to parent project
|
// methods related to parent project
|
||||||
QETProject *project() const;
|
QETProject *project() const;
|
||||||
int folioIndex() const;
|
int folioIndex() const;
|
||||||
void showMe() {emit showDiagram(this);}
|
void showMe() {emit showDiagram(this);}
|
||||||
bool isReadOnly() const;
|
bool isReadOnly() const;
|
||||||
|
|
||||||
// methods related to conductor creation
|
// methods related to conductor creation
|
||||||
void setConductor(bool);
|
void setConductor(bool);
|
||||||
@@ -173,13 +173,13 @@ class Diagram : public QGraphicsScene
|
|||||||
bool = true,
|
bool = true,
|
||||||
DiagramContent * = nullptr);
|
DiagramContent * = nullptr);
|
||||||
bool fromXml(QDomDocument &,
|
bool fromXml(QDomDocument &,
|
||||||
QPointF = QPointF(),
|
QPointF = QPointF(),
|
||||||
bool = true,
|
bool = true,
|
||||||
DiagramContent * = nullptr);
|
DiagramContent * = nullptr);
|
||||||
bool fromXml(QDomElement &,
|
bool fromXml(QDomElement &,
|
||||||
QPointF = QPointF(),
|
QPointF = QPointF(),
|
||||||
bool = true,
|
bool = true,
|
||||||
DiagramContent * = nullptr);
|
DiagramContent * = nullptr);
|
||||||
void folioSequentialsToXml(QHash<QString,
|
void folioSequentialsToXml(QHash<QString,
|
||||||
QStringList>*,
|
QStringList>*,
|
||||||
QDomElement *,
|
QDomElement *,
|
||||||
@@ -187,17 +187,17 @@ class Diagram : public QGraphicsScene
|
|||||||
const QString&,
|
const QString&,
|
||||||
QDomDocument *);
|
QDomDocument *);
|
||||||
void folioSequentialsFromXml(const QDomElement&,
|
void folioSequentialsFromXml(const QDomElement&,
|
||||||
QHash<QString,
|
QHash<QString,
|
||||||
QStringList>*,
|
QStringList>*,
|
||||||
const QString&,
|
const QString&,
|
||||||
const QString&,
|
const QString&,
|
||||||
const QString&,
|
const QString&,
|
||||||
const QString&);
|
const QString&);
|
||||||
|
|
||||||
void refreshContents();
|
void refreshContents();
|
||||||
|
|
||||||
// methods related to graphics items addition/removal on the diagram
|
// methods related to graphics items addition/removal on the diagram
|
||||||
virtual void addItem (QGraphicsItem *item);
|
virtual void addItem (QGraphicsItem *item);
|
||||||
virtual void removeItem (QGraphicsItem *item);
|
virtual void removeItem (QGraphicsItem *item);
|
||||||
|
|
||||||
// methods related to graphics options
|
// methods related to graphics options
|
||||||
@@ -253,8 +253,8 @@ class Diagram : public QGraphicsScene
|
|||||||
const QString& seq,
|
const QString& seq,
|
||||||
NumerotationContext *nc);
|
NumerotationContext *nc);
|
||||||
void loadFolioSeqHash (QHash<QString, QStringList> *hash,
|
void loadFolioSeqHash (QHash<QString, QStringList> *hash,
|
||||||
const QString& title, const QString& seq,
|
const QString& title, const QString& seq,
|
||||||
NumerotationContext *nc);
|
NumerotationContext *nc);
|
||||||
void changeZValue(QET::DepthOption option);
|
void changeZValue(QET::DepthOption option);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -262,7 +262,7 @@ class Diagram : public QGraphicsScene
|
|||||||
void titleChanged(const QString &);
|
void titleChanged(const QString &);
|
||||||
void titleBlockTemplateChanged(const QString &);
|
void titleBlockTemplateChanged(const QString &);
|
||||||
void titleBlockTemplateRemoved(const QString &,
|
void titleBlockTemplateRemoved(const QString &,
|
||||||
const QString & = QString());
|
const QString & = QString());
|
||||||
void setTitleBlockTemplate(const QString &);
|
void setTitleBlockTemplate(const QString &);
|
||||||
void updateLabels();
|
void updateLabels();
|
||||||
void loadElmtFolioSeq();
|
void loadElmtFolioSeq();
|
||||||
@@ -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 *)
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ bool DiagramContext::keyMustShow(const QString &key) const
|
|||||||
|
|
||||||
bool DiagramContext::operator==(const DiagramContext &dc) const
|
bool DiagramContext::operator==(const DiagramContext &dc) const
|
||||||
{
|
{
|
||||||
return(m_content == dc.m_content &&
|
return(m_content == dc.m_content &&
|
||||||
m_content_show == dc.m_content_show);
|
m_content_show == dc.m_content_show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,23 +33,23 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Key for element :
|
* Key for element :
|
||||||
* label -> label or identification of element
|
* label -> label or identification of element
|
||||||
* formula -> formula used to create the label (formula is make with variable)
|
* formula -> formula used to create the label (formula is make with variable)
|
||||||
* designation -> exhaustive comment used to explain what the element does.
|
* designation -> exhaustive comment used to explain what the element does.
|
||||||
* description -> exhaustive description used to explain what the element does.
|
* description -> exhaustive description used to explain what the element does.
|
||||||
* plant -> the plant assigned to the element
|
* plant -> the plant assigned to the element
|
||||||
* comment -> a little comment wich can be displayed in the folio
|
* comment -> a little comment wich can be displayed in the folio
|
||||||
* manufacturer -> the manufacturer of the element
|
* manufacturer -> the manufacturer of the element
|
||||||
* manufacturer_reference -> the manufacturer reference of the element
|
* manufacturer_reference -> the manufacturer reference of the element
|
||||||
* quantity -> quantity of the element
|
* quantity -> quantity of the element
|
||||||
* unity -> unity of the element
|
* unity -> unity of the element
|
||||||
* auxiliary1 -> auxiliary 1 of element
|
* auxiliary1 -> auxiliary 1 of element
|
||||||
* auxiliary2 -> auxiliary 2 of element
|
* auxiliary2 -> auxiliary 2 of element
|
||||||
* machine_manufacturer_reference -> reference of the machine manufacturer
|
* machine_manufacturer_reference -> reference of the machine manufacturer
|
||||||
* supplier -> the supplier of the element
|
* supplier -> the supplier of the element
|
||||||
* function -> the function of element
|
* function -> the function of element
|
||||||
* location -> the location assigned to the element
|
* location -> the location assigned to the element
|
||||||
* frozenLabel -> label locked at a given time
|
* frozenLabel -> label locked at a given time
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class DiagramContext
|
class DiagramContext
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ qreal CustomElementGraphicPart::penWeight() const
|
|||||||
if (_lineweight == NoneWeight || _lineweight == ThinWeight) return 0;
|
if (_lineweight == NoneWeight || _lineweight == ThinWeight) return 0;
|
||||||
else if (_lineweight == NormalWeight) return 1;
|
else if (_lineweight == NormalWeight) return 1;
|
||||||
else if (_lineweight == UltraWeight) return 2;
|
else if (_lineweight == UltraWeight) return 2;
|
||||||
else if (_lineweight == BigWeight) return 5;
|
else if (_lineweight == BigWeight) return 5;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,26 +161,26 @@ void CustomElementGraphicPart::setAntialiased(const bool b)
|
|||||||
Each style separate by ; and name-style/value are separate by :
|
Each style separate by ; and name-style/value are separate by :
|
||||||
@param qde : QDOmElement used to write the style.
|
@param qde : QDOmElement used to write the style.
|
||||||
*/
|
*/
|
||||||
void CustomElementGraphicPart::stylesToXml(QDomElement &qde) const
|
void CustomElementGraphicPart::stylesToXml(QDomDocument &xml_document, QDomElement &qde) const
|
||||||
{
|
{
|
||||||
QString css_like_styles;
|
QString css_like_styles;
|
||||||
|
|
||||||
css_like_styles += "line-style:";
|
css_like_styles += "line-style:";
|
||||||
if (_linestyle == DashedStyle) css_like_styles += "dashed";
|
if (_linestyle == DashedStyle) css_like_styles += "dashed";
|
||||||
else if (_linestyle == DottedStyle) css_like_styles += "dotted";
|
else if (_linestyle == DottedStyle) css_like_styles += "dotted";
|
||||||
else if (_linestyle == DashdottedStyle) css_like_styles += "dashdotted";
|
else if (_linestyle == DashdottedStyle) css_like_styles += "dashdotted";
|
||||||
else if (_linestyle == NormalStyle) css_like_styles += "normal";
|
else if (_linestyle == NormalStyle) css_like_styles += "normal";
|
||||||
|
|
||||||
css_like_styles += ";line-weight:";
|
css_like_styles += ";line-weight:";
|
||||||
if (_lineweight == NoneWeight) css_like_styles += "none";
|
if (_lineweight == NoneWeight) css_like_styles += "none";
|
||||||
else if (_lineweight == ThinWeight) css_like_styles += "thin";
|
else if (_lineweight == ThinWeight) css_like_styles += "thin";
|
||||||
else if (_lineweight == NormalWeight) css_like_styles += "normal";
|
else if (_lineweight == NormalWeight) css_like_styles += "normal";
|
||||||
else if (_lineweight == UltraWeight) css_like_styles += "hight";
|
else if (_lineweight == UltraWeight) css_like_styles += "hight";
|
||||||
else if (_lineweight == BigWeight) css_like_styles += "eleve";
|
else if (_lineweight == BigWeight) css_like_styles += "eleve";
|
||||||
|
|
||||||
|
|
||||||
css_like_styles += ";filling:";
|
css_like_styles += ";filling:";
|
||||||
if (_filling == NoneFilling) css_like_styles += "none";
|
if (_filling == NoneFilling) css_like_styles += "none";
|
||||||
else if (_filling == BlackFilling) css_like_styles += "black";
|
else if (_filling == BlackFilling) css_like_styles += "black";
|
||||||
else if (_filling == WhiteFilling) css_like_styles += "white";
|
else if (_filling == WhiteFilling) css_like_styles += "white";
|
||||||
else if (_filling == GreenFilling) css_like_styles += "green";
|
else if (_filling == GreenFilling) css_like_styles += "green";
|
||||||
@@ -341,7 +341,7 @@ void CustomElementGraphicPart::stylesToXml(QDomElement &qde) const
|
|||||||
|
|
||||||
|
|
||||||
css_like_styles += ";color:";
|
css_like_styles += ";color:";
|
||||||
if (_color == WhiteColor) css_like_styles += "white";
|
if (_color == WhiteColor) css_like_styles += "white";
|
||||||
else if (_color == BlackColor) css_like_styles += "black";
|
else if (_color == BlackColor) css_like_styles += "black";
|
||||||
else if (_color == GreenColor) css_like_styles += "green";
|
else if (_color == GreenColor) css_like_styles += "green";
|
||||||
else if (_color == RedColor) css_like_styles += "red";
|
else if (_color == RedColor) css_like_styles += "red";
|
||||||
@@ -496,9 +496,8 @@ 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.appendChild(createXmlProperty(xml_document, "style", css_like_styles));
|
||||||
qde.setAttribute("style", css_like_styles);
|
qde.appendChild(createXmlProperty(xml_document, "antialias", _antialiased ? "true" : "false"));
|
||||||
qde.setAttribute("antialias", _antialiased ? "true" : "false");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -511,6 +510,9 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
|||||||
{
|
{
|
||||||
resetStyles();
|
resetStyles();
|
||||||
|
|
||||||
|
QString style_string;
|
||||||
|
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);
|
||||||
@@ -521,6 +523,8 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
|||||||
QStringList styles = qde.attribute("style").split(";", Qt::SkipEmptyParts);
|
QStringList styles = qde.attribute("style").split(";", Qt::SkipEmptyParts);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Check each pair of style
|
//Check each pair of style
|
||||||
QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
|
QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
|
||||||
foreach (QString style, styles)
|
foreach (QString style, styles)
|
||||||
@@ -530,14 +534,14 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
|||||||
QString style_value = rx.namedCaptureGroups().at(2);
|
QString style_value = rx.namedCaptureGroups().at(2);
|
||||||
if (style_name == "line-style")
|
if (style_name == "line-style")
|
||||||
{
|
{
|
||||||
if (style_value == "dashed") _linestyle = DashedStyle;
|
if (style_value == "dashed") _linestyle = DashedStyle;
|
||||||
else if (style_value == "dotted") _linestyle = DottedStyle;
|
else if (style_value == "dotted") _linestyle = DottedStyle;
|
||||||
else if (style_value == "dashdotted") _linestyle = DashdottedStyle;
|
else if (style_value == "dashdotted") _linestyle = DashdottedStyle;
|
||||||
else if (style_value == "normal") _linestyle = NormalStyle;
|
else if (style_value == "normal") _linestyle = NormalStyle;
|
||||||
}
|
}
|
||||||
else if (style_name == "line-weight")
|
else if (style_name == "line-weight")
|
||||||
{
|
{
|
||||||
if (style_value == "none") _lineweight = NoneWeight;
|
if (style_value == "none") _lineweight = NoneWeight;
|
||||||
else if (style_value == "thin") _lineweight = ThinWeight;
|
else if (style_value == "thin") _lineweight = ThinWeight;
|
||||||
else if (style_value == "normal") _lineweight = NormalWeight;
|
else if (style_value == "normal") _lineweight = NormalWeight;
|
||||||
else if (style_value == "hight") _lineweight = UltraWeight;
|
else if (style_value == "hight") _lineweight = UltraWeight;
|
||||||
@@ -545,7 +549,7 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
|||||||
}
|
}
|
||||||
else if (style_name == "filling")
|
else if (style_name == "filling")
|
||||||
{
|
{
|
||||||
if (style_value == "white") _filling = WhiteFilling;
|
if (style_value == "white") _filling = WhiteFilling;
|
||||||
else if (style_value == "black") _filling = BlackFilling;
|
else if (style_value == "black") _filling = BlackFilling;
|
||||||
else if (style_value == "red") _filling = RedFilling;
|
else if (style_value == "red") _filling = RedFilling;
|
||||||
else if (style_value == "green") _filling = GreenFilling;
|
else if (style_value == "green") _filling = GreenFilling;
|
||||||
@@ -706,7 +710,7 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
|||||||
}
|
}
|
||||||
else if (style_name == "color")
|
else if (style_name == "color")
|
||||||
{
|
{
|
||||||
if (style_value == "black") _color = BlackColor;
|
if (style_value == "black") _color = BlackColor;
|
||||||
else if (style_value == "white") _color = WhiteColor;
|
else if (style_value == "white") _color = WhiteColor;
|
||||||
else if (style_value == "green") _color = GreenColor;
|
else if (style_value == "green") _color = GreenColor;
|
||||||
else if (style_value == "red") _color = RedColor;
|
else if (style_value == "red") _color = RedColor;
|
||||||
@@ -863,7 +867,9 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Get antialiasing
|
//Get antialiasing
|
||||||
_antialiased = qde.attribute("antialias") == "true";
|
QString a;
|
||||||
|
propertyString(qde, "antialias", &a);
|
||||||
|
_antialiased = a == "true";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -893,17 +899,17 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
|||||||
QBrush brush = painter.brush();
|
QBrush brush = painter.brush();
|
||||||
|
|
||||||
//Apply pen style
|
//Apply pen style
|
||||||
if (_linestyle == DashedStyle) pen.setStyle(Qt::DashLine);
|
if (_linestyle == DashedStyle) pen.setStyle(Qt::DashLine);
|
||||||
else if (_linestyle == DashdottedStyle) pen.setStyle(Qt::DashDotLine);
|
else if (_linestyle == DashdottedStyle) pen.setStyle(Qt::DashDotLine);
|
||||||
else if (_linestyle == DottedStyle) pen.setStyle(Qt::DotLine);
|
else if (_linestyle == DottedStyle) pen.setStyle(Qt::DotLine);
|
||||||
else if (_linestyle == NormalStyle) pen.setStyle(Qt::SolidLine);
|
else if (_linestyle == NormalStyle) pen.setStyle(Qt::SolidLine);
|
||||||
|
|
||||||
//Apply pen width
|
//Apply pen width
|
||||||
if (_lineweight == NoneWeight) pen.setColor(QColor(0, 0, 0, 0));
|
if (_lineweight == NoneWeight) pen.setColor(QColor(0, 0, 0, 0));
|
||||||
else if (_lineweight == ThinWeight) pen.setWidth(0);
|
else if (_lineweight == ThinWeight) pen.setWidth(0);
|
||||||
else if (_lineweight == NormalWeight) pen.setWidthF(1.0);
|
else if (_lineweight == NormalWeight) pen.setWidthF(1.0);
|
||||||
else if (_lineweight == UltraWeight) pen.setWidthF(2.0);
|
else if (_lineweight == UltraWeight) pen.setWidthF(2.0);
|
||||||
else if (_lineweight == BigWeight) pen.setWidthF(5.0);
|
else if (_lineweight == BigWeight) pen.setWidthF(5.0);
|
||||||
|
|
||||||
//Apply brush color
|
//Apply brush color
|
||||||
if (_filling == NoneFilling) brush.setStyle(Qt::NoBrush);
|
if (_filling == NoneFilling) brush.setStyle(Qt::NoBrush);
|
||||||
@@ -914,7 +920,7 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
brush.setStyle(Qt::SolidPattern);
|
brush.setStyle(Qt::SolidPattern);
|
||||||
if (_filling == BlackFilling) brush.setColor(Qt::black);
|
if (_filling == BlackFilling) brush.setColor(Qt::black);
|
||||||
else if (_filling == WhiteFilling) brush.setColor(Qt::white);
|
else if (_filling == WhiteFilling) brush.setColor(Qt::white);
|
||||||
else if (_filling == GreenFilling) brush.setColor(Qt::green);
|
else if (_filling == GreenFilling) brush.setColor(Qt::green);
|
||||||
else if (_filling == RedFilling) brush.setColor(Qt::red);
|
else if (_filling == RedFilling) brush.setColor(Qt::red);
|
||||||
@@ -1070,7 +1076,7 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Apply pen color
|
//Apply pen color
|
||||||
if (_color == WhiteColor) pen.setColor(QColor(255, 255, 255, pen.color().alpha()));
|
if (_color == WhiteColor) pen.setColor(QColor(255, 255, 255, pen.color().alpha()));
|
||||||
else if (_color == BlackColor) pen.setColor(QColor( 0, 0, 0, pen.color().alpha()));
|
else if (_color == BlackColor) pen.setColor(QColor( 0, 0, 0, pen.color().alpha()));
|
||||||
else if (_color == GreenColor) pen.setColor(QColor(Qt::green));
|
else if (_color == GreenColor) pen.setColor(QColor(Qt::green));
|
||||||
else if (_color == RedColor) pen.setColor(QColor(Qt::red));
|
else if (_color == RedColor) pen.setColor(QColor(Qt::red));
|
||||||
@@ -1226,8 +1232,8 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
|||||||
else if (_color == NoneColor) pen.setBrush(Qt::transparent);
|
else if (_color == NoneColor) pen.setBrush(Qt::transparent);
|
||||||
|
|
||||||
//Apply antialiasing
|
//Apply antialiasing
|
||||||
painter.setRenderHint(QPainter::Antialiasing, _antialiased);
|
painter.setRenderHint(QPainter::Antialiasing, _antialiased);
|
||||||
painter.setRenderHint(QPainter::TextAntialiasing, _antialiased);
|
painter.setRenderHint(QPainter::TextAntialiasing, _antialiased);
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform, _antialiased);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform, _antialiased);
|
||||||
|
|
||||||
painter.setPen(pen);
|
painter.setPen(pen);
|
||||||
@@ -1324,7 +1330,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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
|||||||
|
|
||||||
Q_PROPERTY(LineStyle line_style READ lineStyle WRITE setLineStyle)
|
Q_PROPERTY(LineStyle line_style READ lineStyle WRITE setLineStyle)
|
||||||
Q_PROPERTY(LineWeight line_weight READ lineWeight WRITE setLineWeight)
|
Q_PROPERTY(LineWeight line_weight READ lineWeight WRITE setLineWeight)
|
||||||
Q_PROPERTY(Filling filling READ filling WRITE setFilling)
|
Q_PROPERTY(Filling filling READ filling WRITE setFilling)
|
||||||
Q_PROPERTY(Color color READ color WRITE setColor)
|
Q_PROPERTY(Color color READ color WRITE setColor)
|
||||||
Q_PROPERTY(bool antialias READ antialiased WRITE setAntialiased)
|
Q_PROPERTY(bool antialias READ antialiased WRITE setAntialiased)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//Line style
|
//Line style
|
||||||
@@ -62,122 +62,122 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
|||||||
|
|
||||||
//Filling color of the part : NoneFilling -> No filling (i.e. transparent)
|
//Filling color of the part : NoneFilling -> No filling (i.e. transparent)
|
||||||
enum Filling { NoneFilling, BlackFilling, WhiteFilling,
|
enum Filling { NoneFilling, BlackFilling, WhiteFilling,
|
||||||
GreenFilling, RedFilling, BlueFilling,
|
GreenFilling, RedFilling, BlueFilling,
|
||||||
GrayFilling, BrunFilling, YellowFilling,
|
GrayFilling, BrunFilling, YellowFilling,
|
||||||
CyanFilling, MagentaFilling, LightgrayFilling,
|
CyanFilling, MagentaFilling, LightgrayFilling,
|
||||||
OrangeFilling, PurpleFilling,
|
OrangeFilling, PurpleFilling,
|
||||||
HTMLPinkPinkFilling, HTMLPinkLightPinkFilling,
|
HTMLPinkPinkFilling, HTMLPinkLightPinkFilling,
|
||||||
HTMLPinkHotPinkFilling, HTMLPinkDeepPinkFilling,
|
HTMLPinkHotPinkFilling, HTMLPinkDeepPinkFilling,
|
||||||
HTMLPinkPaleVioletRedFilling,
|
HTMLPinkPaleVioletRedFilling,
|
||||||
HTMLPinkMediumVioletRedFilling,
|
HTMLPinkMediumVioletRedFilling,
|
||||||
HTMLRedLightSalmonFilling, HTMLRedSalmonFilling,
|
HTMLRedLightSalmonFilling, HTMLRedSalmonFilling,
|
||||||
HTMLRedDarkSalmonFilling,
|
HTMLRedDarkSalmonFilling,
|
||||||
HTMLRedLightCoralFilling,
|
HTMLRedLightCoralFilling,
|
||||||
HTMLRedIndianRedFilling, HTMLRedCrimsonFilling,
|
HTMLRedIndianRedFilling, HTMLRedCrimsonFilling,
|
||||||
HTMLRedFirebrickFilling, HTMLRedDarkRedFilling,
|
HTMLRedFirebrickFilling, HTMLRedDarkRedFilling,
|
||||||
HTMLRedRedFilling, HTMLOrangeOrangeRedFilling,
|
HTMLRedRedFilling, HTMLOrangeOrangeRedFilling,
|
||||||
HTMLOrangeTomatoFilling, HTMLOrangeCoralFilling,
|
HTMLOrangeTomatoFilling, HTMLOrangeCoralFilling,
|
||||||
HTMLOrangeDarkOrangeFilling,
|
HTMLOrangeDarkOrangeFilling,
|
||||||
HTMLOrangeOrangeFilling, HTMLYellowYellowFilling,
|
HTMLOrangeOrangeFilling, HTMLYellowYellowFilling,
|
||||||
HTMLYellowLightYellowFilling,
|
HTMLYellowLightYellowFilling,
|
||||||
HTMLYellowLemonChiffonFilling,
|
HTMLYellowLemonChiffonFilling,
|
||||||
HTMLYellowLightGoldenrodYellowFilling,
|
HTMLYellowLightGoldenrodYellowFilling,
|
||||||
HTMLYellowPapayaWhipFilling,
|
HTMLYellowPapayaWhipFilling,
|
||||||
HTMLYellowMoccasinFilling,
|
HTMLYellowMoccasinFilling,
|
||||||
HTMLYellowPeachPuffFilling,
|
HTMLYellowPeachPuffFilling,
|
||||||
HTMLYellowPaleGoldenrodFilling,
|
HTMLYellowPaleGoldenrodFilling,
|
||||||
HTMLYellowKhakiFilling,
|
HTMLYellowKhakiFilling,
|
||||||
HTMLYellowDarkKhakiFilling,
|
HTMLYellowDarkKhakiFilling,
|
||||||
HTMLYellowGoldFilling, HTMLBrownCornsilkFilling,
|
HTMLYellowGoldFilling, HTMLBrownCornsilkFilling,
|
||||||
HTMLBrownBlanchedAlmondFilling,
|
HTMLBrownBlanchedAlmondFilling,
|
||||||
HTMLBrownBisqueFilling,
|
HTMLBrownBisqueFilling,
|
||||||
HTMLBrownNavajoWhiteFilling,
|
HTMLBrownNavajoWhiteFilling,
|
||||||
HTMLBrownWheatFilling, HTMLBrownBurlywoodFilling,
|
HTMLBrownWheatFilling, HTMLBrownBurlywoodFilling,
|
||||||
HTMLBrownTanFilling, HTMLBrownRosyBrownFilling,
|
HTMLBrownTanFilling, HTMLBrownRosyBrownFilling,
|
||||||
HTMLBrownSandyBrownFilling,
|
HTMLBrownSandyBrownFilling,
|
||||||
HTMLBrownGoldenrodFilling,
|
HTMLBrownGoldenrodFilling,
|
||||||
HTMLBrownDarkGoldenrodFilling,
|
HTMLBrownDarkGoldenrodFilling,
|
||||||
HTMLBrownPeruFilling, HTMLBrownChocolateFilling,
|
HTMLBrownPeruFilling, HTMLBrownChocolateFilling,
|
||||||
HTMLBrownSaddleBrownFilling,
|
HTMLBrownSaddleBrownFilling,
|
||||||
HTMLBrownSiennaFilling, HTMLBrownBrownFilling,
|
HTMLBrownSiennaFilling, HTMLBrownBrownFilling,
|
||||||
HTMLBrownMaroonFilling,
|
HTMLBrownMaroonFilling,
|
||||||
HTMLGreenDarkOliveGreenFilling,
|
HTMLGreenDarkOliveGreenFilling,
|
||||||
HTMLGreenOliveFilling, HTMLGreenOliveDrabFilling,
|
HTMLGreenOliveFilling, HTMLGreenOliveDrabFilling,
|
||||||
HTMLGreenYellowGreenFilling,
|
HTMLGreenYellowGreenFilling,
|
||||||
HTMLGreenLimeGreenFilling, HTMLGreenLimeFilling,
|
HTMLGreenLimeGreenFilling, HTMLGreenLimeFilling,
|
||||||
HTMLGreenLawnGreenFilling,
|
HTMLGreenLawnGreenFilling,
|
||||||
HTMLGreenChartreuseFilling,
|
HTMLGreenChartreuseFilling,
|
||||||
HTMLGreenGreenYellowFilling,
|
HTMLGreenGreenYellowFilling,
|
||||||
HTMLGreenSpringGreenFilling,
|
HTMLGreenSpringGreenFilling,
|
||||||
HTMLGreenMediumSpringGreenFilling,
|
HTMLGreenMediumSpringGreenFilling,
|
||||||
HTMLGreenLightGreenFilling,
|
HTMLGreenLightGreenFilling,
|
||||||
HTMLGreenPaleGreenFilling,
|
HTMLGreenPaleGreenFilling,
|
||||||
HTMLGreenDarkSeaGreenFilling,
|
HTMLGreenDarkSeaGreenFilling,
|
||||||
HTMLGreenMediumAquamarineFilling,
|
HTMLGreenMediumAquamarineFilling,
|
||||||
HTMLGreenMediumSeaGreenFilling,
|
HTMLGreenMediumSeaGreenFilling,
|
||||||
HTMLGreenSeaGreenFilling,
|
HTMLGreenSeaGreenFilling,
|
||||||
HTMLGreenForestGreenFilling,
|
HTMLGreenForestGreenFilling,
|
||||||
HTMLGreenGreenFilling, HTMLGreenDarkGreenFilling,
|
HTMLGreenGreenFilling, HTMLGreenDarkGreenFilling,
|
||||||
HTMLCyanAquaFilling, HTMLCyanCyanFilling,
|
HTMLCyanAquaFilling, HTMLCyanCyanFilling,
|
||||||
HTMLCyanLightCyanFilling,
|
HTMLCyanLightCyanFilling,
|
||||||
HTMLCyanPaleTurquoiseFilling,
|
HTMLCyanPaleTurquoiseFilling,
|
||||||
HTMLCyanAquamarineFilling,
|
HTMLCyanAquamarineFilling,
|
||||||
HTMLCyanTurquoiseFilling,
|
HTMLCyanTurquoiseFilling,
|
||||||
HTMLCyanMediumTurquoiseFilling,
|
HTMLCyanMediumTurquoiseFilling,
|
||||||
HTMLCyanDarkTurquoiseFilling,
|
HTMLCyanDarkTurquoiseFilling,
|
||||||
HTMLCyanLightSeaGreenFilling,
|
HTMLCyanLightSeaGreenFilling,
|
||||||
HTMLCyanCadetBlueFilling,
|
HTMLCyanCadetBlueFilling,
|
||||||
HTMLCyanDarkCyanFilling, HTMLCyanTealFilling,
|
HTMLCyanDarkCyanFilling, HTMLCyanTealFilling,
|
||||||
HTMLBlueLightSteelBlueFilling,
|
HTMLBlueLightSteelBlueFilling,
|
||||||
HTMLBluePowderBlueFilling,
|
HTMLBluePowderBlueFilling,
|
||||||
HTMLBlueLightBlueFilling, HTMLBlueSkyBlueFilling,
|
HTMLBlueLightBlueFilling, HTMLBlueSkyBlueFilling,
|
||||||
HTMLBlueLightSkyBlueFilling,
|
HTMLBlueLightSkyBlueFilling,
|
||||||
HTMLBlueDeepSkyBlueFilling,
|
HTMLBlueDeepSkyBlueFilling,
|
||||||
HTMLBlueDodgerBlueFilling,
|
HTMLBlueDodgerBlueFilling,
|
||||||
HTMLBlueCornflowerBlueFilling,
|
HTMLBlueCornflowerBlueFilling,
|
||||||
HTMLBlueSteelBlueFilling,
|
HTMLBlueSteelBlueFilling,
|
||||||
HTMLBlueRoyalBlueFilling, HTMLBlueBlueFilling,
|
HTMLBlueRoyalBlueFilling, HTMLBlueBlueFilling,
|
||||||
HTMLBlueMediumBlueFilling,
|
HTMLBlueMediumBlueFilling,
|
||||||
HTMLBlueDarkBlueFilling, HTMLBlueNavyFilling,
|
HTMLBlueDarkBlueFilling, HTMLBlueNavyFilling,
|
||||||
HTMLBlueMidnightBlueFilling,
|
HTMLBlueMidnightBlueFilling,
|
||||||
HTMLPurpleLavenderFilling,
|
HTMLPurpleLavenderFilling,
|
||||||
HTMLPurpleThistleFilling, HTMLPurplePlumFilling,
|
HTMLPurpleThistleFilling, HTMLPurplePlumFilling,
|
||||||
HTMLPurpleVioletFilling, HTMLPurpleOrchidFilling,
|
HTMLPurpleVioletFilling, HTMLPurpleOrchidFilling,
|
||||||
HTMLPurpleFuchsiaFilling,
|
HTMLPurpleFuchsiaFilling,
|
||||||
HTMLPurpleMagentaFilling,
|
HTMLPurpleMagentaFilling,
|
||||||
HTMLPurpleMediumOrchidFilling,
|
HTMLPurpleMediumOrchidFilling,
|
||||||
HTMLPurpleMediumPurpleFilling,
|
HTMLPurpleMediumPurpleFilling,
|
||||||
HTMLPurpleBlueVioletFilling,
|
HTMLPurpleBlueVioletFilling,
|
||||||
HTMLPurpleDarkVioletFilling,
|
HTMLPurpleDarkVioletFilling,
|
||||||
HTMLPurpleDarkOrchidFilling,
|
HTMLPurpleDarkOrchidFilling,
|
||||||
HTMLPurpleDarkMagentaFilling,
|
HTMLPurpleDarkMagentaFilling,
|
||||||
HTMLPurplePurpleFilling, HTMLPurpleIndigoFilling,
|
HTMLPurplePurpleFilling, HTMLPurpleIndigoFilling,
|
||||||
HTMLPurpleDarkSlateBlueFilling,
|
HTMLPurpleDarkSlateBlueFilling,
|
||||||
HTMLPurpleSlateBlueFilling,
|
HTMLPurpleSlateBlueFilling,
|
||||||
HTMLPurpleMediumSlateBlueFilling,
|
HTMLPurpleMediumSlateBlueFilling,
|
||||||
HTMLWhiteWhiteFilling, HTMLWhiteSnowFilling,
|
HTMLWhiteWhiteFilling, HTMLWhiteSnowFilling,
|
||||||
HTMLWhiteHoneydewFilling,
|
HTMLWhiteHoneydewFilling,
|
||||||
HTMLWhiteMintCreamFilling, HTMLWhiteAzureFilling,
|
HTMLWhiteMintCreamFilling, HTMLWhiteAzureFilling,
|
||||||
HTMLWhiteAliceBlueFilling,
|
HTMLWhiteAliceBlueFilling,
|
||||||
HTMLWhiteGhostWhiteFilling,
|
HTMLWhiteGhostWhiteFilling,
|
||||||
HTMLWhiteWhiteSmokeFilling,
|
HTMLWhiteWhiteSmokeFilling,
|
||||||
HTMLWhiteSeashellFilling, HTMLWhiteBeigeFilling,
|
HTMLWhiteSeashellFilling, HTMLWhiteBeigeFilling,
|
||||||
HTMLWhiteOldLaceFilling,
|
HTMLWhiteOldLaceFilling,
|
||||||
HTMLWhiteFloralWhiteFilling,
|
HTMLWhiteFloralWhiteFilling,
|
||||||
HTMLWhiteIvoryFilling,
|
HTMLWhiteIvoryFilling,
|
||||||
HTMLWhiteAntiqueWhiteFilling,
|
HTMLWhiteAntiqueWhiteFilling,
|
||||||
HTMLWhiteLinenFilling,
|
HTMLWhiteLinenFilling,
|
||||||
HTMLWhiteLavenderBlushFilling,
|
HTMLWhiteLavenderBlushFilling,
|
||||||
HTMLWhiteMistyRoseFilling,
|
HTMLWhiteMistyRoseFilling,
|
||||||
HTMLGrayGainsboroFilling,
|
HTMLGrayGainsboroFilling,
|
||||||
HTMLGrayLightGrayFilling, HTMLGraySilverFilling,
|
HTMLGrayLightGrayFilling, HTMLGraySilverFilling,
|
||||||
HTMLGrayDarkGrayFilling, HTMLGrayGrayFilling,
|
HTMLGrayDarkGrayFilling, HTMLGrayGrayFilling,
|
||||||
HTMLGrayDimGrayFilling,
|
HTMLGrayDimGrayFilling,
|
||||||
HTMLGrayLightSlateGrayFilling,
|
HTMLGrayLightSlateGrayFilling,
|
||||||
HTMLGraySlateGrayFilling,
|
HTMLGraySlateGrayFilling,
|
||||||
HTMLGrayDarkSlateGrayFilling,
|
HTMLGrayDarkSlateGrayFilling,
|
||||||
HTMLGrayBlackFilling, HorFilling, VerFilling,
|
HTMLGrayBlackFilling, HorFilling, VerFilling,
|
||||||
BdiagFilling, FdiagFilling};
|
BdiagFilling, FdiagFilling};
|
||||||
Q_ENUM (Filling)
|
Q_ENUM (Filling)
|
||||||
|
|
||||||
//Line color
|
//Line color
|
||||||
@@ -269,18 +269,18 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
|||||||
~CustomElementGraphicPart() override;
|
~CustomElementGraphicPart() override;
|
||||||
|
|
||||||
static void drawCross (const QPointF ¢er,
|
static void drawCross (const QPointF ¢er,
|
||||||
QPainter *painter);
|
QPainter *painter);
|
||||||
|
|
||||||
//Getter and setter
|
//Getter and setter
|
||||||
LineStyle lineStyle () const {return _linestyle;}
|
LineStyle lineStyle () const {return _linestyle;}
|
||||||
void setLineStyle (const LineStyle ls);
|
void setLineStyle (const LineStyle ls);
|
||||||
|
|
||||||
LineWeight lineWeight () const {return _lineweight;}
|
LineWeight lineWeight () const {return _lineweight;}
|
||||||
void setLineWeight (const LineWeight lw);
|
void setLineWeight (const LineWeight lw);
|
||||||
qreal penWeight () const;
|
qreal penWeight () const;
|
||||||
|
|
||||||
Filling filling () const {return _filling;}
|
Filling filling () const {return _filling;}
|
||||||
void setFilling(const Filling f);
|
void setFilling(const Filling f);
|
||||||
|
|
||||||
Color color () const {return _color;}
|
Color color () const {return _color;}
|
||||||
void setColor(const Color c);
|
void setColor(const Color c);
|
||||||
@@ -299,18 +299,18 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
|||||||
|
|
||||||
virtual QPainterPath shadowShape ()const = 0;
|
virtual QPainterPath shadowShape ()const = 0;
|
||||||
virtual void setHandlerColor(QPointF /*pos*/,
|
virtual void setHandlerColor(QPointF /*pos*/,
|
||||||
const QColor &/*color*/) {}
|
const QColor &/*color*/) {}
|
||||||
virtual void resetAllHandlerColor() {}
|
virtual void resetAllHandlerColor() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void stylesToXml (QDomElement &) const;
|
void stylesToXml (QDomDocument &xml_document, QDomElement &) const;
|
||||||
void stylesFromXml(const QDomElement &);
|
void stylesFromXml(const QDomElement &);
|
||||||
void resetStyles ();
|
void resetStyles ();
|
||||||
void applyStylesToQPainter(QPainter &) const;
|
void applyStylesToQPainter(QPainter &) const;
|
||||||
void drawShadowShape (QPainter *painter);
|
void drawShadowShape (QPainter *painter);
|
||||||
|
|
||||||
QVariant itemChange(GraphicsItemChange change,
|
QVariant itemChange(GraphicsItemChange change,
|
||||||
const QVariant &value) override;
|
const QVariant &value) override;
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#define CUSTOM_ELEMENT_PART_H
|
#define CUSTOM_ELEMENT_PART_H
|
||||||
|
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
|
#include "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
|
||||||
*/
|
*/
|
||||||
@@ -92,7 +85,7 @@ class CustomElementPart {
|
|||||||
Make this part fit into the provided rectangle.
|
Make this part fit into the provided rectangle.
|
||||||
*/
|
*/
|
||||||
virtual void handleUserTransformation(const QRectF &,
|
virtual void handleUserTransformation(const QRectF &,
|
||||||
const QRectF &) = 0;
|
const QRectF &) = 0;
|
||||||
/// @return a pointer to the parent element editor
|
/// @return a pointer to the parent element editor
|
||||||
virtual QETElementEditor *elementEditor() const;
|
virtual QETElementEditor *elementEditor() const;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -102,18 +102,22 @@ 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
|
QDomElement PartArc::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement("arc");
|
QDomElement xml_element = xml_document.createElement("arc");
|
||||||
QPointF top_left(sceneTopLeft());
|
QPointF top_left(sceneTopLeft());
|
||||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
|
||||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
xml_element.appendChild(createXmlProperty(xml_document, "x", top_left.x()));
|
||||||
xml_element.setAttribute("width", QString("%1").arg(rect().width()));
|
xml_element.appendChild(createXmlProperty(xml_document, "y", top_left.y()));
|
||||||
xml_element.setAttribute("height", QString("%1").arg(rect().height()));
|
xml_element.appendChild(createXmlProperty(xml_document, "width", rect().width()));
|
||||||
|
xml_element.appendChild(createXmlProperty(xml_document, "height", rect().height()));
|
||||||
|
|
||||||
//to maintain compatibility with the previous version, we write the angle in degrees.
|
//to maintain compatibility with the previous version, we write the angle in degrees.
|
||||||
xml_element.setAttribute("start", QString("%1").arg(m_start_angle / 16));
|
xml_element.appendChild(createXmlProperty(xml_document, "start", m_start_angle / 16));
|
||||||
xml_element.setAttribute("angle", QString("%1").arg(m_span_angle / 16));
|
xml_element.appendChild(createXmlProperty(xml_document, "angle", m_span_angle / 16));
|
||||||
stylesToXml(xml_element);
|
|
||||||
|
|
||||||
|
stylesToXml(xml_document, xml_element);
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,15 +126,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::fromXml(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 (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(qde, "height", &h) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_rect = QRectF(mapFromScene(x, y), QSizeF(w, h) );
|
||||||
|
|
||||||
|
m_start_angle = 0;
|
||||||
|
if (propertyDouble(qde, "start", &m_start_angle) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
m_start_angle *= 16;
|
||||||
|
|
||||||
|
m_span_angle = -1440;
|
||||||
|
if (propertyDouble(qde, "angle", &m_span_angle) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
m_span_angle *= 16;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PartArc::valideXml(QDomElement& element) {
|
||||||
|
|
||||||
|
if (propertyDouble(element, "x") == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(element, "y") == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(element, "width") == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(element, "height") == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(element, "start") == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(element, "angle") == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -49,10 +49,13 @@ class PartArc : public AbstractPartEllipse
|
|||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||||
|
|
||||||
//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;
|
QDomElement toXml (QDomDocument &) const override;
|
||||||
void fromXml (const QDomElement &) override;
|
bool fromXml (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;
|
||||||
@@ -70,7 +73,7 @@ class PartArc : public AbstractPartEllipse
|
|||||||
void switchResizeMode();
|
void switchResizeMode();
|
||||||
void adjusteHandlerPos();
|
void adjusteHandlerPos();
|
||||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void sceneSelectionChanged ();
|
void sceneSelectionChanged ();
|
||||||
|
|
||||||
|
|||||||
@@ -92,36 +92,37 @@ void PartDynamicTextField::handleUserTransformation(
|
|||||||
@param dom_doc
|
@param dom_doc
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
||||||
{
|
{
|
||||||
QDomElement root_element = dom_doc.createElement(xmlName());
|
QDomElement root_element = dom_doc.createElement(xmlName());
|
||||||
|
|
||||||
root_element.setAttribute("x", QString::number(pos().x()));
|
root_element.appendChild(createXmlProperty(dom_doc, "x", pos().x()));
|
||||||
root_element.setAttribute("y", QString::number(pos().y()));
|
root_element.appendChild(createXmlProperty(dom_doc, "y", pos().y()));
|
||||||
root_element.setAttribute("z", QString::number(zValue()));
|
root_element.appendChild(createXmlProperty(dom_doc, "z", zValue()));
|
||||||
root_element.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
|
root_element.appendChild(createXmlProperty(dom_doc, "rotation", QET::correctAngle(rotation())));
|
||||||
root_element.setAttribute("font", font().toString());
|
|
||||||
root_element.setAttribute("uuid", m_uuid.toString());
|
root_element.appendChild(createXmlProperty(dom_doc, "font", font().toString()));
|
||||||
root_element.setAttribute("frame", m_frame? "true" : "false");
|
root_element.appendChild(createXmlProperty(dom_doc, "uuid", m_uuid));
|
||||||
root_element.setAttribute("text_width", QString::number(m_text_width));
|
root_element.appendChild(createXmlProperty(dom_doc, "frame", m_frame));
|
||||||
|
root_element.appendChild(createXmlProperty(dom_doc, "text_width", m_text_width));
|
||||||
|
|
||||||
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
||||||
root_element.setAttribute("text_from", me.valueToKey(m_text_from));
|
root_element.appendChild(createXmlProperty(dom_doc, "text_from", me.valueToKey(m_text_from)));
|
||||||
|
|
||||||
me = QMetaEnum::fromType<Qt::Alignment>();
|
me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
if(this -> alignment() &Qt::AlignRight)
|
if(this -> alignment() &Qt::AlignRight)
|
||||||
root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignRight));
|
root_element.appendChild(createXmlProperty(dom_doc, "Halignment", me.valueToKey(Qt::AlignRight)));
|
||||||
else if(this -> alignment() &Qt::AlignLeft)
|
else if(this -> alignment() &Qt::AlignLeft)
|
||||||
root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignLeft));
|
root_element.appendChild(createXmlProperty(dom_doc, "Halignment", me.valueToKey(Qt::AlignLeft)));
|
||||||
else if(this -> alignment() &Qt::AlignHCenter)
|
else if(this -> alignment() &Qt::AlignHCenter)
|
||||||
root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignHCenter));
|
root_element.appendChild(createXmlProperty(dom_doc, "Halignment", me.valueToKey(Qt::AlignHCenter)));
|
||||||
|
|
||||||
if(this -> alignment() &Qt::AlignBottom)
|
if(this -> alignment() &Qt::AlignBottom)
|
||||||
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignBottom));
|
root_element.appendChild(createXmlProperty(dom_doc, "Valignment", me.valueToKey(Qt::AlignBottom)));
|
||||||
else if(this -> alignment() & Qt::AlignTop)
|
else if(this -> alignment() & Qt::AlignTop)
|
||||||
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignTop));
|
root_element.appendChild(createXmlProperty(dom_doc, "Valignment", me.valueToKey(Qt::AlignTop)));
|
||||||
else if(this -> alignment() &Qt::AlignVCenter)
|
else if(this -> alignment() &Qt::AlignVCenter)
|
||||||
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignVCenter));
|
root_element.appendChild(createXmlProperty(dom_doc, "Valignment", me.valueToKey(Qt::AlignVCenter)));
|
||||||
|
|
||||||
QDomElement dom_text = dom_doc.createElement("text");
|
QDomElement dom_text = dom_doc.createElement("text");
|
||||||
dom_text.appendChild(dom_doc.createTextNode(toPlainText()));
|
dom_text.appendChild(dom_doc.createTextNode(toPlainText()));
|
||||||
@@ -155,25 +156,31 @@ const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
|||||||
@brief PartDynamicTextField::fromXml
|
@brief PartDynamicTextField::fromXml
|
||||||
@param dom_elmt
|
@param dom_elmt
|
||||||
*/
|
*/
|
||||||
void PartDynamicTextField::fromXml(const QDomElement &dom_elmt) {
|
bool PartDynamicTextField::fromXml(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 (propertyDouble(dom_elmt, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||||
dom_elmt.attribute("y", QString::number(0)).toDouble()
|
propertyDouble(dom_elmt, "y", &y) == PropertyFlags::NoValidConversion ||
|
||||||
);
|
propertyDouble(dom_elmt, "z", &z) == PropertyFlags::NoValidConversion ||
|
||||||
setZValue(dom_elmt.attribute("z", QString::number(zValue())).toDouble());
|
propertyDouble(dom_elmt, "rotation", &rot) == 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 (propertyString(dom_elmt, "font", &font) == 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
|
||||||
@@ -181,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()));
|
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());
|
propertyBool(dom_elmt, "frame", &frame);
|
||||||
|
|
||||||
|
double text_width=-1;
|
||||||
|
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()));
|
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(propertyString(dom_elmt, "Halignment", &alignment) != PropertyFlags::NotFound)
|
||||||
me.keyToValue(dom_elmt.attribute("Halignment").toStdString().data())));
|
setAlignment(Qt::Alignment(me.keyToValue(alignment.toStdString().data())));
|
||||||
if(dom_elmt.hasAttribute(("Valignment")))
|
if(propertyString(dom_elmt, "Valignment", &alignment) != 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());
|
||||||
|
|
||||||
@@ -220,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 (propertyDouble(dom_elmt, "x") == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(dom_elmt, "y") == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(dom_elmt, "z") == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(dom_elmt, "rotation") == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (propertyUuid(dom_elmt, "uuid") == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (propertyString(dom_elmt, "text_from"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(propertyString(dom_elmt, "Halignment") == PropertyFlags::NotFound)
|
||||||
|
return false;
|
||||||
|
if(propertyString(dom_elmt, "Valignment") == PropertyFlags::NotFound)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -463,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;
|
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||||
void fromXml(const QDomElement &dom_elmt) override;
|
bool fromXml(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;
|
||||||
|
|||||||
@@ -83,26 +83,26 @@ void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
|||||||
@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 PartEllipse::toXml(QDomDocument &xml_document) const
|
QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element;
|
QDomElement xml_element;
|
||||||
if (qFuzzyCompare(rect().width(), rect().height()))
|
if (qFuzzyCompare(rect().width(), rect().height()))
|
||||||
{
|
{
|
||||||
xml_element = xml_document.createElement("circle");
|
xml_element = xml_document.createElement("circle");
|
||||||
xml_element.setAttribute("diameter", QString("%1").arg(rect().width()));
|
xml_element.appendChild(createXmlProperty(xml_document, "diameter", rect().width()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xml_element = xml_document.createElement("ellipse");
|
xml_element = xml_document.createElement("ellipse");
|
||||||
xml_element.setAttribute("width", QString("%1").arg(rect().width()));
|
xml_element.appendChild(createXmlProperty(xml_document, "width", rect().width()));
|
||||||
xml_element.setAttribute("height", QString("%1").arg(rect().height()));
|
xml_element.appendChild(createXmlProperty(xml_document, "height", rect().height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF top_left(sceneTopLeft());
|
QPointF top_left(sceneTopLeft());
|
||||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
xml_element.appendChild(createXmlProperty(xml_document, "x", top_left.x()));
|
||||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
xml_element.appendChild(createXmlProperty(xml_document, "y", top_left.y()));
|
||||||
|
|
||||||
stylesToXml(xml_element);
|
stylesToXml(xml_document, xml_element);
|
||||||
|
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
@@ -112,22 +112,51 @@ const QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
|||||||
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::fromXml(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 (propertyDouble(qde, "width", &width) == PropertyFlags::NoValidConversion ||
|
||||||
height = qde.attribute("height", "0").toDouble();
|
propertyDouble(qde, "height", &height) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (propertyDouble(qde, "diameter", &width) == 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 (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||||
QSizeF(width, height));
|
propertyDouble(qde, "y", &y) == 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 (propertyDouble(element, "width") & PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(element, "height") & PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (propertyDouble(element, "diameter") & PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ((propertyDouble(element, "x") & PropertyFlags::NoValidConversion) ||
|
||||||
|
(propertyDouble(element, "y") & PropertyFlags::NoValidConversion))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -50,10 +50,13 @@ class PartEllipse : public AbstractPartEllipse
|
|||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||||
|
|
||||||
//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;
|
QDomElement toXml (QDomDocument &) const override;
|
||||||
void fromXml (const QDomElement &) override;
|
bool fromXml (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();}
|
||||||
@@ -67,7 +70,7 @@ class PartEllipse : public AbstractPartEllipse
|
|||||||
void switchResizeMode();
|
void switchResizeMode();
|
||||||
void adjusteHandlerPos();
|
void adjusteHandlerPos();
|
||||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void sceneSelectionChanged ();
|
void sceneSelectionChanged ();
|
||||||
|
|
||||||
|
|||||||
@@ -109,22 +109,24 @@ void PartLine::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 line
|
@return an xml element that describe this line
|
||||||
*/
|
*/
|
||||||
const QDomElement PartLine::toXml(QDomDocument &xml_document) const
|
QDomElement PartLine::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QPointF p1(sceneP1());
|
QPointF p1(sceneP1());
|
||||||
QPointF p2(sceneP2());
|
QPointF p2(sceneP2());
|
||||||
|
|
||||||
QDomElement xml_element = xml_document.createElement("line");
|
QDomElement xml_element = xml_document.createElement("line");
|
||||||
xml_element.setAttribute("x1", QString("%1").arg(p1.x()));
|
|
||||||
xml_element.setAttribute("y1", QString("%1").arg(p1.y()));
|
|
||||||
xml_element.setAttribute("x2", QString("%1").arg(p2.x()));
|
|
||||||
xml_element.setAttribute("y2", QString("%1").arg(p2.y()));
|
|
||||||
xml_element.setAttribute("end1", Qet::endTypeToString(first_end));
|
|
||||||
xml_element.setAttribute("length1", QString("%1").arg(first_length));
|
|
||||||
xml_element.setAttribute("end2", Qet::endTypeToString(second_end));
|
|
||||||
xml_element.setAttribute("length2", QString("%1").arg(second_length));
|
|
||||||
|
|
||||||
stylesToXml(xml_element);
|
xml_element.appendChild(createXmlProperty(xml_document, "x1", p1.x()));
|
||||||
|
xml_element.appendChild(createXmlProperty(xml_document, "y1", p1.y()));
|
||||||
|
xml_element.appendChild(createXmlProperty(xml_document, "x2", p2.x()));
|
||||||
|
xml_element.appendChild(createXmlProperty(xml_document, "y2", p2.y()));
|
||||||
|
|
||||||
|
xml_element.appendChild(createXmlProperty(xml_document, "end1", Qet::endTypeToString(first_end)));
|
||||||
|
xml_element.appendChild(createXmlProperty(xml_document, "length1", first_length));
|
||||||
|
xml_element.appendChild(createXmlProperty(xml_document, "end2", Qet::endTypeToString(second_end)));
|
||||||
|
xml_element.appendChild(createXmlProperty(xml_document, "length2", second_length));
|
||||||
|
|
||||||
|
stylesToXml(xml_document, xml_element);
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,17 +135,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::fromXml(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 (propertyDouble(qde, "x1", &x1) == PropertyFlags::NoValidConversion ||
|
||||||
second_end = Qet::endTypeFromString(qde.attribute("end2"));
|
propertyDouble(qde, "y1", &y1) == PropertyFlags::NoValidConversion ||
|
||||||
second_length = qde.attribute("length2", "1.5").toDouble();
|
propertyDouble(qde, "x2", &x2) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(qde, "y2", &y2) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_line = QLineF(mapFromScene(x1, y1),
|
||||||
|
mapFromScene(x2, y2));
|
||||||
|
|
||||||
|
QString s;
|
||||||
|
if (propertyString(qde, "end1", &s) != PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
first_end = Qet::endTypeFromString(s);
|
||||||
|
|
||||||
|
if (propertyString(qde, "end2", &s) != PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
first_end = Qet::endTypeFromString(s);
|
||||||
|
|
||||||
|
if (propertyDouble(qde, "length1", &first_length) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(qde, "length2", &second_length) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PartLine::valideXml(QDomElement& element) const {
|
||||||
|
if (propertyDouble(element, "x1") ||
|
||||||
|
propertyDouble(element, "y1") ||
|
||||||
|
propertyDouble(element, "x2") ||
|
||||||
|
propertyDouble(element, "y2") ||
|
||||||
|
propertyString(element, "end1") ||
|
||||||
|
propertyString(element, "end2") ||
|
||||||
|
propertyDouble(element, "length1") ||
|
||||||
|
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;
|
QDomElement toXml(QDomDocument &) const override;
|
||||||
void fromXml(const QDomElement &) override;
|
bool fromXml(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;
|
||||||
@@ -102,7 +105,7 @@ class PartLine : public CustomElementGraphicPart
|
|||||||
private:
|
private:
|
||||||
void adjusteHandlerPos();
|
void adjusteHandlerPos();
|
||||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void sceneSelectionChanged ();
|
void sceneSelectionChanged ();
|
||||||
|
|
||||||
@@ -115,10 +118,10 @@ class PartLine : public CustomElementGraphicPart
|
|||||||
|
|
||||||
/*****************/
|
/*****************/
|
||||||
Qet::EndType first_end;
|
Qet::EndType first_end;
|
||||||
qreal first_length;
|
qreal first_length{1.5};
|
||||||
|
|
||||||
Qet::EndType second_end;
|
Qet::EndType second_end;
|
||||||
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;
|
||||||
|
|||||||
@@ -89,29 +89,37 @@ 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::fromXml(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 (propertyDouble(qde, QString("x%1").arg(i)) == PropertyFlags::Success &&
|
||||||
QET::attributeIsAReal(qde, QString("y%1").arg(i)))
|
propertyDouble(qde, QString("y%1").arg(i)) == 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 += propertyDouble(qde, QString("x%1").arg(j), &x);
|
||||||
qde.attribute(QString("y%1").arg(j)).toDouble());
|
error_counter += 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 (propertyBool(qde, "closed", &m_closed) != PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,21 +128,28 @@ void PartPolygon::fromXml(const QDomElement &qde)
|
|||||||
@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 polygon
|
@return an xml element that describe this polygon
|
||||||
*/
|
*/
|
||||||
const QDomElement PartPolygon::toXml(QDomDocument &xml_document) const
|
QDomElement PartPolygon::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement("polygon");
|
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);
|
||||||
xml_element.setAttribute(QString("x%1").arg(i), QString("%1").arg(point.x()));
|
xml_element.appendChild(createXmlProperty(xml_document, QString("x%1").arg(i), point.x()));
|
||||||
xml_element.setAttribute(QString("y%1").arg(i), QString("%1").arg(point.y()));
|
xml_element.appendChild(createXmlProperty(xml_document, QString("y%1").arg(i), point.y()));
|
||||||
++ i;
|
++ i;
|
||||||
}
|
}
|
||||||
if (!m_closed) xml_element.setAttribute("closed", "false");
|
|
||||||
stylesToXml(xml_element);
|
xml_element.appendChild(createXmlProperty(xml_document, "closed", m_closed));
|
||||||
|
|
||||||
|
stylesToXml(xml_document, xml_element);
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PartPolygon::valideXml(QDomElement& element) {
|
||||||
|
// TODO: implement
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartPolygon::isUseless
|
@brief PartPolygon::isUseless
|
||||||
@return true if this part is irrelevant and does not deserve to be Retained / registered.
|
@return true if this part is irrelevant and does not deserve to be Retained / registered.
|
||||||
@@ -525,7 +540,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 fromXml(const QDomElement &) override;
|
||||||
const QDomElement toXml(QDomDocument &) const override;
|
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*/}
|
||||||
|
|
||||||
|
|
||||||
QPainterPath shape () const override;
|
QPainterPath shape () const override;
|
||||||
QPainterPath shadowShape() const override;
|
QPainterPath shadowShape() const override;
|
||||||
@@ -77,8 +81,8 @@ class PartPolygon : public CustomElementGraphicPart
|
|||||||
QPolygonF polygon () const;
|
QPolygonF polygon () const;
|
||||||
void setPolygon (const QPolygonF &polygon);
|
void setPolygon (const QPolygonF &polygon);
|
||||||
|
|
||||||
void addPoint (const QPointF &point);
|
void addPoint (const QPointF &point);
|
||||||
void setLastPoint (const QPointF &point);
|
void setLastPoint (const QPointF &point);
|
||||||
void removeLastPoint ();
|
void removeLastPoint ();
|
||||||
|
|
||||||
bool isClosed () const {return m_closed;}
|
bool isClosed () const {return m_closed;}
|
||||||
@@ -95,7 +99,7 @@ class PartPolygon : public CustomElementGraphicPart
|
|||||||
private:
|
private:
|
||||||
void adjusteHandlerPos();
|
void adjusteHandlerPos();
|
||||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void sceneSelectionChanged ();
|
void sceneSelectionChanged ();
|
||||||
|
|
||||||
|
|||||||
@@ -84,14 +84,15 @@ void PartRectangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
|
|||||||
@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
|
QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement("rect");
|
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("y", QString("%1").arg(top_left.y()));
|
xml_element.appendChild(createXmlProperty(xml_document, "x", top_left.x()));
|
||||||
xml_element.setAttribute("width", QString("%1").arg(m_rect.width()));
|
xml_element.appendChild(createXmlProperty(xml_document, "y", top_left.y()));
|
||||||
xml_element.setAttribute("height", QString("%1").arg(m_rect.height()));
|
xml_element.appendChild(createXmlProperty(xml_document, "width", m_rect.width()));
|
||||||
|
xml_element.appendChild(createXmlProperty(xml_document, "height", m_rect.height()));
|
||||||
|
|
||||||
QRectF rect = m_rect.normalized();
|
QRectF rect = m_rect.normalized();
|
||||||
qreal x = m_xRadius;
|
qreal x = m_xRadius;
|
||||||
@@ -106,7 +107,10 @@ const QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
|||||||
xml_element.setAttribute("rx", QString::number(m_xRadius));
|
xml_element.setAttribute("rx", QString::number(m_xRadius));
|
||||||
xml_element.setAttribute("ry", QString::number(m_yRadius));
|
xml_element.setAttribute("ry", QString::number(m_yRadius));
|
||||||
|
|
||||||
stylesToXml(xml_element);
|
xml_element.appendChild(createXmlProperty(xml_document, "rx", m_xRadius));
|
||||||
|
xml_element.appendChild(createXmlProperty(xml_document, "ry", m_yRadius));
|
||||||
|
|
||||||
|
stylesToXml(xml_document, xml_element);
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,18 +119,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::fromXml(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 (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
setPos(mapFromScene(x, y));
|
||||||
|
|
||||||
|
if (propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(qde, "height", &h) == 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 (propertyDouble(qde, "rx", &rx) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(qde, "ry", &ry) == 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 ((propertyDouble(element, "x") & PropertyFlags::NoValidConversion) |
|
||||||
|
(propertyDouble(element, "y") & PropertyFlags::NoValidConversion) |
|
||||||
|
(propertyDouble(element, "width") & PropertyFlags::NoValidConversion) |
|
||||||
|
(propertyDouble(element, "height") & PropertyFlags::NoValidConversion) |
|
||||||
|
(propertyDouble(element, "rx") & PropertyFlags::NoValidConversion) |
|
||||||
|
(propertyDouble(element, "ry") & PropertyFlags::NoValidConversion))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -536,9 +567,9 @@ void PartRectangle::addHandler()
|
|||||||
for (QetGraphicsHandlerItem *handler : m_handler_vector)
|
for (QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||||
{
|
{
|
||||||
QColor color;
|
QColor color;
|
||||||
if(m_resize_mode == 1) {color = Qt::blue;}
|
if(m_resize_mode == 1) {color = Qt::blue;}
|
||||||
else if (m_resize_mode == 2) {color = Qt::darkGreen;}
|
else if (m_resize_mode == 2) {color = Qt::darkGreen;}
|
||||||
else {color = Qt::magenta;}
|
else {color = Qt::magenta;}
|
||||||
|
|
||||||
handler->setColor(color);
|
handler->setColor(color);
|
||||||
scene()->addItem(handler);
|
scene()->addItem(handler);
|
||||||
|
|||||||
@@ -55,13 +55,16 @@ class PartRectangle : public CustomElementGraphicPart
|
|||||||
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartRectangle.
|
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartRectangle.
|
||||||
@return the QGraphicsItem type
|
@return the QGraphicsItem type
|
||||||
*/
|
*/
|
||||||
int type () const override { return Type; }
|
int type () const override { return Type; }
|
||||||
void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||||
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;
|
QDomElement toXml (QDomDocument &) const override;
|
||||||
void fromXml (const QDomElement &) override;
|
bool fromXml (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);
|
||||||
@@ -90,7 +93,7 @@ class PartRectangle : public CustomElementGraphicPart
|
|||||||
void switchResizeMode();
|
void switchResizeMode();
|
||||||
void adjusteHandlerPos();
|
void adjusteHandlerPos();
|
||||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void sceneSelectionChanged ();
|
void sceneSelectionChanged ();
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent) :
|
|||||||
CustomElementGraphicPart(editor, parent)
|
CustomElementGraphicPart(editor, parent)
|
||||||
{
|
{
|
||||||
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();
|
||||||
@@ -44,10 +45,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::fromXml(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
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,9 +66,25 @@ 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
|
QDomElement PartTerminal::toXml(QDomDocument &xml_document) const {
|
||||||
{
|
|
||||||
return d -> toXml(xml_document);
|
QDomElement qdo = xml_document.createElement("terminal");
|
||||||
|
|
||||||
|
qdo.appendChild(createXmlProperty(xml_document, "uuid", d->m_uuid));
|
||||||
|
|
||||||
|
d->m_pos = pos();
|
||||||
|
|
||||||
|
// Do not store terminal data in its own child
|
||||||
|
QDomElement terminalDataElement = d->toXml(xml_document);
|
||||||
|
for (int i=0; i < terminalDataElement.childNodes().length(); i++) {
|
||||||
|
qdo.appendChild(terminalDataElement.childNodes().at(i).cloneNode()); // cloneNode() is important, otherwise no deep clone is made
|
||||||
|
}
|
||||||
|
|
||||||
|
return qdo;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PartTerminal::valideXml(QDomElement& element) {
|
||||||
|
return TerminalData::valideXml(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,8 +102,8 @@ void PartTerminal::paint(
|
|||||||
painter -> save();
|
painter -> save();
|
||||||
|
|
||||||
// annulation des renderhints
|
// annulation des renderhints
|
||||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||||
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||||
|
|
||||||
QPen t;
|
QPen t;
|
||||||
|
|||||||
@@ -53,9 +53,12 @@ class PartTerminal : public CustomElementGraphicPart {
|
|||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
QString name() const override { return d -> m_name; }
|
QString name() const override { return d -> m_name; }
|
||||||
QString xmlName() const override { return(QString("terminal")); }
|
QString xmlName() const override { return(QString("terminal")); }
|
||||||
void fromXml(const QDomElement &) override;
|
bool fromXml(const QDomElement &) override;
|
||||||
const QDomElement toXml(QDomDocument &) const override;
|
QDomElement toXml(QDomDocument &) const override;
|
||||||
void paint(
|
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(
|
||||||
QPainter *painter,
|
QPainter *painter,
|
||||||
const QStyleOptionGraphicsItem *,
|
const QStyleOptionGraphicsItem *,
|
||||||
QWidget *) override;
|
QWidget *) override;
|
||||||
@@ -76,7 +79,7 @@ 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 saved_position_;
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ PartText::PartText(QETElementEditor *editor, QGraphicsItem *parent) :
|
|||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
setDefaultTextColor(Qt::black);
|
setDefaultTextColor(Qt::black);
|
||||||
setPlainText(QObject::tr(
|
setPlainText(QObject::tr(
|
||||||
"T",
|
"T",
|
||||||
"default text when adding a text in the element editor"));
|
"default text when adding a text in the element editor"));
|
||||||
|
|
||||||
adjustItemPosition(1);
|
adjustItemPosition(1);
|
||||||
// adjust textfield position after line additions/deletions
|
// adjust textfield position after line additions/deletions
|
||||||
@@ -66,29 +66,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::fromXml(const QDomElement &xml_element)
|
||||||
bool ok;
|
{
|
||||||
|
int size;
|
||||||
|
QString font;
|
||||||
|
|
||||||
if (xml_element.hasAttribute("size")) {
|
if (propertyInteger(xml_element, "size", &size) != 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 (propertyString(xml_element, "font", &font) != 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(),
|
propertyColor(xml_element, "color", &color);
|
||||||
xml_element.attribute("y").toDouble());
|
setDefaultTextColor(color);
|
||||||
setRotation(xml_element.attribute("rotation", QString::number(0)).toDouble());
|
|
||||||
|
|
||||||
|
propertyString(xml_element, "text", &text);
|
||||||
|
setPlainText(text);
|
||||||
|
|
||||||
|
double x=0, y=0, rot=0;
|
||||||
|
if (propertyDouble(xml_element, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(xml_element, "y", &y) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
setPos(x, y);
|
||||||
|
|
||||||
|
if (propertyDouble(xml_element, "rotation", &rot) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
setRotation(rot);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,20 +116,44 @@ 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
|
QDomElement PartText::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement(xmlName());
|
QDomElement xml_element = xml_document.createElement(xmlName());
|
||||||
|
|
||||||
xml_element.setAttribute("x", QString::number(pos().x()));
|
xml_element.appendChild(createXmlProperty(xml_document, "x", pos().x()));
|
||||||
xml_element.setAttribute("y", QString::number(pos().y()));
|
xml_element.appendChild(createXmlProperty(xml_document, "y", pos().y()));
|
||||||
xml_element.setAttribute("text", toPlainText());
|
xml_element.appendChild(createXmlProperty(xml_document, "text", toPlainText()));
|
||||||
xml_element.setAttribute("font", font().toString());
|
xml_element.appendChild(createXmlProperty(xml_document, "font", font().toString()));
|
||||||
xml_element.setAttribute("rotation", QString::number(rotation()));
|
xml_element.appendChild(createXmlProperty(xml_document, "rotation", rotation()));
|
||||||
xml_element.setAttribute("color", defaultTextColor().name());
|
xml_element.appendChild(createXmlProperty(xml_document, "color", defaultTextColor().name()));
|
||||||
|
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PartText::valideXml(QDomElement& element) {
|
||||||
|
|
||||||
|
if (propertyInteger(element, "size") == PropertyFlags::NotFound ||
|
||||||
|
propertyString(element, "font") == PropertyFlags::NotFound) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (propertyString(element, "color") == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
if (propertyString(element, "text"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (propertyDouble(element, "x") == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(element, "y") == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (propertyDouble(element, "rotation", 0) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return Les coordonnees du point situe en bas a gauche du texte.
|
@return Les coordonnees du point situe en bas a gauche du texte.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -58,8 +58,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 fromXml(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*/}
|
||||||
|
QDomElement toXml(QDomDocument &) 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;
|
||||||
|
|||||||
@@ -108,8 +108,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");
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,15 @@ void Machine_info::send_info_to_debug()
|
|||||||
+ " x "
|
+ " x "
|
||||||
+ QString::number(pc.screen.height[ii])
|
+ QString::number(pc.screen.height[ii])
|
||||||
+ " )";
|
+ " )";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Machine_info::~Machine_info
|
||||||
|
destructor
|
||||||
|
*/
|
||||||
|
Machine_info::~Machine_info()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,19 @@
|
|||||||
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>
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Available property types
|
||||||
|
*/
|
||||||
|
namespace {
|
||||||
|
const QString integerS = "int";
|
||||||
|
const QString doubleS = "double";
|
||||||
|
const QString boolS = "bool";
|
||||||
|
const QString stringS = "string";
|
||||||
|
const QString uuidS = "uuid";
|
||||||
|
const QString colorS = "color";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PropertiesInterface::PropertiesInterface
|
@brief PropertiesInterface::PropertiesInterface
|
||||||
@@ -23,10 +36,303 @@
|
|||||||
PropertiesInterface::PropertiesInterface()
|
PropertiesInterface::PropertiesInterface()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PropertiesInterface::~PropertiesInterface
|
@brief PropertiesInterface::~PropertiesInterface
|
||||||
*/
|
*/
|
||||||
PropertiesInterface::~PropertiesInterface()
|
PropertiesInterface::~PropertiesInterface()
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PropertiesInterface::valideXml(QDomElement& element) {
|
||||||
|
qDebug(QString("ValideXml() is not implemented. File: %1, Line: %2").arg(__FILE__).arg(__LINE__).toStdString().data());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument &doc, const QString& name, const QString value) {
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", stringS);
|
||||||
|
p.setAttribute("value", value);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument &doc, const QString& name, const char* value) {
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", stringS);
|
||||||
|
p.setAttribute("value", value);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const int value) {
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", integerS);
|
||||||
|
p.setAttribute("value", QString::number(value));
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const double value) {
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", doubleS);
|
||||||
|
p.setAttribute("value", QString::number(value));
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const bool value) {
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", boolS);
|
||||||
|
p.setAttribute("value", QString::number(value));
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const QUuid value) {
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", uuidS);
|
||||||
|
p.setAttribute("value", value.toString());
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const QColor value) {
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", colorS);
|
||||||
|
p.setAttribute("value", value.name());
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomElement PropertiesInterface::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 PropertiesInterface::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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \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
|
||||||
|
*/
|
||||||
|
PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier) {
|
||||||
|
|
||||||
|
QString attr;
|
||||||
|
|
||||||
|
if (!attribute(e, attribute_name, integerS, &attr)) {
|
||||||
|
return PropertyFlags::NotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
// verifie la validite de l'attribut
|
||||||
|
bool ok;
|
||||||
|
int tmp = attr.toInt(&ok);
|
||||||
|
if (!ok) {
|
||||||
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << integerS << ". value: " << attr;
|
||||||
|
return PropertyFlags::NoValidConversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entier != nullptr)
|
||||||
|
*entier = tmp;
|
||||||
|
|
||||||
|
return PropertyFlags::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDomElement &e, const QString& attribute_name, double* reel) {
|
||||||
|
|
||||||
|
QString attr;
|
||||||
|
|
||||||
|
if (!attribute(e, attribute_name, doubleS, &attr)) {
|
||||||
|
return PropertyFlags::NotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
// verifie la validite de l'attribut
|
||||||
|
bool ok;
|
||||||
|
double tmp = attr.toDouble(&ok);
|
||||||
|
if (!ok) {
|
||||||
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << doubleS << ". value: " << attr;
|
||||||
|
return PropertyFlags::NoValidConversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reel != nullptr)
|
||||||
|
*reel = tmp;
|
||||||
|
|
||||||
|
return PropertyFlags::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean) {
|
||||||
|
|
||||||
|
QString attr;
|
||||||
|
|
||||||
|
if (!attribute(e, attribute_name, boolS, &attr)) {
|
||||||
|
return PropertyFlags::NotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
// verifie la validite de l'attribut
|
||||||
|
bool ok;
|
||||||
|
bool tmp = attr.toInt(&ok);
|
||||||
|
if (!ok) {
|
||||||
|
if (attr == "true" || attr == "1")
|
||||||
|
tmp = true;
|
||||||
|
else if (attr == "false" || attr == "0")
|
||||||
|
tmp = false;
|
||||||
|
else {
|
||||||
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << integerS << ". value: " << attr;
|
||||||
|
return PropertyFlags::NoValidConversion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (boolean != nullptr)
|
||||||
|
*boolean = tmp;
|
||||||
|
|
||||||
|
return PropertyFlags::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color) {
|
||||||
|
|
||||||
|
QString attr;
|
||||||
|
|
||||||
|
if (!attribute(e, attribute_name, colorS, &attr)) {
|
||||||
|
return PropertyFlags::NotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
// verifie la validite de l'attribut
|
||||||
|
QColor tmp = QColor(attr);
|
||||||
|
if (!tmp.isValid()) {
|
||||||
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << colorS << ". value: " << attr;
|
||||||
|
return PropertyFlags::NoValidConversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (color != nullptr)
|
||||||
|
*color = tmp;
|
||||||
|
|
||||||
|
return PropertyFlags::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid) {
|
||||||
|
QString attr;
|
||||||
|
|
||||||
|
if (!attribute(e, attribute_name, uuidS, &attr)) {
|
||||||
|
return PropertyFlags::NotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (QUuid(attr).isNull()){
|
||||||
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << uuidS << ". value: " << attr;
|
||||||
|
return PropertyFlags::NoValidConversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (uuid != nullptr)
|
||||||
|
*uuid = QUuid(attr);
|
||||||
|
|
||||||
|
return PropertyFlags::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertiesInterface::PropertyFlags PropertiesInterface::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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \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 PropertiesInterface::validXmlProperty(const QDomElement& e) {
|
||||||
|
if (!e.hasAttribute("name"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!e.hasAttribute("type"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!e.hasAttribute("value"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,11 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QColor>
|
||||||
#include <QDomElement>
|
#include <QDomElement>
|
||||||
|
#include <limits>
|
||||||
|
#include "qet.h"
|
||||||
|
#include <QUuid>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The PropertiesInterface class
|
@brief The PropertiesInterface class
|
||||||
@@ -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,8 +52,8 @@ 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
|
||||||
@@ -64,6 +68,59 @@ class PropertiesInterface
|
|||||||
@return true / false
|
@return true / false
|
||||||
*/
|
*/
|
||||||
virtual bool fromXml (const QDomElement &xml_element) =0;
|
virtual bool fromXml (const QDomElement &xml_element) =0;
|
||||||
|
static bool valideXml(QDomElement& element);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Use this functions to add properties to the xml document
|
||||||
|
*/
|
||||||
|
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const QString value);
|
||||||
|
static QDomElement createXmlProperty(QDomDocument &doc, const QString& name, const char* value);
|
||||||
|
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const int value);
|
||||||
|
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const double value);
|
||||||
|
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const bool value);
|
||||||
|
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const QUuid value);
|
||||||
|
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const QColor value);
|
||||||
|
|
||||||
|
static QDomElement property(const QDomElement& e, const QString& name);
|
||||||
|
static bool attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr);
|
||||||
|
|
||||||
|
enum PropertyFlags {
|
||||||
|
Success = 0,
|
||||||
|
NotFound = 1,
|
||||||
|
NoValidConversion = 2,
|
||||||
|
// = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Try not using the default Value feature. It is better to initialize the class members in the class definition!
|
||||||
|
*/
|
||||||
|
static PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr);
|
||||||
|
static PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr);
|
||||||
|
static PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr);
|
||||||
|
static PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr);
|
||||||
|
static PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr);
|
||||||
|
static PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr);
|
||||||
|
|
||||||
|
|
||||||
|
static bool validXmlProperty(const QDomElement& e);
|
||||||
|
|
||||||
|
QVariant XmlProperty(const QDomElement& element);
|
||||||
|
|
||||||
|
/**
|
||||||
|
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROPERTIESINTERFACE_H
|
#endif // PROPERTIESINTERFACE_H
|
||||||
|
|||||||
@@ -41,7 +41,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);
|
||||||
@@ -56,7 +56,7 @@ 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);
|
||||||
@@ -76,26 +76,22 @@ void TerminalData::fromSettings(const QSettings &settings, const QString prefix)
|
|||||||
*/
|
*/
|
||||||
QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement("terminal");
|
QDomElement xml_element = xml_document.createElement("terminaldata");
|
||||||
|
|
||||||
// write the position of the terminal
|
// write the position of the terminal
|
||||||
// ecrit la position de la borne
|
|
||||||
xml_element.setAttribute("x", QString("%1").arg(q->scenePos().x()));
|
|
||||||
xml_element.setAttribute("y", QString("%1").arg(q->scenePos().y()));
|
|
||||||
|
|
||||||
// Write name and number to XML
|
// Write name and number to XML
|
||||||
xml_element.setAttribute("uuid", m_uuid.toString());
|
// m_pos cannot be stored, because in the partterminal it will not be updated.
|
||||||
xml_element.setAttribute("name", m_name);
|
// In PartTerminal m_pos is the position of the dock, in Terminal m_pos is the second side of the terminal
|
||||||
|
// This is hold for legacy compability reason
|
||||||
// write the orientation of the terminal
|
xml_element.appendChild(createXmlProperty(xml_document, "x", m_pos.x()));
|
||||||
// ecrit l'orientation de la borne
|
xml_element.appendChild(createXmlProperty(xml_document, "y", m_pos.y()));
|
||||||
xml_element.setAttribute("orientation",
|
xml_element.appendChild(createXmlProperty(xml_document, "name", m_name));
|
||||||
Qet::orientationToString(m_orientation));
|
xml_element.appendChild(createXmlProperty(xml_document, "orientation", orientationToString(m_orientation)));
|
||||||
|
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
@brief TerminalData::fromXml
|
@brief TerminalData::fromXml
|
||||||
load properties to xml element
|
load properties to xml element
|
||||||
|
|
||||||
@@ -104,38 +100,59 @@ 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::fromXml (const QDomElement &xml_element) // RETURNS True
|
||||||
{
|
{
|
||||||
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 (propertyDouble(xml_element, "x", &term_x))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!QET::attributeIsAReal(xml_element, "y", &term_y))
|
if (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 (propertyString(xml_element, "name", &m_name))
|
||||||
|
// return false;
|
||||||
|
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 (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"));
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TerminalData::valideXml(const QDomElement& xml_element) {
|
||||||
|
if (propertyDouble(xml_element, "x"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (propertyDouble(xml_element, "y"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// legacy elements do not have an uuid
|
||||||
|
// if (propertyUuid(xml_element, "uuid"))
|
||||||
|
// return false;
|
||||||
|
|
||||||
|
//if (propertyString(xml_element, "name")) // some parts do not have a name. Example: affuteuse_250h.qet, Terminal at x="0" y="-20"
|
||||||
|
// return false;
|
||||||
|
|
||||||
|
if (propertyString(xml_element, "orientation"))
|
||||||
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,26 +27,26 @@ 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;
|
QDomElement toXml(QDomDocument &xml_element) const override;
|
||||||
bool fromXml(const QDomElement &xml_element) override;
|
bool fromXml(const QDomElement &xml_element) override;
|
||||||
|
|
||||||
// must be public, because this class is a private member
|
static bool valideXml(const QDomElement &xml_element);
|
||||||
// of PartTerminal/Terminal and they must access this data
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@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 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 second_point;
|
QPointF second_point{0,0};
|
||||||
/**
|
/**
|
||||||
@brief m_uuid
|
@brief m_uuid
|
||||||
Uuid of the terminal.
|
Uuid of the terminal.
|
||||||
@@ -61,7 +61,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.
|
||||||
@@ -79,7 +79,7 @@ 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};
|
||||||
private:
|
private:
|
||||||
QGraphicsObject* q{nullptr};
|
QGraphicsObject* q{nullptr};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,14 +27,6 @@
|
|||||||
*/
|
*/
|
||||||
XRefProperties::XRefProperties()
|
XRefProperties::XRefProperties()
|
||||||
{
|
{
|
||||||
m_show_power_ctc = true;
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,7 +36,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";
|
||||||
@@ -73,8 +65,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();
|
||||||
@@ -103,58 +95,60 @@ QDomElement XRefProperties::toXml(QDomDocument &xml_document) const
|
|||||||
{
|
{
|
||||||
|
|
||||||
QDomElement xml_element = xml_document.createElement("xref");
|
QDomElement xml_element = xml_document.createElement("xref");
|
||||||
xml_element.setAttribute("type", m_key);
|
|
||||||
|
|
||||||
xml_element.setAttribute("showpowerctc", m_show_power_ctc? "true" : "false");
|
xml_element.appendChild(createXmlProperty(xml_document, "type", m_key));
|
||||||
QString display = m_display == Cross? "cross" : "contacts";
|
xml_element.appendChild(createXmlProperty(xml_document, "showpowerctc", m_show_power_ctc));
|
||||||
xml_element.setAttribute("displayhas", display);
|
xml_element.appendChild(createXmlProperty(xml_document, "displayhas", m_display == Cross? "cross" : "contacts"));
|
||||||
QString snap = m_snap_to == Bottom? "bottom" : "label";
|
xml_element.appendChild(createXmlProperty(xml_document, "snapto", m_snap_to == Bottom? "bottom" : "label"));
|
||||||
xml_element.setAttribute("snapto", snap);
|
|
||||||
|
|
||||||
QString xrefpos;
|
|
||||||
|
|
||||||
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
xml_element.setAttribute("xrefpos", var.valueToKey(m_xref_pos));
|
xml_element.appendChild(createXmlProperty(xml_document, "xrefpos", var.valueToKey(m_xref_pos)));
|
||||||
|
xml_element.appendChild(createXmlProperty(xml_document, "offset", m_offset));
|
||||||
|
xml_element.appendChild(createXmlProperty(xml_document, "master_label", m_master_label));
|
||||||
|
xml_element.appendChild(createXmlProperty(xml_document, "slave_label", m_slave_label));
|
||||||
|
|
||||||
int offset = m_offset;
|
|
||||||
xml_element.setAttribute("offset", QString::number(offset));
|
|
||||||
QString master_label = m_master_label;
|
|
||||||
xml_element.setAttribute("master_label", master_label);
|
|
||||||
QString slave_label = m_slave_label;
|
|
||||||
xml_element.setAttribute("slave_label", slave_label);
|
|
||||||
foreach (QString key, m_prefix.keys()) {
|
foreach (QString key, m_prefix.keys()) {
|
||||||
xml_element.setAttribute(key + "prefix", m_prefix.value(key));
|
xml_element.appendChild(createXmlProperty(xml_document, key + "prefix", m_prefix.value(key)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return xml_element;
|
return xml_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** RETURNS True
|
||||||
@brief XRefProperties::fromXml
|
@brief XRefProperties::fromXml
|
||||||
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::fromXml(const QDomElement &xml_element) {
|
||||||
m_show_power_ctc = xml_element.attribute("showpowerctc") == "true";
|
|
||||||
QString display = xml_element.attribute("displayhas", "cross");
|
|
||||||
display == "cross"? m_display = Cross : m_display = Contacts;
|
|
||||||
QString snap = xml_element.attribute("snapto", "label");
|
|
||||||
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
|
|
||||||
|
|
||||||
QString xrefpos = xml_element.attribute("xrefpos","Left");
|
if (propertyBool(xml_element, "showpowerctc", &m_show_power_ctc))
|
||||||
|
return false;
|
||||||
|
|
||||||
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
QString display;
|
||||||
|
if (propertyString(xml_element, "displayhas", &display) != PropertyFlags::NotFound) {
|
||||||
|
display == "cross"? m_display = Cross : m_display = Contacts;
|
||||||
|
}
|
||||||
|
|
||||||
if(xml_element.hasAttribute("xrefpos"))
|
|
||||||
m_xref_pos = Qt::AlignmentFlag(var.keyToValue(xml_element.attribute("xrefpos").toStdString().data()));
|
|
||||||
else
|
|
||||||
m_xref_pos = Qt::AlignBottom;
|
|
||||||
|
|
||||||
m_offset = xml_element.attribute("offset", "0").toInt();
|
QString snap;
|
||||||
m_master_label = xml_element.attribute("master_label", "%f-%l%c");
|
if (propertyString(xml_element, "snapto", &snap) != PropertyFlags::NotFound) {
|
||||||
m_slave_label = xml_element.attribute("slave_label","(%f-%l%c)");
|
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString xrefpos;
|
||||||
|
if (propertyString(xml_element, "xrefpos", &xrefpos) != PropertyFlags::NotFound) {
|
||||||
|
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
|
m_xref_pos = Qt::AlignmentFlag(var.keyToValue(xrefpos.toStdString().data()));
|
||||||
|
}
|
||||||
|
// TODO: why it compiles without this true??
|
||||||
|
propertyInteger(xml_element, "offset", &m_offset);
|
||||||
|
propertyString(xml_element, "master_label", &m_master_label);
|
||||||
|
propertyString(xml_element, "slave_label", &m_slave_label);
|
||||||
|
QString value;
|
||||||
foreach (QString key, m_prefix_keys) {
|
foreach (QString key, m_prefix_keys) {
|
||||||
m_prefix.insert(key, xml_element.attribute(key + "prefix"));
|
if (!propertyString(xml_element, key + "prefix", &value))
|
||||||
|
m_prefix.insert(key, value);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,10 +42,9 @@ 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;
|
|
||||||
QDomElement toXml (QDomDocument &xml_document) const override;
|
QDomElement toXml (QDomDocument &xml_document) const override;
|
||||||
bool fromXml(const QDomElement &xml_element) override;
|
bool fromXml(const QDomElement &xml_element) override;
|
||||||
|
|
||||||
@@ -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
|
||||||
@@ -532,7 +507,7 @@ QString Qet::endTypeToString(const Qet::EndType &end_type) {
|
|||||||
QET::None est retourne.
|
QET::None est retourne.
|
||||||
*/
|
*/
|
||||||
Qet::EndType Qet::endTypeFromString(const QString &string) {
|
Qet::EndType Qet::endTypeFromString(const QString &string) {
|
||||||
if (string == "simple") return(Qet::Simple);
|
if (string == "simple") return(Qet::Simple);
|
||||||
else if (string == "triangle") return(Qet::Triangle);
|
else if (string == "triangle") return(Qet::Triangle);
|
||||||
else if (string == "circle") return(Qet::Circle);
|
else if (string == "circle") return(Qet::Circle);
|
||||||
else if (string == "diamond") return(Qet::Diamond);
|
else if (string == "diamond") return(Qet::Diamond);
|
||||||
@@ -715,9 +690,9 @@ QActionGroup *QET::depthActionGroup(QObject *parent)
|
|||||||
QActionGroup *action_group = new QActionGroup(parent);
|
QActionGroup *action_group = new QActionGroup(parent);
|
||||||
|
|
||||||
QAction *edit_forward = new QAction(QET::Icons::BringForward, QObject::tr("Amener au premier plan"), action_group);
|
QAction *edit_forward = new QAction(QET::Icons::BringForward, QObject::tr("Amener au premier plan"), action_group);
|
||||||
QAction *edit_raise = new QAction(QET::Icons::Raise, QObject::tr("Rapprocher"), action_group);
|
QAction *edit_raise = new QAction(QET::Icons::Raise, QObject::tr("Rapprocher"), action_group);
|
||||||
QAction *edit_lower = new QAction(QET::Icons::Lower, QObject::tr("Éloigner"), action_group);
|
QAction *edit_lower = new QAction(QET::Icons::Lower, QObject::tr("Éloigner"), action_group);
|
||||||
QAction *edit_backward = new QAction(QET::Icons::SendBackward, QObject::tr("Envoyer au fond"), action_group);
|
QAction *edit_backward = new QAction(QET::Icons::SendBackward, QObject::tr("Envoyer au fond"), action_group);
|
||||||
|
|
||||||
edit_forward ->setStatusTip(QObject::tr("Ramène la ou les sélections au premier plan"));
|
edit_forward ->setStatusTip(QObject::tr("Ramène la ou les sélections au premier plan"));
|
||||||
edit_raise ->setStatusTip(QObject::tr("Rapproche la ou les sélections"));
|
edit_raise ->setStatusTip(QObject::tr("Rapproche la ou les sélections"));
|
||||||
|
|||||||
@@ -76,14 +76,7 @@ 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)
|
|
||||||
{
|
{
|
||||||
//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);
|
||||||
@@ -109,8 +102,8 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
//By default, the 4 profils are nuls -> we must to use priv_calculeConductor
|
//By default, the 4 profils are nuls -> we must to use priv_calculeConductor
|
||||||
conductor_profiles.insert(Qt::TopLeftCorner, ConductorProfile());
|
conductor_profiles.insert(Qt::TopLeftCorner, ConductorProfile());
|
||||||
conductor_profiles.insert(Qt::TopRightCorner, ConductorProfile());
|
conductor_profiles.insert(Qt::TopRightCorner, ConductorProfile());
|
||||||
conductor_profiles.insert(Qt::BottomLeftCorner, ConductorProfile());
|
conductor_profiles.insert(Qt::BottomLeftCorner, ConductorProfile());
|
||||||
conductor_profiles.insert(Qt::BottomRightCorner, ConductorProfile());
|
conductor_profiles.insert(Qt::BottomRightCorner, ConductorProfile());
|
||||||
|
|
||||||
@@ -223,7 +216,7 @@ void Conductor::updateConductorPath(const QPointF &p1, Qet::Orientation o1, cons
|
|||||||
ConductorProfile &conductor_profile = conductor_profiles[currentPathType()];
|
ConductorProfile &conductor_profile = conductor_profiles[currentPathType()];
|
||||||
|
|
||||||
Q_ASSERT_X(conductor_profile.segmentsCount(QET::Both) > 1, "Conductor::priv_modifieConductor", "pas de points a modifier");
|
Q_ASSERT_X(conductor_profile.segmentsCount(QET::Both) > 1, "Conductor::priv_modifieConductor", "pas de points a modifier");
|
||||||
Q_ASSERT_X(!conductor_profile.isNull(), "Conductor::priv_modifieConductor", "pas de profil utilisable");
|
Q_ASSERT_X(!conductor_profile.isNull(), "Conductor::priv_modifieConductor", "pas de profil utilisable");
|
||||||
|
|
||||||
// recupere les coordonnees fournies des bornes
|
// recupere les coordonnees fournies des bornes
|
||||||
QPointF new_p1 = mapFromScene(p1);
|
QPointF new_p1 = mapFromScene(p1);
|
||||||
@@ -327,10 +320,10 @@ QHash<ConductorSegmentProfile *, qreal> Conductor::shareOffsetBetweenSegments(
|
|||||||
|
|
||||||
// on remet le trop-plein dans la reserve d'offset
|
// on remet le trop-plein dans la reserve d'offset
|
||||||
remaining_offset += qAbs(segments_hash[csp]) * getSign(local_offset);
|
remaining_offset += qAbs(segments_hash[csp]) * getSign(local_offset);
|
||||||
//qDebug() << " trop-plein de" << qAbs(segments_hash[csp]) * getSign(local_offset) << "remaining_offset =" << remaining_offset;
|
//qDebug() << " trop-plein de" << qAbs(segments_hash[csp]) * getSign(local_offset) << "remaining_offset =" << remaining_offset;
|
||||||
segments_hash[csp] = 0.0;
|
segments_hash[csp] = 0.0;
|
||||||
} else {
|
} else {
|
||||||
//qDebug() << " offset local de" << local_offset << "accepte";
|
//qDebug() << " offset local de" << local_offset << "accepte";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -362,17 +355,17 @@ void Conductor::generateConductorPath(const QPointF &p1, Qet::Orientation o1, co
|
|||||||
|
|
||||||
// distingue le depart de l'arrivee : le trajet se fait toujours de gauche a droite (apres prolongation)
|
// distingue le depart de l'arrivee : le trajet se fait toujours de gauche a droite (apres prolongation)
|
||||||
if (newp1.x() <= newp2.x()) {
|
if (newp1.x() <= newp2.x()) {
|
||||||
depart = newp1;
|
depart = newp1;
|
||||||
arrivee = newp2;
|
arrivee = newp2;
|
||||||
depart0 = sp1;
|
depart0 = sp1;
|
||||||
arrivee0 = sp2;
|
arrivee0 = sp2;
|
||||||
ori_depart = o1;
|
ori_depart = o1;
|
||||||
ori_arrivee = o2;
|
ori_arrivee = o2;
|
||||||
} else {
|
} else {
|
||||||
depart = newp2;
|
depart = newp2;
|
||||||
arrivee = newp1;
|
arrivee = newp1;
|
||||||
depart0 = sp2;
|
depart0 = sp2;
|
||||||
arrivee0 = sp1;
|
arrivee0 = sp1;
|
||||||
ori_depart = o2;
|
ori_depart = o2;
|
||||||
ori_arrivee = o1;
|
ori_arrivee = o1;
|
||||||
}
|
}
|
||||||
@@ -585,36 +578,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 (propertyDouble(e, "x") ||
|
||||||
if (!e.hasAttribute("terminal2")) return(false);
|
// propertyDouble(e, "y"))
|
||||||
|
// return false;
|
||||||
|
|
||||||
bool conv_ok;
|
// if (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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -987,10 +960,13 @@ 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::fromXml(const QDomElement &dom_element)
|
||||||
{
|
{
|
||||||
setPos(dom_element.attribute("x", nullptr).toDouble(),
|
// TODO: seems to short!
|
||||||
dom_element.attribute("y", nullptr).toDouble());
|
double x=0, y=0;
|
||||||
|
propertyDouble(dom_element, "x", &x);
|
||||||
|
propertyDouble(dom_element, "y", &y);
|
||||||
|
setPos(x, y);
|
||||||
|
|
||||||
bool return_ = pathFromXml(dom_element);
|
bool return_ = pathFromXml(dom_element);
|
||||||
|
|
||||||
@@ -1004,14 +980,14 @@ 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;
|
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::toXml
|
||||||
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 :
|
||||||
@@ -1021,32 +997,39 @@ 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,
|
QDomElement Conductor::toXml(QDomDocument & doc) const {
|
||||||
QHash<Terminal *,
|
QDomElement dom_element = doc.createElement("conductor");
|
||||||
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()));
|
dom_element.appendChild(createXmlProperty(doc, "x", pos().x()));
|
||||||
|
dom_element.appendChild(createXmlProperty(doc, "y", pos().y()));
|
||||||
|
|
||||||
// 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()) {
|
QUuid terminal = terminal1->uuid();
|
||||||
// legacy method to identify the terminal
|
QUuid terminalParent = terminal1->parentElement()->uuid();
|
||||||
dom_element.setAttribute("terminal1", table_adr_id.value(terminal1)); // for backward compability
|
if (terminalParent.isNull() || terminal.isNull()) {
|
||||||
|
// legacy when the terminal does not have a valid uuid
|
||||||
|
// do not store element1 information, because this is used to determine in the fromXml
|
||||||
|
// process that legacy file format
|
||||||
|
dom_element.appendChild(createXmlProperty(doc, "terminal1", terminal1->ID()));
|
||||||
} else {
|
} else {
|
||||||
dom_element.setAttribute("element1", terminal1->parentElement()->uuid().toString());
|
dom_element.appendChild(createXmlProperty(doc, "element1", terminalParent));
|
||||||
dom_element.setAttribute("terminal1", terminal1->uuid().toString());
|
dom_element.appendChild(createXmlProperty(doc, "terminal1", terminal));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (terminal2->uuid().isNull()) {
|
terminal = terminal2->uuid();
|
||||||
// legacy method to identify the terminal
|
terminalParent = terminal2->parentElement()->uuid();
|
||||||
dom_element.setAttribute("terminal2", table_adr_id.value(terminal2)); // for backward compability
|
if (terminalParent.isNull() || terminal.isNull()) {
|
||||||
|
// legacy when the terminal does not have a valid uuid
|
||||||
|
// do not store element1 information, because this is used to determine in the fromXml
|
||||||
|
// process that legacy file format
|
||||||
|
dom_element.appendChild(createXmlProperty(doc, "terminal2", terminal2->ID()));
|
||||||
} else {
|
} else {
|
||||||
dom_element.setAttribute("element2", terminal2->parentElement()->uuid().toString());
|
dom_element.appendChild(createXmlProperty(doc, "element2", terminal2->parentElement()->uuid()));
|
||||||
dom_element.setAttribute("terminal2", terminal2->uuid().toString());
|
dom_element.appendChild(createXmlProperty(doc, "terminal2", terminal2->uuid()));
|
||||||
}
|
}
|
||||||
dom_element.setAttribute("freezeLabel", m_freeze_label? "true" : "false");
|
|
||||||
|
dom_element.appendChild(createXmlProperty(doc, "freezeLabel", m_freeze_label));
|
||||||
|
|
||||||
// on n'exporte les segments du conducteur que si ceux-ci ont
|
// on n'exporte les segments du conducteur que si ceux-ci ont
|
||||||
// ete modifies par l'utilisateur
|
// ete modifies par l'utilisateur
|
||||||
@@ -1056,35 +1039,92 @@ 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 = doc.createElement("segment");
|
||||||
current_segment.setAttribute("orientation", segment -> isHorizontal() ? "horizontal" : "vertical");
|
current_segment.appendChild(createXmlProperty(doc, "orientation", segment->isHorizontal() ? "horizontal": "vertical"));
|
||||||
current_segment.setAttribute("length", QString("%1").arg(segment -> length()));
|
current_segment.appendChild(createXmlProperty(doc, "length", segment -> length()));
|
||||||
dom_element.appendChild(current_segment);
|
dom_element.appendChild(current_segment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement dom_seq = m_autoNum_seq.toXml(dom_document);
|
QDomElement dom_seq = m_autoNum_seq.toXml(doc); // swquentialNumbers tag
|
||||||
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);
|
QDomElement conductorProperties = m_properties.toXml(doc);
|
||||||
if(m_text_item->wasMovedByUser())
|
for (int i=0; i < conductorProperties.childNodes().count(); i++) {
|
||||||
{
|
QDomNode node = conductorProperties.childNodes().at(i).cloneNode(); // cloneNode() is important!
|
||||||
dom_element.setAttribute("userx", QString::number(m_text_item->pos().x()));
|
dom_element.appendChild(node);
|
||||||
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()));
|
m_text_item->toXml(doc, dom_element);
|
||||||
|
|
||||||
return(dom_element);
|
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
|
||||||
@@ -1096,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 (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 (propertyString(current_segment, "orientation", &orientation) == 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 {
|
||||||
@@ -1235,7 +1282,7 @@ ConductorSegment *Conductor::middleSegment()
|
|||||||
QPointF Conductor::posForText(Qt::Orientations &flag)
|
QPointF Conductor::posForText(Qt::Orientations &flag)
|
||||||
{
|
{
|
||||||
|
|
||||||
ConductorSegment *segment = segments;
|
ConductorSegment *segment = segments;
|
||||||
bool all_segment_is_vertical = true;
|
bool all_segment_is_vertical = true;
|
||||||
bool all_segment_is_horizontal = true;
|
bool all_segment_is_horizontal = true;
|
||||||
|
|
||||||
@@ -1354,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;
|
||||||
@@ -1631,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())
|
||||||
{
|
{
|
||||||
@@ -1722,7 +1769,7 @@ QSet<Conductor *> Conductor::relatedPotentialConductors(const bool all_diagram,
|
|||||||
*/
|
*/
|
||||||
QETDiagramEditor* Conductor::diagramEditor() const
|
QETDiagramEditor* Conductor::diagramEditor() const
|
||||||
{
|
{
|
||||||
if (!diagram()) return nullptr;
|
if (!diagram()) return nullptr;
|
||||||
if (diagram() -> views().isEmpty()) return nullptr;
|
if (diagram() -> views().isEmpty()) return nullptr;
|
||||||
|
|
||||||
QWidget *w = const_cast<QGraphicsView *>(diagram() -> views().at(0));
|
QWidget *w = const_cast<QGraphicsView *>(diagram() -> views().at(0));
|
||||||
@@ -2013,7 +2060,7 @@ QPointF Conductor::movePointIntoPolygon(const QPointF &point, const QPainterPath
|
|||||||
qreal length = qAbs(QLineF(points.at(i), point).length());
|
qreal length = qAbs(QLineF(points.at(i), point).length());
|
||||||
if (minimum_length < 0 || length < minimum_length) {
|
if (minimum_length < 0 || length < minimum_length) {
|
||||||
minimum_length = length;
|
minimum_length = length;
|
||||||
point_index = i;
|
point_index = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// on connait desormais le coin le plus proche du texte
|
// on connait desormais le coin le plus proche du texte
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#define CONDUCTOR_H
|
#define CONDUCTOR_H
|
||||||
|
|
||||||
#include "conductorproperties.h"
|
#include "conductorproperties.h"
|
||||||
|
#include "propertiesinterface.h"
|
||||||
#include <QGraphicsPathItem>
|
#include <QGraphicsPathItem>
|
||||||
#include "assignvariables.h"
|
#include "assignvariables.h"
|
||||||
|
|
||||||
@@ -39,7 +40,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 +101,10 @@ class Conductor : public QGraphicsObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static bool valideXml (QDomElement &);
|
static bool valideXml (QDomElement &);
|
||||||
bool fromXml (QDomElement &);
|
bool fromXml (const QDomElement &) override;
|
||||||
QDomElement toXml (
|
QDomElement toXml (QDomDocument &doc) 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 &);
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ class Conductor : public QGraphicsObject
|
|||||||
{return m_autoNum_seq;}
|
{return m_autoNum_seq;}
|
||||||
void setSequenceNum(const autonum::sequentialNumbers& sn);
|
void setSequenceNum(const autonum::sequentialNumbers& sn);
|
||||||
|
|
||||||
QList<QPointF> junctions() const;
|
QList<QPointF> junctions() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setUpConnectionForFormula(
|
void setUpConnectionForFormula(
|
||||||
@@ -181,28 +181,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;
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
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);
|
||||||
}
|
}
|
||||||
@@ -62,19 +60,34 @@ Conductor *ConductorTextItem::parentConductor() const
|
|||||||
return(parent_conductor_);
|
return(parent_conductor_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConductorTextItem::toXml(QDomDocument& doc, QDomElement& e) {
|
||||||
|
if(moved_by_user_)
|
||||||
|
{
|
||||||
|
e.appendChild(PropertiesInterface::createXmlProperty(doc, "userx", pos().x()));
|
||||||
|
e.appendChild(PropertiesInterface::createXmlProperty(doc, "usery", pos().y()));
|
||||||
|
}
|
||||||
|
if(rotate_by_user_)
|
||||||
|
e.appendChild(PropertiesInterface::createXmlProperty(doc, "rotation", rotation()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ConductorTextItem::fromXml
|
@brief ConductorTextItem::fromXml
|
||||||
Read the properties stored in the xml element given in parameter
|
Read the properties stored in the xml element given in parameter
|
||||||
@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 (PropertiesInterface::propertyDouble(e, "userx", &userx) == PropertiesInterface::PropertyFlags::Success &&
|
||||||
|
PropertiesInterface::propertyDouble(e, "usery", &usery) == PropertiesInterface::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 (PropertiesInterface::propertyDouble(e, "rotation", &rotation) == PropertiesInterface::PropertyFlags::Success) {
|
||||||
|
setRotation(rotation);
|
||||||
rotate_by_user_ = true;
|
rotate_by_user_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class ConductorTextItem : public DiagramTextItem
|
|||||||
enum { Type = UserType + 1006 };
|
enum { Type = UserType + 1006 };
|
||||||
Conductor *parentConductor() const;
|
Conductor *parentConductor() const;
|
||||||
void fromXml(const QDomElement &) override;
|
void fromXml(const QDomElement &) override;
|
||||||
|
void toXml(QDomDocument& doc, QDomElement& e);
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
virtual bool wasMovedByUser() const;
|
virtual bool wasMovedByUser() const;
|
||||||
virtual bool wasRotateByUser() const;
|
virtual bool wasRotateByUser() const;
|
||||||
@@ -52,7 +53,7 @@ class ConductorTextItem : public DiagramTextItem
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
|
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override;
|
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override;
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override;
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override;
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override;
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override;
|
||||||
@@ -61,8 +62,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
|
||||||
|
|||||||
@@ -212,7 +212,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());
|
||||||
@@ -1293,12 +1293,12 @@ void DynamicElementTextItem::updateXref()
|
|||||||
m_slave_Xref_item->setFont(QETApp::diagramTextsFont(5));
|
m_slave_Xref_item->setFont(QETApp::diagramTextsFont(5));
|
||||||
m_slave_Xref_item->installSceneEventFilter(this);
|
m_slave_Xref_item->installSceneEventFilter(this);
|
||||||
|
|
||||||
m_update_slave_Xref_connection << connect(m_master_element.data(), &Element::xChanged, this, &DynamicElementTextItem::updateXref);
|
m_update_slave_Xref_connection << connect(m_master_element.data(), &Element::xChanged, this, &DynamicElementTextItem::updateXref);
|
||||||
m_update_slave_Xref_connection << connect(m_master_element.data(), &Element::yChanged, this, &DynamicElementTextItem::updateXref);
|
m_update_slave_Xref_connection << connect(m_master_element.data(), &Element::yChanged, this, &DynamicElementTextItem::updateXref);
|
||||||
m_update_slave_Xref_connection << connect(m_master_element.data(), &Element::elementInfoChange, this, &DynamicElementTextItem::updateXref);
|
m_update_slave_Xref_connection << connect(m_master_element.data(), &Element::elementInfoChange, this, &DynamicElementTextItem::updateXref);
|
||||||
m_update_slave_Xref_connection << connect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &DynamicElementTextItem::updateXref);
|
m_update_slave_Xref_connection << connect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &DynamicElementTextItem::updateXref);
|
||||||
m_update_slave_Xref_connection << connect(diagram()->project(), &QETProject::diagramRemoved, this, &DynamicElementTextItem::updateXref);
|
m_update_slave_Xref_connection << connect(diagram()->project(), &QETProject::diagramRemoved, this, &DynamicElementTextItem::updateXref);
|
||||||
m_update_slave_Xref_connection << connect(diagram()->project(), &QETProject::XRefPropertiesChanged, this, &DynamicElementTextItem::updateXref);
|
m_update_slave_Xref_connection << connect(diagram()->project(), &QETProject::XRefPropertiesChanged, this, &DynamicElementTextItem::updateXref);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_slave_Xref_item->setPlainText(xref_label);
|
m_slave_Xref_item->setPlainText(xref_label);
|
||||||
|
|||||||
@@ -152,7 +152,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;
|
||||||
|
|||||||
@@ -96,7 +96,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;
|
||||||
}
|
}
|
||||||
@@ -337,8 +338,8 @@ void Element::drawSelection(
|
|||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
painter -> save();
|
painter -> save();
|
||||||
// Annulation des renderhints
|
// Annulation des renderhints
|
||||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||||
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||||
// Dessin du cadre de selection en gris
|
// Dessin du cadre de selection en gris
|
||||||
QPen t;
|
QPen t;
|
||||||
@@ -387,7 +388,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
|
||||||
@@ -420,9 +421,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -504,11 +505,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;
|
||||||
@@ -534,13 +539,11 @@ 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -551,8 +554,8 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
|||||||
*/
|
*/
|
||||||
bool Element::parseElement(const QDomElement &dom)
|
bool Element::parseElement(const QDomElement &dom)
|
||||||
{
|
{
|
||||||
if (dom.tagName() == "terminal") return(parseTerminal(dom));
|
if (dom.tagName() == "terminal") return(parseTerminal(dom));
|
||||||
else if (dom.tagName() == "input") return(parseInput(dom));
|
else if (dom.tagName() == "input") return(parseInput(dom));
|
||||||
else if (dom.tagName() == "dynamic_text") return(parseDynamicText(dom));
|
else if (dom.tagName() == "dynamic_text") return(parseDynamicText(dom));
|
||||||
else return(true);
|
else return(true);
|
||||||
}
|
}
|
||||||
@@ -644,13 +647,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
|
||||||
@@ -665,7 +666,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
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -679,8 +680,8 @@ bool Element::valideXml(QDomElement &e) {
|
|||||||
|
|
||||||
// verifie la presence des attributs minimaux
|
// verifie la presence des attributs minimaux
|
||||||
if (!e.hasAttribute("type")) return(false);
|
if (!e.hasAttribute("type")) return(false);
|
||||||
if (!e.hasAttribute("x")) return(false);
|
if (!e.hasAttribute("x")) return(false);
|
||||||
if (!e.hasAttribute("y")) return(false);
|
if (!e.hasAttribute("y")) return(false);
|
||||||
|
|
||||||
bool conv_ok;
|
bool conv_ok;
|
||||||
// parse l'abscisse
|
// parse l'abscisse
|
||||||
@@ -707,15 +708,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;
|
||||||
@@ -723,15 +723,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.
|
||||||
@@ -744,6 +758,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);
|
||||||
}
|
}
|
||||||
@@ -761,15 +776,15 @@ bool Element::fromXml(
|
|||||||
}
|
}
|
||||||
// copie des associations id / adr
|
// copie des associations id / adr
|
||||||
foreach(int id_trouve, priv_id_adr.keys()) {
|
foreach(int id_trouve, priv_id_adr.keys()) {
|
||||||
table_id_adr.insert(id_trouve,
|
table_id_adr.insert(id_trouve,
|
||||||
priv_id_adr.value(id_trouve));
|
priv_id_adr.value(id_trouve));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//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");
|
||||||
@@ -823,7 +838,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",
|
||||||
@@ -837,7 +852,7 @@ bool Element::fromXml(
|
|||||||
//************************//
|
//************************//
|
||||||
//***Element texts item***//
|
//***Element texts item***//
|
||||||
//************************//
|
//************************//
|
||||||
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input");
|
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input"); // inputs in diagram section
|
||||||
|
|
||||||
//First case, we check for the text item converted to dynamic text item
|
//First case, we check for the text item converted to dynamic text item
|
||||||
const QList <DynamicElementTextItem *> conv_deti_list =
|
const QList <DynamicElementTextItem *> conv_deti_list =
|
||||||
@@ -1061,6 +1076,7 @@ bool Element::fromXml(
|
|||||||
}
|
}
|
||||||
|
|
||||||
QPointF pos = deti->pos();
|
QPointF pos = deti->pos();
|
||||||
|
// TODO: check
|
||||||
if (m_link_type !=PreviousReport
|
if (m_link_type !=PreviousReport
|
||||||
|| m_link_type !=NextReport)
|
|| m_link_type !=NextReport)
|
||||||
{
|
{
|
||||||
@@ -1165,9 +1181,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");
|
||||||
|
|
||||||
@@ -1194,18 +1208,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");
|
||||||
@@ -1214,8 +1216,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);
|
||||||
|
|||||||
@@ -38,7 +38,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;
|
||||||
|
|
||||||
@@ -130,14 +130,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;
|
||||||
|
|
||||||
@@ -166,7 +160,7 @@ class Element : public QetGraphicsItem
|
|||||||
QList<Element *> linkedElements ();
|
QList<Element *> linkedElements ();
|
||||||
virtual kind linkType() const {return m_link_type;} // return the linkable type
|
virtual kind linkType() const {return m_link_type;} // return the linkable type
|
||||||
QString linkTypeToString() const;
|
QString linkTypeToString() const;
|
||||||
void newUuid() {m_uuid = QUuid::createUuid();} //create new uuid for this element
|
void newUuid() {m_uuid = QUuid::createUuid();} //create new uuid for this element
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
||||||
@@ -215,9 +209,9 @@ class Element : public QetGraphicsItem
|
|||||||
|
|
||||||
//ATTRIBUTES related to linked element
|
//ATTRIBUTES related to linked element
|
||||||
QList <Element *> connected_elements;
|
QList <Element *> connected_elements;
|
||||||
QList <QUuid> tmp_uuids_link;
|
QList <QUuid> tmp_uuids_link;
|
||||||
QUuid m_uuid;
|
QUuid m_uuid;
|
||||||
kind m_link_type = Element::Simple;
|
kind m_link_type = Element::Simple;
|
||||||
|
|
||||||
//ATTRIBUTES related to informations
|
//ATTRIBUTES related to informations
|
||||||
DiagramContext m_element_informations, m_kind_informations;
|
DiagramContext m_element_informations, m_kind_informations;
|
||||||
|
|||||||
@@ -316,8 +316,8 @@ void ElementTextItemGroup::setHoldToBottomPage(bool hold)
|
|||||||
&Element::linkedElementChanged,
|
&Element::linkedElementChanged,
|
||||||
[this]()
|
[this]()
|
||||||
{QTimer::singleShot(200,
|
{QTimer::singleShot(200,
|
||||||
this,
|
this,
|
||||||
&ElementTextItemGroup::autoPos);}
|
&ElementTextItemGroup::autoPos);}
|
||||||
);
|
);
|
||||||
if(m_parent_element->diagram())
|
if(m_parent_element->diagram())
|
||||||
m_XrefChanged_timer = connect(
|
m_XrefChanged_timer = connect(
|
||||||
@@ -325,8 +325,8 @@ void ElementTextItemGroup::setHoldToBottomPage(bool hold)
|
|||||||
&QETProject::XRefPropertiesChanged,
|
&QETProject::XRefPropertiesChanged,
|
||||||
[this]()
|
[this]()
|
||||||
{QTimer::singleShot(200,
|
{QTimer::singleShot(200,
|
||||||
this,
|
this,
|
||||||
&ElementTextItemGroup::autoPos);}
|
&ElementTextItemGroup::autoPos);}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
autoPos();
|
autoPos();
|
||||||
@@ -437,6 +437,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
|
||||||
@@ -622,7 +623,7 @@ void ElementTextItemGroup::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
{
|
{
|
||||||
if(diagram() && m_first_move)
|
if(diagram() && m_first_move)
|
||||||
diagram()->elementTextsMover().beginMovement(diagram(),
|
diagram()->elementTextsMover().beginMovement(diagram(),
|
||||||
this);
|
this);
|
||||||
|
|
||||||
if(m_first_move)
|
if(m_first_move)
|
||||||
{
|
{
|
||||||
@@ -705,7 +706,7 @@ void ElementTextItemGroup::mouseDoubleClickEvent(
|
|||||||
*/
|
*/
|
||||||
void ElementTextItemGroup::keyPressEvent(QKeyEvent *event)
|
void ElementTextItemGroup::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
if(event->modifiers() == Qt::ControlModifier)
|
if(event->modifiers() == Qt::ControlModifier)
|
||||||
{
|
{
|
||||||
if(event->key() == Qt::Key_Left && m_alignment != Qt::AlignLeft)
|
if(event->key() == Qt::Key_Left && m_alignment != Qt::AlignLeft)
|
||||||
{
|
{
|
||||||
@@ -799,12 +800,12 @@ void ElementTextItemGroup::updateXref()
|
|||||||
m_slave_Xref_item = new QGraphicsTextItem(xref_label, this);
|
m_slave_Xref_item = new QGraphicsTextItem(xref_label, this);
|
||||||
m_slave_Xref_item->setFont(QETApp::diagramTextsFont(5));
|
m_slave_Xref_item->setFont(QETApp::diagramTextsFont(5));
|
||||||
|
|
||||||
m_update_slave_Xref_connection << connect(master_elmt, &Element::xChanged, this, &ElementTextItemGroup::updateXref);
|
m_update_slave_Xref_connection << connect(master_elmt, &Element::xChanged, this, &ElementTextItemGroup::updateXref);
|
||||||
m_update_slave_Xref_connection << connect(master_elmt, &Element::yChanged, this, &ElementTextItemGroup::updateXref);
|
m_update_slave_Xref_connection << connect(master_elmt, &Element::yChanged, this, &ElementTextItemGroup::updateXref);
|
||||||
m_update_slave_Xref_connection << connect(master_elmt, &Element::elementInfoChange, this, &ElementTextItemGroup::updateXref);
|
m_update_slave_Xref_connection << connect(master_elmt, &Element::elementInfoChange, this, &ElementTextItemGroup::updateXref);
|
||||||
m_update_slave_Xref_connection << connect(project, &QETProject::projectDiagramsOrderChanged, this, &ElementTextItemGroup::updateXref);
|
m_update_slave_Xref_connection << connect(project, &QETProject::projectDiagramsOrderChanged, this, &ElementTextItemGroup::updateXref);
|
||||||
m_update_slave_Xref_connection << connect(project, &QETProject::diagramRemoved, this, &ElementTextItemGroup::updateXref);
|
m_update_slave_Xref_connection << connect(project, &QETProject::diagramRemoved, this, &ElementTextItemGroup::updateXref);
|
||||||
m_update_slave_Xref_connection << connect(project, &QETProject::XRefPropertiesChanged, this, &ElementTextItemGroup::updateXref);
|
m_update_slave_Xref_connection << connect(project, &QETProject::XRefPropertiesChanged, this, &ElementTextItemGroup::updateXref);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_slave_Xref_item->setPlainText(xref_label);
|
m_slave_Xref_item->setPlainText(xref_label);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -50,6 +50,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
|
||||||
|
|||||||
@@ -24,10 +24,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()
|
||||||
|
|||||||
@@ -55,10 +55,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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ void QetShapeItem::paint(
|
|||||||
|
|
||||||
switch (m_shapeType)
|
switch (m_shapeType)
|
||||||
{
|
{
|
||||||
case Line: painter->drawLine(QLineF(m_P1, m_P2)); break;
|
case Line: painter->drawLine(QLineF(m_P1, m_P2)); break;
|
||||||
case Rectangle: painter->drawRoundedRect(QRectF(m_P1, m_P2),
|
case Rectangle: painter->drawRoundedRect(QRectF(m_P1, m_P2),
|
||||||
m_xRadius,
|
m_xRadius,
|
||||||
m_yRadius); break;
|
m_yRadius); break;
|
||||||
@@ -662,7 +662,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);
|
||||||
}
|
}
|
||||||
@@ -835,6 +835,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
|
||||||
@@ -852,20 +853,20 @@ bool QetShapeItem::fromXml(const QDomElement &e)
|
|||||||
|
|
||||||
QString type = e.attribute("type");
|
QString type = e.attribute("type");
|
||||||
#if TODO_LIST
|
#if TODO_LIST
|
||||||
#pragma message("@TODO Compatibility for version older than N°4075, shape type was stored with an int")
|
#pragma message("@TODO Compatibility for version older than N??4075, shape type was stored with an int")
|
||||||
#endif
|
#endif
|
||||||
//@TODO Compatibility for version older than N°4075, shape type was stored with an int
|
//@TODO Compatibility for version older than N??4075, shape type was stored with an int
|
||||||
if (type.size() == 1)
|
if (type.size() == 1)
|
||||||
{
|
{
|
||||||
switch(e.attribute("type","0").toInt())
|
switch(e.attribute("type","0").toInt())
|
||||||
{
|
{
|
||||||
case 0: m_shapeType = Line; break;
|
case 0: m_shapeType = Line; break;
|
||||||
case 1: m_shapeType = Rectangle; break;
|
case 1: m_shapeType = Rectangle; break;
|
||||||
case 2: m_shapeType = Ellipse; break;
|
case 2: m_shapeType = Ellipse; break;
|
||||||
case 3: m_shapeType = Polygon; break;
|
case 3: m_shapeType = Polygon; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//For version after N°4075, shape is stored with a string
|
//For version after N??4075, shape is stored with a string
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMetaEnum me = metaObject()->enumerator(metaObject()->indexOfEnumerator("ShapeType"));
|
QMetaEnum me = metaObject()->enumerator(metaObject()->indexOfEnumerator("ShapeType"));
|
||||||
@@ -968,28 +969,28 @@ bool QetShapeItem::toDXF(const QString &filepath,const QPen &pen)
|
|||||||
switch (m_shapeType)
|
switch (m_shapeType)
|
||||||
{
|
{
|
||||||
case Line:
|
case Line:
|
||||||
Createdxf::drawLine(filepath,
|
Createdxf::drawLine(filepath,
|
||||||
QLineF( mapToScene(m_P1),
|
QLineF( mapToScene(m_P1),
|
||||||
mapToScene(m_P2)),
|
mapToScene(m_P2)),
|
||||||
Createdxf::dxfColor(pen));
|
Createdxf::dxfColor(pen));
|
||||||
return true;
|
return true;
|
||||||
case Rectangle:
|
case Rectangle:
|
||||||
Createdxf::drawRectangle(filepath,
|
Createdxf::drawRectangle(filepath,
|
||||||
QRectF(mapToScene(m_P1),
|
QRectF(mapToScene(m_P1),
|
||||||
mapToScene(m_P2)).normalized(),
|
mapToScene(m_P2)).normalized(),
|
||||||
Createdxf::dxfColor(pen));
|
Createdxf::dxfColor(pen));
|
||||||
return true;
|
return true;
|
||||||
case Ellipse:
|
case Ellipse:
|
||||||
Createdxf::drawEllipse(filepath,
|
Createdxf::drawEllipse(filepath,
|
||||||
QRectF(mapToScene(m_P1),
|
QRectF(mapToScene(m_P1),
|
||||||
mapToScene(m_P2)).normalized(),
|
mapToScene(m_P2)).normalized(),
|
||||||
Createdxf::dxfColor(pen));
|
Createdxf::dxfColor(pen));
|
||||||
return true;
|
return true;
|
||||||
case Polygon:
|
case Polygon:
|
||||||
Createdxf::drawPolygon(filepath,m_polygon,Createdxf::dxfColor(pen));
|
Createdxf::drawPolygon(filepath,m_polygon,Createdxf::dxfColor(pen));
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1012,10 +1013,10 @@ void QetShapeItem::editProperty()
|
|||||||
QString QetShapeItem::name() const
|
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
|
||||||
|
|||||||
@@ -26,11 +26,11 @@
|
|||||||
#include "conductortextitem.h"
|
#include "conductortextitem.h"
|
||||||
#include "terminaldata.h"
|
#include "terminaldata.h"
|
||||||
|
|
||||||
QColor Terminal::neutralColor = QColor(Qt::blue);
|
QColor Terminal::neutralColor = QColor(Qt::blue);
|
||||||
QColor Terminal::allowedColor = QColor(Qt::darkGreen);
|
QColor Terminal::allowedColor = QColor(Qt::darkGreen);
|
||||||
QColor Terminal::warningColor = QColor("#ff8000");
|
QColor Terminal::warningColor = QColor("#ff8000");
|
||||||
QColor Terminal::forbiddenColor = QColor(Qt::red);
|
QColor Terminal::forbiddenColor = QColor(Qt::red);
|
||||||
const qreal Terminal::terminalSize = 4.0;
|
const qreal Terminal::terminalSize = 4.0; // TODO: store terminalSize in terminaldata, because in PartTerminal there is the same parameter. So only one is needed
|
||||||
const qreal Terminal::Z = 1000;
|
const qreal Terminal::Z = 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,8 +43,6 @@ const qreal Terminal::Z = 1000;
|
|||||||
void Terminal::init(
|
void Terminal::init(
|
||||||
QString number, QString name, bool hiddenName)
|
QString number, QString name, bool hiddenName)
|
||||||
{
|
{
|
||||||
hovered_color_ = Terminal::neutralColor;
|
|
||||||
|
|
||||||
// calcul de la position du point d'amarrage a l'element
|
// calcul de la position du point d'amarrage a l'element
|
||||||
dock_elmt_ = d->m_pos;
|
dock_elmt_ = d->m_pos;
|
||||||
switch(d->m_orientation) {
|
switch(d->m_orientation) {
|
||||||
@@ -52,22 +50,20 @@ void Terminal::init(
|
|||||||
case Qet::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
|
case Qet::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
|
||||||
case Qet::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
|
case Qet::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
|
||||||
case Qet::South:
|
case Qet::South:
|
||||||
default : dock_elmt_ += QPointF(0, -Terminal::terminalSize);
|
default : dock_elmt_ += QPointF(0, -Terminal::terminalSize);
|
||||||
}
|
}
|
||||||
// Number of terminal
|
// Number of terminal
|
||||||
number_terminal_ = std::move(number);
|
number_terminal_ = std::move(number);
|
||||||
// Name of terminal
|
// Name of terminal
|
||||||
name_terminal_ = std::move(name);
|
d->m_name = std::move(name);
|
||||||
name_terminal_hidden = hiddenName;
|
name_terminal_hidden = hiddenName;
|
||||||
// par defaut : pas de conducteur
|
// par defaut : pas de conducteur
|
||||||
|
|
||||||
// QRectF null
|
// QRectF null
|
||||||
br_ = new QRectF();
|
br_ = new QRectF();
|
||||||
previous_terminal_ = nullptr;
|
|
||||||
// divers
|
// divers
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
setAcceptedMouseButtons(Qt::LeftButton);
|
setAcceptedMouseButtons(Qt::LeftButton);
|
||||||
hovered_ = false;
|
|
||||||
setToolTip(QObject::tr("Borne", "tooltip"));
|
setToolTip(QObject::tr("Borne", "tooltip"));
|
||||||
setZValue(Z);
|
setZValue(Z);
|
||||||
}
|
}
|
||||||
@@ -116,8 +112,8 @@ Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e) :
|
|||||||
initialise une borne
|
initialise une borne
|
||||||
@param pf_x Abscisse du point d'amarrage pour un conducteur
|
@param pf_x Abscisse du point d'amarrage pour un conducteur
|
||||||
@param pf_y Ordonnee 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 o orientation de la borne : Qt::Horizontal ou Qt::Vertical
|
||||||
@param e Element auquel cette borne appartient
|
@param e Element auquel cette borne appartient
|
||||||
*/
|
*/
|
||||||
Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e) :
|
Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e) :
|
||||||
QGraphicsObject(e),
|
QGraphicsObject(e),
|
||||||
@@ -143,7 +139,7 @@ Terminal::Terminal(
|
|||||||
QString name,
|
QString name,
|
||||||
bool hiddenName,
|
bool hiddenName,
|
||||||
Element *e) :
|
Element *e) :
|
||||||
QGraphicsObject (e),
|
QGraphicsObject (e),
|
||||||
d(new TerminalData(this)),
|
d(new TerminalData(this)),
|
||||||
parent_element_ (e)
|
parent_element_ (e)
|
||||||
{
|
{
|
||||||
@@ -214,10 +210,18 @@ void Terminal::setNumber(QString number)
|
|||||||
*/
|
*/
|
||||||
void Terminal::setName(QString name, bool hiddenName)
|
void Terminal::setName(QString name, bool hiddenName)
|
||||||
{
|
{
|
||||||
name_terminal_ = std::move(name);
|
d->m_name = std::move(name);
|
||||||
name_terminal_hidden = hiddenName;
|
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
|
||||||
@@ -283,8 +287,8 @@ void Terminal::paint(
|
|||||||
painter -> save();
|
painter -> save();
|
||||||
|
|
||||||
//annulation des renderhints
|
//annulation des renderhints
|
||||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||||
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||||
|
|
||||||
// on travaille avec les coordonnees de l'element parent
|
// on travaille avec les coordonnees de l'element parent
|
||||||
@@ -418,7 +422,7 @@ void Terminal::drawHelpLine(bool draw)
|
|||||||
QLineF Terminal::HelpLine() const
|
QLineF Terminal::HelpLine() const
|
||||||
{
|
{
|
||||||
QPointF scene_dock = dockConductor();
|
QPointF scene_dock = dockConductor();
|
||||||
QRectF rect = diagram() -> border_and_titleblock.insideBorderRect();
|
QRectF rect = diagram() -> border_and_titleblock.insideBorderRect();
|
||||||
|
|
||||||
QLineF line(scene_dock , QPointF());
|
QLineF line(scene_dock , QPointF());
|
||||||
|
|
||||||
@@ -509,7 +513,7 @@ Terminal* Terminal::alignedWithTerminal() const
|
|||||||
|
|
||||||
//Available_terminals have several terminals, we get the nearest terminal
|
//Available_terminals have several terminals, we get the nearest terminal
|
||||||
line.setP2(available_terminals.first() -> dockConductor());
|
line.setP2(available_terminals.first() -> dockConductor());
|
||||||
qreal current_lenght = line.length();
|
qreal current_lenght = line.length();
|
||||||
Terminal *nearest_terminal = available_terminals.takeFirst();
|
Terminal *nearest_terminal = available_terminals.takeFirst();
|
||||||
|
|
||||||
//Search the nearest terminal to this one
|
//Search the nearest terminal to this one
|
||||||
@@ -632,7 +636,7 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
|
|||||||
void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
||||||
{
|
{
|
||||||
previous_terminal_ = nullptr;
|
previous_terminal_ = nullptr;
|
||||||
hovered_color_ = neutralColor;
|
hovered_color_ = neutralColor;
|
||||||
|
|
||||||
if (!diagram()) return;
|
if (!diagram()) return;
|
||||||
|
|
||||||
@@ -648,7 +652,7 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
|||||||
if (!other_terminal) return;
|
if (!other_terminal) return;
|
||||||
|
|
||||||
other_terminal -> hovered_color_ = neutralColor;
|
other_terminal -> hovered_color_ = neutralColor;
|
||||||
other_terminal -> hovered_ = false;
|
other_terminal -> hovered_ = false;
|
||||||
|
|
||||||
//We stop her if we can't link this terminal with other terminal
|
//We stop her if we can't link this terminal with other terminal
|
||||||
if (!canBeLinkedTo(other_terminal)) return;
|
if (!canBeLinkedTo(other_terminal)) return;
|
||||||
@@ -745,6 +749,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
|
||||||
@@ -764,15 +772,24 @@ QDomElement Terminal::toXml(QDomDocument &doc) const
|
|||||||
{
|
{
|
||||||
QDomElement qdo = doc.createElement("terminal");
|
QDomElement qdo = doc.createElement("terminal");
|
||||||
|
|
||||||
// for backward compatibility
|
qdo.appendChild(createXmlProperty(doc, "number", number_terminal_));
|
||||||
qdo.setAttribute("x", QString("%1").arg(dock_elmt_.x()));
|
qdo.appendChild(createXmlProperty(doc, "nameHidden", name_terminal_hidden));
|
||||||
qdo.setAttribute("y", QString("%1").arg(dock_elmt_.y()));
|
|
||||||
// end for backward compatibility
|
// store terminal data too!
|
||||||
|
|
||||||
|
// Do not store terminal data in its own child
|
||||||
|
// Bad hack. The problem is that in the diagrams the terminal is described by the position and in the Collection by the dock.
|
||||||
|
QPointF tempPos = d->m_pos;
|
||||||
|
d->m_pos = dock_elmt_;
|
||||||
|
QDomElement terminalDataElement = d->toXml(doc);
|
||||||
|
d->m_pos = tempPos;
|
||||||
|
|
||||||
|
int childsCount = terminalDataElement.childNodes().count();
|
||||||
|
for (int i=0; i < childsCount; i++) {
|
||||||
|
QDomNode node = terminalDataElement.childNodes().at(i).cloneNode(); // cloneNode() is important, otherwise no deep clone is made
|
||||||
|
qdo.appendChild(node);
|
||||||
|
}
|
||||||
|
|
||||||
qdo.setAttribute("orientation", d->m_orientation);
|
|
||||||
qdo.setAttribute("number", number_terminal_);
|
|
||||||
qdo.setAttribute("name", name_terminal_);
|
|
||||||
qdo.setAttribute("nameHidden", name_terminal_hidden);
|
|
||||||
return(qdo);
|
return(qdo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -782,42 +799,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 (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 (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
|
||||||
@@ -825,17 +825,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::fromXml(const QDomElement &terminal) {
|
||||||
{
|
propertyString(terminal, "number", &number_terminal_);
|
||||||
number_terminal_ = terminal.attribute("number");
|
|
||||||
name_terminal_ = terminal.attribute("name");
|
|
||||||
name_terminal_hidden = terminal.attribute("nameHidden").toInt();
|
|
||||||
|
|
||||||
return (
|
propertyBool(terminal, "nameHidden", &name_terminal_hidden);
|
||||||
qFuzzyCompare(terminal.attribute("x").toDouble(), dock_elmt_.x()) &&
|
|
||||||
qFuzzyCompare(terminal.attribute("y").toDouble(), dock_elmt_.y()) &&
|
if(!d->fromXml(terminal))
|
||||||
(terminal.attribute("orientation").toInt() == d->m_orientation)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -872,6 +872,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
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
|
#include "propertiesinterface.h"
|
||||||
|
|
||||||
class Conductor;
|
class Conductor;
|
||||||
class Diagram;
|
class Diagram;
|
||||||
class Element;
|
class Element;
|
||||||
@@ -31,7 +33,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
|
||||||
|
|
||||||
@@ -41,10 +43,10 @@ class Terminal : public QGraphicsObject
|
|||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
|
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
|
||||||
Terminal(qreal, qreal, 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,
|
Terminal(QPointF, Qet::Orientation, QString number,
|
||||||
QString name, bool hiddenName, Element * = nullptr);
|
QString name, bool hiddenName, Element * = nullptr);
|
||||||
~Terminal() override;
|
~Terminal() override;
|
||||||
|
|
||||||
@@ -66,17 +68,20 @@ class Terminal : public QGraphicsObject
|
|||||||
const QStyleOptionGraphicsItem *,
|
const QStyleOptionGraphicsItem *,
|
||||||
QWidget *) override;
|
QWidget *) override;
|
||||||
void drawHelpLine (bool draw = true);
|
void drawHelpLine (bool draw = true);
|
||||||
QLineF HelpLine () const;
|
QLineF HelpLine () const;
|
||||||
QRectF boundingRect () const override;
|
QRectF boundingRect () const override;
|
||||||
|
|
||||||
// methods to manage conductors attached to the terminal
|
// methods to manage conductors attached to the terminal
|
||||||
Terminal* alignedWithTerminal () const;
|
Terminal* alignedWithTerminal () const;
|
||||||
bool addConductor (Conductor *conductor);
|
bool addConductor (Conductor *conductor);
|
||||||
void removeConductor (Conductor *conductor);
|
void removeConductor (Conductor *conductor);
|
||||||
int conductorsCount () const;
|
int conductorsCount () const;
|
||||||
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();
|
||||||
|
|
||||||
QList<Conductor *> conductors() const;
|
QList<Conductor *> conductors() const;
|
||||||
Qet::Orientation orientation() const;
|
Qet::Orientation orientation() const;
|
||||||
@@ -88,11 +93,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 fromXml (const QDomElement &) override;
|
||||||
QDomElement toXml (QDomDocument &) const;
|
QDomElement toXml (QDomDocument &) 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
|
||||||
@@ -110,6 +119,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
|
||||||
@@ -120,12 +130,12 @@ class Terminal : public QGraphicsObject
|
|||||||
static QColor forbiddenColor;
|
static QColor forbiddenColor;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_draw_help_line{false};
|
bool m_draw_help_line{false};
|
||||||
QGraphicsLineItem *m_help_line{nullptr};
|
QGraphicsLineItem *m_help_line{nullptr};
|
||||||
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};
|
||||||
@@ -142,16 +152,17 @@ class Terminal : public QGraphicsObject
|
|||||||
*/
|
*/
|
||||||
QRectF *br_{nullptr};
|
QRectF *br_{nullptr};
|
||||||
/// Last terminal seen through an attached conductor
|
/// Last terminal seen through an attached conductor
|
||||||
Terminal *previous_terminal_;
|
Terminal *previous_terminal_{nullptr};
|
||||||
/// Whether the mouse pointer is hovering the terminal
|
/// Whether the mouse pointer is hovering the terminal
|
||||||
bool hovered_;
|
bool hovered_{false};
|
||||||
/// Color used for the hover effect
|
/// Color used for the hover effect
|
||||||
QColor hovered_color_;
|
QColor hovered_color_{Terminal::neutralColor};
|
||||||
/// Number of Terminal
|
/// Number of Terminal
|
||||||
QString number_terminal_;
|
QString number_terminal_;
|
||||||
/// Name of Terminal
|
bool name_terminal_hidden{true};
|
||||||
QString name_terminal_;
|
|
||||||
bool name_terminal_hidden;
|
/// 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(QString number, QString name, bool hiddenName);
|
void init(QString number, QString name, bool hiddenName);
|
||||||
@@ -177,14 +188,6 @@ inline QString Terminal::number() const
|
|||||||
return(number_terminal_);
|
return(number_terminal_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Terminal::name
|
|
||||||
@return the name of terminal.
|
|
||||||
*/
|
|
||||||
inline QString Terminal::name() const
|
|
||||||
{
|
|
||||||
return(name_terminal_);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
|
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
|
||||||
const bool all_diagram = true);
|
const bool all_diagram = true);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ static int BACKUP_INTERVAL = 120000; //interval in ms of backup = 2min
|
|||||||
@param parent
|
@param parent
|
||||||
*/
|
*/
|
||||||
QETProject::QETProject(QObject *parent) :
|
QETProject::QETProject(QObject *parent) :
|
||||||
QObject (parent),
|
QObject (parent),
|
||||||
m_titleblocks_collection(this),
|
m_titleblocks_collection(this),
|
||||||
m_data_base(this, this)
|
m_data_base(this, this)
|
||||||
{
|
{
|
||||||
@@ -64,7 +64,7 @@ QETProject::QETProject(QObject *parent) :
|
|||||||
@param parent : parent QObject
|
@param parent : parent QObject
|
||||||
*/
|
*/
|
||||||
QETProject::QETProject(const QString &path, QObject *parent) :
|
QETProject::QETProject(const QString &path, QObject *parent) :
|
||||||
QObject (parent),
|
QObject (parent),
|
||||||
m_titleblocks_collection(this),
|
m_titleblocks_collection(this),
|
||||||
m_data_base(this, this)
|
m_data_base(this, this)
|
||||||
{
|
{
|
||||||
@@ -83,7 +83,7 @@ QETProject::QETProject(const QString &path, QObject *parent) :
|
|||||||
@param parent : parent QObject
|
@param parent : parent QObject
|
||||||
*/
|
*/
|
||||||
QETProject::QETProject(KAutoSaveFile *backup, QObject *parent) :
|
QETProject::QETProject(KAutoSaveFile *backup, QObject *parent) :
|
||||||
QObject (parent),
|
QObject (parent),
|
||||||
m_titleblocks_collection(this),
|
m_titleblocks_collection(this),
|
||||||
m_data_base(this, this)
|
m_data_base(this, this)
|
||||||
{
|
{
|
||||||
@@ -1459,11 +1459,11 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
|
|||||||
QDomElement newdiagrams_elmt = newdiagrams_nodes.at(0).toElement();
|
QDomElement newdiagrams_elmt = newdiagrams_nodes.at(0).toElement();
|
||||||
|
|
||||||
// By default, use value find in the global conf of QElectroTech
|
// By default, use value find in the global conf of QElectroTech
|
||||||
default_border_properties_ = BorderProperties:: defaultProperties();
|
default_border_properties_ = BorderProperties:: defaultProperties();
|
||||||
default_titleblock_properties_ = TitleBlockProperties::defaultProperties();
|
default_titleblock_properties_ = TitleBlockProperties::defaultProperties();
|
||||||
default_conductor_properties_ = ConductorProperties:: defaultProperties();
|
default_conductor_properties_ = ConductorProperties:: defaultProperties();
|
||||||
m_default_report_properties = ReportProperties:: defaultProperties();
|
m_default_report_properties = ReportProperties:: defaultProperties();
|
||||||
m_default_xref_properties = XRefProperties:: defaultProperties();
|
m_default_xref_properties = XRefProperties:: defaultProperties();
|
||||||
|
|
||||||
//Read values indicate in project
|
//Read values indicate in project
|
||||||
QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt, conds_autonums, folio_autonums, element_autonums;
|
QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt, conds_autonums, folio_autonums, element_autonums;
|
||||||
@@ -1502,7 +1502,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 (PropertiesInterface::propertyString(elmt, "type", &type) == PropertiesInterface::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())
|
||||||
@@ -1560,19 +1564,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");
|
||||||
@@ -1744,8 +1742,8 @@ void QETProject::setProjectProperties(const DiagramContext &context) {
|
|||||||
bool QETProject::projectWasModified()
|
bool QETProject::projectWasModified()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( projectOptionsWereModified() ||
|
if ( projectOptionsWereModified() ||
|
||||||
!m_undo_stack -> isClean() ||
|
!m_undo_stack -> isClean() ||
|
||||||
m_titleblocks_collection.templates().count() )
|
m_titleblocks_collection.templates().count() )
|
||||||
return(true);
|
return(true);
|
||||||
|
|
||||||
|
|||||||
@@ -37,11 +37,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,10 +36,11 @@ 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
|
||||||
int split_size; ///< Length of the split side
|
int split_size; ///< Length of the split side
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,11 +23,7 @@
|
|||||||
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)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,15 +73,15 @@ bool TitleBlockProperties::operator!=(const TitleBlockProperties &ip) {
|
|||||||
void TitleBlockProperties::toXml(QDomElement &e) const
|
void TitleBlockProperties::toXml(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);
|
||||||
e.setAttribute("plant", plant);
|
e.setAttribute("plant", plant);
|
||||||
e.setAttribute("locmach", locmach);
|
e.setAttribute("locmach", locmach);
|
||||||
e.setAttribute("indexrev",indexrev);
|
e.setAttribute("indexrev",indexrev);
|
||||||
e.setAttribute("version", version);
|
e.setAttribute("version", version);
|
||||||
e.setAttribute("folio", folio);
|
e.setAttribute("folio", folio);
|
||||||
e.setAttribute("auto_page_num", auto_page_num);
|
e.setAttribute("auto_page_num", auto_page_num);
|
||||||
e.setAttribute("date", exportDate());
|
e.setAttribute("date", exportDate());
|
||||||
e.setAttribute("displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
|
e.setAttribute("displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
|
||||||
if (!template_name.isEmpty())
|
if (!template_name.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -100,29 +96,42 @@ void TitleBlockProperties::toXml(QDomElement &e) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
QDomElement TitleBlockProperties::toXml(QDomDocument &d) const {
|
||||||
|
Q_UNUSED(d)
|
||||||
|
qDebug() << "NOT IMPLEMENTED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
|
||||||
|
return QDomElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 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::fromXml(const QDomElement &e) {
|
||||||
|
|
||||||
|
|
||||||
// reads the historical fields
|
// reads the historical fields
|
||||||
if (e.hasAttribute("author")) author = e.attribute("author");
|
propertyString(e, "author", &author);
|
||||||
if (e.hasAttribute("title")) title = e.attribute("title");
|
propertyString(e, "title", &title);
|
||||||
if (e.hasAttribute("filename")) filename = e.attribute("filename");
|
propertyString(e, "filename", &filename);
|
||||||
if (e.hasAttribute("plant")) plant = e.attribute("plant");
|
propertyString(e, "plant", &plant);
|
||||||
if (e.hasAttribute("locmach")) locmach = e.attribute("locmach");
|
propertyString(e, "locmach", &locmach);
|
||||||
if (e.hasAttribute("indexrev")) indexrev = e.attribute("indexrev");
|
propertyString(e, "indexrev", &indexrev);
|
||||||
if (e.hasAttribute("version")) version = e.attribute("version");
|
propertyString(e, "version", &version);
|
||||||
if (e.hasAttribute("folio")) folio = e.attribute("folio");
|
propertyString(e, "folio", &folio);
|
||||||
if (e.hasAttribute("auto_page_num")) auto_page_num = e.attribute("auto_page_num");
|
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);
|
propertyString(e, "date", &date);
|
||||||
|
setDateFromString(date);
|
||||||
|
|
||||||
|
QString display_at_temp;
|
||||||
|
if (propertyString(e, "displayAt", &display_at_temp) == 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 (propertyString(e, "titleblocktemplate", &template_name) == PropertyFlags::Success) {
|
||||||
{
|
QString tbc;
|
||||||
template_name = e.attribute("titleblocktemplate");
|
if (propertyString(e, "titleblocktemplateCollection", &tbc) == 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 +139,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,16 +150,16 @@ void TitleBlockProperties::fromXml(const QDomElement &e) {
|
|||||||
*/
|
*/
|
||||||
void TitleBlockProperties::toSettings(QSettings &settings, const QString &prefix) const
|
void TitleBlockProperties::toSettings(QSettings &settings, const QString &prefix) const
|
||||||
{
|
{
|
||||||
settings.setValue(prefix + "title", title);
|
settings.setValue(prefix + "title", title);
|
||||||
settings.setValue(prefix + "author", author);
|
settings.setValue(prefix + "author", author);
|
||||||
settings.setValue(prefix + "filename", filename);
|
settings.setValue(prefix + "filename", filename);
|
||||||
settings.setValue(prefix + "plant", plant);
|
settings.setValue(prefix + "plant", plant);
|
||||||
settings.setValue(prefix + "locmach", locmach);
|
settings.setValue(prefix + "locmach", locmach);
|
||||||
settings.setValue(prefix + "indexrev", indexrev);
|
settings.setValue(prefix + "indexrev", indexrev);
|
||||||
settings.setValue(prefix + "version", version);
|
settings.setValue(prefix + "version", version);
|
||||||
settings.setValue(prefix + "folio", folio);
|
settings.setValue(prefix + "folio", folio);
|
||||||
settings.setValue(prefix + "auto_page_num", auto_page_num);
|
settings.setValue(prefix + "auto_page_num", auto_page_num);
|
||||||
settings.setValue(prefix + "date", exportDate());
|
settings.setValue(prefix + "date", exportDate());
|
||||||
settings.setValue(prefix + "displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
|
settings.setValue(prefix + "displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
|
||||||
settings.setValue(prefix + "titleblocktemplate", template_name.isEmpty()? QString() : template_name);
|
settings.setValue(prefix + "titleblocktemplate", template_name.isEmpty()? QString() : template_name);
|
||||||
settings.setValue(prefix + "titleblocktemplateCollection", QET::qetCollectionToString(collection));
|
settings.setValue(prefix + "titleblocktemplateCollection", QET::qetCollectionToString(collection));
|
||||||
@@ -162,14 +172,14 @@ void TitleBlockProperties::toSettings(QSettings &settings, const QString &prefix
|
|||||||
@param prefix prefixe a ajouter devant les noms des parametres
|
@param prefix prefixe a ajouter devant les noms des parametres
|
||||||
*/
|
*/
|
||||||
void TitleBlockProperties::fromSettings(QSettings &settings, const QString &prefix) {
|
void TitleBlockProperties::fromSettings(QSettings &settings, const QString &prefix) {
|
||||||
title = settings.value(prefix + "title").toString();
|
title = settings.value(prefix + "title").toString();
|
||||||
author = settings.value(prefix + "author").toString();
|
author = settings.value(prefix + "author").toString();
|
||||||
filename = settings.value(prefix + "filename").toString();
|
filename = settings.value(prefix + "filename").toString();
|
||||||
plant = settings.value(prefix + "plant").toString();
|
plant = settings.value(prefix + "plant").toString();
|
||||||
locmach = settings.value(prefix + "locmach").toString();
|
locmach = settings.value(prefix + "locmach").toString();
|
||||||
indexrev = settings.value(prefix + "indexrev").toString();
|
indexrev = settings.value(prefix + "indexrev").toString();
|
||||||
version = settings.value(prefix + "version").toString();
|
version = settings.value(prefix + "version").toString();
|
||||||
folio = settings.value(prefix + "folio", "%id/%total").toString();
|
folio = settings.value(prefix + "folio", "%id/%total").toString();
|
||||||
auto_page_num = settings.value(prefix + "auto_page_num").toString();
|
auto_page_num = settings.value(prefix + "auto_page_num").toString();
|
||||||
setDateFromString(settings.value(prefix + "date").toString());
|
setDateFromString(settings.value(prefix + "date").toString());
|
||||||
display_at = (settings.value(prefix + "displayAt", QVariant("bottom")).toString() == "bottom" ? Qt::BottomEdge : Qt::RightEdge);
|
display_at = (settings.value(prefix + "displayAt", QVariant("bottom")).toString() == "bottom" ? Qt::BottomEdge : Qt::RightEdge);
|
||||||
|
|||||||
@@ -21,12 +21,14 @@
|
|||||||
#include "diagramcontext.h"
|
#include "diagramcontext.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
|
|
||||||
|
#include "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,11 @@ class TitleBlockProperties {
|
|||||||
bool operator==(const TitleBlockProperties &);
|
bool operator==(const TitleBlockProperties &);
|
||||||
bool operator!=(const TitleBlockProperties &);
|
bool operator!=(const TitleBlockProperties &);
|
||||||
|
|
||||||
void toXml(QDomElement &) const;
|
QDomElement toXml(QDomDocument &e) const override;
|
||||||
void fromXml(const QDomElement &);
|
void toXml(QDomElement &e) const;
|
||||||
void toSettings(QSettings &, const QString & = QString()) const;
|
bool fromXml(const QDomElement &) override;
|
||||||
void fromSettings(QSettings &, const QString & = QString());
|
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||||
|
void fromSettings(QSettings &, const QString & = QString()) override;
|
||||||
|
|
||||||
void setAutoPageNum(QString autonum) {auto_page_num = autonum;}
|
void setAutoPageNum(QString autonum) {auto_page_num = autonum;}
|
||||||
|
|
||||||
@@ -51,21 +54,21 @@ class TitleBlockProperties {
|
|||||||
QDate finalDate() const ;
|
QDate finalDate() const ;
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
QString title; ///< Folio title (displayed by the default template)
|
QString title; ///< Folio title (displayed by the default template)
|
||||||
QString author; ///< Author of the diagram/folio (displayed by the default template)
|
QString author; ///< Author of the diagram/folio (displayed by the default template)
|
||||||
QDate date; ///< Date (displayed by the default template)
|
QDate date; ///< Date (displayed by the default template)
|
||||||
QString filename; ///< Filename (displayed by the default template)
|
QString filename; ///< Filename (displayed by the default template)
|
||||||
QString plant; ///< Plant (displayed by the default template)
|
QString plant; ///< Plant (displayed by the default template)
|
||||||
QString locmach; ///< Location(displayed by the default template)
|
QString locmach; ///< Location(displayed by the default template)
|
||||||
QString indexrev; ///< Revision Index (displayed by the default template)
|
QString indexrev; ///< Revision Index (displayed by the default template)
|
||||||
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