diff --git a/sources/QetGraphicsItemModeler/qetgraphicshandleritem.h b/sources/QetGraphicsItemModeler/qetgraphicshandleritem.h
index 270b30123..51b7b00fc 100644
--- a/sources/QetGraphicsItemModeler/qetgraphicshandleritem.h
+++ b/sources/QetGraphicsItemModeler/qetgraphicshandleritem.h
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#ifndef QETGRAPHICSHANDLERITEM_H
#define QETGRAPHICSHANDLERITEM_H
@@ -22,43 +22,43 @@
#include
/**
- @brief The QetGraphicsHandlerItem class
- This graphics item represents a point,
- destined to be used as an handler,
- for modifie the geometrie of a another graphics item (like shapes).
- The graphics item to be modified,
- must call "installSceneEventFilter"
- of this item with itself for argument,.
- The ghraphics item to be modified,
- need to reimplement "sceneEventFilter"
- for create the modification behavior.
+ @brief The QetGraphicsHandlerItem class
+ This graphics item represents a point,
+ destined to be used as an handler,
+ for modifie the geometrie of a another graphics item (like shapes).
+ The graphics item to be modified,
+ must call "installSceneEventFilter"
+ of this item with itself for argument,.
+ The ghraphics item to be modified,
+ need to reimplement "sceneEventFilter"
+ for create the modification behavior.
*/
class QetGraphicsHandlerItem : public QGraphicsItem
{
- public:
- QetGraphicsHandlerItem(qreal size = 10);
- QRectF boundingRect() const override;
-
- enum { Type = UserType + 1200};
- int type() const override {return Type;}
-
- void setColor(QColor color);
+ public:
+ QetGraphicsHandlerItem(qreal size = 10);
+ QRectF boundingRect() const override;
+
+ enum { Type = UserType + 1200};
+ int type() const override {return Type;}
+
+ void setColor(QColor color);
- protected:
- void paint(QPainter *painter,
- const QStyleOptionGraphicsItem *option,
- QWidget *widget) override;
+ protected:
+ void paint(QPainter *painter,
+ const QStyleOptionGraphicsItem *option,
+ QWidget *widget) override;
- private:
- QRectF m_handler_rect,
- m_br;
- qreal m_size;
- QColor m_color;
- QPen m_pen;
-
- public:
- static QVector handlerForPoint(
- const QVector &points, int size = 10);
+ private:
+ QRectF m_handler_rect,
+ m_br;
+ qreal m_size;
+ QColor m_color;
+ QPen m_pen;
+
+ public:
+ static QVector handlerForPoint(
+ const QVector &points, int size = 10);
};
#endif // QETGRAPHICSHANDLERITEM_H
diff --git a/sources/borderproperties.cpp b/sources/borderproperties.cpp
index a2aa3de5f..c16186504 100644
--- a/sources/borderproperties.cpp
+++ b/sources/borderproperties.cpp
@@ -1,180 +1,180 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#include "borderproperties.h"
/**
- @brief BorderProperties::BorderProperties
- constructor
- Initializes a BorderProperties object with default properties
+ @brief BorderProperties::BorderProperties
+ constructor
+ Initializes a BorderProperties object with default properties
- Initializes a BorderProperties object
- with the following default properties:
- - 17 columns of 60.0 px wide by 20.0px high
- - 8 lines of 80.0 px high by 20.0px wide
+ Initializes a BorderProperties object
+ with the following default properties:
+ - 17 columns of 60.0 px wide by 20.0px high
+ - 8 lines of 80.0 px high by 20.0px wide
- \~French Initialise un objet BorderProperties avec les proprietes par
- defaut suivantes :
- - 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
+ \~French Initialise un objet BorderProperties avec les proprietes par
+ defaut suivantes :
+ - 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
*/
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)
+ 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)
{
}
/**
- @brief BorderProperties::~BorderProperties
- destructor
+ @brief BorderProperties::~BorderProperties
+ destructor
*/
BorderProperties::~BorderProperties()
{
}
/**
- @brief BorderProperties::operator ==
+ @brief BorderProperties::operator ==
- \~ @param bp : Other BorderProperties container/class.
- \~French Autre conteneur BorderProperties
- \~ @return True if it and this container are identical, false otherwise.
- \~French True si ip et ce conteneur sont identiques, false sinon
+ \~ @param bp : Other BorderProperties container/class.
+ \~French Autre conteneur BorderProperties
+ \~ @return True if it and this container are identical, false otherwise.
+ \~French True si ip et ce conteneur sont identiques, false sinon
*/
bool BorderProperties::operator==(const BorderProperties &bp) {
- return(
- bp.columns_count == columns_count &&\
- bp.columns_width == columns_width &&\
- bp.columns_header_height == columns_header_height &&\
- bp.display_columns == display_columns &&\
- bp.rows_count == rows_count &&\
- bp.rows_height == rows_height &&\
- bp.rows_header_width == rows_header_width &&\
- bp.display_rows == display_rows
- );
+ return(
+ bp.columns_count == columns_count &&\
+ bp.columns_width == columns_width &&\
+ bp.columns_header_height == columns_header_height &&\
+ bp.display_columns == display_columns &&\
+ bp.rows_count == rows_count &&\
+ bp.rows_height == rows_height &&\
+ bp.rows_header_width == rows_header_width &&\
+ bp.display_rows == display_rows
+ );
}
/**
- @brief BorderProperties::operator !=
+ @brief BorderProperties::operator !=
- \~ @param bp :
- Other BorderProperties container/class.
- \~French Autre conteneur BorderProperties
- \~ @return
- False if it and this container are identical, true otherwise.
- \~French False si bp et ce conteneur sont identiques, true sinon
+ \~ @param bp :
+ Other BorderProperties container/class.
+ \~French Autre conteneur BorderProperties
+ \~ @return
+ False if it and this container are identical, true otherwise.
+ \~French False si bp et ce conteneur sont identiques, true sinon
*/
bool BorderProperties::operator!=(const BorderProperties &bp) {
- return(!(*this == bp));
+ return(!(*this == bp));
}
/**
- @brief BorderProperties::toXml
- Exports dimensions as XML attributes added to element e.
- \~French Exporte les dimensions sous formes d'attributs XML ajoutes a l'element e.
+ @brief BorderProperties::toXml
+ Exports dimensions as XML attributes added to element e.
+ \~French Exporte les dimensions sous formes d'attributs XML ajoutes a l'element e.
- \~ @param e :
- XML element to which attributes will be added
- \~French Element XML auquel seront ajoutes des attributs
+ \~ @param e :
+ XML element to which attributes will be added
+ \~French Element XML auquel seront ajoutes des attributs
*/
void BorderProperties::toXml(QDomElement &e) const
{
- e.setAttribute("cols", columns_count);
- e.setAttribute("colsize", QString("%1").arg(columns_width));
- e.setAttribute("rows", rows_count);
- e.setAttribute("rowsize", QString("%1").arg(rows_height));
- e.setAttribute("displaycols", display_columns ? "true" : "false");
- e.setAttribute("displayrows", display_rows ? "true" : "false");
+ e.setAttribute("cols", columns_count);
+ e.setAttribute("colsize", QString("%1").arg(columns_width));
+ e.setAttribute("rows", rows_count);
+ e.setAttribute("rowsize", QString("%1").arg(rows_height));
+ e.setAttribute("displaycols", display_columns ? "true" : "false");
+ e.setAttribute("displayrows", display_rows ? "true" : "false");
}
/**
- @brief BorderProperties::fromXml
- Import dimensions from XML attributes of element e
- \~French Importe les dimensions a partir des attributs XML de l'element e
+ @brief BorderProperties::fromXml
+ Import dimensions from XML attributes of element e
+ \~French Importe les dimensions a partir des attributs XML de l'element e
- \~ @param e :
- XML element whose attributes will be read
- \~French Element XML dont les attributs seront lus
+ \~ @param e :
+ XML element whose attributes will be read
+ \~French Element XML dont les attributs seront lus
*/
void BorderProperties::fromXml(QDomElement &e) {
- if (e.hasAttribute("cols")) columns_count = e.attribute("cols").toInt();
- if (e.hasAttribute("colsize")) columns_width = e.attribute("colsize").toInt();
- if (e.hasAttribute("rows")) rows_count = e.attribute("rows").toInt();
- if (e.hasAttribute("rowsize")) rows_height = e.attribute("rowsize").toInt();
- if (e.hasAttribute("displaycols")) display_columns = e.attribute("displaycols") == "true";
- if (e.hasAttribute("displayrows")) display_rows = e.attribute("displayrows") == "true";
+ if (e.hasAttribute("cols")) columns_count = e.attribute("cols").toInt();
+ if (e.hasAttribute("colsize")) columns_width = e.attribute("colsize").toInt();
+ if (e.hasAttribute("rows")) rows_count = e.attribute("rows").toInt();
+ if (e.hasAttribute("rowsize")) rows_height = e.attribute("rowsize").toInt();
+ if (e.hasAttribute("displaycols")) display_columns = e.attribute("displaycols") == "true";
+ if (e.hasAttribute("displayrows")) display_rows = e.attribute("displayrows") == "true";
}
/**
- @brief BorderProperties::toSettings
- Export dimensions in a QSettings object.
- \~French Exporte les dimensions dans une configuration.
+ @brief BorderProperties::toSettings
+ Export dimensions in a QSettings object.
+ \~French Exporte les dimensions dans une configuration.
- \~ @param settings :
- QSettings object to write
- \~French Parametres a ecrire
- \~ @param prefix :
- prefix to be added before the names of the parameters
- \~French prefixe a ajouter devant les noms des parametres
+ \~ @param settings :
+ QSettings object to write
+ \~French Parametres a ecrire
+ \~ @param prefix :
+ prefix to be added before the names of the parameters
+ \~French prefixe a ajouter devant les noms des parametres
*/
void BorderProperties::toSettings(QSettings &settings, const QString &prefix) const
{
- settings.setValue(prefix + "cols", columns_count);
- settings.setValue(prefix + "colsize", columns_width);
- settings.setValue(prefix + "displaycols", display_columns);
- settings.setValue(prefix + "rows", rows_count);
- settings.setValue(prefix + "rowsize", rows_height);
- settings.setValue(prefix + "displayrows", display_rows);
+ settings.setValue(prefix + "cols", columns_count);
+ settings.setValue(prefix + "colsize", columns_width);
+ settings.setValue(prefix + "displaycols", display_columns);
+ settings.setValue(prefix + "rows", rows_count);
+ settings.setValue(prefix + "rowsize", rows_height);
+ settings.setValue(prefix + "displayrows", display_rows);
}
/**
- @brief BorderProperties::fromSettings
- Import dimensions from a QSettings object.
- \~French Importe les dimensions depuis une configuration.
- \~ @param settings : QSettings object to read
- \~French Parametres a lire
- \~ @param prefix : prefix to be added before the names of the parameters
- \~French prefixe a ajouter devant les noms des parametres
+ @brief BorderProperties::fromSettings
+ Import dimensions from a QSettings object.
+ \~French Importe les dimensions depuis une configuration.
+ \~ @param settings : QSettings object to read
+ \~French Parametres a lire
+ \~ @param prefix : prefix to be added before the names of the parameters
+ \~French prefixe a ajouter devant les noms des parametres
*/
void BorderProperties::fromSettings(QSettings &settings, const QString &prefix) {
- columns_count = settings.value(prefix + "cols", columns_count).toInt();
- columns_width = qRound(settings.value(prefix + "colsize", columns_width).toDouble());
- display_columns = settings.value(prefix + "displaycols", display_columns).toBool();
-
- rows_count = settings.value(prefix + "rows", rows_count).toInt();
- rows_height = qRound(settings.value(prefix + "rowsize", rows_height).toDouble());
- display_rows = settings.value(prefix + "displayrows", display_rows).toBool();
+ columns_count = settings.value(prefix + "cols", columns_count).toInt();
+ columns_width = qRound(settings.value(prefix + "colsize", columns_width).toDouble());
+ display_columns = settings.value(prefix + "displaycols", display_columns).toBool();
+
+ rows_count = settings.value(prefix + "rows", rows_count).toInt();
+ rows_height = qRound(settings.value(prefix + "rowsize", rows_height).toDouble());
+ display_rows = settings.value(prefix + "displayrows", display_rows).toBool();
}
/**
- @brief BorderProperties::defaultProperties
- @return the default properties stored in the setting file
+ @brief BorderProperties::defaultProperties
+ @return the default properties stored in the setting file
*/
BorderProperties BorderProperties::defaultProperties()
{
- QSettings settings;
+ QSettings settings;
- BorderProperties def;
- def.fromSettings(settings, "diagrameditor/default");
+ BorderProperties def;
+ def.fromSettings(settings, "diagrameditor/default");
- return(def);
+ return(def);
}
diff --git a/sources/borderproperties.h b/sources/borderproperties.h
index 74df1e8bb..a8429a332 100644
--- a/sources/borderproperties.h
+++ b/sources/borderproperties.h
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#ifndef BORDER_PROPERTIES_H
#define BORDER_PROPERTIES_H
@@ -21,36 +21,36 @@
#include
/**
- @brief The BorderProperties class
- This class is a container for dimensions and display properties of a
- diagram.
- @remark Attributes are public
+ @brief The BorderProperties class
+ This class is a container for dimensions and display properties of a
+ diagram.
+ @remark Attributes are public
*/
class BorderProperties {
- public:
- // constructor, destructor, operators
- BorderProperties();
- virtual ~BorderProperties();
-
- bool operator==(const BorderProperties &);
- bool operator!=(const BorderProperties &);
-
- void toXml(QDomElement &) const;
- void fromXml(QDomElement &);
- void toSettings(QSettings &, const QString & = QString()) const;
- void fromSettings(QSettings &, const QString & = QString());
+ public:
+ // constructor, destructor, operators
+ BorderProperties();
+ virtual ~BorderProperties();
+
+ bool operator==(const BorderProperties &);
+ bool operator!=(const BorderProperties &);
+
+ void toXml(QDomElement &) const;
+ void fromXml(QDomElement &);
+ void toSettings(QSettings &, const QString & = QString()) const;
+ void fromSettings(QSettings &, const QString & = QString());
- static BorderProperties defaultProperties();
-
- // attributes
- int columns_count; ///< Columns count
- qreal columns_width; ///< Columns width
- qreal columns_header_height; ///< Column headers height
- bool display_columns; ///< Whether to display column headers
-
- int rows_count; ///< Rows count
- qreal rows_height; ///< Rows height
- qreal rows_header_width; ///< Row headers width
- bool display_rows; ///< Whether to display row headers
+ static BorderProperties defaultProperties();
+
+ // attributes
+ int columns_count; ///< Columns count
+ qreal columns_width; ///< Columns width
+ qreal columns_header_height; ///< Column headers height
+ bool display_columns; ///< Whether to display column headers
+
+ int rows_count; ///< Rows count
+ qreal rows_height; ///< Rows height
+ qreal rows_header_width; ///< Row headers width
+ bool display_rows; ///< Whether to display row headers
};
#endif
diff --git a/sources/bordertitleblock.cpp b/sources/bordertitleblock.cpp
index 026bab62f..9f509f044 100644
--- a/sources/bordertitleblock.cpp
+++ b/sources/bordertitleblock.cpp
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#include
#include
@@ -34,1066 +34,1066 @@
#define MIN_ROW_HEIGHT 5.0
/**
- @brief BorderTitleBlock::BorderTitleBlock
- Simple constructor:
- build a border by recovering the dimensions
- in the application configuration.
+ @brief BorderTitleBlock::BorderTitleBlock
+ Simple constructor:
+ build a border by recovering the dimensions
+ in the application configuration.
- \~French Constructeur simple :
- construit une bordure en recuperant les dimensions
- dans la configuration de l'application.
- \~ @param parent :
- \~French QObject parent de ce BorderTitleBlock
+ \~French Constructeur simple :
+ construit une bordure en recuperant les dimensions
+ dans la configuration de l'application.
+ \~ @param parent :
+ \~French QObject parent de ce BorderTitleBlock
*/
BorderTitleBlock::BorderTitleBlock(QObject *parent) :
- QObject(parent)
+ QObject(parent)
{
- // at first, the internal titleblock template renderer uses the default titleblock template
- m_titleblock_template_renderer = new TitleBlockTemplateRenderer(this);
- m_titleblock_template_renderer -> setTitleBlockTemplate(QETApp::defaultTitleBlockTemplate());
+ // at first, the internal titleblock template renderer uses the default titleblock template
+ m_titleblock_template_renderer = new TitleBlockTemplateRenderer(this);
+ m_titleblock_template_renderer -> setTitleBlockTemplate(QETApp::defaultTitleBlockTemplate());
- // disable the QPicture-based cache from Qt 4.8 to avoid rendering errors and crashes
-#if QT_VERSION < QT_VERSION_CHECK(4, 8, 0) // ### Qt 6: remove
+ // disable the QPicture-based cache from Qt 4.8 to avoid rendering errors and crashes
+#if QT_VERSION < QT_VERSION_CHECK(4, 8, 0) // ### Qt 6: remove
#else
- m_titleblock_template_renderer -> setUseCache(false);
+ m_titleblock_template_renderer -> setUseCache(false);
#endif
- // dimensions par defaut du schema
- importBorder(BorderProperties());
+ // dimensions par defaut du schema
+ importBorder(BorderProperties());
- // contenu par defaut du cartouche
- importTitleBlock(TitleBlockProperties());
+ // contenu par defaut du cartouche
+ importTitleBlock(TitleBlockProperties());
- display_titleblock_ = true;
- display_border_ = true;
- setFolioData(1, 1);
- updateRectangles();
+ display_titleblock_ = true;
+ display_border_ = true;
+ setFolioData(1, 1);
+ updateRectangles();
}
/**
- @brief BorderTitleBlock::~BorderTitleBlock
- \~French Destructeur - ne fait rien
+ @brief BorderTitleBlock::~BorderTitleBlock
+ \~French Destructeur - ne fait rien
*/
BorderTitleBlock::~BorderTitleBlock()
{
}
/**
- @brief BorderTitleBlock::titleBlockRect
- @return the rectangle of the titleblock in scene coordinate.
+ @brief BorderTitleBlock::titleBlockRect
+ @return the rectangle of the titleblock in scene coordinate.
*/
QRectF BorderTitleBlock::titleBlockRect() const
{
- if (m_edge == Qt::BottomEdge)
- return QRectF(diagram_rect_.bottomLeft(),
- QSize(diagram_rect_.width(),
- m_titleblock_template_renderer -> height()
- ));
- else
- return QRectF(diagram_rect_.topRight(),
- QSize(m_titleblock_template_renderer -> height(),
- diagram_rect_.height()
- ));
+ if (m_edge == Qt::BottomEdge)
+ return QRectF(diagram_rect_.bottomLeft(),
+ QSize(diagram_rect_.width(),
+ m_titleblock_template_renderer -> height()
+ ));
+ else
+ return QRectF(diagram_rect_.topRight(),
+ QSize(m_titleblock_template_renderer -> height(),
+ diagram_rect_.height()
+ ));
}
/**
- @brief BorderTitleBlock::titleblockInformation
- @return
+ @brief BorderTitleBlock::titleblockInformation
+ @return
*/
DiagramContext BorderTitleBlock::titleblockInformation() const
{
- return m_titleblock_template_renderer->context();
+ return m_titleblock_template_renderer->context();
}
/**
- @brief BorderTitleBlock::titleBlockRectForQPainter
- @return The title block rect to use with the QPainter in the method draw.
- The returned rect is alway horizontal
- (like displayed at the bottom of rect) only the top left change of pos
- according to the edge where the title block need to be displayed.
- Rect according to edge:
- Bottom : top left is at the bottom left edge of the diagram rect.
- Right : top left is at the bottom right of diagram rect.
- Befor use this rect you need to rotate the QPainter by -90°
- for snap the rect at the right edge of diagram.
+ @brief BorderTitleBlock::titleBlockRectForQPainter
+ @return The title block rect to use with the QPainter in the method draw.
+ The returned rect is alway horizontal
+ (like displayed at the bottom of rect) only the top left change of pos
+ according to the edge where the title block need to be displayed.
+ Rect according to edge:
+ Bottom : top left is at the bottom left edge of the diagram rect.
+ Right : top left is at the bottom right of diagram rect.
+ Befor use this rect you need to rotate the QPainter by -90°
+ for snap the rect at the right edge of diagram.
*/
QRectF BorderTitleBlock::titleBlockRectForQPainter() const
{
- //Rect at bottom have same position and dimension of displayed rect
- if (m_edge == Qt::BottomEdge)
- return titleBlockRect();
- else
- return QRectF (diagram_rect_.bottomRight(),
- QSize(diagram_rect_.height(),
- m_titleblock_template_renderer -> height()
- ));
+ //Rect at bottom have same position and dimension of displayed rect
+ if (m_edge == Qt::BottomEdge)
+ return titleBlockRect();
+ else
+ return QRectF (diagram_rect_.bottomRight(),
+ QSize(diagram_rect_.height(),
+ m_titleblock_template_renderer -> height()
+ ));
}
/**
- @brief BorderTitleBlock::borderAndTitleBlockRect
- @return the bounding rectangle of diagram and titleblock.
- It's like unite outsideBorderRect and titleBlockRect.
- The rect is in scene coordinate
+ @brief BorderTitleBlock::borderAndTitleBlockRect
+ @return the bounding rectangle of diagram and titleblock.
+ It's like unite outsideBorderRect and titleBlockRect.
+ The rect is in scene coordinate
*/
QRectF BorderTitleBlock::borderAndTitleBlockRect() const
{
- return diagram_rect_ | titleBlockRect();
+ return diagram_rect_ | titleBlockRect();
}
/**
- @brief BorderTitleBlock::columnsRect
- @return The columns rect in scene coordinate.
- If column is not displayed, return a null QRectF
+ @brief BorderTitleBlock::columnsRect
+ @return The columns rect in scene coordinate.
+ If column is not displayed, return a null QRectF
*/
QRectF BorderTitleBlock::columnsRect() const
{
- if (!display_columns_) return QRectF();
- return QRectF (Diagram::margin,
- Diagram::margin,
- (columns_count_*columns_width_) + rows_header_width_,
- columns_header_height_);
+ if (!display_columns_) return QRectF();
+ return QRectF (Diagram::margin,
+ Diagram::margin,
+ (columns_count_*columns_width_) + rows_header_width_,
+ columns_header_height_);
}
/**
- @brief BorderTitleBlock::rowsRect
- @return The rows rect in scene coordinate.
- If row is not displayed, return a null QRectF
+ @brief BorderTitleBlock::rowsRect
+ @return The rows rect in scene coordinate.
+ If row is not displayed, return a null QRectF
*/
QRectF BorderTitleBlock::rowsRect() const
{
- if (!display_rows_) return QRectF();
- return QRectF (Diagram::margin,
- Diagram::margin,
- rows_header_width_,
- (rows_count_*rows_height_) + columns_header_height_);
+ if (!display_rows_) return QRectF();
+ return QRectF (Diagram::margin,
+ Diagram::margin,
+ rows_header_width_,
+ (rows_count_*rows_height_) + columns_header_height_);
}
/**
- @brief BorderTitleBlock::outsideBorderRect
- @return The rect of outside border (diagram with columns and rows)
- The rect is in scene coordinate
+ @brief BorderTitleBlock::outsideBorderRect
+ @return The rect of outside border (diagram with columns and rows)
+ The rect is in scene coordinate
*/
QRectF BorderTitleBlock::outsideBorderRect() const
{
- return QRectF (Diagram::margin,
- Diagram::margin,
- (columns_width_*columns_count_) + rows_header_width_,
- (rows_height_*rows_count_) + columns_header_height_);
+ return QRectF (Diagram::margin,
+ Diagram::margin,
+ (columns_width_*columns_count_) + rows_header_width_,
+ (rows_height_*rows_count_) + columns_header_height_);
}
/**
- @brief BorderTitleBlock::insideBorderRect
- @return The rect of the inside border, in other word, the drawing area.
- This method take care about if rows or columns are displayed or not.
- The rect is in scene coordinate
+ @brief BorderTitleBlock::insideBorderRect
+ @return The rect of the inside border, in other word, the drawing area.
+ This method take care about if rows or columns are displayed or not.
+ The rect is in scene coordinate
*/
QRectF BorderTitleBlock::insideBorderRect() const
{
- qreal left = Diagram::margin;
- qreal top = Diagram::margin;
- qreal width = columns_width_*columns_count_;
- qreal height = rows_height_*rows_count_;
+ qreal left = Diagram::margin;
+ qreal top = Diagram::margin;
+ qreal width = columns_width_*columns_count_;
+ qreal height = rows_height_*rows_count_;
- display_rows_ ? left += rows_header_width_ : width += rows_header_width_;
- display_columns_ ? top += columns_header_height_ : height += columns_header_height_;
+ display_rows_ ? left += rows_header_width_ : width += rows_header_width_;
+ display_columns_ ? top += columns_header_height_ : height += columns_header_height_;
- return QRectF (left, top, width, height);
+ return QRectF (left, top, width, height);
}
/**
- @brief BorderTitleBlock::titleBlockToXml
- Exports the title block current values to XML.
- @param xml_elmt the XML element attributes will be added to
+ @brief BorderTitleBlock::titleBlockToXml
+ Exports the title block current values to XML.
+ @param xml_elmt the XML element attributes will be added to
*/
void BorderTitleBlock::titleBlockToXml(QDomElement &xml_elmt) {
- exportTitleBlock().toXml(xml_elmt);
+ exportTitleBlock().toXml(xml_elmt);
}
/**
- @brief BorderTitleBlock::titleBlockFromXml
- Reads the title block values from XML.
- @param xml_elmt the XML element values will be read from
+ @brief BorderTitleBlock::titleBlockFromXml
+ Reads the title block values from XML.
+ @param xml_elmt the XML element values will be read from
*/
void BorderTitleBlock::titleBlockFromXml(const QDomElement &xml_elmt) {
- TitleBlockProperties tbp;
- tbp.fromXml(xml_elmt);
- importTitleBlock(tbp);
+ TitleBlockProperties tbp;
+ tbp.fromXml(xml_elmt);
+ importTitleBlock(tbp);
}
/**
- @brief BorderTitleBlock::borderToXml
- Exports the border current settings to XML.
- @param xml_elmt the XML element attributes will be added to
+ @brief BorderTitleBlock::borderToXml
+ Exports the border current settings to XML.
+ @param xml_elmt the XML element attributes will be added to
*/
void BorderTitleBlock::borderToXml(QDomElement &xml_elmt) {
- xml_elmt.setAttribute("cols", columnsCount());
- xml_elmt.setAttribute("colsize", QString("%1").arg(columnsWidth()));
- xml_elmt.setAttribute("displaycols", columnsAreDisplayed() ? "true" : "false");
+ xml_elmt.setAttribute("cols", columnsCount());
+ xml_elmt.setAttribute("colsize", QString("%1").arg(columnsWidth()));
+ xml_elmt.setAttribute("displaycols", columnsAreDisplayed() ? "true" : "false");
- xml_elmt.setAttribute("rows", rowsCount());
- xml_elmt.setAttribute("rowsize", QString("%1").arg(rowsHeight()));
- xml_elmt.setAttribute("displayrows", rowsAreDisplayed() ? "true" : "false");
+ xml_elmt.setAttribute("rows", rowsCount());
+ xml_elmt.setAttribute("rowsize", QString("%1").arg(rowsHeight()));
+ xml_elmt.setAttribute("displayrows", rowsAreDisplayed() ? "true" : "false");
- // attribut datant de la version 0.1 - laisse pour retrocompatibilite
- xml_elmt.setAttribute("height", QString("%1").arg(diagramHeight()));
+ // attribut datant de la version 0.1 - laisse pour retrocompatibilite
+ xml_elmt.setAttribute("height", QString("%1").arg(diagramHeight()));
}
/**
- @brief BorderTitleBlock::borderFromXml
- Reads the border settings from XML.
- @param xml_elmt the XML element values will be read from
+ @brief BorderTitleBlock::borderFromXml
+ Reads the border settings from XML.
+ @param xml_elmt the XML element values will be read from
*/
void BorderTitleBlock::borderFromXml(const QDomElement &xml_elmt) {
- bool ok;
- // columns count
- int cols_count = xml_elmt.attribute("cols").toInt(&ok);
- if (ok) setColumnsCount(cols_count);
+ bool ok;
+ // columns count
+ int cols_count = xml_elmt.attribute("cols").toInt(&ok);
+ if (ok) setColumnsCount(cols_count);
- // columns width
- double cols_width = xml_elmt.attribute("colsize").toDouble(&ok);
- if (ok) setColumnsWidth(cols_width);
+ // columns width
+ double cols_width = xml_elmt.attribute("colsize").toDouble(&ok);
+ if (ok) setColumnsWidth(cols_width);
- // backward compatibility:
- // diagrams saved with 0.1 version have a "height" attribute
- if (xml_elmt.hasAttribute("rows") && xml_elmt.hasAttribute("rowsize")) {
- // rows counts
- int rows_count = xml_elmt.attribute("rows").toInt(&ok);
- if (ok) setRowsCount(rows_count);
+ // backward compatibility:
+ // diagrams saved with 0.1 version have a "height" attribute
+ if (xml_elmt.hasAttribute("rows") && xml_elmt.hasAttribute("rowsize")) {
+ // rows counts
+ int rows_count = xml_elmt.attribute("rows").toInt(&ok);
+ if (ok) setRowsCount(rows_count);
- // taille des lignes
- double rows_size = xml_elmt.attribute("rowsize").toDouble(&ok);
- if (ok) setRowsHeight(rows_size);
- } else {
- // hauteur du schema
- double height = xml_elmt.attribute("height").toDouble(&ok);
- if (ok) setDiagramHeight(height);
- }
+ // taille des lignes
+ double rows_size = xml_elmt.attribute("rowsize").toDouble(&ok);
+ if (ok) setRowsHeight(rows_size);
+ } else {
+ // hauteur du schema
+ double height = xml_elmt.attribute("height").toDouble(&ok);
+ if (ok) setDiagramHeight(height);
+ }
- // rows and columns display
- displayColumns(xml_elmt.attribute("displaycols") != "false");
- displayRows(xml_elmt.attribute("displayrows") != "false");
+ // rows and columns display
+ displayColumns(xml_elmt.attribute("displaycols") != "false");
+ displayRows(xml_elmt.attribute("displayrows") != "false");
- updateRectangles();
+ updateRectangles();
}
/**
- @brief BorderTitleBlock::exportTitleBlock
- @return the properties of the titleblock
- \~French les proprietes du cartouches
+ @brief BorderTitleBlock::exportTitleBlock
+ @return the properties of the titleblock
+ \~French les proprietes du cartouches
*/
TitleBlockProperties BorderTitleBlock::exportTitleBlock()
{
- TitleBlockProperties ip;
+ TitleBlockProperties ip;
- ip.author = author();
- ip.date = date();
- ip.title = title();
- ip.filename = fileName();
- ip.plant = plant();
- ip.locmach = locmach();
- ip.indexrev = indexrev();
- ip.version = version();
- ip.folio = folio();
- ip.template_name = titleBlockTemplateName();
- ip.display_at = m_edge;
- ip.auto_page_num = autoPageNum();
- ip.context = additional_fields_;
- ip.collection = QET::QetCollection::Embedded;
+ ip.author = author();
+ ip.date = date();
+ ip.title = title();
+ ip.filename = fileName();
+ ip.plant = plant();
+ ip.locmach = locmach();
+ ip.indexrev = indexrev();
+ ip.version = version();
+ ip.folio = folio();
+ ip.template_name = titleBlockTemplateName();
+ ip.display_at = m_edge;
+ ip.auto_page_num = autoPageNum();
+ ip.context = additional_fields_;
+ ip.collection = QET::QetCollection::Embedded;
- return(ip);
+ return(ip);
}
/**
- @brief BorderTitleBlock::importTitleBlock
- @param ip the new properties of titleblock
+ @brief BorderTitleBlock::importTitleBlock
+ @param ip the new properties of titleblock
*/
void BorderTitleBlock::importTitleBlock(const TitleBlockProperties &ip) {
- setAuthor(ip.author);
- setDate(ip.date);
- setTitle(ip.title);
- setFileName(ip.filename);
- setPlant(ip.plant);
- setLocMach(ip.locmach);
- setIndicerev(ip.indexrev);
- setVersion(QET::displayedVersion);
- setFolio(ip.folio);
- setAutoPageNum(ip.auto_page_num);
- if (m_edge != ip.display_at)
- {
- m_edge = ip.display_at;
- emit(displayChanged());
- }
- additional_fields_ = ip.context;
+ setAuthor(ip.author);
+ setDate(ip.date);
+ setTitle(ip.title);
+ setFileName(ip.filename);
+ setPlant(ip.plant);
+ setLocMach(ip.locmach);
+ setIndicerev(ip.indexrev);
+ setVersion(QET::displayedVersion);
+ setFolio(ip.folio);
+ setAutoPageNum(ip.auto_page_num);
+ if (m_edge != ip.display_at)
+ {
+ m_edge = ip.display_at;
+ emit(displayChanged());
+ }
+ additional_fields_ = ip.context;
- emit(needFolioData()); // Note: we expect additional data to be provided
- // through setFolioData(),
- // which in turn calls updateDiagramContextForTitleBlock().
- emit(needTitleBlockTemplate(ip.template_name));
+ emit(needFolioData()); // Note: we expect additional data to be provided
+ // through setFolioData(),
+ // which in turn calls updateDiagramContextForTitleBlock().
+ emit(needTitleBlockTemplate(ip.template_name));
}
/**
- @brief BorderTitleBlock::exportBorder
- @return border properties
- \~French les proprietes de la bordure
+ @brief BorderTitleBlock::exportBorder
+ @return border properties
+ \~French les proprietes de la bordure
*/
BorderProperties BorderTitleBlock::exportBorder()
{
- BorderProperties bp;
- bp.columns_count = columnsCount();
- bp.columns_width = columnsWidth();
- bp.columns_header_height = columnsHeaderHeight();
- bp.display_columns = columnsAreDisplayed();
- bp.rows_count = rowsCount();
- bp.rows_height = rowsHeight();
- bp.rows_header_width = rowsHeaderWidth();
- bp.display_rows = rowsAreDisplayed();
- return(bp);
+ BorderProperties bp;
+ bp.columns_count = columnsCount();
+ bp.columns_width = columnsWidth();
+ bp.columns_header_height = columnsHeaderHeight();
+ bp.display_columns = columnsAreDisplayed();
+ bp.rows_count = rowsCount();
+ bp.rows_height = rowsHeight();
+ bp.rows_header_width = rowsHeaderWidth();
+ bp.display_rows = rowsAreDisplayed();
+ return(bp);
}
/**
- @brief BorderTitleBlock::importBorder
- @param bp : the new properties of the border
- \~French les nouvelles proprietes de la bordure
+ @brief BorderTitleBlock::importBorder
+ @param bp : the new properties of the border
+ \~French les nouvelles proprietes de la bordure
*/
void BorderTitleBlock::importBorder(const BorderProperties &bp) {
- setColumnsHeaderHeight(bp.columns_header_height);
- setColumnsCount(bp.columns_count);
- setColumnsWidth(bp.columns_width);
- displayColumns(bp.display_columns);
- setRowsHeaderWidth(bp.rows_header_width);
- setRowsCount(bp.rows_count);
- setRowsHeight(bp.rows_height);
- displayRows(bp.display_rows);
+ setColumnsHeaderHeight(bp.columns_header_height);
+ setColumnsCount(bp.columns_count);
+ setColumnsWidth(bp.columns_width);
+ displayColumns(bp.display_columns);
+ setRowsHeaderWidth(bp.rows_header_width);
+ setRowsCount(bp.rows_count);
+ setRowsHeight(bp.rows_height);
+ displayRows(bp.display_rows);
}
/**
- @brief BorderTitleBlock::titleBlockTemplate
- @return the titleblock template used to render the titleblock
- @see TitleBlockTemplateRenderer::titleBlockTemplate()
+ @brief BorderTitleBlock::titleBlockTemplate
+ @return the titleblock template used to render the titleblock
+ @see TitleBlockTemplateRenderer::titleBlockTemplate()
*/
const TitleBlockTemplate *BorderTitleBlock::titleBlockTemplate()
{
- return(m_titleblock_template_renderer -> titleBlockTemplate());
+ return(m_titleblock_template_renderer -> titleBlockTemplate());
}
/**
- @brief BorderTitleBlock::setTitleBlockTemplate
- @param titleblock_template:
- The new titleblock template to use to render the titleblock
- @see TitleBlockTemplateRenderer::setTitleBlockTemplate()
+ @brief BorderTitleBlock::setTitleBlockTemplate
+ @param titleblock_template:
+ The new titleblock template to use to render the titleblock
+ @see TitleBlockTemplateRenderer::setTitleBlockTemplate()
*/
void BorderTitleBlock::setTitleBlockTemplate(
- const TitleBlockTemplate *titleblock_template) {
- m_titleblock_template_renderer -> setTitleBlockTemplate(
- titleblock_template);
+ const TitleBlockTemplate *titleblock_template) {
+ m_titleblock_template_renderer -> setTitleBlockTemplate(
+ titleblock_template);
}
/**
- @brief BorderTitleBlock::titleBlockTemplateName
- @return The name of the template used to render the titleblock.
+ @brief BorderTitleBlock::titleBlockTemplateName
+ @return The name of the template used to render the titleblock.
*/
QString BorderTitleBlock::titleBlockTemplateName() const
{
- QString tbt_name = m_titleblock_template_renderer -> titleBlockTemplate() -> name();
- return((tbt_name == "default") ? "" : tbt_name);
+ QString tbt_name = m_titleblock_template_renderer -> titleBlockTemplate() -> name();
+ return((tbt_name == "default") ? "" : tbt_name);
}
/**
- @brief BorderTitleBlock::titleBlockTemplateChanged
- This slot may be used to inform this class that the given title block
- template has changed.
- The title block-dedicated rendering cache will thus be flushed.
- @param template_name : Name of the title block template that has changed
+ @brief BorderTitleBlock::titleBlockTemplateChanged
+ This slot may be used to inform this class that the given title block
+ template has changed.
+ The title block-dedicated rendering cache will thus be flushed.
+ @param template_name : Name of the title block template that has changed
*/
void BorderTitleBlock::titleBlockTemplateChanged(const QString &template_name) {
- if (titleBlockTemplateName() != template_name) return;
- m_titleblock_template_renderer -> invalidateRenderedTemplate();
+ if (titleBlockTemplateName() != template_name) return;
+ m_titleblock_template_renderer -> invalidateRenderedTemplate();
}
/**
- @brief BorderTitleBlock::titleBlockTemplateRemoved
- This slot has to be used to inform this class that the given title block
- template is about to be removed and is no longer accessible. This class
- will either use the provided optional TitleBlockTemplate or the default
- title block provided by QETApp::defaultTitleBlockTemplate()
- @param removed_template_name :
- Name of the title block template that has changed
- @param new_template (Optional) title block template to use instead
+ @brief BorderTitleBlock::titleBlockTemplateRemoved
+ This slot has to be used to inform this class that the given title block
+ template is about to be removed and is no longer accessible. This class
+ will either use the provided optional TitleBlockTemplate or the default
+ title block provided by QETApp::defaultTitleBlockTemplate()
+ @param removed_template_name :
+ Name of the title block template that has changed
+ @param new_template (Optional) title block template to use instead
*/
void BorderTitleBlock::titleBlockTemplateRemoved(
- const QString &removed_template_name,
- const TitleBlockTemplate *new_template) {
- if (titleBlockTemplateName() != removed_template_name) return;
+ const QString &removed_template_name,
+ const TitleBlockTemplate *new_template) {
+ if (titleBlockTemplateName() != removed_template_name) return;
- if (new_template) {
- setTitleBlockTemplate(new_template);
- } else {
- setTitleBlockTemplate(QETApp::defaultTitleBlockTemplate());
- }
+ if (new_template) {
+ setTitleBlockTemplate(new_template);
+ } else {
+ setTitleBlockTemplate(QETApp::defaultTitleBlockTemplate());
+ }
}
/**
- @brief BorderTitleBlock::displayTitleBlock
- @param di : true to display the title block, false otherwise
- \~French true pour afficher le cartouche, false sinon
+ @brief BorderTitleBlock::displayTitleBlock
+ @param di : true to display the title block, false otherwise
+ \~French true pour afficher le cartouche, false sinon
*/
void BorderTitleBlock::displayTitleBlock(bool di) {
- bool change = (di != display_titleblock_);
- display_titleblock_ = di;
- if (change) emit(displayChanged());
+ bool change = (di != display_titleblock_);
+ display_titleblock_ = di;
+ if (change) emit(displayChanged());
}
/**
- @brief BorderTitleBlock::displayColumns
- @param dc : true to display the column headers, false otherwise
- \~French true pour afficher les entetes des colonnes, false sinon
+ @brief BorderTitleBlock::displayColumns
+ @param dc : true to display the column headers, false otherwise
+ \~French true pour afficher les entetes des colonnes, false sinon
*/
void BorderTitleBlock::displayColumns(bool dc) {
- bool change = (dc != display_columns_);
- display_columns_ = dc;
- if (change) emit(displayChanged());
+ bool change = (dc != display_columns_);
+ display_columns_ = dc;
+ if (change) emit(displayChanged());
}
/**
- @brief BorderTitleBlock::displayRows
- @param dr : true to display line headers, false otherwise
- \~French true pour afficher les entetes des lignes, false sinon
+ @brief BorderTitleBlock::displayRows
+ @param dr : true to display line headers, false otherwise
+ \~French true pour afficher les entetes des lignes, false sinon
*/
void BorderTitleBlock::displayRows(bool dr) {
- bool change = (dr != display_rows_);
- display_rows_ = dr;
- if (change) emit(displayChanged());
+ bool change = (dr != display_rows_);
+ display_rows_ = dr;
+ if (change) emit(displayChanged());
}
/**
- @brief BorderTitleBlock::displayBorder
- @param db : true to display the border of the diagram, false otherwise
- \~French true pour afficher la bordure du schema, false sinon
- \~ @note : if the border display is deactivated,
- the rows and columns will not be drawn.
- \~French si l'affichage de la bordure est ainsi desactivee,
- les lignes et colonnes ne seront pas dessinees.
+ @brief BorderTitleBlock::displayBorder
+ @param db : true to display the border of the diagram, false otherwise
+ \~French true pour afficher la bordure du schema, false sinon
+ \~ @note : if the border display is deactivated,
+ the rows and columns will not be drawn.
+ \~French si l'affichage de la bordure est ainsi desactivee,
+ les lignes et colonnes ne seront pas dessinees.
*/
void BorderTitleBlock::displayBorder(bool db) {
- bool change = (db != display_border_);
- display_border_ = db;
- if (change) emit(displayChanged());
+ bool change = (db != display_border_);
+ display_border_ = db;
+ if (change) emit(displayChanged());
}
/**
- @brief BorderTitleBlock::slot_setAutoPageNum
- @param pageAutoNum :
- Set Page (Folio) Auto Num
+ @brief BorderTitleBlock::slot_setAutoPageNum
+ @param pageAutoNum :
+ Set Page (Folio) Auto Num
*/
void BorderTitleBlock::slot_setAutoPageNum(QString pageAutoNum) {
- btb_auto_page_num_=std::move(pageAutoNum);
+ btb_auto_page_num_=std::move(pageAutoNum);
}
/**
- @brief BorderTitleBlock::updateRectangles
- This method update the diagram rect according
- to the value of rows and columns (number and size)
+ @brief BorderTitleBlock::updateRectangles
+ This method update the diagram rect according
+ to the value of rows and columns (number and size)
*/
void BorderTitleBlock::updateRectangles()
{
- QRectF previous_diagram = diagram_rect_;
- diagram_rect_ = QRectF(Diagram::margin,
- Diagram::margin,
- diagramWidth(),
- diagramHeight());
- if (diagram_rect_ != previous_diagram)
- emit(borderChanged(previous_diagram, diagram_rect_));
+ QRectF previous_diagram = diagram_rect_;
+ diagram_rect_ = QRectF(Diagram::margin,
+ Diagram::margin,
+ diagramWidth(),
+ diagramHeight());
+ if (diagram_rect_ != previous_diagram)
+ emit(borderChanged(previous_diagram, diagram_rect_));
}
/**
- @brief BorderTitleBlock::draw
- Draw the border and the titleblock.
- @param painter : QPainter to use for draw this.
+ @brief BorderTitleBlock::draw
+ Draw the border and the titleblock.
+ @param painter : QPainter to use for draw this.
*/
void BorderTitleBlock::draw(QPainter *painter)
{
- //Set the QPainter
- painter -> save();
- QPen pen(Qt::black);
- pen.setCosmetic(true);
- painter -> setPen(pen);
- painter -> setBrush(Qt::NoBrush);
+ //Set the QPainter
+ painter -> save();
+ QPen pen(Qt::black);
+ pen.setCosmetic(true);
+ painter -> setPen(pen);
+ painter -> setBrush(Qt::NoBrush);
- QSettings settings;
+ QSettings settings;
- //Draw the borer
- if (display_border_) painter -> drawRect(diagram_rect_);
+ //Draw the borer
+ if (display_border_) painter -> drawRect(diagram_rect_);
- painter -> setFont(QETApp::diagramTextsFont());
+ painter -> setFont(QETApp::diagramTextsFont());
- //Draw the empty case at the top left of diagram when there is header
- if (display_border_ && (display_columns_ || display_rows_))
- {
- QRectF first_rectangle(
- diagram_rect_.topLeft().x(),
- diagram_rect_.topLeft().y(),
- rows_header_width_,
- columns_header_height_
- );
- painter -> drawRect(first_rectangle);
- }
+ //Draw the empty case at the top left of diagram when there is header
+ if (display_border_ && (display_columns_ || display_rows_))
+ {
+ QRectF first_rectangle(
+ diagram_rect_.topLeft().x(),
+ diagram_rect_.topLeft().y(),
+ rows_header_width_,
+ columns_header_height_
+ );
+ painter -> drawRect(first_rectangle);
+ }
- //Draw the nums of columns
- if (display_border_ && display_columns_) {
- for (int i = 1 ; i <= columns_count_ ; ++ i) {
- QRectF numbered_rectangle = QRectF(
- diagram_rect_.topLeft().x()
- + (rows_header_width_
- + ((i - 1) * columns_width_)),
- diagram_rect_.topLeft().y(),
- columns_width_,
- columns_header_height_
- );
- painter -> drawRect(numbered_rectangle);
- if (settings.value("border-columns_0", true).toBool()){
- painter -> drawText(numbered_rectangle,
- Qt::AlignVCenter
- | Qt::AlignCenter,
- QString("%1").arg(i - 1));
- }else{
- painter -> drawText(numbered_rectangle,
- Qt::AlignVCenter
- | Qt::AlignCenter,
- QString("%1").arg(i));
- }
- }
- }
+ //Draw the nums of columns
+ if (display_border_ && display_columns_) {
+ for (int i = 1 ; i <= columns_count_ ; ++ i) {
+ QRectF numbered_rectangle = QRectF(
+ diagram_rect_.topLeft().x()
+ + (rows_header_width_
+ + ((i - 1) * columns_width_)),
+ diagram_rect_.topLeft().y(),
+ columns_width_,
+ columns_header_height_
+ );
+ painter -> drawRect(numbered_rectangle);
+ if (settings.value("border-columns_0", true).toBool()){
+ painter -> drawText(numbered_rectangle,
+ Qt::AlignVCenter
+ | Qt::AlignCenter,
+ QString("%1").arg(i - 1));
+ }else{
+ painter -> drawText(numbered_rectangle,
+ Qt::AlignVCenter
+ | Qt::AlignCenter,
+ QString("%1").arg(i));
+ }
+ }
+ }
- //Draw the nums of rows
- if (display_border_ && display_rows_) {
- QString row_string("A");
- for (int i = 1 ; i <= rows_count_ ; ++ i) {
- QRectF lettered_rectangle = QRectF(
- diagram_rect_.topLeft().x(),
- diagram_rect_.topLeft().y()
- + (
- columns_header_height_
- + ((i - 1)* rows_height_)
- ),
- rows_header_width_,
- rows_height_
- );
- painter -> drawRect(lettered_rectangle);
- painter -> drawText(lettered_rectangle,
- Qt::AlignVCenter
- | Qt::AlignCenter,
- row_string);
- row_string = incrementLetters(row_string);
- }
- }
+ //Draw the nums of rows
+ if (display_border_ && display_rows_) {
+ QString row_string("A");
+ for (int i = 1 ; i <= rows_count_ ; ++ i) {
+ QRectF lettered_rectangle = QRectF(
+ diagram_rect_.topLeft().x(),
+ diagram_rect_.topLeft().y()
+ + (
+ columns_header_height_
+ + ((i - 1)* rows_height_)
+ ),
+ rows_header_width_,
+ rows_height_
+ );
+ painter -> drawRect(lettered_rectangle);
+ painter -> drawText(lettered_rectangle,
+ Qt::AlignVCenter
+ | Qt::AlignCenter,
+ row_string);
+ row_string = incrementLetters(row_string);
+ }
+ }
- // render the titleblock, using the TitleBlockTemplate object
- if (display_titleblock_) {
- QRectF tbt_rect = titleBlockRectForQPainter();
- if (m_edge == Qt::BottomEdge)
- {
- painter -> translate(tbt_rect.topLeft());
- m_titleblock_template_renderer -> render(
- painter,
- tbt_rect.width());
- painter -> translate(-tbt_rect.topLeft());
- }
- else
- {
- painter->translate(tbt_rect.topLeft());
- painter->rotate(-90);
- m_titleblock_template_renderer -> render(
- painter,
- tbt_rect.width());
- painter->rotate(90);
- painter -> translate(-tbt_rect.topLeft());
- }
- }
+ // render the titleblock, using the TitleBlockTemplate object
+ if (display_titleblock_) {
+ QRectF tbt_rect = titleBlockRectForQPainter();
+ if (m_edge == Qt::BottomEdge)
+ {
+ painter -> translate(tbt_rect.topLeft());
+ m_titleblock_template_renderer -> render(
+ painter,
+ tbt_rect.width());
+ painter -> translate(-tbt_rect.topLeft());
+ }
+ else
+ {
+ painter->translate(tbt_rect.topLeft());
+ painter->rotate(-90);
+ m_titleblock_template_renderer -> render(
+ painter,
+ tbt_rect.width());
+ painter->rotate(90);
+ painter -> translate(-tbt_rect.topLeft());
+ }
+ }
- painter -> restore();
+ painter -> restore();
}
/**
- @brief BorderTitleBlock::drawDxf
- @param file_path
- @param color
+ @brief BorderTitleBlock::drawDxf
+ @param file_path
+ @param color
*/
void BorderTitleBlock::drawDxf(
- QString &file_path,
- int color)
+ QString &file_path,
+ int color)
{
- // Transform to DXF scale.
- columns_header_height_ *= Createdxf::yScale;
- rows_height_ *= Createdxf::yScale;
- rows_header_width_ *= Createdxf::xScale;
- columns_width_ *= Createdxf::xScale;
+ // Transform to DXF scale.
+ columns_header_height_ *= Createdxf::yScale;
+ rows_height_ *= Createdxf::yScale;
+ rows_header_width_ *= Createdxf::xScale;
+ columns_width_ *= Createdxf::xScale;
- // 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
- if (display_border_ &&
- (display_columns_ ||
- display_rows_)
- ) {
- Createdxf::drawRectangle(
- file_path,
- double(diagram_rect_.topLeft().x()) * Createdxf::xScale,
- Createdxf::sheetHeight
- - double(diagram_rect_.topLeft().y())
- * Createdxf::yScale
- - columns_header_height_,
- rows_header_width_,
- columns_header_height_,
- color
- );
- }
+ // 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
+ if (display_border_ &&
+ (display_columns_ ||
+ display_rows_)
+ ) {
+ Createdxf::drawRectangle(
+ file_path,
+ double(diagram_rect_.topLeft().x()) * Createdxf::xScale,
+ Createdxf::sheetHeight
+ - double(diagram_rect_.topLeft().y())
+ * Createdxf::yScale
+ - columns_header_height_,
+ rows_header_width_,
+ columns_header_height_,
+ color
+ );
+ }
- QSettings settings;
+ QSettings settings;
- // draw the numbering of the columns
- // dessine la numerotation des colonnes
- if (display_border_ &&
- display_columns_) {
- int offset = settings.value("border-columns_0", true).toBool() ? -1 : 0;
- for (int i = 1 ; i <= columns_count_ ; ++ i) {
- double xCoord = diagram_rect_.topLeft().x() * Createdxf::xScale +
- (rows_header_width_ + ((i - 1) *
- columns_width_));
- double yCoord = Createdxf::sheetHeight
- - diagram_rect_.topLeft().y()*Createdxf::yScale
- - columns_header_height_;
- double recWidth = columns_width_;
- double recHeight = columns_header_height_;
- Createdxf::drawRectangle(file_path, xCoord, yCoord,
- recWidth, recHeight, color);
+ // draw the numbering of the columns
+ // dessine la numerotation des colonnes
+ if (display_border_ &&
+ display_columns_) {
+ int offset = settings.value("border-columns_0", true).toBool() ? -1 : 0;
+ for (int i = 1 ; i <= columns_count_ ; ++ i) {
+ double xCoord = diagram_rect_.topLeft().x() * Createdxf::xScale +
+ (rows_header_width_ + ((i - 1) *
+ columns_width_));
+ double yCoord = Createdxf::sheetHeight
+ - diagram_rect_.topLeft().y()*Createdxf::yScale
+ - columns_header_height_;
+ double recWidth = columns_width_;
+ double recHeight = columns_header_height_;
+ Createdxf::drawRectangle(file_path, xCoord, yCoord,
+ recWidth, recHeight, color);
- Createdxf::drawTextAligned(file_path,
- QString::number(i + offset),
- xCoord+recWidth/4,
- yCoord + recHeight*0.5,
- recHeight*0.7,
- 0,
- 0,
- 1,
- 2,
- xCoord+recWidth/2,
- 1,
- color);
- }
- }
+ Createdxf::drawTextAligned(file_path,
+ QString::number(i + offset),
+ xCoord+recWidth/4,
+ yCoord + recHeight*0.5,
+ recHeight*0.7,
+ 0,
+ 0,
+ 1,
+ 2,
+ xCoord+recWidth/2,
+ 1,
+ color);
+ }
+ }
- // draw line numbering
- // dessine la numerotation des lignes
- if (display_border_ && display_rows_) {
- QString row_string("A");
- for (int i = 1 ; i <= rows_count_ ; ++ i) {
- double xCoord = diagram_rect_.topLeft().x()
- * Createdxf::xScale;
- double yCoord = Createdxf::sheetHeight
- - diagram_rect_.topLeft().y()
- *Createdxf::yScale
- - (
- columns_header_height_
- + ((i - 1)
- * rows_height_) )
- - rows_height_;
- double recWidth = rows_header_width_;
- double recHeight = rows_height_;
- Createdxf::drawRectangle(file_path, xCoord, yCoord,
- recWidth, recHeight, color);
- Createdxf::drawTextAligned(file_path,
- row_string,
- xCoord+recWidth*0.1,
- yCoord + recHeight*0.4,
- recWidth*0.7,
- 0,
- 0,
- 1,
- 2,
- xCoord+recWidth/2,
- 1,
- color);
- row_string = incrementLetters(row_string);
- }
- }
+ // draw line numbering
+ // dessine la numerotation des lignes
+ if (display_border_ && display_rows_) {
+ QString row_string("A");
+ for (int i = 1 ; i <= rows_count_ ; ++ i) {
+ double xCoord = diagram_rect_.topLeft().x()
+ * Createdxf::xScale;
+ double yCoord = Createdxf::sheetHeight
+ - diagram_rect_.topLeft().y()
+ *Createdxf::yScale
+ - (
+ columns_header_height_
+ + ((i - 1)
+ * rows_height_) )
+ - rows_height_;
+ double recWidth = rows_header_width_;
+ double recHeight = rows_height_;
+ Createdxf::drawRectangle(file_path, xCoord, yCoord,
+ recWidth, recHeight, color);
+ Createdxf::drawTextAligned(file_path,
+ row_string,
+ xCoord+recWidth*0.1,
+ yCoord + recHeight*0.4,
+ recWidth*0.7,
+ 0,
+ 0,
+ 1,
+ 2,
+ xCoord+recWidth/2,
+ 1,
+ color);
+ row_string = incrementLetters(row_string);
+ }
+ }
- // render the titleblock, using the TitleBlockTemplate object
- if (display_titleblock_) {
- //qp -> translate(titleblock_rect_.topLeft());
- QRectF rect = titleBlockRect();
- m_titleblock_template_renderer -> renderDxf(rect,
- rect.width(),
- file_path,
- color);
- //qp -> translate(-titleblock_rect_.topLeft());
- }
+ // render the titleblock, using the TitleBlockTemplate object
+ if (display_titleblock_) {
+ //qp -> translate(titleblock_rect_.topLeft());
+ QRectF rect = titleBlockRect();
+ m_titleblock_template_renderer -> renderDxf(rect,
+ rect.width(),
+ file_path,
+ color);
+ //qp -> translate(-titleblock_rect_.topLeft());
+ }
- // Transform back to QET scale
- columns_header_height_ /= Createdxf::yScale;
- rows_height_ /= Createdxf::yScale;
- rows_header_width_ /= Createdxf::xScale;
- columns_width_ /= Createdxf::xScale;
+ // Transform back to QET scale
+ columns_header_height_ /= Createdxf::yScale;
+ rows_height_ /= Createdxf::yScale;
+ rows_header_width_ /= Createdxf::xScale;
+ columns_width_ /= Createdxf::xScale;
}
/**
- @brief BorderTitleBlock::setColumnsCount
- Allows you to change the number of columns.
- If this number of columns is less than the minimum required,
- it is this minimum which is used.
+ @brief BorderTitleBlock::setColumnsCount
+ Allows you to change the number of columns.
+ If this number of columns is less than the minimum required,
+ it is this minimum which is used.
- \~French Permet de changer le nombre de colonnes.
- Si ce nombre de colonnes est inferieur au minimum requis,
- c'est ce minimum qui est utilise.
- \~ @param nb_c : new number of columns
- \~French nouveau nombre de colonnes
- \~ @see minNbColumns()
+ \~French Permet de changer le nombre de colonnes.
+ Si ce nombre de colonnes est inferieur au minimum requis,
+ c'est ce minimum qui est utilise.
+ \~ @param nb_c : new number of columns
+ \~French nouveau nombre de colonnes
+ \~ @see minNbColumns()
*/
void BorderTitleBlock::setColumnsCount(int nb_c) {
- if (nb_c == columnsCount()) return;
- columns_count_ = qMax(MIN_COLUMN_COUNT , nb_c);
- updateRectangles();
+ if (nb_c == columnsCount()) return;
+ columns_count_ = qMax(MIN_COLUMN_COUNT , nb_c);
+ updateRectangles();
}
/**
- @brief BorderTitleBlock::setColumnsWidth
- Change the width of the columns.
- If the width indicated is less than the minimum required,
- it is this minimum which is used.
+ @brief BorderTitleBlock::setColumnsWidth
+ Change the width of the columns.
+ If the width indicated is less than the minimum required,
+ it is this minimum which is used.
- \~French Change la largeur des colonnes.
- Si la largeur indiquee est inferieure au minimum requis,
- c'est ce minimum qui est utilise.
- \~ @param new_cw : new column width
- \~French nouvelle largeur des colonnes
- \~ @see minColumnsWidth()
+ \~French Change la largeur des colonnes.
+ Si la largeur indiquee est inferieure au minimum requis,
+ c'est ce minimum qui est utilise.
+ \~ @param new_cw : new column width
+ \~French nouvelle largeur des colonnes
+ \~ @see minColumnsWidth()
*/
void BorderTitleBlock::setColumnsWidth(const qreal &new_cw) {
- if (new_cw == columnsWidth()) return;
- columns_width_ = qMax(MIN_COLUMN_WIDTH , new_cw);
- updateRectangles();
+ if (new_cw == columnsWidth()) return;
+ columns_width_ = qMax(MIN_COLUMN_WIDTH , new_cw);
+ updateRectangles();
}
/**
- @brief BorderTitleBlock::setColumnsHeaderHeight
- Change the height of the headers containing the column numbers.
- This must remain between 5 and 50 px.
+ @brief BorderTitleBlock::setColumnsHeaderHeight
+ Change the height of the headers containing the column numbers.
+ This must remain between 5 and 50 px.
- \~French Change la hauteur des en-tetes contenant les numeros de colonnes.
- Celle-ci doit rester comprise entre 5 et 50 px.
- \~ @param new_chh : new height of column headers
- \~French nouvelle hauteur des en-tetes de colonnes
+ \~French Change la hauteur des en-tetes contenant les numeros de colonnes.
+ Celle-ci doit rester comprise entre 5 et 50 px.
+ \~ @param new_chh : new height of column headers
+ \~French nouvelle hauteur des en-tetes de colonnes
*/
void BorderTitleBlock::setColumnsHeaderHeight(const qreal &new_chh) {
- columns_header_height_ = qBound(qreal(5.0), new_chh, qreal(50.0));
- updateRectangles();
+ columns_header_height_ = qBound(qreal(5.0), new_chh, qreal(50.0));
+ updateRectangles();
}
/**
- @brief BorderTitleBlock::setRowsCount
- Allows you to change the number of lines.
- If this number of lines is lower than the minimum required,
- this function does nothing
+ @brief BorderTitleBlock::setRowsCount
+ Allows you to change the number of lines.
+ If this number of lines is lower than the minimum required,
+ this function does nothing
- \~French Permet de changer le nombre de lignes.
- Si ce nombre de lignes est inferieur au minimum requis,
- cette fonction ne fait rien
- \~ @param nb_r : new number of lines
- \~French nouveau nombre de lignes
- \~ @see minNbRows()
+ \~French Permet de changer le nombre de lignes.
+ Si ce nombre de lignes est inferieur au minimum requis,
+ cette fonction ne fait rien
+ \~ @param nb_r : new number of lines
+ \~French nouveau nombre de lignes
+ \~ @see minNbRows()
*/
void BorderTitleBlock::setRowsCount(int nb_r) {
- if (nb_r == rowsCount()) return;
- rows_count_ = qMax(MIN_ROW_COUNT, nb_r);
- updateRectangles();
+ if (nb_r == rowsCount()) return;
+ rows_count_ = qMax(MIN_ROW_COUNT, nb_r);
+ updateRectangles();
}
/**
- @brief BorderTitleBlock::setRowsHeight
- Change the height of the lines.
- If the indicated height is lower than the minimum required,
- it is this minimum which is used.
+ @brief BorderTitleBlock::setRowsHeight
+ Change the height of the lines.
+ If the indicated height is lower than the minimum required,
+ it is this minimum which is used.
- \~French Change la hauteur des lignes.
- Si la hauteur indiquee est inferieure au minimum requis,
- c'est ce minimum qui est utilise.
- \~ @param new_rh : new row height
- \~French nouvelle hauteur des lignes
- \~ @see minRowsHeight()
+ \~French Change la hauteur des lignes.
+ Si la hauteur indiquee est inferieure au minimum requis,
+ c'est ce minimum qui est utilise.
+ \~ @param new_rh : new row height
+ \~French nouvelle hauteur des lignes
+ \~ @see minRowsHeight()
*/
void BorderTitleBlock::setRowsHeight(const qreal &new_rh) {
- if (new_rh == rowsHeight()) return;
- rows_height_ = qMax(MIN_ROW_HEIGHT, new_rh);
- updateRectangles();
+ if (new_rh == rowsHeight()) return;
+ rows_height_ = qMax(MIN_ROW_HEIGHT, new_rh);
+ updateRectangles();
}
/**
- @brief BorderTitleBlock::setRowsHeaderWidth
- Change the width of the headers containing the line numbers.
- This must remain between 5 and 50 px.
+ @brief BorderTitleBlock::setRowsHeaderWidth
+ Change the width of the headers containing the line numbers.
+ This must remain between 5 and 50 px.
- \~French Change la largeur des en-tetes contenant les numeros de lignes.
- Celle-ci doit rester comprise entre 5 et 50 px.
- \~ @param new_rhw : new width of line headers
- \~French nouvelle largeur des en-tetes des lignes
+ \~French Change la largeur des en-tetes contenant les numeros de lignes.
+ Celle-ci doit rester comprise entre 5 et 50 px.
+ \~ @param new_rhw : new width of line headers
+ \~French nouvelle largeur des en-tetes des lignes
*/
void BorderTitleBlock::setRowsHeaderWidth(const qreal &new_rhw) {
- rows_header_width_ = qBound(qreal(5.0), new_rhw, qreal(50.0));
- updateRectangles();
+ rows_header_width_ = qBound(qreal(5.0), new_rhw, qreal(50.0));
+ updateRectangles();
}
/**
- @brief BorderTitleBlock::setDiagramHeight
- This method tries to get as close as possible to the given height
- as a parameter by modifying the number of rows in progress.
+ @brief BorderTitleBlock::setDiagramHeight
+ This method tries to get as close as possible to the given height
+ as a parameter by modifying the number of rows in progress.
- \~French Cette methode essaye de se rapprocher le plus possible de la
- hauteur donnee en parametre en modifiant le nombre de lignes en cours.
- \~ @param height :
+ \~French Cette methode essaye de se rapprocher le plus possible de la
+ hauteur donnee en parametre en modifiant le nombre de lignes en cours.
+ \~ @param height :
*/
void BorderTitleBlock::setDiagramHeight(const qreal &height) {
- // size of rows to use = rows_height
- // taille des lignes a utiliser = rows_height
- setRowsCount(qRound(ceil(height / rows_height_)));
+ // size of rows to use = rows_height
+ // taille des lignes a utiliser = rows_height
+ setRowsCount(qRound(ceil(height / rows_height_)));
}
/**
- @brief BorderTitleBlock::convertPosition
- Convert a Point in cartesian coordinate (x : 12.5, 56.9)
- to a point in grid coordinate (ex : B2)
- @param pos : position to convert
- @return the converted point in grid coordinate.
+ @brief BorderTitleBlock::convertPosition
+ Convert a Point in cartesian coordinate (x : 12.5, 56.9)
+ to a point in grid coordinate (ex : B2)
+ @param pos : position to convert
+ @return the converted point in grid coordinate.
*/
DiagramPosition BorderTitleBlock::convertPosition(const QPointF &pos)
{
- if(!insideBorderRect().contains(pos))
- return (DiagramPosition("", 0));
+ if(!insideBorderRect().contains(pos))
+ return (DiagramPosition("", 0));
- QPointF relative_pos = pos - insideBorderRect().topLeft();
- int row_number = int(ceil(relative_pos.x() / columnsWidth()));
- int column_number = int(ceil(relative_pos.y() / rowsHeight()));
+ QPointF relative_pos = pos - insideBorderRect().topLeft();
+ int row_number = int(ceil(relative_pos.x() / columnsWidth()));
+ int column_number = int(ceil(relative_pos.y() / rowsHeight()));
- QString letter = "A";
- for (int i = 1 ; i < column_number ; ++ i)
- letter = incrementLetters(letter);
+ QString letter = "A";
+ for (int i = 1 ; i < column_number ; ++ i)
+ letter = incrementLetters(letter);
- return(DiagramPosition(letter, row_number));
+ return(DiagramPosition(letter, row_number));
}
/**
- @brief BorderTitleBlock::setAuthor
- @param author the new value of the "Author" field
+ @brief BorderTitleBlock::setAuthor
+ @param author the new value of the "Author" field
*/
void BorderTitleBlock::setAuthor(const QString &author) {
- btb_author_ = author;
+ btb_author_ = author;
}
/**
- @brief BorderTitleBlock::setDate
- @param date the new value of the "Date" field
+ @brief BorderTitleBlock::setDate
+ @param date the new value of the "Date" field
*/
void BorderTitleBlock::setDate(const QDate &date) {
- btb_date_ = date;
+ btb_date_ = date;
}
/**
- @brief BorderTitleBlock::setTitle
- @param title the new value of the "Title" field
+ @brief BorderTitleBlock::setTitle
+ @param title the new value of the "Title" field
*/
void BorderTitleBlock::setTitle(const QString &title)
{
- if (btb_title_ != title)
- {
- btb_title_ = title;
- emit(diagramTitleChanged(title));
- }
+ if (btb_title_ != title)
+ {
+ btb_title_ = title;
+ emit(diagramTitleChanged(title));
+ }
}
/**
- @brief BorderTitleBlock::setFolio
- @param folio the new value of the "Folio" field
+ @brief BorderTitleBlock::setFolio
+ @param folio the new value of the "Folio" field
*/
void BorderTitleBlock::setFolio(const QString &folio)
{
- btb_folio_ = folio;
- emit (titleBlockFolioChanged(folio));
+ btb_folio_ = folio;
+ emit (titleBlockFolioChanged(folio));
}
/**
- @brief BorderTitleBlock::updateDiagramContextForTitleBlock
- Update the informations given to the titleblock template
- by regenerating a DiagramContext object.
- @param initial_context :
- Base diagram context that will be overridden by diagram-wide values
+ @brief BorderTitleBlock::updateDiagramContextForTitleBlock
+ Update the informations given to the titleblock template
+ by regenerating a DiagramContext object.
+ @param initial_context :
+ Base diagram context that will be overridden by diagram-wide values
*/
void BorderTitleBlock::updateDiagramContextForTitleBlock(
- const DiagramContext &initial_context) {
- // Our final DiagramContext is the initial one (which is supposed to bring
- // project-wide properties), overridden by the "additional fields" one...
- DiagramContext context = initial_context;
- foreach (QString key, additional_fields_.keys()) {
- context.addValue(key, additional_fields_[key]);
- }
+ const DiagramContext &initial_context) {
+ // Our final DiagramContext is the initial one (which is supposed to bring
+ // project-wide properties), overridden by the "additional fields" one...
+ DiagramContext context = initial_context;
+ foreach (QString key, additional_fields_.keys()) {
+ context.addValue(key, additional_fields_[key]);
+ }
- // ... overridden by the historical and/or dynamically generated fields
- QLocale var;
- var.dateFormat(QLocale::ShortFormat);
- context.addValue("author", btb_author_);
- context.addValue(
- "date",
- QLocale::system().toString(btb_date_, QLocale::ShortFormat));
- context.addValue("title", btb_title_);
- context.addValue("filename", btb_filename_);
- context.addValue("plant", btb_plant_);
- context.addValue("locmach", btb_locmach_);
- context.addValue("indexrev", btb_indexrev_);
- context.addValue("version", btb_version_);
- context.addValue("folio", btb_final_folio_);
- context.addValue("folio-id", folio_index_);
- context.addValue("folio-total", folio_total_);
- context.addValue("auto_page_num", btb_auto_page_num_);
- context.addValue("previous-folio-num", m_previous_folio_num);
- context.addValue("next-folio-num", m_next_folio_num);
+ // ... overridden by the historical and/or dynamically generated fields
+ QLocale var;
+ var.dateFormat(QLocale::ShortFormat);
+ context.addValue("author", btb_author_);
+ context.addValue(
+ "date",
+ QLocale::system().toString(btb_date_, QLocale::ShortFormat));
+ context.addValue("title", btb_title_);
+ context.addValue("filename", btb_filename_);
+ context.addValue("plant", btb_plant_);
+ context.addValue("locmach", btb_locmach_);
+ context.addValue("indexrev", btb_indexrev_);
+ context.addValue("version", btb_version_);
+ context.addValue("folio", btb_final_folio_);
+ context.addValue("folio-id", folio_index_);
+ context.addValue("folio-total", folio_total_);
+ context.addValue("auto_page_num", btb_auto_page_num_);
+ context.addValue("previous-folio-num", m_previous_folio_num);
+ context.addValue("next-folio-num", m_next_folio_num);
- m_titleblock_template_renderer -> setContext(context);
+ m_titleblock_template_renderer -> setContext(context);
}
/**
- @brief BorderTitleBlock::incrementLetters
- increments string with Letters A to Z
- @param string
- @return string ++Letters
- eg:
- - A-> B
- - Z -> AA
+ @brief BorderTitleBlock::incrementLetters
+ increments string with Letters A to Z
+ @param string
+ @return string ++Letters
+ eg:
+ - A-> B
+ - Z -> AA
*/
QString BorderTitleBlock::incrementLetters(const QString &string) {
- if (string.isEmpty()) {
- return("A");
- } else {
- // separate previous digits from last digit
- // separe les digits precedents du dernier digit
- QString first_digits(string.left(string.count() - 1));
- QChar last_digit(string.at(string.count() - 1));
- if (last_digit != 'Z') {
- // increments the last digit
- // incremente le dernier digit
- last_digit = last_digit.toLatin1() + 1;
- return(first_digits + QString(last_digit));
- } else {
- return(incrementLetters(first_digits) + "A");
- }
- }
+ if (string.isEmpty()) {
+ return("A");
+ } else {
+ // separate previous digits from last digit
+ // separe les digits precedents du dernier digit
+ QString first_digits(string.left(string.count() - 1));
+ QChar last_digit(string.at(string.count() - 1));
+ if (last_digit != 'Z') {
+ // increments the last digit
+ // incremente le dernier digit
+ last_digit = last_digit.toLatin1() + 1;
+ return(first_digits + QString(last_digit));
+ } else {
+ return(incrementLetters(first_digits) + "A");
+ }
+ }
}
/**
- @brief BorderTitleBlock::setFolioData
+ @brief BorderTitleBlock::setFolioData
- \~ @param index : schema number (from 1 to total)
- \~French numero du schema (de 1 a total)
+ \~ @param index : schema number (from 1 to total)
+ \~French numero du schema (de 1 a total)
- \~ @param total : total number of diagrams in the project
- \~French nombre total de schemas dans le projet
+ \~ @param total : total number of diagrams in the project
+ \~French nombre total de schemas dans le projet
- \~ @param autonum :
+ \~ @param autonum :
- \~ @param project_properties : Project-wide properties,
- to be merged with diagram-wide ones.
+ \~ @param project_properties : Project-wide properties,
+ to be merged with diagram-wide ones.
*/
void BorderTitleBlock::setFolioData(
- int index,
- int total,
- const QString& autonum,
- const DiagramContext &project_properties) {
- if (index < 1 || total < 1 || index > total) return;
+ int index,
+ int total,
+ const QString& autonum,
+ const DiagramContext &project_properties) {
+ if (index < 1 || total < 1 || index > total) return;
- // memorize information
- // memorise les informations
- folio_index_ = index;
- folio_total_ = total;
+ // memorize information
+ // memorise les informations
+ folio_index_ = index;
+ folio_total_ = total;
- // regenerate the content of the folio field
- // regenere le contenu du champ folio
- btb_final_folio_ = btb_folio_;
+ // regenerate the content of the folio field
+ // regenere le contenu du champ folio
+ btb_final_folio_ = btb_folio_;
- if (btb_final_folio_.contains("%autonum")){
- btb_final_folio_.replace("%autonum", autonum);
- btb_folio_ = btb_final_folio_;
- }
- btb_final_folio_.replace("%id", QString::number(folio_index_));
- btb_final_folio_.replace("%total", QString::number(folio_total_));
+ if (btb_final_folio_.contains("%autonum")){
+ btb_final_folio_.replace("%autonum", autonum);
+ btb_folio_ = btb_final_folio_;
+ }
+ btb_final_folio_.replace("%id", QString::number(folio_index_));
+ btb_final_folio_.replace("%total", QString::number(folio_total_));
- updateDiagramContextForTitleBlock(project_properties);
+ updateDiagramContextForTitleBlock(project_properties);
}
/**
- @brief BorderTitleBlock::setPlant
- @param plant the new value of the "plant" field
+ @brief BorderTitleBlock::setPlant
+ @param plant the new value of the "plant" field
*/
void BorderTitleBlock::setPlant(const QString &plant) {
- btb_plant_ = plant;
+ btb_plant_ = plant;
}
/**
- @brief BorderTitleBlock::setLocMach
- @param locmach the new value of the "locmach" field
+ @brief BorderTitleBlock::setLocMach
+ @param locmach the new value of the "locmach" field
*/
void BorderTitleBlock::setLocMach(const QString &locmach) {
- btb_locmach_ = locmach;
+ btb_locmach_ = locmach;
}
/**
- @brief BorderTitleBlock::setIndicerev
- @param indexrev the new value of the "indexrev" field
+ @brief BorderTitleBlock::setIndicerev
+ @param indexrev the new value of the "indexrev" field
*/
void BorderTitleBlock::setIndicerev(const QString &indexrev) {
- btb_indexrev_ = indexrev;
+ btb_indexrev_ = indexrev;
}
/**
- @brief BorderTitleBlock::setFileName
- @param filename the new value of the "filename" field
+ @brief BorderTitleBlock::setFileName
+ @param filename the new value of the "filename" field
*/
void BorderTitleBlock::setFileName(const QString &filename) {
- btb_filename_ = filename;
+ btb_filename_ = filename;
}
/**
- @brief BorderTitleBlock::setVersion
- @param version the new value of the "version" field
+ @brief BorderTitleBlock::setVersion
+ @param version the new value of the "version" field
*/
void BorderTitleBlock::setVersion(const QString &version) {
- btb_version_ = version;
+ btb_version_ = version;
}
/**
- @brief BorderTitleBlock::setAutoPageNum
- @param auto_page_num the new value of the "auto_page_num" field
+ @brief BorderTitleBlock::setAutoPageNum
+ @param auto_page_num the new value of the "auto_page_num" field
*/
void BorderTitleBlock::setAutoPageNum(const QString &auto_page_num) {
- btb_auto_page_num_ = auto_page_num;
+ btb_auto_page_num_ = auto_page_num;
}
/**
- @brief BorderTitleBlock::setPreviousFolioNum
- @param previous the new value of the "previous-folio-num" field
+ @brief BorderTitleBlock::setPreviousFolioNum
+ @param previous the new value of the "previous-folio-num" field
*/
void BorderTitleBlock::setPreviousFolioNum(const QString &previous)
{
- m_previous_folio_num = previous;
- DiagramContext context = m_titleblock_template_renderer->context();
- context.addValue("previous-folio-num", m_previous_folio_num);
- m_titleblock_template_renderer->setContext(context);
+ m_previous_folio_num = previous;
+ DiagramContext context = m_titleblock_template_renderer->context();
+ context.addValue("previous-folio-num", m_previous_folio_num);
+ m_titleblock_template_renderer->setContext(context);
}
/**
- @brief BorderTitleBlock::setNextFolioNum
- @param next the new value of the "next-folio-num" field
+ @brief BorderTitleBlock::setNextFolioNum
+ @param next the new value of the "next-folio-num" field
*/
void BorderTitleBlock::setNextFolioNum(const QString &next)
{
- m_next_folio_num = next;
- DiagramContext context = m_titleblock_template_renderer->context();
- context.addValue("next-folio-num", m_next_folio_num);
- m_titleblock_template_renderer->setContext(context);
+ m_next_folio_num = next;
+ DiagramContext context = m_titleblock_template_renderer->context();
+ context.addValue("next-folio-num", m_next_folio_num);
+ m_titleblock_template_renderer->setContext(context);
}
diff --git a/sources/bordertitleblock.h b/sources/bordertitleblock.h
index 39a7f93a6..779b2f005 100644
--- a/sources/bordertitleblock.h
+++ b/sources/bordertitleblock.h
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#ifndef BORDERTITLEBLOCK_H
#define BORDERTITLEBLOCK_H
@@ -29,266 +29,266 @@ class DiagramPosition;
class TitleBlockTemplate;
class TitleBlockTemplateRenderer;
/**
- @brief The BorderTitleBlock class
- This class represents the border and the titleblock which frame a
- particular electric diagram.
+ @brief The BorderTitleBlock class
+ This class represents the border and the titleblock which frame a
+ particular electric diagram.
*/
class BorderTitleBlock : public QObject
{
- Q_OBJECT
-
- public:
- BorderTitleBlock(QObject * = nullptr);
- ~BorderTitleBlock() override;
-
- private:
- BorderTitleBlock(const BorderTitleBlock &);
-
- //METHODS
- public:
- void draw(QPainter *painter);
- void drawDxf(QString &, int);
-
- //METHODS TO GET DIMENSION
- //COLUMNS
- /// @return the number of columns
- int columnsCount() const { return(columns_count_); }
- /// @return the columns width, in pixels
- qreal columnsWidth() const { return(columns_width_); }
- /// @return the total width of all columns, headers excluded
- qreal columnsTotalWidth() const {
- return(columns_count_ * columns_width_); }
- /// @return the column headers height, in pixels
- qreal columnsHeaderHeight() const {
- return(columns_header_height_); }
-
- //ROWS
- /// @return the number of rows
- int rowsCount() const { return(rows_count_); }
- /// @return the rows height, in pixels
- qreal rowsHeight() const { return(rows_height_); }
- /// @return the total height of all rows, headers excluded
- qreal rowsTotalHeight() const {
- return(rows_count_ * rows_height_); }
- /// @return la rows header width, in pixels
- qreal rowsHeaderWidth() const { return(rows_header_width_); }
-
- // border - title block = diagram
- /**
- @brief diagramWidth
- @return the diagram width,
- i.e. the width of the border without title block
- */
- qreal diagramWidth() const
+ Q_OBJECT
+
+ public:
+ BorderTitleBlock(QObject * = nullptr);
+ ~BorderTitleBlock() override;
+
+ private:
+ BorderTitleBlock(const BorderTitleBlock &);
+
+ //METHODS
+ public:
+ void draw(QPainter *painter);
+ void drawDxf(QString &, int);
+
+ //METHODS TO GET DIMENSION
+ //COLUMNS
+ /// @return the number of columns
+ int columnsCount() const { return(columns_count_); }
+ /// @return the columns width, in pixels
+ qreal columnsWidth() const { return(columns_width_); }
+ /// @return the total width of all columns, headers excluded
+ qreal columnsTotalWidth() const {
+ return(columns_count_ * columns_width_); }
+ /// @return the column headers height, in pixels
+ qreal columnsHeaderHeight() const {
+ return(columns_header_height_); }
+
+ //ROWS
+ /// @return the number of rows
+ int rowsCount() const { return(rows_count_); }
+ /// @return the rows height, in pixels
+ qreal rowsHeight() const { return(rows_height_); }
+ /// @return the total height of all rows, headers excluded
+ qreal rowsTotalHeight() const {
+ return(rows_count_ * rows_height_); }
+ /// @return la rows header width, in pixels
+ qreal rowsHeaderWidth() const { return(rows_header_width_); }
+
+ // border - title block = diagram
+ /**
+ @brief diagramWidth
+ @return the diagram width,
+ i.e. the width of the border without title block
+ */
+ qreal diagramWidth() const
{
- return(columnsTotalWidth() + rowsHeaderWidth()); }
- /**
- @brief diagramHeight
- @return the diagram height,
- i.e. the height of the border without title block
- */
- qreal diagramHeight() const
+ return(columnsTotalWidth() + rowsHeaderWidth()); }
+ /**
+ @brief diagramHeight
+ @return the diagram height,
+ i.e. the height of the border without title block
+ */
+ qreal diagramHeight() const
{
- return(rowsTotalHeight() + columnsHeaderHeight()); }
+ return(rowsTotalHeight() + columnsHeaderHeight()); }
- QRectF titleBlockRect () const;
+ QRectF titleBlockRect () const;
- DiagramContext titleblockInformation() const;
- private:
- QRectF titleBlockRectForQPainter () const;
+ DiagramContext titleblockInformation() const;
+ private:
+ QRectF titleBlockRectForQPainter () const;
- public:
- QRectF borderAndTitleBlockRect () const;
- QRectF columnsRect () const;
- QRectF rowsRect () const;
- QRectF outsideBorderRect() const;
- QRectF insideBorderRect() const;
-
- // methods to get title block basic data
- /// @return the value of the title block "Author" field
- QString author() const { return(btb_author_); }
- /// @return the value of the title block "Date" field
- QDate date() const { return(btb_date_); }
- /// @return the value of the title block "Title" field
- QString title() const { return(btb_title_); }
- /// @return the value of the title block "Folio" field
- QString folio() const { return(btb_folio_); }
- /// @return the value of the title block "Folio" field as displayed
- QString finalfolio() const { return(btb_final_folio_); }
- /// @return the value of the title block "Plant" field
- QString plant() const { return(btb_plant_); }
- /// @return the value of the title block "Locmach" field
- QString locmach() const { return(btb_locmach_); }
- /// @return the value of the revision index block "Folio" field
- QString indexrev() const { return(btb_indexrev_); }
- /// @return the value of the title block "File" field
- QString fileName() const { return(btb_filename_); }
- /// @return the value of the title block Additional Fields
- QString version() const { return(btb_version_); }
- /// @return the value of the title block Additional Fields
- DiagramContext additionalFields() const {
- return (additional_fields_); }
- /// @return the value of the title block
- QString autoPageNum() const { return(btb_auto_page_num_); }
- /// @return the value of the total number of folios
- int folioTotal() const { return(folio_total_);}
-
- // methods to get display options
- /// @return true si le cartouche est affiche, false sinon
- bool titleBlockIsDisplayed() const {
- return(display_titleblock_); }
- /// @return true si les entetes des colonnes sont affiches,
- /// false sinon
- bool columnsAreDisplayed() const { return(display_columns_); }
- /// @return true si les entetes des lignes sont affiches,
- /// false sinon
- bool rowsAreDisplayed() const { return(display_rows_); }
- /// @return true si la bordure est affichee, false sinon
- bool borderIsDisplayed() const { return(display_border_); }
-
- // methods to set dimensions
- void setColumnsCount(int);
- void setRowsCount(int);
- void setColumnsWidth(const qreal &);
- void setRowsHeight(const qreal &);
- void setColumnsHeaderHeight(const qreal &);
- void setRowsHeaderWidth(const qreal &);
- void setDiagramHeight(const qreal &);
-
- DiagramPosition convertPosition(const QPointF &);
-
- // methods to set title block basic data
- void setAuthor(const QString &author);
- void setDate(const QDate &date);
- void setTitle(const QString &title);
- void setFolio(const QString &folio);
- void setFolioData(int, int, const QString& = nullptr,
- const DiagramContext & = DiagramContext());
- void setPlant(const QString &plant);
- void setLocMach(const QString &locmach);
- void setIndicerev(const QString &indexrev);
- void setFileName(const QString &filename);
- void setVersion(const QString &version);
- void setAutoPageNum(const QString &auto_page_num);
- void setPreviousFolioNum(const QString &previous);
- void setNextFolioNum(const QString &next);
-
- void titleBlockToXml(QDomElement &);
- void titleBlockFromXml(const QDomElement &);
- void borderToXml(QDomElement &);
- void borderFromXml(const QDomElement &);
-
- TitleBlockProperties exportTitleBlock();
- void importTitleBlock(const TitleBlockProperties &);
- BorderProperties exportBorder();
- void importBorder(const BorderProperties &);
-
- const TitleBlockTemplate *titleBlockTemplate();
- void setTitleBlockTemplate(const TitleBlockTemplate *);
- QString titleBlockTemplateName() const;
-
- public slots:
- void titleBlockTemplateChanged(const QString &);
- void titleBlockTemplateRemoved(
- const QString &,
- const TitleBlockTemplate * = nullptr);
-
- // methods to set display options
- void displayTitleBlock(bool);
- void displayColumns(bool);
- void displayRows(bool);
- void displayBorder(bool);
- void slot_setAutoPageNum (QString);
-
- private:
- void updateRectangles();
- void updateDiagramContextForTitleBlock(
- const DiagramContext & = DiagramContext());
- QString incrementLetters(const QString &);
-
- signals:
- /**
- @brief borderChanged
- Signal emitted after the border has changed
- @param old_border Former border
- @param new_border New border
- */
- void borderChanged(QRectF old_border, QRectF new_border);
- /**
- @brief displayChanged
- Signal emitted after display options have changed
- */
- void displayChanged();
- /**
- @brief diagramTitleChanged
- Signal emitted after the title has changed
- */
- void diagramTitleChanged(const QString &);
- /**
- @brief titleBlockFolioChanged
- Signal emitted after Folio has changed
- */
- void titleBlockFolioChanged(const QString &);
- /**
- @brief needFolioData
- Signal emitted when the title block
- requires its data to be updated
- in order to generate the folio field.
- */
- void needFolioData();
- /**
- @brief needTitleBlockTemplate
- Signal emitted when this object needs to
- set a specific title block template.
- This object cannot handle the job
- since it does not know of its parent project.
- */
- void needTitleBlockTemplate(const QString &);
-
- // attributes
- private:
- // titleblock basic data
- QString btb_author_; ///< titleblock author
- QDate btb_date_; ///< titleblock date
- QString btb_title_; ///< titleblock title
- QString btb_folio_; ///< titleblock folio
- QString btb_plant_; ///< titleblock plant
- QString btb_locmach_; ///< titleblock locmach
- QString btb_indexrev_; ///< titleblock index rev
- QString btb_final_folio_; ///< titleblock final folio
- QString btb_auto_page_num_; ///< titleblock auto page num
- int folio_index_; ///< titleblock index
- int folio_total_; ///< titleblock total
- QString btb_filename_; ///< titleblock filename
- QString btb_version_; ///< titleblock version
- /// titleblock additional fields
- DiagramContext additional_fields_;
- Qt::Edge m_edge; ///< titleblock edge
- QString m_next_folio_num; ///< titleblock next folio num
- QString m_previous_folio_num; ///< titleblock previous folio num
-
- // border dimensions (rows and columns)
- // columns: number and dimensions
- int columns_count_; ///< columns count
- qreal columns_width_; ///< columns width
- qreal columns_header_height_; ///< columns header height
-
- // rows: number and dimensions
- int rows_count_; ///< rows count
- qreal rows_height_; ///< rows height
- qreal rows_header_width_; ///< rows header width
-
- // title block dimensions
- qreal titleblock_height_;
-
- // rectangles used for drawing operations
- QRectF diagram_rect_;
-
- // display options
- bool display_titleblock_;
- bool display_columns_;
- bool display_rows_;
- bool display_border_;
- TitleBlockTemplateRenderer *m_titleblock_template_renderer;
+ public:
+ QRectF borderAndTitleBlockRect () const;
+ QRectF columnsRect () const;
+ QRectF rowsRect () const;
+ QRectF outsideBorderRect() const;
+ QRectF insideBorderRect() const;
+
+ // methods to get title block basic data
+ /// @return the value of the title block "Author" field
+ QString author() const { return(btb_author_); }
+ /// @return the value of the title block "Date" field
+ QDate date() const { return(btb_date_); }
+ /// @return the value of the title block "Title" field
+ QString title() const { return(btb_title_); }
+ /// @return the value of the title block "Folio" field
+ QString folio() const { return(btb_folio_); }
+ /// @return the value of the title block "Folio" field as displayed
+ QString finalfolio() const { return(btb_final_folio_); }
+ /// @return the value of the title block "Plant" field
+ QString plant() const { return(btb_plant_); }
+ /// @return the value of the title block "Locmach" field
+ QString locmach() const { return(btb_locmach_); }
+ /// @return the value of the revision index block "Folio" field
+ QString indexrev() const { return(btb_indexrev_); }
+ /// @return the value of the title block "File" field
+ QString fileName() const { return(btb_filename_); }
+ /// @return the value of the title block Additional Fields
+ QString version() const { return(btb_version_); }
+ /// @return the value of the title block Additional Fields
+ DiagramContext additionalFields() const {
+ return (additional_fields_); }
+ /// @return the value of the title block
+ QString autoPageNum() const { return(btb_auto_page_num_); }
+ /// @return the value of the total number of folios
+ int folioTotal() const { return(folio_total_);}
+
+ // methods to get display options
+ /// @return true si le cartouche est affiche, false sinon
+ bool titleBlockIsDisplayed() const {
+ return(display_titleblock_); }
+ /// @return true si les entetes des colonnes sont affiches,
+ /// false sinon
+ bool columnsAreDisplayed() const { return(display_columns_); }
+ /// @return true si les entetes des lignes sont affiches,
+ /// false sinon
+ bool rowsAreDisplayed() const { return(display_rows_); }
+ /// @return true si la bordure est affichee, false sinon
+ bool borderIsDisplayed() const { return(display_border_); }
+
+ // methods to set dimensions
+ void setColumnsCount(int);
+ void setRowsCount(int);
+ void setColumnsWidth(const qreal &);
+ void setRowsHeight(const qreal &);
+ void setColumnsHeaderHeight(const qreal &);
+ void setRowsHeaderWidth(const qreal &);
+ void setDiagramHeight(const qreal &);
+
+ DiagramPosition convertPosition(const QPointF &);
+
+ // methods to set title block basic data
+ void setAuthor(const QString &author);
+ void setDate(const QDate &date);
+ void setTitle(const QString &title);
+ void setFolio(const QString &folio);
+ void setFolioData(int, int, const QString& = nullptr,
+ const DiagramContext & = DiagramContext());
+ void setPlant(const QString &plant);
+ void setLocMach(const QString &locmach);
+ void setIndicerev(const QString &indexrev);
+ void setFileName(const QString &filename);
+ void setVersion(const QString &version);
+ void setAutoPageNum(const QString &auto_page_num);
+ void setPreviousFolioNum(const QString &previous);
+ void setNextFolioNum(const QString &next);
+
+ void titleBlockToXml(QDomElement &);
+ void titleBlockFromXml(const QDomElement &);
+ void borderToXml(QDomElement &);
+ void borderFromXml(const QDomElement &);
+
+ TitleBlockProperties exportTitleBlock();
+ void importTitleBlock(const TitleBlockProperties &);
+ BorderProperties exportBorder();
+ void importBorder(const BorderProperties &);
+
+ const TitleBlockTemplate *titleBlockTemplate();
+ void setTitleBlockTemplate(const TitleBlockTemplate *);
+ QString titleBlockTemplateName() const;
+
+ public slots:
+ void titleBlockTemplateChanged(const QString &);
+ void titleBlockTemplateRemoved(
+ const QString &,
+ const TitleBlockTemplate * = nullptr);
+
+ // methods to set display options
+ void displayTitleBlock(bool);
+ void displayColumns(bool);
+ void displayRows(bool);
+ void displayBorder(bool);
+ void slot_setAutoPageNum (QString);
+
+ private:
+ void updateRectangles();
+ void updateDiagramContextForTitleBlock(
+ const DiagramContext & = DiagramContext());
+ QString incrementLetters(const QString &);
+
+ signals:
+ /**
+ @brief borderChanged
+ Signal emitted after the border has changed
+ @param old_border Former border
+ @param new_border New border
+ */
+ void borderChanged(QRectF old_border, QRectF new_border);
+ /**
+ @brief displayChanged
+ Signal emitted after display options have changed
+ */
+ void displayChanged();
+ /**
+ @brief diagramTitleChanged
+ Signal emitted after the title has changed
+ */
+ void diagramTitleChanged(const QString &);
+ /**
+ @brief titleBlockFolioChanged
+ Signal emitted after Folio has changed
+ */
+ void titleBlockFolioChanged(const QString &);
+ /**
+ @brief needFolioData
+ Signal emitted when the title block
+ requires its data to be updated
+ in order to generate the folio field.
+ */
+ void needFolioData();
+ /**
+ @brief needTitleBlockTemplate
+ Signal emitted when this object needs to
+ set a specific title block template.
+ This object cannot handle the job
+ since it does not know of its parent project.
+ */
+ void needTitleBlockTemplate(const QString &);
+
+ // attributes
+ private:
+ // titleblock basic data
+ QString btb_author_; ///< titleblock author
+ QDate btb_date_; ///< titleblock date
+ QString btb_title_; ///< titleblock title
+ QString btb_folio_; ///< titleblock folio
+ QString btb_plant_; ///< titleblock plant
+ QString btb_locmach_; ///< titleblock locmach
+ QString btb_indexrev_; ///< titleblock index rev
+ QString btb_final_folio_; ///< titleblock final folio
+ QString btb_auto_page_num_; ///< titleblock auto page num
+ int folio_index_; ///< titleblock index
+ int folio_total_; ///< titleblock total
+ QString btb_filename_; ///< titleblock filename
+ QString btb_version_; ///< titleblock version
+ /// titleblock additional fields
+ DiagramContext additional_fields_;
+ Qt::Edge m_edge; ///< titleblock edge
+ QString m_next_folio_num; ///< titleblock next folio num
+ QString m_previous_folio_num; ///< titleblock previous folio num
+
+ // border dimensions (rows and columns)
+ // columns: number and dimensions
+ int columns_count_; ///< columns count
+ qreal columns_width_; ///< columns width
+ qreal columns_header_height_; ///< columns header height
+
+ // rows: number and dimensions
+ int rows_count_; ///< rows count
+ qreal rows_height_; ///< rows height
+ qreal rows_header_width_; ///< rows header width
+
+ // title block dimensions
+ qreal titleblock_height_;
+
+ // rectangles used for drawing operations
+ QRectF diagram_rect_;
+
+ // display options
+ bool display_titleblock_;
+ bool display_columns_;
+ bool display_rows_;
+ bool display_border_;
+ TitleBlockTemplateRenderer *m_titleblock_template_renderer;
};
#endif
diff --git a/sources/conductorproperties.cpp b/sources/conductorproperties.cpp
index b26853f8b..bd1b3f999 100644
--- a/sources/conductorproperties.cpp
+++ b/sources/conductorproperties.cpp
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#include "conductorproperties.h"
#include
@@ -21,13 +21,13 @@
#include
#include
/**
- Constructeur par defaut
+ Constructeur par defaut
*/
SingleLineProperties::SingleLineProperties() :
- hasGround(true),
- hasNeutral(true),
- is_pen(false),
- phases(1)
+ hasGround(true),
+ hasNeutral(true),
+ is_pen(false),
+ phases(1)
{
}
@@ -37,224 +37,224 @@ SingleLineProperties::~SingleLineProperties()
}
/**
- Definit le nombre de phases (0, 1, 2, ou 3)
- @param n Nombre de phases
+ Definit le nombre de phases (0, 1, 2, ou 3)
+ @param n Nombre de phases
*/
void SingleLineProperties::setPhasesCount(int n) {
- phases = qBound(0, n, 3);
+ phases = qBound(0, n, 3);
}
/// @return le nombre de phases (0, 1, 2, ou 3)
unsigned short int SingleLineProperties::phasesCount()
{
- return(phases);
+ return(phases);
}
/**
- @return true if the singleline conductor should be drawn using the PEN
- (Protective Earth Neutral) representation and if it features the ground and
- the neutral.
+ @return true if the singleline conductor should be drawn using the PEN
+ (Protective Earth Neutral) representation and if it features the ground and
+ the neutral.
*/
bool SingleLineProperties::isPen() const
{
- return(hasNeutral && hasGround && is_pen);
+ return(hasNeutral && hasGround && is_pen);
}
/**
- Dessine les symboles propres a un conducteur unifilaire
- @param painter QPainter a utiliser pour dessiner les symboles
- @param direction direction du segment sur lequel les symboles apparaitront
- @param rect rectangle englobant le dessin ; utilise pour specifier a la fois la position et la taille du dessin
+ Dessine les symboles propres a un conducteur unifilaire
+ @param painter QPainter a utiliser pour dessiner les symboles
+ @param direction direction du segment sur lequel les symboles apparaitront
+ @param rect rectangle englobant le dessin ; utilise pour specifier a la fois la position et la taille du dessin
*/
void SingleLineProperties::draw(QPainter *painter,
- QET::ConductorSegmentType direction,
- const QRectF &rect) {
- // s'il n'y a rien a dessiner, on retourne immediatement
- if (!hasNeutral && !hasGround && !phases) return;
+ QET::ConductorSegmentType direction,
+ const QRectF &rect) {
+ // s'il n'y a rien a dessiner, on retourne immediatement
+ if (!hasNeutral && !hasGround && !phases) return;
- // prepare le QPainter
- painter -> save();
- QPen pen(painter -> pen());
- pen.setCapStyle(Qt::FlatCap);
- pen.setJoinStyle(Qt::MiterJoin);
- pen.setStyle(Qt::SolidLine);
- pen.setWidthF(1);
- painter -> setPen(pen);
- painter -> setRenderHint(QPainter::Antialiasing, true);
+ // prepare le QPainter
+ painter -> save();
+ QPen pen(painter -> pen());
+ pen.setCapStyle(Qt::FlatCap);
+ pen.setJoinStyle(Qt::MiterJoin);
+ pen.setStyle(Qt::SolidLine);
+ pen.setWidthF(1);
+ painter -> setPen(pen);
+ painter -> setRenderHint(QPainter::Antialiasing, true);
- uint symbols_count = (hasNeutral ? 1 : 0) + (hasGround ? 1 : 0) - (isPen() ? 1 : 0) + phases;
- qreal interleave_base = (direction == QET::Horizontal ? rect.width() : rect.height());
- qreal interleave = interleave_base / (symbols_count + 1);;
- qreal symbol_width = interleave_base / 12;
+ uint symbols_count = (hasNeutral ? 1 : 0) + (hasGround ? 1 : 0) - (isPen() ? 1 : 0) + phases;
+ qreal interleave_base = (direction == QET::Horizontal ? rect.width() : rect.height());
+ qreal interleave = interleave_base / (symbols_count + 1);;
+ qreal symbol_width = interleave_base / 12;
- for (uint i = 1 ; i <= symbols_count ; ++ i) {
- // dessine le tronc du symbole
- QPointF symbol_p1, symbol_p2;
- if (direction == QET::Horizontal) {
- symbol_p1 = QPointF(rect.x() + (i * interleave) + symbol_width, rect.y() + rect.height() * 0.75);
- symbol_p2 = QPointF(rect.x() + (i * interleave) - symbol_width, rect.y() + rect.height() * 0.25);
- } else {
- symbol_p2 = QPointF(rect.x() + rect.width() * 0.75, rect.y() + (i * interleave) - symbol_width);
- symbol_p1 = QPointF(rect.x() + rect.width() * 0.25, rect.y() + (i * interleave) + symbol_width);
- }
- painter -> drawLine(QLineF(symbol_p1, symbol_p2));
+ for (uint i = 1 ; i <= symbols_count ; ++ i) {
+ // dessine le tronc du symbole
+ QPointF symbol_p1, symbol_p2;
+ if (direction == QET::Horizontal) {
+ symbol_p1 = QPointF(rect.x() + (i * interleave) + symbol_width, rect.y() + rect.height() * 0.75);
+ symbol_p2 = QPointF(rect.x() + (i * interleave) - symbol_width, rect.y() + rect.height() * 0.25);
+ } else {
+ symbol_p2 = QPointF(rect.x() + rect.width() * 0.75, rect.y() + (i * interleave) - symbol_width);
+ symbol_p1 = QPointF(rect.x() + rect.width() * 0.25, rect.y() + (i * interleave) + symbol_width);
+ }
+ painter -> drawLine(QLineF(symbol_p1, symbol_p2));
- // dessine le reste des symboles terre et neutre
- if (isPen()) {
- if (i == 1) {
- drawPen(painter, direction, symbol_p2, symbol_width);
- }
- } else {
- if (hasGround && i == 1) {
- drawGround(painter, direction, symbol_p2, symbol_width * 2.0);
- } else if (hasNeutral && ((i == 1 && !hasGround) || (i == 2 && hasGround))) {
- drawNeutral(painter, symbol_p2, symbol_width * 1.5);
- }
- }
- }
- painter -> restore();
+ // dessine le reste des symboles terre et neutre
+ if (isPen()) {
+ if (i == 1) {
+ drawPen(painter, direction, symbol_p2, symbol_width);
+ }
+ } else {
+ if (hasGround && i == 1) {
+ drawGround(painter, direction, symbol_p2, symbol_width * 2.0);
+ } else if (hasNeutral && ((i == 1 && !hasGround) || (i == 2 && hasGround))) {
+ drawNeutral(painter, symbol_p2, symbol_width * 1.5);
+ }
+ }
+ }
+ painter -> restore();
}
/**
- Dessine le segment correspondant au symbole de la terre sur un conducteur unifilaire
- @param painter QPainter a utiliser pour dessiner le segment
- @param direction direction du segment sur lequel le symbole apparaitra
- @param center centre du segment
- @param size taille du segment
+ Dessine le segment correspondant au symbole de la terre sur un conducteur unifilaire
+ @param painter QPainter a utiliser pour dessiner le segment
+ @param direction direction du segment sur lequel le symbole apparaitra
+ @param center centre du segment
+ @param size taille du segment
*/
void SingleLineProperties::drawGround(QPainter *painter,
- QET::ConductorSegmentType direction,
- QPointF center,
- qreal size) {
- painter -> save();
+ QET::ConductorSegmentType direction,
+ QPointF center,
+ qreal size) {
+ painter -> save();
- // prepare le QPainter
- painter -> setRenderHint(QPainter::Antialiasing, false);
- QPen pen2(painter -> pen());
- pen2.setCapStyle(Qt::SquareCap);
- painter -> setPen(pen2);
+ // prepare le QPainter
+ painter -> setRenderHint(QPainter::Antialiasing, false);
+ QPen pen2(painter -> pen());
+ pen2.setCapStyle(Qt::SquareCap);
+ painter -> setPen(pen2);
- // dessine le segment representant la terre
- qreal half_size = size / 2.0;
- QPointF offset_point(
- (direction == QET::Horizontal) ? half_size : 0.0,
- (direction == QET::Horizontal) ? 0.0 : half_size
- );
- painter -> drawLine(
- QLineF(
- center + offset_point,
- center - offset_point
- )
- );
+ // dessine le segment representant la terre
+ qreal half_size = size / 2.0;
+ QPointF offset_point(
+ (direction == QET::Horizontal) ? half_size : 0.0,
+ (direction == QET::Horizontal) ? 0.0 : half_size
+ );
+ painter -> drawLine(
+ QLineF(
+ center + offset_point,
+ center - offset_point
+ )
+ );
- painter -> restore();
+ painter -> restore();
}
/**
- Dessine le cercle correspondant au symbole du neutre sur un conducteur unifilaire
- @param painter QPainter a utiliser pour dessiner le segment
- @param center centre du cercle
- @param size diametre du cercle
+ Dessine le cercle correspondant au symbole du neutre sur un conducteur unifilaire
+ @param painter QPainter a utiliser pour dessiner le segment
+ @param center centre du cercle
+ @param size diametre du cercle
*/
void SingleLineProperties::drawNeutral(
- QPainter *painter,
- QPointF center,
- qreal size)
+ QPainter *painter,
+ QPointF center,
+ qreal size)
{
- painter -> save();
+ painter -> save();
- // prepare le QPainter
- if (painter -> brush() == Qt::NoBrush) painter -> setBrush(Qt::black);
- painter -> setPen(Qt::NoPen);
+ // prepare le QPainter
+ if (painter -> brush() == Qt::NoBrush) painter -> setBrush(Qt::black);
+ painter -> setPen(Qt::NoPen);
- // desine le cercle representant le neutre
- painter -> drawEllipse(
- QRectF(
- center - QPointF(size / 2.0, size / 2.0),
- QSizeF(size, size)
- )
- );
+ // desine le cercle representant le neutre
+ painter -> drawEllipse(
+ QRectF(
+ center - QPointF(size / 2.0, size / 2.0),
+ QSizeF(size, size)
+ )
+ );
- painter -> restore();
+ painter -> restore();
}
/**
- @brief SingleLineProperties::drawPen
- Draw the PEN (Protective Earth Neutral) symbol using
- \a painter at position \a center, using a size hint of \a size.
- @param painter
- @param direction :
- Indicate the direction of the underlying conductor segment
- @param center
- @param size
+ @brief SingleLineProperties::drawPen
+ Draw the PEN (Protective Earth Neutral) symbol using
+ \a painter at position \a center, using a size hint of \a size.
+ @param painter
+ @param direction :
+ Indicate the direction of the underlying conductor segment
+ @param center
+ @param size
*/
void SingleLineProperties::drawPen(QPainter *painter,
- QET::ConductorSegmentType direction,
- QPointF center,
- qreal size) {
- painter -> save();
+ QET::ConductorSegmentType direction,
+ QPointF center,
+ qreal size) {
+ painter -> save();
- //painter -> setBrush(Qt::white);
- // desine le cercle representant le neutre
- //painter -> drawEllipse(
- // QRectF(
- // center - QPointF(size * 1.5 / 2.0, size * 1.5 / 2.0),
- // QSizeF(size * 1.5, size * 1.5)
- // )
- //);
- drawNeutral(painter, center, size * 1.5);
+ //painter -> setBrush(Qt::white);
+ // desine le cercle representant le neutre
+ //painter -> drawEllipse(
+ // QRectF(
+ // center - QPointF(size * 1.5 / 2.0, size * 1.5 / 2.0),
+ // QSizeF(size * 1.5, size * 1.5)
+ // )
+ //);
+ drawNeutral(painter, center, size * 1.5);
- int offset = (size * 1.5 / 2.0);
- QPointF pos = center + (direction == QET::Horizontal ? QPointF(0.0, -offset - 0.5) : QPointF(offset + 0.5, 0.0));
- drawGround(painter, direction, pos, 2.0 * size);
- painter -> restore();
+ int offset = (size * 1.5 / 2.0);
+ QPointF pos = center + (direction == QET::Horizontal ? QPointF(0.0, -offset - 0.5) : QPointF(offset + 0.5, 0.0));
+ drawGround(painter, direction, pos, 2.0 * size);
+ painter -> restore();
}
/**
- Exporte les parametres du conducteur unifilaire sous formes d'attributs XML
- ajoutes a l'element e.
- @param e Element XML auquel seront ajoutes des attributs
+ Exporte les parametres du conducteur unifilaire sous formes d'attributs XML
+ ajoutes a l'element e.
+ @param e Element XML auquel seront ajoutes des attributs
*/
void SingleLineProperties::toXml(QDomElement &e) const
{
- e.setAttribute("ground", hasGround ? "true" : "false");
- e.setAttribute("neutral", hasNeutral ? "true" : "false");
- e.setAttribute("phase", phases);
- if (isPen()) e.setAttribute("pen", "true");
+ e.setAttribute("ground", hasGround ? "true" : "false");
+ e.setAttribute("neutral", hasNeutral ? "true" : "false");
+ e.setAttribute("phase", phases);
+ if (isPen()) e.setAttribute("pen", "true");
}
/**
- Importe les parametres du conducteur unifilaire a partir des attributs XML
- de l'element e
- @param e Element XML dont les attributs seront lus
+ Importe les parametres du conducteur unifilaire a partir des attributs XML
+ de l'element e
+ @param e Element XML dont les attributs seront lus
*/
void SingleLineProperties::fromXml(QDomElement &e) {
- hasGround = e.attribute("ground") == "true";
- hasNeutral = e.attribute("neutral") == "true";
- setPhasesCount(e.attribute("phase").toInt());
- is_pen = (hasGround && hasNeutral && e.attribute("pen", "false") == "true");
+ hasGround = e.attribute("ground") == "true";
+ hasNeutral = e.attribute("neutral") == "true";
+ setPhasesCount(e.attribute("phase").toInt());
+ is_pen = (hasGround && hasNeutral && e.attribute("pen", "false") == "true");
}
/**
- Constructeur : par defaut, les proprietes font un conducteur
- multifilaire noir dont le texte est "_"
+ Constructeur : par defaut, les proprietes font un conducteur
+ multifilaire noir dont le texte est "_"
*/
ConductorProperties::ConductorProperties() :
- type(Multi),
- color(Qt::black),
- text_color(Qt::black),
- text("_"),
- text_size(9),
- cond_size(1),
- verti_rotate_text(270),
- horiz_rotate_text(0),
- m_show_text(true),
- m_one_text_per_folio(false),
- style(Qt::SolidLine)
+ type(Multi),
+ color(Qt::black),
+ text_color(Qt::black),
+ text("_"),
+ text_size(9),
+ cond_size(1),
+ verti_rotate_text(270),
+ horiz_rotate_text(0),
+ m_show_text(true),
+ m_one_text_per_folio(false),
+ style(Qt::SolidLine)
{}
/**
- Destructeur
+ Destructeur
*/
ConductorProperties::~ConductorProperties()
{
@@ -262,662 +262,662 @@ ConductorProperties::~ConductorProperties()
/**
- @brief ConductorProperties::toXml
- Export conductor propertie, in the XML element 'e'
- @param e the xml element
+ @brief ConductorProperties::toXml
+ Export conductor propertie, in the XML element 'e'
+ @param e the xml element
*/
void ConductorProperties::toXml(QDomElement &e) const
{
- e.setAttribute("type", typeToString(type));
+ e.setAttribute("type", typeToString(type));
- if (color != QColor(Qt::black))
- e.setAttribute("color", color.name());
+ if (color != QColor(Qt::black))
+ e.setAttribute("color", color.name());
- e.setAttribute("bicolor", m_bicolor? "true" : "false");
- e.setAttribute("color2", m_color_2.name());
- e.setAttribute("dash-size", QString::number(m_dash_size));
+ e.setAttribute("bicolor", m_bicolor? "true" : "false");
+ e.setAttribute("color2", m_color_2.name());
+ e.setAttribute("dash-size", QString::number(m_dash_size));
- if (type == Single)
- singleLineProperties.toXml(e);
+ if (type == Single)
+ singleLineProperties.toXml(e);
- 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.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));
- QMetaEnum me = QMetaEnum::fromType();
- e.setAttribute("horizontal-alignment", me.valueToKey(m_horizontal_alignment));
- e.setAttribute("vertical-alignment", me.valueToKey(m_vertical_alignment));
+ QMetaEnum me = QMetaEnum::fromType();
+ e.setAttribute("horizontal-alignment", me.valueToKey(m_horizontal_alignment));
+ e.setAttribute("vertical-alignment", me.valueToKey(m_vertical_alignment));
- QString conductor_style = writeStyle();
- if (!conductor_style.isEmpty())
- e.setAttribute("style", conductor_style);
+ QString conductor_style = writeStyle();
+ if (!conductor_style.isEmpty())
+ e.setAttribute("style", conductor_style);
}
/**
- @brief ConductorProperties::fromXml
- Import conductor propertie, from the attribute of the xml element 'e'
- @param e the xml document
+ @brief ConductorProperties::fromXml
+ Import conductor propertie, from the attribute of the xml element 'e'
+ @param e the xml document
*/
void ConductorProperties::fromXml(QDomElement &e)
{
- // get conductor color
- QColor xml_color= QColor(e.attribute("color"));
- color = (xml_color.isValid()? xml_color : QColor(Qt::black));
+ // get conductor color
+ QColor xml_color= QColor(e.attribute("color"));
+ color = (xml_color.isValid()? xml_color : QColor(Qt::black));
- QString bicolor_str = e.attribute("bicolor", "false");
- m_bicolor = bicolor_str == "true"? true : false;
+ QString bicolor_str = e.attribute("bicolor", "false");
+ 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);
+ 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();
+ m_dash_size = e.attribute("dash-size", QString::number(1)).toInt();
- // read style of conductor
- readStyle(e.attribute("style"));
+ // read style of conductor
+ readStyle(e.attribute("style"));
- if (e.attribute("type") == typeToString(Single))
- {
- // get specific properties for single conductor
- singleLineProperties.fromXml(e);
- type = Single;
- }
- else
- type = Multi;
+ if (e.attribute("type") == typeToString(Single))
+ {
+ // get specific properties for single conductor
+ singleLineProperties.fromXml(e);
+ type = Single;
+ }
+ else
+ type = Multi;
- text = e.attribute("num");
- // get text color
- QColor xml_text_color= QColor(e.attribute("text_color"));
- text_color = (xml_text_color.isValid()? xml_text_color : QColor(Qt::black));
- m_formula = e.attribute("formula");
- m_cable = e.attribute("cable");
- m_bus = e.attribute("bus");
- m_function = e.attribute("function");
- m_tension_protocol = e.attribute("tension_protocol");
- m_wire_color = e.attribute("conductor_color");
- m_wire_section = e.attribute("conductor_section");
- text_size = e.attribute("numsize", QString::number(9)).toInt();
- cond_size = e.attribute("condsize", QString::number(1)).toDouble();
- m_show_text = e.attribute("displaytext", QString::number(1)).toInt();
- 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();
+ text = e.attribute("num");
+ // get text color
+ QColor xml_text_color= QColor(e.attribute("text_color"));
+ text_color = (xml_text_color.isValid()? xml_text_color : QColor(Qt::black));
+ m_formula = e.attribute("formula");
+ m_cable = e.attribute("cable");
+ m_bus = e.attribute("bus");
+ m_function = e.attribute("function");
+ m_tension_protocol = e.attribute("tension_protocol");
+ m_wire_color = e.attribute("conductor_color");
+ m_wire_section = e.attribute("conductor_section");
+ text_size = e.attribute("numsize", QString::number(9)).toInt();
+ cond_size = e.attribute("condsize", QString::number(1)).toDouble();
+ m_show_text = e.attribute("displaytext", QString::number(1)).toInt();
+ 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();
- 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()));
+ QMetaEnum me = QMetaEnum::fromType();
+ 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
- //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
+ //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
#if TODO_LIST
#pragma message("@TODO remove this code for qet 0.6 or later")
#endif
- if (e.attribute("type") == "simple") m_show_text = false;
+ if (e.attribute("type") == "simple") m_show_text = false;
}
/**
- @param settings Parametres a ecrire
- @param prefix prefixe a ajouter devant les noms des parametres
+ @param settings Parametres a ecrire
+ @param prefix prefixe a ajouter devant les noms des parametres
*/
void ConductorProperties::toSettings(QSettings &settings, const QString &prefix) const
{
- settings.setValue(prefix + "color", color.name());
- settings.setValue(prefix + "bicolor", m_bicolor);
- settings.setValue(prefix + "color2", m_color_2.name());
- settings.setValue(prefix + "dash-size", m_dash_size);
- settings.setValue(prefix + "style", writeStyle());
- settings.setValue(prefix + "type", typeToString(type));
- settings.setValue(prefix + "text", text);
- settings.setValue(prefix + "text_color", text_color.name());
- settings.setValue(prefix + "formula", m_formula);
- settings.setValue(prefix + "cable", m_cable);
- settings.setValue(prefix + "bus", m_bus);
- settings.setValue(prefix + "function", m_function);
- settings.setValue(prefix + "tension_protocol", m_tension_protocol);
- settings.setValue(prefix + "conductor_color", m_wire_color);
- settings.setValue(prefix + "conductor_section", m_wire_section);
- settings.setValue(prefix + "textsize", QString::number(text_size));
- settings.setValue(prefix + "size", QString::number(cond_size));
- settings.setValue(prefix + "displaytext", m_show_text);
- settings.setValue(prefix + "onetextperfolio", m_one_text_per_folio);
- settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text));
- settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text));
+ settings.setValue(prefix + "color", color.name());
+ settings.setValue(prefix + "bicolor", m_bicolor);
+ settings.setValue(prefix + "color2", m_color_2.name());
+ settings.setValue(prefix + "dash-size", m_dash_size);
+ settings.setValue(prefix + "style", writeStyle());
+ settings.setValue(prefix + "type", typeToString(type));
+ settings.setValue(prefix + "text", text);
+ settings.setValue(prefix + "text_color", text_color.name());
+ settings.setValue(prefix + "formula", m_formula);
+ settings.setValue(prefix + "cable", m_cable);
+ settings.setValue(prefix + "bus", m_bus);
+ settings.setValue(prefix + "function", m_function);
+ settings.setValue(prefix + "tension_protocol", m_tension_protocol);
+ settings.setValue(prefix + "conductor_color", m_wire_color);
+ settings.setValue(prefix + "conductor_section", m_wire_section);
+ settings.setValue(prefix + "textsize", QString::number(text_size));
+ settings.setValue(prefix + "size", QString::number(cond_size));
+ settings.setValue(prefix + "displaytext", m_show_text);
+ settings.setValue(prefix + "onetextperfolio", m_one_text_per_folio);
+ settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text));
+ settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text));
- QMetaEnum me = QMetaEnum::fromType();
- settings.setValue(prefix + "horizontal-alignment", me.valueToKey(m_horizontal_alignment));
- settings.setValue(prefix + "vertical-alignment", me.valueToKey(m_vertical_alignment));
+ QMetaEnum me = QMetaEnum::fromType();
+ settings.setValue(prefix + "horizontal-alignment", me.valueToKey(m_horizontal_alignment));
+ settings.setValue(prefix + "vertical-alignment", me.valueToKey(m_vertical_alignment));
- singleLineProperties.toSettings(settings, prefix);
+ singleLineProperties.toSettings(settings, prefix);
}
/**
- @param settings Parametres a lire
- @param prefix prefixe a ajouter devant les noms des parametres
+ @param settings Parametres a lire
+ @param prefix prefixe a ajouter devant les noms des parametres
*/
void ConductorProperties::fromSettings(QSettings &settings, const QString &prefix)
{
- QColor settings_color = QColor(settings.value(prefix + "color").toString());
- color = (settings_color.isValid()? settings_color : QColor(Qt::black));
+ QColor settings_color = QColor(settings.value(prefix + "color").toString());
+ color = (settings_color.isValid()? settings_color : QColor(Qt::black));
- QColor settings_color_2 = QColor(settings.value(prefix + "color2").toString());
- m_color_2 = (settings_color_2.isValid()? settings_color_2 : QColor(Qt::black));
+ QColor settings_color_2 = QColor(settings.value(prefix + "color2").toString());
+ m_color_2 = (settings_color_2.isValid()? settings_color_2 : QColor(Qt::black));
- m_bicolor = settings.value(prefix + "bicolor", false).toBool();
- m_dash_size = settings.value(prefix + "dash-size", 1).toInt();
+ m_bicolor = settings.value(prefix + "bicolor", false).toBool();
+ m_dash_size = settings.value(prefix + "dash-size", 1).toInt();
- QString setting_type = settings.value(prefix + "type", typeToString(Multi)).toString();
- type = (setting_type == typeToString(Single)? Single : Multi);
+ QString setting_type = settings.value(prefix + "type", typeToString(Multi)).toString();
+ type = (setting_type == typeToString(Single)? Single : Multi);
- singleLineProperties.fromSettings(settings, prefix);
+ singleLineProperties.fromSettings(settings, prefix);
- text = settings.value(prefix + "text", "_").toString();
- QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString());
- text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black));
- m_formula = settings.value(prefix + "formula", "").toString();
- m_cable = settings.value(prefix + "cable", "").toString();
- m_bus = settings.value(prefix + "bus", "").toString();
- m_function = settings.value(prefix + "function", "").toString();
- m_tension_protocol = settings.value(prefix + "tension_protocol", "").toString();
- m_wire_color = settings.value(prefix + "conductor_color", "").toString();
- m_wire_section = settings.value(prefix + "conductor_section", "").toString();
- text_size = settings.value(prefix + "textsize", "7").toInt();
- cond_size = settings.value(prefix + "size", "1").toInt();
- m_show_text = settings.value(prefix + "displaytext", true).toBool();
- m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
- verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
- horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
+ text = settings.value(prefix + "text", "_").toString();
+ QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString());
+ text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black));
+ m_formula = settings.value(prefix + "formula", "").toString();
+ m_cable = settings.value(prefix + "cable", "").toString();
+ m_bus = settings.value(prefix + "bus", "").toString();
+ m_function = settings.value(prefix + "function", "").toString();
+ m_tension_protocol = settings.value(prefix + "tension_protocol", "").toString();
+ m_wire_color = settings.value(prefix + "conductor_color", "").toString();
+ m_wire_section = settings.value(prefix + "conductor_section", "").toString();
+ text_size = settings.value(prefix + "textsize", "7").toInt();
+ cond_size = settings.value(prefix + "size", "1").toInt();
+ m_show_text = settings.value(prefix + "displaytext", true).toBool();
+ m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
+ verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
+ horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
- QMetaEnum me = QMetaEnum::fromType();
- m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "horizontal-alignment", "AlignBottom").toString().toStdString().data()));
- m_vertical_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "vertical-alignment", "AlignRight").toString().toStdString().data()));
+ QMetaEnum me = QMetaEnum::fromType();
+ m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "horizontal-alignment", "AlignBottom").toString().toStdString().data()));
+ m_vertical_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "vertical-alignment", "AlignRight").toString().toStdString().data()));
- readStyle(settings.value(prefix + "style").toString());
+ readStyle(settings.value(prefix + "style").toString());
}
/**
- @param t type du conducteur
+ @param t type du conducteur
*/
QString ConductorProperties::typeToString(ConductorType t)
{
- switch(t)
- {
- case Single: return("single");
- case Multi: return("multi");
- }
- return QString();
+ switch(t)
+ {
+ case Single: return("single");
+ case Multi: return("multi");
+ }
+ return QString();
}
/**
- @brief ConductorProperties::applyForEqualAttributes
- Test each attribute of properties in the list separatly.
- For each attributes, if is equal, the attribute is apply to this.
- @param list
+ @brief ConductorProperties::applyForEqualAttributes
+ Test each attribute of properties in the list separatly.
+ For each attributes, if is equal, the attribute is apply to this.
+ @param list
*/
void ConductorProperties::applyForEqualAttributes(QList list)
{
- const QList clist = std::move(list);
+ const QList clist = std::move(list);
- if (clist.isEmpty())
- return;
+ if (clist.isEmpty())
+ return;
- if (clist.size() == 1)
- {
- ConductorProperties cp = clist.first();
- color = cp.color;
- m_bicolor = cp.m_bicolor;
- m_color_2 = cp.m_color_2;
- m_dash_size = cp.m_dash_size;
- text = cp.text;
- text_color = cp.text_color;
- m_formula = cp.m_formula;
- m_cable = cp.m_cable;
- m_bus = cp.m_bus;
- m_function = cp.m_function;
- m_tension_protocol = cp.m_tension_protocol;
- m_wire_color = cp.m_wire_color;
- m_wire_section = cp.m_wire_section;
- text_size = cp.text_size;
- cond_size = cp.cond_size;
- m_show_text = cp.m_show_text;
- m_one_text_per_folio = cp.m_one_text_per_folio;
- verti_rotate_text = cp.verti_rotate_text;
- horiz_rotate_text = cp.horiz_rotate_text;
- m_vertical_alignment = cp.m_vertical_alignment;
- m_horizontal_alignment = cp.m_horizontal_alignment;
+ if (clist.size() == 1)
+ {
+ ConductorProperties cp = clist.first();
+ color = cp.color;
+ m_bicolor = cp.m_bicolor;
+ m_color_2 = cp.m_color_2;
+ m_dash_size = cp.m_dash_size;
+ text = cp.text;
+ text_color = cp.text_color;
+ m_formula = cp.m_formula;
+ m_cable = cp.m_cable;
+ m_bus = cp.m_bus;
+ m_function = cp.m_function;
+ m_tension_protocol = cp.m_tension_protocol;
+ m_wire_color = cp.m_wire_color;
+ m_wire_section = cp.m_wire_section;
+ text_size = cp.text_size;
+ cond_size = cp.cond_size;
+ m_show_text = cp.m_show_text;
+ m_one_text_per_folio = cp.m_one_text_per_folio;
+ verti_rotate_text = cp.verti_rotate_text;
+ horiz_rotate_text = cp.horiz_rotate_text;
+ m_vertical_alignment = cp.m_vertical_alignment;
+ m_horizontal_alignment = cp.m_horizontal_alignment;
- return;
- }
+ return;
+ }
- bool equal = true;
- QColor c_value;
- bool b_value;
- QString s_value;
- int i_value;
- double d_value;
- Qt::Alignment align_value;
+ bool equal = true;
+ QColor c_value;
+ bool b_value;
+ QString s_value;
+ int i_value;
+ double d_value;
+ Qt::Alignment align_value;
- //Color
- c_value = clist.first().color;
- for(ConductorProperties cp : clist)
- {
- if (cp.color != c_value)
- equal = false;
- }
- if (equal)
- color = c_value;
- equal = true;
+ //Color
+ c_value = clist.first().color;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.color != c_value)
+ equal = false;
+ }
+ if (equal)
+ color = c_value;
+ equal = true;
- //bicolor
- b_value = clist.first().m_bicolor;
- for(ConductorProperties cp : clist)
- {
- if (cp.m_bicolor != b_value)
- equal = false;
- }
- if (equal)
- m_bicolor = b_value;
- equal = true;
+ //bicolor
+ b_value = clist.first().m_bicolor;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.m_bicolor != b_value)
+ equal = false;
+ }
+ if (equal)
+ m_bicolor = b_value;
+ equal = true;
- //second color
- c_value = clist.first().m_color_2;
- for(ConductorProperties cp : clist)
- {
- if (cp.m_color_2 != c_value)
- equal = false;
- }
- if (equal)
- m_color_2 = c_value;
- equal = true;
+ //second color
+ c_value = clist.first().m_color_2;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.m_color_2 != c_value)
+ equal = false;
+ }
+ if (equal)
+ m_color_2 = c_value;
+ equal = true;
- //Dash size
- i_value = clist.first().m_dash_size;
- for(ConductorProperties cp : clist)
- {
- if (cp.m_dash_size != i_value)
- equal = false;
- }
- if (equal)
- m_dash_size = i_value;
- equal = true;
+ //Dash size
+ i_value = clist.first().m_dash_size;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.m_dash_size != i_value)
+ equal = false;
+ }
+ if (equal)
+ m_dash_size = i_value;
+ equal = true;
- //text
- s_value = clist.first().text;
- for(ConductorProperties cp : clist)
- {
- if (cp.text != s_value)
- equal = false;
- }
- if (equal)
- text = s_value;
- equal = true;
+ //text
+ s_value = clist.first().text;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.text != s_value)
+ equal = false;
+ }
+ if (equal)
+ text = s_value;
+ equal = true;
- //text color
- c_value = clist.first().text_color;
- for(ConductorProperties cp : clist)
- {
- if (cp.text_color != c_value)
- equal = false;
- }
- if (equal)
- text_color = c_value;
- equal = true;
+ //text color
+ c_value = clist.first().text_color;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.text_color != c_value)
+ equal = false;
+ }
+ if (equal)
+ text_color = c_value;
+ equal = true;
- //formula
- s_value = clist.first().m_formula;
- for(ConductorProperties cp : clist)
- {
- if (cp.m_formula != s_value)
- equal = false;
- }
- if (equal)
- m_formula = s_value;
- equal = true;
+ //formula
+ s_value = clist.first().m_formula;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.m_formula != s_value)
+ equal = false;
+ }
+ if (equal)
+ m_formula = s_value;
+ equal = true;
- //cable
- s_value = clist.first().m_cable;
- for(ConductorProperties cp : clist)
- {
- if (cp.m_cable != s_value)
- equal = false;
- }
- if (equal)
- m_cable = s_value;
- equal = true;
+ //cable
+ s_value = clist.first().m_cable;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.m_cable != s_value)
+ equal = false;
+ }
+ if (equal)
+ m_cable = s_value;
+ equal = true;
- //bus
- s_value = clist.first().m_bus;
- for(ConductorProperties cp : clist)
- {
- if (cp.m_bus != s_value)
- equal = false;
- }
- if (equal)
- m_bus = s_value;
- equal = true;
+ //bus
+ s_value = clist.first().m_bus;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.m_bus != s_value)
+ equal = false;
+ }
+ if (equal)
+ m_bus = s_value;
+ equal = true;
- //function
- s_value = clist.first().m_function;
- for(ConductorProperties cp : clist)
- {
- if (cp.m_function != s_value)
- equal = false;
- }
- if (equal)
- m_function = s_value;
- equal = true;
+ //function
+ s_value = clist.first().m_function;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.m_function != s_value)
+ equal = false;
+ }
+ if (equal)
+ m_function = s_value;
+ equal = true;
- //Tension protocol
- s_value = clist.first().m_tension_protocol;
- for(ConductorProperties cp : clist)
- {
- if (cp.m_tension_protocol != s_value)
- equal = false;
- }
- if (equal)
- m_tension_protocol = s_value;
- equal = true;
+ //Tension protocol
+ s_value = clist.first().m_tension_protocol;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.m_tension_protocol != s_value)
+ equal = false;
+ }
+ if (equal)
+ m_tension_protocol = s_value;
+ equal = true;
- //conductor_color
- s_value = clist.first().m_wire_color;
- for(ConductorProperties cp : clist)
- {
- if (cp.m_wire_color != s_value)
- equal = false;
- }
- if (equal)
- m_wire_color = s_value;
- equal = true;
+ //conductor_color
+ s_value = clist.first().m_wire_color;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.m_wire_color != s_value)
+ equal = false;
+ }
+ if (equal)
+ m_wire_color = s_value;
+ equal = true;
- //conductor_section
- s_value = clist.first().m_wire_section;
- for(ConductorProperties cp : clist)
- {
- if (cp.m_wire_section != s_value)
- equal = false;
- }
- if (equal)
- m_wire_section = s_value;
- equal = true;
+ //conductor_section
+ s_value = clist.first().m_wire_section;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.m_wire_section != s_value)
+ equal = false;
+ }
+ if (equal)
+ m_wire_section = s_value;
+ equal = true;
- //text size
- i_value = clist.first().text_size;
- for(ConductorProperties cp : clist)
- {
- if (cp.text_size != i_value)
- equal = false;
- }
- if (equal)
- text_size = i_value;
- equal = true;
+ //text size
+ i_value = clist.first().text_size;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.text_size != i_value)
+ equal = false;
+ }
+ if (equal)
+ text_size = i_value;
+ equal = true;
- //conductor size
- d_value = clist.first().cond_size;
- for(ConductorProperties cp : clist)
- {
- if (cp.cond_size != d_value)
- equal = false;
- }
- if (equal)
- cond_size = d_value;
- equal = true;
+ //conductor size
+ d_value = clist.first().cond_size;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.cond_size != d_value)
+ equal = false;
+ }
+ if (equal)
+ cond_size = d_value;
+ equal = true;
- //show text
- b_value = clist.first().m_show_text;
- for(ConductorProperties cp : clist)
- {
- if (cp.m_show_text != b_value)
- equal = false;
- }
- if (equal)
- m_show_text = b_value;
- equal = true;
+ //show text
+ b_value = clist.first().m_show_text;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.m_show_text != b_value)
+ equal = false;
+ }
+ if (equal)
+ m_show_text = b_value;
+ equal = true;
- //One text per folio
- b_value = clist.first().m_one_text_per_folio;
- for(ConductorProperties cp : clist)
- {
- if (cp.m_one_text_per_folio != b_value)
- equal = false;
- }
- if (equal)
- m_one_text_per_folio = b_value;
- equal = true;
+ //One text per folio
+ b_value = clist.first().m_one_text_per_folio;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.m_one_text_per_folio != b_value)
+ equal = false;
+ }
+ if (equal)
+ m_one_text_per_folio = b_value;
+ equal = true;
- //Text rotation for vertical conducor
- d_value = clist.first().verti_rotate_text;
- for(ConductorProperties cp : clist)
- {
- if (cp.verti_rotate_text != d_value)
- equal = false;
- }
- if (equal)
- verti_rotate_text = d_value;
- equal = true;
+ //Text rotation for vertical conducor
+ d_value = clist.first().verti_rotate_text;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.verti_rotate_text != d_value)
+ equal = false;
+ }
+ if (equal)
+ verti_rotate_text = d_value;
+ equal = true;
- //Text rotation for horizontal conducor
- d_value = clist.first().horiz_rotate_text;
- for(ConductorProperties cp : clist)
- {
- if (cp.horiz_rotate_text != d_value)
- equal = false;
- }
- if (equal)
- horiz_rotate_text = d_value;
- equal = true;
+ //Text rotation for horizontal conducor
+ d_value = clist.first().horiz_rotate_text;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.horiz_rotate_text != d_value)
+ equal = false;
+ }
+ if (equal)
+ horiz_rotate_text = d_value;
+ equal = true;
- //Text alignment for horizontal conducor
- align_value = clist.first().m_horizontal_alignment;
- for(ConductorProperties cp : clist)
- {
- if (cp.m_horizontal_alignment != align_value)
- equal = false;
- }
- if (equal)
- m_horizontal_alignment = align_value;
- equal = true;
+ //Text alignment for horizontal conducor
+ align_value = clist.first().m_horizontal_alignment;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.m_horizontal_alignment != align_value)
+ equal = false;
+ }
+ if (equal)
+ m_horizontal_alignment = align_value;
+ equal = true;
- //Text alignment for vertical conducor
- align_value = clist.first().m_vertical_alignment;
- for(ConductorProperties cp : clist)
- {
- if (cp.m_vertical_alignment != align_value)
- equal = false;
- }
- if (equal)
- m_vertical_alignment = align_value;
- equal = true;
+ //Text alignment for vertical conducor
+ align_value = clist.first().m_vertical_alignment;
+ for(ConductorProperties cp : clist)
+ {
+ if (cp.m_vertical_alignment != align_value)
+ equal = false;
+ }
+ if (equal)
+ m_vertical_alignment = align_value;
+ equal = true;
}
/**
- @brief ConductorProperties::defaultProperties
- @return the default properties stored in the setting file
+ @brief ConductorProperties::defaultProperties
+ @return the default properties stored in the setting file
*/
ConductorProperties ConductorProperties::defaultProperties()
{
- QSettings settings;
+ QSettings settings;
- ConductorProperties def;
- def.fromSettings(settings, "diagrameditor/defaultconductor");
+ ConductorProperties def;
+ def.fromSettings(settings, "diagrameditor/defaultconductor");
- return(def);
+ return(def);
}
/**
- @brief ConductorProperties::operator ==
- @param other
- @return true if other == this
+ @brief ConductorProperties::operator ==
+ @param other
+ @return true if other == this
*/
bool ConductorProperties::operator==(const ConductorProperties &other) const
{
- return(
- other.type == type &&\
- other.color == color &&\
- other.m_bicolor == m_bicolor &&\
- other.m_color_2 == m_color_2 &&\
- other.m_dash_size == m_dash_size &&\
- other.style == style &&\
- other.text == text &&\
- other.text_color == text_color &&\
- other.m_formula == m_formula &&\
- other.m_cable == m_cable &&\
- other.m_bus == m_bus &&\
- other.m_function == m_function &&\
- other.m_tension_protocol == m_tension_protocol &&\
- other.m_wire_color == m_wire_color && \
- other.m_wire_section == m_wire_section && \
- other.m_show_text == m_show_text &&\
- other.text_size == text_size &&\
- other.cond_size == cond_size &&\
- other.verti_rotate_text == verti_rotate_text &&\
- other.horiz_rotate_text == horiz_rotate_text &&\
- other.singleLineProperties == singleLineProperties &&\
- other.m_one_text_per_folio == m_one_text_per_folio &&\
- other.m_horizontal_alignment == m_horizontal_alignment &&\
- other.m_vertical_alignment == m_vertical_alignment
- );
+ return(
+ other.type == type &&\
+ other.color == color &&\
+ other.m_bicolor == m_bicolor &&\
+ other.m_color_2 == m_color_2 &&\
+ other.m_dash_size == m_dash_size &&\
+ other.style == style &&\
+ other.text == text &&\
+ other.text_color == text_color &&\
+ other.m_formula == m_formula &&\
+ other.m_cable == m_cable &&\
+ other.m_bus == m_bus &&\
+ other.m_function == m_function &&\
+ other.m_tension_protocol == m_tension_protocol &&\
+ other.m_wire_color == m_wire_color && \
+ other.m_wire_section == m_wire_section && \
+ other.m_show_text == m_show_text &&\
+ other.text_size == text_size &&\
+ other.cond_size == cond_size &&\
+ other.verti_rotate_text == verti_rotate_text &&\
+ other.horiz_rotate_text == horiz_rotate_text &&\
+ other.singleLineProperties == singleLineProperties &&\
+ other.m_one_text_per_folio == m_one_text_per_folio &&\
+ other.m_horizontal_alignment == m_horizontal_alignment &&\
+ other.m_vertical_alignment == m_vertical_alignment
+ );
}
/**
- @param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
- @return true si les deux ensembles de proprietes sont differents, false sinon
+ @param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
+ @return true si les deux ensembles de proprietes sont differents, false sinon
*/
bool ConductorProperties::operator!=(const ConductorProperties &other) const{
- return(!(*this == other));
+ return(!(*this == other));
}
/**
- Applique les styles passes en parametre dans cet objet
- @param style_string Chaine decrivant le style du conducteur
+ Applique les styles passes en parametre dans cet objet
+ @param style_string Chaine decrivant le style du conducteur
*/
void ConductorProperties::readStyle(const QString &style_string) {
- style = Qt::SolidLine; // style par defaut
+ style = Qt::SolidLine; // style par defaut
- if (style_string.isEmpty()) return;
+ if (style_string.isEmpty()) return;
- // recupere la liste des couples style / valeur
-#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
- QStringList styles = style_string.split(";", QString::SkipEmptyParts);
+ // recupere la liste des couples style / valeur
+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
+ QStringList styles = style_string.split(";", QString::SkipEmptyParts);
#else
#if TODO_LIST
#pragma message("@TODO remove code QString::SkipEmptyParts for QT 5.14 or later")
#endif
- QStringList styles = style_string.split(";", Qt::SkipEmptyParts);
+ QStringList styles = style_string.split(";", Qt::SkipEmptyParts);
#endif
- QRegularExpression Rx("^(?[a-z-]+): (?[a-z-]+)$");
- if (!Rx.isValid())
- {
- qWarning() <[a-z-]+): (?[a-z-]+)$");
+ if (!Rx.isValid())
+ {
+ qWarning() <.
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#ifndef CONDUCTOR_PROPERTIES_H
#define CONDUCTOR_PROPERTIES_H
@@ -25,117 +25,117 @@
class QPainter;
/**
- @brief The SingleLineProperties class
- This class represents the properties of a singleline conductor.
+ @brief The SingleLineProperties class
+ This class represents the properties of a singleline conductor.
*/
class SingleLineProperties {
- public:
- SingleLineProperties();
- virtual ~SingleLineProperties();
+ public:
+ SingleLineProperties();
+ virtual ~SingleLineProperties();
- void setPhasesCount(int);
- unsigned short int phasesCount();
- bool isPen() const;
- void draw(QPainter *, QET::ConductorSegmentType, const QRectF &);
- void toXml(QDomElement &) const;
- void fromXml(QDomElement &);
- void toSettings(QSettings &, const QString & = QString()) const;
- void fromSettings(QSettings &, const QString & = QString());
+ void setPhasesCount(int);
+ unsigned short int phasesCount();
+ bool isPen() const;
+ void draw(QPainter *, QET::ConductorSegmentType, const QRectF &);
+ void toXml(QDomElement &) const;
+ void fromXml(QDomElement &);
+ void toSettings(QSettings &, const QString & = QString()) const;
+ void fromSettings(QSettings &, const QString & = QString());
- /// Whether the singleline conductor should display the ground symbol
- bool hasGround;
- /// Whether the singleline conductor should display the neutral symbol
- bool hasNeutral;
- /// Protective Earth Neutral: visually merge neutral and ground
- bool is_pen;
+ /// Whether the singleline conductor should display the ground symbol
+ bool hasGround;
+ /// Whether the singleline conductor should display the neutral symbol
+ bool hasNeutral;
+ /// Protective Earth Neutral: visually merge neutral and ground
+ bool is_pen;
- int operator==(const SingleLineProperties &) const;
- int operator!=(const SingleLineProperties &) const;
+ int operator==(const SingleLineProperties &) const;
+ int operator!=(const SingleLineProperties &) const;
- private:
- unsigned short int phases;
- void drawGround (QPainter *, QET::ConductorSegmentType, QPointF, qreal);
- void drawNeutral(QPainter *, QPointF, qreal);
- void drawPen(QPainter *, QET::ConductorSegmentType, QPointF, qreal);
+ private:
+ unsigned short int phases;
+ void drawGround (QPainter *, QET::ConductorSegmentType, QPointF, qreal);
+ void drawNeutral(QPainter *, QPointF, qreal);
+ void drawPen(QPainter *, QET::ConductorSegmentType, QPointF, qreal);
};
/**
- @brief The ConductorProperties class
- This class represents the functional properties of a particular conductor,
- i.e. properties other than path and terminals.
+ @brief The ConductorProperties class
+ This class represents the functional properties of a particular conductor,
+ i.e. properties other than path and terminals.
*/
class ConductorProperties
{
- public:
- ConductorProperties();
- virtual ~ConductorProperties();
+ public:
+ ConductorProperties();
+ virtual ~ConductorProperties();
- /**
- @brief The ConductorType enum Represents
- the kind of a particular conductor:
- Single: singleline symbols, no text input
- Multi: text input, no symbol
- */
- enum ConductorType { Single, Multi };
+ /**
+ @brief The ConductorType enum Represents
+ the kind of a particular conductor:
+ Single: singleline symbols, no text input
+ Multi: text input, no symbol
+ */
+ enum ConductorType { Single, Multi };
- //Attributes
- ConductorType type;
+ //Attributes
+ ConductorType type;
- QColor
- color,
- m_color_2,
- text_color;
+ QColor
+ color,
+ m_color_2,
+ text_color;
- QString
- text,
- m_function,
- m_tension_protocol,
- m_wire_color,
- m_wire_section,
- m_formula,
- m_bus,
- m_cable;
+ QString
+ text,
+ m_function,
+ m_tension_protocol,
+ m_wire_color,
+ m_wire_section,
+ m_formula,
+ m_bus,
+ m_cable;
- int
- text_size,
- m_dash_size = 1;
+ int
+ text_size,
+ m_dash_size = 1;
- double
- cond_size,
- verti_rotate_text,
- horiz_rotate_text;
+ double
+ cond_size,
+ verti_rotate_text,
+ horiz_rotate_text;
- bool
- m_show_text,
- m_one_text_per_folio,
- m_bicolor = false;
+ bool
+ m_show_text,
+ m_one_text_per_folio,
+ m_bicolor = false;
- Qt::Alignment
- m_horizontal_alignment = Qt::AlignBottom,
- m_vertical_alignment = Qt::AlignRight;
+ Qt::Alignment
+ m_horizontal_alignment = Qt::AlignBottom,
+ m_vertical_alignment = Qt::AlignRight;
- Qt::PenStyle style;
+ Qt::PenStyle style;
- SingleLineProperties singleLineProperties;
+ SingleLineProperties singleLineProperties;
- // methods
- void toXml(QDomElement &) const;
- void fromXml(QDomElement &);
- void toSettings(QSettings &, const QString & = QString()) const;
- void fromSettings(QSettings &, const QString & = QString());
- static QString typeToString(ConductorType);
- void applyForEqualAttributes(QList list);
+ // methods
+ void toXml(QDomElement &) const;
+ void fromXml(QDomElement &);
+ void toSettings(QSettings &, const QString & = QString()) const;
+ void fromSettings(QSettings &, const QString & = QString());
+ static QString typeToString(ConductorType);
+ void applyForEqualAttributes(QList list);
- static ConductorProperties defaultProperties();
+ static ConductorProperties defaultProperties();
- // operators
- bool operator==(const ConductorProperties &) const;
- bool operator!=(const ConductorProperties &) const;
+ // operators
+ bool operator==(const ConductorProperties &) const;
+ bool operator!=(const ConductorProperties &) const;
- private:
- void readStyle(const QString &);
- QString writeStyle() const;
+ private:
+ void readStyle(const QString &);
+ QString writeStyle() const;
};
Q_DECLARE_METATYPE(ConductorProperties)
diff --git a/sources/diagram.cpp b/sources/diagram.cpp
index 5414c35bb..9b3e981ac 100644
--- a/sources/diagram.cpp
+++ b/sources/diagram.cpp
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#include
#include
@@ -51,2346 +51,2346 @@ int Diagram::yKeyGridFine = 1;
const qreal Diagram::margin = 5.0;
/**
- @brief Diagram::background_color
- static variable to keep track of present background color of the diagram.
+ @brief Diagram::background_color
+ static variable to keep track of present background color of the diagram.
*/
-QColor Diagram::background_color = Qt::white;
+QColor Diagram::background_color = Qt::white;
/**
- @brief Diagram::Diagram
- Constructor
- @param project : The project of this diagram and also parent QObject
+ @brief Diagram::Diagram
+ Constructor
+ @param project : The project of this diagram and also parent QObject
*/
Diagram::Diagram(QETProject *project) :
- QGraphicsScene (project),
- m_project (project),
- draw_grid_ (true),
- use_border_ (true),
- draw_terminals_ (true),
- draw_colored_conductors_ (true),
- m_event_interface (nullptr),
- m_freeze_new_elements (false),
- m_freeze_new_conductors_ (false)
+ QGraphicsScene (project),
+ m_project (project),
+ draw_grid_ (true),
+ use_border_ (true),
+ draw_terminals_ (true),
+ draw_colored_conductors_ (true),
+ m_event_interface (nullptr),
+ m_freeze_new_elements (false),
+ m_freeze_new_conductors_ (false)
{
- setItemIndexMethod(QGraphicsScene::NoIndex);
- /* Set to no index,
- * because they can be the source of the crash with conductor and shape ghost.
- * https://forum.qt.io/topic/71316/qgraphicsscenefinditembsptreevisitor-visit-crashes-due-to-an-obsolete-paintevent-after-qgraphicsscene-removeitem
- * https://stackoverflow.com/questions/38458830/crash-after-qgraphicssceneremoveitem-with-custom-item-class
- * http://www.qtcentre.org/archive/index.php/t-33730.html
- * http://tech-artists.org/t/qt-properly-removing-qgraphicitems/3063
- */
+ setItemIndexMethod(QGraphicsScene::NoIndex);
+ /* Set to no index,
+ * because they can be the source of the crash with conductor and shape ghost.
+ * https://forum.qt.io/topic/71316/qgraphicsscenefinditembsptreevisitor-visit-crashes-due-to-an-obsolete-paintevent-after-qgraphicsscene-removeitem
+ * https://stackoverflow.com/questions/38458830/crash-after-qgraphicssceneremoveitem-with-custom-item-class
+ * http://www.qtcentre.org/archive/index.php/t-33730.html
+ * http://tech-artists.org/t/qt-properly-removing-qgraphicitems/3063
+ */
- qgi_manager_ = new QGIManager(this);
- setBackgroundBrush(Qt::white);
- conductor_setter_ = new QGraphicsLineItem(nullptr);
- conductor_setter_ -> setZValue(1000000);
+ qgi_manager_ = new QGIManager(this);
+ setBackgroundBrush(Qt::white);
+ conductor_setter_ = new QGraphicsLineItem(nullptr);
+ conductor_setter_ -> setZValue(1000000);
- QPen pen(Qt::NoBrush, 1.5, Qt::DashLine);
- pen.setColor(Qt::black);
- conductor_setter_ -> setPen(pen);
+ QPen pen(Qt::NoBrush, 1.5, Qt::DashLine);
+ pen.setColor(Qt::black);
+ conductor_setter_ -> setPen(pen);
- connect(&border_and_titleblock,
- &BorderTitleBlock::needTitleBlockTemplate,
- this, &Diagram::setTitleBlockTemplate);
- connect(&border_and_titleblock,
- &BorderTitleBlock::diagramTitleChanged,
- this, &Diagram::titleChanged);
- connect(&border_and_titleblock,
- &BorderTitleBlock::titleBlockFolioChanged,
- this, &Diagram::titleChanged);
- connect(&border_and_titleblock,
- &BorderTitleBlock::borderChanged,
- this, &Diagram::adjustSceneRect);
- connect(&border_and_titleblock,
- &BorderTitleBlock::titleBlockFolioChanged,
- this, &Diagram::updateLabels);
- connect(this, &Diagram::diagramActivated,
- this, &Diagram::loadElmtFolioSeq);
- connect(this, &Diagram::diagramActivated,
- this, &Diagram::loadCndFolioSeq);
- adjustSceneRect();
+ connect(&border_and_titleblock,
+ &BorderTitleBlock::needTitleBlockTemplate,
+ this, &Diagram::setTitleBlockTemplate);
+ connect(&border_and_titleblock,
+ &BorderTitleBlock::diagramTitleChanged,
+ this, &Diagram::titleChanged);
+ connect(&border_and_titleblock,
+ &BorderTitleBlock::titleBlockFolioChanged,
+ this, &Diagram::titleChanged);
+ connect(&border_and_titleblock,
+ &BorderTitleBlock::borderChanged,
+ this, &Diagram::adjustSceneRect);
+ connect(&border_and_titleblock,
+ &BorderTitleBlock::titleBlockFolioChanged,
+ this, &Diagram::updateLabels);
+ connect(this, &Diagram::diagramActivated,
+ this, &Diagram::loadElmtFolioSeq);
+ connect(this, &Diagram::diagramActivated,
+ this, &Diagram::loadCndFolioSeq);
+ adjustSceneRect();
}
/**
- @brief Diagram::~Diagram
- Destructor
+ @brief Diagram::~Diagram
+ Destructor
*/
Diagram::~Diagram()
{
- //First clear every selection to close an hypothetical editor
- clearSelection();
- // clear undo stack to prevent errors,
- // because contains pointers to this diagram and is elements.
- undoStack().clear();
- //delete of QGIManager, every elements he knows are removed
- delete qgi_manager_;
- // remove of conductor setter
- delete conductor_setter_;
+ //First clear every selection to close an hypothetical editor
+ clearSelection();
+ // clear undo stack to prevent errors,
+ // because contains pointers to this diagram and is elements.
+ undoStack().clear();
+ //delete of QGIManager, every elements he knows are removed
+ delete qgi_manager_;
+ // remove of conductor setter
+ delete conductor_setter_;
- if (m_event_interface)
- delete m_event_interface;
+ if (m_event_interface)
+ delete m_event_interface;
- // list removable items
- QList deletable_items;
- for(QGraphicsItem *qgi : items())
- {
- if (qgi -> parentItem()) continue;
- if (qgraphicsitem_cast(qgi)) continue;
- deletable_items << qgi;
- }
+ // list removable items
+ QList deletable_items;
+ for(QGraphicsItem *qgi : items())
+ {
+ if (qgi -> parentItem()) continue;
+ if (qgraphicsitem_cast(qgi)) continue;
+ deletable_items << qgi;
+ }
- qDeleteAll (deletable_items);
+ qDeleteAll (deletable_items);
}
/**
- @brief Diagram::drawBackground
- Draw the background of the diagram, ie the grid.
- \~French Dessine l'arriere-plan du schema, cad la grille.
- \~ @param p :
- The QPainter to use for drawing
- \~French Le QPainter a utiliser pour dessiner
- \~ @param r :
- The rectangle of the area to be drawn
- \~French Le rectangle de la zone a dessiner
+ @brief Diagram::drawBackground
+ Draw the background of the diagram, ie the grid.
+ \~French Dessine l'arriere-plan du schema, cad la grille.
+ \~ @param p :
+ The QPainter to use for drawing
+ \~French Le QPainter a utiliser pour dessiner
+ \~ @param r :
+ The rectangle of the area to be drawn
+ \~French Le rectangle de la zone a dessiner
*/
void Diagram::drawBackground(QPainter *p, const QRectF &r) {
- p -> save();
+ p -> save();
- // disable all antialiasing, except for text
- // desactive tout antialiasing, sauf pour le texte
- p -> setRenderHint(QPainter::Antialiasing, false);
- p -> setRenderHint(QPainter::TextAntialiasing, true);
- p -> setRenderHint(QPainter::SmoothPixmapTransform, false);
+ // disable all antialiasing, except for text
+ // desactive tout antialiasing, sauf pour le texte
+ p -> setRenderHint(QPainter::Antialiasing, false);
+ p -> setRenderHint(QPainter::TextAntialiasing, true);
+ p -> setRenderHint(QPainter::SmoothPixmapTransform, false);
- // draw a white background
- // dessine un fond blanc
- p -> setPen(Qt::NoPen);
- //set brush color to present background color.
- p -> setBrush(Diagram::background_color);
- p -> drawRect(r);
+ // draw a white background
+ // dessine un fond blanc
+ p -> setPen(Qt::NoPen);
+ //set brush color to present background color.
+ p -> setBrush(Diagram::background_color);
+ p -> drawRect(r);
- if (draw_grid_) {
- /* Draw the point of the grid
- * if background color is black,
- * then grid spots shall be white,
- * else they shall be black in color.
- */
- QPen pen;
- Diagram::background_color == Qt::black? pen.setColor(Qt::white)
- : pen.setColor(Qt::black);
- pen.setCosmetic(true);
- p->setPen(pen);
+ if (draw_grid_) {
+ /* Draw the point of the grid
+ * if background color is black,
+ * then grid spots shall be white,
+ * else they shall be black in color.
+ */
+ QPen pen;
+ Diagram::background_color == Qt::black? pen.setColor(Qt::white)
+ : pen.setColor(Qt::black);
+ pen.setCosmetic(true);
+ p->setPen(pen);
- p -> setBrush(Qt::NoBrush);
+ p -> setBrush(Qt::NoBrush);
- // If user allow zoom out beyond of folio,
- // we draw grid outside of border.
- QSettings settings;
- int xGrid = settings.value("diagrameditor/Xgrid",
- Diagram::xGrid).toInt();
- int yGrid = settings.value("diagrameditor/Ygrid",
- Diagram::yGrid).toInt();
- QRectF rect = settings.value(
- "diagrameditor/zoom-out-beyond-of-folio",
- false).toBool() ? r
- : border_and_titleblock
- .insideBorderRect()
- .intersected(r);
+ // If user allow zoom out beyond of folio,
+ // we draw grid outside of border.
+ QSettings settings;
+ int xGrid = settings.value("diagrameditor/Xgrid",
+ Diagram::xGrid).toInt();
+ int yGrid = settings.value("diagrameditor/Ygrid",
+ Diagram::yGrid).toInt();
+ QRectF rect = settings.value(
+ "diagrameditor/zoom-out-beyond-of-folio",
+ false).toBool() ? r
+ : border_and_titleblock
+ .insideBorderRect()
+ .intersected(r);
- qreal limite_x = rect.x() + rect.width();
- qreal limite_y = rect.y() + rect.height();
+ qreal limite_x = rect.x() + rect.width();
+ qreal limite_y = rect.y() + rect.height();
- int g_x = (int)ceil(rect.x());
- while (g_x % xGrid) ++ g_x;
- int g_y = (int)ceil(rect.y());
- while (g_y % yGrid) ++ g_y;
+ int g_x = (int)ceil(rect.x());
+ while (g_x % xGrid) ++ g_x;
+ int g_y = (int)ceil(rect.y());
+ while (g_y % yGrid) ++ g_y;
- QPolygon points;
- for (int gx = g_x ; gx < limite_x ; gx += xGrid) {
- for (int gy = g_y ; gy < limite_y ; gy += yGrid) {
- points << QPoint(gx, gy);
- }
- }
- p -> drawPoints(points);
- }
+ QPolygon points;
+ for (int gx = g_x ; gx < limite_x ; gx += xGrid) {
+ for (int gy = g_y ; gy < limite_y ; gy += yGrid) {
+ points << QPoint(gx, gy);
+ }
+ }
+ p -> drawPoints(points);
+ }
- if (use_border_) border_and_titleblock.draw(p);
- p -> restore();
+ if (use_border_) border_and_titleblock.draw(p);
+ p -> restore();
}
/**
- @brief Diagram::mouseDoubleClickEvent
- This event is managed by diagram event interface if any.
- @param event :
+ @brief Diagram::mouseDoubleClickEvent
+ This event is managed by diagram event interface if any.
+ @param event :
*/
void Diagram::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
- event->setAccepted(false);
+ event->setAccepted(false);
- if (m_event_interface) {
- m_event_interface->mouseDoubleClickEvent(event);
- if (event->isAccepted()) {
- return;
- }
- }
+ if (m_event_interface) {
+ m_event_interface->mouseDoubleClickEvent(event);
+ if (event->isAccepted()) {
+ return;
+ }
+ }
- QGraphicsScene::mouseDoubleClickEvent(event);
+ QGraphicsScene::mouseDoubleClickEvent(event);
}
/**
- @brief Diagram::mousePressEvent
- This event is managed by diagram event interface if any.
- @param event
+ @brief Diagram::mousePressEvent
+ This event is managed by diagram event interface if any.
+ @param event
*/
void Diagram::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
- event->setAccepted(false);
+ event->setAccepted(false);
- if (m_event_interface) {
- m_event_interface->mousePressEvent(event);
- if (event->isAccepted()) {
- return;
- }
- }
+ if (m_event_interface) {
+ m_event_interface->mousePressEvent(event);
+ if (event->isAccepted()) {
+ return;
+ }
+ }
- QGraphicsScene::mousePressEvent(event);
+ QGraphicsScene::mousePressEvent(event);
}
/**
- @brief Diagram::mouseMoveEvent
- This event is managed by diagram event interface if any.
- @param event
+ @brief Diagram::mouseMoveEvent
+ This event is managed by diagram event interface if any.
+ @param event
*/
void Diagram::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
- event->setAccepted(false);
+ event->setAccepted(false);
- if (m_event_interface) {
- m_event_interface->mouseMoveEvent(event);
- if (event->isAccepted()) {
- return;
- }
- }
+ if (m_event_interface) {
+ m_event_interface->mouseMoveEvent(event);
+ if (event->isAccepted()) {
+ return;
+ }
+ }
- QGraphicsScene::mouseMoveEvent(event);
+ QGraphicsScene::mouseMoveEvent(event);
}
/**
- @brief Diagram::mouseReleaseEvent
- This event is managed by diagram event interface if any.
- @param event
+ @brief Diagram::mouseReleaseEvent
+ This event is managed by diagram event interface if any.
+ @param event
*/
void Diagram::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
- event->setAccepted(false);
+ event->setAccepted(false);
- if (m_event_interface) {
- m_event_interface->mouseReleaseEvent(event);
- if (event->isAccepted()) {
- return;
- }
- }
+ if (m_event_interface) {
+ m_event_interface->mouseReleaseEvent(event);
+ if (event->isAccepted()) {
+ return;
+ }
+ }
- QGraphicsScene::mouseReleaseEvent(event);
+ QGraphicsScene::mouseReleaseEvent(event);
}
/**
- @brief Diagram::wheelEvent
- This event is managed by diagram event interface if any.
- @param event
+ @brief Diagram::wheelEvent
+ This event is managed by diagram event interface if any.
+ @param event
*/
void Diagram::wheelEvent(QGraphicsSceneWheelEvent *event)
{
- event->setAccepted(false);
+ event->setAccepted(false);
- if (m_event_interface) {
- m_event_interface->wheelEvent(event);
- if (event->isAccepted()) {
- return;
- }
- }
+ if (m_event_interface) {
+ m_event_interface->wheelEvent(event);
+ if (event->isAccepted()) {
+ return;
+ }
+ }
- QGraphicsScene::wheelEvent(event);
+ QGraphicsScene::wheelEvent(event);
}
/**
- @brief Diagram::keyPressEvent
- This event is managed by diagram event interface if any.
- Else move selected elements
- @param event
+ @brief Diagram::keyPressEvent
+ This event is managed by diagram event interface if any.
+ Else move selected elements
+ @param event
*/
void Diagram::keyPressEvent(QKeyEvent *event)
{
- QSettings settings;
- int xKeyGrid = settings.value("diagrameditor/key_Xgrid",
- Diagram::xKeyGrid).toInt();
- int yKeyGrid = settings.value("diagrameditor/key_Ygrid",
- Diagram::yKeyGrid).toInt();
- int xKeyGridFine = settings.value("diagrameditor/key_fine_Xgrid",
- Diagram::xKeyGridFine).toInt();
- int yKeyGridFine = settings.value("diagrameditor/key_fine_Ygrid",
- Diagram::yKeyGridFine).toInt();
- event->setAccepted(false);
+ QSettings settings;
+ int xKeyGrid = settings.value("diagrameditor/key_Xgrid",
+ Diagram::xKeyGrid).toInt();
+ int yKeyGrid = settings.value("diagrameditor/key_Ygrid",
+ Diagram::yKeyGrid).toInt();
+ int xKeyGridFine = settings.value("diagrameditor/key_fine_Xgrid",
+ Diagram::xKeyGridFine).toInt();
+ int yKeyGridFine = settings.value("diagrameditor/key_fine_Ygrid",
+ Diagram::yKeyGridFine).toInt();
+ event->setAccepted(false);
- if (m_event_interface) {
- m_event_interface->keyPressEvent(event);
- if (event->isAccepted()) {
- return;
- }
- }
+ if (m_event_interface) {
+ m_event_interface->keyPressEvent(event);
+ if (event->isAccepted()) {
+ return;
+ }
+ }
- if (isReadOnly()) return;
+ if (isReadOnly()) return;
- QPointF movement;
- qreal top_position = 0;
- qreal left_position = 0;
- DiagramContent dc(this);
- if (dc.items(DiagramContent::All).isEmpty())
- {
- event->ignore();
- QGraphicsScene::keyPressEvent(event);
- return;
- }
+ QPointF movement;
+ qreal top_position = 0;
+ qreal left_position = 0;
+ DiagramContent dc(this);
+ if (dc.items(DiagramContent::All).isEmpty())
+ {
+ event->ignore();
+ QGraphicsScene::keyPressEvent(event);
+ return;
+ }
#if TODO_LIST
#pragma message("@TODO move code to new function")
#endif
- //Move item with the keyboard arrow
- if(event->modifiers() == Qt::NoModifier)
- {
- switch(event->key())
- {
- case Qt::Key_Left:
- for (Element *item : dc.m_elements)
- {
- left_position = item->sceneBoundingRect().x();
- if(left_position <= 5)
- return;
- }
- movement = QPointF(-xKeyGrid, 0.0);
- break;
- case Qt::Key_Right:
- movement = QPointF(+xKeyGrid, 0.0);
- break;
- case Qt::Key_Up:
- for(Element *item : dc.m_elements)
- {
- top_position = item->sceneBoundingRect().y();
- if(top_position <= 5)
- return;
- }
- movement = QPointF(0.0, -yKeyGrid);
- break;
- case Qt::Key_Down:
- movement = QPointF(0.0, +yKeyGrid);
- break;
- }
+ //Move item with the keyboard arrow
+ if(event->modifiers() == Qt::NoModifier)
+ {
+ switch(event->key())
+ {
+ case Qt::Key_Left:
+ for (Element *item : dc.m_elements)
+ {
+ left_position = item->sceneBoundingRect().x();
+ if(left_position <= 5)
+ return;
+ }
+ movement = QPointF(-xKeyGrid, 0.0);
+ break;
+ case Qt::Key_Right:
+ movement = QPointF(+xKeyGrid, 0.0);
+ break;
+ case Qt::Key_Up:
+ for(Element *item : dc.m_elements)
+ {
+ top_position = item->sceneBoundingRect().y();
+ if(top_position <= 5)
+ return;
+ }
+ movement = QPointF(0.0, -yKeyGrid);
+ break;
+ case Qt::Key_Down:
+ movement = QPointF(0.0, +yKeyGrid);
+ break;
+ }
- if (!movement.isNull() && !focusItem())
- {
- m_elements_mover.beginMovement(this);
- m_elements_mover.continueMovement(movement);
- event->accept();
- return;
- }
- }
- else if(event->modifiers() == Qt::AltModifier)
- {
- switch(event->key())
- {
- case Qt::Key_Left:
- for (Element *item : dc.m_elements)
- {
- left_position = item->sceneBoundingRect().x();
- if(left_position <= 5)
- return;
- }
- movement = QPointF(-xKeyGridFine, 0.0);
- break;
- case Qt::Key_Right:
- movement = QPointF(+xKeyGridFine, 0.0);
- break;
- case Qt::Key_Up:
- for(Element *item : dc.m_elements)
- {
- top_position = item->sceneBoundingRect().y();
- if(top_position <= 5)
- return;
- }
- movement = QPointF(0.0, -yKeyGridFine);
- break;
- case Qt::Key_Down:
- movement = QPointF(0.0, +yKeyGridFine);
- break;
- }
+ if (!movement.isNull() && !focusItem())
+ {
+ m_elements_mover.beginMovement(this);
+ m_elements_mover.continueMovement(movement);
+ event->accept();
+ return;
+ }
+ }
+ else if(event->modifiers() == Qt::AltModifier)
+ {
+ switch(event->key())
+ {
+ case Qt::Key_Left:
+ for (Element *item : dc.m_elements)
+ {
+ left_position = item->sceneBoundingRect().x();
+ if(left_position <= 5)
+ return;
+ }
+ movement = QPointF(-xKeyGridFine, 0.0);
+ break;
+ case Qt::Key_Right:
+ movement = QPointF(+xKeyGridFine, 0.0);
+ break;
+ case Qt::Key_Up:
+ for(Element *item : dc.m_elements)
+ {
+ top_position = item->sceneBoundingRect().y();
+ if(top_position <= 5)
+ return;
+ }
+ movement = QPointF(0.0, -yKeyGridFine);
+ break;
+ case Qt::Key_Down:
+ movement = QPointF(0.0, +yKeyGridFine);
+ break;
+ }
- if (!movement.isNull() && !focusItem())
- {
- m_elements_mover.beginMovement(this);
- m_elements_mover.continueMovement(movement);
- event->accept();
- return;
- }
- }
- else if(event->modifiers() == Qt::ControlModifier)
- {
- //Adjust the alignment of a texts group
- if(selectedItems().size() == 1
- && selectedItems().first()->type()
- == QGraphicsItemGroup::Type)
- {
- if(ElementTextItemGroup *etig =
- dynamic_cast
- (selectedItems().first()))
- {
- if(event->key() == Qt::Key_Left
- && etig->alignment() != Qt::AlignLeft)
- undoStack().push(
- new AlignmentTextsGroupCommand(
- etig,
- Qt::AlignLeft));
+ if (!movement.isNull() && !focusItem())
+ {
+ m_elements_mover.beginMovement(this);
+ m_elements_mover.continueMovement(movement);
+ event->accept();
+ return;
+ }
+ }
+ else if(event->modifiers() == Qt::ControlModifier)
+ {
+ //Adjust the alignment of a texts group
+ if(selectedItems().size() == 1
+ && selectedItems().first()->type()
+ == QGraphicsItemGroup::Type)
+ {
+ if(ElementTextItemGroup *etig =
+ dynamic_cast
+ (selectedItems().first()))
+ {
+ if(event->key() == Qt::Key_Left
+ && etig->alignment() != Qt::AlignLeft)
+ undoStack().push(
+ new AlignmentTextsGroupCommand(
+ etig,
+ Qt::AlignLeft));
- else if (event->key() == Qt::Key_Up
- && etig->alignment() != Qt::AlignVCenter)
- undoStack().push(
- new AlignmentTextsGroupCommand(
- etig,
- Qt::AlignVCenter));
+ else if (event->key() == Qt::Key_Up
+ && etig->alignment() != Qt::AlignVCenter)
+ undoStack().push(
+ new AlignmentTextsGroupCommand(
+ etig,
+ Qt::AlignVCenter));
- else if (event->key() == Qt::Key_Right
- && etig->alignment() != Qt::AlignRight)
- undoStack().push(
- new AlignmentTextsGroupCommand(
- etig,
- Qt::AlignRight));
- }
- }
- }
- event->ignore();
- QGraphicsScene::keyPressEvent(event);
+ else if (event->key() == Qt::Key_Right
+ && etig->alignment() != Qt::AlignRight)
+ undoStack().push(
+ new AlignmentTextsGroupCommand(
+ etig,
+ Qt::AlignRight));
+ }
+ }
+ }
+ event->ignore();
+ QGraphicsScene::keyPressEvent(event);
}
/**
- @brief Diagram::keyReleaseEvent
- This event is managed by diagram event interface if any.
- Else move selected element
- @param e
+ @brief Diagram::keyReleaseEvent
+ This event is managed by diagram event interface if any.
+ Else move selected element
+ @param e
*/
void Diagram::keyReleaseEvent(QKeyEvent *e)
{
- e->setAccepted(false);
+ e->setAccepted(false);
- if (m_event_interface) {
- m_event_interface->keyReleaseEvent(e);
- if (e->isAccepted()) {
- return;
- }
- }
+ if (m_event_interface) {
+ m_event_interface->keyReleaseEvent(e);
+ if (e->isAccepted()) {
+ return;
+ }
+ }
- bool transmit_event = true;
- if (!isReadOnly()) {
- /* detects the release of a direction key
- * (= movement of elements)
- * detecte le relachement d'une touche de direction
- * ( = deplacement d'elements)
- */
- if (
- (
- e -> key() == Qt::Key_Left
- || e -> key() == Qt::Key_Right
- || e -> key() == Qt::Key_Up
- || e -> key() == Qt::Key_Down
- ) && !e -> isAutoRepeat()
- ) {
- m_elements_mover.endMovement();
- e -> accept();
- transmit_event = false;
- }
- }
- if (transmit_event) {
- QGraphicsScene::keyReleaseEvent(e);
- }
+ bool transmit_event = true;
+ if (!isReadOnly()) {
+ /* detects the release of a direction key
+ * (= movement of elements)
+ * detecte le relachement d'une touche de direction
+ * ( = deplacement d'elements)
+ */
+ if (
+ (
+ e -> key() == Qt::Key_Left
+ || e -> key() == Qt::Key_Right
+ || e -> key() == Qt::Key_Up
+ || e -> key() == Qt::Key_Down
+ ) && !e -> isAutoRepeat()
+ ) {
+ m_elements_mover.endMovement();
+ e -> accept();
+ transmit_event = false;
+ }
+ }
+ if (transmit_event) {
+ QGraphicsScene::keyReleaseEvent(e);
+ }
}
/**
- @brief Diagram::uuid
- @return the uuid of this diagram
+ @brief Diagram::uuid
+ @return the uuid of this diagram
*/
QUuid Diagram::uuid()
{
- return m_uuid;
+ return m_uuid;
}
/**
- @brief Diagram::setEventInterface
- Set event_interface has current interface.
- Diagram become the ownership of event_interface
- If there is a previous interface, they will be delete before
- and call init() to the new interface.
- @param event_interface
+ @brief Diagram::setEventInterface
+ Set event_interface has current interface.
+ Diagram become the ownership of event_interface
+ If there is a previous interface, they will be delete before
+ and call init() to the new interface.
+ @param event_interface
*/
void Diagram::setEventInterface(DiagramEventInterface *event_interface)
{
- if (m_event_interface)
- {
- delete m_event_interface;
- event_interface -> init();
- }
- m_event_interface = event_interface;
+ if (m_event_interface)
+ {
+ delete m_event_interface;
+ event_interface -> init();
+ }
+ m_event_interface = event_interface;
- connect(m_event_interface, &DiagramEventInterface::finish, [this]()
- {
- delete this->m_event_interface;
- this->m_event_interface = nullptr;
- });
+ connect(m_event_interface, &DiagramEventInterface::finish, [this]()
+ {
+ delete this->m_event_interface;
+ this->m_event_interface = nullptr;
+ });
}
/**
- @brief Diagram::clearEventInterface
- Clear the current event interface.
+ @brief Diagram::clearEventInterface
+ Clear the current event interface.
*/
void Diagram::clearEventInterface()
{
- if(m_event_interface)
- {
- delete m_event_interface;
- m_event_interface = nullptr;
- }
+ if(m_event_interface)
+ {
+ delete m_event_interface;
+ m_event_interface = nullptr;
+ }
}
/**
- @brief Diagram::conductorsAutonumName
- @return the name of autonum to use.
+ @brief Diagram::conductorsAutonumName
+ @return the name of autonum to use.
*/
QString Diagram::conductorsAutonumName() const
{
- return m_conductors_autonum_name;
+ return m_conductors_autonum_name;
}
/**
- @brief Diagram::setConductorsAutonumName
- @param name : name of autonum to use.
+ @brief Diagram::setConductorsAutonumName
+ @param name : name of autonum to use.
*/
void Diagram::setConductorsAutonumName(const QString &name) {
- m_conductors_autonum_name= name;
+ m_conductors_autonum_name= name;
}
/**
- Exporte le schema vers une image
- @return Une QImage representant le schema
+ Exporte le schema vers une image
+ @return Une QImage representant le schema
*/
bool Diagram::toPaintDevice(QPaintDevice &pix,
- int width,
- int height,
- Qt::AspectRatioMode aspectRatioMode) {
- // determine the source area = schema content + margins
- // determine la zone source = contenu du schema + marges
- QRectF source_area;
- if (!use_border_) {
- source_area = itemsBoundingRect();
- source_area.translate(-margin, -margin);
- source_area.setWidth (source_area.width () + 2.0 * margin);
- source_area.setHeight(source_area.height() + 2.0 * margin);
- } else {
- source_area = QRectF(
- 0.0,
- 0.0,
- border_and_titleblock.borderAndTitleBlockRect().width()
- + 2.0 * margin,
- border_and_titleblock.borderAndTitleBlockRect().height()
- + 2.0 * margin
- );
- }
+ int width,
+ int height,
+ Qt::AspectRatioMode aspectRatioMode) {
+ // determine the source area = schema content + margins
+ // determine la zone source = contenu du schema + marges
+ QRectF source_area;
+ if (!use_border_) {
+ source_area = itemsBoundingRect();
+ source_area.translate(-margin, -margin);
+ source_area.setWidth (source_area.width () + 2.0 * margin);
+ source_area.setHeight(source_area.height() + 2.0 * margin);
+ } else {
+ source_area = QRectF(
+ 0.0,
+ 0.0,
+ border_and_titleblock.borderAndTitleBlockRect().width()
+ + 2.0 * margin,
+ border_and_titleblock.borderAndTitleBlockRect().height()
+ + 2.0 * margin
+ );
+ }
- /* if the dimensions are not specified,
- * the image is exported at 1: 1 scale
- * si les dimensions ne sont pas precisees,
- * l'image est exportee a l'echelle 1:1
- */
- QSize image_size = (width == -1 && height == -1)
- ? source_area.size().toSize() : QSize(width, height);
+ /* if the dimensions are not specified,
+ * the image is exported at 1: 1 scale
+ * si les dimensions ne sont pas precisees,
+ * l'image est exportee a l'echelle 1:1
+ */
+ QSize image_size = (width == -1 && height == -1)
+ ? source_area.size().toSize() : QSize(width, height);
- // prepare the rendering
- // prepare le rendu
- QPainter p;
- if (!p.begin(&pix)) return(false);
+ // prepare the rendering
+ // prepare le rendu
+ QPainter p;
+ if (!p.begin(&pix)) return(false);
- // anti-aliasis rendering
- // rendu antialiase
- p.setRenderHint(QPainter::Antialiasing, true);
- p.setRenderHint(QPainter::TextAntialiasing, true);
- p.setRenderHint(QPainter::SmoothPixmapTransform, true);
+ // anti-aliasis rendering
+ // rendu antialiase
+ p.setRenderHint(QPainter::Antialiasing, true);
+ p.setRenderHint(QPainter::TextAntialiasing, true);
+ p.setRenderHint(QPainter::SmoothPixmapTransform, true);
- // deselect all elements
- // deselectionne tous les elements
- QList selected_elmts = selectedItems();
- foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(false);
+ // deselect all elements
+ // deselectionne tous les elements
+ QList selected_elmts = selectedItems();
+ foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(false);
- // renders itself
- // effectue le rendu lui-meme
- render(&p,
- QRect(QPoint(0, 0),image_size),
- source_area,
- aspectRatioMode);
- p.end();
+ // renders itself
+ // effectue le rendu lui-meme
+ render(&p,
+ QRect(QPoint(0, 0),image_size),
+ source_area,
+ aspectRatioMode);
+ p.end();
- // restore selected items
- // restaure les elements selectionnes
- foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(true);
+ // restore selected items
+ // restaure les elements selectionnes
+ foreach (QGraphicsItem *qgi, selected_elmts) qgi -> setSelected(true);
- return(true);
+ return(true);
}
/**
- @brief Diagram::imageSize
- Allows you to know the dimensions
- that the image generated by the toImage() method will have
- \~French Permet de connaitre les dimensions
- qu'aura l'image generee par la methode toImage()
- \~ @return The size of the image generated by toImage()
- \~French La taille de l'image generee par toImage()
+ @brief Diagram::imageSize
+ Allows you to know the dimensions
+ that the image generated by the toImage() method will have
+ \~French Permet de connaitre les dimensions
+ qu'aura l'image generee par la methode toImage()
+ \~ @return The size of the image generated by toImage()
+ \~French La taille de l'image generee par toImage()
*/
QSize Diagram::imageSize() const
{
- // determine la zone source = contenu du schema + marges
- qreal image_width, image_height;
- if (!use_border_) {
- QRectF items_rect = itemsBoundingRect();
- image_width = items_rect.width();
- image_height = items_rect.height();
- } else {
- image_width = border_and_titleblock
- .borderAndTitleBlockRect().width();
- image_height = border_and_titleblock
- .borderAndTitleBlockRect().height();
- }
+ // determine la zone source = contenu du schema + marges
+ qreal image_width, image_height;
+ if (!use_border_) {
+ QRectF items_rect = itemsBoundingRect();
+ image_width = items_rect.width();
+ image_height = items_rect.height();
+ } else {
+ image_width = border_and_titleblock
+ .borderAndTitleBlockRect().width();
+ image_height = border_and_titleblock
+ .borderAndTitleBlockRect().height();
+ }
- image_width += 2.0 * margin;
- image_height += 2.0 * margin;
+ image_width += 2.0 * margin;
+ image_height += 2.0 * margin;
- // returns the size of the source area
- // renvoie la taille de la zone source
- return(QSizeF(image_width, image_height).toSize());
+ // returns the size of the source area
+ // renvoie la taille de la zone source
+ return(QSizeF(image_width, image_height).toSize());
}
/**
- @brief Diagram::isEmpty
- An empty schema contains no element, conductor, or text field
- @return true if the schema is considered empty, false otherwise.
- \~French true si le schema est considere comme vide, false sinon.
- Un schema vide ne contient ni element, ni conducteur, ni champ de texte
+ @brief Diagram::isEmpty
+ An empty schema contains no element, conductor, or text field
+ @return true if the schema is considered empty, false otherwise.
+ \~French true si le schema est considere comme vide, false sinon.
+ Un schema vide ne contient ni element, ni conducteur, ni champ de texte
*/
bool Diagram::isEmpty() const
{
- return(!items().count());
+ return(!items().count());
}
/**
- @brief Diagram::potential
- @return all potential in the diagram
- each potential are in the QList
- and each conductors of one potential are in the QSet
+ @brief Diagram::potential
+ @return all potential in the diagram
+ each potential are in the QList
+ and each conductors of one potential are in the QSet
*/
QList < QSet > Diagram::potentials()
{
- QList < QSet > potential_List;
- if (content().conductors().size() == 0)
- return (potential_List); //return an empty potential
- QList conductors_list = content().conductors();
+ QList < QSet > potential_List;
+ if (content().conductors().size() == 0)
+ return (potential_List); //return an empty potential
+ QList conductors_list = content().conductors();
- do {
- QSet one_potential =
- conductors_list.first()
- -> relatedPotentialConductors();
- one_potential << conductors_list.takeFirst();
- foreach (Conductor *c, one_potential)
- conductors_list.removeOne(c);
- potential_List << one_potential;
- } while (!conductors_list.empty());
+ do {
+ QSet one_potential =
+ conductors_list.first()
+ -> relatedPotentialConductors();
+ one_potential << conductors_list.takeFirst();
+ foreach (Conductor *c, one_potential)
+ conductors_list.removeOne(c);
+ potential_List << one_potential;
+ } while (!conductors_list.empty());
- return (potential_List);
+ return (potential_List);
}
/**
- @brief Diagram::toXml
- Exports all or part of the schema
- \~French Exporte tout ou partie du schema
- \~ @param whole_content :
- Boolean (to true by default) indicating if the generated XML must
- represent the entire schema or only the selected content
- \~French Booleen (a vrai par defaut) indiquant si le XML genere doit
- representer l'integralite du schema ou seulement le contenu selectionne
- \~ @return An XML Document (QDomDocument)
- \~French Un Document XML (QDomDocument)
+ @brief Diagram::toXml
+ Exports all or part of the schema
+ \~French Exporte tout ou partie du schema
+ \~ @param whole_content :
+ Boolean (to true by default) indicating if the generated XML must
+ represent the entire schema or only the selected content
+ \~French Booleen (a vrai par defaut) indiquant si le XML genere doit
+ representer l'integralite du schema ou seulement le contenu selectionne
+ \~ @return An XML Document (QDomDocument)
+ \~French Un Document XML (QDomDocument)
*/
QDomDocument Diagram::toXml(bool whole_content) {
- // document
- QDomDocument document;
+ // document
+ QDomDocument document;
- // XML tree root
- // racine de l'arbre XML
- auto dom_root = document.createElement("diagram");
+ // XML tree root
+ // racine de l'arbre XML
+ auto dom_root = document.createElement("diagram");
- // schema properties
- // proprietes du schema
- if (whole_content) {
- border_and_titleblock.titleBlockToXml(dom_root);
- border_and_titleblock.borderToXml(dom_root);
+ // schema properties
+ // proprietes du schema
+ if (whole_content) {
+ border_and_titleblock.titleBlockToXml(dom_root);
+ border_and_titleblock.borderToXml(dom_root);
- // Default conductor properties
- QDomElement default_conductor =
- document.createElement("defaultconductor");
- defaultConductorProperties.toXml(default_conductor);
- dom_root.appendChild(default_conductor);
+ // Default conductor properties
+ QDomElement default_conductor =
+ document.createElement("defaultconductor");
+ defaultConductorProperties.toXml(default_conductor);
+ dom_root.appendChild(default_conductor);
- // Conductor autonum
- if (!m_conductors_autonum_name.isEmpty()) {
- dom_root.setAttribute("conductorAutonum",
- m_conductors_autonum_name);
- }
+ // Conductor autonum
+ if (!m_conductors_autonum_name.isEmpty()) {
+ dom_root.setAttribute("conductorAutonum",
+ m_conductors_autonum_name);
+ }
- //Default New Element
- dom_root.setAttribute("freezeNewElement",
- m_freeze_new_elements ? "true" : "false");
+ //Default New Element
+ dom_root.setAttribute("freezeNewElement",
+ m_freeze_new_elements ? "true" : "false");
- //Default New Conductor
- dom_root.setAttribute("freezeNewConductor",
- m_freeze_new_conductors_
- ? "true" : "false");
+ //Default New Conductor
+ dom_root.setAttribute("freezeNewConductor",
+ m_freeze_new_conductors_
+ ? "true" : "false");
- //Element Folio Sequential Variables
- if (!m_elmt_unitfolio_max.isEmpty()
- || !m_elmt_tenfolio_max.isEmpty()
- || !m_elmt_hundredfolio_max.isEmpty()) {
- QDomElement elmtfoliosequential =
- document.createElement(
- "elementautonumfoliosequentials");
- if (!m_elmt_unitfolio_max.isEmpty()) {
- QDomElement elmtfolioseq =
- document.createElement(
- "elementunitfolioseq");
- folioSequentialsToXml(&m_elmt_unitfolio_max,
- &elmtfolioseq,
- "sequf_",
- "unitfolioseq",
- &document);
- elmtfoliosequential.appendChild(elmtfolioseq);
- }
- if (!m_elmt_tenfolio_max.isEmpty()) {
- QDomElement elmtfolioseq =
- document.createElement(
- "elementtenfolioseq");
- folioSequentialsToXml(&m_elmt_tenfolio_max,
- &elmtfolioseq,
- "seqtf_",
- "tenfolioseq",
- &document);
- elmtfoliosequential.appendChild(elmtfolioseq);
- }
- if (!m_elmt_hundredfolio_max.isEmpty()) {
- QDomElement elmtfolioseq =
- document.createElement(
- "elementhundredfolioseq");
- folioSequentialsToXml(&m_elmt_hundredfolio_max,
- &elmtfolioseq,
- "seqhf_",
- "hundredfolioseq",
- &document);
- elmtfoliosequential.appendChild(elmtfolioseq);
- }
- dom_root.appendChild(elmtfoliosequential);
- }
- // Conductor Folio Sequential Variables
- if (!m_cnd_unitfolio_max.isEmpty()
- || !m_cnd_tenfolio_max.isEmpty() ||
- !m_cnd_hundredfolio_max.isEmpty()) {
- QDomElement cndfoliosequential =
- document.createElement(
- "conductorautonumfoliosequentials");
- QHash::iterator i;
- if (!m_cnd_unitfolio_max.isEmpty()) {
- QDomElement cndfolioseq =
- document.createElement(
- "conductorunitfolioseq");
- folioSequentialsToXml(&m_cnd_unitfolio_max,
- &cndfolioseq,
- "sequf_",
- "unitfolioseq",
- &document);
- cndfoliosequential.appendChild(cndfolioseq);
- }
- if (!m_cnd_tenfolio_max.isEmpty()) {
- QDomElement cndfolioseq =
- document.createElement(
- "conductortenfolioseq");
- folioSequentialsToXml(&m_cnd_tenfolio_max,
- &cndfolioseq,
- "seqtf_",
- "tenfolioseq",
- &document);
- cndfoliosequential.appendChild(cndfolioseq);
- }
- if (!m_cnd_hundredfolio_max.isEmpty()) {
- QDomElement cndfolioseq =
- document.createElement(
- "conductorhundredfolioseq");
- folioSequentialsToXml(&m_cnd_hundredfolio_max,
- &cndfolioseq,
- "seqhf_",
- "hundredfolioseq",
- &document);
- cndfoliosequential.appendChild(cndfolioseq);
- }
- dom_root.appendChild(cndfoliosequential);
- }
- }
- else {
- //this method with whole_content to false,
- //is often use to copy and paste the current selection
- //so we add the id of the project where copy occur.
- dom_root.setAttribute("projectId", QETApp::projectId(m_project));
- }
- document.appendChild(dom_root);
+ //Element Folio Sequential Variables
+ if (!m_elmt_unitfolio_max.isEmpty()
+ || !m_elmt_tenfolio_max.isEmpty()
+ || !m_elmt_hundredfolio_max.isEmpty()) {
+ QDomElement elmtfoliosequential =
+ document.createElement(
+ "elementautonumfoliosequentials");
+ if (!m_elmt_unitfolio_max.isEmpty()) {
+ QDomElement elmtfolioseq =
+ document.createElement(
+ "elementunitfolioseq");
+ folioSequentialsToXml(&m_elmt_unitfolio_max,
+ &elmtfolioseq,
+ "sequf_",
+ "unitfolioseq",
+ &document);
+ elmtfoliosequential.appendChild(elmtfolioseq);
+ }
+ if (!m_elmt_tenfolio_max.isEmpty()) {
+ QDomElement elmtfolioseq =
+ document.createElement(
+ "elementtenfolioseq");
+ folioSequentialsToXml(&m_elmt_tenfolio_max,
+ &elmtfolioseq,
+ "seqtf_",
+ "tenfolioseq",
+ &document);
+ elmtfoliosequential.appendChild(elmtfolioseq);
+ }
+ if (!m_elmt_hundredfolio_max.isEmpty()) {
+ QDomElement elmtfolioseq =
+ document.createElement(
+ "elementhundredfolioseq");
+ folioSequentialsToXml(&m_elmt_hundredfolio_max,
+ &elmtfolioseq,
+ "seqhf_",
+ "hundredfolioseq",
+ &document);
+ elmtfoliosequential.appendChild(elmtfolioseq);
+ }
+ dom_root.appendChild(elmtfoliosequential);
+ }
+ // Conductor Folio Sequential Variables
+ if (!m_cnd_unitfolio_max.isEmpty()
+ || !m_cnd_tenfolio_max.isEmpty() ||
+ !m_cnd_hundredfolio_max.isEmpty()) {
+ QDomElement cndfoliosequential =
+ document.createElement(
+ "conductorautonumfoliosequentials");
+ QHash::iterator i;
+ if (!m_cnd_unitfolio_max.isEmpty()) {
+ QDomElement cndfolioseq =
+ document.createElement(
+ "conductorunitfolioseq");
+ folioSequentialsToXml(&m_cnd_unitfolio_max,
+ &cndfolioseq,
+ "sequf_",
+ "unitfolioseq",
+ &document);
+ cndfoliosequential.appendChild(cndfolioseq);
+ }
+ if (!m_cnd_tenfolio_max.isEmpty()) {
+ QDomElement cndfolioseq =
+ document.createElement(
+ "conductortenfolioseq");
+ folioSequentialsToXml(&m_cnd_tenfolio_max,
+ &cndfolioseq,
+ "seqtf_",
+ "tenfolioseq",
+ &document);
+ cndfoliosequential.appendChild(cndfolioseq);
+ }
+ if (!m_cnd_hundredfolio_max.isEmpty()) {
+ QDomElement cndfolioseq =
+ document.createElement(
+ "conductorhundredfolioseq");
+ folioSequentialsToXml(&m_cnd_hundredfolio_max,
+ &cndfolioseq,
+ "seqhf_",
+ "hundredfolioseq",
+ &document);
+ cndfoliosequential.appendChild(cndfolioseq);
+ }
+ dom_root.appendChild(cndfoliosequential);
+ }
+ }
+ else {
+ //this method with whole_content to false,
+ //is often use to copy and paste the current selection
+ //so we add the id of the project where copy occur.
+ dom_root.setAttribute("projectId", QETApp::projectId(m_project));
+ }
+ document.appendChild(dom_root);
- if (items().isEmpty())
- return(document);
+ if (items().isEmpty())
+ return(document);
- QVector list_elements;
- QVector list_conductors;
- QVector list_texts;
- QVector list_images;
- QVector list_shapes;
- QVector table_vector;
+ QVector list_elements;
+ QVector list_conductors;
+ QVector list_texts;
+ QVector list_images;
+ QVector list_shapes;
+ QVector table_vector;
- //Ckeck graphics item to "XMLise"
- for(QGraphicsItem *qgi : items())
- {
- switch (qgi->type())
- {
- case Element::Type: {
- auto elmt = static_cast(qgi);
- if (whole_content || elmt->isSelected())
- list_elements << elmt;
- break;
- }
- case Conductor::Type: {
- auto cond = static_cast(qgi);
- if (whole_content)
- list_conductors << cond;
- /* When we did not export the whole diagram,
- * we must to remove the non selected conductors.
- * At this step that mean a conductor which one
- * of these two element are not selected
- */
- else if (cond->terminal1->parentItem()->isSelected()
- && cond->terminal2->parentItem()->isSelected())
- list_conductors << cond;
- break;
- }
- case DiagramImageItem::Type: {
- auto image = static_cast(qgi);
- if (whole_content || image->isSelected())
- list_images << image;
- break;
- }
- case IndependentTextItem::Type: {
- auto indi_text = static_cast(qgi);
- if (whole_content || indi_text->isSelected())
- list_texts << indi_text;
- break;
- }
- case QetShapeItem::Type: {
- auto shape = static_cast(qgi);
- if (whole_content || shape->isSelected())
- list_shapes << shape;
- break;
- }
- case QetGraphicsTableItem::Type: {
- auto table = static_cast(qgi);
- if (whole_content || table->isSelected())
- table_vector << table;
- }
- }
- }
+ //Ckeck graphics item to "XMLise"
+ for(QGraphicsItem *qgi : items())
+ {
+ switch (qgi->type())
+ {
+ case Element::Type: {
+ auto elmt = static_cast(qgi);
+ if (whole_content || elmt->isSelected())
+ list_elements << elmt;
+ break;
+ }
+ case Conductor::Type: {
+ auto cond = static_cast(qgi);
+ if (whole_content)
+ list_conductors << cond;
+ /* When we did not export the whole diagram,
+ * we must to remove the non selected conductors.
+ * At this step that mean a conductor which one
+ * of these two element are not selected
+ */
+ else if (cond->terminal1->parentItem()->isSelected()
+ && cond->terminal2->parentItem()->isSelected())
+ list_conductors << cond;
+ break;
+ }
+ case DiagramImageItem::Type: {
+ auto image = static_cast(qgi);
+ if (whole_content || image->isSelected())
+ list_images << image;
+ break;
+ }
+ case IndependentTextItem::Type: {
+ auto indi_text = static_cast(qgi);
+ if (whole_content || indi_text->isSelected())
+ list_texts << indi_text;
+ break;
+ }
+ case QetShapeItem::Type: {
+ auto shape = static_cast(qgi);
+ if (whole_content || shape->isSelected())
+ list_shapes << shape;
+ break;
+ }
+ case QetGraphicsTableItem::Type: {
+ auto table = static_cast(qgi);
+ if (whole_content || table->isSelected())
+ table_vector << table;
+ }
+ }
+ }
- // correspondence table between the addresses of the terminals and their ids
- // table de correspondance entre les adresses des bornes et leurs ids
- QHash table_adr_id;
+ // correspondence table between the addresses of the terminals and their ids
+ // table de correspondance entre les adresses des bornes et leurs ids
+ QHash table_adr_id;
- if (!list_elements.isEmpty()) {
- auto dom_elements = document.createElement("elements");
- for (auto elmt : list_elements) {
- dom_elements.appendChild(elmt->toXml(document,
- table_adr_id));
- }
- dom_root.appendChild(dom_elements);
- }
+ if (!list_elements.isEmpty()) {
+ auto dom_elements = document.createElement("elements");
+ for (auto elmt : list_elements) {
+ dom_elements.appendChild(elmt->toXml(document,
+ table_adr_id));
+ }
+ dom_root.appendChild(dom_elements);
+ }
- if (!list_conductors.isEmpty()) {
- auto dom_conductors = document.createElement("conductors");
- for (auto cond : list_conductors) {
- dom_conductors.appendChild(cond->toXml(document,
- table_adr_id));
- }
- dom_root.appendChild(dom_conductors);
- }
+ if (!list_conductors.isEmpty()) {
+ auto dom_conductors = document.createElement("conductors");
+ for (auto cond : list_conductors) {
+ dom_conductors.appendChild(cond->toXml(document,
+ table_adr_id));
+ }
+ dom_root.appendChild(dom_conductors);
+ }
- if (!list_texts.isEmpty()) {
- auto dom_texts = document.createElement("inputs");
- for (auto dti : list_texts) {
- dom_texts.appendChild(dti->toXml(document));
- }
- dom_root.appendChild(dom_texts);
- }
+ if (!list_texts.isEmpty()) {
+ auto dom_texts = document.createElement("inputs");
+ for (auto dti : list_texts) {
+ dom_texts.appendChild(dti->toXml(document));
+ }
+ dom_root.appendChild(dom_texts);
+ }
- if (!list_images.isEmpty()) {
- auto dom_images = document.createElement("images");
- for (auto dii : list_images) {
- dom_images.appendChild(dii->toXml(document));
- }
- dom_root.appendChild(dom_images);
- }
+ if (!list_images.isEmpty()) {
+ auto dom_images = document.createElement("images");
+ for (auto dii : list_images) {
+ dom_images.appendChild(dii->toXml(document));
+ }
+ dom_root.appendChild(dom_images);
+ }
- if (!list_shapes.isEmpty()) {
- auto dom_shapes = document.createElement("shapes");
- for (auto dii : list_shapes) {
- dom_shapes.appendChild(dii -> toXml(document));
- }
- dom_root.appendChild(dom_shapes);
- }
+ if (!list_shapes.isEmpty()) {
+ auto dom_shapes = document.createElement("shapes");
+ for (auto dii : list_shapes) {
+ dom_shapes.appendChild(dii -> toXml(document));
+ }
+ dom_root.appendChild(dom_shapes);
+ }
- if (table_vector.size()) {
- auto tables = document.createElement("tables");
- for (auto table : table_vector) {
- tables.appendChild(table->toXml(document));
- }
- dom_root.appendChild(tables);
- }
+ if (table_vector.size()) {
+ auto tables = document.createElement("tables");
+ for (auto table : table_vector) {
+ tables.appendChild(table->toXml(document));
+ }
+ dom_root.appendChild(tables);
+ }
- return(document);
+ return(document);
}
/**
- @brief Diagram::folioSequentialsToXml
- Add folio sequential to QDomElement
- @param hash to retrieve content with content
- @param domElement to add attributes
- @param seq_type type
- @param type
- @param doc
+ @brief Diagram::folioSequentialsToXml
+ Add folio sequential to QDomElement
+ @param hash to retrieve content with content
+ @param domElement to add attributes
+ @param seq_type type
+ @param type
+ @param doc
*/
void Diagram::folioSequentialsToXml(QHash *hash,
- QDomElement *domElement,
- const QString& seq_type,
- const QString& type,
- QDomDocument *doc) {
- QHash::iterator i;
- for (i = hash->begin(); i != hash->end(); i++) {
- QDomElement folioseq = doc->createElement(type);
- folioseq.setAttribute("title", i.key());
- for (int j = 0; j < i.value().size(); j++) {
- folioseq.setAttribute(seq_type + QString::number(j+1),
- i.value().at(j));
- }
- domElement->appendChild(folioseq);
- }
+ QStringList> *hash,
+ QDomElement *domElement,
+ const QString& seq_type,
+ const QString& type,
+ QDomDocument *doc) {
+ QHash::iterator i;
+ for (i = hash->begin(); i != hash->end(); i++) {
+ QDomElement folioseq = doc->createElement(type);
+ folioseq.setAttribute("title", i.key());
+ for (int j = 0; j < i.value().size(); j++) {
+ folioseq.setAttribute(seq_type + QString::number(j+1),
+ i.value().at(j));
+ }
+ domElement->appendChild(folioseq);
+ }
}
/**
- @brief Diagram::fromXml
- Imports the described schema into an XML document.
- If a position is specified,
- the imported elements are positioned so that the upper left corner
- of the smallest rectangle that can surround them all
- (the bounding rect) is at this position.
- \~French Importe le schema decrit dans un document XML.
- Si une position estprecisee,
- les elements importes sont positionnes de maniere a ce que le coin
- superieur gauche du plus petit rectangle pouvant les entourant tous
- (le bounding rect) soit a cette position.
- \~ @param document :
- The XML document to analyze
- \~French Le document XML a analyser
- \~ @param position :
- The position of the diagram matters
- \~French La position du schema importe
- \~ @param consider_informations :
- If true, additional information
- (author, title, ...) will be taken into account
- \~French Si vrai, les informations complementaires
- (auteur, titre, ...) seront prises en compte
- \~ @param content_ptr :
- if this pointer to a DiagramContent is different from 0,
- it will be filled with the content added to the schema by the fromXml
- \~French si ce pointeur vers un DiagramContent est different de 0,
- il sera rempli avec le contenu ajoute au schema par le fromXml
- \~ @return true if the import was successful, false otherwise
- \~French true si l'import a reussi, false sinon
+ @brief Diagram::fromXml
+ Imports the described schema into an XML document.
+ If a position is specified,
+ the imported elements are positioned so that the upper left corner
+ of the smallest rectangle that can surround them all
+ (the bounding rect) is at this position.
+ \~French Importe le schema decrit dans un document XML.
+ Si une position estprecisee,
+ les elements importes sont positionnes de maniere a ce que le coin
+ superieur gauche du plus petit rectangle pouvant les entourant tous
+ (le bounding rect) soit a cette position.
+ \~ @param document :
+ The XML document to analyze
+ \~French Le document XML a analyser
+ \~ @param position :
+ The position of the diagram matters
+ \~French La position du schema importe
+ \~ @param consider_informations :
+ If true, additional information
+ (author, title, ...) will be taken into account
+ \~French Si vrai, les informations complementaires
+ (auteur, titre, ...) seront prises en compte
+ \~ @param content_ptr :
+ if this pointer to a DiagramContent is different from 0,
+ it will be filled with the content added to the schema by the fromXml
+ \~French si ce pointeur vers un DiagramContent est different de 0,
+ il sera rempli avec le contenu ajoute au schema par le fromXml
+ \~ @return true if the import was successful, false otherwise
+ \~French true si l'import a reussi, false sinon
*/
bool Diagram::fromXml(QDomDocument &document,
- QPointF position,
- bool consider_informations,
- DiagramContent *content_ptr) {
- QDomElement root = document.documentElement();
- return(fromXml(root, position, consider_informations, content_ptr));
+ QPointF position,
+ bool consider_informations,
+ DiagramContent *content_ptr) {
+ QDomElement root = document.documentElement();
+ return(fromXml(root, position, consider_informations, content_ptr));
}
/**
- @brief Diagram::initFromXml
- Imports the described schema in an XML element.
- This method delegates its work to Diagram :: fromXml
- If the import is successful,
- this method also initializes the XML document internal allowing to
- manage the recording of this diagram in the project to which it belongs.
- @see Diagram::fromXml
- \~French Importe le schema decrit dans un element XML.
- Cette methode delegue son travail a Diagram::fromXml
- Si l'import reussit, cette methode initialise egalement le document XML
- interne permettant de bien gerer l'enregistrement de ce schema dans le
- projet auquel il appartient.
- \~ @param document : The XML document to analyze
- \~French Le document XML a analyser
- \~ @param position : The position of the diagram matters
- \~French La position du schema importe
- \~ @param consider_informations :
- If true, additional information
- (author, title, ...) will be taken into account
- \~French Si vrai, les informations complementaires
- (auteur, titre, ...) seront prises en compte
- \~ @param content_ptr :
- if this pointer to a DiagramContent is different from 0,
- it will be filled with the content added to the schema by the fromXml
- \~French si ce pointeur vers un DiagramContent est different de 0,
- il sera rempli avec le contenu ajoute au schema par le fromXml
- \~ @return true if the import was successful, false otherwise
- \~French true si l'import a reussi, false sinon
+ @brief Diagram::initFromXml
+ Imports the described schema in an XML element.
+ This method delegates its work to Diagram :: fromXml
+ If the import is successful,
+ this method also initializes the XML document internal allowing to
+ manage the recording of this diagram in the project to which it belongs.
+ @see Diagram::fromXml
+ \~French Importe le schema decrit dans un element XML.
+ Cette methode delegue son travail a Diagram::fromXml
+ Si l'import reussit, cette methode initialise egalement le document XML
+ interne permettant de bien gerer l'enregistrement de ce schema dans le
+ projet auquel il appartient.
+ \~ @param document : The XML document to analyze
+ \~French Le document XML a analyser
+ \~ @param position : The position of the diagram matters
+ \~French La position du schema importe
+ \~ @param consider_informations :
+ If true, additional information
+ (author, title, ...) will be taken into account
+ \~French Si vrai, les informations complementaires
+ (auteur, titre, ...) seront prises en compte
+ \~ @param content_ptr :
+ if this pointer to a DiagramContent is different from 0,
+ it will be filled with the content added to the schema by the fromXml
+ \~French si ce pointeur vers un DiagramContent est different de 0,
+ il sera rempli avec le contenu ajoute au schema par le fromXml
+ \~ @return true if the import was successful, false otherwise
+ \~French true si l'import a reussi, false sinon
*/
bool Diagram::initFromXml(QDomElement &document,
- QPointF position,
- bool consider_informations,
- DiagramContent *content_ptr) {
- /* import the content and properties of the schema
- * from the XML element provided as a parameter
- * import le contenu et les proprietes du schema
- * depuis l'element XML fourni en parametre
- */
- bool from_xml = fromXml(document,
- position,
- consider_informations,
- content_ptr);
+ QPointF position,
+ bool consider_informations,
+ DiagramContent *content_ptr) {
+ /* import the content and properties of the schema
+ * from the XML element provided as a parameter
+ * import le contenu et les proprietes du schema
+ * depuis l'element XML fourni en parametre
+ */
+ bool from_xml = fromXml(document,
+ position,
+ consider_informations,
+ content_ptr);
- return(from_xml);
+ return(from_xml);
}
/**
- @brief findTerminal
- Find terminal to which the conductor should be connected
- @param conductor_index 1 or 2 depending on which terminal is searched
- @param f Conductor xml element
- @param table_adr_id Hash table to all terminal id assignement (legacy)
- @param added_elements Elements found in the xml file
- @return
+ @brief findTerminal
+ Find terminal to which the conductor should be connected
+ @param conductor_index 1 or 2 depending on which terminal is searched
+ @param f Conductor xml element
+ @param table_adr_id Hash table to all terminal id assignement (legacy)
+ @param added_elements Elements found in the xml file
+ @return
*/
Terminal* findTerminal(int conductor_index,
- QDomElement& f,
- QHash& table_adr_id,
- QList& added_elements) {
- assert(conductor_index == 1 || conductor_index == 2);
+ QDomElement& f,
+ QHash& table_adr_id,
+ QList& added_elements) {
+ assert(conductor_index == 1 || conductor_index == 2);
- QString element_index = "element" + QString::number(conductor_index);
- QString terminal_index = "terminal" + QString::number(conductor_index);
+ QString element_index = "element" + QString::number(conductor_index);
+ QString terminal_index = "terminal" + QString::number(conductor_index);
- if (f.hasAttribute(element_index)) {
- QUuid element_uuid = QUuid(f.attribute(element_index));
- // 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
- bool element_found = false;
- for (auto element: added_elements) {
- if (element->uuid() != element_uuid)
- continue;
- element_found = true;
- QUuid terminal_uuid = QUuid(f.attribute(terminal_index));
- for (auto terminal: element->terminals()) {
- if (terminal->uuid() != terminal_uuid)
- continue;
+ if (f.hasAttribute(element_index)) {
+ QUuid element_uuid = QUuid(f.attribute(element_index));
+ // 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
+ bool element_found = false;
+ for (auto element: added_elements) {
+ if (element->uuid() != element_uuid)
+ continue;
+ element_found = true;
+ QUuid terminal_uuid = QUuid(f.attribute(terminal_index));
+ for (auto terminal: element->terminals()) {
+ if (terminal->uuid() != terminal_uuid)
+ continue;
- return terminal;
- }
- qDebug() << "Diagram::fromXml() : "
- << terminal_index
- << ":"
- << terminal_uuid
- << "not found in "
- << element_index
- << ":"
- << element_uuid;
- break;
- }
- if (!element_found)
- qDebug() << "Diagram::fromXml() : "
- << element_index
- << ": "
- << element_uuid
- << "not found";
- } else {
- // Backward compatibility.
- // Until version 0.7 a generated id is used to link the terminal.
- int id_p1 = f.attribute(terminal_index).toInt();
- if (!table_adr_id.contains(id_p1)) {
- qDebug() << "Diagram::fromXml() : terminal id "
- << id_p1
- << " not found";
- } else
- return table_adr_id.value(id_p1);
- }
- return nullptr;
+ return terminal;
+ }
+ qDebug() << "Diagram::fromXml() : "
+ << terminal_index
+ << ":"
+ << terminal_uuid
+ << "not found in "
+ << element_index
+ << ":"
+ << element_uuid;
+ break;
+ }
+ if (!element_found)
+ qDebug() << "Diagram::fromXml() : "
+ << element_index
+ << ": "
+ << element_uuid
+ << "not found";
+ } else {
+ // Backward compatibility.
+ // Until version 0.7 a generated id is used to link the terminal.
+ int id_p1 = f.attribute(terminal_index).toInt();
+ if (!table_adr_id.contains(id_p1)) {
+ qDebug() << "Diagram::fromXml() : terminal id "
+ << id_p1
+ << " not found";
+ } else
+ return table_adr_id.value(id_p1);
+ }
+ return nullptr;
}
/**
- @brief Diagram::fromXml
- Imports the described schema in an XML element. If a position is
- specified, the imported elements are positioned in such a way that the
- upper left corner of the smallest rectangle that can surround them all
- (the bounding rect) either at this position.
- \~French Importe le schema decrit dans un element XML.
- Si une position est precisee,
- les elements importes sont positionnes de maniere a ce que le
- coin superieur gauche du plus petit rectangle pouvant les entourant tous
- (le bounding rect) soit a cette position.
- \~ @param document :
- The XML document to analyze
- \~French Le document XML a analyser
- \~ @param position :
- The position of the diagram matters
- \~French La position du schema importe
- \~ @param consider_informations :
- If true, additional information
- (author, title, ...) will be taken into account
- \~French Si vrai, les informations complementaires
- (auteur, titre, ...) seront prises en compte
- \~ @param content_ptr :
- if this pointer to a DiagramContent is different from 0,
- it will be filled with the content added to the schema by the fromXml
- \~French si ce pointeur vers un DiagramContent est different de 0,
- il sera rempli avec le contenu ajoute au schema par le fromXml
- \~ @return
- true if the import was successful, false otherwise
- \~French true si l'import a reussi, false sinon
+ @brief Diagram::fromXml
+ Imports the described schema in an XML element. If a position is
+ specified, the imported elements are positioned in such a way that the
+ upper left corner of the smallest rectangle that can surround them all
+ (the bounding rect) either at this position.
+ \~French Importe le schema decrit dans un element XML.
+ Si une position est precisee,
+ les elements importes sont positionnes de maniere a ce que le
+ coin superieur gauche du plus petit rectangle pouvant les entourant tous
+ (le bounding rect) soit a cette position.
+ \~ @param document :
+ The XML document to analyze
+ \~French Le document XML a analyser
+ \~ @param position :
+ The position of the diagram matters
+ \~French La position du schema importe
+ \~ @param consider_informations :
+ If true, additional information
+ (author, title, ...) will be taken into account
+ \~French Si vrai, les informations complementaires
+ (auteur, titre, ...) seront prises en compte
+ \~ @param content_ptr :
+ if this pointer to a DiagramContent is different from 0,
+ it will be filled with the content added to the schema by the fromXml
+ \~French si ce pointeur vers un DiagramContent est different de 0,
+ il sera rempli avec le contenu ajoute au schema par le fromXml
+ \~ @return
+ true if the import was successful, false otherwise
+ \~French true si l'import a reussi, false sinon
*/
bool Diagram::fromXml(QDomElement &document,
- QPointF position,
- bool consider_informations,
- DiagramContent *content_ptr) {
- const QDomElement& root = document;
- // The first element must be a diagram
- if (root.tagName() != "diagram") return(false);
+ QPointF position,
+ bool consider_informations,
+ DiagramContent *content_ptr) {
+ const QDomElement& root = document;
+ // The first element must be a diagram
+ if (root.tagName() != "diagram") return(false);
- // Read attributes of this diagram
- if (consider_informations)
- {
- // Load border and titleblock
- border_and_titleblock.titleBlockFromXml(root);
- border_and_titleblock.borderFromXml(root);
+ // Read attributes of this diagram
+ if (consider_informations)
+ {
+ // Load border and titleblock
+ border_and_titleblock.titleBlockFromXml(root);
+ border_and_titleblock.borderFromXml(root);
- // Find the element "defaultconductor".
- // If found, load default conductor properties.
- QDomElement default_conductor_elmt =
- root.firstChildElement("defaultconductor");
- if (!default_conductor_elmt.isNull()) {
- defaultConductorProperties.fromXml(default_conductor_elmt);
- }
+ // Find the element "defaultconductor".
+ // If found, load default conductor properties.
+ QDomElement default_conductor_elmt =
+ root.firstChildElement("defaultconductor");
+ if (!default_conductor_elmt.isNull()) {
+ defaultConductorProperties.fromXml(default_conductor_elmt);
+ }
- // Load the autonum
- m_conductors_autonum_name = root.attribute("conductorAutonum");
+ // Load the autonum
+ m_conductors_autonum_name = root.attribute("conductorAutonum");
- // Load Freeze New Element
- m_freeze_new_elements = root.attribute("freezeNewElement").toInt();
+ // Load Freeze New Element
+ m_freeze_new_elements = root.attribute("freezeNewElement").toInt();
- // Load Freeze New Conductor
- m_freeze_new_conductors_ = root.attribute("freezeNewConductor").toInt();
+ // Load Freeze New Conductor
+ m_freeze_new_conductors_ = root.attribute("freezeNewConductor").toInt();
- //Load Element Folio Sequential
- folioSequentialsFromXml(root,
- &m_elmt_unitfolio_max,
- "elementunitfolioseq",
- "sequf_",
- "unitfolioseq",
- "elementautonumfoliosequentials");
- folioSequentialsFromXml(root, &m_elmt_tenfolio_max,
- "elementtenfolioseq",
- "seqtf_",
- "tenfolioseq",
- "elementautonumfoliosequentials");
- folioSequentialsFromXml(root, &m_elmt_hundredfolio_max,
- "elementhundredfolioseq",
- "seqhf_",
- "hundredfolioseq",
- "elementautonumfoliosequentials");
+ //Load Element Folio Sequential
+ folioSequentialsFromXml(root,
+ &m_elmt_unitfolio_max,
+ "elementunitfolioseq",
+ "sequf_",
+ "unitfolioseq",
+ "elementautonumfoliosequentials");
+ folioSequentialsFromXml(root, &m_elmt_tenfolio_max,
+ "elementtenfolioseq",
+ "seqtf_",
+ "tenfolioseq",
+ "elementautonumfoliosequentials");
+ folioSequentialsFromXml(root, &m_elmt_hundredfolio_max,
+ "elementhundredfolioseq",
+ "seqhf_",
+ "hundredfolioseq",
+ "elementautonumfoliosequentials");
- //Load Conductor Folio Sequential
- folioSequentialsFromXml(root, &m_cnd_unitfolio_max,
- "conductorunitfolioseq",
- "sequf_",
- "unitfolioseq",
- "conductorautonumfoliosequentials");
- folioSequentialsFromXml(root, &m_cnd_tenfolio_max,
- "conductortenfolioseq",
- "seqtf_","tenfolioseq",
- "conductorautonumfoliosequentials");
- folioSequentialsFromXml(root, &m_cnd_hundredfolio_max,
- "conductorhundredfolioseq",
- "seqhf_",
- "hundredfolioseq",
- "conductorautonumfoliosequentials");
- }
+ //Load Conductor Folio Sequential
+ folioSequentialsFromXml(root, &m_cnd_unitfolio_max,
+ "conductorunitfolioseq",
+ "sequf_",
+ "unitfolioseq",
+ "conductorautonumfoliosequentials");
+ folioSequentialsFromXml(root, &m_cnd_tenfolio_max,
+ "conductortenfolioseq",
+ "seqtf_","tenfolioseq",
+ "conductorautonumfoliosequentials");
+ folioSequentialsFromXml(root, &m_cnd_hundredfolio_max,
+ "conductorhundredfolioseq",
+ "seqhf_",
+ "hundredfolioseq",
+ "conductorautonumfoliosequentials");
+ }
- // if child haven't got a child, loading is finish (diagram is empty)
- if (root.firstChild().isNull()) {
- return(true);
- }
+ // if child haven't got a child, loading is finish (diagram is empty)
+ if (root.firstChild().isNull()) {
+ return(true);
+ }
- //If paste from another project
- if (root.hasAttribute("projectId")) {
- QETProject *other_project = QETApp::project(
- root.attribute("projectId",
- "-1").toInt());
+ //If paste from another project
+ if (root.hasAttribute("projectId")) {
+ QETProject *other_project = QETApp::project(
+ root.attribute("projectId",
+ "-1").toInt());
- /* We try to paste from another project,
- * then befor paste elements,
- * we must to import the definition of the pasted elements
- * (owned by other project)
- * in the embedded collection of this project
- */
- if (other_project && other_project != m_project) {
- ElementCollectionHandler ech;
- foreach (QDomElement element_xml,
- QET::findInDomElement(root,
- "elements",
- "element")) {
- if (!Element::valideXml(element_xml)) continue;
+ /* We try to paste from another project,
+ * then befor paste elements,
+ * we must to import the definition of the pasted elements
+ * (owned by other project)
+ * in the embedded collection of this project
+ */
+ if (other_project && other_project != m_project) {
+ ElementCollectionHandler ech;
+ foreach (QDomElement element_xml,
+ QET::findInDomElement(root,
+ "elements",
+ "element")) {
+ if (!Element::valideXml(element_xml)) continue;
- QString type_id = element_xml.attribute("type");
+ QString type_id = element_xml.attribute("type");
- if (type_id.startsWith("embed://")) {
- ElementsLocation location(
- type_id,
- other_project);
- ech.importFromProject(m_project,
- location);
- }
- }
- }
- }
- //Load all elements from the XML
- QList added_elements;
- QHash table_adr_id;
- foreach (QDomElement element_xml,
- QET::findInDomElement(root, "elements", "element"))
- {
- if (!Element::valideXml(element_xml)) continue;
+ if (type_id.startsWith("embed://")) {
+ ElementsLocation location(
+ type_id,
+ other_project);
+ ech.importFromProject(m_project,
+ location);
+ }
+ }
+ }
+ }
+ //Load all elements from the XML
+ QList added_elements;
+ QHash table_adr_id;
+ foreach (QDomElement element_xml,
+ QET::findInDomElement(root, "elements", "element"))
+ {
+ if (!Element::valideXml(element_xml)) continue;
- // cree un element dont le type correspond a l'id type
- QString type_id = element_xml.attribute("type");
- ElementsLocation element_location;
- if (type_id.startsWith("embed://")) {
- element_location = ElementsLocation(type_id, m_project);
- }
- else {
- element_location = ElementsLocation(type_id);
- }
+ // cree un element dont le type correspond a l'id type
+ QString type_id = element_xml.attribute("type");
+ ElementsLocation element_location;
+ if (type_id.startsWith("embed://")) {
+ element_location = ElementsLocation(type_id, m_project);
+ }
+ else {
+ element_location = ElementsLocation(type_id);
+ }
- int state = 0;
- Element *nvel_elmt =
- ElementFactory::Instance() -> createElement(
- element_location, nullptr, &state);
- if (state)
- {
- QString debug_message =
- QString("Diagram::fromXml() : Le chargement de "
- "la description de l'element %1 a "
- "echoue avec le code d'erreur %2").arg(
- element_location.path()).arg(state);
- qDebug() << qPrintable(debug_message);
- delete nvel_elmt;
- continue;
- }
+ int state = 0;
+ Element *nvel_elmt =
+ ElementFactory::Instance() -> createElement(
+ element_location, nullptr, &state);
+ if (state)
+ {
+ QString debug_message =
+ QString("Diagram::fromXml() : Le chargement de "
+ "la description de l'element %1 a "
+ "echoue avec le code d'erreur %2").arg(
+ element_location.path()).arg(state);
+ qDebug() << qPrintable(debug_message);
+ delete nvel_elmt;
+ continue;
+ }
- addItem(nvel_elmt);
- //Loading fail, remove item from the diagram
- if (!nvel_elmt->fromXml(element_xml, table_adr_id))
- {
- removeItem(nvel_elmt);
- delete nvel_elmt;
- qDebug() << "Diagram::fromXml() : Le chargement des "
- "parametres d'un element a echoue";
- } else {
- added_elements << nvel_elmt;
- }
- }
+ addItem(nvel_elmt);
+ //Loading fail, remove item from the diagram
+ if (!nvel_elmt->fromXml(element_xml, table_adr_id))
+ {
+ removeItem(nvel_elmt);
+ delete nvel_elmt;
+ qDebug() << "Diagram::fromXml() : Le chargement des "
+ "parametres d'un element a echoue";
+ } else {
+ added_elements << nvel_elmt;
+ }
+ }
- // Load text
- QList added_texts;
- foreach (QDomElement text_xml, QET::findInDomElement(root,
- "inputs",
- "input")) {
- IndependentTextItem *iti = new IndependentTextItem();
- iti -> fromXml(text_xml);
- addItem(iti);
- added_texts << iti;
- }
+ // Load text
+ QList added_texts;
+ foreach (QDomElement text_xml, QET::findInDomElement(root,
+ "inputs",
+ "input")) {
+ IndependentTextItem *iti = new IndependentTextItem();
+ iti -> fromXml(text_xml);
+ addItem(iti);
+ added_texts << iti;
+ }
- // Load image
- QList added_images;
- foreach (QDomElement image_xml, QET::findInDomElement(root,
- "images",
- "image")) {
- DiagramImageItem *dii = new DiagramImageItem ();
- dii -> fromXml(image_xml);
- addItem(dii);
- added_images << dii;
- }
+ // Load image
+ QList added_images;
+ foreach (QDomElement image_xml, QET::findInDomElement(root,
+ "images",
+ "image")) {
+ DiagramImageItem *dii = new DiagramImageItem ();
+ dii -> fromXml(image_xml);
+ addItem(dii);
+ added_images << dii;
+ }
- // Load shape
- QList added_shapes;
- foreach (QDomElement shape_xml, QET::findInDomElement(root,
- "shapes",
- "shape")) {
- QetShapeItem *dii = new QetShapeItem (QPointF(0,0));
- dii -> fromXml(shape_xml);
- addItem(dii);
- added_shapes << dii;
- }
+ // Load shape
+ QList added_shapes;
+ foreach (QDomElement shape_xml, QET::findInDomElement(root,
+ "shapes",
+ "shape")) {
+ QetShapeItem *dii = new QetShapeItem (QPointF(0,0));
+ dii -> fromXml(shape_xml);
+ addItem(dii);
+ added_shapes << dii;
+ }
- // Load conductor
- QList added_conductors;
- foreach (QDomElement f, QET::findInDomElement(root,
- "conductors",
- "conductor"))
- {
- if (!Conductor::valideXml(f)) continue;
+ // Load conductor
+ QList added_conductors;
+ foreach (QDomElement f, QET::findInDomElement(root,
+ "conductors",
+ "conductor"))
+ {
+ if (!Conductor::valideXml(f)) continue;
- //Check if terminal that conductor must be linked is know
+ //Check if terminal that conductor must be linked is know
- Terminal* p1 = findTerminal(1, f, table_adr_id, added_elements);
- Terminal* p2 = findTerminal(2, 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);
- if (p1 && p2 && p1 != p2)
- {
- Conductor *c = new Conductor(p1, p2);
- if (c->isValid())
- {
- addItem(c);
- c -> fromXml(f);
- added_conductors << c;
- }
- else
- delete c;
- }
- }
+ if (p1 && p2 && p1 != p2)
+ {
+ Conductor *c = new Conductor(p1, p2);
+ if (c->isValid())
+ {
+ addItem(c);
+ c -> fromXml(f);
+ added_conductors << c;
+ }
+ else
+ delete c;
+ }
+ }
- //Load tables
- QVector added_tables;
- for (auto dom_table
- : QETXML::subChild(root,
- "tables",
- QetGraphicsTableItem::xmlTagName()))
- {
- auto table = new QetGraphicsTableItem();
- addItem(table);
- table->fromXml(dom_table);
- added_tables << table;
- }
+ //Load tables
+ QVector added_tables;
+ for (auto dom_table
+ : QETXML::subChild(root,
+ "tables",
+ QetGraphicsTableItem::xmlTagName()))
+ {
+ auto table = new QetGraphicsTableItem();
+ addItem(table);
+ table->fromXml(dom_table);
+ added_tables << table;
+ }
- //Translate items if a new position was given in parameter
- if (position != QPointF())
- {
- QVector added_items;
- for (auto element : added_elements ) added_items << element;
- for (auto cond : added_conductors) added_items << cond;
- for (auto shape : added_shapes ) added_items << shape;
- for (auto text : added_texts ) added_items << text;
- for (auto image : added_images ) added_items << image;
- for (auto table : added_tables ) added_items << table;
+ //Translate items if a new position was given in parameter
+ if (position != QPointF())
+ {
+ QVector added_items;
+ for (auto element : added_elements ) added_items << element;
+ for (auto cond : added_conductors) added_items << cond;
+ for (auto shape : added_shapes ) added_items << shape;
+ for (auto text : added_texts ) added_items << text;
+ for (auto image : added_images ) added_items << image;
+ for (auto table : added_tables ) added_items << table;
- //Get the top left corner of the rectangle that contain all added items
- QRectF items_rect;
- for (auto item : added_items) {
- items_rect = items_rect.united(
- item->mapToScene(
- item->boundingRect()
- ).boundingRect());
- }
+ //Get the top left corner of the rectangle that contain all added items
+ QRectF items_rect;
+ for (auto item : added_items) {
+ items_rect = items_rect.united(
+ item->mapToScene(
+ item->boundingRect()
+ ).boundingRect());
+ }
- QPointF point_ = items_rect.topLeft();
- QPointF pos_ = Diagram::snapToGrid(QPointF (position.x() - point_.x(),
- position.y() - point_.y()));
+ QPointF point_ = items_rect.topLeft();
+ QPointF pos_ = Diagram::snapToGrid(QPointF (position.x() - point_.x(),
+ position.y() - point_.y()));
- //Translate all added items
- for (auto qgi : added_items)
- qgi->setPos(qgi->pos() += pos_);
- }
+ //Translate all added items
+ for (auto qgi : added_items)
+ qgi->setPos(qgi->pos() += pos_);
+ }
- //Filling of falculatory lists
- if (content_ptr) {
- content_ptr -> m_elements = added_elements;
- content_ptr -> m_conductors_to_move = added_conductors;
-#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
- content_ptr -> m_text_fields = added_texts.toSet();
- content_ptr -> m_images = added_images.toSet();
- content_ptr -> m_shapes = added_shapes.toSet();
+ //Filling of falculatory lists
+ if (content_ptr) {
+ content_ptr -> m_elements = added_elements;
+ content_ptr -> m_conductors_to_move = added_conductors;
+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
+ content_ptr -> m_text_fields = added_texts.toSet();
+ content_ptr -> m_images = added_images.toSet();
+ content_ptr -> m_shapes = added_shapes.toSet();
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 5.14 or later")
#endif
- content_ptr -> m_text_fields = QSet(
- added_texts.begin(),
- added_texts.end());
- content_ptr -> m_images = QSet(
- added_images.begin(),
- added_images.end());
- content_ptr -> m_shapes = QSet(
- added_shapes.begin(),
- added_shapes.end());
+ content_ptr -> m_text_fields = QSet(
+ added_texts.begin(),
+ added_texts.end());
+ content_ptr -> m_images = QSet(
+ added_images.begin(),
+ added_images.end());
+ content_ptr -> m_shapes = QSet(
+ added_shapes.begin(),
+ added_shapes.end());
#endif
- content_ptr -> m_tables = added_tables;
- }
+ content_ptr -> m_tables = added_tables;
+ }
- adjustSceneRect();
- return(true);
+ adjustSceneRect();
+ return(true);
}
/**
- @brief Diagram::folioSequentialsFromXml
- Load folio sequential from QDomElement
- @param root containing all folio sequentials
- @param hash : to be loaded with content
- @param folioSeq type
- @param seq type
- @param type of sequential
- @param autonumFolioSeqType
+ @brief Diagram::folioSequentialsFromXml
+ Load folio sequential from QDomElement
+ @param root containing all folio sequentials
+ @param hash : to be loaded with content
+ @param folioSeq type
+ @param seq type
+ @param type of sequential
+ @param autonumFolioSeqType
*/
void Diagram::folioSequentialsFromXml(const QDomElement &root,
- QHash* hash,
- const QString& folioSeq,
- const QString& seq,
- const QString& type,
- const QString& autonumFolioSeqType) {
- foreach (QDomElement folioSeqAutoNum,
- QET::findInDomElement(root, autonumFolioSeqType, folioSeq)) {
- for(QDomElement folioseq
- = folioSeqAutoNum.firstChildElement(type);
- !folioseq.isNull();
- folioseq = folioseq.nextSiblingElement(type)) {
- QString title = folioseq.attribute("title");
- QStringList list;
- int i = 1;
- while (folioseq.hasAttribute(seq
- + QString::number(i))) {
- list << folioseq.attribute(
- seq + QString::number(i));
- i++;
- }
- hash->insert(title,list);
- }
- }
+ QHash* hash,
+ const QString& folioSeq,
+ const QString& seq,
+ const QString& type,
+ const QString& autonumFolioSeqType) {
+ foreach (QDomElement folioSeqAutoNum,
+ QET::findInDomElement(root, autonumFolioSeqType, folioSeq)) {
+ for(QDomElement folioseq
+ = folioSeqAutoNum.firstChildElement(type);
+ !folioseq.isNull();
+ folioseq = folioseq.nextSiblingElement(type)) {
+ QString title = folioseq.attribute("title");
+ QStringList list;
+ int i = 1;
+ while (folioseq.hasAttribute(seq
+ + QString::number(i))) {
+ list << folioseq.attribute(
+ seq + QString::number(i));
+ i++;
+ }
+ hash->insert(title,list);
+ }
+ }
}
/**
- @brief Diagram::refreshContents
- refresh all content of diagram.
- - refresh conductor text.
- - linking the elements waiting to be linked
- - Refresh the connection of the dynamic element text item
- (use for text with source of text label)
+ @brief Diagram::refreshContents
+ refresh all content of diagram.
+ - refresh conductor text.
+ - linking the elements waiting to be linked
+ - Refresh the connection of the dynamic element text item
+ (use for text with source of text label)
*/
void Diagram::refreshContents()
{
- ElementProvider provider_(this);
+ ElementProvider provider_(this);
- for (Element *elmt : elements())
- {
- elmt->initLink(project());
- for (DynamicElementTextItem *deti : elmt->dynamicTextItems())
- deti->refreshLabelConnection();
- }
+ for (Element *elmt : elements())
+ {
+ elmt->initLink(project());
+ for (DynamicElementTextItem *deti : elmt->dynamicTextItems())
+ deti->refreshLabelConnection();
+ }
- for (Conductor *conductor : conductors())
- conductor->refreshText();
+ for (Conductor *conductor : conductors())
+ conductor->refreshText();
- for (auto table : provider_.table())
- table->initLink();
+ for (auto table : provider_.table())
+ table->initLink();
}
/**
- @brief Diagram::addItem
- Réimplemented from QGraphicsScene::addItem(QGraphicsItem *item)
- Do some specific operation if item need it (for exemple an element)
- @param item
+ @brief Diagram::addItem
+ R??implemented from QGraphicsScene::addItem(QGraphicsItem *item)
+ Do some specific operation if item need it (for exemple an element)
+ @param item
*/
void Diagram::addItem(QGraphicsItem *item)
{
- if (!item || isReadOnly() || item->scene() == this) return;
- QGraphicsScene::addItem(item);
+ if (!item || isReadOnly() || item->scene() == this) return;
+ QGraphicsScene::addItem(item);
- switch (item->type())
- {
- case Element::Type:
- {
- m_project->dataBase()->addElement(
- static_cast(item));
- break;
- }
- case Conductor::Type:
- {
- Conductor *conductor = static_cast(item);
- conductor->terminal1->addConductor(conductor);
- conductor->terminal2->addConductor(conductor);
- conductor->calculateTextItemPosition();
- break;
- }
- default: {break;}
- }
+ switch (item->type())
+ {
+ case Element::Type:
+ {
+ m_project->dataBase()->addElement(
+ static_cast(item));
+ break;
+ }
+ case Conductor::Type:
+ {
+ Conductor *conductor = static_cast(item);
+ conductor->terminal1->addConductor(conductor);
+ conductor->terminal2->addConductor(conductor);
+ conductor->calculateTextItemPosition();
+ break;
+ }
+ default: {break;}
+ }
}
/**
- @brief Diagram::removeItem
- Reimplemented from QGraphicsScene::removeItem(QGraphicsItem *item)
- Do some specific operation if item need it (for exemple an element)
- @param item
+ @brief Diagram::removeItem
+ Reimplemented from QGraphicsScene::removeItem(QGraphicsItem *item)
+ Do some specific operation if item need it (for exemple an element)
+ @param item
*/
void Diagram::removeItem(QGraphicsItem *item)
{
- if (!item || isReadOnly()) return;
+ if (!item || isReadOnly()) return;
- switch (item->type())
- {
- case Element::Type:
- {
- auto elmt = static_cast(item);
- elmt->unlinkAllElements();
- m_project->dataBase()->removeElement(elmt);
- break;
- }
- case Conductor::Type:
- {
- Conductor *conductor = static_cast(item);
- conductor->terminal1->removeConductor(conductor);
- conductor->terminal2->removeConductor(conductor);
- break;
- }
- default: {break;}
- }
+ switch (item->type())
+ {
+ case Element::Type:
+ {
+ auto elmt = static_cast(item);
+ elmt->unlinkAllElements();
+ m_project->dataBase()->removeElement(elmt);
+ break;
+ }
+ case Conductor::Type:
+ {
+ Conductor *conductor = static_cast(item);
+ conductor->terminal1->removeConductor(conductor);
+ conductor->terminal2->removeConductor(conductor);
+ break;
+ }
+ default: {break;}
+ }
- QGraphicsScene::removeItem(item);
+ QGraphicsScene::removeItem(item);
}
/**
- @brief Diagram::titleChanged
- emit(diagramTitleChanged(this, title));
- @param title
+ @brief Diagram::titleChanged
+ emit(diagramTitleChanged(this, title));
+ @param title
*/
void Diagram::titleChanged(const QString &title) {
- emit(diagramTitleChanged(this, title));
+ emit(diagramTitleChanged(this, title));
}
/**
- @brief Diagram::titleBlockTemplateChanged
- This slot may be used to inform the diagram object that the given title
- block template has changed. The diagram will thus flush its title
- block-dedicated rendering cache.
- @param template_name Name of the title block template that has changed
+ @brief Diagram::titleBlockTemplateChanged
+ This slot may be used to inform the diagram object that the given title
+ block template has changed. The diagram will thus flush its title
+ block-dedicated rendering cache.
+ @param template_name Name of the title block template that has changed
*/
void Diagram::titleBlockTemplateChanged(const QString &template_name) {
- if (border_and_titleblock.titleBlockTemplateName() != template_name)
- return;
+ if (border_and_titleblock.titleBlockTemplateName() != template_name)
+ return;
- border_and_titleblock.titleBlockTemplateChanged(template_name);
- update();
+ border_and_titleblock.titleBlockTemplateChanged(template_name);
+ update();
}
/**
- @brief Diagram::titleBlockTemplateRemoved
- This slot has to be be used to inform this class that the given title block
- template is about to be removed and is no longer accessible. This class
- will either use the provided optional TitleBlockTemplate or the default
- title block provided by QETApp::defaultTitleBlockTemplate()
- @param template_name Name of the title block template that has changed
- @param new_template (Optional) Name of the title block template to use instead
+ @brief Diagram::titleBlockTemplateRemoved
+ This slot has to be be used to inform this class that the given title block
+ template is about to be removed and is no longer accessible. This class
+ will either use the provided optional TitleBlockTemplate or the default
+ title block provided by QETApp::defaultTitleBlockTemplate()
+ @param template_name Name of the title block template that has changed
+ @param new_template (Optional) Name of the title block template to use instead
*/
void Diagram::titleBlockTemplateRemoved(const QString &template_name,
- const QString &new_template)
+ const QString &new_template)
{
- if (border_and_titleblock.titleBlockTemplateName() != template_name) return;
- const TitleBlockTemplate *final_template =
- m_project->embeddedTitleBlockTemplatesCollection()
- ->getTemplate(new_template);
- border_and_titleblock.titleBlockTemplateRemoved(template_name,
- final_template);
- update();
+ if (border_and_titleblock.titleBlockTemplateName() != template_name) return;
+ const TitleBlockTemplate *final_template =
+ m_project->embeddedTitleBlockTemplatesCollection()
+ ->getTemplate(new_template);
+ border_and_titleblock.titleBlockTemplateRemoved(template_name,
+ final_template);
+ update();
}
/**
- @brief Diagram::setTitleBlockTemplate
- Set the template to use to render the title block of this diagram.
- @param template_name Name of the title block template.
+ @brief Diagram::setTitleBlockTemplate
+ Set the template to use to render the title block of this diagram.
+ @param template_name Name of the title block template.
*/
void Diagram::setTitleBlockTemplate(const QString &template_name)
{
- if (!m_project) return;
+ if (!m_project) return;
- QString current_name = border_and_titleblock.titleBlockTemplateName();
- const TitleBlockTemplate *titleblock_template =
- m_project->embeddedTitleBlockTemplatesCollection()
- ->getTemplate(template_name);
- border_and_titleblock.titleBlockTemplateRemoved(current_name,
- titleblock_template);
+ QString current_name = border_and_titleblock.titleBlockTemplateName();
+ const TitleBlockTemplate *titleblock_template =
+ m_project->embeddedTitleBlockTemplatesCollection()
+ ->getTemplate(template_name);
+ border_and_titleblock.titleBlockTemplateRemoved(current_name,
+ titleblock_template);
- if (template_name != current_name)
- emit(usedTitleBlockTemplateChanged(template_name));
+ if (template_name != current_name)
+ emit(usedTitleBlockTemplateChanged(template_name));
}
/**
- @brief Diagram::selectAll
- Select all schema objects
- \~French Selectionne tous les objets du schema
+ @brief Diagram::selectAll
+ Select all schema objects
+ \~French Selectionne tous les objets du schema
*/
void Diagram::selectAll()
{
- if (items().isEmpty()) return;
+ if (items().isEmpty()) return;
- blockSignals(true);
- foreach(QGraphicsItem *qgi, items()) qgi -> setSelected(true);
- blockSignals(false);
- emit(selectionChanged());
+ blockSignals(true);
+ foreach(QGraphicsItem *qgi, items()) qgi -> setSelected(true);
+ blockSignals(false);
+ emit(selectionChanged());
}
/**
- @brief Diagram::deselectAll
- Deselects all selected objects
- \~French Deslectionne tous les objets selectionnes
+ @brief Diagram::deselectAll
+ Deselects all selected objects
+ \~French Deslectionne tous les objets selectionnes
*/
void Diagram::deselectAll()
{
- if (items().isEmpty()) return;
+ if (items().isEmpty()) return;
- clearSelection();
+ clearSelection();
}
/**
- @brief Diagram::invertSelection
- Reverses the selection state of all schema objects
- Inverse l'etat de selection de tous les objets du schema
+ @brief Diagram::invertSelection
+ Reverses the selection state of all schema objects
+ Inverse l'etat de selection de tous les objets du schema
*/
void Diagram::invertSelection()
{
- if (items().isEmpty()) return;
+ if (items().isEmpty()) return;
- blockSignals(true);
- foreach (QGraphicsItem *item,
- items()) item -> setSelected(!item -> isSelected());
- blockSignals(false);
- emit(selectionChanged());
+ blockSignals(true);
+ foreach (QGraphicsItem *item,
+ items()) item -> setSelected(!item -> isSelected());
+ blockSignals(false);
+ emit(selectionChanged());
}
/**
- @brief Diagram::updateLabels
- Update elements and conductors that reference folio field
- in their labels.
+ @brief Diagram::updateLabels
+ Update elements and conductors that reference folio field
+ in their labels.
*/
void Diagram::updateLabels()
{
- for (Conductor *cnd : content().conductors())
- {
- cnd->refreshText();
- }
+ for (Conductor *cnd : content().conductors())
+ {
+ cnd->refreshText();
+ }
}
/**
- @brief Diagram::insertFolioSeqHash
- This class inserts a stringlist containing all
- sequential variables related to an autonum in a QHash
- @param hash : to be accessed
- @param title : autonum title
- @param type : to be treated
- @param nc : Context to be manipulated
+ @brief Diagram::insertFolioSeqHash
+ This class inserts a stringlist containing all
+ sequential variables related to an autonum in a QHash
+ @param hash : to be accessed
+ @param title : autonum title
+ @param type : to be treated
+ @param nc : Context to be manipulated
*/
void Diagram::insertFolioSeqHash(QHash *hash,
- const QString& title,
- const QString& type,
- NumerotationContext *nc) {
- QStringList max;
- for (int i = 0; i < nc->size(); i++) {
- if (nc->itemAt(i).at(0) == type) {
- nc->replaceValue(i,
- QString::number(
- nc->itemAt(i).at(3).toInt()));
- max.append(QString::number(nc->itemAt(i).at(3).toInt()
- - nc->itemAt(i).at(2).toInt()));
- }
- }
- hash->insert(title,max);
+ QStringList> *hash,
+ const QString& title,
+ const QString& type,
+ NumerotationContext *nc) {
+ QStringList max;
+ for (int i = 0; i < nc->size(); i++) {
+ if (nc->itemAt(i).at(0) == type) {
+ nc->replaceValue(i,
+ QString::number(
+ nc->itemAt(i).at(3).toInt()));
+ max.append(QString::number(nc->itemAt(i).at(3).toInt()
+ - nc->itemAt(i).at(2).toInt()));
+ }
+ }
+ hash->insert(title,max);
}
/**
- @brief Diagram::loadFolioSeqHash
- This class loads all folio sequential variables
- related to the current autonum
- @param hash : to be accessed
- @param title : autonum title
- @param type : to be treated
- @param nc : Context to be manipulated
+ @brief Diagram::loadFolioSeqHash
+ This class loads all folio sequential variables
+ related to the current autonum
+ @param hash : to be accessed
+ @param title : autonum title
+ @param type : to be treated
+ @param nc : Context to be manipulated
*/
void Diagram::loadFolioSeqHash(QHash *hash,
- const QString& title,
- const QString& type,
- NumerotationContext *nc) {
- int j = 0;
- for (int i = 0; i < nc->size(); i++) {
- if (nc->itemAt(i).at(0) == type) {
- QString new_value;
- new_value =
- QString::number(
- hash->value(title).at(j).toInt()
- + nc->itemAt(i).at(2).toInt());
- nc->replaceValue(i,new_value);
- j++;
- }
- }
+ QStringList> *hash,
+ const QString& title,
+ const QString& type,
+ NumerotationContext *nc) {
+ int j = 0;
+ for (int i = 0; i < nc->size(); i++) {
+ if (nc->itemAt(i).at(0) == type) {
+ QString new_value;
+ new_value =
+ QString::number(
+ hash->value(title).at(j).toInt()
+ + nc->itemAt(i).at(2).toInt());
+ nc->replaceValue(i,new_value);
+ j++;
+ }
+ }
}
/**
- @brief Diagram::changeZValue
- Change the Z value of the current selected item, according to option
- @param option
+ @brief Diagram::changeZValue
+ Change the Z value of the current selected item, according to option
+ @param option
*/
void Diagram::changeZValue(QET::DepthOption option)
{
- DiagramContent dc(this);
- QUndoCommand *undo = new QUndoCommand(tr("Modifier la profondeur"));
- QList l = dc.items(DiagramContent::SelectedOnly | \
- DiagramContent::Elements | \
- DiagramContent::Shapes | \
- DiagramContent::Images);
- QList list;
- for(QGraphicsItem *item : l)
- list << item->toGraphicsObject();
+ DiagramContent dc(this);
+ QUndoCommand *undo = new QUndoCommand(tr("Modifier la profondeur"));
+ QList l = dc.items(DiagramContent::SelectedOnly | \
+ DiagramContent::Elements | \
+ DiagramContent::Shapes | \
+ DiagramContent::Images);
+ QList list;
+ for(QGraphicsItem *item : l)
+ list << item->toGraphicsObject();
- qreal maxz=0,
- minz=0;
- for(QGraphicsItem *item : this->items())
- {
- qreal z = item->zValue();
- if(z >= Terminal::Z-2)
- continue;
- maxz = std::max(maxz,z);
- minz = std::min(minz,z);
- }
+ qreal maxz=0,
+ minz=0;
+ for(QGraphicsItem *item : this->items())
+ {
+ qreal z = item->zValue();
+ if(z >= Terminal::Z-2)
+ continue;
+ maxz = std::max(maxz,z);
+ minz = std::min(minz,z);
+ }
- if(option == QET::Raise)
- {
- for(QGraphicsObject *qgo : list)
- if(qgo->zValue() < (Terminal::Z-2)) //Ensure item is always below terminal
- new QPropertyUndoCommand(qgo,
- "z",
- qgo->zValue(),
- qgo->zValue()+1,
- undo);
- }
- else if(option == QET::Lower)
- {
- for(QGraphicsObject *qgo : list)
- if(qgo->zValue() < (Terminal::Z-2)) //Ensure item is always below terminal
- new QPropertyUndoCommand(qgo,
- "z",
- qgo->zValue(),
- qgo->zValue()-1,
- undo);
- }
- else if (option == QET::BringForward)
- {
- for(QGraphicsObject *qgo : list)
- new QPropertyUndoCommand(qgo,
- "z",
- qgo->zValue(),
- maxz+1,
- undo);
- }
- else if(option == QET::SendBackward)
- {
- for(QGraphicsObject *qgo : list)
- new QPropertyUndoCommand(qgo,
- "z",
- qgo->zValue(),
- minz-1,
- undo);
- }
+ if(option == QET::Raise)
+ {
+ for(QGraphicsObject *qgo : list)
+ if(qgo->zValue() < (Terminal::Z-2)) //Ensure item is always below terminal
+ new QPropertyUndoCommand(qgo,
+ "z",
+ qgo->zValue(),
+ qgo->zValue()+1,
+ undo);
+ }
+ else if(option == QET::Lower)
+ {
+ for(QGraphicsObject *qgo : list)
+ if(qgo->zValue() < (Terminal::Z-2)) //Ensure item is always below terminal
+ new QPropertyUndoCommand(qgo,
+ "z",
+ qgo->zValue(),
+ qgo->zValue()-1,
+ undo);
+ }
+ else if (option == QET::BringForward)
+ {
+ for(QGraphicsObject *qgo : list)
+ new QPropertyUndoCommand(qgo,
+ "z",
+ qgo->zValue(),
+ maxz+1,
+ undo);
+ }
+ else if(option == QET::SendBackward)
+ {
+ for(QGraphicsObject *qgo : list)
+ new QPropertyUndoCommand(qgo,
+ "z",
+ qgo->zValue(),
+ minz-1,
+ undo);
+ }
- if(undo->childCount())
- this->undoStack().push(undo);
- else
- delete undo;
+ if(undo->childCount())
+ this->undoStack().push(undo);
+ else
+ delete undo;
}
/**
- @brief Diagram::loadElmtFolioSeq
- This class loads all folio sequential variables related
- to the current autonum
+ @brief Diagram::loadElmtFolioSeq
+ This class loads all folio sequential variables related
+ to the current autonum
*/
void Diagram::loadElmtFolioSeq()
{
- QString title = project()->elementCurrentAutoNum();
- NumerotationContext nc = project()->elementAutoNum(title);
+ QString title = project()->elementCurrentAutoNum();
+ NumerotationContext nc = project()->elementAutoNum(title);
- //Unit Folio
- if (m_elmt_unitfolio_max.isEmpty()
- || !m_elmt_unitfolio_max.contains(title)) {
- //Insert Initial Value
- if (project()->elementAutoNumCurrentFormula().contains(
- "%sequf_")) {
- insertFolioSeqHash(&m_elmt_unitfolio_max,
- title,
- "unitfolio",
- &nc);
- project()->addElementAutoNum(title,nc);
- }
- }
- else if (m_elmt_unitfolio_max.contains(title)) {
- //Load Folio Current Value
- if (project()->elementAutoNumCurrentFormula().contains(
- "%sequf_")) {
- loadFolioSeqHash(&m_elmt_unitfolio_max,
- title,
- "unitfolio",
- &nc);
- project()->addElementAutoNum(title,nc);
- }
- }
+ //Unit Folio
+ if (m_elmt_unitfolio_max.isEmpty()
+ || !m_elmt_unitfolio_max.contains(title)) {
+ //Insert Initial Value
+ if (project()->elementAutoNumCurrentFormula().contains(
+ "%sequf_")) {
+ insertFolioSeqHash(&m_elmt_unitfolio_max,
+ title,
+ "unitfolio",
+ &nc);
+ project()->addElementAutoNum(title,nc);
+ }
+ }
+ else if (m_elmt_unitfolio_max.contains(title)) {
+ //Load Folio Current Value
+ if (project()->elementAutoNumCurrentFormula().contains(
+ "%sequf_")) {
+ loadFolioSeqHash(&m_elmt_unitfolio_max,
+ title,
+ "unitfolio",
+ &nc);
+ project()->addElementAutoNum(title,nc);
+ }
+ }
- //Ten Folio
- if (m_elmt_tenfolio_max.isEmpty()
- || !m_elmt_tenfolio_max.contains(title)) {
- //Insert Initial Value
- if (project()->elementAutoNumCurrentFormula().contains(
- "%seqtf_")) {
- insertFolioSeqHash(&m_elmt_tenfolio_max,
- title,
- "tenfolio",
- &nc);
- project()->addElementAutoNum(title,nc);
- }
- }
- else if (m_elmt_tenfolio_max.contains(title)) {
- //Load Folio Current Value
- if (project()->elementAutoNumCurrentFormula().contains(
- "%seqtf_")) {
- loadFolioSeqHash(&m_elmt_tenfolio_max,
- title,
- "tenfolio",
- &nc);
- project()->addElementAutoNum(title,nc);
- }
- }
+ //Ten Folio
+ if (m_elmt_tenfolio_max.isEmpty()
+ || !m_elmt_tenfolio_max.contains(title)) {
+ //Insert Initial Value
+ if (project()->elementAutoNumCurrentFormula().contains(
+ "%seqtf_")) {
+ insertFolioSeqHash(&m_elmt_tenfolio_max,
+ title,
+ "tenfolio",
+ &nc);
+ project()->addElementAutoNum(title,nc);
+ }
+ }
+ else if (m_elmt_tenfolio_max.contains(title)) {
+ //Load Folio Current Value
+ if (project()->elementAutoNumCurrentFormula().contains(
+ "%seqtf_")) {
+ loadFolioSeqHash(&m_elmt_tenfolio_max,
+ title,
+ "tenfolio",
+ &nc);
+ project()->addElementAutoNum(title,nc);
+ }
+ }
- //Hundred Folio
- if (m_elmt_hundredfolio_max.isEmpty()
- || !m_elmt_hundredfolio_max.contains(title)) {
- //Insert Initial Value
- if (project()->elementAutoNumCurrentFormula().contains(
- "%seqhf_")) {
- insertFolioSeqHash(&m_elmt_hundredfolio_max,
- title,
- "hundredfolio",
- &nc);
- project()->addElementAutoNum(title,nc);
- }
- }
- else if (m_elmt_hundredfolio_max.contains(title)) {
- //Load Folio Current Value
- if (project()->elementAutoNumCurrentFormula().contains(
- "%seqhf_")) {
- loadFolioSeqHash(&m_elmt_hundredfolio_max,
- title,
- "hundredfolio",
- &nc);
- project()->addElementAutoNum(title,nc);
- }
- }
+ //Hundred Folio
+ if (m_elmt_hundredfolio_max.isEmpty()
+ || !m_elmt_hundredfolio_max.contains(title)) {
+ //Insert Initial Value
+ if (project()->elementAutoNumCurrentFormula().contains(
+ "%seqhf_")) {
+ insertFolioSeqHash(&m_elmt_hundredfolio_max,
+ title,
+ "hundredfolio",
+ &nc);
+ project()->addElementAutoNum(title,nc);
+ }
+ }
+ else if (m_elmt_hundredfolio_max.contains(title)) {
+ //Load Folio Current Value
+ if (project()->elementAutoNumCurrentFormula().contains(
+ "%seqhf_")) {
+ loadFolioSeqHash(&m_elmt_hundredfolio_max,
+ title,
+ "hundredfolio",
+ &nc);
+ project()->addElementAutoNum(title,nc);
+ }
+ }
}
/**
- @brief Diagram::loadCndFolioSeq
- This class loads all conductor folio sequential variables related
- to the current autonum
+ @brief Diagram::loadCndFolioSeq
+ This class loads all conductor folio sequential variables related
+ to the current autonum
*/
void Diagram::loadCndFolioSeq()
{
- //Conductor
- QString title = project()->conductorCurrentAutoNum();
- NumerotationContext nc = project()->conductorAutoNum(title);
- QString formula = autonum::numerotationContextToFormula(nc);
+ //Conductor
+ QString title = project()->conductorCurrentAutoNum();
+ NumerotationContext nc = project()->conductorAutoNum(title);
+ QString formula = autonum::numerotationContextToFormula(nc);
- //Unit Folio
- if (m_cnd_unitfolio_max.isEmpty()
- || !m_cnd_unitfolio_max.contains(title)) {
- //Insert Initial Value
- if (formula.contains("%sequf_")) {
- insertFolioSeqHash(&m_cnd_unitfolio_max,
- title,
- "unitfolio",
- &nc);
- project()->addConductorAutoNum(title,nc);
- }
- }
- else if (m_cnd_unitfolio_max.contains(title)) {
- //Load Folio Current Value
- if (formula.contains("%sequf_")) {
- loadFolioSeqHash(&m_cnd_unitfolio_max,
- title,
- "unitfolio",
- &nc);
- project()->addConductorAutoNum(title,nc);
- }
- }
+ //Unit Folio
+ if (m_cnd_unitfolio_max.isEmpty()
+ || !m_cnd_unitfolio_max.contains(title)) {
+ //Insert Initial Value
+ if (formula.contains("%sequf_")) {
+ insertFolioSeqHash(&m_cnd_unitfolio_max,
+ title,
+ "unitfolio",
+ &nc);
+ project()->addConductorAutoNum(title,nc);
+ }
+ }
+ else if (m_cnd_unitfolio_max.contains(title)) {
+ //Load Folio Current Value
+ if (formula.contains("%sequf_")) {
+ loadFolioSeqHash(&m_cnd_unitfolio_max,
+ title,
+ "unitfolio",
+ &nc);
+ project()->addConductorAutoNum(title,nc);
+ }
+ }
- //Ten Folio
- if (m_cnd_tenfolio_max.isEmpty()
- || !m_cnd_tenfolio_max.contains(title)) {
- //Insert Initial Value
- if (formula.contains("%seqtf_")) {
- insertFolioSeqHash(&m_cnd_tenfolio_max,
- title,
- "tenfolio",
- &nc);
- project()->addConductorAutoNum(title,nc);
- }
- }
- else if (m_cnd_tenfolio_max.contains(title)) {
- //Load Folio Current Value
- if (formula.contains("%seqtf_")) {
- loadFolioSeqHash(&m_cnd_tenfolio_max,
- title,
- "tenfolio",
- &nc);
- project()->addConductorAutoNum(title,nc);
- }
- }
+ //Ten Folio
+ if (m_cnd_tenfolio_max.isEmpty()
+ || !m_cnd_tenfolio_max.contains(title)) {
+ //Insert Initial Value
+ if (formula.contains("%seqtf_")) {
+ insertFolioSeqHash(&m_cnd_tenfolio_max,
+ title,
+ "tenfolio",
+ &nc);
+ project()->addConductorAutoNum(title,nc);
+ }
+ }
+ else if (m_cnd_tenfolio_max.contains(title)) {
+ //Load Folio Current Value
+ if (formula.contains("%seqtf_")) {
+ loadFolioSeqHash(&m_cnd_tenfolio_max,
+ title,
+ "tenfolio",
+ &nc);
+ project()->addConductorAutoNum(title,nc);
+ }
+ }
- //Hundred Folio
- if (m_cnd_hundredfolio_max.isEmpty()
- || !m_cnd_hundredfolio_max.contains(title)) {
- //Insert Initial Value
- if (formula.contains("%seqhf_")) {
- insertFolioSeqHash(&m_cnd_hundredfolio_max,
- title,
- "hundredfolio",
- &nc);
- project()->addConductorAutoNum(title,nc);
- }
- }
- else if (m_cnd_hundredfolio_max.contains(title)) {
- //Load Folio Current Value
- if (formula.contains("%seqhf_")) {
- loadFolioSeqHash(&m_cnd_hundredfolio_max,
- title,
- "hundredfolio",
- &nc);
- project()->addConductorAutoNum(title,nc);
- }
- }
+ //Hundred Folio
+ if (m_cnd_hundredfolio_max.isEmpty()
+ || !m_cnd_hundredfolio_max.contains(title)) {
+ //Insert Initial Value
+ if (formula.contains("%seqhf_")) {
+ insertFolioSeqHash(&m_cnd_hundredfolio_max,
+ title,
+ "hundredfolio",
+ &nc);
+ project()->addConductorAutoNum(title,nc);
+ }
+ }
+ else if (m_cnd_hundredfolio_max.contains(title)) {
+ //Load Folio Current Value
+ if (formula.contains("%seqhf_")) {
+ loadFolioSeqHash(&m_cnd_hundredfolio_max,
+ title,
+ "hundredfolio",
+ &nc);
+ project()->addConductorAutoNum(title,nc);
+ }
+ }
}
/**
- @brief Diagram::title
- @return title of the titleblock
- \~Frenchle titre du cartouche
+ @brief Diagram::title
+ @return title of the titleblock
+ \~Frenchle titre du cartouche
*/
QString Diagram::title() const
{
- return(border_and_titleblock.title());
+ return(border_and_titleblock.title());
}
/**
- @brief Diagram::elements
- @return the list containing all elements
+ @brief Diagram::elements
+ @return the list containing all elements
*/
QList Diagram::elements() const
{
- QList element_list;
- foreach (QGraphicsItem *qgi, items()) {
- if (Element *elmt = qgraphicsitem_cast(qgi))
- element_list < element_list;
+ foreach (QGraphicsItem *qgi, items()) {
+ if (Element *elmt = qgraphicsitem_cast(qgi))
+ element_list < Diagram::conductors() const
{
- QList cnd_list;
- foreach (QGraphicsItem *qgi, items()) {
- if (Conductor *cnd = qgraphicsitem_cast(qgi))
- cnd_list < cnd_list;
+ foreach (QGraphicsItem *qgi, items()) {
+ if (Conductor *cnd = qgraphicsitem_cast(qgi))
+ cnd_list < location() == location) {
- return(true);
- }
- }
- return(false);
+ for(Element *element : elements()) {
+ if (element -> location() == location) {
+ return(true);
+ }
+ }
+ return(false);
}
/**
- @brief Diagram::usesTitleBlockTemplate
- @param name : a title block template name
- @return true if the provided template is used by this diagram, false
- otherwise.
+ @brief Diagram::usesTitleBlockTemplate
+ @param name : a title block template name
+ @return true if the provided template is used by this diagram, false
+ otherwise.
*/
bool Diagram::usesTitleBlockTemplate(const QString &name) {
- return(name == border_and_titleblock.titleBlockTemplateName());
+ return(name == border_and_titleblock.titleBlockTemplateName());
}
/**
- @brief Diagram::freezeElements
- Freeze every existent element label.
+ @brief Diagram::freezeElements
+ Freeze every existent element label.
*/
void Diagram::freezeElements(bool freeze) {
- foreach (Element *elmt, elements()) {
- elmt->freezeLabel(freeze);
- }
+ foreach (Element *elmt, elements()) {
+ elmt->freezeLabel(freeze);
+ }
}
/**
- @brief Diagram::unfreezeElements
- Unfreeze every existent element label.
+ @brief Diagram::unfreezeElements
+ Unfreeze every existent element label.
*/
void Diagram::unfreezeElements()
{
- foreach (Element *elmt, elements()) {
- elmt->freezeLabel(false);
- }
+ foreach (Element *elmt, elements()) {
+ elmt->freezeLabel(false);
+ }
}
/**
- @brief Diagram::freezeNewElements
- Set new element label to be frozen.
+ @brief Diagram::freezeNewElements
+ Set new element label to be frozen.
*/
void Diagram::setFreezeNewElements(bool b) {
- m_freeze_new_elements = b;
+ m_freeze_new_elements = b;
}
/**
- @brief Diagram::freezeNewElements
- @return current freeze new element status .
+ @brief Diagram::freezeNewElements
+ @return current freeze new element status .
*/
bool Diagram::freezeNewElements()
{
- return m_freeze_new_elements;
+ return m_freeze_new_elements;
}
/**
- @brief Diagram::freezeConductors
- Freeze every existent conductor label.
+ @brief Diagram::freezeConductors
+ Freeze every existent conductor label.
*/
void Diagram::freezeConductors(bool freeze) {
- foreach (Conductor *cnd, conductors()) {
- cnd->setFreezeLabel(freeze);
- }
+ foreach (Conductor *cnd, conductors()) {
+ cnd->setFreezeLabel(freeze);
+ }
}
/**
- @brief Diagram::setfreezeNewConductors
- Set new conductor label to be frozen.
+ @brief Diagram::setfreezeNewConductors
+ Set new conductor label to be frozen.
*/
void Diagram::setFreezeNewConductors(bool b) {
- m_freeze_new_conductors_ = b;
+ m_freeze_new_conductors_ = b;
}
/**
- @brief Diagram::freezeNewConductors
- @return current freeze new conductor status .
+ @brief Diagram::freezeNewConductors
+ @return current freeze new conductor status .
*/
bool Diagram::freezeNewConductors()
{
- return m_freeze_new_conductors_;
+ return m_freeze_new_conductors_;
}
/**
- @brief Diagram::adjustSceneRect
- Recalcul and adjust the size of the scene
+ @brief Diagram::adjustSceneRect
+ Recalcul and adjust the size of the scene
*/
void Diagram::adjustSceneRect()
{
- QRectF old_rect = sceneRect();
- setSceneRect(border_and_titleblock.borderAndTitleBlockRect().united(
- itemsBoundingRect()));
- update(old_rect.united(sceneRect()));
+ QRectF old_rect = sceneRect();
+ setSceneRect(border_and_titleblock.borderAndTitleBlockRect().united(
+ itemsBoundingRect()));
+ update(old_rect.united(sceneRect()));
}
/**
- @brief Diagram::applyProperties
- This method allows you to apply new rendering options while
- accessing the current rendering properties.
- \~French Cette methode permet d'appliquer de nouvelles options de rendu
- tout en accedant aux proprietes de rendu en cours.
- \~ @param new_properties :
- New rendering options to apply
- \~French Nouvelles options de rendu a appliquer
- \~ @return rendering options before applying new_properties
- \~French les options de rendu avant l'application de new_properties
+ @brief Diagram::applyProperties
+ This method allows you to apply new rendering options while
+ accessing the current rendering properties.
+ \~French Cette methode permet d'appliquer de nouvelles options de rendu
+ tout en accedant aux proprietes de rendu en cours.
+ \~ @param new_properties :
+ New rendering options to apply
+ \~French Nouvelles options de rendu a appliquer
+ \~ @return rendering options before applying new_properties
+ \~French les options de rendu avant l'application de new_properties
*/
ExportProperties Diagram::applyProperties(
- const ExportProperties &new_properties) {
- // exports current rendering options
- // exporte les options de rendu en cours
- ExportProperties old_properties;
- old_properties.draw_grid = displayGrid();
- old_properties.draw_border = border_and_titleblock.borderIsDisplayed();
- old_properties.draw_titleblock = border_and_titleblock.titleBlockIsDisplayed();
- old_properties.draw_terminals = drawTerminals();
- old_properties.draw_colored_conductors = drawColoredConductors();
- old_properties.exported_area = useBorder() ? QET::BorderArea
- : QET::ElementsArea;
+ const ExportProperties &new_properties) {
+ // exports current rendering options
+ // exporte les options de rendu en cours
+ ExportProperties old_properties;
+ old_properties.draw_grid = displayGrid();
+ old_properties.draw_border = border_and_titleblock.borderIsDisplayed();
+ old_properties.draw_titleblock = border_and_titleblock.titleBlockIsDisplayed();
+ old_properties.draw_terminals = drawTerminals();
+ old_properties.draw_colored_conductors = drawColoredConductors();
+ old_properties.exported_area = useBorder() ? QET::BorderArea
+ : QET::ElementsArea;
- // apply the new rendering options
- // applique les nouvelles options de rendu
- setUseBorder (new_properties.exported_area == QET::BorderArea);
- setDrawTerminals (new_properties.draw_terminals);
- setDrawColoredConductors (new_properties.draw_colored_conductors);
- setDisplayGrid (new_properties.draw_grid);
- border_and_titleblock.displayBorder(new_properties.draw_border);
- border_and_titleblock.displayTitleBlock (new_properties.draw_titleblock);
+ // apply the new rendering options
+ // applique les nouvelles options de rendu
+ setUseBorder (new_properties.exported_area == QET::BorderArea);
+ setDrawTerminals (new_properties.draw_terminals);
+ setDrawColoredConductors (new_properties.draw_colored_conductors);
+ setDisplayGrid (new_properties.draw_grid);
+ border_and_titleblock.displayBorder(new_properties.draw_border);
+ border_and_titleblock.displayTitleBlock (new_properties.draw_titleblock);
- // return old rendering options
- // retourne les anciennes options de rendu
- return(old_properties);
+ // return old rendering options
+ // retourne les anciennes options de rendu
+ return(old_properties);
}
/**
- @brief Diagram::convertPosition
- @param pos :
- Cartesian position (ex: 10.3, 45.2) to transform into position
- in the grid (ex: B2)
- \~French Position cartesienne (ex : 10.3, 45.2) a transformer en position
- dans la grille (ex : B2)
- \~ @return a position in the grid corresponding to pos
- \~French la position dans la grille correspondant a pos
+ @brief Diagram::convertPosition
+ @param pos :
+ Cartesian position (ex: 10.3, 45.2) to transform into position
+ in the grid (ex: B2)
+ \~French Position cartesienne (ex : 10.3, 45.2) a transformer en position
+ dans la grille (ex : B2)
+ \~ @return a position in the grid corresponding to pos
+ \~French la position dans la grille correspondant a pos
*/
DiagramPosition Diagram::convertPosition(const QPointF &pos) {
- // delegue le calcul au BorderTitleBlock
- DiagramPosition diagram_position =
- border_and_titleblock.convertPosition(pos);
+ // delegue le calcul au BorderTitleBlock
+ DiagramPosition diagram_position =
+ border_and_titleblock.convertPosition(pos);
- // embarque la position cartesienne
- diagram_position.setPosition(pos);
+ // embarque la position cartesienne
+ diagram_position.setPosition(pos);
- return(diagram_position);
+ return(diagram_position);
}
/**
- @brief Diagram::snapToGrid
- Return a nearest snap point of p
- @param p point to find the nearest snaped point
- @return
+ @brief Diagram::snapToGrid
+ Return a nearest snap point of p
+ @param p point to find the nearest snaped point
+ @return
*/
QPointF Diagram::snapToGrid(const QPointF &p)
{
- QSettings settings;
- int xGrid = settings.value("diagrameditor/Xgrid",
- Diagram::xGrid).toInt();
- int yGrid = settings.value("diagrameditor/Ygrid",
- Diagram::yGrid).toInt();
+ QSettings settings;
+ int xGrid = settings.value("diagrameditor/Xgrid",
+ Diagram::xGrid).toInt();
+ int yGrid = settings.value("diagrameditor/Ygrid",
+ Diagram::yGrid).toInt();
- //Return a point rounded to the nearest pixel
- if (QApplication::keyboardModifiers().testFlag(Qt::ControlModifier))
- {
- int p_x = qRound(p.x());
- int p_y = qRound(p.y());
- return (QPointF(p_x, p_y));
- }
+ //Return a point rounded to the nearest pixel
+ if (QApplication::keyboardModifiers().testFlag(Qt::ControlModifier))
+ {
+ int p_x = qRound(p.x());
+ int p_y = qRound(p.y());
+ return (QPointF(p_x, p_y));
+ }
- //Return a point snapped to the grid
- int p_x = qRound(p.x() / xGrid) * xGrid;
- int p_y = qRound(p.y() / yGrid) * yGrid;
- return (QPointF(p_x, p_y));
+ //Return a point snapped to the grid
+ int p_x = qRound(p.x() / xGrid) * xGrid;
+ int p_y = qRound(p.y() / yGrid) * yGrid;
+ return (QPointF(p_x, p_y));
}
/**
- @brief Diagram::setDrawTerminals
- Defines whether or not to display the terminals
- \~French Definit s'il faut afficher ou non les bornes
- \~ @param dt : true to display the bounds, false otherwise
- \~French true pour afficher les bornes, false sinon
+ @brief Diagram::setDrawTerminals
+ Defines whether or not to display the terminals
+ \~French Definit s'il faut afficher ou non les bornes
+ \~ @param dt : true to display the bounds, false otherwise
+ \~French true pour afficher les bornes, false sinon
*/
void Diagram::setDrawTerminals(bool dt) {
- foreach(QGraphicsItem *qgi, items()) {
- if (Terminal *t = qgraphicsitem_cast(qgi)) {
- t -> setVisible(dt);
- }
- }
+ foreach(QGraphicsItem *qgi, items()) {
+ if (Terminal *t = qgraphicsitem_cast(qgi)) {
+ t -> setVisible(dt);
+ }
+ }
}
/**
- @brief Diagram::setDrawColoredConductors
- Defines whether or not to respect the colors of the conductors.
- If not, the conductors are all drawn in black.
- \~French Definit s'il faut respecter ou non les couleurs des conducteurs.
- Si non, les conducteurs sont tous dessines en noir.
- \~ @param dcc true to respect the colors, false otherwise
- \~French dcc true pour respecter les couleurs, false sinon
+ @brief Diagram::setDrawColoredConductors
+ Defines whether or not to respect the colors of the conductors.
+ If not, the conductors are all drawn in black.
+ \~French Definit s'il faut respecter ou non les couleurs des conducteurs.
+ Si non, les conducteurs sont tous dessines en noir.
+ \~ @param dcc true to respect the colors, false otherwise
+ \~French dcc true pour respecter les couleurs, false sinon
*/
void Diagram::setDrawColoredConductors(bool dcc) {
- draw_colored_conductors_ = dcc;
+ draw_colored_conductors_ = dcc;
}
/**
- @brief Diagram::selectedConductors
- @return the list of conductors selected on the diagram
- \~French la liste des conducteurs selectionnes sur le schema
+ @brief Diagram::selectedConductors
+ @return the list of conductors selected on the diagram
+ \~French la liste des conducteurs selectionnes sur le schema
*/
QSet Diagram::selectedConductors() const
{
- QSet conductors_set;
- foreach(QGraphicsItem *qgi, selectedItems()) {
- if (Conductor *c = qgraphicsitem_cast(qgi)) {
- conductors_set << c;
- }
- }
- return(conductors_set);
+ QSet conductors_set;
+ foreach(QGraphicsItem *qgi, selectedItems()) {
+ if (Conductor *c = qgraphicsitem_cast(qgi)) {
+ conductors_set << c;
+ }
+ }
+ return(conductors_set);
}
/**
- @brief Diagram::clipboardMayContainDiagram
- @return true if the clipboard appears to contain a schema
- \~French true si le presse-papier semble contenir un schema
+ @brief Diagram::clipboardMayContainDiagram
+ @return true if the clipboard appears to contain a schema
+ \~French true si le presse-papier semble contenir un schema
*/
bool Diagram::clipboardMayContainDiagram()
{
- QString clipboard_text = QApplication::clipboard() -> text().trimmed();
- bool may_be_diagram = clipboard_text.startsWith("");
- return(may_be_diagram);
+ QString clipboard_text = QApplication::clipboard() -> text().trimmed();
+ bool may_be_diagram = clipboard_text.startsWith("");
+ return(may_be_diagram);
}
/**
- @brief Diagram::project
- @return the project to which this schema belongs
- or 0 if it is an independent schema.
- \~French le projet auquel ce schema appartient
- ou 0 s'il s'agit d'un schema independant.
+ @brief Diagram::project
+ @return the project to which this schema belongs
+ or 0 if it is an independent schema.
+ \~French le projet auquel ce schema appartient
+ ou 0 s'il s'agit d'un schema independant.
*/
QETProject *Diagram::project() const
{
- return(m_project);
+ return(m_project);
}
/**
- @brief Diagram::folioIndex
- @return the folio number of this diagram within its parent project,
- or -1 if it is has no parent project
+ @brief Diagram::folioIndex
+ @return the folio number of this diagram within its parent project,
+ or -1 if it is has no parent project
*/
int Diagram::folioIndex() const
{
- if (!m_project) return(-1);
- return(m_project -> folioIndex(this));
+ if (!m_project) return(-1);
+ return(m_project -> folioIndex(this));
}
/**
- @brief Diagram::isReadOnly
- @return true if this diagram is read only.
- This method is same has call Diagram::project() -> isReadOnly()
+ @brief Diagram::isReadOnly
+ @return true if this diagram is read only.
+ This method is same has call Diagram::project() -> isReadOnly()
*/
bool Diagram::isReadOnly() const
{
- return m_project -> isReadOnly();
+ return m_project -> isReadOnly();
}
/**
- @brief Diagram::content
- @return The content of the diagram.
- The conductors are all seated in conductorsToMove.
- \~French Le contenu du schema. Les conducteurs sont tous places dans
- conductorsToMove.
+ @brief Diagram::content
+ @return The content of the diagram.
+ The conductors are all seated in conductorsToMove.
+ \~French Le contenu du schema. Les conducteurs sont tous places dans
+ conductorsToMove.
*/
DiagramContent Diagram::content() const
{
- DiagramContent dc;
- foreach(QGraphicsItem *qgi, items()) {
- if (Element *e = qgraphicsitem_cast(qgi)) {
- dc.m_elements << e;
- } else if (IndependentTextItem *iti =
- qgraphicsitem_cast(qgi)) {
- dc.m_text_fields << iti;
- } else if (Conductor *c =
- qgraphicsitem_cast(qgi)) {
- dc.m_conductors_to_move << c;
- }
- }
- return(dc);
+ DiagramContent dc;
+ foreach(QGraphicsItem *qgi, items()) {
+ if (Element *e = qgraphicsitem_cast(qgi)) {
+ dc.m_elements << e;
+ } else if (IndependentTextItem *iti =
+ qgraphicsitem_cast(qgi)) {
+ dc.m_text_fields << iti;
+ } else if (Conductor *c =
+ qgraphicsitem_cast(qgi)) {
+ dc.m_conductors_to_move << c;
+ }
+ }
+ return(dc);
}
/**
- @brief Diagram::canRotateSelection
- @return True if a least one of selected items can be rotated
+ @brief Diagram::canRotateSelection
+ @return True if a least one of selected items can be rotated
*/
bool Diagram::canRotateSelection() const
{
- for (QGraphicsItem *qgi : selectedItems())
- {
- if (qgi->type() == IndependentTextItem::Type ||
- qgi->type() == ConductorTextItem::Type ||
- qgi->type() == DiagramImageItem::Type ||
- qgi->type() == Element::Type ||
- qgi->type() == DynamicElementTextItem::Type)
- return true;
+ for (QGraphicsItem *qgi : selectedItems())
+ {
+ if (qgi->type() == IndependentTextItem::Type ||
+ qgi->type() == ConductorTextItem::Type ||
+ qgi->type() == DiagramImageItem::Type ||
+ qgi->type() == Element::Type ||
+ qgi->type() == DynamicElementTextItem::Type)
+ return true;
- if(qgi->type() == QGraphicsItemGroup::Type)
- if(dynamic_cast(qgi))
- return true;
- }
+ if(qgi->type() == QGraphicsItemGroup::Type)
+ if(dynamic_cast(qgi))
+ return true;
+ }
- return false;
+ return false;
}
diff --git a/sources/diagram.h b/sources/diagram.h
index f0df1ff60..553335b8b 100644
--- a/sources/diagram.h
+++ b/sources/diagram.h
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#ifndef DIAGRAM_H
#define DIAGRAM_H
@@ -47,377 +47,377 @@ class DiagramFolioList;
class QETProject;
/**
- @brief The Diagram class
- This class represents an electric diagram.
- It manages its various child elements,
- conductors and texts and handles their graphic rendering.
+ @brief The Diagram class
+ This class represents an electric diagram.
+ It manages its various child elements,
+ conductors and texts and handles their graphic rendering.
*/
class Diagram : public QGraphicsScene
{
- friend DiagramFolioList;
- friend QETProject;
+ friend DiagramFolioList;
+ friend QETProject;
- Q_OBJECT
-
- // constructors, destructor
- private:
- Diagram(QETProject *project);
- ~Diagram() override;
- Diagram(const Diagram &diagram);
-
- // ATTRIBUTES
- public:
- /**
- @brief The BorderOptions enum
- Represents available options when rendering a particular diagram:
- EmptyBorder: display border only
- TitleBlock: display title block
- Columns: display columns
- */
- enum BorderOptions { EmptyBorder, TitleBlock, Columns };
- /// Represents available option of Numerotation type.
- enum NumerotationType { Conductors };
- /// Default properties for new conductors
- ConductorProperties defaultConductorProperties;
- /// Diagram dimensions and title block
- BorderTitleBlock border_and_titleblock;
- /// abscissa grid step size
- static int xGrid;
- /// ordinate grid step size
- static int yGrid;
- /// Key grid x step size
- static int xKeyGrid;
- /// Key grid y step size
- static int yKeyGrid;
- /// Key grid fine x step size
- static int xKeyGridFine;
- /// Key grid fine y step size
- static int yKeyGridFine;
- /// margin around the diagram
- static const qreal margin;
- /// background color of diagram
- static QColor background_color;
- /// Hash containing max values for folio sequential autonums in this diagram
- QHash m_elmt_unitfolio_max;
- QHash m_elmt_tenfolio_max;
- QHash m_elmt_hundredfolio_max;
- /// Hash containing max values for folio sequential autonums in this diagram
- QHash m_cnd_unitfolio_max;
- QHash m_cnd_tenfolio_max;
- QHash m_cnd_hundredfolio_max;
+ Q_OBJECT
+
+ // constructors, destructor
+ private:
+ Diagram(QETProject *project);
+ ~Diagram() override;
+ Diagram(const Diagram &diagram);
+
+ // ATTRIBUTES
+ public:
+ /**
+ @brief The BorderOptions enum
+ Represents available options when rendering a particular diagram:
+ EmptyBorder: display border only
+ TitleBlock: display title block
+ Columns: display columns
+ */
+ enum BorderOptions { EmptyBorder, TitleBlock, Columns };
+ /// Represents available option of Numerotation type.
+ enum NumerotationType { Conductors };
+ /// Default properties for new conductors
+ ConductorProperties defaultConductorProperties;
+ /// Diagram dimensions and title block
+ BorderTitleBlock border_and_titleblock;
+ /// abscissa grid step size
+ static int xGrid;
+ /// ordinate grid step size
+ static int yGrid;
+ /// Key grid x step size
+ static int xKeyGrid;
+ /// Key grid y step size
+ static int yKeyGrid;
+ /// Key grid fine x step size
+ static int xKeyGridFine;
+ /// Key grid fine y step size
+ static int yKeyGridFine;
+ /// margin around the diagram
+ static const qreal margin;
+ /// background color of diagram
+ static QColor background_color;
+ /// Hash containing max values for folio sequential autonums in this diagram
+ QHash m_elmt_unitfolio_max;
+ QHash m_elmt_tenfolio_max;
+ QHash m_elmt_hundredfolio_max;
+ /// Hash containing max values for folio sequential autonums in this diagram
+ QHash m_cnd_unitfolio_max;
+ QHash m_cnd_tenfolio_max;
+ QHash m_cnd_hundredfolio_max;
- private:
- QGraphicsLineItem *conductor_setter_;
- ElementsMover m_elements_mover;
- ElementTextsMover m_element_texts_mover;
- QGIManager *qgi_manager_;
- QETProject *m_project;
+ private:
+ QGraphicsLineItem *conductor_setter_;
+ ElementsMover m_elements_mover;
+ ElementTextsMover m_element_texts_mover;
+ QGIManager *qgi_manager_;
+ QETProject *m_project;
- QDomDocument xml_document_;
+ QDomDocument xml_document_;
- qreal diagram_qet_version_;
+ qreal diagram_qet_version_;
- bool draw_grid_;
- bool use_border_;
- bool draw_terminals_;
- bool draw_colored_conductors_;
+ bool draw_grid_;
+ bool use_border_;
+ bool draw_terminals_;
+ bool draw_colored_conductors_;
- QString m_conductors_autonum_name;
- DiagramEventInterface *m_event_interface;
+ QString m_conductors_autonum_name;
+ DiagramEventInterface *m_event_interface;
- bool m_freeze_new_elements;
- bool m_freeze_new_conductors_;
- QUuid m_uuid = QUuid::createUuid();
-
- // METHODS
- protected:
- void drawBackground(QPainter *, const QRectF &) override;
+ bool m_freeze_new_elements;
+ bool m_freeze_new_conductors_;
+ QUuid m_uuid = QUuid::createUuid();
+
+ // METHODS
+ protected:
+ void drawBackground(QPainter *, const QRectF &) override;
- void mouseDoubleClickEvent (
- QGraphicsSceneMouseEvent *event) override;
- void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
- void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
- void mouseReleaseEvent (
- QGraphicsSceneMouseEvent *event) override;
- void wheelEvent (QGraphicsSceneWheelEvent *event) override;
- void keyPressEvent (QKeyEvent *event) override;
- void keyReleaseEvent (QKeyEvent *) override;
-
- public:
- QUuid uuid();
- void setEventInterface (DiagramEventInterface *event_interface);
- void clearEventInterface();
+ void mouseDoubleClickEvent (
+ QGraphicsSceneMouseEvent *event) override;
+ void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
+ void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
+ void mouseReleaseEvent (
+ QGraphicsSceneMouseEvent *event) override;
+ void wheelEvent (QGraphicsSceneWheelEvent *event) override;
+ void keyPressEvent (QKeyEvent *event) override;
+ void keyReleaseEvent (QKeyEvent *) override;
+
+ public:
+ QUuid uuid();
+ void setEventInterface (DiagramEventInterface *event_interface);
+ void clearEventInterface();
- //methods related to autonum
- QString conductorsAutonumName() const;
- void setConductorsAutonumName(const QString &name);
+ //methods related to autonum
+ QString conductorsAutonumName() const;
+ void setConductorsAutonumName(const QString &name);
- static bool clipboardMayContainDiagram();
-
- // methods related to parent project
- QETProject *project() const;
- int folioIndex() const;
- void showMe() {emit showDiagram(this);}
- bool isReadOnly() const;
-
- // methods related to conductor creation
- void setConductor(bool);
- void setConductorStart (QPointF);
- void setConductorStop(QPointF);
- QList < QSet > potentials();
-
- // methods related to XML import/export
- QDomDocument toXml(bool = true);
- bool initFromXml(QDomElement &,
- QPointF = QPointF(),
- bool = true,
- DiagramContent * = nullptr);
- bool fromXml(QDomDocument &,
- QPointF = QPointF(),
- bool = true,
- DiagramContent * = nullptr);
- bool fromXml(QDomElement &,
- QPointF = QPointF(),
- bool = true,
- DiagramContent * = nullptr);
- void folioSequentialsToXml(QHash*,
- QDomElement *,
- const QString&,
- const QString&,
- QDomDocument *);
- void folioSequentialsFromXml(const QDomElement&,
- QHash*,
- const QString&,
- const QString&,
- const QString&,
- const QString&);
-
- void refreshContents();
-
- // methods related to graphics items addition/removal on the diagram
- virtual void addItem (QGraphicsItem *item);
- virtual void removeItem (QGraphicsItem *item);
-
- // methods related to graphics options
- ExportProperties applyProperties(const ExportProperties &);
- void setDisplayGrid(bool);
- bool displayGrid();
- void setUseBorder(bool);
- bool useBorder();
- void setBorderOptions(BorderOptions);
- BorderOptions borderOptions();
- DiagramPosition convertPosition(const QPointF &);
- static QPointF snapToGrid(const QPointF &p);
-
- bool drawTerminals() const;
- void setDrawTerminals(bool);
- bool drawColoredConductors() const;
- void setDrawColoredConductors(bool);
-
- QString title() const;
- bool toPaintDevice(QPaintDevice &, int = -1, int = -1,
- Qt::AspectRatioMode = Qt::KeepAspectRatio);
- QSize imageSize() const;
-
- bool isEmpty() const;
-
- QList elements() const;
- QList conductors() const;
- QSet selectedConductors() const;
- DiagramContent content() const;
- bool canRotateSelection() const;
- ElementsMover &elementsMover();
- ElementTextsMover &elementTextsMover();
- bool usesElement(const ElementsLocation &);
- bool usesTitleBlockTemplate(const QString &);
-
- QUndoStack &undoStack();
- QGIManager &qgiManager();
-
- //methods related to element label Update Policy
- void freezeElements(bool freeze);
- void unfreezeElements();
- void setFreezeNewElements(bool);
- bool freezeNewElements();
-
- //methods related to conductor label Update Policy
- void freezeConductors(bool freeze);
- void setFreezeNewConductors(bool);
- bool freezeNewConductors();
-
- //methods related to insertion and loading of folio sequential
- void insertFolioSeqHash (QHash *hash,
- const QString& title,
- const QString& seq,
- NumerotationContext *nc);
- void loadFolioSeqHash (QHash *hash,
- const QString& title, const QString& seq,
- NumerotationContext *nc);
- void changeZValue(QET::DepthOption option);
+ static bool clipboardMayContainDiagram();
+
+ // methods related to parent project
+ QETProject *project() const;
+ int folioIndex() const;
+ void showMe() {emit showDiagram(this);}
+ bool isReadOnly() const;
+
+ // methods related to conductor creation
+ void setConductor(bool);
+ void setConductorStart (QPointF);
+ void setConductorStop(QPointF);
+ QList < QSet > potentials();
+
+ // methods related to XML import/export
+ QDomDocument toXml(bool = true);
+ bool initFromXml(QDomElement &,
+ QPointF = QPointF(),
+ bool = true,
+ DiagramContent * = nullptr);
+ bool fromXml(QDomDocument &,
+ QPointF = QPointF(),
+ bool = true,
+ DiagramContent * = nullptr);
+ bool fromXml(QDomElement &,
+ QPointF = QPointF(),
+ bool = true,
+ DiagramContent * = nullptr);
+ void folioSequentialsToXml(QHash*,
+ QDomElement *,
+ const QString&,
+ const QString&,
+ QDomDocument *);
+ void folioSequentialsFromXml(const QDomElement&,
+ QHash*,
+ const QString&,
+ const QString&,
+ const QString&,
+ const QString&);
+
+ void refreshContents();
+
+ // methods related to graphics items addition/removal on the diagram
+ virtual void addItem (QGraphicsItem *item);
+ virtual void removeItem (QGraphicsItem *item);
+
+ // methods related to graphics options
+ ExportProperties applyProperties(const ExportProperties &);
+ void setDisplayGrid(bool);
+ bool displayGrid();
+ void setUseBorder(bool);
+ bool useBorder();
+ void setBorderOptions(BorderOptions);
+ BorderOptions borderOptions();
+ DiagramPosition convertPosition(const QPointF &);
+ static QPointF snapToGrid(const QPointF &p);
+
+ bool drawTerminals() const;
+ void setDrawTerminals(bool);
+ bool drawColoredConductors() const;
+ void setDrawColoredConductors(bool);
+
+ QString title() const;
+ bool toPaintDevice(QPaintDevice &, int = -1, int = -1,
+ Qt::AspectRatioMode = Qt::KeepAspectRatio);
+ QSize imageSize() const;
+
+ bool isEmpty() const;
+
+ QList elements() const;
+ QList conductors() const;
+ QSet selectedConductors() const;
+ DiagramContent content() const;
+ bool canRotateSelection() const;
+ ElementsMover &elementsMover();
+ ElementTextsMover &elementTextsMover();
+ bool usesElement(const ElementsLocation &);
+ bool usesTitleBlockTemplate(const QString &);
+
+ QUndoStack &undoStack();
+ QGIManager &qgiManager();
+
+ //methods related to element label Update Policy
+ void freezeElements(bool freeze);
+ void unfreezeElements();
+ void setFreezeNewElements(bool);
+ bool freezeNewElements();
+
+ //methods related to conductor label Update Policy
+ void freezeConductors(bool freeze);
+ void setFreezeNewConductors(bool);
+ bool freezeNewConductors();
+
+ //methods related to insertion and loading of folio sequential
+ void insertFolioSeqHash (QHash *hash,
+ const QString& title,
+ const QString& seq,
+ NumerotationContext *nc);
+ void loadFolioSeqHash (QHash *hash,
+ const QString& title, const QString& seq,
+ NumerotationContext *nc);
+ void changeZValue(QET::DepthOption option);
- public slots:
- void adjustSceneRect ();
- void titleChanged(const QString &);
- void titleBlockTemplateChanged(const QString &);
- void titleBlockTemplateRemoved(const QString &,
- const QString & = QString());
- void setTitleBlockTemplate(const QString &);
- void updateLabels();
- void loadElmtFolioSeq();
- void loadCndFolioSeq();
-
- // methods related to graphics items selection
- void selectAll();
- void deselectAll();
- void invertSelection();
+ public slots:
+ void adjustSceneRect ();
+ void titleChanged(const QString &);
+ void titleBlockTemplateChanged(const QString &);
+ void titleBlockTemplateRemoved(const QString &,
+ const QString & = QString());
+ void setTitleBlockTemplate(const QString &);
+ void updateLabels();
+ void loadElmtFolioSeq();
+ void loadCndFolioSeq();
+
+ // methods related to graphics items selection
+ void selectAll();
+ void deselectAll();
+ void invertSelection();
- signals:
- void showDiagram (Diagram *);
- void usedTitleBlockTemplateChanged(const QString &);
- void diagramTitleChanged(Diagram *, const QString &);
+ signals:
+ void showDiagram (Diagram *);
+ void usedTitleBlockTemplateChanged(const QString &);
+ void diagramTitleChanged(Diagram *, const QString &);
- /// Signal emitted when users wish to locate an element
- /// from the diagram within elements collection
- void findElementRequired(const ElementsLocation &);
+ /// Signal emitted when users wish to locate an element
+ /// from the diagram within elements collection
+ void findElementRequired(const ElementsLocation &);
- void diagramActivated();
+ void diagramActivated();
};
Q_DECLARE_METATYPE(Diagram *)
/**
- @brief Diagram::setConductor
- Display or hide the conductor setter,
- i.e. a dashed conductor stub which appears
- when creating a conductor between two terminals.
- @param adding true add conductor ,false remove conductor
+ @brief Diagram::setConductor
+ Display or hide the conductor setter,
+ i.e. a dashed conductor stub which appears
+ when creating a conductor between two terminals.
+ @param adding true add conductor ,false remove conductor
*/
inline void Diagram::setConductor(bool adding) {
- if (adding) {
- if (!conductor_setter_ -> scene()) addItem(conductor_setter_);
- } else {
- if (conductor_setter_ -> scene()) removeItem(conductor_setter_);
- }
+ if (adding) {
+ if (!conductor_setter_ -> scene()) addItem(conductor_setter_);
+ } else {
+ if (conductor_setter_ -> scene()) removeItem(conductor_setter_);
+ }
}
/**
- @brief Diagram::setConductorStart
- Set the start point of the conductor setter.
- @param start the point (in scene coordinates) which the newly created
- conductor should start from.
+ @brief Diagram::setConductorStart
+ Set the start point of the conductor setter.
+ @param start the point (in scene coordinates) which the newly created
+ conductor should start from.
*/
inline void Diagram::setConductorStart(QPointF start) {
- conductor_setter_ -> setLine(QLineF(start, conductor_setter_ -> line().p2()));
+ conductor_setter_ -> setLine(QLineF(start, conductor_setter_ -> line().p2()));
}
/**
- @brief Diagram::setConductorStop
- Set the end point of the conductor setter.
- @param end the point (in scene coordinates) upon to which the newly created
- conductor should be drawn.
+ @brief Diagram::setConductorStop
+ Set the end point of the conductor setter.
+ @param end the point (in scene coordinates) upon to which the newly created
+ conductor should be drawn.
*/
inline void Diagram::setConductorStop(QPointF end) {
- conductor_setter_ -> setLine(QLineF(conductor_setter_ -> line().p1(), end));
+ conductor_setter_ -> setLine(QLineF(conductor_setter_ -> line().p1(), end));
}
/**
- @brief Diagram::setDisplayGrid
- Set whether the diagram grid should be drawn.
- @param dg true to render the grid, false otherwise.
+ @brief Diagram::setDisplayGrid
+ Set whether the diagram grid should be drawn.
+ @param dg true to render the grid, false otherwise.
*/
inline void Diagram::setDisplayGrid(bool dg) {
- draw_grid_ = dg;
+ draw_grid_ = dg;
}
/**
- @brief Diagram::displayGrid
- @return draw_grid_ true if the grid is drawn, false otherwise.
+ @brief Diagram::displayGrid
+ @return draw_grid_ true if the grid is drawn, false otherwise.
*/
inline bool Diagram::displayGrid() {
- return(draw_grid_);
+ return(draw_grid_);
}
/**
- @brief Diagram::setUseBorder
- Set whether the diagram border (including rows/colums headers and the title
- block) should be rendered along with the diagram. When set to false, the size
- of the smallest rectangle containing all items is considered as the diagram
- size.
- @param ub true to take the border into account, false otherwise
+ @brief Diagram::setUseBorder
+ Set whether the diagram border (including rows/colums headers and the title
+ block) should be rendered along with the diagram. When set to false, the size
+ of the smallest rectangle containing all items is considered as the diagram
+ size.
+ @param ub true to take the border into account, false otherwise
*/
inline void Diagram::setUseBorder(bool ub) {
- use_border_ = ub;
+ use_border_ = ub;
}
/**
- @brief Diagram::useBorder
- @return use_border_ true if the border is rendered and take into account,
- false otherwise.
+ @brief Diagram::useBorder
+ @return use_border_ true if the border is rendered and take into account,
+ false otherwise.
*/
inline bool Diagram::useBorder() {
- return(use_border_);
+ return(use_border_);
}
/**
- @brief Diagram::setBorderOptions
- Set the rendering options for the diagram border (including rows/colums
- headers and the title block)
- @param bo Enabled options ORed together
- @see BorderOptions
+ @brief Diagram::setBorderOptions
+ Set the rendering options for the diagram border (including rows/colums
+ headers and the title block)
+ @param bo Enabled options ORed together
+ @see BorderOptions
*/
inline void Diagram::setBorderOptions(Diagram::BorderOptions bo) {
- border_and_titleblock.displayBorder(!(bo & EmptyBorder));
- border_and_titleblock.displayColumns(bo & Columns);
- border_and_titleblock.displayTitleBlock(bo & TitleBlock);
+ border_and_titleblock.displayBorder(!(bo & EmptyBorder));
+ border_and_titleblock.displayColumns(bo & Columns);
+ border_and_titleblock.displayTitleBlock(bo & TitleBlock);
}
/**
- @brief Diagram::borderOptions
- @return The rendering optios for the diagram border
- @see setBorderOptions
+ @brief Diagram::borderOptions
+ @return The rendering optios for the diagram border
+ @see setBorderOptions
*/
inline Diagram::BorderOptions Diagram::borderOptions() {
- BorderOptions options = EmptyBorder;
- if (border_and_titleblock.titleBlockIsDisplayed())
- options = (BorderOptions)(options|TitleBlock);
- if (border_and_titleblock.columnsAreDisplayed())
- options = (BorderOptions)(options|Columns);
- return(options);
+ BorderOptions options = EmptyBorder;
+ if (border_and_titleblock.titleBlockIsDisplayed())
+ options = (BorderOptions)(options|TitleBlock);
+ if (border_and_titleblock.columnsAreDisplayed())
+ options = (BorderOptions)(options|Columns);
+ return(options);
}
/**
- @brief Diagram::undoStack
- @return the diagram undo stack
+ @brief Diagram::undoStack
+ @return the diagram undo stack
*/
inline QUndoStack &Diagram::undoStack() {
- return *(project()->undoStack());
+ return *(project()->undoStack());
}
/**
- @brief Diagram::qgiManager
- @return the diagram graphics item manager
+ @brief Diagram::qgiManager
+ @return the diagram graphics item manager
*/
inline QGIManager &Diagram::qgiManager() {
- return(*qgi_manager_);
+ return(*qgi_manager_);
}
/**
- @brief Diagram::drawTerminals
- @return true if terminals are rendered, false otherwise
+ @brief Diagram::drawTerminals
+ @return true if terminals are rendered, false otherwise
*/
inline bool Diagram::drawTerminals() const
{
- return(draw_terminals_);
+ return(draw_terminals_);
}
/**
- @brief Diagram::drawColoredConductors
- @return true if conductors colors are rendered, false otherwise.
+ @brief Diagram::drawColoredConductors
+ @return true if conductors colors are rendered, false otherwise.
*/
inline bool Diagram::drawColoredConductors() const
{
- return(draw_colored_conductors_);
+ return(draw_colored_conductors_);
}
#endif
diff --git a/sources/diagramcontext.cpp b/sources/diagramcontext.cpp
index b7e711099..9df38993c 100644
--- a/sources/diagramcontext.cpp
+++ b/sources/diagramcontext.cpp
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#include "diagramcontext.h"
#include "qet.h"
@@ -22,238 +22,238 @@
#include
/**
- @brief DiagramContext::add
- Add all value of other to this.
- If a key already exist, the value is replaced.
- If a key doesn't exist, she will be added.
- All other keys of this context, which are not present in other, stay unchanged.
- @param other
+ @brief DiagramContext::add
+ Add all value of other to this.
+ If a key already exist, the value is replaced.
+ If a key doesn't exist, she will be added.
+ All other keys of this context, which are not present in other, stay unchanged.
+ @param other
*/
void DiagramContext::add(DiagramContext other)
{
- for (QString key : other.keys()) {
- addValue(key, other.value(key));
- }
+ for (QString key : other.keys()) {
+ addValue(key, other.value(key));
+ }
}
/**
- @brief DiagramContext::remove
- @param key
+ @brief DiagramContext::remove
+ @param key
*/
void DiagramContext::remove(const QString &key) {
- m_content.remove(key);
+ m_content.remove(key);
}
/**
- @return a list containing all the keys in the context object.
+ @return a list containing all the keys in the context object.
*/
QList DiagramContext::keys(DiagramContext::KeyOrder order) const
{
- if (order == None) {
- return m_content.keys();
- }
- else
- {
- QList keys_list = m_content.keys();
- if (order == Alphabetical) {
- std::sort(keys_list.begin(), keys_list.end());
- } else {
- std::sort(keys_list.begin(), keys_list.end(), DiagramContext::stringLongerThan);
- }
- return(keys_list);
- }
+ if (order == None) {
+ return m_content.keys();
+ }
+ else
+ {
+ QList keys_list = m_content.keys();
+ if (order == Alphabetical) {
+ std::sort(keys_list.begin(), keys_list.end());
+ } else {
+ std::sort(keys_list.begin(), keys_list.end(), DiagramContext::stringLongerThan);
+ }
+ return(keys_list);
+ }
}
/**
- @param key string key
- @return true if that key is known to the diagram context, false otherwise
+ @param key string key
+ @return true if that key is known to the diagram context, false otherwise
*/
bool DiagramContext::contains(const QString &key) const
{
- return(m_content.contains(key));
+ return(m_content.contains(key));
}
/**
- @param key
+ @param key
*/
const QVariant DiagramContext::operator[](const QString &key) const
{
- return(m_content[key]);
+ return(m_content[key]);
}
/**
- @param key key to insert in the context - the key may only contain lowercase
- letters and dashes.
- If embedded key is set, key must be find it else value is not added.
- @see DiagramContext::keyIsAcceptable()
- @param value value to insert in the context
- @param show if value is used to be show on the diagram or somewhere else,
- we can specify if he is show(true) or not(false)
- @return true if the insertion succeeds, false otherwise
+ @param key key to insert in the context - the key may only contain lowercase
+ letters and dashes.
+ If embedded key is set, key must be find it else value is not added.
+ @see DiagramContext::keyIsAcceptable()
+ @param value value to insert in the context
+ @param show if value is used to be show on the diagram or somewhere else,
+ we can specify if he is show(true) or not(false)
+ @return true if the insertion succeeds, false otherwise
*/
bool DiagramContext::addValue(const QString &key, const QVariant &value, bool show) {
- if (keyIsAcceptable(key)) {
- m_content.insert(key, value);
- m_content_show.insert(key, show);
- return(true);
- }
- return(false);
+ if (keyIsAcceptable(key)) {
+ m_content.insert(key, value);
+ m_content_show.insert(key, show);
+ return(true);
+ }
+ return(false);
}
QVariant DiagramContext::value(const QString &key) const
{
- return m_content.value(key);
+ return m_content.value(key);
}
/**
- Clear the content of this diagram context.
+ Clear the content of this diagram context.
*/
void DiagramContext::clear()
{
- m_content.clear();
- m_content_show.clear();
+ m_content.clear();
+ m_content_show.clear();
}
/**
- @return the number of key/value pairs stored in this object.
+ @return the number of key/value pairs stored in this object.
*/
int DiagramContext::count()
{
- return(m_content.count());
+ return(m_content.count());
}
/**
- @brief DiagramContext::keyMustShow
- @return the value pairs with key, if key no found, return false
+ @brief DiagramContext::keyMustShow
+ @return the value pairs with key, if key no found, return false
*/
bool DiagramContext::keyMustShow(const QString &key) const
{
- if (m_content_show.contains(key))
- return m_content_show[key];
- return false;
+ if (m_content_show.contains(key))
+ return m_content_show[key];
+ return false;
}
bool DiagramContext::operator==(const DiagramContext &dc) const
{
- return(m_content == dc.m_content &&
- m_content_show == dc.m_content_show);
+ return(m_content == dc.m_content &&
+ m_content_show == dc.m_content_show);
}
bool DiagramContext::operator!=(const DiagramContext &dc) const
{
- return(!(*this == dc));
+ return(!(*this == dc));
}
/**
- Export this context properties under the \a e XML element, using tags
- named \a tag_name (defaults to "property").
+ Export this context properties under the \a e XML element, using tags
+ named \a tag_name (defaults to "property").
*/
void DiagramContext::toXml(QDomElement &e, const QString &tag_name) const
{
- foreach (QString key, keys()) {
- QDomElement property = e.ownerDocument().createElement(tag_name);
- property.setAttribute("name", key);
- property.setAttribute("show",m_content_show[key]);
- QDomText value = e.ownerDocument().createTextNode(m_content[key].toString());
- property.appendChild(value);
- e.appendChild(property);
- }
+ foreach (QString key, keys()) {
+ QDomElement property = e.ownerDocument().createElement(tag_name);
+ property.setAttribute("name", key);
+ property.setAttribute("show",m_content_show[key]);
+ QDomText value = e.ownerDocument().createTextNode(m_content[key].toString());
+ property.appendChild(value);
+ e.appendChild(property);
+ }
}
/**
- Read this context properties from the \a e XML element, looking for tags named
- \a tag_name (defaults to "property").
+ Read this context properties from the \a e XML element, looking for tags named
+ \a tag_name (defaults to "property").
*/
void DiagramContext::fromXml(const QDomElement &e, const QString &tag_name) {
- foreach (QDomElement property, QET::findInDomElement(e, tag_name)) {
- if (!property.hasAttribute("name")) continue;
- addValue(property.attribute("name"), QVariant(property.text()));
- m_content_show.insert(property.attribute("name"), property.attribute("show", "1").toInt());
- }
+ foreach (QDomElement property, QET::findInDomElement(e, tag_name)) {
+ if (!property.hasAttribute("name")) continue;
+ addValue(property.attribute("name"), QVariant(property.text()));
+ m_content_show.insert(property.attribute("name"), property.attribute("show", "1").toInt());
+ }
}
/**
- @brief DiagramContext::fromXml
- Read this context properties from the dom_element,
- looking for tags named tag_name
- @param dom_element : dom element to parse
- @param tag_name : tag name to find, by default "property"
+ @brief DiagramContext::fromXml
+ Read this context properties from the dom_element,
+ looking for tags named tag_name
+ @param dom_element : dom element to parse
+ @param tag_name : tag name to find, by default "property"
*/
void DiagramContext::fromXml(const pugi::xml_node &dom_element, const QString &tag_name)
{
- for(auto node = dom_element.child(tag_name.toStdString().c_str()) ; node ; node = node.next_sibling(tag_name.toStdString().c_str()))
- {
- addValue(node.attribute("name").as_string(), QVariant(node.text().as_string()));
- m_content_show.insert(node.attribute("name").as_string(), node.attribute("show").empty()? 1 : node.attribute("show").as_int());
- }
+ for(auto node = dom_element.child(tag_name.toStdString().c_str()) ; node ; node = node.next_sibling(tag_name.toStdString().c_str()))
+ {
+ addValue(node.attribute("name").as_string(), QVariant(node.text().as_string()));
+ m_content_show.insert(node.attribute("name").as_string(), node.attribute("show").empty()? 1 : node.attribute("show").as_int());
+ }
}
/**
- Export this context properties to \a settings by creating an array named \a
- array_name.
+ Export this context properties to \a settings by creating an array named \a
+ array_name.
*/
void DiagramContext::toSettings(QSettings &settings, const QString &array_name) const
{
- settings.beginWriteArray(array_name);
- int i = 0;
- foreach (QString key, m_content.keys()) {
- settings.setArrayIndex(i);
- settings.setValue("name", key);
- settings.setValue("value", m_content[key].toString());
- ++ i;
- }
- settings.endArray();
+ settings.beginWriteArray(array_name);
+ int i = 0;
+ foreach (QString key, m_content.keys()) {
+ settings.setArrayIndex(i);
+ settings.setValue("name", key);
+ settings.setValue("value", m_content[key].toString());
+ ++ i;
+ }
+ settings.endArray();
}
/**
- Read this context properties from \a settings by running through the array
- named \a array_name.
+ Read this context properties from \a settings by running through the array
+ named \a array_name.
*/
void DiagramContext::fromSettings(QSettings &settings, const QString &array_name) {
- int size = settings.beginReadArray(array_name);
- for (int i = 0 ; i < size; ++ i) {
- settings.setArrayIndex(i);
- QString key = settings.value("name").toString();
- if (key.isEmpty()) continue;
- addValue(key, settings.value("value").toString());
- }
- settings.endArray();
+ int size = settings.beginReadArray(array_name);
+ for (int i = 0 ; i < size; ++ i) {
+ settings.setArrayIndex(i);
+ QString key = settings.value("name").toString();
+ if (key.isEmpty()) continue;
+ addValue(key, settings.value("value").toString());
+ }
+ settings.endArray();
}
/**
- @return the regular expression used to check whether a given key is acceptable.
- @see keyIsAcceptable()
+ @return the regular expression used to check whether a given key is acceptable.
+ @see keyIsAcceptable()
*/
QString DiagramContext::validKeyRegExp()
{
- return("^[a-z0-9-_]+$");
+ return("^[a-z0-9-_]+$");
}
/**
- @return True if \a a is longer than \a b, false otherwise.
+ @return True if \a a is longer than \a b, false otherwise.
*/
bool DiagramContext::stringLongerThan(const QString &a, const QString &b) {
- return (a.length() > b.length());
+ return (a.length() > b.length());
}
/**
- @param key a key string
- @return true if that key is acceptable, false otherwise
+ @param key a key string
+ @return true if that key is acceptable, false otherwise
*/
bool DiagramContext::keyIsAcceptable(const QString &key) const
{
- QRegularExpression re(DiagramContext::validKeyRegExp());
- QRegularExpressionMatch match =re.match(key);
- return match.hasMatch();
+ QRegularExpression re(DiagramContext::validKeyRegExp());
+ QRegularExpressionMatch match =re.match(key);
+ return match.hasMatch();
}
QDebug operator <<(QDebug debug, const DiagramContext &context)
{
- debug << "DiagramContext";
- for (auto key : context.keys()) {
- debug.nospace() << key << " : " << context.value(key) << "\n";
- }
- debug << " end DiagramContext";
+ debug << "DiagramContext";
+ for (auto key : context.keys()) {
+ debug.nospace() << key << " : " << context.value(key) << "\n";
+ }
+ debug << " end DiagramContext";
- return debug;
+ return debug;
}
diff --git a/sources/diagramcontext.h b/sources/diagramcontext.h
index f887b0ff6..7dfc5b6f4 100644
--- a/sources/diagramcontext.h
+++ b/sources/diagramcontext.h
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#ifndef DIAGRAM_CONTEXT_H
#define DIAGRAM_CONTEXT_H
@@ -26,9 +26,9 @@
#include "pugixml.hpp"
/**
- This class represents a diagram context, i.e. the data (a list of key/value
- pairs) of a diagram at a given time. It is notably used by titleblock templates
- to fetch the informations they need to do their rendering, or element for retrieve information about itself
+ This class represents a diagram context, i.e. the data (a list of key/value
+ pairs) of a diagram at a given time. It is notably used by titleblock templates
+ to fetch the informations they need to do their rendering, or element for retrieve information about itself
*/
/**
@@ -54,41 +54,41 @@
*/
class DiagramContext
{
- public:
- enum KeyOrder {
- None,
- Alphabetical,
- DecreasingLength
- };
-
- void add(DiagramContext other);
- void remove(const QString &key);
- QList keys(KeyOrder = None) const;
- bool contains(const QString &) const;
- const QVariant operator[](const QString &) const;
- bool addValue(const QString &, const QVariant &, bool show = true);
- QVariant value(const QString &key) const;
- void clear();
- int count();
- bool keyMustShow (const QString &) const;
-
- bool operator==(const DiagramContext &) const;
- bool operator!=(const DiagramContext &) const;
-
- void toXml(QDomElement &, const QString & = "property") const;
- void fromXml(const QDomElement &, const QString & = "property");
- void fromXml(const pugi::xml_node &dom_element, const QString &tag_name = "property");
- void toSettings(QSettings &, const QString &) const;
- void fromSettings(QSettings &, const QString &);
-
- static QString validKeyRegExp();
-
- private:
- static bool stringLongerThan(const QString &, const QString &);
- bool keyIsAcceptable(const QString &) const;
- /// Diagram context data (key/value pairs)
- QHash m_content;
- QHash m_content_show;
+ public:
+ enum KeyOrder {
+ None,
+ Alphabetical,
+ DecreasingLength
+ };
+
+ void add(DiagramContext other);
+ void remove(const QString &key);
+ QList keys(KeyOrder = None) const;
+ bool contains(const QString &) const;
+ const QVariant operator[](const QString &) const;
+ bool addValue(const QString &, const QVariant &, bool show = true);
+ QVariant value(const QString &key) const;
+ void clear();
+ int count();
+ bool keyMustShow (const QString &) const;
+
+ bool operator==(const DiagramContext &) const;
+ bool operator!=(const DiagramContext &) const;
+
+ void toXml(QDomElement &, const QString & = "property") const;
+ void fromXml(const QDomElement &, const QString & = "property");
+ void fromXml(const pugi::xml_node &dom_element, const QString &tag_name = "property");
+ void toSettings(QSettings &, const QString &) const;
+ void fromSettings(QSettings &, const QString &);
+
+ static QString validKeyRegExp();
+
+ private:
+ static bool stringLongerThan(const QString &, const QString &);
+ bool keyIsAcceptable(const QString &) const;
+ /// Diagram context data (key/value pairs)
+ QHash m_content;
+ QHash m_content_show;
};
QDebug operator <<(QDebug debug, const DiagramContext &context);
diff --git a/sources/editor/graphicspart/customelementgraphicpart.cpp b/sources/editor/graphicspart/customelementgraphicpart.cpp
index b804fdee6..53d0990c3 100644
--- a/sources/editor/graphicspart/customelementgraphicpart.cpp
+++ b/sources/editor/graphicspart/customelementgraphicpart.cpp
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#include "customelementgraphicpart.h"
#include "elementscene.h"
@@ -22,503 +22,503 @@
#include
/**
- @brief CustomElementGraphicPart::CustomElementGraphicPart
- Default constructor.
- By default, item is selectable, send geometry change (Qt > 4.6),
- accept mouse left button and accept hover event
- @param editor QETElement editor that belong this.
- @param parent
+ @brief CustomElementGraphicPart::CustomElementGraphicPart
+ Default constructor.
+ By default, item is selectable, send geometry change (Qt > 4.6),
+ accept mouse left button and accept hover event
+ @param editor QETElement editor that belong this.
+ @param parent
*/
CustomElementGraphicPart::CustomElementGraphicPart(QETElementEditor *editor,
- QGraphicsItem *parent) :
- QGraphicsObject (parent),
- CustomElementPart(editor),
- m_hovered (false),
- _linestyle(NormalStyle),
- _lineweight(NormalWeight),
- _filling(NoneFilling),
- _color(BlackColor),
- _antialiased(false)
+ QGraphicsItem *parent) :
+ QGraphicsObject (parent),
+ CustomElementPart(editor),
+ m_hovered (false),
+ _linestyle(NormalStyle),
+ _lineweight(NormalWeight),
+ _filling(NoneFilling),
+ _color(BlackColor),
+ _antialiased(false)
{
- setFlags(QGraphicsItem::ItemIsSelectable
- | QGraphicsItem::ItemIsMovable
- | QGraphicsItem::ItemSendsGeometryChanges);
- setAcceptHoverEvents(true);
+ setFlags(QGraphicsItem::ItemIsSelectable
+ | QGraphicsItem::ItemIsMovable
+ | QGraphicsItem::ItemSendsGeometryChanges);
+ setAcceptHoverEvents(true);
}
/**
- @brief CustomElementGraphicPart::~CustomElementGraphicPart
- Destructor
+ @brief CustomElementGraphicPart::~CustomElementGraphicPart
+ Destructor
*/
CustomElementGraphicPart::~CustomElementGraphicPart() {}
/**
- @brief CustomElementGraphicPart::drawCross
- Draw a cross at pos center
- @param center : center of cross
- @param painter : painter to use for draw cross,
- the painter state is restored at end of this method.
+ @brief CustomElementGraphicPart::drawCross
+ Draw a cross at pos center
+ @param center : center of cross
+ @param painter : painter to use for draw cross,
+ the painter state is restored at end of this method.
*/
void CustomElementGraphicPart::drawCross(const QPointF ¢er,
- QPainter *painter)
+ QPainter *painter)
{
- painter -> save();
- painter -> setRenderHint(QPainter::Antialiasing, false);
- painter -> setPen((painter -> brush().color()
- == QColor(Qt::black)
- && painter -> brush().isOpaque())
- ? Qt::yellow
- : Qt::blue);
- painter -> drawLine(QLineF(center.x() - 2.0,
- center.y(),
- center.x() + 2.0,
- center.y()));
- painter -> drawLine(QLineF(center.x(),
- center.y() - 2.0,
- center.x(),
- center.y() + 2.0));
- painter -> restore();
+ painter -> save();
+ painter -> setRenderHint(QPainter::Antialiasing, false);
+ painter -> setPen((painter -> brush().color()
+ == QColor(Qt::black)
+ && painter -> brush().isOpaque())
+ ? Qt::yellow
+ : Qt::blue);
+ painter -> drawLine(QLineF(center.x() - 2.0,
+ center.y(),
+ center.x() + 2.0,
+ center.y()));
+ painter -> drawLine(QLineF(center.x(),
+ center.y() - 2.0,
+ center.x(),
+ center.y() + 2.0));
+ painter -> restore();
}
/**
- @brief CustomElementGraphicPart::setLineStyle
- Set line style to ls
- @param ls
+ @brief CustomElementGraphicPart::setLineStyle
+ Set line style to ls
+ @param ls
*/
void CustomElementGraphicPart::setLineStyle(const LineStyle ls)
{
- if (_linestyle == ls) return;
- _linestyle = ls;
- update();
+ if (_linestyle == ls) return;
+ _linestyle = ls;
+ update();
}
/**
- @brief CustomElementGraphicPart::setLineWeight
- Set line weight to lw
- @param lw
+ @brief CustomElementGraphicPart::setLineWeight
+ Set line weight to lw
+ @param lw
*/
void CustomElementGraphicPart::setLineWeight(const LineWeight lw)
{
- if (_lineweight == lw) return;
- _lineweight = lw;
- update();
+ if (_lineweight == lw) return;
+ _lineweight = lw;
+ update();
}
/**
- @brief CustomElementGraphicPart::penWeight
- @return the weight of pen
+ @brief CustomElementGraphicPart::penWeight
+ @return the weight of pen
*/
qreal CustomElementGraphicPart::penWeight() const
{
- if (_lineweight == NoneWeight || _lineweight == ThinWeight) return 0;
- else if (_lineweight == NormalWeight) return 1;
- else if (_lineweight == UltraWeight) return 2;
- else if (_lineweight == BigWeight) return 5;
- return 1;
+ if (_lineweight == NoneWeight || _lineweight == ThinWeight) return 0;
+ else if (_lineweight == NormalWeight) return 1;
+ else if (_lineweight == UltraWeight) return 2;
+ else if (_lineweight == BigWeight) return 5;
+ return 1;
}
/**
- @brief CustomElementGraphicPart::setFilling
- Set filling to f
- @param f
+ @brief CustomElementGraphicPart::setFilling
+ Set filling to f
+ @param f
*/
void CustomElementGraphicPart::setFilling(const Filling f)
{
- if (_filling == f) return;
- _filling = f;
- update();
+ if (_filling == f) return;
+ _filling = f;
+ update();
}
/**
- @brief CustomElementGraphicPart::setColor
- Set color to c
- @param c
+ @brief CustomElementGraphicPart::setColor
+ Set color to c
+ @param c
*/
void CustomElementGraphicPart::setColor(const Color c)
{
- if (_color == c) return;
- _color = c;
- update();
+ if (_color == c) return;
+ _color = c;
+ update();
}
/**
- @brief CustomElementGraphicPart::setAntialiased
- Set antialias to b
- @param b
+ @brief CustomElementGraphicPart::setAntialiased
+ Set antialias to b
+ @param b
*/
void CustomElementGraphicPart::setAntialiased(const bool b)
{
- if (_antialiased == b) return;
- _antialiased = b;
- update();
+ if (_antialiased == b) return;
+ _antialiased = b;
+ update();
}
/**
- @brief CustomElementGraphicPart::stylesToXml
- Write the curent style to xml element.
- The style are stored like this:
- name-of-style:value;name-of-style:value
- Each style separate by ; and name-style/value are separate by :
- @param qde : QDOmElement used to write the style.
+ @brief CustomElementGraphicPart::stylesToXml
+ Write the curent style to xml element.
+ The style are stored like this:
+ name-of-style:value;name-of-style:value
+ Each style separate by ; and name-style/value are separate by :
+ @param qde : QDOmElement used to write the style.
*/
void CustomElementGraphicPart::stylesToXml(QDomElement &qde) const
{
- QString css_like_styles;
+ QString css_like_styles;
- css_like_styles += "line-style:";
- if (_linestyle == DashedStyle) css_like_styles += "dashed";
- else if (_linestyle == DottedStyle) css_like_styles += "dotted";
- else if (_linestyle == DashdottedStyle) css_like_styles += "dashdotted";
- else if (_linestyle == NormalStyle) css_like_styles += "normal";
+ css_like_styles += "line-style:";
+ if (_linestyle == DashedStyle) css_like_styles += "dashed";
+ else if (_linestyle == DottedStyle) css_like_styles += "dotted";
+ else if (_linestyle == DashdottedStyle) css_like_styles += "dashdotted";
+ else if (_linestyle == NormalStyle) css_like_styles += "normal";
- css_like_styles += ";line-weight:";
- if (_lineweight == NoneWeight) css_like_styles += "none";
- else if (_lineweight == ThinWeight) css_like_styles += "thin";
- else if (_lineweight == NormalWeight) css_like_styles += "normal";
- else if (_lineweight == UltraWeight) css_like_styles += "hight";
- else if (_lineweight == BigWeight) css_like_styles += "eleve";
+ css_like_styles += ";line-weight:";
+ if (_lineweight == NoneWeight) css_like_styles += "none";
+ else if (_lineweight == ThinWeight) css_like_styles += "thin";
+ else if (_lineweight == NormalWeight) css_like_styles += "normal";
+ else if (_lineweight == UltraWeight) css_like_styles += "hight";
+ else if (_lineweight == BigWeight) css_like_styles += "eleve";
- css_like_styles += ";filling:";
- if (_filling == NoneFilling) css_like_styles += "none";
- else if (_filling == BlackFilling) css_like_styles += "black";
- else if (_filling == WhiteFilling) css_like_styles += "white";
- else if (_filling == GreenFilling) css_like_styles += "green";
- else if (_filling == BlueFilling) css_like_styles += "blue";
- else if (_filling == RedFilling) css_like_styles += "red";
- else if (_filling == GrayFilling) css_like_styles += "gray";
- else if (_filling == BrunFilling) css_like_styles += "brun";
- else if (_filling == YellowFilling) css_like_styles += "yellow";
- else if (_filling == CyanFilling) css_like_styles += "cyan";
- else if (_filling == MagentaFilling) css_like_styles += "magenta";
- else if (_filling == LightgrayFilling) css_like_styles += "lightgray";
- else if (_filling == OrangeFilling) css_like_styles += "orange";
- else if (_filling == PurpleFilling) css_like_styles += "purple";
- else if (_filling == HTMLPinkPinkFilling) css_like_styles += "HTMLPinkPink";
- else if (_filling == HTMLPinkLightPinkFilling) css_like_styles += "HTMLPinkLightPink";
- else if (_filling == HTMLPinkHotPinkFilling) css_like_styles += "HTMLPinkHotPink";
- else if (_filling == HTMLPinkDeepPinkFilling) css_like_styles += "HTMLPinkDeepPink";
- else if (_filling == HTMLPinkPaleVioletRedFilling) css_like_styles += "HTMLPinkPaleVioletRed";
- else if (_filling == HTMLPinkMediumVioletRedFilling) css_like_styles += "HTMLPinkMediumVioletRed";
- else if (_filling == HTMLRedLightSalmonFilling) css_like_styles += "HTMLRedLightSalmon";
- else if (_filling == HTMLRedSalmonFilling) css_like_styles += "HTMLRedSalmon";
- else if (_filling == HTMLRedDarkSalmonFilling) css_like_styles += "HTMLRedDarkSalmon";
- else if (_filling == HTMLRedLightCoralFilling) css_like_styles += "HTMLRedLightCoral";
- else if (_filling == HTMLRedIndianRedFilling) css_like_styles += "HTMLRedIndianRed";
- else if (_filling == HTMLRedCrimsonFilling) css_like_styles += "HTMLRedCrimson";
- else if (_filling == HTMLRedFirebrickFilling) css_like_styles += "HTMLRedFirebrick";
- else if (_filling == HTMLRedDarkRedFilling) css_like_styles += "HTMLRedDarkRed";
- else if (_filling == HTMLRedRedFilling) css_like_styles += "HTMLRedRed";
- else if (_filling == HTMLOrangeOrangeRedFilling) css_like_styles += "HTMLOrangeOrangeRed";
- else if (_filling == HTMLOrangeTomatoFilling) css_like_styles += "HTMLOrangeTomato";
- else if (_filling == HTMLOrangeCoralFilling) css_like_styles += "HTMLOrangeCoral";
- else if (_filling == HTMLOrangeDarkOrangeFilling) css_like_styles += "HTMLOrangeDarkOrange";
- else if (_filling == HTMLOrangeOrangeFilling) css_like_styles += "HTMLOrangeOrange";
- else if (_filling == HTMLYellowYellowFilling) css_like_styles += "HTMLYellowYellow";
- else if (_filling == HTMLYellowLightYellowFilling) css_like_styles += "HTMLYellowLightYellow";
- else if (_filling == HTMLYellowLemonChiffonFilling) css_like_styles += "HTMLYellowLemonChiffon";
- else if (_filling == HTMLYellowLightGoldenrodYellowFilling) css_like_styles += "HTMLYellowLightGoldenrodYellow";
- else if (_filling == HTMLYellowPapayaWhipFilling) css_like_styles += "HTMLYellowPapayaWhip";
- else if (_filling == HTMLYellowMoccasinFilling) css_like_styles += "HTMLYellowMoccasin";
- else if (_filling == HTMLYellowPeachPuffFilling) css_like_styles += "HTMLYellowPeachPuff";
- else if (_filling == HTMLYellowPaleGoldenrodFilling) css_like_styles += "HTMLYellowPaleGoldenrod";
- else if (_filling == HTMLYellowKhakiFilling) css_like_styles += "HTMLYellowKhaki";
- else if (_filling == HTMLYellowDarkKhakiFilling) css_like_styles += "HTMLYellowDarkKhaki";
- else if (_filling == HTMLYellowGoldFilling) css_like_styles += "HTMLYellowGold";
- else if (_filling == HTMLBrownCornsilkFilling) css_like_styles += "HTMLBrownCornsilk";
- else if (_filling == HTMLBrownBlanchedAlmondFilling) css_like_styles += "HTMLBrownBlanchedAlmond";
- else if (_filling == HTMLBrownBisqueFilling) css_like_styles += "HTMLBrownBisque";
- else if (_filling == HTMLBrownNavajoWhiteFilling) css_like_styles += "HTMLBrownNavajoWhite";
- else if (_filling == HTMLBrownWheatFilling) css_like_styles += "HTMLBrownWheat";
- else if (_filling == HTMLBrownBurlywoodFilling) css_like_styles += "HTMLBrownBurlywood";
- else if (_filling == HTMLBrownTanFilling) css_like_styles += "HTMLBrownTan";
- else if (_filling == HTMLBrownRosyBrownFilling) css_like_styles += "HTMLBrownRosyBrown";
- else if (_filling == HTMLBrownSandyBrownFilling) css_like_styles += "HTMLBrownSandyBrown";
- else if (_filling == HTMLBrownGoldenrodFilling) css_like_styles += "HTMLBrownGoldenrod";
- else if (_filling == HTMLBrownDarkGoldenrodFilling) css_like_styles += "HTMLBrownDarkGoldenrod";
- else if (_filling == HTMLBrownPeruFilling) css_like_styles += "HTMLBrownPeru";
- else if (_filling == HTMLBrownChocolateFilling) css_like_styles += "HTMLBrownChocolate";
- else if (_filling == HTMLBrownSaddleBrownFilling) css_like_styles += "HTMLBrownSaddleBrown";
- else if (_filling == HTMLBrownSiennaFilling) css_like_styles += "HTMLBrownSienna";
- else if (_filling == HTMLBrownBrownFilling) css_like_styles += "HTMLBrownBrown";
- else if (_filling == HTMLBrownMaroonFilling) css_like_styles += "HTMLBrownMaroon";
- else if (_filling == HTMLGreenDarkOliveGreenFilling) css_like_styles += "HTMLGreenDarkOliveGreen";
- else if (_filling == HTMLGreenOliveFilling) css_like_styles += "HTMLGreenOlive";
- else if (_filling == HTMLGreenOliveDrabFilling) css_like_styles += "HTMLGreenOliveDrab";
- else if (_filling == HTMLGreenYellowGreenFilling) css_like_styles += "HTMLGreenYellowGreen";
- else if (_filling == HTMLGreenLimeGreenFilling) css_like_styles += "HTMLGreenLimeGreen";
- else if (_filling == HTMLGreenLimeFilling) css_like_styles += "HTMLGreenLime";
- else if (_filling == HTMLGreenLawnGreenFilling) css_like_styles += "HTMLGreenLawnGreen";
- else if (_filling == HTMLGreenChartreuseFilling) css_like_styles += "HTMLGreenChartreuse";
- else if (_filling == HTMLGreenGreenYellowFilling) css_like_styles += "HTMLGreenGreenYellow";
- else if (_filling == HTMLGreenSpringGreenFilling) css_like_styles += "HTMLGreenSpringGreen";
- else if (_filling == HTMLGreenMediumSpringGreenFilling) css_like_styles += "HTMLGreenMediumSpringGreen";
- else if (_filling == HTMLGreenLightGreenFilling) css_like_styles += "HTMLGreenLightGreen";
- else if (_filling == HTMLGreenPaleGreenFilling) css_like_styles += "HTMLGreenPaleGreen";
- else if (_filling == HTMLGreenDarkSeaGreenFilling) css_like_styles += "HTMLGreenDarkSeaGreen";
- else if (_filling == HTMLGreenMediumAquamarineFilling) css_like_styles += "HTMLGreenMediumAquamarine";
- else if (_filling == HTMLGreenMediumSeaGreenFilling) css_like_styles += "HTMLGreenMediumSeaGreen";
- else if (_filling == HTMLGreenSeaGreenFilling) css_like_styles += "HTMLGreenSeaGreen";
- else if (_filling == HTMLGreenForestGreenFilling) css_like_styles += "HTMLGreenForestGreen";
- else if (_filling == HTMLGreenGreenFilling) css_like_styles += "HTMLGreenGreen";
- else if (_filling == HTMLGreenDarkGreenFilling) css_like_styles += "HTMLGreenDarkGreen";
- else if (_filling == HTMLCyanAquaFilling) css_like_styles += "HTMLCyanAqua";
- else if (_filling == HTMLCyanCyanFilling) css_like_styles += "HTMLCyanCyan";
- else if (_filling == HTMLCyanLightCyanFilling) css_like_styles += "HTMLCyanLightCyan";
- else if (_filling == HTMLCyanPaleTurquoiseFilling) css_like_styles += "HTMLCyanPaleTurquoise";
- else if (_filling == HTMLCyanAquamarineFilling) css_like_styles += "HTMLCyanAquamarine";
- else if (_filling == HTMLCyanTurquoiseFilling) css_like_styles += "HTMLCyanTurquoise";
- else if (_filling == HTMLCyanMediumTurquoiseFilling) css_like_styles += "HTMLCyanMediumTurquoise";
- else if (_filling == HTMLCyanDarkTurquoiseFilling) css_like_styles += "HTMLCyanDarkTurquoise";
- else if (_filling == HTMLCyanLightSeaGreenFilling) css_like_styles += "HTMLCyanLightSeaGreen";
- else if (_filling == HTMLCyanCadetBlueFilling) css_like_styles += "HTMLCyanCadetBlue";
- else if (_filling == HTMLCyanDarkCyanFilling) css_like_styles += "HTMLCyanDarkCyan";
- else if (_filling == HTMLCyanTealFilling) css_like_styles += "HTMLCyanTeal";
- else if (_filling == HTMLBlueLightSteelBlueFilling) css_like_styles += "HTMLBlueLightSteelBlue";
- else if (_filling == HTMLBluePowderBlueFilling) css_like_styles += "HTMLBluePowderBlue";
- else if (_filling == HTMLBlueLightBlueFilling) css_like_styles += "HTMLBlueLightBlue";
- else if (_filling == HTMLBlueSkyBlueFilling) css_like_styles += "HTMLBlueSkyBlue";
- else if (_filling == HTMLBlueLightSkyBlueFilling) css_like_styles += "HTMLBlueLightSkyBlue";
- else if (_filling == HTMLBlueDeepSkyBlueFilling) css_like_styles += "HTMLBlueDeepSkyBlue";
- else if (_filling == HTMLBlueDodgerBlueFilling) css_like_styles += "HTMLBlueDodgerBlue";
- else if (_filling == HTMLBlueCornflowerBlueFilling) css_like_styles += "HTMLBlueCornflowerBlue";
- else if (_filling == HTMLBlueSteelBlueFilling) css_like_styles += "HTMLBlueSteelBlue";
- else if (_filling == HTMLBlueRoyalBlueFilling) css_like_styles += "HTMLBlueRoyalBlue";
- else if (_filling == HTMLBlueBlueFilling) css_like_styles += "HTMLBlueBlue";
- else if (_filling == HTMLBlueMediumBlueFilling) css_like_styles += "HTMLBlueMediumBlue";
- else if (_filling == HTMLBlueDarkBlueFilling) css_like_styles += "HTMLBlueDarkBlue";
- else if (_filling == HTMLBlueNavyFilling) css_like_styles += "HTMLBlueNavy";
- else if (_filling == HTMLBlueMidnightBlueFilling) css_like_styles += "HTMLBlueMidnightBlue";
- else if (_filling == HTMLPurpleLavenderFilling) css_like_styles += "HTMLPurpleLavender";
- else if (_filling == HTMLPurpleThistleFilling) css_like_styles += "HTMLPurpleThistle";
- else if (_filling == HTMLPurplePlumFilling) css_like_styles += "HTMLPurplePlum";
- else if (_filling == HTMLPurpleVioletFilling) css_like_styles += "HTMLPurpleViolet";
- else if (_filling == HTMLPurpleOrchidFilling) css_like_styles += "HTMLPurpleOrchid";
- else if (_filling == HTMLPurpleFuchsiaFilling) css_like_styles += "HTMLPurpleFuchsia";
- else if (_filling == HTMLPurpleMagentaFilling) css_like_styles += "HTMLPurpleMagenta";
- else if (_filling == HTMLPurpleMediumOrchidFilling) css_like_styles += "HTMLPurpleMediumOrchid";
- else if (_filling == HTMLPurpleMediumPurpleFilling) css_like_styles += "HTMLPurpleMediumPurple";
- else if (_filling == HTMLPurpleBlueVioletFilling) css_like_styles += "HTMLPurpleBlueViolet";
- else if (_filling == HTMLPurpleDarkVioletFilling) css_like_styles += "HTMLPurpleDarkViolet";
- else if (_filling == HTMLPurpleDarkOrchidFilling) css_like_styles += "HTMLPurpleDarkOrchid";
- else if (_filling == HTMLPurpleDarkMagentaFilling) css_like_styles += "HTMLPurpleDarkMagenta";
- else if (_filling == HTMLPurplePurpleFilling) css_like_styles += "HTMLPurplePurple";
- else if (_filling == HTMLPurpleIndigoFilling) css_like_styles += "HTMLPurpleIndigo";
- else if (_filling == HTMLPurpleDarkSlateBlueFilling) css_like_styles += "HTMLPurpleDarkSlateBlue";
- else if (_filling == HTMLPurpleSlateBlueFilling) css_like_styles += "HTMLPurpleSlateBlue";
- else if (_filling == HTMLPurpleMediumSlateBlueFilling) css_like_styles += "HTMLPurpleMediumSlateBlue";
- else if (_filling == HTMLWhiteWhiteFilling) css_like_styles += "HTMLWhiteWhite";
- else if (_filling == HTMLWhiteSnowFilling) css_like_styles += "HTMLWhiteSnow";
- else if (_filling == HTMLWhiteHoneydewFilling) css_like_styles += "HTMLWhiteHoneydew";
- else if (_filling == HTMLWhiteMintCreamFilling) css_like_styles += "HTMLWhiteMintCream";
- else if (_filling == HTMLWhiteAzureFilling) css_like_styles += "HTMLWhiteAzure";
- else if (_filling == HTMLWhiteAliceBlueFilling) css_like_styles += "HTMLWhiteAliceBlue";
- else if (_filling == HTMLWhiteGhostWhiteFilling) css_like_styles += "HTMLWhiteGhostWhite";
- else if (_filling == HTMLWhiteWhiteSmokeFilling) css_like_styles += "HTMLWhiteWhiteSmoke";
- else if (_filling == HTMLWhiteSeashellFilling) css_like_styles += "HTMLWhiteSeashell";
- else if (_filling == HTMLWhiteBeigeFilling) css_like_styles += "HTMLWhiteBeige";
- else if (_filling == HTMLWhiteOldLaceFilling) css_like_styles += "HTMLWhiteOldLace";
- else if (_filling == HTMLWhiteFloralWhiteFilling) css_like_styles += "HTMLWhiteFloralWhite";
- else if (_filling == HTMLWhiteIvoryFilling) css_like_styles += "HTMLWhiteIvory";
- else if (_filling == HTMLWhiteAntiqueWhiteFilling) css_like_styles += "HTMLWhiteAntiqueWhite";
- else if (_filling == HTMLWhiteLinenFilling) css_like_styles += "HTMLWhiteLinen";
- else if (_filling == HTMLWhiteLavenderBlushFilling) css_like_styles += "HTMLWhiteLavenderBlush";
- else if (_filling == HTMLWhiteMistyRoseFilling) css_like_styles += "HTMLWhiteMistyRose";
- else if (_filling == HTMLGrayGainsboroFilling) css_like_styles += "HTMLGrayGainsboro";
- else if (_filling == HTMLGrayLightGrayFilling) css_like_styles += "HTMLGrayLightGray";
- else if (_filling == HTMLGraySilverFilling) css_like_styles += "HTMLGraySilver";
- else if (_filling == HTMLGrayDarkGrayFilling) css_like_styles += "HTMLGrayDarkGray";
- else if (_filling == HTMLGrayGrayFilling) css_like_styles += "HTMLGrayGray";
- else if (_filling == HTMLGrayDimGrayFilling) css_like_styles += "HTMLGrayDimGray";
- else if (_filling == HTMLGrayLightSlateGrayFilling) css_like_styles += "HTMLGrayLightSlateGray";
- else if (_filling == HTMLGraySlateGrayFilling) css_like_styles += "HTMLGraySlateGray";
- else if (_filling == HTMLGrayDarkSlateGrayFilling) css_like_styles += "HTMLGrayDarkSlateGray";
- else if (_filling == HTMLGrayBlackFilling) css_like_styles += "HTMLGrayBlack";
- else if (_filling == HorFilling) css_like_styles += "hor";
- else if (_filling == VerFilling) css_like_styles += "ver";
- else if (_filling == BdiagFilling) css_like_styles += "bdiag";
- else if (_filling == FdiagFilling) css_like_styles += "fdiag";
+ css_like_styles += ";filling:";
+ if (_filling == NoneFilling) css_like_styles += "none";
+ else if (_filling == BlackFilling) css_like_styles += "black";
+ else if (_filling == WhiteFilling) css_like_styles += "white";
+ else if (_filling == GreenFilling) css_like_styles += "green";
+ else if (_filling == BlueFilling) css_like_styles += "blue";
+ else if (_filling == RedFilling) css_like_styles += "red";
+ else if (_filling == GrayFilling) css_like_styles += "gray";
+ else if (_filling == BrunFilling) css_like_styles += "brun";
+ else if (_filling == YellowFilling) css_like_styles += "yellow";
+ else if (_filling == CyanFilling) css_like_styles += "cyan";
+ else if (_filling == MagentaFilling) css_like_styles += "magenta";
+ else if (_filling == LightgrayFilling) css_like_styles += "lightgray";
+ else if (_filling == OrangeFilling) css_like_styles += "orange";
+ else if (_filling == PurpleFilling) css_like_styles += "purple";
+ else if (_filling == HTMLPinkPinkFilling) css_like_styles += "HTMLPinkPink";
+ else if (_filling == HTMLPinkLightPinkFilling) css_like_styles += "HTMLPinkLightPink";
+ else if (_filling == HTMLPinkHotPinkFilling) css_like_styles += "HTMLPinkHotPink";
+ else if (_filling == HTMLPinkDeepPinkFilling) css_like_styles += "HTMLPinkDeepPink";
+ else if (_filling == HTMLPinkPaleVioletRedFilling) css_like_styles += "HTMLPinkPaleVioletRed";
+ else if (_filling == HTMLPinkMediumVioletRedFilling) css_like_styles += "HTMLPinkMediumVioletRed";
+ else if (_filling == HTMLRedLightSalmonFilling) css_like_styles += "HTMLRedLightSalmon";
+ else if (_filling == HTMLRedSalmonFilling) css_like_styles += "HTMLRedSalmon";
+ else if (_filling == HTMLRedDarkSalmonFilling) css_like_styles += "HTMLRedDarkSalmon";
+ else if (_filling == HTMLRedLightCoralFilling) css_like_styles += "HTMLRedLightCoral";
+ else if (_filling == HTMLRedIndianRedFilling) css_like_styles += "HTMLRedIndianRed";
+ else if (_filling == HTMLRedCrimsonFilling) css_like_styles += "HTMLRedCrimson";
+ else if (_filling == HTMLRedFirebrickFilling) css_like_styles += "HTMLRedFirebrick";
+ else if (_filling == HTMLRedDarkRedFilling) css_like_styles += "HTMLRedDarkRed";
+ else if (_filling == HTMLRedRedFilling) css_like_styles += "HTMLRedRed";
+ else if (_filling == HTMLOrangeOrangeRedFilling) css_like_styles += "HTMLOrangeOrangeRed";
+ else if (_filling == HTMLOrangeTomatoFilling) css_like_styles += "HTMLOrangeTomato";
+ else if (_filling == HTMLOrangeCoralFilling) css_like_styles += "HTMLOrangeCoral";
+ else if (_filling == HTMLOrangeDarkOrangeFilling) css_like_styles += "HTMLOrangeDarkOrange";
+ else if (_filling == HTMLOrangeOrangeFilling) css_like_styles += "HTMLOrangeOrange";
+ else if (_filling == HTMLYellowYellowFilling) css_like_styles += "HTMLYellowYellow";
+ else if (_filling == HTMLYellowLightYellowFilling) css_like_styles += "HTMLYellowLightYellow";
+ else if (_filling == HTMLYellowLemonChiffonFilling) css_like_styles += "HTMLYellowLemonChiffon";
+ else if (_filling == HTMLYellowLightGoldenrodYellowFilling) css_like_styles += "HTMLYellowLightGoldenrodYellow";
+ else if (_filling == HTMLYellowPapayaWhipFilling) css_like_styles += "HTMLYellowPapayaWhip";
+ else if (_filling == HTMLYellowMoccasinFilling) css_like_styles += "HTMLYellowMoccasin";
+ else if (_filling == HTMLYellowPeachPuffFilling) css_like_styles += "HTMLYellowPeachPuff";
+ else if (_filling == HTMLYellowPaleGoldenrodFilling) css_like_styles += "HTMLYellowPaleGoldenrod";
+ else if (_filling == HTMLYellowKhakiFilling) css_like_styles += "HTMLYellowKhaki";
+ else if (_filling == HTMLYellowDarkKhakiFilling) css_like_styles += "HTMLYellowDarkKhaki";
+ else if (_filling == HTMLYellowGoldFilling) css_like_styles += "HTMLYellowGold";
+ else if (_filling == HTMLBrownCornsilkFilling) css_like_styles += "HTMLBrownCornsilk";
+ else if (_filling == HTMLBrownBlanchedAlmondFilling) css_like_styles += "HTMLBrownBlanchedAlmond";
+ else if (_filling == HTMLBrownBisqueFilling) css_like_styles += "HTMLBrownBisque";
+ else if (_filling == HTMLBrownNavajoWhiteFilling) css_like_styles += "HTMLBrownNavajoWhite";
+ else if (_filling == HTMLBrownWheatFilling) css_like_styles += "HTMLBrownWheat";
+ else if (_filling == HTMLBrownBurlywoodFilling) css_like_styles += "HTMLBrownBurlywood";
+ else if (_filling == HTMLBrownTanFilling) css_like_styles += "HTMLBrownTan";
+ else if (_filling == HTMLBrownRosyBrownFilling) css_like_styles += "HTMLBrownRosyBrown";
+ else if (_filling == HTMLBrownSandyBrownFilling) css_like_styles += "HTMLBrownSandyBrown";
+ else if (_filling == HTMLBrownGoldenrodFilling) css_like_styles += "HTMLBrownGoldenrod";
+ else if (_filling == HTMLBrownDarkGoldenrodFilling) css_like_styles += "HTMLBrownDarkGoldenrod";
+ else if (_filling == HTMLBrownPeruFilling) css_like_styles += "HTMLBrownPeru";
+ else if (_filling == HTMLBrownChocolateFilling) css_like_styles += "HTMLBrownChocolate";
+ else if (_filling == HTMLBrownSaddleBrownFilling) css_like_styles += "HTMLBrownSaddleBrown";
+ else if (_filling == HTMLBrownSiennaFilling) css_like_styles += "HTMLBrownSienna";
+ else if (_filling == HTMLBrownBrownFilling) css_like_styles += "HTMLBrownBrown";
+ else if (_filling == HTMLBrownMaroonFilling) css_like_styles += "HTMLBrownMaroon";
+ else if (_filling == HTMLGreenDarkOliveGreenFilling) css_like_styles += "HTMLGreenDarkOliveGreen";
+ else if (_filling == HTMLGreenOliveFilling) css_like_styles += "HTMLGreenOlive";
+ else if (_filling == HTMLGreenOliveDrabFilling) css_like_styles += "HTMLGreenOliveDrab";
+ else if (_filling == HTMLGreenYellowGreenFilling) css_like_styles += "HTMLGreenYellowGreen";
+ else if (_filling == HTMLGreenLimeGreenFilling) css_like_styles += "HTMLGreenLimeGreen";
+ else if (_filling == HTMLGreenLimeFilling) css_like_styles += "HTMLGreenLime";
+ else if (_filling == HTMLGreenLawnGreenFilling) css_like_styles += "HTMLGreenLawnGreen";
+ else if (_filling == HTMLGreenChartreuseFilling) css_like_styles += "HTMLGreenChartreuse";
+ else if (_filling == HTMLGreenGreenYellowFilling) css_like_styles += "HTMLGreenGreenYellow";
+ else if (_filling == HTMLGreenSpringGreenFilling) css_like_styles += "HTMLGreenSpringGreen";
+ else if (_filling == HTMLGreenMediumSpringGreenFilling) css_like_styles += "HTMLGreenMediumSpringGreen";
+ else if (_filling == HTMLGreenLightGreenFilling) css_like_styles += "HTMLGreenLightGreen";
+ else if (_filling == HTMLGreenPaleGreenFilling) css_like_styles += "HTMLGreenPaleGreen";
+ else if (_filling == HTMLGreenDarkSeaGreenFilling) css_like_styles += "HTMLGreenDarkSeaGreen";
+ else if (_filling == HTMLGreenMediumAquamarineFilling) css_like_styles += "HTMLGreenMediumAquamarine";
+ else if (_filling == HTMLGreenMediumSeaGreenFilling) css_like_styles += "HTMLGreenMediumSeaGreen";
+ else if (_filling == HTMLGreenSeaGreenFilling) css_like_styles += "HTMLGreenSeaGreen";
+ else if (_filling == HTMLGreenForestGreenFilling) css_like_styles += "HTMLGreenForestGreen";
+ else if (_filling == HTMLGreenGreenFilling) css_like_styles += "HTMLGreenGreen";
+ else if (_filling == HTMLGreenDarkGreenFilling) css_like_styles += "HTMLGreenDarkGreen";
+ else if (_filling == HTMLCyanAquaFilling) css_like_styles += "HTMLCyanAqua";
+ else if (_filling == HTMLCyanCyanFilling) css_like_styles += "HTMLCyanCyan";
+ else if (_filling == HTMLCyanLightCyanFilling) css_like_styles += "HTMLCyanLightCyan";
+ else if (_filling == HTMLCyanPaleTurquoiseFilling) css_like_styles += "HTMLCyanPaleTurquoise";
+ else if (_filling == HTMLCyanAquamarineFilling) css_like_styles += "HTMLCyanAquamarine";
+ else if (_filling == HTMLCyanTurquoiseFilling) css_like_styles += "HTMLCyanTurquoise";
+ else if (_filling == HTMLCyanMediumTurquoiseFilling) css_like_styles += "HTMLCyanMediumTurquoise";
+ else if (_filling == HTMLCyanDarkTurquoiseFilling) css_like_styles += "HTMLCyanDarkTurquoise";
+ else if (_filling == HTMLCyanLightSeaGreenFilling) css_like_styles += "HTMLCyanLightSeaGreen";
+ else if (_filling == HTMLCyanCadetBlueFilling) css_like_styles += "HTMLCyanCadetBlue";
+ else if (_filling == HTMLCyanDarkCyanFilling) css_like_styles += "HTMLCyanDarkCyan";
+ else if (_filling == HTMLCyanTealFilling) css_like_styles += "HTMLCyanTeal";
+ else if (_filling == HTMLBlueLightSteelBlueFilling) css_like_styles += "HTMLBlueLightSteelBlue";
+ else if (_filling == HTMLBluePowderBlueFilling) css_like_styles += "HTMLBluePowderBlue";
+ else if (_filling == HTMLBlueLightBlueFilling) css_like_styles += "HTMLBlueLightBlue";
+ else if (_filling == HTMLBlueSkyBlueFilling) css_like_styles += "HTMLBlueSkyBlue";
+ else if (_filling == HTMLBlueLightSkyBlueFilling) css_like_styles += "HTMLBlueLightSkyBlue";
+ else if (_filling == HTMLBlueDeepSkyBlueFilling) css_like_styles += "HTMLBlueDeepSkyBlue";
+ else if (_filling == HTMLBlueDodgerBlueFilling) css_like_styles += "HTMLBlueDodgerBlue";
+ else if (_filling == HTMLBlueCornflowerBlueFilling) css_like_styles += "HTMLBlueCornflowerBlue";
+ else if (_filling == HTMLBlueSteelBlueFilling) css_like_styles += "HTMLBlueSteelBlue";
+ else if (_filling == HTMLBlueRoyalBlueFilling) css_like_styles += "HTMLBlueRoyalBlue";
+ else if (_filling == HTMLBlueBlueFilling) css_like_styles += "HTMLBlueBlue";
+ else if (_filling == HTMLBlueMediumBlueFilling) css_like_styles += "HTMLBlueMediumBlue";
+ else if (_filling == HTMLBlueDarkBlueFilling) css_like_styles += "HTMLBlueDarkBlue";
+ else if (_filling == HTMLBlueNavyFilling) css_like_styles += "HTMLBlueNavy";
+ else if (_filling == HTMLBlueMidnightBlueFilling) css_like_styles += "HTMLBlueMidnightBlue";
+ else if (_filling == HTMLPurpleLavenderFilling) css_like_styles += "HTMLPurpleLavender";
+ else if (_filling == HTMLPurpleThistleFilling) css_like_styles += "HTMLPurpleThistle";
+ else if (_filling == HTMLPurplePlumFilling) css_like_styles += "HTMLPurplePlum";
+ else if (_filling == HTMLPurpleVioletFilling) css_like_styles += "HTMLPurpleViolet";
+ else if (_filling == HTMLPurpleOrchidFilling) css_like_styles += "HTMLPurpleOrchid";
+ else if (_filling == HTMLPurpleFuchsiaFilling) css_like_styles += "HTMLPurpleFuchsia";
+ else if (_filling == HTMLPurpleMagentaFilling) css_like_styles += "HTMLPurpleMagenta";
+ else if (_filling == HTMLPurpleMediumOrchidFilling) css_like_styles += "HTMLPurpleMediumOrchid";
+ else if (_filling == HTMLPurpleMediumPurpleFilling) css_like_styles += "HTMLPurpleMediumPurple";
+ else if (_filling == HTMLPurpleBlueVioletFilling) css_like_styles += "HTMLPurpleBlueViolet";
+ else if (_filling == HTMLPurpleDarkVioletFilling) css_like_styles += "HTMLPurpleDarkViolet";
+ else if (_filling == HTMLPurpleDarkOrchidFilling) css_like_styles += "HTMLPurpleDarkOrchid";
+ else if (_filling == HTMLPurpleDarkMagentaFilling) css_like_styles += "HTMLPurpleDarkMagenta";
+ else if (_filling == HTMLPurplePurpleFilling) css_like_styles += "HTMLPurplePurple";
+ else if (_filling == HTMLPurpleIndigoFilling) css_like_styles += "HTMLPurpleIndigo";
+ else if (_filling == HTMLPurpleDarkSlateBlueFilling) css_like_styles += "HTMLPurpleDarkSlateBlue";
+ else if (_filling == HTMLPurpleSlateBlueFilling) css_like_styles += "HTMLPurpleSlateBlue";
+ else if (_filling == HTMLPurpleMediumSlateBlueFilling) css_like_styles += "HTMLPurpleMediumSlateBlue";
+ else if (_filling == HTMLWhiteWhiteFilling) css_like_styles += "HTMLWhiteWhite";
+ else if (_filling == HTMLWhiteSnowFilling) css_like_styles += "HTMLWhiteSnow";
+ else if (_filling == HTMLWhiteHoneydewFilling) css_like_styles += "HTMLWhiteHoneydew";
+ else if (_filling == HTMLWhiteMintCreamFilling) css_like_styles += "HTMLWhiteMintCream";
+ else if (_filling == HTMLWhiteAzureFilling) css_like_styles += "HTMLWhiteAzure";
+ else if (_filling == HTMLWhiteAliceBlueFilling) css_like_styles += "HTMLWhiteAliceBlue";
+ else if (_filling == HTMLWhiteGhostWhiteFilling) css_like_styles += "HTMLWhiteGhostWhite";
+ else if (_filling == HTMLWhiteWhiteSmokeFilling) css_like_styles += "HTMLWhiteWhiteSmoke";
+ else if (_filling == HTMLWhiteSeashellFilling) css_like_styles += "HTMLWhiteSeashell";
+ else if (_filling == HTMLWhiteBeigeFilling) css_like_styles += "HTMLWhiteBeige";
+ else if (_filling == HTMLWhiteOldLaceFilling) css_like_styles += "HTMLWhiteOldLace";
+ else if (_filling == HTMLWhiteFloralWhiteFilling) css_like_styles += "HTMLWhiteFloralWhite";
+ else if (_filling == HTMLWhiteIvoryFilling) css_like_styles += "HTMLWhiteIvory";
+ else if (_filling == HTMLWhiteAntiqueWhiteFilling) css_like_styles += "HTMLWhiteAntiqueWhite";
+ else if (_filling == HTMLWhiteLinenFilling) css_like_styles += "HTMLWhiteLinen";
+ else if (_filling == HTMLWhiteLavenderBlushFilling) css_like_styles += "HTMLWhiteLavenderBlush";
+ else if (_filling == HTMLWhiteMistyRoseFilling) css_like_styles += "HTMLWhiteMistyRose";
+ else if (_filling == HTMLGrayGainsboroFilling) css_like_styles += "HTMLGrayGainsboro";
+ else if (_filling == HTMLGrayLightGrayFilling) css_like_styles += "HTMLGrayLightGray";
+ else if (_filling == HTMLGraySilverFilling) css_like_styles += "HTMLGraySilver";
+ else if (_filling == HTMLGrayDarkGrayFilling) css_like_styles += "HTMLGrayDarkGray";
+ else if (_filling == HTMLGrayGrayFilling) css_like_styles += "HTMLGrayGray";
+ else if (_filling == HTMLGrayDimGrayFilling) css_like_styles += "HTMLGrayDimGray";
+ else if (_filling == HTMLGrayLightSlateGrayFilling) css_like_styles += "HTMLGrayLightSlateGray";
+ else if (_filling == HTMLGraySlateGrayFilling) css_like_styles += "HTMLGraySlateGray";
+ else if (_filling == HTMLGrayDarkSlateGrayFilling) css_like_styles += "HTMLGrayDarkSlateGray";
+ else if (_filling == HTMLGrayBlackFilling) css_like_styles += "HTMLGrayBlack";
+ else if (_filling == HorFilling) css_like_styles += "hor";
+ else if (_filling == VerFilling) css_like_styles += "ver";
+ else if (_filling == BdiagFilling) css_like_styles += "bdiag";
+ else if (_filling == FdiagFilling) css_like_styles += "fdiag";
- css_like_styles += ";color:";
- if (_color == WhiteColor) css_like_styles += "white";
- else if (_color == BlackColor) css_like_styles += "black";
- else if (_color == GreenColor) css_like_styles += "green";
- else if (_color == RedColor) css_like_styles += "red";
- else if (_color == BlueColor) css_like_styles += "blue";
- else if (_color == GrayColor) css_like_styles += "gray";
- else if (_color == BrunColor) css_like_styles += "brun";
- else if (_color == YellowColor) css_like_styles += "yellow";
- else if (_color == CyanColor) css_like_styles += "cyan";
- else if (_color == MagentaColor) css_like_styles += "magenta";
- else if (_color == LightgrayColor) css_like_styles += "lightgray";
- else if (_color == OrangeColor) css_like_styles += "orange";
- else if (_color == PurpleColor) css_like_styles += "purple";
- else if (_color == HTMLPinkPinkColor) css_like_styles += "HTMLPinkPink";
- else if (_color == HTMLPinkLightPinkColor) css_like_styles += "HTMLPinkLightPink";
- else if (_color == HTMLPinkHotPinkColor) css_like_styles += "HTMLPinkHotPink";
- else if (_color == HTMLPinkDeepPinkColor) css_like_styles += "HTMLPinkDeepPink";
- else if (_color == HTMLPinkPaleVioletRedColor) css_like_styles += "HTMLPinkPaleVioletRed";
- else if (_color == HTMLPinkMediumVioletRedColor) css_like_styles += "HTMLPinkMediumVioletRed";
- else if (_color == HTMLRedLightSalmonColor) css_like_styles += "HTMLRedLightSalmon";
- else if (_color == HTMLRedSalmonColor) css_like_styles += "HTMLRedSalmon";
- else if (_color == HTMLRedDarkSalmonColor) css_like_styles += "HTMLRedDarkSalmon";
- else if (_color == HTMLRedLightCoralColor) css_like_styles += "HTMLRedLightCoral";
- else if (_color == HTMLRedIndianRedColor) css_like_styles += "HTMLRedIndianRed";
- else if (_color == HTMLRedCrimsonColor) css_like_styles += "HTMLRedCrimson";
- else if (_color == HTMLRedFirebrickColor) css_like_styles += "HTMLRedFirebrick";
- else if (_color == HTMLRedDarkRedColor) css_like_styles += "HTMLRedDarkRed";
- else if (_color == HTMLRedRedColor) css_like_styles += "HTMLRedRed";
- else if (_color == HTMLOrangeOrangeRedColor) css_like_styles += "HTMLOrangeOrangeRed";
- else if (_color == HTMLOrangeTomatoColor) css_like_styles += "HTMLOrangeTomato";
- else if (_color == HTMLOrangeCoralColor) css_like_styles += "HTMLOrangeCoral";
- else if (_color == HTMLOrangeDarkOrangeColor) css_like_styles += "HTMLOrangeDarkOrange";
- else if (_color == HTMLOrangeOrangeColor) css_like_styles += "HTMLOrangeOrange";
- else if (_color == HTMLYellowYellowColor) css_like_styles += "HTMLYellowYellow";
- else if (_color == HTMLYellowLightYellowColor) css_like_styles += "HTMLYellowLightYellow";
- else if (_color == HTMLYellowLemonChiffonColor) css_like_styles += "HTMLYellowLemonChiffon";
- else if (_color == HTMLYellowLightGoldenrodYellowColor) css_like_styles += "HTMLYellowLightGoldenrodYellow";
- else if (_color == HTMLYellowPapayaWhipColor) css_like_styles += "HTMLYellowPapayaWhip";
- else if (_color == HTMLYellowMoccasinColor) css_like_styles += "HTMLYellowMoccasin";
- else if (_color == HTMLYellowPeachPuffColor) css_like_styles += "HTMLYellowPeachPuff";
- else if (_color == HTMLYellowPaleGoldenrodColor) css_like_styles += "HTMLYellowPaleGoldenrod";
- else if (_color == HTMLYellowKhakiColor) css_like_styles += "HTMLYellowKhaki";
- else if (_color == HTMLYellowDarkKhakiColor) css_like_styles += "HTMLYellowDarkKhaki";
- else if (_color == HTMLYellowGoldColor) css_like_styles += "HTMLYellowGold";
- else if (_color == HTMLBrownCornsilkColor) css_like_styles += "HTMLBrownCornsilk";
- else if (_color == HTMLBrownBlanchedAlmondColor) css_like_styles += "HTMLBrownBlanchedAlmond";
- else if (_color == HTMLBrownBisqueColor) css_like_styles += "HTMLBrownBisque";
- else if (_color == HTMLBrownNavajoWhiteColor) css_like_styles += "HTMLBrownNavajoWhite";
- else if (_color == HTMLBrownWheatColor) css_like_styles += "HTMLBrownWheat";
- else if (_color == HTMLBrownBurlywoodColor) css_like_styles += "HTMLBrownBurlywood";
- else if (_color == HTMLBrownTanColor) css_like_styles += "HTMLBrownTan";
- else if (_color == HTMLBrownRosyBrownColor) css_like_styles += "HTMLBrownRosyBrown";
- else if (_color == HTMLBrownSandyBrownColor) css_like_styles += "HTMLBrownSandyBrown";
- else if (_color == HTMLBrownGoldenrodColor) css_like_styles += "HTMLBrownGoldenrod";
- else if (_color == HTMLBrownDarkGoldenrodColor) css_like_styles += "HTMLBrownDarkGoldenrod";
- else if (_color == HTMLBrownPeruColor) css_like_styles += "HTMLBrownPeru";
- else if (_color == HTMLBrownChocolateColor) css_like_styles += "HTMLBrownChocolate";
- else if (_color == HTMLBrownSaddleBrownColor) css_like_styles += "HTMLBrownSaddleBrown";
- else if (_color == HTMLBrownSiennaColor) css_like_styles += "HTMLBrownSienna";
- else if (_color == HTMLBrownBrownColor) css_like_styles += "HTMLBrownBrown";
- else if (_color == HTMLBrownMaroonColor) css_like_styles += "HTMLBrownMaroon";
- else if (_color == HTMLGreenDarkOliveGreenColor) css_like_styles += "HTMLGreenDarkOliveGreen";
- else if (_color == HTMLGreenOliveColor) css_like_styles += "HTMLGreenOlive";
- else if (_color == HTMLGreenOliveDrabColor) css_like_styles += "HTMLGreenOliveDrab";
- else if (_color == HTMLGreenYellowGreenColor) css_like_styles += "HTMLGreenYellowGreen";
- else if (_color == HTMLGreenLimeGreenColor) css_like_styles += "HTMLGreenLimeGreen";
- else if (_color == HTMLGreenLimeColor) css_like_styles += "HTMLGreenLime";
- else if (_color == HTMLGreenLawnGreenColor) css_like_styles += "HTMLGreenLawnGreen";
- else if (_color == HTMLGreenChartreuseColor) css_like_styles += "HTMLGreenChartreuse";
- else if (_color == HTMLGreenGreenYellowColor) css_like_styles += "HTMLGreenGreenYellow";
- else if (_color == HTMLGreenSpringGreenColor) css_like_styles += "HTMLGreenSpringGreen";
- else if (_color == HTMLGreenMediumSpringGreenColor) css_like_styles += "HTMLGreenMediumSpringGreen";
- else if (_color == HTMLGreenLightGreenColor) css_like_styles += "HTMLGreenLightGreen";
- else if (_color == HTMLGreenPaleGreenColor) css_like_styles += "HTMLGreenPaleGreen";
- else if (_color == HTMLGreenDarkSeaGreenColor) css_like_styles += "HTMLGreenDarkSeaGreen";
- else if (_color == HTMLGreenMediumAquamarineColor) css_like_styles += "HTMLGreenMediumAquamarine";
- else if (_color == HTMLGreenMediumSeaGreenColor) css_like_styles += "HTMLGreenMediumSeaGreen";
- else if (_color == HTMLGreenSeaGreenColor) css_like_styles += "HTMLGreenSeaGreen";
- else if (_color == HTMLGreenForestGreenColor) css_like_styles += "HTMLGreenForestGreen";
- else if (_color == HTMLGreenGreenColor) css_like_styles += "HTMLGreenGreen";
- else if (_color == HTMLGreenDarkGreenColor) css_like_styles += "HTMLGreenDarkGreen";
- else if (_color == HTMLCyanAquaColor) css_like_styles += "HTMLCyanAqua";
- else if (_color == HTMLCyanCyanColor) css_like_styles += "HTMLCyanCyan";
- else if (_color == HTMLCyanLightCyanColor) css_like_styles += "HTMLCyanLightCyan";
- else if (_color == HTMLCyanPaleTurquoiseColor) css_like_styles += "HTMLCyanPaleTurquoise";
- else if (_color == HTMLCyanAquamarineColor) css_like_styles += "HTMLCyanAquamarine";
- else if (_color == HTMLCyanTurquoiseColor) css_like_styles += "HTMLCyanTurquoise";
- else if (_color == HTMLCyanMediumTurquoiseColor) css_like_styles += "HTMLCyanMediumTurquoise";
- else if (_color == HTMLCyanDarkTurquoiseColor) css_like_styles += "HTMLCyanDarkTurquoise";
- else if (_color == HTMLCyanLightSeaGreenColor) css_like_styles += "HTMLCyanLightSeaGreen";
- else if (_color == HTMLCyanCadetBlueColor) css_like_styles += "HTMLCyanCadetBlue";
- else if (_color == HTMLCyanDarkCyanColor) css_like_styles += "HTMLCyanDarkCyan";
- else if (_color == HTMLCyanTealColor) css_like_styles += "HTMLCyanTeal";
- else if (_color == HTMLBlueLightSteelBlueColor) css_like_styles += "HTMLBlueLightSteelBlue";
- else if (_color == HTMLBluePowderBlueColor) css_like_styles += "HTMLBluePowderBlue";
- else if (_color == HTMLBlueLightBlueColor) css_like_styles += "HTMLBlueLightBlue";
- else if (_color == HTMLBlueSkyBlueColor) css_like_styles += "HTMLBlueSkyBlue";
- else if (_color == HTMLBlueLightSkyBlueColor) css_like_styles += "HTMLBlueLightSkyBlue";
- else if (_color == HTMLBlueDeepSkyBlueColor) css_like_styles += "HTMLBlueDeepSkyBlue";
- else if (_color == HTMLBlueDodgerBlueColor) css_like_styles += "HTMLBlueDodgerBlue";
- else if (_color == HTMLBlueCornflowerBlueColor) css_like_styles += "HTMLBlueCornflowerBlue";
- else if (_color == HTMLBlueSteelBlueColor) css_like_styles += "HTMLBlueSteelBlue";
- else if (_color == HTMLBlueRoyalBlueColor) css_like_styles += "HTMLBlueRoyalBlue";
- else if (_color == HTMLBlueBlueColor) css_like_styles += "HTMLBlueBlue";
- else if (_color == HTMLBlueMediumBlueColor) css_like_styles += "HTMLBlueMediumBlue";
- else if (_color == HTMLBlueDarkBlueColor) css_like_styles += "HTMLBlueDarkBlue";
- else if (_color == HTMLBlueNavyColor) css_like_styles += "HTMLBlueNavy";
- else if (_color == HTMLBlueMidnightBlueColor) css_like_styles += "HTMLBlueMidnightBlue";
- else if (_color == HTMLPurpleLavenderColor) css_like_styles += "HTMLPurpleLavender";
- else if (_color == HTMLPurpleThistleColor) css_like_styles += "HTMLPurpleThistle";
- else if (_color == HTMLPurplePlumColor) css_like_styles += "HTMLPurplePlum";
- else if (_color == HTMLPurpleVioletColor) css_like_styles += "HTMLPurpleViolet";
- else if (_color == HTMLPurpleOrchidColor) css_like_styles += "HTMLPurpleOrchid";
- else if (_color == HTMLPurpleFuchsiaColor) css_like_styles += "HTMLPurpleFuchsia";
- else if (_color == HTMLPurpleMagentaColor) css_like_styles += "HTMLPurpleMagenta";
- else if (_color == HTMLPurpleMediumOrchidColor) css_like_styles += "HTMLPurpleMediumOrchid";
- else if (_color == HTMLPurpleMediumPurpleColor) css_like_styles += "HTMLPurpleMediumPurple";
- else if (_color == HTMLPurpleBlueVioletColor) css_like_styles += "HTMLPurpleBlueViolet";
- else if (_color == HTMLPurpleDarkVioletColor) css_like_styles += "HTMLPurpleDarkViolet";
- else if (_color == HTMLPurpleDarkOrchidColor) css_like_styles += "HTMLPurpleDarkOrchid";
- else if (_color == HTMLPurpleDarkMagentaColor) css_like_styles += "HTMLPurpleDarkMagenta";
- else if (_color == HTMLPurplePurpleColor) css_like_styles += "HTMLPurplePurple";
- else if (_color == HTMLPurpleIndigoColor) css_like_styles += "HTMLPurpleIndigo";
- else if (_color == HTMLPurpleDarkSlateBlueColor) css_like_styles += "HTMLPurpleDarkSlateBlue";
- else if (_color == HTMLPurpleSlateBlueColor) css_like_styles += "HTMLPurpleSlateBlue";
- else if (_color == HTMLPurpleMediumSlateBlueColor) css_like_styles += "HTMLPurpleMediumSlateBlue";
- else if (_color == HTMLWhiteWhiteColor) css_like_styles += "HTMLWhiteWhite";
- else if (_color == HTMLWhiteSnowColor) css_like_styles += "HTMLWhiteSnow";
- else if (_color == HTMLWhiteHoneydewColor) css_like_styles += "HTMLWhiteHoneydew";
- else if (_color == HTMLWhiteMintCreamColor) css_like_styles += "HTMLWhiteMintCream";
- else if (_color == HTMLWhiteAzureColor) css_like_styles += "HTMLWhiteAzure";
- else if (_color == HTMLWhiteAliceBlueColor) css_like_styles += "HTMLWhiteAliceBlue";
- else if (_color == HTMLWhiteGhostWhiteColor) css_like_styles += "HTMLWhiteGhostWhite";
- else if (_color == HTMLWhiteWhiteSmokeColor) css_like_styles += "HTMLWhiteWhiteSmoke";
- else if (_color == HTMLWhiteSeashellColor) css_like_styles += "HTMLWhiteSeashell";
- else if (_color == HTMLWhiteBeigeColor) css_like_styles += "HTMLWhiteBeige";
- else if (_color == HTMLWhiteOldLaceColor) css_like_styles += "HTMLWhiteOldLace";
- else if (_color == HTMLWhiteFloralWhiteColor) css_like_styles += "HTMLWhiteFloralWhite";
- else if (_color == HTMLWhiteIvoryColor) css_like_styles += "HTMLWhiteIvory";
- else if (_color == HTMLWhiteAntiqueWhiteColor) css_like_styles += "HTMLWhiteAntiqueWhite";
- else if (_color == HTMLWhiteLinenColor) css_like_styles += "HTMLWhiteLinen";
- else if (_color == HTMLWhiteLavenderBlushColor) css_like_styles += "HTMLWhiteLavenderBlush";
- else if (_color == HTMLWhiteMistyRoseColor) css_like_styles += "HTMLWhiteMistyRose";
- else if (_color == HTMLGrayGainsboroColor) css_like_styles += "HTMLGrayGainsboro";
- else if (_color == HTMLGrayLightGrayColor) css_like_styles += "HTMLGrayLightGray";
- else if (_color == HTMLGraySilverColor) css_like_styles += "HTMLGraySilver";
- else if (_color == HTMLGrayDarkGrayColor) css_like_styles += "HTMLGrayDarkGray";
- else if (_color == HTMLGrayGrayColor) css_like_styles += "HTMLGrayGray";
- else if (_color == HTMLGrayDimGrayColor) css_like_styles += "HTMLGrayDimGray";
- else if (_color == HTMLGrayLightSlateGrayColor) css_like_styles += "HTMLGrayLightSlateGray";
- else if (_color == HTMLGraySlateGrayColor) css_like_styles += "HTMLGraySlateGray";
- else if (_color == HTMLGrayDarkSlateGrayColor) css_like_styles += "HTMLGrayDarkSlateGray";
- else if (_color == HTMLGrayBlackColor) css_like_styles += "HTMLGrayBlack";
- else if (_color == NoneColor) css_like_styles += "none";
+ css_like_styles += ";color:";
+ if (_color == WhiteColor) css_like_styles += "white";
+ else if (_color == BlackColor) css_like_styles += "black";
+ else if (_color == GreenColor) css_like_styles += "green";
+ else if (_color == RedColor) css_like_styles += "red";
+ else if (_color == BlueColor) css_like_styles += "blue";
+ else if (_color == GrayColor) css_like_styles += "gray";
+ else if (_color == BrunColor) css_like_styles += "brun";
+ else if (_color == YellowColor) css_like_styles += "yellow";
+ else if (_color == CyanColor) css_like_styles += "cyan";
+ else if (_color == MagentaColor) css_like_styles += "magenta";
+ else if (_color == LightgrayColor) css_like_styles += "lightgray";
+ else if (_color == OrangeColor) css_like_styles += "orange";
+ else if (_color == PurpleColor) css_like_styles += "purple";
+ else if (_color == HTMLPinkPinkColor) css_like_styles += "HTMLPinkPink";
+ else if (_color == HTMLPinkLightPinkColor) css_like_styles += "HTMLPinkLightPink";
+ else if (_color == HTMLPinkHotPinkColor) css_like_styles += "HTMLPinkHotPink";
+ else if (_color == HTMLPinkDeepPinkColor) css_like_styles += "HTMLPinkDeepPink";
+ else if (_color == HTMLPinkPaleVioletRedColor) css_like_styles += "HTMLPinkPaleVioletRed";
+ else if (_color == HTMLPinkMediumVioletRedColor) css_like_styles += "HTMLPinkMediumVioletRed";
+ else if (_color == HTMLRedLightSalmonColor) css_like_styles += "HTMLRedLightSalmon";
+ else if (_color == HTMLRedSalmonColor) css_like_styles += "HTMLRedSalmon";
+ else if (_color == HTMLRedDarkSalmonColor) css_like_styles += "HTMLRedDarkSalmon";
+ else if (_color == HTMLRedLightCoralColor) css_like_styles += "HTMLRedLightCoral";
+ else if (_color == HTMLRedIndianRedColor) css_like_styles += "HTMLRedIndianRed";
+ else if (_color == HTMLRedCrimsonColor) css_like_styles += "HTMLRedCrimson";
+ else if (_color == HTMLRedFirebrickColor) css_like_styles += "HTMLRedFirebrick";
+ else if (_color == HTMLRedDarkRedColor) css_like_styles += "HTMLRedDarkRed";
+ else if (_color == HTMLRedRedColor) css_like_styles += "HTMLRedRed";
+ else if (_color == HTMLOrangeOrangeRedColor) css_like_styles += "HTMLOrangeOrangeRed";
+ else if (_color == HTMLOrangeTomatoColor) css_like_styles += "HTMLOrangeTomato";
+ else if (_color == HTMLOrangeCoralColor) css_like_styles += "HTMLOrangeCoral";
+ else if (_color == HTMLOrangeDarkOrangeColor) css_like_styles += "HTMLOrangeDarkOrange";
+ else if (_color == HTMLOrangeOrangeColor) css_like_styles += "HTMLOrangeOrange";
+ else if (_color == HTMLYellowYellowColor) css_like_styles += "HTMLYellowYellow";
+ else if (_color == HTMLYellowLightYellowColor) css_like_styles += "HTMLYellowLightYellow";
+ else if (_color == HTMLYellowLemonChiffonColor) css_like_styles += "HTMLYellowLemonChiffon";
+ else if (_color == HTMLYellowLightGoldenrodYellowColor) css_like_styles += "HTMLYellowLightGoldenrodYellow";
+ else if (_color == HTMLYellowPapayaWhipColor) css_like_styles += "HTMLYellowPapayaWhip";
+ else if (_color == HTMLYellowMoccasinColor) css_like_styles += "HTMLYellowMoccasin";
+ else if (_color == HTMLYellowPeachPuffColor) css_like_styles += "HTMLYellowPeachPuff";
+ else if (_color == HTMLYellowPaleGoldenrodColor) css_like_styles += "HTMLYellowPaleGoldenrod";
+ else if (_color == HTMLYellowKhakiColor) css_like_styles += "HTMLYellowKhaki";
+ else if (_color == HTMLYellowDarkKhakiColor) css_like_styles += "HTMLYellowDarkKhaki";
+ else if (_color == HTMLYellowGoldColor) css_like_styles += "HTMLYellowGold";
+ else if (_color == HTMLBrownCornsilkColor) css_like_styles += "HTMLBrownCornsilk";
+ else if (_color == HTMLBrownBlanchedAlmondColor) css_like_styles += "HTMLBrownBlanchedAlmond";
+ else if (_color == HTMLBrownBisqueColor) css_like_styles += "HTMLBrownBisque";
+ else if (_color == HTMLBrownNavajoWhiteColor) css_like_styles += "HTMLBrownNavajoWhite";
+ else if (_color == HTMLBrownWheatColor) css_like_styles += "HTMLBrownWheat";
+ else if (_color == HTMLBrownBurlywoodColor) css_like_styles += "HTMLBrownBurlywood";
+ else if (_color == HTMLBrownTanColor) css_like_styles += "HTMLBrownTan";
+ else if (_color == HTMLBrownRosyBrownColor) css_like_styles += "HTMLBrownRosyBrown";
+ else if (_color == HTMLBrownSandyBrownColor) css_like_styles += "HTMLBrownSandyBrown";
+ else if (_color == HTMLBrownGoldenrodColor) css_like_styles += "HTMLBrownGoldenrod";
+ else if (_color == HTMLBrownDarkGoldenrodColor) css_like_styles += "HTMLBrownDarkGoldenrod";
+ else if (_color == HTMLBrownPeruColor) css_like_styles += "HTMLBrownPeru";
+ else if (_color == HTMLBrownChocolateColor) css_like_styles += "HTMLBrownChocolate";
+ else if (_color == HTMLBrownSaddleBrownColor) css_like_styles += "HTMLBrownSaddleBrown";
+ else if (_color == HTMLBrownSiennaColor) css_like_styles += "HTMLBrownSienna";
+ else if (_color == HTMLBrownBrownColor) css_like_styles += "HTMLBrownBrown";
+ else if (_color == HTMLBrownMaroonColor) css_like_styles += "HTMLBrownMaroon";
+ else if (_color == HTMLGreenDarkOliveGreenColor) css_like_styles += "HTMLGreenDarkOliveGreen";
+ else if (_color == HTMLGreenOliveColor) css_like_styles += "HTMLGreenOlive";
+ else if (_color == HTMLGreenOliveDrabColor) css_like_styles += "HTMLGreenOliveDrab";
+ else if (_color == HTMLGreenYellowGreenColor) css_like_styles += "HTMLGreenYellowGreen";
+ else if (_color == HTMLGreenLimeGreenColor) css_like_styles += "HTMLGreenLimeGreen";
+ else if (_color == HTMLGreenLimeColor) css_like_styles += "HTMLGreenLime";
+ else if (_color == HTMLGreenLawnGreenColor) css_like_styles += "HTMLGreenLawnGreen";
+ else if (_color == HTMLGreenChartreuseColor) css_like_styles += "HTMLGreenChartreuse";
+ else if (_color == HTMLGreenGreenYellowColor) css_like_styles += "HTMLGreenGreenYellow";
+ else if (_color == HTMLGreenSpringGreenColor) css_like_styles += "HTMLGreenSpringGreen";
+ else if (_color == HTMLGreenMediumSpringGreenColor) css_like_styles += "HTMLGreenMediumSpringGreen";
+ else if (_color == HTMLGreenLightGreenColor) css_like_styles += "HTMLGreenLightGreen";
+ else if (_color == HTMLGreenPaleGreenColor) css_like_styles += "HTMLGreenPaleGreen";
+ else if (_color == HTMLGreenDarkSeaGreenColor) css_like_styles += "HTMLGreenDarkSeaGreen";
+ else if (_color == HTMLGreenMediumAquamarineColor) css_like_styles += "HTMLGreenMediumAquamarine";
+ else if (_color == HTMLGreenMediumSeaGreenColor) css_like_styles += "HTMLGreenMediumSeaGreen";
+ else if (_color == HTMLGreenSeaGreenColor) css_like_styles += "HTMLGreenSeaGreen";
+ else if (_color == HTMLGreenForestGreenColor) css_like_styles += "HTMLGreenForestGreen";
+ else if (_color == HTMLGreenGreenColor) css_like_styles += "HTMLGreenGreen";
+ else if (_color == HTMLGreenDarkGreenColor) css_like_styles += "HTMLGreenDarkGreen";
+ else if (_color == HTMLCyanAquaColor) css_like_styles += "HTMLCyanAqua";
+ else if (_color == HTMLCyanCyanColor) css_like_styles += "HTMLCyanCyan";
+ else if (_color == HTMLCyanLightCyanColor) css_like_styles += "HTMLCyanLightCyan";
+ else if (_color == HTMLCyanPaleTurquoiseColor) css_like_styles += "HTMLCyanPaleTurquoise";
+ else if (_color == HTMLCyanAquamarineColor) css_like_styles += "HTMLCyanAquamarine";
+ else if (_color == HTMLCyanTurquoiseColor) css_like_styles += "HTMLCyanTurquoise";
+ else if (_color == HTMLCyanMediumTurquoiseColor) css_like_styles += "HTMLCyanMediumTurquoise";
+ else if (_color == HTMLCyanDarkTurquoiseColor) css_like_styles += "HTMLCyanDarkTurquoise";
+ else if (_color == HTMLCyanLightSeaGreenColor) css_like_styles += "HTMLCyanLightSeaGreen";
+ else if (_color == HTMLCyanCadetBlueColor) css_like_styles += "HTMLCyanCadetBlue";
+ else if (_color == HTMLCyanDarkCyanColor) css_like_styles += "HTMLCyanDarkCyan";
+ else if (_color == HTMLCyanTealColor) css_like_styles += "HTMLCyanTeal";
+ else if (_color == HTMLBlueLightSteelBlueColor) css_like_styles += "HTMLBlueLightSteelBlue";
+ else if (_color == HTMLBluePowderBlueColor) css_like_styles += "HTMLBluePowderBlue";
+ else if (_color == HTMLBlueLightBlueColor) css_like_styles += "HTMLBlueLightBlue";
+ else if (_color == HTMLBlueSkyBlueColor) css_like_styles += "HTMLBlueSkyBlue";
+ else if (_color == HTMLBlueLightSkyBlueColor) css_like_styles += "HTMLBlueLightSkyBlue";
+ else if (_color == HTMLBlueDeepSkyBlueColor) css_like_styles += "HTMLBlueDeepSkyBlue";
+ else if (_color == HTMLBlueDodgerBlueColor) css_like_styles += "HTMLBlueDodgerBlue";
+ else if (_color == HTMLBlueCornflowerBlueColor) css_like_styles += "HTMLBlueCornflowerBlue";
+ else if (_color == HTMLBlueSteelBlueColor) css_like_styles += "HTMLBlueSteelBlue";
+ else if (_color == HTMLBlueRoyalBlueColor) css_like_styles += "HTMLBlueRoyalBlue";
+ else if (_color == HTMLBlueBlueColor) css_like_styles += "HTMLBlueBlue";
+ else if (_color == HTMLBlueMediumBlueColor) css_like_styles += "HTMLBlueMediumBlue";
+ else if (_color == HTMLBlueDarkBlueColor) css_like_styles += "HTMLBlueDarkBlue";
+ else if (_color == HTMLBlueNavyColor) css_like_styles += "HTMLBlueNavy";
+ else if (_color == HTMLBlueMidnightBlueColor) css_like_styles += "HTMLBlueMidnightBlue";
+ else if (_color == HTMLPurpleLavenderColor) css_like_styles += "HTMLPurpleLavender";
+ else if (_color == HTMLPurpleThistleColor) css_like_styles += "HTMLPurpleThistle";
+ else if (_color == HTMLPurplePlumColor) css_like_styles += "HTMLPurplePlum";
+ else if (_color == HTMLPurpleVioletColor) css_like_styles += "HTMLPurpleViolet";
+ else if (_color == HTMLPurpleOrchidColor) css_like_styles += "HTMLPurpleOrchid";
+ else if (_color == HTMLPurpleFuchsiaColor) css_like_styles += "HTMLPurpleFuchsia";
+ else if (_color == HTMLPurpleMagentaColor) css_like_styles += "HTMLPurpleMagenta";
+ else if (_color == HTMLPurpleMediumOrchidColor) css_like_styles += "HTMLPurpleMediumOrchid";
+ else if (_color == HTMLPurpleMediumPurpleColor) css_like_styles += "HTMLPurpleMediumPurple";
+ else if (_color == HTMLPurpleBlueVioletColor) css_like_styles += "HTMLPurpleBlueViolet";
+ else if (_color == HTMLPurpleDarkVioletColor) css_like_styles += "HTMLPurpleDarkViolet";
+ else if (_color == HTMLPurpleDarkOrchidColor) css_like_styles += "HTMLPurpleDarkOrchid";
+ else if (_color == HTMLPurpleDarkMagentaColor) css_like_styles += "HTMLPurpleDarkMagenta";
+ else if (_color == HTMLPurplePurpleColor) css_like_styles += "HTMLPurplePurple";
+ else if (_color == HTMLPurpleIndigoColor) css_like_styles += "HTMLPurpleIndigo";
+ else if (_color == HTMLPurpleDarkSlateBlueColor) css_like_styles += "HTMLPurpleDarkSlateBlue";
+ else if (_color == HTMLPurpleSlateBlueColor) css_like_styles += "HTMLPurpleSlateBlue";
+ else if (_color == HTMLPurpleMediumSlateBlueColor) css_like_styles += "HTMLPurpleMediumSlateBlue";
+ else if (_color == HTMLWhiteWhiteColor) css_like_styles += "HTMLWhiteWhite";
+ else if (_color == HTMLWhiteSnowColor) css_like_styles += "HTMLWhiteSnow";
+ else if (_color == HTMLWhiteHoneydewColor) css_like_styles += "HTMLWhiteHoneydew";
+ else if (_color == HTMLWhiteMintCreamColor) css_like_styles += "HTMLWhiteMintCream";
+ else if (_color == HTMLWhiteAzureColor) css_like_styles += "HTMLWhiteAzure";
+ else if (_color == HTMLWhiteAliceBlueColor) css_like_styles += "HTMLWhiteAliceBlue";
+ else if (_color == HTMLWhiteGhostWhiteColor) css_like_styles += "HTMLWhiteGhostWhite";
+ else if (_color == HTMLWhiteWhiteSmokeColor) css_like_styles += "HTMLWhiteWhiteSmoke";
+ else if (_color == HTMLWhiteSeashellColor) css_like_styles += "HTMLWhiteSeashell";
+ else if (_color == HTMLWhiteBeigeColor) css_like_styles += "HTMLWhiteBeige";
+ else if (_color == HTMLWhiteOldLaceColor) css_like_styles += "HTMLWhiteOldLace";
+ else if (_color == HTMLWhiteFloralWhiteColor) css_like_styles += "HTMLWhiteFloralWhite";
+ else if (_color == HTMLWhiteIvoryColor) css_like_styles += "HTMLWhiteIvory";
+ else if (_color == HTMLWhiteAntiqueWhiteColor) css_like_styles += "HTMLWhiteAntiqueWhite";
+ else if (_color == HTMLWhiteLinenColor) css_like_styles += "HTMLWhiteLinen";
+ else if (_color == HTMLWhiteLavenderBlushColor) css_like_styles += "HTMLWhiteLavenderBlush";
+ else if (_color == HTMLWhiteMistyRoseColor) css_like_styles += "HTMLWhiteMistyRose";
+ else if (_color == HTMLGrayGainsboroColor) css_like_styles += "HTMLGrayGainsboro";
+ else if (_color == HTMLGrayLightGrayColor) css_like_styles += "HTMLGrayLightGray";
+ else if (_color == HTMLGraySilverColor) css_like_styles += "HTMLGraySilver";
+ else if (_color == HTMLGrayDarkGrayColor) css_like_styles += "HTMLGrayDarkGray";
+ else if (_color == HTMLGrayGrayColor) css_like_styles += "HTMLGrayGray";
+ else if (_color == HTMLGrayDimGrayColor) css_like_styles += "HTMLGrayDimGray";
+ else if (_color == HTMLGrayLightSlateGrayColor) css_like_styles += "HTMLGrayLightSlateGray";
+ else if (_color == HTMLGraySlateGrayColor) css_like_styles += "HTMLGraySlateGray";
+ else if (_color == HTMLGrayDarkSlateGrayColor) css_like_styles += "HTMLGrayDarkSlateGray";
+ else if (_color == HTMLGrayBlackColor) css_like_styles += "HTMLGrayBlack";
+ else if (_color == NoneColor) css_like_styles += "none";
- qde.setAttribute("style", css_like_styles);
- qde.setAttribute("antialias", _antialiased ? "true" : "false");
+ qde.setAttribute("style", css_like_styles);
+ qde.setAttribute("antialias", _antialiased ? "true" : "false");
}
/**
- @brief CustomElementGraphicPart::stylesFromXml
- Read the style used by this, from a xml element.
- @param qde : QDomElement used to read the style
+ @brief CustomElementGraphicPart::stylesFromXml
+ Read the style used by this, from a xml element.
+ @param qde : QDomElement used to read the style
*/
void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
{
- resetStyles();
+ resetStyles();
- //Get the list of pair style/value
-#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
- QStringList styles = qde.attribute("style").split(";", QString::SkipEmptyParts);
+ //Get the list of pair style/value
+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
+ QStringList styles = qde.attribute("style").split(";", QString::SkipEmptyParts);
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 5.14 or later")
#endif
- QStringList styles = qde.attribute("style").split(";", Qt::SkipEmptyParts);
+ QStringList styles = qde.attribute("style").split(";", Qt::SkipEmptyParts);
#endif
//Check each pair of style
@@ -873,466 +873,466 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
/**
- @brief CustomElementGraphicPart::resetStyles
- Reset the curent style to default,
- same style of default constructor
+ @brief CustomElementGraphicPart::resetStyles
+ Reset the curent style to default,
+ same style of default constructor
*/
void CustomElementGraphicPart::resetStyles()
{
- _linestyle = NormalStyle;
- _lineweight = NormalWeight;
- _filling = NoneFilling;
- _color = BlackColor;
- _antialiased = false;
+ _linestyle = NormalStyle;
+ _lineweight = NormalWeight;
+ _filling = NoneFilling;
+ _color = BlackColor;
+ _antialiased = false;
}
/**
- @brief CustomElementGraphicPart::applyStylesToQPainter
- Apply the current style to the QPainter
- @param painter
+ @brief CustomElementGraphicPart::applyStylesToQPainter
+ Apply the current style to the QPainter
+ @param painter
*/
void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
{
- //Get the pen and brush
- QPen pen = painter.pen();
- QBrush brush = painter.brush();
+ //Get the pen and brush
+ QPen pen = painter.pen();
+ QBrush brush = painter.brush();
- //Apply pen style
- if (_linestyle == DashedStyle) pen.setStyle(Qt::DashLine);
- else if (_linestyle == DashdottedStyle) pen.setStyle(Qt::DashDotLine);
- else if (_linestyle == DottedStyle) pen.setStyle(Qt::DotLine);
- else if (_linestyle == NormalStyle) pen.setStyle(Qt::SolidLine);
+ //Apply pen style
+ if (_linestyle == DashedStyle) pen.setStyle(Qt::DashLine);
+ else if (_linestyle == DashdottedStyle) pen.setStyle(Qt::DashDotLine);
+ else if (_linestyle == DottedStyle) pen.setStyle(Qt::DotLine);
+ else if (_linestyle == NormalStyle) pen.setStyle(Qt::SolidLine);
- //Apply pen width
- if (_lineweight == NoneWeight) pen.setColor(QColor(0, 0, 0, 0));
- else if (_lineweight == ThinWeight) pen.setWidth(0);
- else if (_lineweight == NormalWeight) pen.setWidthF(1.0);
- else if (_lineweight == UltraWeight) pen.setWidthF(2.0);
- else if (_lineweight == BigWeight) pen.setWidthF(5.0);
+ //Apply pen width
+ if (_lineweight == NoneWeight) pen.setColor(QColor(0, 0, 0, 0));
+ else if (_lineweight == ThinWeight) pen.setWidth(0);
+ else if (_lineweight == NormalWeight) pen.setWidthF(1.0);
+ else if (_lineweight == UltraWeight) pen.setWidthF(2.0);
+ else if (_lineweight == BigWeight) pen.setWidthF(5.0);
- //Apply brush color
- if (_filling == NoneFilling) brush.setStyle(Qt::NoBrush);
- else if (_filling == HorFilling) brush.setStyle(Qt::HorPattern);
- else if (_filling == VerFilling) brush.setStyle(Qt::VerPattern);
- else if (_filling == BdiagFilling) brush.setStyle(Qt::BDiagPattern);
- else if (_filling == FdiagFilling) brush.setStyle(Qt::FDiagPattern);
- else
- {
- brush.setStyle(Qt::SolidPattern);
- if (_filling == BlackFilling) brush.setColor(Qt::black);
- else if (_filling == WhiteFilling) brush.setColor(Qt::white);
- else if (_filling == GreenFilling) brush.setColor(Qt::green);
- else if (_filling == RedFilling) brush.setColor(Qt::red);
- else if (_filling == BlueFilling) brush.setColor(Qt::blue);
- else if (_filling == GrayFilling) brush.setColor(Qt::gray);
- else if (_filling == BrunFilling) brush.setColor(QColor(97, 44, 0));
- else if (_filling == YellowFilling) brush.setColor(Qt::yellow);
- else if (_filling == CyanFilling) brush.setColor(Qt::cyan);
- else if (_filling == MagentaFilling) brush.setColor(Qt::magenta);
- else if (_filling == LightgrayFilling) brush.setColor(Qt::lightGray);
- else if (_filling == OrangeFilling) brush.setColor(QColor(255, 128, 0));
- else if (_filling == PurpleFilling) brush.setColor(QColor(136, 28, 168));
- else if (_filling == HTMLPinkPinkFilling) brush.setColor(QColor(255, 192, 203));
- else if (_filling == HTMLPinkLightPinkFilling) brush.setColor(QColor(255, 182, 193));
- else if (_filling == HTMLPinkHotPinkFilling) brush.setColor(QColor(255, 105, 180));
- else if (_filling == HTMLPinkDeepPinkFilling) brush.setColor(QColor(255, 20, 147));
- else if (_filling == HTMLPinkPaleVioletRedFilling) brush.setColor(QColor(219, 112, 147));
- else if (_filling == HTMLPinkMediumVioletRedFilling) brush.setColor(QColor(199, 21, 133));
- else if (_filling == HTMLRedLightSalmonFilling) brush.setColor(QColor(255, 160, 122));
- else if (_filling == HTMLRedSalmonFilling) brush.setColor(QColor(250, 128, 114));
- else if (_filling == HTMLRedDarkSalmonFilling) brush.setColor(QColor(233, 150, 122));
- else if (_filling == HTMLRedLightCoralFilling) brush.setColor(QColor(240, 128, 128));
- else if (_filling == HTMLRedIndianRedFilling) brush.setColor(QColor(205, 92, 92));
- else if (_filling == HTMLRedCrimsonFilling) brush.setColor(QColor(220, 20, 60));
- else if (_filling == HTMLRedFirebrickFilling) brush.setColor(QColor(178, 34, 34));
- else if (_filling == HTMLRedDarkRedFilling) brush.setColor(QColor(139, 0, 0));
- else if (_filling == HTMLRedRedFilling) brush.setColor(QColor(255, 0, 0));
- else if (_filling == HTMLOrangeOrangeRedFilling) brush.setColor(QColor(255, 69, 0));
- else if (_filling == HTMLOrangeTomatoFilling) brush.setColor(QColor(255, 99, 71));
- else if (_filling == HTMLOrangeCoralFilling) brush.setColor(QColor(255, 127, 80));
- else if (_filling == HTMLOrangeDarkOrangeFilling) brush.setColor(QColor(255, 140, 0));
- else if (_filling == HTMLOrangeOrangeFilling) brush.setColor(QColor(255, 165, 0));
- else if (_filling == HTMLYellowYellowFilling) brush.setColor(QColor(255, 255, 0));
- else if (_filling == HTMLYellowLightYellowFilling) brush.setColor(QColor(255, 255, 224));
- else if (_filling == HTMLYellowLemonChiffonFilling) brush.setColor(QColor(255, 250, 205));
- else if (_filling == HTMLYellowLightGoldenrodYellowFilling) brush.setColor(QColor(250, 250, 210));
- else if (_filling == HTMLYellowPapayaWhipFilling) brush.setColor(QColor(255, 239, 213));
- else if (_filling == HTMLYellowMoccasinFilling) brush.setColor(QColor(255, 228, 181));
- else if (_filling == HTMLYellowPeachPuffFilling) brush.setColor(QColor(255, 218, 185));
- else if (_filling == HTMLYellowPaleGoldenrodFilling) brush.setColor(QColor(238, 232, 170));
- else if (_filling == HTMLYellowKhakiFilling) brush.setColor(QColor(240, 230, 140));
- else if (_filling == HTMLYellowDarkKhakiFilling) brush.setColor(QColor(189, 183, 107));
- else if (_filling == HTMLYellowGoldFilling) brush.setColor(QColor(255, 215, 0));
- else if (_filling == HTMLBrownCornsilkFilling) brush.setColor(QColor(255, 248, 220));
- else if (_filling == HTMLBrownBlanchedAlmondFilling) brush.setColor(QColor(255, 235, 205));
- else if (_filling == HTMLBrownBisqueFilling) brush.setColor(QColor(255, 228, 196));
- else if (_filling == HTMLBrownNavajoWhiteFilling) brush.setColor(QColor(255, 222, 173));
- else if (_filling == HTMLBrownWheatFilling) brush.setColor(QColor(245, 222, 179));
- else if (_filling == HTMLBrownBurlywoodFilling) brush.setColor(QColor(222, 184, 135));
- else if (_filling == HTMLBrownTanFilling) brush.setColor(QColor(210, 180, 140));
- else if (_filling == HTMLBrownRosyBrownFilling) brush.setColor(QColor(188, 143, 143));
- else if (_filling == HTMLBrownSandyBrownFilling) brush.setColor(QColor(244, 164, 96));
- else if (_filling == HTMLBrownGoldenrodFilling) brush.setColor(QColor(218, 165, 32));
- else if (_filling == HTMLBrownDarkGoldenrodFilling) brush.setColor(QColor(184, 134, 11));
- else if (_filling == HTMLBrownPeruFilling) brush.setColor(QColor(205, 133, 63));
- else if (_filling == HTMLBrownChocolateFilling) brush.setColor(QColor(210, 105, 30));
- else if (_filling == HTMLBrownSaddleBrownFilling) brush.setColor(QColor(139, 69, 19));
- else if (_filling == HTMLBrownSiennaFilling) brush.setColor(QColor(160, 82, 45));
- else if (_filling == HTMLBrownBrownFilling) brush.setColor(QColor(165, 42, 42));
- else if (_filling == HTMLBrownMaroonFilling) brush.setColor(QColor(128, 0, 0));
- else if (_filling == HTMLGreenDarkOliveGreenFilling) brush.setColor(QColor(85, 107, 47));
- else if (_filling == HTMLGreenOliveFilling) brush.setColor(QColor(128, 128, 0));
- else if (_filling == HTMLGreenOliveDrabFilling) brush.setColor(QColor(107, 142, 35));
- else if (_filling == HTMLGreenYellowGreenFilling) brush.setColor(QColor(154, 205, 50));
- else if (_filling == HTMLGreenLimeGreenFilling) brush.setColor(QColor(50, 205, 50));
- else if (_filling == HTMLGreenLimeFilling) brush.setColor(QColor(0, 255, 0));
- else if (_filling == HTMLGreenLawnGreenFilling) brush.setColor(QColor(124, 252, 0));
- else if (_filling == HTMLGreenChartreuseFilling) brush.setColor(QColor(127, 255, 0));
- else if (_filling == HTMLGreenGreenYellowFilling) brush.setColor(QColor(173, 255, 47));
- else if (_filling == HTMLGreenSpringGreenFilling) brush.setColor(QColor(0, 255, 127));
- else if (_filling == HTMLGreenMediumSpringGreenFilling) brush.setColor(QColor(0, 250, 154));
- else if (_filling == HTMLGreenLightGreenFilling) brush.setColor(QColor(144, 238, 144));
- else if (_filling == HTMLGreenPaleGreenFilling) brush.setColor(QColor(152, 251, 152));
- else if (_filling == HTMLGreenDarkSeaGreenFilling) brush.setColor(QColor(143, 188, 143));
- else if (_filling == HTMLGreenMediumAquamarineFilling) brush.setColor(QColor(102, 205, 170));
- else if (_filling == HTMLGreenMediumSeaGreenFilling) brush.setColor(QColor(60, 179, 113));
- else if (_filling == HTMLGreenSeaGreenFilling) brush.setColor(QColor(46, 139, 87));
- else if (_filling == HTMLGreenForestGreenFilling) brush.setColor(QColor(34, 139, 34));
- else if (_filling == HTMLGreenGreenFilling) brush.setColor(QColor(0, 128, 0));
- else if (_filling == HTMLGreenDarkGreenFilling) brush.setColor(QColor(0, 100, 0));
- else if (_filling == HTMLCyanAquaFilling) brush.setColor(QColor(0, 255, 255));
- else if (_filling == HTMLCyanCyanFilling) brush.setColor(QColor(0, 255, 255));
- else if (_filling == HTMLCyanLightCyanFilling) brush.setColor(QColor(224, 255, 255));
- else if (_filling == HTMLCyanPaleTurquoiseFilling) brush.setColor(QColor(175, 238, 238));
- else if (_filling == HTMLCyanAquamarineFilling) brush.setColor(QColor(127, 255, 212));
- else if (_filling == HTMLCyanTurquoiseFilling) brush.setColor(QColor(64, 224, 208));
- else if (_filling == HTMLCyanMediumTurquoiseFilling) brush.setColor(QColor(72, 209, 204));
- else if (_filling == HTMLCyanDarkTurquoiseFilling) brush.setColor(QColor(0, 206, 209));
- else if (_filling == HTMLCyanLightSeaGreenFilling) brush.setColor(QColor(32, 178, 170));
- else if (_filling == HTMLCyanCadetBlueFilling) brush.setColor(QColor(95, 158, 160));
- else if (_filling == HTMLCyanDarkCyanFilling) brush.setColor(QColor(0, 139, 139));
- else if (_filling == HTMLCyanTealFilling) brush.setColor(QColor(0, 128, 128));
- else if (_filling == HTMLBlueLightSteelBlueFilling) brush.setColor(QColor(176, 196, 222));
- else if (_filling == HTMLBluePowderBlueFilling) brush.setColor(QColor(176, 224, 230));
- else if (_filling == HTMLBlueLightBlueFilling) brush.setColor(QColor(173, 216, 230));
- else if (_filling == HTMLBlueSkyBlueFilling) brush.setColor(QColor(135, 206, 235));
- else if (_filling == HTMLBlueLightSkyBlueFilling) brush.setColor(QColor(135, 206, 250));
- else if (_filling == HTMLBlueDeepSkyBlueFilling) brush.setColor(QColor(0, 191, 255));
- else if (_filling == HTMLBlueDodgerBlueFilling) brush.setColor(QColor(30, 144, 255));
- else if (_filling == HTMLBlueCornflowerBlueFilling) brush.setColor(QColor(100, 149, 237));
- else if (_filling == HTMLBlueSteelBlueFilling) brush.setColor(QColor(70, 130, 180));
- else if (_filling == HTMLBlueRoyalBlueFilling) brush.setColor(QColor(65, 105, 225));
- else if (_filling == HTMLBlueBlueFilling) brush.setColor(QColor(0, 0, 255));
- else if (_filling == HTMLBlueMediumBlueFilling) brush.setColor(QColor(0, 0, 205));
- else if (_filling == HTMLBlueDarkBlueFilling) brush.setColor(QColor(0, 0, 139));
- else if (_filling == HTMLBlueNavyFilling) brush.setColor(QColor(0, 0, 128));
- else if (_filling == HTMLBlueMidnightBlueFilling) brush.setColor(QColor(25, 25, 112));
- else if (_filling == HTMLPurpleLavenderFilling) brush.setColor(QColor(230, 230, 250));
- else if (_filling == HTMLPurpleThistleFilling) brush.setColor(QColor(216, 191, 216));
- else if (_filling == HTMLPurplePlumFilling) brush.setColor(QColor(221, 160, 221));
- else if (_filling == HTMLPurpleVioletFilling) brush.setColor(QColor(238, 130, 238));
- else if (_filling == HTMLPurpleOrchidFilling) brush.setColor(QColor(218, 112, 214));
- else if (_filling == HTMLPurpleFuchsiaFilling) brush.setColor(QColor(255, 0, 255));
- else if (_filling == HTMLPurpleMagentaFilling) brush.setColor(QColor(255, 0, 255));
- else if (_filling == HTMLPurpleMediumOrchidFilling) brush.setColor(QColor(186, 85, 211));
- else if (_filling == HTMLPurpleMediumPurpleFilling) brush.setColor(QColor(147, 112, 219));
- else if (_filling == HTMLPurpleBlueVioletFilling) brush.setColor(QColor(138, 43, 226));
- else if (_filling == HTMLPurpleDarkVioletFilling) brush.setColor(QColor(148, 0, 211));
- else if (_filling == HTMLPurpleDarkOrchidFilling) brush.setColor(QColor(153, 50, 204));
- else if (_filling == HTMLPurpleDarkMagentaFilling) brush.setColor(QColor(139, 0, 139));
- else if (_filling == HTMLPurplePurpleFilling) brush.setColor(QColor(128, 0, 128));
- else if (_filling == HTMLPurpleIndigoFilling) brush.setColor(QColor(75, 0, 130));
- else if (_filling == HTMLPurpleDarkSlateBlueFilling) brush.setColor(QColor(72, 61, 139));
- else if (_filling == HTMLPurpleSlateBlueFilling) brush.setColor(QColor(106, 90, 205));
- else if (_filling == HTMLPurpleMediumSlateBlueFilling) brush.setColor(QColor(123, 104, 238));
- else if (_filling == HTMLWhiteWhiteFilling) brush.setColor(QColor(255, 255, 255));
- else if (_filling == HTMLWhiteSnowFilling) brush.setColor(QColor(255, 250, 250));
- else if (_filling == HTMLWhiteHoneydewFilling) brush.setColor(QColor(240, 255, 240));
- else if (_filling == HTMLWhiteMintCreamFilling) brush.setColor(QColor(245, 255, 250));
- else if (_filling == HTMLWhiteAzureFilling) brush.setColor(QColor(240, 255, 255));
- else if (_filling == HTMLWhiteAliceBlueFilling) brush.setColor(QColor(240, 248, 255));
- else if (_filling == HTMLWhiteGhostWhiteFilling) brush.setColor(QColor(248, 248, 255));
- else if (_filling == HTMLWhiteWhiteSmokeFilling) brush.setColor(QColor(245, 245, 245));
- else if (_filling == HTMLWhiteSeashellFilling) brush.setColor(QColor(255, 245, 238));
- else if (_filling == HTMLWhiteBeigeFilling) brush.setColor(QColor(245, 245, 220));
- else if (_filling == HTMLWhiteOldLaceFilling) brush.setColor(QColor(253, 245, 230));
- else if (_filling == HTMLWhiteFloralWhiteFilling) brush.setColor(QColor(255, 250, 240));
- else if (_filling == HTMLWhiteIvoryFilling) brush.setColor(QColor(255, 255, 240));
- else if (_filling == HTMLWhiteAntiqueWhiteFilling) brush.setColor(QColor(250, 235, 215));
- else if (_filling == HTMLWhiteLinenFilling) brush.setColor(QColor(250, 240, 230));
- else if (_filling == HTMLWhiteLavenderBlushFilling) brush.setColor(QColor(255, 240, 245));
- else if (_filling == HTMLWhiteMistyRoseFilling) brush.setColor(QColor(255, 228, 225));
- else if (_filling == HTMLGrayGainsboroFilling) brush.setColor(QColor(220, 220, 220));
- else if (_filling == HTMLGrayLightGrayFilling) brush.setColor(QColor(211, 211, 211));
- else if (_filling == HTMLGraySilverFilling) brush.setColor(QColor(192, 192, 192));
- else if (_filling == HTMLGrayDarkGrayFilling) brush.setColor(QColor(169, 169, 169));
- else if (_filling == HTMLGrayGrayFilling) brush.setColor(QColor(128, 128, 128));
- else if (_filling == HTMLGrayDimGrayFilling) brush.setColor(QColor(105, 105, 105));
- else if (_filling == HTMLGrayLightSlateGrayFilling) brush.setColor(QColor(119, 136, 153));
- else if (_filling == HTMLGraySlateGrayFilling) brush.setColor(QColor(112, 128, 144));
- else if (_filling == HTMLGrayDarkSlateGrayFilling) brush.setColor(QColor(47, 79, 79));
- else if (_filling == HTMLGrayBlackFilling) brush.setColor(QColor(0, 0, 0));
- }
+ //Apply brush color
+ if (_filling == NoneFilling) brush.setStyle(Qt::NoBrush);
+ else if (_filling == HorFilling) brush.setStyle(Qt::HorPattern);
+ else if (_filling == VerFilling) brush.setStyle(Qt::VerPattern);
+ else if (_filling == BdiagFilling) brush.setStyle(Qt::BDiagPattern);
+ else if (_filling == FdiagFilling) brush.setStyle(Qt::FDiagPattern);
+ else
+ {
+ brush.setStyle(Qt::SolidPattern);
+ if (_filling == BlackFilling) brush.setColor(Qt::black);
+ else if (_filling == WhiteFilling) brush.setColor(Qt::white);
+ else if (_filling == GreenFilling) brush.setColor(Qt::green);
+ else if (_filling == RedFilling) brush.setColor(Qt::red);
+ else if (_filling == BlueFilling) brush.setColor(Qt::blue);
+ else if (_filling == GrayFilling) brush.setColor(Qt::gray);
+ else if (_filling == BrunFilling) brush.setColor(QColor(97, 44, 0));
+ else if (_filling == YellowFilling) brush.setColor(Qt::yellow);
+ else if (_filling == CyanFilling) brush.setColor(Qt::cyan);
+ else if (_filling == MagentaFilling) brush.setColor(Qt::magenta);
+ else if (_filling == LightgrayFilling) brush.setColor(Qt::lightGray);
+ else if (_filling == OrangeFilling) brush.setColor(QColor(255, 128, 0));
+ else if (_filling == PurpleFilling) brush.setColor(QColor(136, 28, 168));
+ else if (_filling == HTMLPinkPinkFilling) brush.setColor(QColor(255, 192, 203));
+ else if (_filling == HTMLPinkLightPinkFilling) brush.setColor(QColor(255, 182, 193));
+ else if (_filling == HTMLPinkHotPinkFilling) brush.setColor(QColor(255, 105, 180));
+ else if (_filling == HTMLPinkDeepPinkFilling) brush.setColor(QColor(255, 20, 147));
+ else if (_filling == HTMLPinkPaleVioletRedFilling) brush.setColor(QColor(219, 112, 147));
+ else if (_filling == HTMLPinkMediumVioletRedFilling) brush.setColor(QColor(199, 21, 133));
+ else if (_filling == HTMLRedLightSalmonFilling) brush.setColor(QColor(255, 160, 122));
+ else if (_filling == HTMLRedSalmonFilling) brush.setColor(QColor(250, 128, 114));
+ else if (_filling == HTMLRedDarkSalmonFilling) brush.setColor(QColor(233, 150, 122));
+ else if (_filling == HTMLRedLightCoralFilling) brush.setColor(QColor(240, 128, 128));
+ else if (_filling == HTMLRedIndianRedFilling) brush.setColor(QColor(205, 92, 92));
+ else if (_filling == HTMLRedCrimsonFilling) brush.setColor(QColor(220, 20, 60));
+ else if (_filling == HTMLRedFirebrickFilling) brush.setColor(QColor(178, 34, 34));
+ else if (_filling == HTMLRedDarkRedFilling) brush.setColor(QColor(139, 0, 0));
+ else if (_filling == HTMLRedRedFilling) brush.setColor(QColor(255, 0, 0));
+ else if (_filling == HTMLOrangeOrangeRedFilling) brush.setColor(QColor(255, 69, 0));
+ else if (_filling == HTMLOrangeTomatoFilling) brush.setColor(QColor(255, 99, 71));
+ else if (_filling == HTMLOrangeCoralFilling) brush.setColor(QColor(255, 127, 80));
+ else if (_filling == HTMLOrangeDarkOrangeFilling) brush.setColor(QColor(255, 140, 0));
+ else if (_filling == HTMLOrangeOrangeFilling) brush.setColor(QColor(255, 165, 0));
+ else if (_filling == HTMLYellowYellowFilling) brush.setColor(QColor(255, 255, 0));
+ else if (_filling == HTMLYellowLightYellowFilling) brush.setColor(QColor(255, 255, 224));
+ else if (_filling == HTMLYellowLemonChiffonFilling) brush.setColor(QColor(255, 250, 205));
+ else if (_filling == HTMLYellowLightGoldenrodYellowFilling) brush.setColor(QColor(250, 250, 210));
+ else if (_filling == HTMLYellowPapayaWhipFilling) brush.setColor(QColor(255, 239, 213));
+ else if (_filling == HTMLYellowMoccasinFilling) brush.setColor(QColor(255, 228, 181));
+ else if (_filling == HTMLYellowPeachPuffFilling) brush.setColor(QColor(255, 218, 185));
+ else if (_filling == HTMLYellowPaleGoldenrodFilling) brush.setColor(QColor(238, 232, 170));
+ else if (_filling == HTMLYellowKhakiFilling) brush.setColor(QColor(240, 230, 140));
+ else if (_filling == HTMLYellowDarkKhakiFilling) brush.setColor(QColor(189, 183, 107));
+ else if (_filling == HTMLYellowGoldFilling) brush.setColor(QColor(255, 215, 0));
+ else if (_filling == HTMLBrownCornsilkFilling) brush.setColor(QColor(255, 248, 220));
+ else if (_filling == HTMLBrownBlanchedAlmondFilling) brush.setColor(QColor(255, 235, 205));
+ else if (_filling == HTMLBrownBisqueFilling) brush.setColor(QColor(255, 228, 196));
+ else if (_filling == HTMLBrownNavajoWhiteFilling) brush.setColor(QColor(255, 222, 173));
+ else if (_filling == HTMLBrownWheatFilling) brush.setColor(QColor(245, 222, 179));
+ else if (_filling == HTMLBrownBurlywoodFilling) brush.setColor(QColor(222, 184, 135));
+ else if (_filling == HTMLBrownTanFilling) brush.setColor(QColor(210, 180, 140));
+ else if (_filling == HTMLBrownRosyBrownFilling) brush.setColor(QColor(188, 143, 143));
+ else if (_filling == HTMLBrownSandyBrownFilling) brush.setColor(QColor(244, 164, 96));
+ else if (_filling == HTMLBrownGoldenrodFilling) brush.setColor(QColor(218, 165, 32));
+ else if (_filling == HTMLBrownDarkGoldenrodFilling) brush.setColor(QColor(184, 134, 11));
+ else if (_filling == HTMLBrownPeruFilling) brush.setColor(QColor(205, 133, 63));
+ else if (_filling == HTMLBrownChocolateFilling) brush.setColor(QColor(210, 105, 30));
+ else if (_filling == HTMLBrownSaddleBrownFilling) brush.setColor(QColor(139, 69, 19));
+ else if (_filling == HTMLBrownSiennaFilling) brush.setColor(QColor(160, 82, 45));
+ else if (_filling == HTMLBrownBrownFilling) brush.setColor(QColor(165, 42, 42));
+ else if (_filling == HTMLBrownMaroonFilling) brush.setColor(QColor(128, 0, 0));
+ else if (_filling == HTMLGreenDarkOliveGreenFilling) brush.setColor(QColor(85, 107, 47));
+ else if (_filling == HTMLGreenOliveFilling) brush.setColor(QColor(128, 128, 0));
+ else if (_filling == HTMLGreenOliveDrabFilling) brush.setColor(QColor(107, 142, 35));
+ else if (_filling == HTMLGreenYellowGreenFilling) brush.setColor(QColor(154, 205, 50));
+ else if (_filling == HTMLGreenLimeGreenFilling) brush.setColor(QColor(50, 205, 50));
+ else if (_filling == HTMLGreenLimeFilling) brush.setColor(QColor(0, 255, 0));
+ else if (_filling == HTMLGreenLawnGreenFilling) brush.setColor(QColor(124, 252, 0));
+ else if (_filling == HTMLGreenChartreuseFilling) brush.setColor(QColor(127, 255, 0));
+ else if (_filling == HTMLGreenGreenYellowFilling) brush.setColor(QColor(173, 255, 47));
+ else if (_filling == HTMLGreenSpringGreenFilling) brush.setColor(QColor(0, 255, 127));
+ else if (_filling == HTMLGreenMediumSpringGreenFilling) brush.setColor(QColor(0, 250, 154));
+ else if (_filling == HTMLGreenLightGreenFilling) brush.setColor(QColor(144, 238, 144));
+ else if (_filling == HTMLGreenPaleGreenFilling) brush.setColor(QColor(152, 251, 152));
+ else if (_filling == HTMLGreenDarkSeaGreenFilling) brush.setColor(QColor(143, 188, 143));
+ else if (_filling == HTMLGreenMediumAquamarineFilling) brush.setColor(QColor(102, 205, 170));
+ else if (_filling == HTMLGreenMediumSeaGreenFilling) brush.setColor(QColor(60, 179, 113));
+ else if (_filling == HTMLGreenSeaGreenFilling) brush.setColor(QColor(46, 139, 87));
+ else if (_filling == HTMLGreenForestGreenFilling) brush.setColor(QColor(34, 139, 34));
+ else if (_filling == HTMLGreenGreenFilling) brush.setColor(QColor(0, 128, 0));
+ else if (_filling == HTMLGreenDarkGreenFilling) brush.setColor(QColor(0, 100, 0));
+ else if (_filling == HTMLCyanAquaFilling) brush.setColor(QColor(0, 255, 255));
+ else if (_filling == HTMLCyanCyanFilling) brush.setColor(QColor(0, 255, 255));
+ else if (_filling == HTMLCyanLightCyanFilling) brush.setColor(QColor(224, 255, 255));
+ else if (_filling == HTMLCyanPaleTurquoiseFilling) brush.setColor(QColor(175, 238, 238));
+ else if (_filling == HTMLCyanAquamarineFilling) brush.setColor(QColor(127, 255, 212));
+ else if (_filling == HTMLCyanTurquoiseFilling) brush.setColor(QColor(64, 224, 208));
+ else if (_filling == HTMLCyanMediumTurquoiseFilling) brush.setColor(QColor(72, 209, 204));
+ else if (_filling == HTMLCyanDarkTurquoiseFilling) brush.setColor(QColor(0, 206, 209));
+ else if (_filling == HTMLCyanLightSeaGreenFilling) brush.setColor(QColor(32, 178, 170));
+ else if (_filling == HTMLCyanCadetBlueFilling) brush.setColor(QColor(95, 158, 160));
+ else if (_filling == HTMLCyanDarkCyanFilling) brush.setColor(QColor(0, 139, 139));
+ else if (_filling == HTMLCyanTealFilling) brush.setColor(QColor(0, 128, 128));
+ else if (_filling == HTMLBlueLightSteelBlueFilling) brush.setColor(QColor(176, 196, 222));
+ else if (_filling == HTMLBluePowderBlueFilling) brush.setColor(QColor(176, 224, 230));
+ else if (_filling == HTMLBlueLightBlueFilling) brush.setColor(QColor(173, 216, 230));
+ else if (_filling == HTMLBlueSkyBlueFilling) brush.setColor(QColor(135, 206, 235));
+ else if (_filling == HTMLBlueLightSkyBlueFilling) brush.setColor(QColor(135, 206, 250));
+ else if (_filling == HTMLBlueDeepSkyBlueFilling) brush.setColor(QColor(0, 191, 255));
+ else if (_filling == HTMLBlueDodgerBlueFilling) brush.setColor(QColor(30, 144, 255));
+ else if (_filling == HTMLBlueCornflowerBlueFilling) brush.setColor(QColor(100, 149, 237));
+ else if (_filling == HTMLBlueSteelBlueFilling) brush.setColor(QColor(70, 130, 180));
+ else if (_filling == HTMLBlueRoyalBlueFilling) brush.setColor(QColor(65, 105, 225));
+ else if (_filling == HTMLBlueBlueFilling) brush.setColor(QColor(0, 0, 255));
+ else if (_filling == HTMLBlueMediumBlueFilling) brush.setColor(QColor(0, 0, 205));
+ else if (_filling == HTMLBlueDarkBlueFilling) brush.setColor(QColor(0, 0, 139));
+ else if (_filling == HTMLBlueNavyFilling) brush.setColor(QColor(0, 0, 128));
+ else if (_filling == HTMLBlueMidnightBlueFilling) brush.setColor(QColor(25, 25, 112));
+ else if (_filling == HTMLPurpleLavenderFilling) brush.setColor(QColor(230, 230, 250));
+ else if (_filling == HTMLPurpleThistleFilling) brush.setColor(QColor(216, 191, 216));
+ else if (_filling == HTMLPurplePlumFilling) brush.setColor(QColor(221, 160, 221));
+ else if (_filling == HTMLPurpleVioletFilling) brush.setColor(QColor(238, 130, 238));
+ else if (_filling == HTMLPurpleOrchidFilling) brush.setColor(QColor(218, 112, 214));
+ else if (_filling == HTMLPurpleFuchsiaFilling) brush.setColor(QColor(255, 0, 255));
+ else if (_filling == HTMLPurpleMagentaFilling) brush.setColor(QColor(255, 0, 255));
+ else if (_filling == HTMLPurpleMediumOrchidFilling) brush.setColor(QColor(186, 85, 211));
+ else if (_filling == HTMLPurpleMediumPurpleFilling) brush.setColor(QColor(147, 112, 219));
+ else if (_filling == HTMLPurpleBlueVioletFilling) brush.setColor(QColor(138, 43, 226));
+ else if (_filling == HTMLPurpleDarkVioletFilling) brush.setColor(QColor(148, 0, 211));
+ else if (_filling == HTMLPurpleDarkOrchidFilling) brush.setColor(QColor(153, 50, 204));
+ else if (_filling == HTMLPurpleDarkMagentaFilling) brush.setColor(QColor(139, 0, 139));
+ else if (_filling == HTMLPurplePurpleFilling) brush.setColor(QColor(128, 0, 128));
+ else if (_filling == HTMLPurpleIndigoFilling) brush.setColor(QColor(75, 0, 130));
+ else if (_filling == HTMLPurpleDarkSlateBlueFilling) brush.setColor(QColor(72, 61, 139));
+ else if (_filling == HTMLPurpleSlateBlueFilling) brush.setColor(QColor(106, 90, 205));
+ else if (_filling == HTMLPurpleMediumSlateBlueFilling) brush.setColor(QColor(123, 104, 238));
+ else if (_filling == HTMLWhiteWhiteFilling) brush.setColor(QColor(255, 255, 255));
+ else if (_filling == HTMLWhiteSnowFilling) brush.setColor(QColor(255, 250, 250));
+ else if (_filling == HTMLWhiteHoneydewFilling) brush.setColor(QColor(240, 255, 240));
+ else if (_filling == HTMLWhiteMintCreamFilling) brush.setColor(QColor(245, 255, 250));
+ else if (_filling == HTMLWhiteAzureFilling) brush.setColor(QColor(240, 255, 255));
+ else if (_filling == HTMLWhiteAliceBlueFilling) brush.setColor(QColor(240, 248, 255));
+ else if (_filling == HTMLWhiteGhostWhiteFilling) brush.setColor(QColor(248, 248, 255));
+ else if (_filling == HTMLWhiteWhiteSmokeFilling) brush.setColor(QColor(245, 245, 245));
+ else if (_filling == HTMLWhiteSeashellFilling) brush.setColor(QColor(255, 245, 238));
+ else if (_filling == HTMLWhiteBeigeFilling) brush.setColor(QColor(245, 245, 220));
+ else if (_filling == HTMLWhiteOldLaceFilling) brush.setColor(QColor(253, 245, 230));
+ else if (_filling == HTMLWhiteFloralWhiteFilling) brush.setColor(QColor(255, 250, 240));
+ else if (_filling == HTMLWhiteIvoryFilling) brush.setColor(QColor(255, 255, 240));
+ else if (_filling == HTMLWhiteAntiqueWhiteFilling) brush.setColor(QColor(250, 235, 215));
+ else if (_filling == HTMLWhiteLinenFilling) brush.setColor(QColor(250, 240, 230));
+ else if (_filling == HTMLWhiteLavenderBlushFilling) brush.setColor(QColor(255, 240, 245));
+ else if (_filling == HTMLWhiteMistyRoseFilling) brush.setColor(QColor(255, 228, 225));
+ else if (_filling == HTMLGrayGainsboroFilling) brush.setColor(QColor(220, 220, 220));
+ else if (_filling == HTMLGrayLightGrayFilling) brush.setColor(QColor(211, 211, 211));
+ else if (_filling == HTMLGraySilverFilling) brush.setColor(QColor(192, 192, 192));
+ else if (_filling == HTMLGrayDarkGrayFilling) brush.setColor(QColor(169, 169, 169));
+ else if (_filling == HTMLGrayGrayFilling) brush.setColor(QColor(128, 128, 128));
+ else if (_filling == HTMLGrayDimGrayFilling) brush.setColor(QColor(105, 105, 105));
+ else if (_filling == HTMLGrayLightSlateGrayFilling) brush.setColor(QColor(119, 136, 153));
+ else if (_filling == HTMLGraySlateGrayFilling) brush.setColor(QColor(112, 128, 144));
+ else if (_filling == HTMLGrayDarkSlateGrayFilling) brush.setColor(QColor(47, 79, 79));
+ else if (_filling == HTMLGrayBlackFilling) brush.setColor(QColor(0, 0, 0));
+ }
- //Apply pen color
- 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 == GreenColor) pen.setColor(QColor(Qt::green));
- else if (_color == RedColor) pen.setColor(QColor(Qt::red));
- else if (_color == BlueColor) pen.setColor(QColor(Qt::blue));
- else if (_color == GrayColor) pen.setColor(QColor(Qt::gray));
- else if (_color == BrunColor) pen.setColor(QColor(97, 44, 0));
- else if (_color == YellowColor) pen.setColor(QColor(Qt::yellow));
- else if (_color == CyanColor) pen.setColor(Qt::cyan);
- else if (_color == MagentaColor) pen.setColor(Qt::magenta);
- else if (_color == LightgrayColor) pen.setColor(Qt::lightGray);
- else if (_color == OrangeColor) pen.setColor(QColor(255, 128, 0));
- else if (_color == PurpleColor) pen.setColor(QColor(136, 28, 168));
- else if (_color == HTMLPinkPinkColor) pen.setColor(QColor(255, 192, 203));
- else if (_color == HTMLPinkLightPinkColor) pen.setColor(QColor(255, 182, 193));
- else if (_color == HTMLPinkHotPinkColor) pen.setColor(QColor(255, 105, 180));
- else if (_color == HTMLPinkDeepPinkColor) pen.setColor(QColor(255, 20, 147));
- else if (_color == HTMLPinkPaleVioletRedColor) pen.setColor(QColor(219, 112, 147));
- else if (_color == HTMLPinkMediumVioletRedColor) pen.setColor(QColor(199, 21, 133));
- else if (_color == HTMLRedLightSalmonColor) pen.setColor(QColor(255, 160, 122));
- else if (_color == HTMLRedSalmonColor) pen.setColor(QColor(250, 128, 114));
- else if (_color == HTMLRedDarkSalmonColor) pen.setColor(QColor(233, 150, 122));
- else if (_color == HTMLRedLightCoralColor) pen.setColor(QColor(240, 128, 128));
- else if (_color == HTMLRedIndianRedColor) pen.setColor(QColor(205, 92, 92));
- else if (_color == HTMLRedCrimsonColor) pen.setColor(QColor(220, 20, 60));
- else if (_color == HTMLRedFirebrickColor) pen.setColor(QColor(178, 34, 34));
- else if (_color == HTMLRedDarkRedColor) pen.setColor(QColor(139, 0, 0));
- else if (_color == HTMLRedRedColor) pen.setColor(QColor(255, 0, 0));
- else if (_color == HTMLOrangeOrangeRedColor) pen.setColor(QColor(255, 69, 0));
- else if (_color == HTMLOrangeTomatoColor) pen.setColor(QColor(255, 99, 71));
- else if (_color == HTMLOrangeCoralColor) pen.setColor(QColor(255, 127, 80));
- else if (_color == HTMLOrangeDarkOrangeColor) pen.setColor(QColor(255, 140, 0));
- else if (_color == HTMLOrangeOrangeColor) pen.setColor(QColor(255, 165, 0));
- else if (_color == HTMLYellowYellowColor) pen.setColor(QColor(255, 255, 0));
- else if (_color == HTMLYellowLightYellowColor) pen.setColor(QColor(255, 255, 224));
- else if (_color == HTMLYellowLemonChiffonColor) pen.setColor(QColor(255, 250, 205));
- else if (_color == HTMLYellowLightGoldenrodYellowColor) pen.setColor(QColor(250, 250, 210));
- else if (_color == HTMLYellowPapayaWhipColor) pen.setColor(QColor(255, 239, 213));
- else if (_color == HTMLYellowMoccasinColor) pen.setColor(QColor(255, 228, 181));
- else if (_color == HTMLYellowPeachPuffColor) pen.setColor(QColor(255, 218, 185));
- else if (_color == HTMLYellowPaleGoldenrodColor) pen.setColor(QColor(238, 232, 170));
- else if (_color == HTMLYellowKhakiColor) pen.setColor(QColor(240, 230, 140));
- else if (_color == HTMLYellowDarkKhakiColor) pen.setColor(QColor(189, 183, 107));
- else if (_color == HTMLYellowGoldColor) pen.setColor(QColor(255, 215, 0));
- else if (_color == HTMLBrownCornsilkColor) pen.setColor(QColor(255, 248, 220));
- else if (_color == HTMLBrownBlanchedAlmondColor) pen.setColor(QColor(255, 235, 205));
- else if (_color == HTMLBrownBisqueColor) pen.setColor(QColor(255, 228, 196));
- else if (_color == HTMLBrownNavajoWhiteColor) pen.setColor(QColor(255, 222, 173));
- else if (_color == HTMLBrownWheatColor) pen.setColor(QColor(245, 222, 179));
- else if (_color == HTMLBrownBurlywoodColor) pen.setColor(QColor(222, 184, 135));
- else if (_color == HTMLBrownTanColor) pen.setColor(QColor(210, 180, 140));
- else if (_color == HTMLBrownRosyBrownColor) pen.setColor(QColor(188, 143, 143));
- else if (_color == HTMLBrownSandyBrownColor) pen.setColor(QColor(244, 164, 96));
- else if (_color == HTMLBrownGoldenrodColor) pen.setColor(QColor(218, 165, 32));
- else if (_color == HTMLBrownDarkGoldenrodColor) pen.setColor(QColor(184, 134, 11));
- else if (_color == HTMLBrownPeruColor) pen.setColor(QColor(205, 133, 63));
- else if (_color == HTMLBrownChocolateColor) pen.setColor(QColor(210, 105, 30));
- else if (_color == HTMLBrownSaddleBrownColor) pen.setColor(QColor(139, 69, 19));
- else if (_color == HTMLBrownSiennaColor) pen.setColor(QColor(160, 82, 45));
- else if (_color == HTMLBrownBrownColor) pen.setColor(QColor(165, 42, 42));
- else if (_color == HTMLBrownMaroonColor) pen.setColor(QColor(128, 0, 0));
- else if (_color == HTMLGreenDarkOliveGreenColor) pen.setColor(QColor(85, 107, 47));
- else if (_color == HTMLGreenOliveColor) pen.setColor(QColor(128, 128, 0));
- else if (_color == HTMLGreenOliveDrabColor) pen.setColor(QColor(107, 142, 35));
- else if (_color == HTMLGreenYellowGreenColor) pen.setColor(QColor(154, 205, 50));
- else if (_color == HTMLGreenLimeGreenColor) pen.setColor(QColor(50, 205, 50));
- else if (_color == HTMLGreenLimeColor) pen.setColor(QColor(0, 255, 0));
- else if (_color == HTMLGreenLawnGreenColor) pen.setColor(QColor(124, 252, 0));
- else if (_color == HTMLGreenChartreuseColor) pen.setColor(QColor(127, 255, 0));
- else if (_color == HTMLGreenGreenYellowColor) pen.setColor(QColor(173, 255, 47));
- else if (_color == HTMLGreenSpringGreenColor) pen.setColor(QColor(0, 255, 127));
- else if (_color == HTMLGreenMediumSpringGreenColor) pen.setColor(QColor(0, 250, 154));
- else if (_color == HTMLGreenLightGreenColor) pen.setColor(QColor(144, 238, 144));
- else if (_color == HTMLGreenPaleGreenColor) pen.setColor(QColor(152, 251, 152));
- else if (_color == HTMLGreenDarkSeaGreenColor) pen.setColor(QColor(143, 188, 143));
- else if (_color == HTMLGreenMediumAquamarineColor) pen.setColor(QColor(102, 205, 170));
- else if (_color == HTMLGreenMediumSeaGreenColor) pen.setColor(QColor(60, 179, 113));
- else if (_color == HTMLGreenSeaGreenColor) pen.setColor(QColor(46, 139, 87));
- else if (_color == HTMLGreenForestGreenColor) pen.setColor(QColor(34, 139, 34));
- else if (_color == HTMLGreenGreenColor) pen.setColor(QColor(0, 128, 0));
- else if (_color == HTMLGreenDarkGreenColor) pen.setColor(QColor(0, 100, 0));
- else if (_color == HTMLCyanAquaColor) pen.setColor(QColor(0, 255, 255));
- else if (_color == HTMLCyanCyanColor) pen.setColor(QColor(0, 255, 255));
- else if (_color == HTMLCyanLightCyanColor) pen.setColor(QColor(224, 255, 255));
- else if (_color == HTMLCyanPaleTurquoiseColor) pen.setColor(QColor(175, 238, 238));
- else if (_color == HTMLCyanAquamarineColor) pen.setColor(QColor(127, 255, 212));
- else if (_color == HTMLCyanTurquoiseColor) pen.setColor(QColor(64, 224, 208));
- else if (_color == HTMLCyanMediumTurquoiseColor) pen.setColor(QColor(72, 209, 204));
- else if (_color == HTMLCyanDarkTurquoiseColor) pen.setColor(QColor(0, 206, 209));
- else if (_color == HTMLCyanLightSeaGreenColor) pen.setColor(QColor(32, 178, 170));
- else if (_color == HTMLCyanCadetBlueColor) pen.setColor(QColor(95, 158, 160));
- else if (_color == HTMLCyanDarkCyanColor) pen.setColor(QColor(0, 139, 139));
- else if (_color == HTMLCyanTealColor) pen.setColor(QColor(0, 128, 128));
- else if (_color == HTMLBlueLightSteelBlueColor) pen.setColor(QColor(176, 196, 222));
- else if (_color == HTMLBluePowderBlueColor) pen.setColor(QColor(176, 224, 230));
- else if (_color == HTMLBlueLightBlueColor) pen.setColor(QColor(173, 216, 230));
- else if (_color == HTMLBlueSkyBlueColor) pen.setColor(QColor(135, 206, 235));
- else if (_color == HTMLBlueLightSkyBlueColor) pen.setColor(QColor(135, 206, 250));
- else if (_color == HTMLBlueDeepSkyBlueColor) pen.setColor(QColor(0, 191, 255));
- else if (_color == HTMLBlueDodgerBlueColor) pen.setColor(QColor(30, 144, 255));
- else if (_color == HTMLBlueCornflowerBlueColor) pen.setColor(QColor(100, 149, 237));
- else if (_color == HTMLBlueSteelBlueColor) pen.setColor(QColor(70, 130, 180));
- else if (_color == HTMLBlueRoyalBlueColor) pen.setColor(QColor(65, 105, 225));
- else if (_color == HTMLBlueBlueColor) pen.setColor(QColor(0, 0, 255));
- else if (_color == HTMLBlueMediumBlueColor) pen.setColor(QColor(0, 0, 205));
- else if (_color == HTMLBlueDarkBlueColor) pen.setColor(QColor(0, 0, 139));
- else if (_color == HTMLBlueNavyColor) pen.setColor(QColor(0, 0, 128));
- else if (_color == HTMLBlueMidnightBlueColor) pen.setColor(QColor(25, 25, 112));
- else if (_color == HTMLPurpleLavenderColor) pen.setColor(QColor(230, 230, 250));
- else if (_color == HTMLPurpleThistleColor) pen.setColor(QColor(216, 191, 216));
- else if (_color == HTMLPurplePlumColor) pen.setColor(QColor(221, 160, 221));
- else if (_color == HTMLPurpleVioletColor) pen.setColor(QColor(238, 130, 238));
- else if (_color == HTMLPurpleOrchidColor) pen.setColor(QColor(218, 112, 214));
- else if (_color == HTMLPurpleFuchsiaColor) pen.setColor(QColor(255, 0, 255));
- else if (_color == HTMLPurpleMagentaColor) pen.setColor(QColor(255, 0, 255));
- else if (_color == HTMLPurpleMediumOrchidColor) pen.setColor(QColor(186, 85, 211));
- else if (_color == HTMLPurpleMediumPurpleColor) pen.setColor(QColor(147, 112, 219));
- else if (_color == HTMLPurpleBlueVioletColor) pen.setColor(QColor(138, 43, 226));
- else if (_color == HTMLPurpleDarkVioletColor) pen.setColor(QColor(148, 0, 211));
- else if (_color == HTMLPurpleDarkOrchidColor) pen.setColor(QColor(153, 50, 204));
- else if (_color == HTMLPurpleDarkMagentaColor) pen.setColor(QColor(139, 0, 139));
- else if (_color == HTMLPurplePurpleColor) pen.setColor(QColor(128, 0, 128));
- else if (_color == HTMLPurpleIndigoColor) pen.setColor(QColor(75, 0, 130));
- else if (_color == HTMLPurpleDarkSlateBlueColor) pen.setColor(QColor(72, 61, 139));
- else if (_color == HTMLPurpleSlateBlueColor) pen.setColor(QColor(106, 90, 205));
- else if (_color == HTMLPurpleMediumSlateBlueColor) pen.setColor(QColor(123, 104, 238));
- else if (_color == HTMLWhiteWhiteColor) pen.setColor(QColor(255, 255, 255));
- else if (_color == HTMLWhiteSnowColor) pen.setColor(QColor(255, 250, 250));
- else if (_color == HTMLWhiteHoneydewColor) pen.setColor(QColor(240, 255, 240));
- else if (_color == HTMLWhiteMintCreamColor) pen.setColor(QColor(245, 255, 250));
- else if (_color == HTMLWhiteAzureColor) pen.setColor(QColor(240, 255, 255));
- else if (_color == HTMLWhiteAliceBlueColor) pen.setColor(QColor(240, 248, 255));
- else if (_color == HTMLWhiteGhostWhiteColor) pen.setColor(QColor(248, 248, 255));
- else if (_color == HTMLWhiteWhiteSmokeColor) pen.setColor(QColor(245, 245, 245));
- else if (_color == HTMLWhiteSeashellColor) pen.setColor(QColor(255, 245, 238));
- else if (_color == HTMLWhiteBeigeColor) pen.setColor(QColor(245, 245, 220));
- else if (_color == HTMLWhiteOldLaceColor) pen.setColor(QColor(253, 245, 230));
- else if (_color == HTMLWhiteFloralWhiteColor) pen.setColor(QColor(255, 250, 240));
- else if (_color == HTMLWhiteIvoryColor) pen.setColor(QColor(255, 255, 240));
- else if (_color == HTMLWhiteAntiqueWhiteColor) pen.setColor(QColor(250, 235, 215));
- else if (_color == HTMLWhiteLinenColor) pen.setColor(QColor(250, 240, 230));
- else if (_color == HTMLWhiteLavenderBlushColor) pen.setColor(QColor(255, 240, 245));
- else if (_color == HTMLWhiteMistyRoseColor) pen.setColor(QColor(255, 228, 225));
- else if (_color == HTMLGrayGainsboroColor) pen.setColor(QColor(220, 220, 220));
- else if (_color == HTMLGrayLightGrayColor) pen.setColor(QColor(211, 211, 211));
- else if (_color == HTMLGraySilverColor) pen.setColor(QColor(192, 192, 192));
- else if (_color == HTMLGrayDarkGrayColor) pen.setColor(QColor(169, 169, 169));
- else if (_color == HTMLGrayGrayColor) pen.setColor(QColor(128, 128, 128));
- else if (_color == HTMLGrayDimGrayColor) pen.setColor(QColor(105, 105, 105));
- else if (_color == HTMLGrayLightSlateGrayColor) pen.setColor(QColor(119, 136, 153));
- else if (_color == HTMLGraySlateGrayColor) pen.setColor(QColor(112, 128, 144));
- else if (_color == HTMLGrayDarkSlateGrayColor) pen.setColor(QColor(47, 79, 79));
- else if (_color == HTMLGrayBlackColor) pen.setColor(QColor(0, 0, 0));
- else if (_color == NoneColor) pen.setBrush(Qt::transparent);
+ //Apply pen color
+ 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 == GreenColor) pen.setColor(QColor(Qt::green));
+ else if (_color == RedColor) pen.setColor(QColor(Qt::red));
+ else if (_color == BlueColor) pen.setColor(QColor(Qt::blue));
+ else if (_color == GrayColor) pen.setColor(QColor(Qt::gray));
+ else if (_color == BrunColor) pen.setColor(QColor(97, 44, 0));
+ else if (_color == YellowColor) pen.setColor(QColor(Qt::yellow));
+ else if (_color == CyanColor) pen.setColor(Qt::cyan);
+ else if (_color == MagentaColor) pen.setColor(Qt::magenta);
+ else if (_color == LightgrayColor) pen.setColor(Qt::lightGray);
+ else if (_color == OrangeColor) pen.setColor(QColor(255, 128, 0));
+ else if (_color == PurpleColor) pen.setColor(QColor(136, 28, 168));
+ else if (_color == HTMLPinkPinkColor) pen.setColor(QColor(255, 192, 203));
+ else if (_color == HTMLPinkLightPinkColor) pen.setColor(QColor(255, 182, 193));
+ else if (_color == HTMLPinkHotPinkColor) pen.setColor(QColor(255, 105, 180));
+ else if (_color == HTMLPinkDeepPinkColor) pen.setColor(QColor(255, 20, 147));
+ else if (_color == HTMLPinkPaleVioletRedColor) pen.setColor(QColor(219, 112, 147));
+ else if (_color == HTMLPinkMediumVioletRedColor) pen.setColor(QColor(199, 21, 133));
+ else if (_color == HTMLRedLightSalmonColor) pen.setColor(QColor(255, 160, 122));
+ else if (_color == HTMLRedSalmonColor) pen.setColor(QColor(250, 128, 114));
+ else if (_color == HTMLRedDarkSalmonColor) pen.setColor(QColor(233, 150, 122));
+ else if (_color == HTMLRedLightCoralColor) pen.setColor(QColor(240, 128, 128));
+ else if (_color == HTMLRedIndianRedColor) pen.setColor(QColor(205, 92, 92));
+ else if (_color == HTMLRedCrimsonColor) pen.setColor(QColor(220, 20, 60));
+ else if (_color == HTMLRedFirebrickColor) pen.setColor(QColor(178, 34, 34));
+ else if (_color == HTMLRedDarkRedColor) pen.setColor(QColor(139, 0, 0));
+ else if (_color == HTMLRedRedColor) pen.setColor(QColor(255, 0, 0));
+ else if (_color == HTMLOrangeOrangeRedColor) pen.setColor(QColor(255, 69, 0));
+ else if (_color == HTMLOrangeTomatoColor) pen.setColor(QColor(255, 99, 71));
+ else if (_color == HTMLOrangeCoralColor) pen.setColor(QColor(255, 127, 80));
+ else if (_color == HTMLOrangeDarkOrangeColor) pen.setColor(QColor(255, 140, 0));
+ else if (_color == HTMLOrangeOrangeColor) pen.setColor(QColor(255, 165, 0));
+ else if (_color == HTMLYellowYellowColor) pen.setColor(QColor(255, 255, 0));
+ else if (_color == HTMLYellowLightYellowColor) pen.setColor(QColor(255, 255, 224));
+ else if (_color == HTMLYellowLemonChiffonColor) pen.setColor(QColor(255, 250, 205));
+ else if (_color == HTMLYellowLightGoldenrodYellowColor) pen.setColor(QColor(250, 250, 210));
+ else if (_color == HTMLYellowPapayaWhipColor) pen.setColor(QColor(255, 239, 213));
+ else if (_color == HTMLYellowMoccasinColor) pen.setColor(QColor(255, 228, 181));
+ else if (_color == HTMLYellowPeachPuffColor) pen.setColor(QColor(255, 218, 185));
+ else if (_color == HTMLYellowPaleGoldenrodColor) pen.setColor(QColor(238, 232, 170));
+ else if (_color == HTMLYellowKhakiColor) pen.setColor(QColor(240, 230, 140));
+ else if (_color == HTMLYellowDarkKhakiColor) pen.setColor(QColor(189, 183, 107));
+ else if (_color == HTMLYellowGoldColor) pen.setColor(QColor(255, 215, 0));
+ else if (_color == HTMLBrownCornsilkColor) pen.setColor(QColor(255, 248, 220));
+ else if (_color == HTMLBrownBlanchedAlmondColor) pen.setColor(QColor(255, 235, 205));
+ else if (_color == HTMLBrownBisqueColor) pen.setColor(QColor(255, 228, 196));
+ else if (_color == HTMLBrownNavajoWhiteColor) pen.setColor(QColor(255, 222, 173));
+ else if (_color == HTMLBrownWheatColor) pen.setColor(QColor(245, 222, 179));
+ else if (_color == HTMLBrownBurlywoodColor) pen.setColor(QColor(222, 184, 135));
+ else if (_color == HTMLBrownTanColor) pen.setColor(QColor(210, 180, 140));
+ else if (_color == HTMLBrownRosyBrownColor) pen.setColor(QColor(188, 143, 143));
+ else if (_color == HTMLBrownSandyBrownColor) pen.setColor(QColor(244, 164, 96));
+ else if (_color == HTMLBrownGoldenrodColor) pen.setColor(QColor(218, 165, 32));
+ else if (_color == HTMLBrownDarkGoldenrodColor) pen.setColor(QColor(184, 134, 11));
+ else if (_color == HTMLBrownPeruColor) pen.setColor(QColor(205, 133, 63));
+ else if (_color == HTMLBrownChocolateColor) pen.setColor(QColor(210, 105, 30));
+ else if (_color == HTMLBrownSaddleBrownColor) pen.setColor(QColor(139, 69, 19));
+ else if (_color == HTMLBrownSiennaColor) pen.setColor(QColor(160, 82, 45));
+ else if (_color == HTMLBrownBrownColor) pen.setColor(QColor(165, 42, 42));
+ else if (_color == HTMLBrownMaroonColor) pen.setColor(QColor(128, 0, 0));
+ else if (_color == HTMLGreenDarkOliveGreenColor) pen.setColor(QColor(85, 107, 47));
+ else if (_color == HTMLGreenOliveColor) pen.setColor(QColor(128, 128, 0));
+ else if (_color == HTMLGreenOliveDrabColor) pen.setColor(QColor(107, 142, 35));
+ else if (_color == HTMLGreenYellowGreenColor) pen.setColor(QColor(154, 205, 50));
+ else if (_color == HTMLGreenLimeGreenColor) pen.setColor(QColor(50, 205, 50));
+ else if (_color == HTMLGreenLimeColor) pen.setColor(QColor(0, 255, 0));
+ else if (_color == HTMLGreenLawnGreenColor) pen.setColor(QColor(124, 252, 0));
+ else if (_color == HTMLGreenChartreuseColor) pen.setColor(QColor(127, 255, 0));
+ else if (_color == HTMLGreenGreenYellowColor) pen.setColor(QColor(173, 255, 47));
+ else if (_color == HTMLGreenSpringGreenColor) pen.setColor(QColor(0, 255, 127));
+ else if (_color == HTMLGreenMediumSpringGreenColor) pen.setColor(QColor(0, 250, 154));
+ else if (_color == HTMLGreenLightGreenColor) pen.setColor(QColor(144, 238, 144));
+ else if (_color == HTMLGreenPaleGreenColor) pen.setColor(QColor(152, 251, 152));
+ else if (_color == HTMLGreenDarkSeaGreenColor) pen.setColor(QColor(143, 188, 143));
+ else if (_color == HTMLGreenMediumAquamarineColor) pen.setColor(QColor(102, 205, 170));
+ else if (_color == HTMLGreenMediumSeaGreenColor) pen.setColor(QColor(60, 179, 113));
+ else if (_color == HTMLGreenSeaGreenColor) pen.setColor(QColor(46, 139, 87));
+ else if (_color == HTMLGreenForestGreenColor) pen.setColor(QColor(34, 139, 34));
+ else if (_color == HTMLGreenGreenColor) pen.setColor(QColor(0, 128, 0));
+ else if (_color == HTMLGreenDarkGreenColor) pen.setColor(QColor(0, 100, 0));
+ else if (_color == HTMLCyanAquaColor) pen.setColor(QColor(0, 255, 255));
+ else if (_color == HTMLCyanCyanColor) pen.setColor(QColor(0, 255, 255));
+ else if (_color == HTMLCyanLightCyanColor) pen.setColor(QColor(224, 255, 255));
+ else if (_color == HTMLCyanPaleTurquoiseColor) pen.setColor(QColor(175, 238, 238));
+ else if (_color == HTMLCyanAquamarineColor) pen.setColor(QColor(127, 255, 212));
+ else if (_color == HTMLCyanTurquoiseColor) pen.setColor(QColor(64, 224, 208));
+ else if (_color == HTMLCyanMediumTurquoiseColor) pen.setColor(QColor(72, 209, 204));
+ else if (_color == HTMLCyanDarkTurquoiseColor) pen.setColor(QColor(0, 206, 209));
+ else if (_color == HTMLCyanLightSeaGreenColor) pen.setColor(QColor(32, 178, 170));
+ else if (_color == HTMLCyanCadetBlueColor) pen.setColor(QColor(95, 158, 160));
+ else if (_color == HTMLCyanDarkCyanColor) pen.setColor(QColor(0, 139, 139));
+ else if (_color == HTMLCyanTealColor) pen.setColor(QColor(0, 128, 128));
+ else if (_color == HTMLBlueLightSteelBlueColor) pen.setColor(QColor(176, 196, 222));
+ else if (_color == HTMLBluePowderBlueColor) pen.setColor(QColor(176, 224, 230));
+ else if (_color == HTMLBlueLightBlueColor) pen.setColor(QColor(173, 216, 230));
+ else if (_color == HTMLBlueSkyBlueColor) pen.setColor(QColor(135, 206, 235));
+ else if (_color == HTMLBlueLightSkyBlueColor) pen.setColor(QColor(135, 206, 250));
+ else if (_color == HTMLBlueDeepSkyBlueColor) pen.setColor(QColor(0, 191, 255));
+ else if (_color == HTMLBlueDodgerBlueColor) pen.setColor(QColor(30, 144, 255));
+ else if (_color == HTMLBlueCornflowerBlueColor) pen.setColor(QColor(100, 149, 237));
+ else if (_color == HTMLBlueSteelBlueColor) pen.setColor(QColor(70, 130, 180));
+ else if (_color == HTMLBlueRoyalBlueColor) pen.setColor(QColor(65, 105, 225));
+ else if (_color == HTMLBlueBlueColor) pen.setColor(QColor(0, 0, 255));
+ else if (_color == HTMLBlueMediumBlueColor) pen.setColor(QColor(0, 0, 205));
+ else if (_color == HTMLBlueDarkBlueColor) pen.setColor(QColor(0, 0, 139));
+ else if (_color == HTMLBlueNavyColor) pen.setColor(QColor(0, 0, 128));
+ else if (_color == HTMLBlueMidnightBlueColor) pen.setColor(QColor(25, 25, 112));
+ else if (_color == HTMLPurpleLavenderColor) pen.setColor(QColor(230, 230, 250));
+ else if (_color == HTMLPurpleThistleColor) pen.setColor(QColor(216, 191, 216));
+ else if (_color == HTMLPurplePlumColor) pen.setColor(QColor(221, 160, 221));
+ else if (_color == HTMLPurpleVioletColor) pen.setColor(QColor(238, 130, 238));
+ else if (_color == HTMLPurpleOrchidColor) pen.setColor(QColor(218, 112, 214));
+ else if (_color == HTMLPurpleFuchsiaColor) pen.setColor(QColor(255, 0, 255));
+ else if (_color == HTMLPurpleMagentaColor) pen.setColor(QColor(255, 0, 255));
+ else if (_color == HTMLPurpleMediumOrchidColor) pen.setColor(QColor(186, 85, 211));
+ else if (_color == HTMLPurpleMediumPurpleColor) pen.setColor(QColor(147, 112, 219));
+ else if (_color == HTMLPurpleBlueVioletColor) pen.setColor(QColor(138, 43, 226));
+ else if (_color == HTMLPurpleDarkVioletColor) pen.setColor(QColor(148, 0, 211));
+ else if (_color == HTMLPurpleDarkOrchidColor) pen.setColor(QColor(153, 50, 204));
+ else if (_color == HTMLPurpleDarkMagentaColor) pen.setColor(QColor(139, 0, 139));
+ else if (_color == HTMLPurplePurpleColor) pen.setColor(QColor(128, 0, 128));
+ else if (_color == HTMLPurpleIndigoColor) pen.setColor(QColor(75, 0, 130));
+ else if (_color == HTMLPurpleDarkSlateBlueColor) pen.setColor(QColor(72, 61, 139));
+ else if (_color == HTMLPurpleSlateBlueColor) pen.setColor(QColor(106, 90, 205));
+ else if (_color == HTMLPurpleMediumSlateBlueColor) pen.setColor(QColor(123, 104, 238));
+ else if (_color == HTMLWhiteWhiteColor) pen.setColor(QColor(255, 255, 255));
+ else if (_color == HTMLWhiteSnowColor) pen.setColor(QColor(255, 250, 250));
+ else if (_color == HTMLWhiteHoneydewColor) pen.setColor(QColor(240, 255, 240));
+ else if (_color == HTMLWhiteMintCreamColor) pen.setColor(QColor(245, 255, 250));
+ else if (_color == HTMLWhiteAzureColor) pen.setColor(QColor(240, 255, 255));
+ else if (_color == HTMLWhiteAliceBlueColor) pen.setColor(QColor(240, 248, 255));
+ else if (_color == HTMLWhiteGhostWhiteColor) pen.setColor(QColor(248, 248, 255));
+ else if (_color == HTMLWhiteWhiteSmokeColor) pen.setColor(QColor(245, 245, 245));
+ else if (_color == HTMLWhiteSeashellColor) pen.setColor(QColor(255, 245, 238));
+ else if (_color == HTMLWhiteBeigeColor) pen.setColor(QColor(245, 245, 220));
+ else if (_color == HTMLWhiteOldLaceColor) pen.setColor(QColor(253, 245, 230));
+ else if (_color == HTMLWhiteFloralWhiteColor) pen.setColor(QColor(255, 250, 240));
+ else if (_color == HTMLWhiteIvoryColor) pen.setColor(QColor(255, 255, 240));
+ else if (_color == HTMLWhiteAntiqueWhiteColor) pen.setColor(QColor(250, 235, 215));
+ else if (_color == HTMLWhiteLinenColor) pen.setColor(QColor(250, 240, 230));
+ else if (_color == HTMLWhiteLavenderBlushColor) pen.setColor(QColor(255, 240, 245));
+ else if (_color == HTMLWhiteMistyRoseColor) pen.setColor(QColor(255, 228, 225));
+ else if (_color == HTMLGrayGainsboroColor) pen.setColor(QColor(220, 220, 220));
+ else if (_color == HTMLGrayLightGrayColor) pen.setColor(QColor(211, 211, 211));
+ else if (_color == HTMLGraySilverColor) pen.setColor(QColor(192, 192, 192));
+ else if (_color == HTMLGrayDarkGrayColor) pen.setColor(QColor(169, 169, 169));
+ else if (_color == HTMLGrayGrayColor) pen.setColor(QColor(128, 128, 128));
+ else if (_color == HTMLGrayDimGrayColor) pen.setColor(QColor(105, 105, 105));
+ else if (_color == HTMLGrayLightSlateGrayColor) pen.setColor(QColor(119, 136, 153));
+ else if (_color == HTMLGraySlateGrayColor) pen.setColor(QColor(112, 128, 144));
+ else if (_color == HTMLGrayDarkSlateGrayColor) pen.setColor(QColor(47, 79, 79));
+ else if (_color == HTMLGrayBlackColor) pen.setColor(QColor(0, 0, 0));
+ else if (_color == NoneColor) pen.setBrush(Qt::transparent);
- //Apply antialiasing
- painter.setRenderHint(QPainter::Antialiasing, _antialiased);
- painter.setRenderHint(QPainter::TextAntialiasing, _antialiased);
- painter.setRenderHint(QPainter::SmoothPixmapTransform, _antialiased);
+ //Apply antialiasing
+ painter.setRenderHint(QPainter::Antialiasing, _antialiased);
+ painter.setRenderHint(QPainter::TextAntialiasing, _antialiased);
+ painter.setRenderHint(QPainter::SmoothPixmapTransform, _antialiased);
- painter.setPen(pen);
- painter.setBrush(brush);
+ painter.setPen(pen);
+ painter.setBrush(brush);
}
/**
- @brief CustomElementGraphicPart::drawShadowShape
- Draw a transparent blue shadow arround the shape of this item.
- The QPainterPathStroker used to draw shadows have a width of SHADOWS_HEIGHT
- Be carefull if penWeight of this item is to 0 the outline of strock is bigger of 0.5
- @param painter : painter to use for draw this shadows
+ @brief CustomElementGraphicPart::drawShadowShape
+ Draw a transparent blue shadow arround the shape of this item.
+ The QPainterPathStroker used to draw shadows have a width of SHADOWS_HEIGHT
+ Be carefull if penWeight of this item is to 0 the outline of strock is bigger of 0.5
+ @param painter : painter to use for draw this shadows
*/
void CustomElementGraphicPart::drawShadowShape(QPainter *painter)
{
- //@FIXME if pen weight is 0, the strock outline is SHADOWS_HEIGHT/2 + 0.5
- //may be because shape have no line weight
- QPainterPathStroker strock;
- strock.setWidth(SHADOWS_HEIGHT);
- strock.setJoinStyle(Qt::RoundJoin);
+ //@FIXME if pen weight is 0, the strock outline is SHADOWS_HEIGHT/2 + 0.5
+ //may be because shape have no line weight
+ QPainterPathStroker strock;
+ strock.setWidth(SHADOWS_HEIGHT);
+ strock.setJoinStyle(Qt::RoundJoin);
- painter->save();
- QColor color(Qt::darkBlue);
- color.setAlpha(50);
- painter -> setBrush (QBrush (color));
- painter -> setPen (Qt::NoPen);
- painter -> drawPath (strock.createStroke(shadowShape()));
- painter -> restore ();
+ painter->save();
+ QColor color(Qt::darkBlue);
+ color.setAlpha(50);
+ painter -> setBrush (QBrush (color));
+ painter -> setPen (Qt::NoPen);
+ painter -> drawPath (strock.createStroke(shadowShape()));
+ painter -> restore ();
}
/**
- @brief CustomElementGraphicPart::itemChange
- Reimplemented from QGraphicsObject.
- If the item position change call updateCurrentPartEditor()
- the change is always send to QGraphicsObject
- @param change
- @param value
- @return the returned value of QGraphicsObject::itemChange
+ @brief CustomElementGraphicPart::itemChange
+ Reimplemented from QGraphicsObject.
+ If the item position change call updateCurrentPartEditor()
+ the change is always send to QGraphicsObject
+ @param change
+ @param value
+ @return the returned value of QGraphicsObject::itemChange
*/
QVariant CustomElementGraphicPart::itemChange(GraphicsItemChange change, const QVariant &value)
{
- if (scene())
- if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemPositionHasChanged)
- updateCurrentPartEditor();
+ if (scene())
+ if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemPositionHasChanged)
+ updateCurrentPartEditor();
- return(QGraphicsObject::itemChange(change, value));
+ return(QGraphicsObject::itemChange(change, value));
}
/**
- @brief CustomElementGraphicPart::hoverEnterEvent
- Reimplemented from QGraphicsObject.
- Set m_hovered to true
- @param event
+ @brief CustomElementGraphicPart::hoverEnterEvent
+ Reimplemented from QGraphicsObject.
+ Set m_hovered to true
+ @param event
*/
void CustomElementGraphicPart::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
- m_hovered = true;
- QGraphicsObject::hoverEnterEvent(event);
+ m_hovered = true;
+ QGraphicsObject::hoverEnterEvent(event);
}
/**
- @brief CustomElementGraphicPart::hoverLeaveEvent
- Reimplemented from QGraphicsObject.
- Set m_hovered to false
- @param event
+ @brief CustomElementGraphicPart::hoverLeaveEvent
+ Reimplemented from QGraphicsObject.
+ Set m_hovered to false
+ @param event
*/
void CustomElementGraphicPart::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
- m_hovered = false;
- QGraphicsObject::hoverLeaveEvent(event);
+ m_hovered = false;
+ QGraphicsObject::hoverLeaveEvent(event);
}
void CustomElementGraphicPart::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
- if(event->button() == Qt::LeftButton)
- m_origin_pos = this->pos();
+ if(event->button() == Qt::LeftButton)
+ m_origin_pos = this->pos();
- QGraphicsObject::mousePressEvent(event);
+ QGraphicsObject::mousePressEvent(event);
}
void CustomElementGraphicPart::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
- if((event->buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable))
- {
- QPointF pos = event->scenePos() + (m_origin_pos - event->buttonDownScenePos(Qt::LeftButton));
- event->modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene()->snapToGrid(pos));
- }
- else
- QGraphicsObject::mouseMoveEvent(event);
+ if((event->buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable))
+ {
+ QPointF pos = event->scenePos() + (m_origin_pos - event->buttonDownScenePos(Qt::LeftButton));
+ event->modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene()->snapToGrid(pos));
+ }
+ else
+ QGraphicsObject::mouseMoveEvent(event);
}
void CustomElementGraphicPart::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
- if((event->button() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable) && m_origin_pos != pos())
- {
- QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "pos", QVariant(m_origin_pos), QVariant(pos()));
- undo->setText(tr("Déplacer une primitive"));
- undo->enableAnimation();
- elementScene()->undoStack().push(undo);
- }
+ if((event->button() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable) && m_origin_pos != pos())
+ {
+ QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "pos", QVariant(m_origin_pos), QVariant(pos()));
+ undo->setText(tr("D??placer une primitive"));
+ undo->enableAnimation();
+ elementScene()->undoStack().push(undo);
+ }
- QGraphicsObject::mouseReleaseEvent(event);
+ QGraphicsObject::mouseReleaseEvent(event);
}
diff --git a/sources/editor/graphicspart/customelementgraphicpart.h b/sources/editor/graphicspart/customelementgraphicpart.h
index 4131c86a1..4138d21e0 100644
--- a/sources/editor/graphicspart/customelementgraphicpart.h
+++ b/sources/editor/graphicspart/customelementgraphicpart.h
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#ifndef CUSTOM_ELEMENT_GRAPHIC_PART_H
#define CUSTOM_ELEMENT_GRAPHIC_PART_H
@@ -26,308 +26,308 @@ class QPainter;
/**
- @brief The CustomElementGraphicPart class
- This class is the base for all home-made primitive like line,
- rectangle, ellipse etc....
- It provides methods and enums to manage style attributes available
- for primitive (color, pen style, etc...)
+ @brief The CustomElementGraphicPart class
+ This class is the base for all home-made primitive like line,
+ rectangle, ellipse etc....
+ It provides methods and enums to manage style attributes available
+ for primitive (color, pen style, etc...)
*/
class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPart
{
- #define SHADOWS_HEIGHT 4.0
+ #define SHADOWS_HEIGHT 4.0
- Q_OBJECT
+ Q_OBJECT
- Q_PROPERTY(LineStyle line_style READ lineStyle WRITE setLineStyle)
- Q_PROPERTY(LineWeight line_weight READ lineWeight WRITE setLineWeight)
- Q_PROPERTY(Filling filling READ filling WRITE setFilling)
- Q_PROPERTY(Color color READ color WRITE setColor)
- Q_PROPERTY(bool antialias READ antialiased WRITE setAntialiased)
+ Q_PROPERTY(LineStyle line_style READ lineStyle WRITE setLineStyle)
+ Q_PROPERTY(LineWeight line_weight READ lineWeight WRITE setLineWeight)
+ Q_PROPERTY(Filling filling READ filling WRITE setFilling)
+ Q_PROPERTY(Color color READ color WRITE setColor)
+ Q_PROPERTY(bool antialias READ antialiased WRITE setAntialiased)
- public:
- //Line style
- enum LineStyle {NormalStyle,
- DashedStyle,
- DottedStyle,
- DashdottedStyle};
- Q_ENUM (LineStyle)
+ public:
+ //Line style
+ enum LineStyle {NormalStyle,
+ DashedStyle,
+ DottedStyle,
+ DashdottedStyle};
+ Q_ENUM (LineStyle)
- //Line weight : invisible, 0px, 1px, 2px, 5px
- enum LineWeight {NoneWeight,
- ThinWeight,
- NormalWeight,
- UltraWeight,
- BigWeight};
- Q_ENUM (LineWeight)
+ //Line weight : invisible, 0px, 1px, 2px, 5px
+ enum LineWeight {NoneWeight,
+ ThinWeight,
+ NormalWeight,
+ UltraWeight,
+ BigWeight};
+ Q_ENUM (LineWeight)
- //Filling color of the part : NoneFilling -> No filling (i.e. transparent)
- enum Filling { NoneFilling, BlackFilling, WhiteFilling,
- GreenFilling, RedFilling, BlueFilling,
- GrayFilling, BrunFilling, YellowFilling,
- CyanFilling, MagentaFilling, LightgrayFilling,
- OrangeFilling, PurpleFilling,
- HTMLPinkPinkFilling, HTMLPinkLightPinkFilling,
- HTMLPinkHotPinkFilling, HTMLPinkDeepPinkFilling,
- HTMLPinkPaleVioletRedFilling,
- HTMLPinkMediumVioletRedFilling,
- HTMLRedLightSalmonFilling, HTMLRedSalmonFilling,
- HTMLRedDarkSalmonFilling,
- HTMLRedLightCoralFilling,
- HTMLRedIndianRedFilling, HTMLRedCrimsonFilling,
- HTMLRedFirebrickFilling, HTMLRedDarkRedFilling,
- HTMLRedRedFilling, HTMLOrangeOrangeRedFilling,
- HTMLOrangeTomatoFilling, HTMLOrangeCoralFilling,
- HTMLOrangeDarkOrangeFilling,
- HTMLOrangeOrangeFilling, HTMLYellowYellowFilling,
- HTMLYellowLightYellowFilling,
- HTMLYellowLemonChiffonFilling,
- HTMLYellowLightGoldenrodYellowFilling,
- HTMLYellowPapayaWhipFilling,
- HTMLYellowMoccasinFilling,
- HTMLYellowPeachPuffFilling,
- HTMLYellowPaleGoldenrodFilling,
- HTMLYellowKhakiFilling,
- HTMLYellowDarkKhakiFilling,
- HTMLYellowGoldFilling, HTMLBrownCornsilkFilling,
- HTMLBrownBlanchedAlmondFilling,
- HTMLBrownBisqueFilling,
- HTMLBrownNavajoWhiteFilling,
- HTMLBrownWheatFilling, HTMLBrownBurlywoodFilling,
- HTMLBrownTanFilling, HTMLBrownRosyBrownFilling,
- HTMLBrownSandyBrownFilling,
- HTMLBrownGoldenrodFilling,
- HTMLBrownDarkGoldenrodFilling,
- HTMLBrownPeruFilling, HTMLBrownChocolateFilling,
- HTMLBrownSaddleBrownFilling,
- HTMLBrownSiennaFilling, HTMLBrownBrownFilling,
- HTMLBrownMaroonFilling,
- HTMLGreenDarkOliveGreenFilling,
- HTMLGreenOliveFilling, HTMLGreenOliveDrabFilling,
- HTMLGreenYellowGreenFilling,
- HTMLGreenLimeGreenFilling, HTMLGreenLimeFilling,
- HTMLGreenLawnGreenFilling,
- HTMLGreenChartreuseFilling,
- HTMLGreenGreenYellowFilling,
- HTMLGreenSpringGreenFilling,
- HTMLGreenMediumSpringGreenFilling,
- HTMLGreenLightGreenFilling,
- HTMLGreenPaleGreenFilling,
- HTMLGreenDarkSeaGreenFilling,
- HTMLGreenMediumAquamarineFilling,
- HTMLGreenMediumSeaGreenFilling,
- HTMLGreenSeaGreenFilling,
- HTMLGreenForestGreenFilling,
- HTMLGreenGreenFilling, HTMLGreenDarkGreenFilling,
- HTMLCyanAquaFilling, HTMLCyanCyanFilling,
- HTMLCyanLightCyanFilling,
- HTMLCyanPaleTurquoiseFilling,
- HTMLCyanAquamarineFilling,
- HTMLCyanTurquoiseFilling,
- HTMLCyanMediumTurquoiseFilling,
- HTMLCyanDarkTurquoiseFilling,
- HTMLCyanLightSeaGreenFilling,
- HTMLCyanCadetBlueFilling,
- HTMLCyanDarkCyanFilling, HTMLCyanTealFilling,
- HTMLBlueLightSteelBlueFilling,
- HTMLBluePowderBlueFilling,
- HTMLBlueLightBlueFilling, HTMLBlueSkyBlueFilling,
- HTMLBlueLightSkyBlueFilling,
- HTMLBlueDeepSkyBlueFilling,
- HTMLBlueDodgerBlueFilling,
- HTMLBlueCornflowerBlueFilling,
- HTMLBlueSteelBlueFilling,
- HTMLBlueRoyalBlueFilling, HTMLBlueBlueFilling,
- HTMLBlueMediumBlueFilling,
- HTMLBlueDarkBlueFilling, HTMLBlueNavyFilling,
- HTMLBlueMidnightBlueFilling,
- HTMLPurpleLavenderFilling,
- HTMLPurpleThistleFilling, HTMLPurplePlumFilling,
- HTMLPurpleVioletFilling, HTMLPurpleOrchidFilling,
- HTMLPurpleFuchsiaFilling,
- HTMLPurpleMagentaFilling,
- HTMLPurpleMediumOrchidFilling,
- HTMLPurpleMediumPurpleFilling,
- HTMLPurpleBlueVioletFilling,
- HTMLPurpleDarkVioletFilling,
- HTMLPurpleDarkOrchidFilling,
- HTMLPurpleDarkMagentaFilling,
- HTMLPurplePurpleFilling, HTMLPurpleIndigoFilling,
- HTMLPurpleDarkSlateBlueFilling,
- HTMLPurpleSlateBlueFilling,
- HTMLPurpleMediumSlateBlueFilling,
- HTMLWhiteWhiteFilling, HTMLWhiteSnowFilling,
- HTMLWhiteHoneydewFilling,
- HTMLWhiteMintCreamFilling, HTMLWhiteAzureFilling,
- HTMLWhiteAliceBlueFilling,
- HTMLWhiteGhostWhiteFilling,
- HTMLWhiteWhiteSmokeFilling,
- HTMLWhiteSeashellFilling, HTMLWhiteBeigeFilling,
- HTMLWhiteOldLaceFilling,
- HTMLWhiteFloralWhiteFilling,
- HTMLWhiteIvoryFilling,
- HTMLWhiteAntiqueWhiteFilling,
- HTMLWhiteLinenFilling,
- HTMLWhiteLavenderBlushFilling,
- HTMLWhiteMistyRoseFilling,
- HTMLGrayGainsboroFilling,
- HTMLGrayLightGrayFilling, HTMLGraySilverFilling,
- HTMLGrayDarkGrayFilling, HTMLGrayGrayFilling,
- HTMLGrayDimGrayFilling,
- HTMLGrayLightSlateGrayFilling,
- HTMLGraySlateGrayFilling,
- HTMLGrayDarkSlateGrayFilling,
- HTMLGrayBlackFilling, HorFilling, VerFilling,
- BdiagFilling, FdiagFilling};
- Q_ENUM (Filling)
+ //Filling color of the part : NoneFilling -> No filling (i.e. transparent)
+ enum Filling { NoneFilling, BlackFilling, WhiteFilling,
+ GreenFilling, RedFilling, BlueFilling,
+ GrayFilling, BrunFilling, YellowFilling,
+ CyanFilling, MagentaFilling, LightgrayFilling,
+ OrangeFilling, PurpleFilling,
+ HTMLPinkPinkFilling, HTMLPinkLightPinkFilling,
+ HTMLPinkHotPinkFilling, HTMLPinkDeepPinkFilling,
+ HTMLPinkPaleVioletRedFilling,
+ HTMLPinkMediumVioletRedFilling,
+ HTMLRedLightSalmonFilling, HTMLRedSalmonFilling,
+ HTMLRedDarkSalmonFilling,
+ HTMLRedLightCoralFilling,
+ HTMLRedIndianRedFilling, HTMLRedCrimsonFilling,
+ HTMLRedFirebrickFilling, HTMLRedDarkRedFilling,
+ HTMLRedRedFilling, HTMLOrangeOrangeRedFilling,
+ HTMLOrangeTomatoFilling, HTMLOrangeCoralFilling,
+ HTMLOrangeDarkOrangeFilling,
+ HTMLOrangeOrangeFilling, HTMLYellowYellowFilling,
+ HTMLYellowLightYellowFilling,
+ HTMLYellowLemonChiffonFilling,
+ HTMLYellowLightGoldenrodYellowFilling,
+ HTMLYellowPapayaWhipFilling,
+ HTMLYellowMoccasinFilling,
+ HTMLYellowPeachPuffFilling,
+ HTMLYellowPaleGoldenrodFilling,
+ HTMLYellowKhakiFilling,
+ HTMLYellowDarkKhakiFilling,
+ HTMLYellowGoldFilling, HTMLBrownCornsilkFilling,
+ HTMLBrownBlanchedAlmondFilling,
+ HTMLBrownBisqueFilling,
+ HTMLBrownNavajoWhiteFilling,
+ HTMLBrownWheatFilling, HTMLBrownBurlywoodFilling,
+ HTMLBrownTanFilling, HTMLBrownRosyBrownFilling,
+ HTMLBrownSandyBrownFilling,
+ HTMLBrownGoldenrodFilling,
+ HTMLBrownDarkGoldenrodFilling,
+ HTMLBrownPeruFilling, HTMLBrownChocolateFilling,
+ HTMLBrownSaddleBrownFilling,
+ HTMLBrownSiennaFilling, HTMLBrownBrownFilling,
+ HTMLBrownMaroonFilling,
+ HTMLGreenDarkOliveGreenFilling,
+ HTMLGreenOliveFilling, HTMLGreenOliveDrabFilling,
+ HTMLGreenYellowGreenFilling,
+ HTMLGreenLimeGreenFilling, HTMLGreenLimeFilling,
+ HTMLGreenLawnGreenFilling,
+ HTMLGreenChartreuseFilling,
+ HTMLGreenGreenYellowFilling,
+ HTMLGreenSpringGreenFilling,
+ HTMLGreenMediumSpringGreenFilling,
+ HTMLGreenLightGreenFilling,
+ HTMLGreenPaleGreenFilling,
+ HTMLGreenDarkSeaGreenFilling,
+ HTMLGreenMediumAquamarineFilling,
+ HTMLGreenMediumSeaGreenFilling,
+ HTMLGreenSeaGreenFilling,
+ HTMLGreenForestGreenFilling,
+ HTMLGreenGreenFilling, HTMLGreenDarkGreenFilling,
+ HTMLCyanAquaFilling, HTMLCyanCyanFilling,
+ HTMLCyanLightCyanFilling,
+ HTMLCyanPaleTurquoiseFilling,
+ HTMLCyanAquamarineFilling,
+ HTMLCyanTurquoiseFilling,
+ HTMLCyanMediumTurquoiseFilling,
+ HTMLCyanDarkTurquoiseFilling,
+ HTMLCyanLightSeaGreenFilling,
+ HTMLCyanCadetBlueFilling,
+ HTMLCyanDarkCyanFilling, HTMLCyanTealFilling,
+ HTMLBlueLightSteelBlueFilling,
+ HTMLBluePowderBlueFilling,
+ HTMLBlueLightBlueFilling, HTMLBlueSkyBlueFilling,
+ HTMLBlueLightSkyBlueFilling,
+ HTMLBlueDeepSkyBlueFilling,
+ HTMLBlueDodgerBlueFilling,
+ HTMLBlueCornflowerBlueFilling,
+ HTMLBlueSteelBlueFilling,
+ HTMLBlueRoyalBlueFilling, HTMLBlueBlueFilling,
+ HTMLBlueMediumBlueFilling,
+ HTMLBlueDarkBlueFilling, HTMLBlueNavyFilling,
+ HTMLBlueMidnightBlueFilling,
+ HTMLPurpleLavenderFilling,
+ HTMLPurpleThistleFilling, HTMLPurplePlumFilling,
+ HTMLPurpleVioletFilling, HTMLPurpleOrchidFilling,
+ HTMLPurpleFuchsiaFilling,
+ HTMLPurpleMagentaFilling,
+ HTMLPurpleMediumOrchidFilling,
+ HTMLPurpleMediumPurpleFilling,
+ HTMLPurpleBlueVioletFilling,
+ HTMLPurpleDarkVioletFilling,
+ HTMLPurpleDarkOrchidFilling,
+ HTMLPurpleDarkMagentaFilling,
+ HTMLPurplePurpleFilling, HTMLPurpleIndigoFilling,
+ HTMLPurpleDarkSlateBlueFilling,
+ HTMLPurpleSlateBlueFilling,
+ HTMLPurpleMediumSlateBlueFilling,
+ HTMLWhiteWhiteFilling, HTMLWhiteSnowFilling,
+ HTMLWhiteHoneydewFilling,
+ HTMLWhiteMintCreamFilling, HTMLWhiteAzureFilling,
+ HTMLWhiteAliceBlueFilling,
+ HTMLWhiteGhostWhiteFilling,
+ HTMLWhiteWhiteSmokeFilling,
+ HTMLWhiteSeashellFilling, HTMLWhiteBeigeFilling,
+ HTMLWhiteOldLaceFilling,
+ HTMLWhiteFloralWhiteFilling,
+ HTMLWhiteIvoryFilling,
+ HTMLWhiteAntiqueWhiteFilling,
+ HTMLWhiteLinenFilling,
+ HTMLWhiteLavenderBlushFilling,
+ HTMLWhiteMistyRoseFilling,
+ HTMLGrayGainsboroFilling,
+ HTMLGrayLightGrayFilling, HTMLGraySilverFilling,
+ HTMLGrayDarkGrayFilling, HTMLGrayGrayFilling,
+ HTMLGrayDimGrayFilling,
+ HTMLGrayLightSlateGrayFilling,
+ HTMLGraySlateGrayFilling,
+ HTMLGrayDarkSlateGrayFilling,
+ HTMLGrayBlackFilling, HorFilling, VerFilling,
+ BdiagFilling, FdiagFilling};
+ Q_ENUM (Filling)
- //Line color
- enum Color {
- BlackColor, WhiteColor, GreenColor, RedColor, BlueColor,
- GrayColor, BrunColor, YellowColor, CyanColor,
- MagentaColor, LightgrayColor, OrangeColor, PurpleColor,
- HTMLPinkPinkColor, HTMLPinkLightPinkColor,
- HTMLPinkHotPinkColor, HTMLPinkDeepPinkColor,
- HTMLPinkPaleVioletRedColor,
- HTMLPinkMediumVioletRedColor, HTMLRedLightSalmonColor,
- HTMLRedSalmonColor, HTMLRedDarkSalmonColor,
- HTMLRedLightCoralColor, HTMLRedIndianRedColor,
- HTMLRedCrimsonColor, HTMLRedFirebrickColor,
- HTMLRedDarkRedColor, HTMLRedRedColor,
- HTMLOrangeOrangeRedColor, HTMLOrangeTomatoColor,
- HTMLOrangeCoralColor, HTMLOrangeDarkOrangeColor,
- HTMLOrangeOrangeColor, HTMLYellowYellowColor,
- HTMLYellowLightYellowColor, HTMLYellowLemonChiffonColor,
- HTMLYellowLightGoldenrodYellowColor,
- HTMLYellowPapayaWhipColor, HTMLYellowMoccasinColor,
- HTMLYellowPeachPuffColor, HTMLYellowPaleGoldenrodColor,
- HTMLYellowKhakiColor, HTMLYellowDarkKhakiColor,
- HTMLYellowGoldColor, HTMLBrownCornsilkColor,
- HTMLBrownBlanchedAlmondColor, HTMLBrownBisqueColor,
- HTMLBrownNavajoWhiteColor, HTMLBrownWheatColor,
- HTMLBrownBurlywoodColor, HTMLBrownTanColor,
- HTMLBrownRosyBrownColor, HTMLBrownSandyBrownColor,
- HTMLBrownGoldenrodColor, HTMLBrownDarkGoldenrodColor,
- HTMLBrownPeruColor, HTMLBrownChocolateColor,
- HTMLBrownSaddleBrownColor, HTMLBrownSiennaColor,
- HTMLBrownBrownColor, HTMLBrownMaroonColor,
- HTMLGreenDarkOliveGreenColor, HTMLGreenOliveColor,
- HTMLGreenOliveDrabColor, HTMLGreenYellowGreenColor,
- HTMLGreenLimeGreenColor, HTMLGreenLimeColor,
- HTMLGreenLawnGreenColor, HTMLGreenChartreuseColor,
- HTMLGreenGreenYellowColor, HTMLGreenSpringGreenColor,
- HTMLGreenMediumSpringGreenColor,
- HTMLGreenLightGreenColor, HTMLGreenPaleGreenColor,
- HTMLGreenDarkSeaGreenColor,
- HTMLGreenMediumAquamarineColor,
- HTMLGreenMediumSeaGreenColor, HTMLGreenSeaGreenColor,
- HTMLGreenForestGreenColor, HTMLGreenGreenColor,
- HTMLGreenDarkGreenColor, HTMLCyanAquaColor,
- HTMLCyanCyanColor, HTMLCyanLightCyanColor,
- HTMLCyanPaleTurquoiseColor, HTMLCyanAquamarineColor,
- HTMLCyanTurquoiseColor, HTMLCyanMediumTurquoiseColor,
- HTMLCyanDarkTurquoiseColor, HTMLCyanLightSeaGreenColor,
- HTMLCyanCadetBlueColor, HTMLCyanDarkCyanColor,
- HTMLCyanTealColor, HTMLBlueLightSteelBlueColor,
- HTMLBluePowderBlueColor, HTMLBlueLightBlueColor,
- HTMLBlueSkyBlueColor, HTMLBlueLightSkyBlueColor,
- HTMLBlueDeepSkyBlueColor, HTMLBlueDodgerBlueColor,
- HTMLBlueCornflowerBlueColor, HTMLBlueSteelBlueColor,
- HTMLBlueRoyalBlueColor, HTMLBlueBlueColor,
- HTMLBlueMediumBlueColor, HTMLBlueDarkBlueColor,
- HTMLBlueNavyColor, HTMLBlueMidnightBlueColor,
- HTMLPurpleLavenderColor, HTMLPurpleThistleColor,
- HTMLPurplePlumColor, HTMLPurpleVioletColor,
- HTMLPurpleOrchidColor, HTMLPurpleFuchsiaColor,
- HTMLPurpleMagentaColor, HTMLPurpleMediumOrchidColor,
- HTMLPurpleMediumPurpleColor, HTMLPurpleBlueVioletColor,
- HTMLPurpleDarkVioletColor, HTMLPurpleDarkOrchidColor,
- HTMLPurpleDarkMagentaColor, HTMLPurplePurpleColor,
- HTMLPurpleIndigoColor, HTMLPurpleDarkSlateBlueColor,
- HTMLPurpleSlateBlueColor,
- HTMLPurpleMediumSlateBlueColor,
- HTMLWhiteWhiteColor, HTMLWhiteSnowColor,
- HTMLWhiteHoneydewColor, HTMLWhiteMintCreamColor,
- HTMLWhiteAzureColor, HTMLWhiteAliceBlueColor,
- HTMLWhiteGhostWhiteColor, HTMLWhiteWhiteSmokeColor,
- HTMLWhiteSeashellColor, HTMLWhiteBeigeColor,
- HTMLWhiteOldLaceColor, HTMLWhiteFloralWhiteColor,
- HTMLWhiteIvoryColor, HTMLWhiteAntiqueWhiteColor,
- HTMLWhiteLinenColor, HTMLWhiteLavenderBlushColor,
- HTMLWhiteMistyRoseColor, HTMLGrayGainsboroColor,
- HTMLGrayLightGrayColor, HTMLGraySilverColor,
- HTMLGrayDarkGrayColor, HTMLGrayGrayColor,
- HTMLGrayDimGrayColor, HTMLGrayLightSlateGrayColor,
- HTMLGraySlateGrayColor, HTMLGrayDarkSlateGrayColor,
- HTMLGrayBlackColor, NoneColor};
- Q_ENUM (Color)
+ //Line color
+ enum Color {
+ BlackColor, WhiteColor, GreenColor, RedColor, BlueColor,
+ GrayColor, BrunColor, YellowColor, CyanColor,
+ MagentaColor, LightgrayColor, OrangeColor, PurpleColor,
+ HTMLPinkPinkColor, HTMLPinkLightPinkColor,
+ HTMLPinkHotPinkColor, HTMLPinkDeepPinkColor,
+ HTMLPinkPaleVioletRedColor,
+ HTMLPinkMediumVioletRedColor, HTMLRedLightSalmonColor,
+ HTMLRedSalmonColor, HTMLRedDarkSalmonColor,
+ HTMLRedLightCoralColor, HTMLRedIndianRedColor,
+ HTMLRedCrimsonColor, HTMLRedFirebrickColor,
+ HTMLRedDarkRedColor, HTMLRedRedColor,
+ HTMLOrangeOrangeRedColor, HTMLOrangeTomatoColor,
+ HTMLOrangeCoralColor, HTMLOrangeDarkOrangeColor,
+ HTMLOrangeOrangeColor, HTMLYellowYellowColor,
+ HTMLYellowLightYellowColor, HTMLYellowLemonChiffonColor,
+ HTMLYellowLightGoldenrodYellowColor,
+ HTMLYellowPapayaWhipColor, HTMLYellowMoccasinColor,
+ HTMLYellowPeachPuffColor, HTMLYellowPaleGoldenrodColor,
+ HTMLYellowKhakiColor, HTMLYellowDarkKhakiColor,
+ HTMLYellowGoldColor, HTMLBrownCornsilkColor,
+ HTMLBrownBlanchedAlmondColor, HTMLBrownBisqueColor,
+ HTMLBrownNavajoWhiteColor, HTMLBrownWheatColor,
+ HTMLBrownBurlywoodColor, HTMLBrownTanColor,
+ HTMLBrownRosyBrownColor, HTMLBrownSandyBrownColor,
+ HTMLBrownGoldenrodColor, HTMLBrownDarkGoldenrodColor,
+ HTMLBrownPeruColor, HTMLBrownChocolateColor,
+ HTMLBrownSaddleBrownColor, HTMLBrownSiennaColor,
+ HTMLBrownBrownColor, HTMLBrownMaroonColor,
+ HTMLGreenDarkOliveGreenColor, HTMLGreenOliveColor,
+ HTMLGreenOliveDrabColor, HTMLGreenYellowGreenColor,
+ HTMLGreenLimeGreenColor, HTMLGreenLimeColor,
+ HTMLGreenLawnGreenColor, HTMLGreenChartreuseColor,
+ HTMLGreenGreenYellowColor, HTMLGreenSpringGreenColor,
+ HTMLGreenMediumSpringGreenColor,
+ HTMLGreenLightGreenColor, HTMLGreenPaleGreenColor,
+ HTMLGreenDarkSeaGreenColor,
+ HTMLGreenMediumAquamarineColor,
+ HTMLGreenMediumSeaGreenColor, HTMLGreenSeaGreenColor,
+ HTMLGreenForestGreenColor, HTMLGreenGreenColor,
+ HTMLGreenDarkGreenColor, HTMLCyanAquaColor,
+ HTMLCyanCyanColor, HTMLCyanLightCyanColor,
+ HTMLCyanPaleTurquoiseColor, HTMLCyanAquamarineColor,
+ HTMLCyanTurquoiseColor, HTMLCyanMediumTurquoiseColor,
+ HTMLCyanDarkTurquoiseColor, HTMLCyanLightSeaGreenColor,
+ HTMLCyanCadetBlueColor, HTMLCyanDarkCyanColor,
+ HTMLCyanTealColor, HTMLBlueLightSteelBlueColor,
+ HTMLBluePowderBlueColor, HTMLBlueLightBlueColor,
+ HTMLBlueSkyBlueColor, HTMLBlueLightSkyBlueColor,
+ HTMLBlueDeepSkyBlueColor, HTMLBlueDodgerBlueColor,
+ HTMLBlueCornflowerBlueColor, HTMLBlueSteelBlueColor,
+ HTMLBlueRoyalBlueColor, HTMLBlueBlueColor,
+ HTMLBlueMediumBlueColor, HTMLBlueDarkBlueColor,
+ HTMLBlueNavyColor, HTMLBlueMidnightBlueColor,
+ HTMLPurpleLavenderColor, HTMLPurpleThistleColor,
+ HTMLPurplePlumColor, HTMLPurpleVioletColor,
+ HTMLPurpleOrchidColor, HTMLPurpleFuchsiaColor,
+ HTMLPurpleMagentaColor, HTMLPurpleMediumOrchidColor,
+ HTMLPurpleMediumPurpleColor, HTMLPurpleBlueVioletColor,
+ HTMLPurpleDarkVioletColor, HTMLPurpleDarkOrchidColor,
+ HTMLPurpleDarkMagentaColor, HTMLPurplePurpleColor,
+ HTMLPurpleIndigoColor, HTMLPurpleDarkSlateBlueColor,
+ HTMLPurpleSlateBlueColor,
+ HTMLPurpleMediumSlateBlueColor,
+ HTMLWhiteWhiteColor, HTMLWhiteSnowColor,
+ HTMLWhiteHoneydewColor, HTMLWhiteMintCreamColor,
+ HTMLWhiteAzureColor, HTMLWhiteAliceBlueColor,
+ HTMLWhiteGhostWhiteColor, HTMLWhiteWhiteSmokeColor,
+ HTMLWhiteSeashellColor, HTMLWhiteBeigeColor,
+ HTMLWhiteOldLaceColor, HTMLWhiteFloralWhiteColor,
+ HTMLWhiteIvoryColor, HTMLWhiteAntiqueWhiteColor,
+ HTMLWhiteLinenColor, HTMLWhiteLavenderBlushColor,
+ HTMLWhiteMistyRoseColor, HTMLGrayGainsboroColor,
+ HTMLGrayLightGrayColor, HTMLGraySilverColor,
+ HTMLGrayDarkGrayColor, HTMLGrayGrayColor,
+ HTMLGrayDimGrayColor, HTMLGrayLightSlateGrayColor,
+ HTMLGraySlateGrayColor, HTMLGrayDarkSlateGrayColor,
+ HTMLGrayBlackColor, NoneColor};
+ Q_ENUM (Color)
- // constructors, destructor
- public:
+ // constructors, destructor
+ public:
- CustomElementGraphicPart(QETElementEditor *editor,
- QGraphicsItem *parent = nullptr);
- ~CustomElementGraphicPart() override;
+ CustomElementGraphicPart(QETElementEditor *editor,
+ QGraphicsItem *parent = nullptr);
+ ~CustomElementGraphicPart() override;
- static void drawCross (const QPointF ¢er,
- QPainter *painter);
+ static void drawCross (const QPointF ¢er,
+ QPainter *painter);
- //Getter and setter
- LineStyle lineStyle () const {return _linestyle;}
- void setLineStyle (const LineStyle ls);
+ //Getter and setter
+ LineStyle lineStyle () const {return _linestyle;}
+ void setLineStyle (const LineStyle ls);
- LineWeight lineWeight () const {return _lineweight;}
- void setLineWeight (const LineWeight lw);
- qreal penWeight () const;
+ LineWeight lineWeight () const {return _lineweight;}
+ void setLineWeight (const LineWeight lw);
+ qreal penWeight () const;
- Filling filling () const {return _filling;}
- void setFilling(const Filling f);
+ Filling filling () const {return _filling;}
+ void setFilling(const Filling f);
- Color color () const {return _color;}
- void setColor(const Color c);
+ Color color () const {return _color;}
+ void setColor(const Color c);
- bool antialiased () const {return _antialiased;}
- void setAntialiased(const bool b);
- //End of getter and setter
+ bool antialiased () const {return _antialiased;}
+ void setAntialiased(const bool b);
+ //End of getter and setter
- //Rediriged to QObject Q_PROPERTY system
- void setProperty (const char *name,
- const QVariant &value) override {
- QObject::setProperty(name, value);}
- QVariant property (const char *name) const override {
- return QObject::property(name);}
+ //Rediriged to QObject Q_PROPERTY system
+ void setProperty (const char *name,
+ const QVariant &value) override {
+ QObject::setProperty(name, value);}
+ QVariant property (const char *name) const override {
+ return QObject::property(name);}
- virtual QPainterPath shadowShape ()const = 0;
- virtual void setHandlerColor(QPointF /*pos*/,
- const QColor &/*color*/) {}
- virtual void resetAllHandlerColor() {}
+ virtual QPainterPath shadowShape ()const = 0;
+ virtual void setHandlerColor(QPointF /*pos*/,
+ const QColor &/*color*/) {}
+ virtual void resetAllHandlerColor() {}
- protected:
- void stylesToXml (QDomElement &) const;
- void stylesFromXml(const QDomElement &);
- void resetStyles ();
- void applyStylesToQPainter(QPainter &) const;
- void drawShadowShape (QPainter *painter);
+ protected:
+ void stylesToXml (QDomElement &) const;
+ void stylesFromXml(const QDomElement &);
+ void resetStyles ();
+ void applyStylesToQPainter(QPainter &) const;
+ void drawShadowShape (QPainter *painter);
- QVariant itemChange(GraphicsItemChange change,
- const QVariant &value) override;
- void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
- void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
+ QVariant itemChange(GraphicsItemChange change,
+ const QVariant &value) override;
+ void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
+ void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
- void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
- void mouseReleaseEvent(
- QGraphicsSceneMouseEvent *event) override;
+ void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
+ void mouseReleaseEvent(
+ QGraphicsSceneMouseEvent *event) override;
- // attributes
- bool m_hovered;
- private:
- LineStyle _linestyle;
- LineWeight _lineweight;
- Filling _filling ;
- Color _color;
- bool _antialiased;
- QPointF m_origin_pos;
+ // attributes
+ bool m_hovered;
+ private:
+ LineStyle _linestyle;
+ LineWeight _lineweight;
+ Filling _filling ;
+ Color _color;
+ bool _antialiased;
+ QPointF m_origin_pos;
};
typedef CustomElementGraphicPart CEGP;
diff --git a/sources/editor/graphicspart/customelementpart.h b/sources/editor/graphicspart/customelementpart.h
index 9f3eaddc7..a4e88ad96 100644
--- a/sources/editor/graphicspart/customelementpart.h
+++ b/sources/editor/graphicspart/customelementpart.h
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#ifndef CUSTOM_ELEMENT_PART_H
#define CUSTOM_ELEMENT_PART_H
@@ -29,94 +29,94 @@ class QGraphicsItem;
class QGraphicsSceneMouseEvent;
/**
- @brief The CustomElementPart class
- This abstract class represents a primitive of
- the visual representation of an electrical element.
- The Element, FixedElement and CustomElement classes do not embed
- its attributes and methods in order to remain lightweight; indeed,
- there is no point for those classes to store their visual representation
- with anything more complex than a QImage.
+ @brief The CustomElementPart class
+ This abstract class represents a primitive of
+ the visual representation of an electrical element.
+ The Element, FixedElement and CustomElement classes do not embed
+ its attributes and methods in order to remain lightweight; indeed,
+ there is no point for those classes to store their visual representation
+ with anything more complex than a QImage.
*/
class CustomElementPart {
- // constructors, destructor
- public:
- /**
- @brief CustomElementPart
- Constructor
- @param editor Element editor this primitive is attached to
- */
- CustomElementPart(QETElementEditor *editor) : element_editor(editor) {}
- /**
- @brief ~CustomElementPart
- Destructor
- */
- virtual ~CustomElementPart() {}
-
- private:
- CustomElementPart(const CustomElementPart &);
-
- // attributes
- private:
- QETElementEditor *element_editor;
-
- // methods
- 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
- */
- virtual void setProperty(const char *name, const QVariant &value) = 0;
- /**
- Get the current value of a specific primitive property
- */
- virtual QVariant property(const char *name) const = 0;
- /**
- @return whether the primitive appears to be useless (e.g. 0-length line)
- Typically, useless primitives are discarded when saving the element.
- */
- virtual bool isUseless() const = 0;
- virtual QRectF sceneGeometricRect() const = 0;
- /**
- Inform this part a user-induced transformation is about to begin.
- This method can be used to save data required by handleUserTransformation().
- */
- virtual void startUserTransformation(const QRectF &) = 0;
- /**
- Make this part fit into the provided rectangle.
- */
- virtual void handleUserTransformation(const QRectF &,
- const QRectF &) = 0;
- /// @return a pointer to the parent element editor
- virtual QETElementEditor *elementEditor() const;
- /**
- Call the updateCurrentPartEditor() slot of the editor
- @see QETElementEditor::updateCurrentPartEditor()
- */
- virtual void updateCurrentPartEditor() const;
- /// @return a pointer to the parent editing scene
- virtual ElementScene *elementScene() const;
- /// @return the element editor undo stack
- virtual QUndoStack &undoStack() const;
- /// @return the name of the primitive
- virtual QString name() const = 0;
- /// @return the name that will be used as XML tag when exporting the primitive
- virtual QString xmlName() const = 0;
-
- virtual QGraphicsItem *toItem();
-
- virtual QET::ScalingMethod preferredScalingMethod() const;
-
- protected:
- QList mapPoints(
- const QRectF &,
- const QRectF &,
- const QList &);
+ // constructors, destructor
+ public:
+ /**
+ @brief CustomElementPart
+ Constructor
+ @param editor Element editor this primitive is attached to
+ */
+ CustomElementPart(QETElementEditor *editor) : element_editor(editor) {}
+ /**
+ @brief ~CustomElementPart
+ Destructor
+ */
+ virtual ~CustomElementPart() {}
+
+ private:
+ CustomElementPart(const CustomElementPart &);
+
+ // attributes
+ private:
+ QETElementEditor *element_editor;
+
+ // methods
+ 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
+ */
+ virtual void setProperty(const char *name, const QVariant &value) = 0;
+ /**
+ Get the current value of a specific primitive property
+ */
+ virtual QVariant property(const char *name) const = 0;
+ /**
+ @return whether the primitive appears to be useless (e.g. 0-length line)
+ Typically, useless primitives are discarded when saving the element.
+ */
+ virtual bool isUseless() const = 0;
+ virtual QRectF sceneGeometricRect() const = 0;
+ /**
+ Inform this part a user-induced transformation is about to begin.
+ This method can be used to save data required by handleUserTransformation().
+ */
+ virtual void startUserTransformation(const QRectF &) = 0;
+ /**
+ Make this part fit into the provided rectangle.
+ */
+ virtual void handleUserTransformation(const QRectF &,
+ const QRectF &) = 0;
+ /// @return a pointer to the parent element editor
+ virtual QETElementEditor *elementEditor() const;
+ /**
+ Call the updateCurrentPartEditor() slot of the editor
+ @see QETElementEditor::updateCurrentPartEditor()
+ */
+ virtual void updateCurrentPartEditor() const;
+ /// @return a pointer to the parent editing scene
+ virtual ElementScene *elementScene() const;
+ /// @return the element editor undo stack
+ virtual QUndoStack &undoStack() const;
+ /// @return the name of the primitive
+ virtual QString name() const = 0;
+ /// @return the name that will be used as XML tag when exporting the primitive
+ virtual QString xmlName() const = 0;
+
+ virtual QGraphicsItem *toItem();
+
+ virtual QET::ScalingMethod preferredScalingMethod() const;
+
+ protected:
+ QList mapPoints(
+ const QRectF &,
+ const QRectF &,
+ const QList &);
};
#endif
diff --git a/sources/editor/graphicspart/partarc.cpp b/sources/editor/graphicspart/partarc.cpp
index 1b3430d8c..6c33a5b98 100644
--- a/sources/editor/graphicspart/partarc.cpp
+++ b/sources/editor/graphicspart/partarc.cpp
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#include "partarc.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
@@ -23,143 +23,143 @@
/**
- @brief PartArc::PartArc
- Constructor
- @param editor : QETElementEditor of this part
- @param parent : parent item
+ @brief PartArc::PartArc
+ Constructor
+ @param editor : QETElementEditor of this part
+ @param parent : parent item
*/
PartArc::PartArc(QETElementEditor *editor, QGraphicsItem *parent) :
- AbstractPartEllipse(editor, parent)
+ AbstractPartEllipse(editor, parent)
{
- m_start_angle = 0;
- m_span_angle = -1440;
+ m_start_angle = 0;
+ m_span_angle = -1440;
}
/**
- @brief PartArc::~PartArc
- Destructor
+ @brief PartArc::~PartArc
+ Destructor
*/
PartArc::~PartArc()
{
- if(m_undo_command) delete m_undo_command;
- removeHandler();
+ if(m_undo_command) delete m_undo_command;
+ removeHandler();
}
/**
- @brief PartArc::paint
- Draw this arc
- @param painter
- @param options
- @param widget
+ @brief PartArc::paint
+ Draw this arc
+ @param painter
+ @param options
+ @param widget
*/
void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget)
{
- Q_UNUSED(widget)
+ Q_UNUSED(widget)
- applyStylesToQPainter(*painter);
+ applyStylesToQPainter(*painter);
- //Always remove the brush
- painter -> setBrush(Qt::NoBrush);
- QPen t = painter -> pen();
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
- t.setCosmetic(options && options -> levelOfDetail < 1.0);
+ //Always remove the brush
+ painter -> setBrush(Qt::NoBrush);
+ QPen t = painter -> pen();
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
+ t.setCosmetic(options && options -> levelOfDetail < 1.0);
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
- t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
+ t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
#endif
- painter -> setPen(t);
+ painter -> setPen(t);
- if (isSelected())
- {
- painter->save();
- QPen pen(Qt::DotLine);
- pen.setWidth(1);
- pen.setCosmetic(true);
- painter->setPen(pen);
- //Draw the ellipse in black
- painter -> drawEllipse(rect());
- painter->restore();
+ if (isSelected())
+ {
+ painter->save();
+ QPen pen(Qt::DotLine);
+ pen.setWidth(1);
+ pen.setCosmetic(true);
+ painter->setPen(pen);
+ //Draw the ellipse in black
+ painter -> drawEllipse(rect());
+ painter->restore();
- //Draw the arc in red
- t.setColor(Qt::red);
- painter -> setPen(t);
- }
+ //Draw the arc in red
+ t.setColor(Qt::red);
+ painter -> setPen(t);
+ }
- painter->drawArc(m_rect, m_start_angle, m_span_angle);
+ painter->drawArc(m_rect, m_start_angle, m_span_angle);
- if (m_hovered)
- drawShadowShape(painter);
+ if (m_hovered)
+ drawShadowShape(painter);
- if (isSelected())
- drawCross(m_rect.center(), painter);
+ if (isSelected())
+ drawCross(m_rect.center(), painter);
}
/**
- @brief PartArc::toXml
- Export this arc in xml
- @param xml_document : Xml document to use for create the xml element.
- @return : an xml element that describe this arc
+ @brief PartArc::toXml
+ Export this arc in xml
+ @param xml_document : Xml document to use for create the xml element.
+ @return : an xml element that describe this arc
*/
const QDomElement PartArc::toXml(QDomDocument &xml_document) const
{
- QDomElement xml_element = xml_document.createElement("arc");
- 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.setAttribute("width", QString("%1").arg(rect().width()));
- xml_element.setAttribute("height", QString("%1").arg(rect().height()));
- //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.setAttribute("angle", QString("%1").arg(m_span_angle / 16));
- stylesToXml(xml_element);
- return(xml_element);
+ QDomElement xml_element = xml_document.createElement("arc");
+ 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.setAttribute("width", QString("%1").arg(rect().width()));
+ xml_element.setAttribute("height", QString("%1").arg(rect().height()));
+ //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.setAttribute("angle", QString("%1").arg(m_span_angle / 16));
+ stylesToXml(xml_element);
+ return(xml_element);
}
/**
- @brief PartArc::fromXml
- Import the properties of this arc from a xml element.
- @param qde : Xml document to use.
+ @brief PartArc::fromXml
+ Import the properties of this arc from a xml element.
+ @param qde : Xml document to use.
*/
void PartArc::fromXml(const QDomElement &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()) );
+ 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;
- m_span_angle = qde.attribute("angle", "-1440").toDouble() * 16;
+ m_start_angle = qde.attribute("start", "0").toDouble() * 16;
+ m_span_angle = qde.attribute("angle", "-1440").toDouble() * 16;
}
/**
- @brief PartArc::shape
- @return the shape of this item
+ @brief PartArc::shape
+ @return the shape of this item
*/
QPainterPath PartArc::shape() const
{
- QPainterPath shape;
- shape.arcMoveTo(m_rect, m_start_angle/16);
- shape.arcTo(m_rect, m_start_angle /16, m_span_angle /16);
+ QPainterPath shape;
+ shape.arcMoveTo(m_rect, m_start_angle/16);
+ shape.arcTo(m_rect, m_start_angle /16, m_span_angle /16);
- QPainterPathStroker pps;
- pps.setWidth(m_hovered? penWeight()+SHADOWS_HEIGHT : penWeight());
- shape = pps.createStroke(shape);
+ QPainterPathStroker pps;
+ pps.setWidth(m_hovered? penWeight()+SHADOWS_HEIGHT : penWeight());
+ shape = pps.createStroke(shape);
- return shape;
+ return shape;
}
QPainterPath PartArc::shadowShape() const
{
- QPainterPath shape;
- shape.arcMoveTo(m_rect, m_start_angle/16);
- shape.arcTo(m_rect, m_start_angle /16, m_span_angle /16);
+ QPainterPath shape;
+ shape.arcMoveTo(m_rect, m_start_angle/16);
+ shape.arcTo(m_rect, m_start_angle /16, m_span_angle /16);
- QPainterPathStroker pps;
- pps.setWidth(penWeight());
+ QPainterPathStroker pps;
+ pps.setWidth(penWeight());
- return (pps.createStroke(shape));
+ return (pps.createStroke(shape));
}
/**
@@ -173,327 +173,327 @@ QPainterPath PartArc::shadowShape() const
*/
QRectF PartArc::sceneGeometricRect() const
{
- return mapToScene(QetGraphicsHandlerUtility::rectForArc(m_rect, m_start_angle/16, m_span_angle/16)).boundingRect();
+ return mapToScene(QetGraphicsHandlerUtility::rectForArc(m_rect, m_start_angle/16, m_span_angle/16)).boundingRect();
}
/**
- @brief PartArc::mouseReleaseEvent
- Handle mouse release event
- @param event
+ @brief PartArc::mouseReleaseEvent
+ Handle mouse release event
+ @param event
*/
void PartArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
- if (event->button() == Qt::LeftButton && event->buttonDownPos(Qt::LeftButton) == event->pos())
- switchResizeMode();
+ if (event->button() == Qt::LeftButton && event->buttonDownPos(Qt::LeftButton) == event->pos())
+ switchResizeMode();
- CustomElementGraphicPart::mouseReleaseEvent(event);
+ CustomElementGraphicPart::mouseReleaseEvent(event);
}
/**
- @brief PartArc::itemChange
- @param change
- @param value
- @return
+ @brief PartArc::itemChange
+ @param change
+ @param value
+ @return
*/
QVariant PartArc::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
- if (change == ItemSelectedHasChanged && scene())
- {
- if (value.toBool() == true)
- {
- //When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler,
- //according to the number of selected items.
- connect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged);
+ if (change == ItemSelectedHasChanged && scene())
+ {
+ if (value.toBool() == true)
+ {
+ //When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler,
+ //according to the number of selected items.
+ connect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged);
- if (scene()->selectedItems().size() == 1)
- addHandler();
- }
- else
- {
- disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged);
- removeHandler();
- }
- }
- else if (change == ItemPositionHasChanged)
- {
- adjusteHandlerPos();
- }
- else if (change == ItemSceneChange)
- {
- if(scene())
- disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged);
+ if (scene()->selectedItems().size() == 1)
+ addHandler();
+ }
+ else
+ {
+ disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged);
+ removeHandler();
+ }
+ }
+ else if (change == ItemPositionHasChanged)
+ {
+ adjusteHandlerPos();
+ }
+ else if (change == ItemSceneChange)
+ {
+ if(scene())
+ disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged);
- setSelected(false); //This is item removed from scene, then we deselect this, and so, the handlers is also removed.
- }
+ setSelected(false); //This is item removed from scene, then we deselect this, and so, the handlers is also removed.
+ }
- return QGraphicsItem::itemChange(change, value);
+ return QGraphicsItem::itemChange(change, value);
}
/**
- @brief PartArc::sceneEventFilter
- @param watched
- @param event
- @return
+ @brief PartArc::sceneEventFilter
+ @param watched
+ @param event
+ @return
*/
bool PartArc::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
{
- //Watched must be an handler
- if(watched->type() == QetGraphicsHandlerItem::Type)
- {
- QetGraphicsHandlerItem *qghi = qgraphicsitem_cast(watched);
+ //Watched must be an handler
+ if(watched->type() == QetGraphicsHandlerItem::Type)
+ {
+ QetGraphicsHandlerItem *qghi = qgraphicsitem_cast(watched);
- if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
- {
- m_vector_index = m_handler_vector.indexOf(qghi);
- if (m_vector_index != -1)
- {
- if(event->type() == QEvent::GraphicsSceneMousePress) //Click
- {
- handlerMousePressEvent(qghi, static_cast(event));
- return true;
- }
- else if(event->type() == QEvent::GraphicsSceneMouseMove) //Move
- {
- handlerMouseMoveEvent(qghi, static_cast(event));
- return true;
- }
- else if (event->type() == QEvent::GraphicsSceneMouseRelease) //Release
- {
- handlerMouseReleaseEvent(qghi, static_cast(event));
- return true;
- }
- }
- }
- }
+ if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
+ {
+ m_vector_index = m_handler_vector.indexOf(qghi);
+ if (m_vector_index != -1)
+ {
+ if(event->type() == QEvent::GraphicsSceneMousePress) //Click
+ {
+ handlerMousePressEvent(qghi, static_cast(event));
+ return true;
+ }
+ else if(event->type() == QEvent::GraphicsSceneMouseMove) //Move
+ {
+ handlerMouseMoveEvent(qghi, static_cast(event));
+ return true;
+ }
+ else if (event->type() == QEvent::GraphicsSceneMouseRelease) //Release
+ {
+ handlerMouseReleaseEvent(qghi, static_cast(event));
+ return true;
+ }
+ }
+ }
+ }
- return false;
+ return false;
}
/**
- @brief PartArc::switchResizeMode
+ @brief PartArc::switchResizeMode
*/
void PartArc::switchResizeMode()
{
- if (m_resize_mode == 1)
- {
- m_resize_mode = 2;
- for (QetGraphicsHandlerItem *qghi : m_handler_vector)
- qghi->setColor(Qt::darkGreen);
- }
- else if (m_resize_mode == 2)
- {
- m_resize_mode = 3;
+ if (m_resize_mode == 1)
+ {
+ m_resize_mode = 2;
+ for (QetGraphicsHandlerItem *qghi : m_handler_vector)
+ qghi->setColor(Qt::darkGreen);
+ }
+ else if (m_resize_mode == 2)
+ {
+ m_resize_mode = 3;
- //From rect mode to angle mode, then numbers of handlers change
- removeHandler();
- addHandler();
+ //From rect mode to angle mode, then numbers of handlers change
+ removeHandler();
+ addHandler();
- for (QetGraphicsHandlerItem *qghi : m_handler_vector)
- qghi->setColor(Qt::magenta);
- }
- else
- {
- m_resize_mode = 1;
+ for (QetGraphicsHandlerItem *qghi : m_handler_vector)
+ qghi->setColor(Qt::magenta);
+ }
+ else
+ {
+ m_resize_mode = 1;
- //From angle mode to rect mode, then numbers of handlers change
- removeHandler();
- addHandler();
+ //From angle mode to rect mode, then numbers of handlers change
+ removeHandler();
+ addHandler();
- for (QetGraphicsHandlerItem *qghi : m_handler_vector)
- qghi->setColor(Qt::blue);
- }
+ for (QetGraphicsHandlerItem *qghi : m_handler_vector)
+ qghi->setColor(Qt::blue);
+ }
}
/**
- @brief PartArc::adjusteHandlerPos
+ @brief PartArc::adjusteHandlerPos
*/
void PartArc::adjusteHandlerPos()
{
- if (m_handler_vector.isEmpty())
- return;
+ if (m_handler_vector.isEmpty())
+ return;
- QVector points_vector;
+ QVector points_vector;
- if(m_resize_mode == 3)
- points_vector = QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16);
- else
- points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect);
+ if(m_resize_mode == 3)
+ points_vector = QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16);
+ else
+ points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect);
- if (m_handler_vector.size() == points_vector.size())
- {
- points_vector = mapToScene(points_vector);
- for (int i = 0 ; i < points_vector.size() ; ++i)
- m_handler_vector.at(i)->setPos(points_vector.at(i));
- }
+ if (m_handler_vector.size() == points_vector.size())
+ {
+ points_vector = mapToScene(points_vector);
+ for (int i = 0 ; i < points_vector.size() ; ++i)
+ m_handler_vector.at(i)->setPos(points_vector.at(i));
+ }
}
/**
- @brief PartArc::handlerMousePressEvent
- @param qghi
- @param event
+ @brief PartArc::handlerMousePressEvent
+ @param qghi
+ @param event
*/
void PartArc::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
{
- Q_UNUSED(qghi)
- Q_UNUSED(event)
+ Q_UNUSED(qghi)
+ Q_UNUSED(event)
- if (m_resize_mode == 3) //Resize angle
- {
- if (m_vector_index == 0)
- {
- m_span_point = QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16).at(1);
+ if (m_resize_mode == 3) //Resize angle
+ {
+ if (m_vector_index == 0)
+ {
+ m_span_point = QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16).at(1);
- m_undo_command = new QPropertyUndoCommand(this, "startAngle", QVariant(m_start_angle));
- m_undo_command->setText(tr("Modifier un arc"));
- m_undo_command->enableAnimation();
+ m_undo_command = new QPropertyUndoCommand(this, "startAngle", QVariant(m_start_angle));
+ m_undo_command->setText(tr("Modifier un arc"));
+ m_undo_command->enableAnimation();
- m_undo_command2 = new QPropertyUndoCommand(this, "spanAngle", QVariant(m_span_angle), m_undo_command);
- m_undo_command2->setText(tr("Modifier un arc"));
- m_undo_command2->enableAnimation();
- }
- else if (m_vector_index == 1)
- {
- m_undo_command = new QPropertyUndoCommand(this, "spanAngle", QVariant(m_span_angle));
- m_undo_command->setText(tr("Modifier un arc"));
- m_undo_command->enableAnimation();
- }
- }
- else //resize rect
- {
- m_undo_command = new QPropertyUndoCommand(this, "rect", QVariant(m_rect));
- m_undo_command->setText(tr("Modifier un arc"));
- m_undo_command->enableAnimation();
- }
+ m_undo_command2 = new QPropertyUndoCommand(this, "spanAngle", QVariant(m_span_angle), m_undo_command);
+ m_undo_command2->setText(tr("Modifier un arc"));
+ m_undo_command2->enableAnimation();
+ }
+ else if (m_vector_index == 1)
+ {
+ m_undo_command = new QPropertyUndoCommand(this, "spanAngle", QVariant(m_span_angle));
+ m_undo_command->setText(tr("Modifier un arc"));
+ m_undo_command->enableAnimation();
+ }
+ }
+ else //resize rect
+ {
+ m_undo_command = new QPropertyUndoCommand(this, "rect", QVariant(m_rect));
+ m_undo_command->setText(tr("Modifier un arc"));
+ m_undo_command->enableAnimation();
+ }
}
/**
- @brief PartArc::handlerMouseMoveEvent
- @param qghi
- @param event
+ @brief PartArc::handlerMouseMoveEvent
+ @param qghi
+ @param event
*/
void PartArc::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
{
- Q_UNUSED(qghi)
+ Q_UNUSED(qghi)
- QPointF new_pos = event->scenePos();
- if (event->modifiers() != Qt::ControlModifier)
- new_pos = elementScene()->snapToGrid(event->scenePos());
- new_pos = mapFromScene(new_pos);
+ QPointF new_pos = event->scenePos();
+ if (event->modifiers() != Qt::ControlModifier)
+ new_pos = elementScene()->snapToGrid(event->scenePos());
+ new_pos = mapFromScene(new_pos);
- if (m_resize_mode == 1)
- setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index));
- else if (m_resize_mode == 2)
- setRect(QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(m_rect, new_pos, m_vector_index));
- else
- {
- QLineF line(m_rect.center(), mapFromScene(event->scenePos()));
- prepareGeometryChange();
+ if (m_resize_mode == 1)
+ setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index));
+ else if (m_resize_mode == 2)
+ setRect(QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(m_rect, new_pos, m_vector_index));
+ else
+ {
+ QLineF line(m_rect.center(), mapFromScene(event->scenePos()));
+ prepareGeometryChange();
- if (m_vector_index == 0) {
- setStartAngle(line.angle()*16);
- setSpanAngle(line.angleTo(QLineF(m_rect.center(), m_span_point))*16);
- }
- else if (m_vector_index == 1) {
- QLineF line2(m_rect.center(), QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16).at(0));
- setSpanAngle (line2.angleTo(line)*16);
- }
- }
+ if (m_vector_index == 0) {
+ setStartAngle(line.angle()*16);
+ setSpanAngle(line.angleTo(QLineF(m_rect.center(), m_span_point))*16);
+ }
+ else if (m_vector_index == 1) {
+ QLineF line2(m_rect.center(), QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16).at(0));
+ setSpanAngle (line2.angleTo(line)*16);
+ }
+ }
}
/**
- @brief PartArc::handlerMouseReleaseEvent
- @param qghi
- @param event
+ @brief PartArc::handlerMouseReleaseEvent
+ @param qghi
+ @param event
*/
void PartArc::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
{
- Q_UNUSED(qghi)
- Q_UNUSED(event)
+ Q_UNUSED(qghi)
+ Q_UNUSED(event)
- if (m_resize_mode == 3)
- {
- if (m_vector_index == 0)
- {
- m_undo_command->setNewValue(QVariant(m_start_angle));
- m_undo_command2->setNewValue(QVariant(m_span_angle));
- elementScene()->undoStack().push(m_undo_command);
- m_undo_command = nullptr;
- m_undo_command2 = nullptr;
- m_vector_index = -1;
- }
- else if (m_vector_index == 1)
- {
- m_undo_command->setNewValue(QVariant(m_span_angle));
- elementScene()->undoStack().push(m_undo_command);
- m_undo_command = nullptr;
- m_vector_index = -1;
- }
- }
- else
- {
- if (!m_rect.isValid())
- m_rect = m_rect.normalized();
+ if (m_resize_mode == 3)
+ {
+ if (m_vector_index == 0)
+ {
+ m_undo_command->setNewValue(QVariant(m_start_angle));
+ m_undo_command2->setNewValue(QVariant(m_span_angle));
+ elementScene()->undoStack().push(m_undo_command);
+ m_undo_command = nullptr;
+ m_undo_command2 = nullptr;
+ m_vector_index = -1;
+ }
+ else if (m_vector_index == 1)
+ {
+ m_undo_command->setNewValue(QVariant(m_span_angle));
+ elementScene()->undoStack().push(m_undo_command);
+ m_undo_command = nullptr;
+ m_vector_index = -1;
+ }
+ }
+ else
+ {
+ if (!m_rect.isValid())
+ m_rect = m_rect.normalized();
- m_undo_command->setNewValue(QVariant(m_rect));
- elementScene()->undoStack().push(m_undo_command);
- m_undo_command = nullptr;
- m_vector_index = -1;
- }
+ m_undo_command->setNewValue(QVariant(m_rect));
+ elementScene()->undoStack().push(m_undo_command);
+ m_undo_command = nullptr;
+ m_vector_index = -1;
+ }
}
/**
- @brief PartArc::sceneSelectionChanged
- When the scene selection change, if there are several primitive selected, we remove the handler of this item
+ @brief PartArc::sceneSelectionChanged
+ When the scene selection change, if there are several primitive selected, we remove the handler of this item
*/
void PartArc::sceneSelectionChanged()
{
- if (this->isSelected() && scene()->selectedItems().size() == 1)
- addHandler();
- else
- removeHandler();
+ if (this->isSelected() && scene()->selectedItems().size() == 1)
+ addHandler();
+ else
+ removeHandler();
}
/**
- @brief PartArc::addHandler
- Add handlers for this item
+ @brief PartArc::addHandler
+ Add handlers for this item
*/
void PartArc::addHandler()
{
- if (m_handler_vector.isEmpty() && scene())
- {
- if(m_resize_mode == 3)
- {
- m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16)));
- }
- else
- m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
+ if (m_handler_vector.isEmpty() && scene())
+ {
+ if(m_resize_mode == 3)
+ {
+ m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16)));
+ }
+ else
+ m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
- for(QetGraphicsHandlerItem *handler : m_handler_vector)
- {
- QColor color = Qt::blue;
- if (m_resize_mode == 2)
- color = Qt::darkGreen;
- else if (m_resize_mode == 3)
- color = Qt::magenta;
+ for(QetGraphicsHandlerItem *handler : m_handler_vector)
+ {
+ QColor color = Qt::blue;
+ if (m_resize_mode == 2)
+ color = Qt::darkGreen;
+ else if (m_resize_mode == 3)
+ color = Qt::magenta;
- handler->setColor(color);
- scene()->addItem(handler);
- handler->installSceneEventFilter(this);
- handler->setZValue(this->zValue()+1);
- }
- }
+ handler->setColor(color);
+ scene()->addItem(handler);
+ handler->installSceneEventFilter(this);
+ handler->setZValue(this->zValue()+1);
+ }
+ }
}
/**
- @brief PartArc::removeHandler
- Remove the handlers of this item
+ @brief PartArc::removeHandler
+ Remove the handlers of this item
*/
void PartArc::removeHandler()
{
- if (!m_handler_vector.isEmpty())
- {
- qDeleteAll(m_handler_vector);
- m_handler_vector.clear();
- }
+ if (!m_handler_vector.isEmpty())
+ {
+ qDeleteAll(m_handler_vector);
+ m_handler_vector.clear();
+ }
}
diff --git a/sources/editor/graphicspart/partarc.h b/sources/editor/graphicspart/partarc.h
index 9026f833f..2cb00a545 100644
--- a/sources/editor/graphicspart/partarc.h
+++ b/sources/editor/graphicspart/partarc.h
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#ifndef PART_ARC_H
#define PART_ARC_H
@@ -24,65 +24,65 @@ class QPropertyUndoCommand;
class QetGraphicsHandlerItem;
/**
- @brief The PartArc class
- This class represents an elliptical arc primitive which may be used to
- compose the drawing of an electrical element within the element editor.
+ @brief The PartArc class
+ This class represents an elliptical arc primitive which may be used to
+ compose the drawing of an electrical element within the element editor.
*/
class PartArc : public AbstractPartEllipse
{
- Q_OBJECT
+ Q_OBJECT
- public:
- PartArc(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
- ~PartArc() override;
-
- private:
- PartArc(const PartArc &);
- // methods
- public:
- enum { Type = UserType + 1101 };
- /**
- Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartArc.
- @return the QGraphicsItem type
- */
- int type() const override { return Type; }
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
+ public:
+ PartArc(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
+ ~PartArc() override;
+
+ private:
+ PartArc(const PartArc &);
+ // methods
+ public:
+ enum { Type = UserType + 1101 };
+ /**
+ Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartArc.
+ @return the QGraphicsItem type
+ */
+ int type() const override { return Type; }
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
- //Name and XML
- QString name() const override { return(QObject::tr("arc", "element part name")); }
- QString xmlName() const override { return(QString("arc")); }
- const QDomElement toXml (QDomDocument &) const override;
- void fromXml (const QDomElement &) override;
+ //Name and XML
+ QString name() const override { return(QObject::tr("arc", "element part name")); }
+ QString xmlName() const override { return(QString("arc")); }
+ const QDomElement toXml (QDomDocument &) const override;
+ void fromXml (const QDomElement &) override;
- QPainterPath shape() const override;
- QPainterPath shadowShape() const override;
- void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
- void setStartAngle(const int &start_angle) override {AbstractPartEllipse::setStartAngle(start_angle); adjusteHandlerPos();}
- void setSpanAngle(const int &span_angle) override {AbstractPartEllipse::setSpanAngle(span_angle); adjusteHandlerPos();}
- QRectF sceneGeometricRect() const override;
+ QPainterPath shape() const override;
+ QPainterPath shadowShape() const override;
+ void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
+ void setStartAngle(const int &start_angle) override {AbstractPartEllipse::setStartAngle(start_angle); adjusteHandlerPos();}
+ void setSpanAngle(const int &span_angle) override {AbstractPartEllipse::setSpanAngle(span_angle); adjusteHandlerPos();}
+ QRectF sceneGeometricRect() const override;
- protected:
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
- QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
- bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
+ protected:
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
+ bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
- private:
- void switchResizeMode();
- void adjusteHandlerPos();
- void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
- void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
- void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
- void sceneSelectionChanged ();
-
- void addHandler();
- void removeHandler();
+ private:
+ void switchResizeMode();
+ void adjusteHandlerPos();
+ void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
+ void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
+ void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
+ void sceneSelectionChanged ();
+
+ void addHandler();
+ void removeHandler();
- private:
- QPropertyUndoCommand *m_undo_command = nullptr;
- QPropertyUndoCommand *m_undo_command2 = nullptr;
- int m_resize_mode = 1,
- m_vector_index = -1;
- QPointF m_span_point;
- QVector m_handler_vector;
+ private:
+ QPropertyUndoCommand *m_undo_command = nullptr;
+ QPropertyUndoCommand *m_undo_command2 = nullptr;
+ int m_resize_mode = 1,
+ m_vector_index = -1;
+ QPointF m_span_point;
+ QVector m_handler_vector;
};
#endif
diff --git a/sources/editor/graphicspart/partdynamictextfield.cpp b/sources/editor/graphicspart/partdynamictextfield.cpp
index a425628d3..e40a80f70 100644
--- a/sources/editor/graphicspart/partdynamictextfield.cpp
+++ b/sources/editor/graphicspart/partdynamictextfield.cpp
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#include "partdynamictextfield.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
@@ -25,574 +25,574 @@
#include
PartDynamicTextField::PartDynamicTextField(QETElementEditor *editor, QGraphicsItem *parent) :
- QGraphicsTextItem(parent),
- CustomElementPart(editor),
- m_uuid(QUuid::createUuid())
+ QGraphicsTextItem(parent),
+ CustomElementPart(editor),
+ m_uuid(QUuid::createUuid())
{
- setDefaultTextColor(Qt::black);
- setFont(QETApp::dynamicTextsItemFont());
- QSettings settings;
- setRotation(settings.value("diagrameditor/dynamic_text_rotation", 0).toInt());
- setTextWidth(settings.value("diagrameditor/dynamic_text_width", -1).toInt());
- setText("_");
- setTextFrom(DynamicElementTextItem::UserText);
- setFlags(
- QGraphicsItem::ItemIsSelectable |
- QGraphicsItem::ItemSendsGeometryChanges |
- QGraphicsItem::ItemIsMovable
- );
+ setDefaultTextColor(Qt::black);
+ setFont(QETApp::dynamicTextsItemFont());
+ QSettings settings;
+ setRotation(settings.value("diagrameditor/dynamic_text_rotation", 0).toInt());
+ setTextWidth(settings.value("diagrameditor/dynamic_text_width", -1).toInt());
+ setText("_");
+ setTextFrom(DynamicElementTextItem::UserText);
+ setFlags(
+ QGraphicsItem::ItemIsSelectable |
+ QGraphicsItem::ItemSendsGeometryChanges |
+ QGraphicsItem::ItemIsMovable
+ );
- //Option when text is displayed in multiple line
- QTextOption option = document() -> defaultTextOption();
- option.setAlignment(Qt::AlignHCenter);
- option.setWrapMode(QTextOption::WordWrap);
- document() -> setDefaultTextOption(option);
+ //Option when text is displayed in multiple line
+ QTextOption option = document() -> defaultTextOption();
+ option.setAlignment(Qt::AlignHCenter);
+ option.setWrapMode(QTextOption::WordWrap);
+ document() -> setDefaultTextOption(option);
}
QString PartDynamicTextField::name() const
{
- return tr("Champ de texte dynamique", "element part name");
+ return tr("Champ de texte dynamique", "element part name");
}
QString PartDynamicTextField::xmlName() const
{
- return QString("dynamic_text");
+ return QString("dynamic_text");
}
/**
- @brief PartDynamicTextField::startUserTransformation
- @param initial_selection_rect
- Start the user-induced transformation,
- provided this primitive is contained
- within the initial_selection_rect bounding rectangle.
+ @brief PartDynamicTextField::startUserTransformation
+ @param initial_selection_rect
+ Start the user-induced transformation,
+ provided this primitive is contained
+ within the initial_selection_rect bounding rectangle.
*/
void PartDynamicTextField::startUserTransformation(const QRectF &initial_selection_rect) {
- Q_UNUSED(initial_selection_rect)
- m_saved_point = pos(); // scene coordinates, no need to mapFromScene()
+ Q_UNUSED(initial_selection_rect)
+ m_saved_point = pos(); // scene coordinates, no need to mapFromScene()
}
/**
- @brief PartDynamicTextField::handleUserTransformation
- @param initial_selection_rect
- @param new_selection_rect
- Handle the user-induced transformation
- from initial_selection_rect to new_selection_rect
+ @brief PartDynamicTextField::handleUserTransformation
+ @param initial_selection_rect
+ @param new_selection_rect
+ Handle the user-induced transformation
+ from initial_selection_rect to new_selection_rect
*/
void PartDynamicTextField::handleUserTransformation(
- const QRectF &initial_selection_rect,
- const QRectF &new_selection_rect)
+ const QRectF &initial_selection_rect,
+ const QRectF &new_selection_rect)
{
- QPointF new_pos = mapPoints(
- initial_selection_rect, new_selection_rect, QList() << m_saved_point).first();
- setPos(new_pos);
+ QPointF new_pos = mapPoints(
+ initial_selection_rect, new_selection_rect, QList() << m_saved_point).first();
+ setPos(new_pos);
}
/**
- @brief PartDynamicTextField::toXml
- @param dom_doc
- @return
+ @brief PartDynamicTextField::toXml
+ @param dom_doc
+ @return
*/
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.setAttribute("y", QString::number(pos().y()));
- root_element.setAttribute("z", QString::number(zValue()));
- root_element.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
- root_element.setAttribute("font", font().toString());
- root_element.setAttribute("uuid", m_uuid.toString());
- root_element.setAttribute("frame", m_frame? "true" : "false");
- root_element.setAttribute("text_width", QString::number(m_text_width));
+ root_element.setAttribute("x", QString::number(pos().x()));
+ root_element.setAttribute("y", QString::number(pos().y()));
+ root_element.setAttribute("z", QString::number(zValue()));
+ root_element.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
+ root_element.setAttribute("font", font().toString());
+ root_element.setAttribute("uuid", m_uuid.toString());
+ root_element.setAttribute("frame", m_frame? "true" : "false");
+ root_element.setAttribute("text_width", QString::number(m_text_width));
- QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
- root_element.setAttribute("text_from", me.valueToKey(m_text_from));
+ QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
+ root_element.setAttribute("text_from", me.valueToKey(m_text_from));
- me = QMetaEnum::fromType();
- if(this -> alignment() &Qt::AlignRight)
- root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignRight));
- else if(this -> alignment() &Qt::AlignLeft)
- root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignLeft));
- else if(this -> alignment() &Qt::AlignHCenter)
- root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignHCenter));
+ me = QMetaEnum::fromType();
+ if(this -> alignment() &Qt::AlignRight)
+ root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignRight));
+ else if(this -> alignment() &Qt::AlignLeft)
+ root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignLeft));
+ else if(this -> alignment() &Qt::AlignHCenter)
+ root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignHCenter));
- if(this -> alignment() &Qt::AlignBottom)
- root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignBottom));
- else if(this -> alignment() & Qt::AlignTop)
- root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignTop));
- else if(this -> alignment() &Qt::AlignVCenter)
- root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignVCenter));
+ if(this -> alignment() &Qt::AlignBottom)
+ root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignBottom));
+ else if(this -> alignment() & Qt::AlignTop)
+ root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignTop));
+ else if(this -> alignment() &Qt::AlignVCenter)
+ root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignVCenter));
- QDomElement dom_text = dom_doc.createElement("text");
- dom_text.appendChild(dom_doc.createTextNode(toPlainText()));
- root_element.appendChild(dom_text);
+ QDomElement dom_text = dom_doc.createElement("text");
+ dom_text.appendChild(dom_doc.createTextNode(toPlainText()));
+ root_element.appendChild(dom_text);
- //Info name
- if(!m_info_name.isEmpty()) {
- QDomElement dom_info_name = dom_doc.createElement("info_name");
- dom_info_name.appendChild(dom_doc.createTextNode(m_info_name));
- root_element.appendChild(dom_info_name);
- }
+ //Info name
+ if(!m_info_name.isEmpty()) {
+ QDomElement dom_info_name = dom_doc.createElement("info_name");
+ dom_info_name.appendChild(dom_doc.createTextNode(m_info_name));
+ root_element.appendChild(dom_info_name);
+ }
- //Composite text
- if(!m_composite_text.isEmpty()) {
- QDomElement dom_comp_text = dom_doc.createElement("composite_text");
- dom_comp_text.appendChild(dom_doc.createTextNode(m_composite_text));
- root_element.appendChild(dom_comp_text);
- }
+ //Composite text
+ if(!m_composite_text.isEmpty()) {
+ QDomElement dom_comp_text = dom_doc.createElement("composite_text");
+ dom_comp_text.appendChild(dom_doc.createTextNode(m_composite_text));
+ root_element.appendChild(dom_comp_text);
+ }
- //Color
- if(color() != QColor(Qt::black)) {
- QDomElement dom_color = dom_doc.createElement("color");
- dom_color.appendChild(dom_doc.createTextNode(color().name()));
- root_element.appendChild(dom_color);
- }
+ //Color
+ if(color() != QColor(Qt::black)) {
+ QDomElement dom_color = dom_doc.createElement("color");
+ dom_color.appendChild(dom_doc.createTextNode(color().name()));
+ root_element.appendChild(dom_color);
+ }
- return root_element;
+ return root_element;
}
/**
- @brief PartDynamicTextField::fromXml
- @param dom_elmt
+ @brief PartDynamicTextField::fromXml
+ @param dom_elmt
*/
void PartDynamicTextField::fromXml(const QDomElement &dom_elmt) {
- if (dom_elmt.tagName() != xmlName()) {
- qDebug() << "PartDynamicTextField::fromXml : Wrong tagg name";
- return;
- }
+ if (dom_elmt.tagName() != xmlName()) {
+ qDebug() << "PartDynamicTextField::fromXml : Wrong tagg name";
+ return;
+ }
- QGraphicsTextItem::setPos(
- dom_elmt.attribute("x", QString::number(0)).toDouble(),
- dom_elmt.attribute("y", QString::number(0)).toDouble()
- );
- setZValue(dom_elmt.attribute("z", QString::number(zValue())).toDouble());
- QGraphicsTextItem::setRotation(dom_elmt.attribute("rotation", QString::number(0)).toDouble());
+ QGraphicsTextItem::setPos(
+ dom_elmt.attribute("x", QString::number(0)).toDouble(),
+ dom_elmt.attribute("y", QString::number(0)).toDouble()
+ );
+ setZValue(dom_elmt.attribute("z", QString::number(zValue())).toDouble());
+ QGraphicsTextItem::setRotation(dom_elmt.attribute("rotation", QString::number(0)).toDouble());
- if (dom_elmt.hasAttribute("font")) {
- QFont font_;
- font_.fromString(dom_elmt.attribute("font"));
- setFont(font_);
- }
- else {
+ if (dom_elmt.hasAttribute("font")) {
+ QFont font_;
+ font_.fromString(dom_elmt.attribute("font"));
+ setFont(font_);
+ }
+ else {
#if TODO_LIST
#pragma message("@TODO remove in futur")
#endif
- //Keep compatibility TODO remove in futur
- setFont(QETApp::dynamicTextsItemFont(9));
- }
+ //Keep compatibility TODO remove in futur
+ setFont(QETApp::dynamicTextsItemFont(9));
+ }
- m_uuid = QUuid(dom_elmt.attribute("uuid", QUuid::createUuid().toString()));
- setFrame(dom_elmt.attribute("frame", "false") == "true"? true : false);
- setTextWidth(dom_elmt.attribute("text_width", QString::number(-1)).toDouble());
+ m_uuid = QUuid(dom_elmt.attribute("uuid", QUuid::createUuid().toString()));
+ setFrame(dom_elmt.attribute("frame", "false") == "true"? true : false);
+ setTextWidth(dom_elmt.attribute("text_width", QString::number(-1)).toDouble());
- QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
- m_text_from = DynamicElementTextItem::TextFrom(
- me.keyToValue(dom_elmt.attribute("text_from").toStdString().data()));
+ QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
+ m_text_from = DynamicElementTextItem::TextFrom(
+ me.keyToValue(dom_elmt.attribute("text_from").toStdString().data()));
- me = QMetaEnum::fromType();
- if(dom_elmt.hasAttribute("Halignment"))
- setAlignment(Qt::Alignment(
- me.keyToValue(dom_elmt.attribute("Halignment").toStdString().data())));
- if(dom_elmt.hasAttribute(("Valignment")))
- setAlignment(Qt::Alignment(
- me.keyToValue(dom_elmt.attribute("Valignment").toStdString().data())) | this -> alignment());
+ me = QMetaEnum::fromType();
+ if(dom_elmt.hasAttribute("Halignment"))
+ setAlignment(Qt::Alignment(
+ me.keyToValue(dom_elmt.attribute("Halignment").toStdString().data())));
+ if(dom_elmt.hasAttribute(("Valignment")))
+ setAlignment(Qt::Alignment(
+ me.keyToValue(dom_elmt.attribute("Valignment").toStdString().data())) | this -> alignment());
- //Text
- QDomElement dom_text = dom_elmt.firstChildElement("text");
- if (!dom_text.isNull()) {
- m_text = dom_text.text();
- m_block_alignment = true;
- setPlainText(m_text);
- m_block_alignment = false;
- }
+ //Text
+ QDomElement dom_text = dom_elmt.firstChildElement("text");
+ if (!dom_text.isNull()) {
+ m_text = dom_text.text();
+ m_block_alignment = true;
+ setPlainText(m_text);
+ m_block_alignment = false;
+ }
- //Info name
- QDomElement dom_info_name = dom_elmt.firstChildElement("info_name");
- if(!dom_info_name.isNull())
- m_info_name = dom_info_name.text();
+ //Info name
+ QDomElement dom_info_name = dom_elmt.firstChildElement("info_name");
+ if(!dom_info_name.isNull())
+ m_info_name = dom_info_name.text();
- //Composite text
- QDomElement dom_comp_text = dom_elmt.firstChildElement("composite_text");
- if(!dom_comp_text.isNull())
- m_composite_text = dom_comp_text.text();
+ //Composite text
+ QDomElement dom_comp_text = dom_elmt.firstChildElement("composite_text");
+ if(!dom_comp_text.isNull())
+ m_composite_text = dom_comp_text.text();
- //Color
- QDomElement dom_color = dom_elmt.firstChildElement("color");
- if(!dom_color.isNull())
- setColor(QColor(dom_color.text()));
+ //Color
+ QDomElement dom_color = dom_elmt.firstChildElement("color");
+ if(!dom_color.isNull())
+ setColor(QColor(dom_color.text()));
}
/**
- @brief PartDynamicTextField::fromTextFieldXml
- Setup this text from the xml definition
- of a text field (The xml tagg of a text field is "input");
- @param dom_element
+ @brief PartDynamicTextField::fromTextFieldXml
+ Setup this text from the xml definition
+ of a text field (The xml tagg of a text field is "input");
+ @param dom_element
*/
void PartDynamicTextField::fromTextFieldXml(const QDomElement &dom_element)
{
- if(dom_element.tagName() != "input")
- return;
+ if(dom_element.tagName() != "input")
+ return;
- setFont(QETApp::diagramTextsFont(dom_element.attribute("size", QString::number(9)).toInt()));
+ setFont(QETApp::diagramTextsFont(dom_element.attribute("size", QString::number(9)).toInt()));
- if(dom_element.attribute("tagg", "none") == "none") {
- setTextFrom(DynamicElementTextItem::UserText);
- setText(dom_element.attribute("text", "_"));
- }
- else {
- setTextFrom(DynamicElementTextItem::ElementInfo);
- setInfoName(dom_element.attribute("tagg", "label"));
- }
+ if(dom_element.attribute("tagg", "none") == "none") {
+ setTextFrom(DynamicElementTextItem::UserText);
+ setText(dom_element.attribute("text", "_"));
+ }
+ else {
+ setTextFrom(DynamicElementTextItem::ElementInfo);
+ setInfoName(dom_element.attribute("tagg", "label"));
+ }
- QGraphicsTextItem::setRotation(dom_element.attribute("rotation", "0").toDouble());
+ QGraphicsTextItem::setRotation(dom_element.attribute("rotation", "0").toDouble());
- //the origin transformation point of PartDynamicTextField is the top left corner, no matter the font size
- //The origin transformation point of PartTextField is the middle of left edge, and so by definition, change with the size of the font
- //We need to use a QTransform to find the pos of this text from the saved pos of text item
- QTransform transform;
- //First make the rotation
- transform.rotate(dom_element.attribute("rotation", "0").toDouble());
- QPointF pos = transform.map(QPointF(0, -boundingRect().height()/2));
- transform.reset();
- //Second translate to the pos
- transform.translate(
- dom_element.attribute("x", QString::number(0)).toDouble(),
- dom_element.attribute("y", QString::number(0)).toDouble()
- );
- QGraphicsTextItem::setPos(transform.map(pos));
+ //the origin transformation point of PartDynamicTextField is the top left corner, no matter the font size
+ //The origin transformation point of PartTextField is the middle of left edge, and so by definition, change with the size of the font
+ //We need to use a QTransform to find the pos of this text from the saved pos of text item
+ QTransform transform;
+ //First make the rotation
+ transform.rotate(dom_element.attribute("rotation", "0").toDouble());
+ QPointF pos = transform.map(QPointF(0, -boundingRect().height()/2));
+ transform.reset();
+ //Second translate to the pos
+ transform.translate(
+ dom_element.attribute("x", QString::number(0)).toDouble(),
+ dom_element.attribute("y", QString::number(0)).toDouble()
+ );
+ QGraphicsTextItem::setPos(transform.map(pos));
}
/**
- @brief PartDynamicTextField::textFrom
- @return what the final text is created from.
+ @brief PartDynamicTextField::textFrom
+ @return what the final text is created from.
*/
DynamicElementTextItem::TextFrom PartDynamicTextField::textFrom() const
{
- return m_text_from;
+ return m_text_from;
}
/**
- @brief PartDynamicTextField::setTextFrom
- Set the final text is created from.
- @param text_from
+ @brief PartDynamicTextField::setTextFrom
+ Set the final text is created from.
+ @param text_from
*/
void PartDynamicTextField::setTextFrom(DynamicElementTextItem::TextFrom text_from) {
- m_text_from = text_from;
- switch (m_text_from) {
- case DynamicElementTextItem::UserText:
- setPlainText(m_text);
- break;
- case DynamicElementTextItem::ElementInfo:
- setInfoName(m_info_name);
- break;
- case DynamicElementTextItem::CompositeText:
- setCompositeText(m_composite_text);
- break;
- default:
- break;
- }
- emit textFromChanged(m_text_from);
+ m_text_from = text_from;
+ switch (m_text_from) {
+ case DynamicElementTextItem::UserText:
+ setPlainText(m_text);
+ break;
+ case DynamicElementTextItem::ElementInfo:
+ setInfoName(m_info_name);
+ break;
+ case DynamicElementTextItem::CompositeText:
+ setCompositeText(m_composite_text);
+ break;
+ default:
+ break;
+ }
+ emit textFromChanged(m_text_from);
}
/**
- @brief PartDynamicTextField::text
- @return the text of this text
+ @brief PartDynamicTextField::text
+ @return the text of this text
*/
QString PartDynamicTextField::text() const
{
- return m_text;
+ return m_text;
}
/**
- @brief PartDynamicTextField::setText
- Set the text of this text
- @param text
+ @brief PartDynamicTextField::setText
+ Set the text of this text
+ @param text
*/
void PartDynamicTextField::setText(const QString &text) {
- m_text = text;
- setPlainText(m_text);
- emit textChanged(m_text);
+ m_text = text;
+ setPlainText(m_text);
+ emit textChanged(m_text);
}
void PartDynamicTextField::setInfoName(const QString &info_name) {
- m_info_name = info_name;
- if(m_text_from == DynamicElementTextItem::ElementInfo && elementScene())
- setPlainText(elementScene() -> elementInformation().value(m_info_name).toString());
- emit infoNameChanged(m_info_name);
+ m_info_name = info_name;
+ if(m_text_from == DynamicElementTextItem::ElementInfo && elementScene())
+ setPlainText(elementScene() -> elementInformation().value(m_info_name).toString());
+ emit infoNameChanged(m_info_name);
}
/**
- @brief PartDynamicTextField::infoName
- @return the info name of this text
+ @brief PartDynamicTextField::infoName
+ @return the info name of this text
*/
QString PartDynamicTextField::infoName() const{
- return m_info_name;
+ return m_info_name;
}
/**
- @brief PartDynamicTextField::setCompositeText
- Set the composite text of this text item to text
- @param text
+ @brief PartDynamicTextField::setCompositeText
+ Set the composite text of this text item to text
+ @param text
*/
void PartDynamicTextField::setCompositeText(const QString &text) {
- m_composite_text = text;
- if(m_text_from == DynamicElementTextItem::CompositeText && elementScene())
- setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, elementScene() -> elementInformation()));
- emit compositeTextChanged(m_composite_text);
+ m_composite_text = text;
+ if(m_text_from == DynamicElementTextItem::CompositeText && elementScene())
+ setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, elementScene() -> elementInformation()));
+ emit compositeTextChanged(m_composite_text);
}
/**
- @brief PartDynamicTextField::compositeText
- @return the composite text of this text
+ @brief PartDynamicTextField::compositeText
+ @return the composite text of this text
*/
QString PartDynamicTextField::compositeText() const
{
- return m_composite_text;
+ return m_composite_text;
}
/**
- @brief PartDynamicTextField::setColor
- @param color set text color to color
+ @brief PartDynamicTextField::setColor
+ @param color set text color to color
*/
void PartDynamicTextField::setColor(const QColor& color) {
- setDefaultTextColor(color);
- emit colorChanged(color);
+ setDefaultTextColor(color);
+ emit colorChanged(color);
}
/**
- @brief PartDynamicTextField::color
- @return The color of this text
+ @brief PartDynamicTextField::color
+ @return The color of this text
*/
QColor PartDynamicTextField::color() const
{
- return defaultTextColor();
+ return defaultTextColor();
}
void PartDynamicTextField::setFrame(bool frame) {
- m_frame = frame;
- update();
- emit frameChanged(m_frame);
+ m_frame = frame;
+ update();
+ emit frameChanged(m_frame);
}
bool PartDynamicTextField::frame() const
{
- return m_frame;
+ return m_frame;
}
void PartDynamicTextField::setTextWidth(qreal width) {
- this -> document() -> setTextWidth(width);
+ this -> document() -> setTextWidth(width);
- //Adjust the width, to ideal width if needed
- if(width > 0 && document() -> size().width() > width)
- document() -> setTextWidth(document() -> idealWidth());
+ //Adjust the width, to ideal width if needed
+ if(width > 0 && document() -> size().width() > width)
+ document() -> setTextWidth(document() -> idealWidth());
- m_text_width = document() -> textWidth();
- emit textWidthChanged(m_text_width);
+ m_text_width = document() -> textWidth();
+ emit textWidthChanged(m_text_width);
}
void PartDynamicTextField::setPlainText(const QString &text) {
- if(toPlainText() == text)
- return;
+ if(toPlainText() == text)
+ return;
- prepareAlignment();
- QGraphicsTextItem::setPlainText(text);
+ prepareAlignment();
+ QGraphicsTextItem::setPlainText(text);
- //User define a text width
- if(m_text_width > 0) {
- if(document() -> size().width() > m_text_width) {
- document() -> setTextWidth(m_text_width);
- if(document() -> size().width() > m_text_width) {
- document() -> setTextWidth(document() -> idealWidth());
- }
- }
- }
- finishAlignment();
+ //User define a text width
+ if(m_text_width > 0) {
+ if(document() -> size().width() > m_text_width) {
+ document() -> setTextWidth(m_text_width);
+ if(document() -> size().width() > m_text_width) {
+ document() -> setTextWidth(document() -> idealWidth());
+ }
+ }
+ }
+ finishAlignment();
}
void PartDynamicTextField::setAlignment(Qt::Alignment alignment) {
- m_alignment = alignment;
- emit alignmentChanged(m_alignment);
+ m_alignment = alignment;
+ emit alignmentChanged(m_alignment);
}
Qt::Alignment PartDynamicTextField::alignment() const
{
- return m_alignment;
+ return m_alignment;
}
void PartDynamicTextField::setFont(const QFont &font) {
- if (font == this -> font()) {
- return;
- }
- prepareAlignment();
- QGraphicsTextItem::setFont(font);
- finishAlignment();
- emit fontChanged(font);
+ if (font == this -> font()) {
+ return;
+ }
+ prepareAlignment();
+ QGraphicsTextItem::setFont(font);
+ finishAlignment();
+ emit fontChanged(font);
}
/**
- @brief PartDynamicTextField::mouseMoveEvent
- @param event
+ @brief PartDynamicTextField::mouseMoveEvent
+ @param event
*/
void PartDynamicTextField::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
- if((event -> buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable)) {
- QPointF pos = event -> scenePos() + (m_origine_pos - event -> buttonDownScenePos(Qt::LeftButton));
- event -> modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene() -> snapToGrid(pos));
- }
- else
- QGraphicsObject::mouseMoveEvent(event);
+ if((event -> buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable)) {
+ QPointF pos = event -> scenePos() + (m_origine_pos - event -> buttonDownScenePos(Qt::LeftButton));
+ event -> modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene() -> snapToGrid(pos));
+ }
+ else
+ QGraphicsObject::mouseMoveEvent(event);
}
/**
- @brief PartDynamicTextField::mousePressEvent
- @param event
+ @brief PartDynamicTextField::mousePressEvent
+ @param event
*/
void PartDynamicTextField::mousePressEvent(QGraphicsSceneMouseEvent *event) {
- if(event -> button() == Qt::LeftButton)
- m_origine_pos = this -> pos();
+ if(event -> button() == Qt::LeftButton)
+ m_origine_pos = this -> pos();
- QGraphicsObject::mousePressEvent(event);
+ QGraphicsObject::mousePressEvent(event);
}
/**
- @brief PartDynamicTextField::mouseReleaseEvent
- @param event
+ @brief PartDynamicTextField::mouseReleaseEvent
+ @param event
*/
void PartDynamicTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
- if((event -> button() & Qt::LeftButton) &&
- (flags() & QGraphicsItem::ItemIsMovable) &&
- m_origine_pos != pos()) {
- QPropertyUndoCommand *undo =\
- new QPropertyUndoCommand(this, "pos", QVariant(m_origine_pos), QVariant(pos()));
- undo -> setText(tr("Déplacer un champ texte"));
- undo -> enableAnimation();
- elementScene() -> undoStack().push(undo);
- }
+ if((event -> button() & Qt::LeftButton) &&
+ (flags() & QGraphicsItem::ItemIsMovable) &&
+ m_origine_pos != pos()) {
+ QPropertyUndoCommand *undo =\
+ new QPropertyUndoCommand(this, "pos", QVariant(m_origine_pos), QVariant(pos()));
+ undo -> setText(tr("D??placer un champ texte"));
+ undo -> enableAnimation();
+ elementScene() -> undoStack().push(undo);
+ }
- QGraphicsObject::mouseReleaseEvent(event);
+ QGraphicsObject::mouseReleaseEvent(event);
}
/**
- @brief PartDynamicTextField::itemChange
- @param change
- @param value
- @return
+ @brief PartDynamicTextField::itemChange
+ @param change
+ @param value
+ @return
*/
QVariant PartDynamicTextField::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) {
- if (change == QGraphicsItem::ItemPositionHasChanged || change == QGraphicsItem::ItemSceneHasChanged) {
- updateCurrentPartEditor();
- if(change == QGraphicsItem::ItemSceneHasChanged &&
- m_first_add &&
- elementScene() != nullptr)
- {
- connect(elementScene(), &ElementScene::elementInfoChanged,
- this, &PartDynamicTextField::elementInfoChanged);
- m_first_add = false;
- }
- }
- else if ((change == QGraphicsItem::ItemSelectedHasChanged) && (value.toBool() == true))
- updateCurrentPartEditor();
+ if (change == QGraphicsItem::ItemPositionHasChanged || change == QGraphicsItem::ItemSceneHasChanged) {
+ updateCurrentPartEditor();
+ if(change == QGraphicsItem::ItemSceneHasChanged &&
+ m_first_add &&
+ elementScene() != nullptr)
+ {
+ connect(elementScene(), &ElementScene::elementInfoChanged,
+ this, &PartDynamicTextField::elementInfoChanged);
+ m_first_add = false;
+ }
+ }
+ else if ((change == QGraphicsItem::ItemSelectedHasChanged) && (value.toBool() == true))
+ updateCurrentPartEditor();
- return(QGraphicsTextItem::itemChange(change, value));
+ return(QGraphicsTextItem::itemChange(change, value));
}
void PartDynamicTextField::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
- QGraphicsTextItem::paint(painter, option, widget);
+ QGraphicsTextItem::paint(painter, option, widget);
- if (m_frame) {
- painter -> save();
- painter -> setFont(this -> font());
+ if (m_frame) {
+ painter -> save();
+ painter -> setFont(this -> font());
- //Adjust the thickness according to the font size,
- qreal w=0.3;
- if(this -> font().pointSize() >= 5) {
- w = this -> font().pointSizeF()*0.1;
- if(w > 2.5)
- w = 2.5;
- }
+ //Adjust the thickness according to the font size,
+ qreal w=0.3;
+ if(this -> font().pointSize() >= 5) {
+ w = this -> font().pointSizeF()*0.1;
+ if(w > 2.5)
+ w = 2.5;
+ }
- QPen pen;
- pen.setColor(color());
- pen.setWidthF(w);
- painter -> setPen(pen);
- painter -> setRenderHint(QPainter::Antialiasing);
+ QPen pen;
+ pen.setColor(color());
+ pen.setWidthF(w);
+ painter -> setPen(pen);
+ painter -> setRenderHint(QPainter::Antialiasing);
- //Get the bounding rectangle of the text
- QSizeF size = document() -> size();
- size.setWidth(document() -> idealWidth());
- //Remove the margin. Size is exactly the bounding rect of the text
- size.rheight() -= document() -> documentMargin()*2;
- size.rwidth() -= document() -> documentMargin()*2;
- //Add a little margin only for a better visual;
- size.rheight() += 2;
- size.rwidth() += 2;
+ //Get the bounding rectangle of the text
+ QSizeF size = document() -> size();
+ size.setWidth(document() -> idealWidth());
+ //Remove the margin. Size is exactly the bounding rect of the text
+ size.rheight() -= document() -> documentMargin()*2;
+ size.rwidth() -= document() -> documentMargin()*2;
+ //Add a little margin only for a better visual;
+ size.rheight() += 2;
+ size.rwidth() += 2;
- //The pos of the rect
- QPointF pos = boundingRect().center();
- pos.rx() -= size.width()/2;
- pos.ry() -= size.height()/2;
+ //The pos of the rect
+ QPointF pos = boundingRect().center();
+ pos.rx() -= size.width()/2;
+ pos.ry() -= size.height()/2;
- //Adjust the rounding of the rectangle according to the size of the font
- qreal ro = this -> font().pointSizeF()/3;
- painter -> drawRoundedRect(QRectF(pos, size), ro, ro);
+ //Adjust the rounding of the rectangle according to the size of the font
+ qreal ro = this -> font().pointSizeF()/3;
+ painter -> drawRoundedRect(QRectF(pos, size), ro, ro);
- painter -> restore();
- }
+ painter -> restore();
+ }
}
/**
- @brief PartDynamicTextField::elementInfoChanged
- Used to up to date this text field,
- when the element information (see elementScene) changed
+ @brief PartDynamicTextField::elementInfoChanged
+ Used to up to date this text field,
+ when the element information (see elementScene) changed
*/
void PartDynamicTextField::elementInfoChanged()
{
- if(!elementScene())
- return;
+ if(!elementScene())
+ return;
- if(m_text_from == DynamicElementTextItem::ElementInfo)
- setPlainText(elementScene() -> elementInformation().value(m_info_name).toString());
- else if (m_text_from == DynamicElementTextItem::CompositeText && elementScene())
- setPlainText(autonum::AssignVariables::replaceVariable(
- m_composite_text, elementScene() -> elementInformation()));
+ if(m_text_from == DynamicElementTextItem::ElementInfo)
+ setPlainText(elementScene() -> elementInformation().value(m_info_name).toString());
+ else if (m_text_from == DynamicElementTextItem::CompositeText && elementScene())
+ setPlainText(autonum::AssignVariables::replaceVariable(
+ m_composite_text, elementScene() -> elementInformation()));
}
void PartDynamicTextField::prepareAlignment()
{
- m_alignment_rect = boundingRect();
+ m_alignment_rect = boundingRect();
}
void PartDynamicTextField::finishAlignment()
{
- if(m_block_alignment)
- return;
+ if(m_block_alignment)
+ return;
- QTransform transform;
- transform.rotate(this -> rotation());
- qreal x,xa, y,ya;
- x=xa=0;
- y=ya=0;
+ QTransform transform;
+ transform.rotate(this -> rotation());
+ qreal x,xa, y,ya;
+ x=xa=0;
+ y=ya=0;
- if(m_alignment &Qt::AlignRight) {
- x = m_alignment_rect.right();
- xa = boundingRect().right();
- }
- else if(m_alignment &Qt::AlignHCenter) {
- x = m_alignment_rect.center().x();
- xa = boundingRect().center().x();
- }
+ if(m_alignment &Qt::AlignRight) {
+ x = m_alignment_rect.right();
+ xa = boundingRect().right();
+ }
+ else if(m_alignment &Qt::AlignHCenter) {
+ x = m_alignment_rect.center().x();
+ xa = boundingRect().center().x();
+ }
- if(m_alignment &Qt::AlignBottom) {
- y = m_alignment_rect.bottom();
- ya = boundingRect().bottom();
- }
- else if(m_alignment &Qt::AlignVCenter) {
- y = m_alignment_rect.center().y();
- ya = boundingRect().center().y();
- }
+ if(m_alignment &Qt::AlignBottom) {
+ y = m_alignment_rect.bottom();
+ ya = boundingRect().bottom();
+ }
+ else if(m_alignment &Qt::AlignVCenter) {
+ y = m_alignment_rect.center().y();
+ ya = boundingRect().center().y();
+ }
- QPointF p = transform.map(QPointF(x,y));
- QPointF pa = transform.map(QPointF(xa,ya));
- QPointF diff = pa-p;
+ QPointF p = transform.map(QPointF(x,y));
+ QPointF pa = transform.map(QPointF(xa,ya));
+ QPointF diff = pa-p;
- setPos(this -> pos() - diff);
+ setPos(this -> pos() - diff);
}
diff --git a/sources/editor/graphicspart/partdynamictextfield.h b/sources/editor/graphicspart/partdynamictextfield.h
index 2ed40a123..39eecdfd2 100644
--- a/sources/editor/graphicspart/partdynamictextfield.h
+++ b/sources/editor/graphicspart/partdynamictextfield.h
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#ifndef PARTDYNAMICTEXTFIELD_H
#define PARTDYNAMICTEXTFIELD_H
@@ -23,106 +23,106 @@
#include "dynamicelementtextitem.h"
/**
- @brief The PartDynamicTextField class
- This class represents an editable dynamic text field
- which may be used to compose the
- drawing of an electrical element within the element editor.
- The field will remain editable once the element is added onto
- a diagram
+ @brief The PartDynamicTextField class
+ This class represents an editable dynamic text field
+ which may be used to compose the
+ drawing of an electrical element within the element editor.
+ The field will remain editable once the element is added onto
+ a diagram
*/
class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
{
- Q_OBJECT
+ Q_OBJECT
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
- Q_PROPERTY(DynamicElementTextItem::TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
- Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
- Q_PROPERTY(QString compositeText READ compositeText WRITE setCompositeText NOTIFY compositeTextChanged)
- Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
- Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
- Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
- Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
- Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(DynamicElementTextItem::TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
+ Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
+ Q_PROPERTY(QString compositeText READ compositeText WRITE setCompositeText NOTIFY compositeTextChanged)
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+ Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
+ Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
- public:
- ///PROPERTY
- void setProperty(const char *name, const QVariant &value) override {QGraphicsTextItem::setProperty(name, value);}
- QVariant property(const char *name) const override {return QGraphicsTextItem::property(name);}
+ public:
+ ///PROPERTY
+ void setProperty(const char *name, const QVariant &value) override {QGraphicsTextItem::setProperty(name, value);}
+ QVariant property(const char *name) const override {return QGraphicsTextItem::property(name);}
- signals:
- void taggChanged(QString tagg);
- void textChanged(QString text);
- void textFromChanged(DynamicElementTextItem::TextFrom text_from);
- void infoNameChanged(QString info);
- void compositeTextChanged(QString text);
- void colorChanged(QColor color);
- void frameChanged(bool frame);
- void textWidthChanged(qreal width);
- void alignmentChanged(Qt::Alignment alignment);
- void fontChanged(QFont font);
+ signals:
+ void taggChanged(QString tagg);
+ void textChanged(QString text);
+ void textFromChanged(DynamicElementTextItem::TextFrom text_from);
+ void infoNameChanged(QString info);
+ void compositeTextChanged(QString text);
+ void colorChanged(QColor color);
+ void frameChanged(bool frame);
+ void textWidthChanged(qreal width);
+ void alignmentChanged(Qt::Alignment alignment);
+ void fontChanged(QFont font);
- public:
- PartDynamicTextField(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
+ public:
+ PartDynamicTextField(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
- enum {Type = UserType + 1110};
- int type() const override {return Type;}
+ enum {Type = UserType + 1110};
+ int type() const override {return Type;}
- QString name() const override;
- QString xmlName() const override;
- static QString xmlTaggName() {return QString("dynamic_text");}
- bool isUseless() const override {return false;}
- QRectF sceneGeometricRect() const override {return sceneBoundingRect();}
- void startUserTransformation(const QRectF &initial_selection_rect) override;
- void handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) override;
+ QString name() const override;
+ QString xmlName() const override;
+ static QString xmlTaggName() {return QString("dynamic_text");}
+ bool isUseless() const override {return false;}
+ QRectF sceneGeometricRect() const override {return sceneBoundingRect();}
+ void startUserTransformation(const QRectF &initial_selection_rect) override;
+ void handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) override;
- const QDomElement toXml(QDomDocument &dom_doc) const override;
- void fromXml(const QDomElement &dom_elmt) override;
- void fromTextFieldXml(const QDomElement &dom_element);
+ const QDomElement toXml(QDomDocument &dom_doc) const override;
+ void fromXml(const QDomElement &dom_elmt) override;
+ void fromTextFieldXml(const QDomElement &dom_element);
- DynamicElementTextItem::TextFrom textFrom() const;
- void setTextFrom (DynamicElementTextItem::TextFrom text_from);
- QString text() const;
- void setText(const QString &text);
- void setInfoName(const QString &info_name);
- QString infoName() const;
- void setCompositeText(const QString &text);
- QString compositeText() const;
- void setColor(const QColor& color);
- QColor color() const;
- void setFrame(bool frame);
- bool frame() const;
- void setTextWidth(qreal width);
- void setPlainText(const QString &text);
- void setAlignment(Qt::Alignment alignment);
- Qt::Alignment alignment() const;
- void setFont(const QFont &font);
+ DynamicElementTextItem::TextFrom textFrom() const;
+ void setTextFrom (DynamicElementTextItem::TextFrom text_from);
+ QString text() const;
+ void setText(const QString &text);
+ void setInfoName(const QString &info_name);
+ QString infoName() const;
+ void setCompositeText(const QString &text);
+ QString compositeText() const;
+ void setColor(const QColor& color);
+ QColor color() const;
+ void setFrame(bool frame);
+ bool frame() const;
+ void setTextWidth(qreal width);
+ void setPlainText(const QString &text);
+ void setAlignment(Qt::Alignment alignment);
+ Qt::Alignment alignment() const;
+ void setFont(const QFont &font);
- protected:
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
- void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
- QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
+ protected:
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
+ void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
- private:
- void elementInfoChanged();
- void prepareAlignment();
- void finishAlignment();
+ private:
+ void elementInfoChanged();
+ void prepareAlignment();
+ void finishAlignment();
- private:
- QPointF m_origine_pos,
- m_saved_point;
- QString m_text,
- m_info_name,
- m_composite_text;
- DynamicElementTextItem::TextFrom m_text_from = DynamicElementTextItem::UserText;
- QUuid m_uuid;
- bool m_frame = false,
- m_first_add = true,
- m_block_alignment = false;
- qreal m_text_width = -1;
- Qt::Alignment m_alignment = Qt::AlignTop|Qt::AlignLeft;
- QRectF m_alignment_rect;
+ private:
+ QPointF m_origine_pos,
+ m_saved_point;
+ QString m_text,
+ m_info_name,
+ m_composite_text;
+ DynamicElementTextItem::TextFrom m_text_from = DynamicElementTextItem::UserText;
+ QUuid m_uuid;
+ bool m_frame = false,
+ m_first_add = true,
+ m_block_alignment = false;
+ qreal m_text_width = -1;
+ Qt::Alignment m_alignment = Qt::AlignTop|Qt::AlignLeft;
+ QRectF m_alignment_rect;
};
#endif // PARTDYNAMICTEXTFIELD_H
diff --git a/sources/editor/graphicspart/partellipse.cpp b/sources/editor/graphicspart/partellipse.cpp
index c121e6135..b7f7a2c1a 100644
--- a/sources/editor/graphicspart/partellipse.cpp
+++ b/sources/editor/graphicspart/partellipse.cpp
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#include "partellipse.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
@@ -22,367 +22,367 @@
#include "QetGraphicsItemModeler/qetgraphicshandlerutility.h"
/**
- @brief PartEllipse::PartEllipse
- Constructor
- @param editor : QETElementEditor of this part
- @param parent : parent item
+ @brief PartEllipse::PartEllipse
+ Constructor
+ @param editor : QETElementEditor of this part
+ @param parent : parent item
*/
PartEllipse::PartEllipse(QETElementEditor *editor, QGraphicsItem *parent) :
- AbstractPartEllipse(editor, parent),
- m_undo_command(nullptr)
+ AbstractPartEllipse(editor, parent),
+ m_undo_command(nullptr)
{}
/**
- @brief PartEllipse::~PartEllipse
- Destructor
+ @brief PartEllipse::~PartEllipse
+ Destructor
*/
PartEllipse::~PartEllipse()
{
- if(m_undo_command) delete m_undo_command;
- removeHandler();
+ if(m_undo_command) delete m_undo_command;
+ removeHandler();
}
/**
- @brief PartEllipse::paint
- Draw this ellpise
- @param painter
- @param options
- @param widget
+ @brief PartEllipse::paint
+ Draw this ellpise
+ @param painter
+ @param options
+ @param widget
*/
void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget)
{
- Q_UNUSED(widget);
- applyStylesToQPainter(*painter);
+ Q_UNUSED(widget);
+ applyStylesToQPainter(*painter);
- QPen t = painter -> pen();
+ QPen t = painter -> pen();
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
- t.setCosmetic(options && options -> levelOfDetail < 1.0);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
+ t.setCosmetic(options && options -> levelOfDetail < 1.0);
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
- t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
+ t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
#endif
- if (isSelected())
- t.setColor(Qt::red);
+ if (isSelected())
+ t.setColor(Qt::red);
- painter -> setPen(t);
- painter -> drawEllipse(rect());
+ painter -> setPen(t);
+ painter -> drawEllipse(rect());
- if (m_hovered)
- drawShadowShape(painter);
+ if (m_hovered)
+ drawShadowShape(painter);
- if (isSelected())
- drawCross(m_rect.center(), painter);
+ if (isSelected())
+ drawCross(m_rect.center(), painter);
}
/**
- @brief PartEllipse::toXml
- Export this ellipse in xml
- @param xml_document : Xml document to use for create the xml element.
- @return : an xml element that describe this ellipse
+ @brief PartEllipse::toXml
+ Export this ellipse in xml
+ @param xml_document : Xml document to use for create the xml element.
+ @return : an xml element that describe this ellipse
*/
const QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
{
- QDomElement xml_element;
- if (qFuzzyCompare(rect().width(), rect().height()))
- {
- xml_element = xml_document.createElement("circle");
- xml_element.setAttribute("diameter", QString("%1").arg(rect().width()));
- }
- else
- {
- xml_element = xml_document.createElement("ellipse");
- xml_element.setAttribute("width", QString("%1").arg(rect().width()));
- xml_element.setAttribute("height", QString("%1").arg(rect().height()));
- }
+ QDomElement xml_element;
+ if (qFuzzyCompare(rect().width(), rect().height()))
+ {
+ xml_element = xml_document.createElement("circle");
+ xml_element.setAttribute("diameter", QString("%1").arg(rect().width()));
+ }
+ else
+ {
+ xml_element = xml_document.createElement("ellipse");
+ xml_element.setAttribute("width", QString("%1").arg(rect().width()));
+ xml_element.setAttribute("height", QString("%1").arg(rect().height()));
+ }
- QPointF top_left(sceneTopLeft());
- xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
- xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
+ QPointF top_left(sceneTopLeft());
+ xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
+ xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
- stylesToXml(xml_element);
+ stylesToXml(xml_element);
- return(xml_element);
+ return(xml_element);
}
/**
- @brief PartEllipse::fromXml
- Import the properties of this ellipse from a xml element.
- @param qde : Xml document to use.
+ @brief PartEllipse::fromXml
+ Import the properties of this ellipse from a xml element.
+ @param qde : Xml document to use.
*/
void PartEllipse::fromXml(const QDomElement &qde)
{
- stylesFromXml(qde);
- qreal width, height;
+ stylesFromXml(qde);
+ qreal width, height;
- if (qde.tagName() == "ellipse")
- {
- width = qde.attribute("width", "0").toDouble();
- height = qde.attribute("height", "0").toDouble();
- }
- else
- width = height = qde.attribute("diameter", "0").toDouble();
+ if (qde.tagName() == "ellipse")
+ {
+ width = qde.attribute("width", "0").toDouble();
+ height = qde.attribute("height", "0").toDouble();
+ }
+ else
+ width = height = qde.attribute("diameter", "0").toDouble();
- m_rect = QRectF(mapFromScene(qde.attribute("x", "0").toDouble(),
- qde.attribute("y", "0").toDouble()),
- QSizeF(width, height));
+ m_rect = QRectF(mapFromScene(qde.attribute("x", "0").toDouble(),
+ qde.attribute("y", "0").toDouble()),
+ QSizeF(width, height));
}
/**
- @brief PartEllipse::shape
- @return the shape of this item
+ @brief PartEllipse::shape
+ @return the shape of this item
*/
QPainterPath PartEllipse::shape() const
{
- QPainterPath shape;
- shape.addEllipse(m_rect);
+ QPainterPath shape;
+ shape.addEllipse(m_rect);
- QPainterPathStroker pps;
- pps.setWidth(m_hovered? penWeight()+SHADOWS_HEIGHT : penWeight());
- shape = pps.createStroke(shape);
+ QPainterPathStroker pps;
+ pps.setWidth(m_hovered? penWeight()+SHADOWS_HEIGHT : penWeight());
+ shape = pps.createStroke(shape);
- return shape;
+ return shape;
}
QPainterPath PartEllipse::shadowShape() const
{
- QPainterPath shape;
- shape.addEllipse(m_rect);
+ QPainterPath shape;
+ shape.addEllipse(m_rect);
- QPainterPathStroker pps;
- pps.setWidth(penWeight());
+ QPainterPathStroker pps;
+ pps.setWidth(penWeight());
- return (pps.createStroke(shape));
+ return (pps.createStroke(shape));
}
/**
- @brief PartEllipse::mouseReleaseEvent
- Handle mouse release event
- @param event
+ @brief PartEllipse::mouseReleaseEvent
+ Handle mouse release event
+ @param event
*/
void PartEllipse::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
- if (event->button() == Qt::LeftButton && event->buttonDownPos(Qt::LeftButton) == event->pos())
- switchResizeMode();
+ if (event->button() == Qt::LeftButton && event->buttonDownPos(Qt::LeftButton) == event->pos())
+ switchResizeMode();
- CustomElementGraphicPart::mouseReleaseEvent(event);
+ CustomElementGraphicPart::mouseReleaseEvent(event);
}
/**
- @brief PartEllipse::itemChange
- @param change
- @param value
- @return
+ @brief PartEllipse::itemChange
+ @param change
+ @param value
+ @return
*/
QVariant PartEllipse::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
- if (change == ItemSelectedHasChanged && scene())
- {
- if (value.toBool() == true)
- {
- //When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler,
- //according to the number of selected items.
- connect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged);
+ if (change == ItemSelectedHasChanged && scene())
+ {
+ if (value.toBool() == true)
+ {
+ //When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler,
+ //according to the number of selected items.
+ connect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged);
- if (scene()->selectedItems().size() == 1)
- addHandler();
- }
- else
- {
- disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged);
- removeHandler();
- }
- }
- else if (change == ItemPositionHasChanged)
- {
- adjusteHandlerPos();
- }
- else if (change == ItemSceneChange)
- {
- if(scene())
- disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged);
+ if (scene()->selectedItems().size() == 1)
+ addHandler();
+ }
+ else
+ {
+ disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged);
+ removeHandler();
+ }
+ }
+ else if (change == ItemPositionHasChanged)
+ {
+ adjusteHandlerPos();
+ }
+ else if (change == ItemSceneChange)
+ {
+ if(scene())
+ disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged);
- setSelected(false); //This item is removed from scene, then we deselect this, and so, the handlers is also removed.
- }
+ setSelected(false); //This item is removed from scene, then we deselect this, and so, the handlers is also removed.
+ }
- return QGraphicsItem::itemChange(change, value);
+ return QGraphicsItem::itemChange(change, value);
}
/**
- @brief PartEllipse::sceneEventFilter
- @param watched
- @param event
- @return
+ @brief PartEllipse::sceneEventFilter
+ @param watched
+ @param event
+ @return
*/
bool PartEllipse::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
{
- //Watched must be an handler
- if(watched->type() == QetGraphicsHandlerItem::Type)
- {
- QetGraphicsHandlerItem *qghi = qgraphicsitem_cast(watched);
+ //Watched must be an handler
+ if(watched->type() == QetGraphicsHandlerItem::Type)
+ {
+ QetGraphicsHandlerItem *qghi = qgraphicsitem_cast(watched);
- if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
- {
- m_vector_index = m_handler_vector.indexOf(qghi);
- if (m_vector_index != -1)
- {
- if(event->type() == QEvent::GraphicsSceneMousePress) //Click
- {
- handlerMousePressEvent(qghi, static_cast(event));
- return true;
- }
- else if(event->type() == QEvent::GraphicsSceneMouseMove) //Move
- {
- handlerMouseMoveEvent(qghi, static_cast(event));
- return true;
- }
- else if (event->type() == QEvent::GraphicsSceneMouseRelease) //Release
- {
- handlerMouseReleaseEvent(qghi, static_cast(event));
- return true;
- }
- }
- }
- }
+ if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
+ {
+ m_vector_index = m_handler_vector.indexOf(qghi);
+ if (m_vector_index != -1)
+ {
+ if(event->type() == QEvent::GraphicsSceneMousePress) //Click
+ {
+ handlerMousePressEvent(qghi, static_cast(event));
+ return true;
+ }
+ else if(event->type() == QEvent::GraphicsSceneMouseMove) //Move
+ {
+ handlerMouseMoveEvent(qghi, static_cast(event));
+ return true;
+ }
+ else if (event->type() == QEvent::GraphicsSceneMouseRelease) //Release
+ {
+ handlerMouseReleaseEvent(qghi, static_cast(event));
+ return true;
+ }
+ }
+ }
+ }
- return false;
+ return false;
}
void PartEllipse::switchResizeMode()
{
- if (m_resize_mode == 1)
- {
- m_resize_mode = 2;
- for (QetGraphicsHandlerItem *qghi : m_handler_vector)
- qghi->setColor(Qt::darkGreen);
- }
- else
- {
- m_resize_mode = 1;
- for (QetGraphicsHandlerItem *qghi : m_handler_vector)
- qghi->setColor(Qt::blue);
- }
+ if (m_resize_mode == 1)
+ {
+ m_resize_mode = 2;
+ for (QetGraphicsHandlerItem *qghi : m_handler_vector)
+ qghi->setColor(Qt::darkGreen);
+ }
+ else
+ {
+ m_resize_mode = 1;
+ for (QetGraphicsHandlerItem *qghi : m_handler_vector)
+ qghi->setColor(Qt::blue);
+ }
}
/**
- @brief PartEllipse::adjusteHandlerPos
+ @brief PartEllipse::adjusteHandlerPos
*/
void PartEllipse::adjusteHandlerPos()
{
- if (m_handler_vector.isEmpty())
- return;
+ if (m_handler_vector.isEmpty())
+ return;
- QVector points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect);
+ QVector points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect);
- if (m_handler_vector.size() == points_vector.size())
- {
- points_vector = mapToScene(points_vector);
- for (int i = 0 ; i < points_vector.size() ; ++i)
- m_handler_vector.at(i)->setPos(points_vector.at(i));
- }
+ if (m_handler_vector.size() == points_vector.size())
+ {
+ points_vector = mapToScene(points_vector);
+ for (int i = 0 ; i < points_vector.size() ; ++i)
+ m_handler_vector.at(i)->setPos(points_vector.at(i));
+ }
}
/**
- @brief PartEllipse::handlerMousePressEvent
- @param qghi
- @param event
+ @brief PartEllipse::handlerMousePressEvent
+ @param qghi
+ @param event
*/
void PartEllipse::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
{
- Q_UNUSED(qghi);
- Q_UNUSED(event);
+ Q_UNUSED(qghi);
+ Q_UNUSED(event);
- m_undo_command = new QPropertyUndoCommand(this, "rect", QVariant(m_rect));
- m_undo_command->setText(tr("Modifier un rectangle"));
- m_undo_command->enableAnimation();
- return;
+ m_undo_command = new QPropertyUndoCommand(this, "rect", QVariant(m_rect));
+ m_undo_command->setText(tr("Modifier un rectangle"));
+ m_undo_command->enableAnimation();
+ return;
}
/**
- @brief PartEllipse::handlerMouseMoveEvent
- @param qghi
- @param event
+ @brief PartEllipse::handlerMouseMoveEvent
+ @param qghi
+ @param event
*/
void PartEllipse::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
{
- Q_UNUSED(qghi);
+ Q_UNUSED(qghi);
- QPointF new_pos = event->scenePos();
- if (event->modifiers() != Qt::ControlModifier)
- new_pos = elementScene()->snapToGrid(event->scenePos());
- new_pos = mapFromScene(new_pos);
+ QPointF new_pos = event->scenePos();
+ if (event->modifiers() != Qt::ControlModifier)
+ new_pos = elementScene()->snapToGrid(event->scenePos());
+ new_pos = mapFromScene(new_pos);
- if (m_resize_mode == 1)
- setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index));
- else
- setRect(QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(m_rect, new_pos, m_vector_index));
+ if (m_resize_mode == 1)
+ setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index));
+ else
+ setRect(QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(m_rect, new_pos, m_vector_index));
- adjusteHandlerPos();
+ adjusteHandlerPos();
}
/**
- @brief PartEllipse::handlerMouseReleaseEvent
- @param qghi
- @param event
+ @brief PartEllipse::handlerMouseReleaseEvent
+ @param qghi
+ @param event
*/
void PartEllipse::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
{
- Q_UNUSED(qghi);
- Q_UNUSED(event);
+ Q_UNUSED(qghi);
+ Q_UNUSED(event);
- m_undo_command->setNewValue(QVariant(m_rect));
- elementScene()->undoStack().push(m_undo_command);
- m_undo_command = nullptr;
- m_vector_index = -1;
+ m_undo_command->setNewValue(QVariant(m_rect));
+ elementScene()->undoStack().push(m_undo_command);
+ m_undo_command = nullptr;
+ m_vector_index = -1;
}
/**
- @brief PartEllipse::sceneSelectionChanged
- When the scene selection change, if there are several primitive selected, we remove the handler of this item
+ @brief PartEllipse::sceneSelectionChanged
+ When the scene selection change, if there are several primitive selected, we remove the handler of this item
*/
void PartEllipse::sceneSelectionChanged()
{
- if (this->isSelected() && scene()->selectedItems().size() == 1)
- addHandler();
- else
- removeHandler();
+ if (this->isSelected() && scene()->selectedItems().size() == 1)
+ addHandler();
+ else
+ removeHandler();
}
/**
- @brief PartEllipse::addHandler
- Add handlers for this item
+ @brief PartEllipse::addHandler
+ Add handlers for this item
*/
void PartEllipse::addHandler()
{
- if (m_handler_vector.isEmpty() && scene())
- {
- m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
+ if (m_handler_vector.isEmpty() && scene())
+ {
+ m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
- for(QetGraphicsHandlerItem *handler : m_handler_vector)
- {
- QColor color = Qt::blue;
- if (m_resize_mode == 2)
- color = Qt::darkGreen;
+ for(QetGraphicsHandlerItem *handler : m_handler_vector)
+ {
+ QColor color = Qt::blue;
+ if (m_resize_mode == 2)
+ color = Qt::darkGreen;
- handler->setColor(color);
- scene()->addItem(handler);
- handler->installSceneEventFilter(this);
- handler->setZValue(this->zValue()+1);
- }
- }
+ handler->setColor(color);
+ scene()->addItem(handler);
+ handler->installSceneEventFilter(this);
+ handler->setZValue(this->zValue()+1);
+ }
+ }
}
/**
- @brief PartEllipse::removeHandler
- Remove the handlers of this item
+ @brief PartEllipse::removeHandler
+ Remove the handlers of this item
*/
void PartEllipse::removeHandler()
{
- if (!m_handler_vector.isEmpty())
- {
- qDeleteAll(m_handler_vector);
- m_handler_vector.clear();
- }
+ if (!m_handler_vector.isEmpty())
+ {
+ qDeleteAll(m_handler_vector);
+ m_handler_vector.clear();
+ }
}
diff --git a/sources/editor/graphicspart/partellipse.h b/sources/editor/graphicspart/partellipse.h
index 477db5111..472b1abc3 100644
--- a/sources/editor/graphicspart/partellipse.h
+++ b/sources/editor/graphicspart/partellipse.h
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#ifndef PART_ELLIPSE_H
#define PART_ELLIPSE_H
@@ -23,60 +23,60 @@
class QPropertyUndoCommand;
/**
- @brief The PartEllipse class
- This class represents an ellipse primitive which may be used to compose the
- drawing of an electrical element within the element editor.
+ @brief The PartEllipse class
+ This class represents an ellipse primitive which may be used to compose the
+ drawing of an electrical element within the element editor.
*/
class PartEllipse : public AbstractPartEllipse
{
- Q_OBJECT
+ Q_OBJECT
- // constructors, destructor
- public:
- PartEllipse(QETElementEditor *editor, QGraphicsItem * parent = nullptr);
- ~PartEllipse() override;
-
- private:
- PartEllipse(const PartEllipse &);
-
- // methods
- public:
- enum { Type = UserType + 1103 };
- /**
- Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartEllipse.
- @return the QGraphicsItem type
- */
- int type() const override { return Type; }
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
+ // constructors, destructor
+ public:
+ PartEllipse(QETElementEditor *editor, QGraphicsItem * parent = nullptr);
+ ~PartEllipse() override;
+
+ private:
+ PartEllipse(const PartEllipse &);
+
+ // methods
+ public:
+ enum { Type = UserType + 1103 };
+ /**
+ Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartEllipse.
+ @return the QGraphicsItem type
+ */
+ int type() const override { return Type; }
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
- //Name and XML
- QString name() const override { return(QObject::tr("ellipse", "element part name")); }
- QString xmlName() const override { return(QString("ellipse")); }
- const QDomElement toXml (QDomDocument &) const override;
- void fromXml (const QDomElement &) override;
- QPainterPath shape() const override;
- QPainterPath shadowShape() const override;
- void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
+ //Name and XML
+ QString name() const override { return(QObject::tr("ellipse", "element part name")); }
+ QString xmlName() const override { return(QString("ellipse")); }
+ const QDomElement toXml (QDomDocument &) const override;
+ void fromXml (const QDomElement &) override;
+ QPainterPath shape() const override;
+ QPainterPath shadowShape() const override;
+ void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
- protected:
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
- QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
- bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
+ protected:
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
+ bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
- private:
- void switchResizeMode();
- void adjusteHandlerPos();
- void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
- void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
- void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
- void sceneSelectionChanged ();
-
- void addHandler();
- void removeHandler();
+ private:
+ void switchResizeMode();
+ void adjusteHandlerPos();
+ void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
+ void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
+ void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
+ void sceneSelectionChanged ();
+
+ void addHandler();
+ void removeHandler();
- private:
- QPropertyUndoCommand *m_undo_command;
- int m_resize_mode = 1,
- m_vector_index = -1;
+ private:
+ QPropertyUndoCommand *m_undo_command;
+ int m_resize_mode = 1,
+ m_vector_index = -1;
};
#endif
diff --git a/sources/editor/graphicspart/partline.cpp b/sources/editor/graphicspart/partline.cpp
index 304406e2e..d65935a2d 100644
--- a/sources/editor/graphicspart/partline.cpp
+++ b/sources/editor/graphicspart/partline.cpp
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#include "partline.h"
#include
@@ -23,697 +23,697 @@
/**
- @brief PartLine::PartLine
- Constructor
- @param editor : QETElementEditor of this part
- @param parent : parent item
+ @brief PartLine::PartLine
+ Constructor
+ @param editor : QETElementEditor of this part
+ @param parent : parent item
*/
PartLine::PartLine(QETElementEditor *editor, QGraphicsItem *parent) :
- CustomElementGraphicPart(editor, parent),
- first_end(Qet::None),
- first_length(1.5),
- second_end(Qet::None),
- second_length(1.5),
- m_undo_command(nullptr)
+ CustomElementGraphicPart(editor, parent),
+ first_end(Qet::None),
+ first_length(1.5),
+ second_end(Qet::None),
+ second_length(1.5),
+ m_undo_command(nullptr)
{}
/// Destructeur
PartLine::~PartLine()
{
- if(m_undo_command)
- delete m_undo_command;
+ if(m_undo_command)
+ delete m_undo_command;
- removeHandler();
+ removeHandler();
}
/**
- @brief PartLine::requiredLengthForEndType
- @param end_type
- @return the number of "length" needed to draw a extremity of type Qet::EndType.
+ @brief PartLine::requiredLengthForEndType
+ @param end_type
+ @return the number of "length" needed to draw a extremity of type Qet::EndType.
*/
uint PartLine::requiredLengthForEndType(const Qet::EndType &end_type)
{
- uint length_count_required = 0;
+ uint length_count_required = 0;
- if (end_type == Qet::Circle || end_type == Qet::Diamond)
- length_count_required = 2;
- else if (end_type == Qet::Simple || end_type == Qet::Triangle)
- length_count_required = 1;
+ if (end_type == Qet::Circle || end_type == Qet::Diamond)
+ length_count_required = 2;
+ else if (end_type == Qet::Simple || end_type == Qet::Triangle)
+ length_count_required = 1;
- return(length_count_required);
+ return(length_count_required);
}
/**
- @brief PartLine::paint
- Draw this line
- @param painter
- @param options
- @param widget
+ @brief PartLine::paint
+ Draw this line
+ @param painter
+ @param options
+ @param widget
*/
void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget)
{
- Q_UNUSED(widget)
- if (isUseless()) return;
+ Q_UNUSED(widget)
+ if (isUseless()) return;
- painter->save();
- applyStylesToQPainter(*painter);
- QPen t = painter -> pen();
- t.setJoinStyle(Qt::MiterJoin);
+ painter->save();
+ applyStylesToQPainter(*painter);
+ QPen t = painter -> pen();
+ t.setJoinStyle(Qt::MiterJoin);
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
- t.setCosmetic(options && options -> levelOfDetail < 1.0);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
+ t.setCosmetic(options && options -> levelOfDetail < 1.0);
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
- t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
+ t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
#endif
- if (isSelected()) t.setColor(Qt::red);
+ if (isSelected()) t.setColor(Qt::red);
- painter -> setPen(t);
+ painter -> setPen(t);
- if (first_end || second_end)
- painter -> drawPath(path());
- else
- painter -> drawLine(m_line);
+ if (first_end || second_end)
+ painter -> drawPath(path());
+ else
+ painter -> drawLine(m_line);
- if (m_hovered)
- drawShadowShape(painter);
+ if (m_hovered)
+ drawShadowShape(painter);
- painter->restore();
+ painter->restore();
}
/**
- @brief PartLine::toXml
- Export this line in xml
- @param xml_document : Xml document to use for create the xml element.
- @return an xml element that describe this line
+ @brief PartLine::toXml
+ Export this line in xml
+ @param xml_document : Xml document to use for create the xml element.
+ @return an xml element that describe this line
*/
const QDomElement PartLine::toXml(QDomDocument &xml_document) const
{
- QPointF p1(sceneP1());
- QPointF p2(sceneP2());
+ QPointF p1(sceneP1());
+ QPointF p2(sceneP2());
- 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));
+ 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);
- return(xml_element);
+ stylesToXml(xml_element);
+ return(xml_element);
}
/**
- @brief PartLine::fromXml
- Import the properties of this line from a xml element.
- @param qde : Xml document to use
+ @brief PartLine::fromXml
+ Import the properties of this line from a xml element.
+ @param qde : Xml document to use
*/
void PartLine::fromXml(const QDomElement &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()));
+ 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"));
- first_length = qde.attribute("length1", "1.5").toDouble();
- second_end = Qet::endTypeFromString(qde.attribute("end2"));
- second_length = qde.attribute("length2", "1.5").toDouble();
+ first_end = Qet::endTypeFromString(qde.attribute("end1"));
+ first_length = qde.attribute("length1", "1.5").toDouble();
+ second_end = Qet::endTypeFromString(qde.attribute("end2"));
+ second_length = qde.attribute("length2", "1.5").toDouble();
}
/**
- @brief PartLine::itemChange
- @param change
- @param value
- @return
+ @brief PartLine::itemChange
+ @param change
+ @param value
+ @return
*/
QVariant PartLine::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
- if (change == ItemSelectedHasChanged && scene())
- {
- if (value.toBool() == true)
- {
- //When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler,
- //according to the number of selected items.
- connect(scene(), &QGraphicsScene::selectionChanged, this, &PartLine::sceneSelectionChanged);
+ if (change == ItemSelectedHasChanged && scene())
+ {
+ if (value.toBool() == true)
+ {
+ //When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler,
+ //according to the number of selected items.
+ connect(scene(), &QGraphicsScene::selectionChanged, this, &PartLine::sceneSelectionChanged);
- if (scene()->selectedItems().size() == 1)
- addHandler();
- }
- else
- {
- disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartLine::sceneSelectionChanged);
- removeHandler();
- }
- }
- else if (change == ItemPositionHasChanged)
- {
- adjusteHandlerPos();
- }
- else if (change == ItemSceneChange)
- {
- if(scene())
- disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartLine::sceneSelectionChanged);
+ if (scene()->selectedItems().size() == 1)
+ addHandler();
+ }
+ else
+ {
+ disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartLine::sceneSelectionChanged);
+ removeHandler();
+ }
+ }
+ else if (change == ItemPositionHasChanged)
+ {
+ adjusteHandlerPos();
+ }
+ else if (change == ItemSceneChange)
+ {
+ if(scene())
+ disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartLine::sceneSelectionChanged);
- setSelected(false); //This is item removed from scene, then we deselect this, and so, the handlers is also removed.
- }
+ setSelected(false); //This is item removed from scene, then we deselect this, and so, the handlers is also removed.
+ }
- return QGraphicsItem::itemChange(change, value);
+ return QGraphicsItem::itemChange(change, value);
}
/**
- @brief PartLine::sceneEventFilter
- @param watched
- @param event
- @return
+ @brief PartLine::sceneEventFilter
+ @param watched
+ @param event
+ @return
*/
bool PartLine::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
{
- //Watched must be an handler
- if(watched->type() == QetGraphicsHandlerItem::Type)
- {
- QetGraphicsHandlerItem *qghi = qgraphicsitem_cast(watched);
+ //Watched must be an handler
+ if(watched->type() == QetGraphicsHandlerItem::Type)
+ {
+ QetGraphicsHandlerItem *qghi = qgraphicsitem_cast(watched);
- if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
- {
- m_vector_index = m_handler_vector.indexOf(qghi);
- if (m_vector_index != -1)
- {
- if(event->type() == QEvent::GraphicsSceneMousePress) //Click
- {
- handlerMousePressEvent(qghi, static_cast(event));
- return true;
- }
- else if(event->type() == QEvent::GraphicsSceneMouseMove) //Move
- {
- handlerMouseMoveEvent(qghi, static_cast(event));
- return true;
- }
- else if (event->type() == QEvent::GraphicsSceneMouseRelease) //Release
- {
- handlerMouseReleaseEvent(qghi, static_cast(event));
- return true;
- }
- }
- }
- }
+ if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
+ {
+ m_vector_index = m_handler_vector.indexOf(qghi);
+ if (m_vector_index != -1)
+ {
+ if(event->type() == QEvent::GraphicsSceneMousePress) //Click
+ {
+ handlerMousePressEvent(qghi, static_cast(event));
+ return true;
+ }
+ else if(event->type() == QEvent::GraphicsSceneMouseMove) //Move
+ {
+ handlerMouseMoveEvent(qghi, static_cast(event));
+ return true;
+ }
+ else if (event->type() == QEvent::GraphicsSceneMouseRelease) //Release
+ {
+ handlerMouseReleaseEvent(qghi, static_cast(event));
+ return true;
+ }
+ }
+ }
+ }
- return false;
+ return false;
}
/**
- @brief PartLine::adjusteHandlerPos
- Adjust the position of the handler item
+ @brief PartLine::adjusteHandlerPos
+ Adjust the position of the handler item
*/
void PartLine::adjusteHandlerPos()
{
- if(m_handler_vector.isEmpty())
- return;
+ if(m_handler_vector.isEmpty())
+ return;
- QVector points_vector;
- points_vector << m_line.p1() << m_line.p2();
+ QVector points_vector;
+ points_vector << m_line.p1() << m_line.p2();
- if (m_handler_vector.size() == points_vector.size())
- {
- points_vector = mapToScene(points_vector);
- for (int i = 0 ; i < points_vector.size() ; ++i)
- m_handler_vector.at(i)->setPos(points_vector.at(i));
- }
+ if (m_handler_vector.size() == points_vector.size())
+ {
+ points_vector = mapToScene(points_vector);
+ for (int i = 0 ; i < points_vector.size() ; ++i)
+ m_handler_vector.at(i)->setPos(points_vector.at(i));
+ }
}
/**
- @brief PartLine::handlerMousePressEvent
- @param qghi
- @param event
+ @brief PartLine::handlerMousePressEvent
+ @param qghi
+ @param event
*/
void PartLine::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
{
- Q_UNUSED(qghi)
- Q_UNUSED(event)
+ Q_UNUSED(qghi)
+ Q_UNUSED(event)
- m_undo_command = new QPropertyUndoCommand(this, "line", QVariant(m_line));
- m_undo_command->setText(tr("Modifier une ligne"));
- m_undo_command->enableAnimation();
- return;
+ m_undo_command = new QPropertyUndoCommand(this, "line", QVariant(m_line));
+ m_undo_command->setText(tr("Modifier une ligne"));
+ m_undo_command->enableAnimation();
+ return;
}
/**
- @brief PartLine::handlerMouseMoveEvent
- @param qghi
- @param event
+ @brief PartLine::handlerMouseMoveEvent
+ @param qghi
+ @param event
*/
void PartLine::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
{
- Q_UNUSED(qghi)
+ Q_UNUSED(qghi)
- QPointF new_pos = event->scenePos();
- if (event->modifiers() != Qt::ControlModifier)
- new_pos = elementScene()->snapToGrid(event->scenePos());
- new_pos = mapFromScene(new_pos);
+ QPointF new_pos = event->scenePos();
+ if (event->modifiers() != Qt::ControlModifier)
+ new_pos = elementScene()->snapToGrid(event->scenePos());
+ new_pos = mapFromScene(new_pos);
- prepareGeometryChange();
- if (m_vector_index == 0)
- m_line.setP1(new_pos);
- else
- m_line.setP2(new_pos);
+ prepareGeometryChange();
+ if (m_vector_index == 0)
+ m_line.setP1(new_pos);
+ else
+ m_line.setP2(new_pos);
- emit lineChanged();
+ emit lineChanged();
- adjusteHandlerPos();
+ adjusteHandlerPos();
}
/**
- @brief PartLine::handlerMouseReleaseEvent
- @param qghi
- @param event
+ @brief PartLine::handlerMouseReleaseEvent
+ @param qghi
+ @param event
*/
void PartLine::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
{
- Q_UNUSED(qghi)
- Q_UNUSED(event)
+ Q_UNUSED(qghi)
+ Q_UNUSED(event)
- m_undo_command->setNewValue(QVariant(m_line));
- elementScene()->undoStack().push(m_undo_command);
- m_undo_command = nullptr;
- m_vector_index = -1;
+ m_undo_command->setNewValue(QVariant(m_line));
+ elementScene()->undoStack().push(m_undo_command);
+ m_undo_command = nullptr;
+ m_vector_index = -1;
}
/**
- @brief PartLine::sceneSelectionChanged
- When the scene selection change, if there are several primitive selected, we remove the handler of this item
+ @brief PartLine::sceneSelectionChanged
+ When the scene selection change, if there are several primitive selected, we remove the handler of this item
*/
void PartLine::sceneSelectionChanged()
{
- if (this->isSelected() && scene()->selectedItems().size() == 1)
- addHandler();
- else
- removeHandler();
+ if (this->isSelected() && scene()->selectedItems().size() == 1)
+ addHandler();
+ else
+ removeHandler();
}
/**
- @brief PartLine::addHandler
- Add handlers for this item
+ @brief PartLine::addHandler
+ Add handlers for this item
*/
void PartLine::addHandler()
{
- if (m_handler_vector.isEmpty() && scene())
- {
- QVector points_vector;
- points_vector << m_line.p1() << m_line.p2();
+ if (m_handler_vector.isEmpty() && scene())
+ {
+ QVector points_vector;
+ points_vector << m_line.p1() << m_line.p2();
- m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(points_vector));
+ m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(points_vector));
- for(QetGraphicsHandlerItem *handler : m_handler_vector)
- {
- handler->setColor(Qt::blue);
- scene()->addItem(handler);
- handler->installSceneEventFilter(this);
- handler->setZValue(this->zValue()+1);
- }
- }
+ for(QetGraphicsHandlerItem *handler : m_handler_vector)
+ {
+ handler->setColor(Qt::blue);
+ scene()->addItem(handler);
+ handler->installSceneEventFilter(this);
+ handler->setZValue(this->zValue()+1);
+ }
+ }
}
/**
- @brief PartLine::removeHandler
- Remove the handlers of this item
+ @brief PartLine::removeHandler
+ Remove the handlers of this item
*/
void PartLine::removeHandler()
{
- if (!m_handler_vector.isEmpty())
- {
- qDeleteAll(m_handler_vector);
- m_handler_vector.clear();
- }
+ if (!m_handler_vector.isEmpty())
+ {
+ qDeleteAll(m_handler_vector);
+ m_handler_vector.clear();
+ }
}
/**
- @brief PartLine::sceneP1
- @return the point p1 in scene coordinate
+ @brief PartLine::sceneP1
+ @return the point p1 in scene coordinate
*/
QPointF PartLine::sceneP1() const
{
- return(mapToScene(m_line.p1()));
+ return(mapToScene(m_line.p1()));
}
/**
- @brief PartLine::sceneP2
- @return the point p2 in scen coordinate
+ @brief PartLine::sceneP2
+ @return the point p2 in scen coordinate
*/
QPointF PartLine::sceneP2() const
{
- return(mapToScene(m_line.p2()));
+ return(mapToScene(m_line.p2()));
}
/**
- @brief PartLine::shape
- @return the shape of this item
+ @brief PartLine::shape
+ @return the shape of this item
*/
QPainterPath PartLine::shape() const
{
- QPainterPath shape;
+ QPainterPath shape;
- //We calcul path only if there is an end type
- //Else we just draw a line
- if (first_end || second_end)
- shape.addPath(path());
- else
- {
- shape.moveTo(m_line.p1());
- shape.lineTo(m_line.p2());
- }
+ //We calcul path only if there is an end type
+ //Else we just draw a line
+ if (first_end || second_end)
+ shape.addPath(path());
+ else
+ {
+ shape.moveTo(m_line.p1());
+ shape.lineTo(m_line.p2());
+ }
- QPainterPathStroker pps;
- pps.setWidth(m_hovered? penWeight()+SHADOWS_HEIGHT : penWeight());
- shape = pps.createStroke(shape);
+ QPainterPathStroker pps;
+ pps.setWidth(m_hovered? penWeight()+SHADOWS_HEIGHT : penWeight());
+ shape = pps.createStroke(shape);
- return shape;
+ return shape;
}
QPainterPath PartLine::shadowShape() const
{
- QPainterPath shape;
+ QPainterPath shape;
- //We calcul path only if there is an end type
- //Else we just draw a line
- if (first_end || second_end)
- shape.addPath(path());
- else
- {
- shape.moveTo(m_line.p1());
- shape.lineTo(m_line.p2());
- }
+ //We calcul path only if there is an end type
+ //Else we just draw a line
+ if (first_end || second_end)
+ shape.addPath(path());
+ else
+ {
+ shape.moveTo(m_line.p1());
+ shape.lineTo(m_line.p2());
+ }
- QPainterPathStroker pps;
- pps.setWidth(penWeight());
+ QPainterPathStroker pps;
+ pps.setWidth(penWeight());
- return (pps.createStroke(shape));
+ return (pps.createStroke(shape));
}
/**
- @brief PartLine::firstEndCircleRect
- @return the rectangle bordering the entirety of the first extremity
+ @brief PartLine::firstEndCircleRect
+ @return the rectangle bordering the entirety of the first extremity
*/
QRectF PartLine::firstEndCircleRect() const
{
- QList interesting_points = fourEndPoints(m_line.p1(),
- m_line.p2(),
- first_length);
+ QList interesting_points = fourEndPoints(m_line.p1(),
+ m_line.p2(),
+ first_length);
- QRectF end_rect(
- interesting_points[0] - QPointF(first_length, first_length),
- QSizeF(2.0 * first_length, 2.0 * first_length)
- );
+ QRectF end_rect(
+ interesting_points[0] - QPointF(first_length, first_length),
+ QSizeF(2.0 * first_length, 2.0 * first_length)
+ );
- return(end_rect);
+ return(end_rect);
}
/**
- @brief PartLine::secondEndCircleRect
- @return the rectangle bordering the entirety of the second extremity
+ @brief PartLine::secondEndCircleRect
+ @return the rectangle bordering the entirety of the second extremity
*/
QRectF PartLine::secondEndCircleRect() const
{
- QList interesting_points = fourEndPoints(m_line.p2(),
- m_line.p1(),
- second_length);
+ QList interesting_points = fourEndPoints(m_line.p2(),
+ m_line.p1(),
+ second_length);
- QRectF end_rect(
- interesting_points[0] - QPointF(second_length, second_length),
- QSizeF(2.0 * second_length, 2.0 * second_length)
- );
+ QRectF end_rect(
+ interesting_points[0] - QPointF(second_length, second_length),
+ QSizeF(2.0 * second_length, 2.0 * second_length)
+ );
- return(end_rect);
+ return(end_rect);
}
/**
- @brief PartLine::boundingRect
- @return the bounding rect of this part
+ @brief PartLine::boundingRect
+ @return the bounding rect of this part
*/
QRectF PartLine::boundingRect() const
{
- QRectF bound;
- if (first_end || second_end)
- bound = path().boundingRect();
- else
- bound = QRectF (m_line.p1(), m_line.p2());
+ QRectF bound;
+ if (first_end || second_end)
+ bound = path().boundingRect();
+ else
+ bound = QRectF (m_line.p1(), m_line.p2());
- qreal adjust = (SHADOWS_HEIGHT + penWeight()) / 2;
- //We add 0.5 because CustomElementGraphicPart::drawShadowShape
- //draw a shape bigger of 0.5 when pen weight is to 0.
- if (penWeight() == 0) adjust += 0.5;
+ qreal adjust = (SHADOWS_HEIGHT + penWeight()) / 2;
+ //We add 0.5 because CustomElementGraphicPart::drawShadowShape
+ //draw a shape bigger of 0.5 when pen weight is to 0.
+ if (penWeight() == 0) adjust += 0.5;
- bound = bound.normalized();
- bound.adjust(-adjust, -adjust, adjust, adjust);
+ bound = bound.normalized();
+ bound.adjust(-adjust, -adjust, adjust, adjust);
- return bound;
+ return bound;
}
/**
- @brief PartLine::isUseless
- @return true if this part is irrelevant and does not deserve to be Retained / registered.
- A line is relevant when is two point is different
+ @brief PartLine::isUseless
+ @return true if this part is irrelevant and does not deserve to be Retained / registered.
+ A line is relevant when is two point is different
*/
bool PartLine::isUseless() const
{
- return(m_line.p1() == m_line.p2());
+ return(m_line.p1() == m_line.p2());
}
/**
- @brief PartLine::sceneGeometricRect
- @return the minimum, margin-less rectangle this part can fit into, in scene
- coordinates. It is different from boundingRect() because it is not supposed
- to imply any margin, and it is different from shape because it is a regular
- rectangle, not a complex shape.
+ @brief PartLine::sceneGeometricRect
+ @return the minimum, margin-less rectangle this part can fit into, in scene
+ coordinates. It is different from boundingRect() because it is not supposed
+ to imply any margin, and it is different from shape because it is a regular
+ rectangle, not a complex shape.
*/
QRectF PartLine::sceneGeometricRect() const
{
- return(QRectF(sceneP1(), sceneP2()));
+ return(QRectF(sceneP1(), sceneP2()));
}
/**
- @brief PartLine::startUserTransformation
- Start the user-induced transformation, provided this primitive is contained
- within the \a initial_selection_rect bounding rectangle.
- @param initial_selection_rect
+ @brief PartLine::startUserTransformation
+ Start the user-induced transformation, provided this primitive is contained
+ within the \a initial_selection_rect bounding rectangle.
+ @param initial_selection_rect
*/
void PartLine::startUserTransformation(const QRectF &initial_selection_rect)
{
- Q_UNUSED(initial_selection_rect)
- saved_points_.clear();
- saved_points_ << sceneP1() << sceneP2();
+ Q_UNUSED(initial_selection_rect)
+ saved_points_.clear();
+ saved_points_ << sceneP1() << sceneP2();
}
/**
- @brief PartLine::handleUserTransformation
- Handle the user-induced transformation from \a initial_selection_rect to \a new_selection_rect
- @param initial_selection_rect
- @param new_selection_rect
+ @brief PartLine::handleUserTransformation
+ Handle the user-induced transformation from \a initial_selection_rect to \a new_selection_rect
+ @param initial_selection_rect
+ @param new_selection_rect
*/
void PartLine::handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect)
{
- QList mapped_points = mapPoints(initial_selection_rect, new_selection_rect, saved_points_);
- prepareGeometryChange();
- m_line = QLineF(mapFromScene(mapped_points.at(0)), mapFromScene(mapped_points.at(1)));
+ QList mapped_points = mapPoints(initial_selection_rect, new_selection_rect, saved_points_);
+ prepareGeometryChange();
+ m_line = QLineF(mapFromScene(mapped_points.at(0)), mapFromScene(mapped_points.at(1)));
}
/**
- @brief PartLine::fourEndPoints
- Return the four interesting point needed to draw the shape
- at extremity of line (circle, diamond, arrow, triangle)
- This points are in order :
- * O : point on the line, at a distance 'length' of the extremity
- * A : point on the line at a 'length' of 2x the extremity length
- * B : point at a distance of length O - O is the projection of B on the line
- * C : point at a distance of length O - O is the projection of C on the line
- @param end_point : The concerned extremity
- @param other_point : other needed point to define the line
- @param length : length to use between the extremity and the point O
- @return
+ @brief PartLine::fourEndPoints
+ Return the four interesting point needed to draw the shape
+ at extremity of line (circle, diamond, arrow, triangle)
+ This points are in order :
+ * O : point on the line, at a distance 'length' of the extremity
+ * A : point on the line at a 'length' of 2x the extremity length
+ * B : point at a distance of length O - O is the projection of B on the line
+ * C : point at a distance of length O - O is the projection of C on the line
+ @param end_point : The concerned extremity
+ @param other_point : other needed point to define the line
+ @param length : length to use between the extremity and the point O
+ @return
*/
QList PartLine::fourEndPoints(const QPointF &end_point, const QPointF &other_point, const qreal &length)
{
- //Vector and length of the line
- QPointF line_vector = end_point - other_point;
- qreal line_length = sqrt(pow(line_vector.x(), 2) + pow(line_vector.y(), 2));
+ //Vector and length of the line
+ QPointF line_vector = end_point - other_point;
+ qreal line_length = sqrt(pow(line_vector.x(), 2) + pow(line_vector.y(), 2));
- //Unitary vector and perpendicular vector
- QPointF u(line_vector / line_length * length);
- QPointF v(-u.y(), u.x());
+ //Unitary vector and perpendicular vector
+ QPointF u(line_vector / line_length * length);
+ QPointF v(-u.y(), u.x());
- // points O, A, B, C
- QPointF o(end_point - u);
- QPointF a(o - u);
- QPointF b(o + v);
- QPointF c(o - v);
+ // points O, A, B, C
+ QPointF o(end_point - u);
+ QPointF a(o - u);
+ QPointF b(o + v);
+ QPointF c(o - v);
- return(QList() << o << a << b << c);
+ return(QList() << o << a << b << c);
}
QLineF PartLine::line() const
{
- return m_line;
+ return m_line;
}
void PartLine::setLine(const QLineF &line)
{
- if (m_line == line) return;
- prepareGeometryChange();
- m_line = line;
- adjusteHandlerPos();
- emit lineChanged();
+ if (m_line == line) return;
+ prepareGeometryChange();
+ m_line = line;
+ adjusteHandlerPos();
+ emit lineChanged();
}
void PartLine::setFirstEndType(const Qet::EndType &et)
{
- if (first_end == et) return;
- prepareGeometryChange();
- first_end = et;
- emit firstEndTypeChanged();
+ if (first_end == et) return;
+ prepareGeometryChange();
+ first_end = et;
+ emit firstEndTypeChanged();
}
void PartLine::setSecondEndType(const Qet::EndType &et)
{
- if (second_end == et) return;
- prepareGeometryChange();
- second_end = et;
- emit secondEndTypeChanged();
+ if (second_end == et) return;
+ prepareGeometryChange();
+ second_end = et;
+ emit secondEndTypeChanged();
}
void PartLine::setFirstEndLength(const qreal &l)
{
- qreal length = qMin(qAbs(l), m_line.length());
- if (first_length == length) return;
- prepareGeometryChange();
- first_length = length;
- emit firstEndLengthChanged();
+ qreal length = qMin(qAbs(l), m_line.length());
+ if (first_length == length) return;
+ prepareGeometryChange();
+ first_length = length;
+ emit firstEndLengthChanged();
}
void PartLine::setSecondEndLength(const qreal &l)
{
- qreal length = qMin(qAbs(l), m_line.length());
- if (second_length == length) return;
- prepareGeometryChange();
- second_length = length;
- emit secondEndLengthChanged();
+ qreal length = qMin(qAbs(l), m_line.length());
+ if (second_length == length) return;
+ prepareGeometryChange();
+ second_length = length;
+ emit secondEndLengthChanged();
}
/**
- @brief PartLine::path
- @return this line has a QPainterPath.
- It's notably use when this line have an end type (circle, triangle etc....),
- because return a QPainterPath with end already draw.
- Else if there isn't an end type get P1 and P2 of line is better (faster).
+ @brief PartLine::path
+ @return this line has a QPainterPath.
+ It's notably use when this line have an end type (circle, triangle etc....),
+ because return a QPainterPath with end already draw.
+ Else if there isn't an end type get P1 and P2 of line is better (faster).
*/
QPainterPath PartLine::path() const
{
- QPainterPath path;
+ QPainterPath path;
- QPointF point1(m_line.p1());
- QPointF point2(m_line.p2());
+ QPointF point1(m_line.p1());
+ QPointF point2(m_line.p2());
- qreal line_length(m_line.length());
- qreal pen_width = penWeight();
+ qreal line_length(m_line.length());
+ qreal pen_width = penWeight();
- qreal length1 = first_length;
- qreal length2 = second_length;
+ qreal length1 = first_length;
+ qreal length2 = second_length;
- //debugPaint(painter);
+ //debugPaint(painter);
- //Determine if we must to draw extremity
- qreal reduced_line_length = line_length - (length1 * requiredLengthForEndType(first_end));
- bool draw_1st_end = first_end && reduced_line_length >= 0;
+ //Determine if we must to draw extremity
+ qreal reduced_line_length = line_length - (length1 * requiredLengthForEndType(first_end));
+ bool draw_1st_end = first_end && reduced_line_length >= 0;
- if (draw_1st_end)
- reduced_line_length -= (length2 * requiredLengthForEndType(second_end));
- else
- reduced_line_length = line_length - (length2 * requiredLengthForEndType(second_end));
+ if (draw_1st_end)
+ reduced_line_length -= (length2 * requiredLengthForEndType(second_end));
+ else
+ reduced_line_length = line_length - (length2 * requiredLengthForEndType(second_end));
- //Draw the first extremity
- QPointF start_point;
- if (draw_1st_end)
- {
- QList four_points1(fourEndPoints(point1, point2, length1));
+ //Draw the first extremity
+ QPointF start_point;
+ if (draw_1st_end)
+ {
+ QList four_points1(fourEndPoints(point1, point2, length1));
- if (first_end == Qet::Circle)
- {
- path.addEllipse(QRectF(four_points1[0] - QPointF(length1, length1), QSizeF(length1 * 2.0, length1 * 2.0)));
- start_point = four_points1[1];
- }
- else if (first_end == Qet::Diamond)
- {
- path.addPolygon(QPolygonF() << four_points1[1] << four_points1[2] << point1 << four_points1[3] << four_points1[1]);
- start_point = four_points1[1];
- }
- else if (first_end == Qet::Simple)
- {
- path.addPolygon(QPolygonF() << four_points1[3] << point1 << four_points1[2]);
- start_point = point1;
+ if (first_end == Qet::Circle)
+ {
+ path.addEllipse(QRectF(four_points1[0] - QPointF(length1, length1), QSizeF(length1 * 2.0, length1 * 2.0)));
+ start_point = four_points1[1];
+ }
+ else if (first_end == Qet::Diamond)
+ {
+ path.addPolygon(QPolygonF() << four_points1[1] << four_points1[2] << point1 << four_points1[3] << four_points1[1]);
+ start_point = four_points1[1];
+ }
+ else if (first_end == Qet::Simple)
+ {
+ path.addPolygon(QPolygonF() << four_points1[3] << point1 << four_points1[2]);
+ start_point = point1;
- }
- else if (first_end == Qet::Triangle)
- {
- path.addPolygon(QPolygonF() << four_points1[0] << four_points1[2] << point1 << four_points1[3] << four_points1[0]);
- start_point = four_points1[0];
- }
+ }
+ else if (first_end == Qet::Triangle)
+ {
+ path.addPolygon(QPolygonF() << four_points1[0] << four_points1[2] << point1 << four_points1[3] << four_points1[0]);
+ start_point = four_points1[0];
+ }
- //Adjust the start point according to the pen width
- if (pen_width && (first_end == Qet::Simple || first_end == Qet::Circle))
- start_point = QLineF(start_point, point2).pointAt(pen_width / 2.0 / line_length);
- }
- else
- {
- start_point = point1;
- }
+ //Adjust the start point according to the pen width
+ if (pen_width && (first_end == Qet::Simple || first_end == Qet::Circle))
+ start_point = QLineF(start_point, point2).pointAt(pen_width / 2.0 / line_length);
+ }
+ else
+ {
+ start_point = point1;
+ }
- //Draw the second extremity
- QPointF stop_point;
- bool draw_2nd_end = second_end && reduced_line_length >= 0;
- if (draw_2nd_end)
- {
- QList four_points2(fourEndPoints(point2, point1, length2));
+ //Draw the second extremity
+ QPointF stop_point;
+ bool draw_2nd_end = second_end && reduced_line_length >= 0;
+ if (draw_2nd_end)
+ {
+ QList four_points2(fourEndPoints(point2, point1, length2));
- if (second_end == Qet::Circle)
- {
- path.addEllipse(QRectF(four_points2[0] - QPointF(length2, length2), QSizeF(length2 * 2.0, length2 * 2.0)));
- stop_point = four_points2[1];
- }
- else if (second_end == Qet::Diamond)
- {
- path.addPolygon(QPolygonF() << four_points2[2] << point2 << four_points2[3] << four_points2[1] << four_points2[2]);
- stop_point = four_points2[1];
- }
- else if (second_end == Qet::Simple)
- {
- path.addPolygon(QPolygonF() << four_points2[3] << point2 << four_points2[2]);
- stop_point = point2;
- }
- else if (second_end == Qet::Triangle)
- {/**
- @return true si cette partie n'est pas pertinente et ne merite pas d'etre
- conservee / enregistree.
- Une ligne est pertinente des lors que ses deux points sont differents
+ if (second_end == Qet::Circle)
+ {
+ path.addEllipse(QRectF(four_points2[0] - QPointF(length2, length2), QSizeF(length2 * 2.0, length2 * 2.0)));
+ stop_point = four_points2[1];
+ }
+ else if (second_end == Qet::Diamond)
+ {
+ path.addPolygon(QPolygonF() << four_points2[2] << point2 << four_points2[3] << four_points2[1] << four_points2[2]);
+ stop_point = four_points2[1];
+ }
+ else if (second_end == Qet::Simple)
+ {
+ path.addPolygon(QPolygonF() << four_points2[3] << point2 << four_points2[2]);
+ stop_point = point2;
+ }
+ else if (second_end == Qet::Triangle)
+ {/**
+ @return true si cette partie n'est pas pertinente et ne merite pas d'etre
+ conservee / enregistree.
+ Une ligne est pertinente des lors que ses deux points sont differents
*/
- path.addPolygon(QPolygonF() << four_points2[0] << four_points2[2] << point2 << four_points2[3] << four_points2[0]);
- stop_point = four_points2[0];
- }
+ path.addPolygon(QPolygonF() << four_points2[0] << four_points2[2] << point2 << four_points2[3] << four_points2[0]);
+ stop_point = four_points2[0];
+ }
- //Adjust the end point accordint to the pen width
- if (pen_width && (second_end == Qet::Simple || second_end == Qet::Circle))
- stop_point = QLineF(point1, stop_point).pointAt((line_length - (pen_width / 2.0)) / line_length);
- }
- else
- {
- stop_point = point2;
- }
+ //Adjust the end point accordint to the pen width
+ if (pen_width && (second_end == Qet::Simple || second_end == Qet::Circle))
+ stop_point = QLineF(point1, stop_point).pointAt((line_length - (pen_width / 2.0)) / line_length);
+ }
+ else
+ {
+ stop_point = point2;
+ }
- path.moveTo(start_point);
- path.lineTo(stop_point);
+ path.moveTo(start_point);
+ path.lineTo(stop_point);
- return path;
+ return path;
}
diff --git a/sources/editor/graphicspart/partline.h b/sources/editor/graphicspart/partline.h
index 589335ba2..22635d2d1 100644
--- a/sources/editor/graphicspart/partline.h
+++ b/sources/editor/graphicspart/partline.h
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
-
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#ifndef PART_LINE_H
#define PART_LINE_H
@@ -25,104 +25,104 @@ class QPropertyUndoCommand;
class QetGraphicsHandlerItem;
/**
- This class represents a line primitive which may be used to compose the
- drawing of an electrical element within the element editor. Lines may have
- specific visual ends (e.g. arrows) through the setFirstEndType and
- setSecondEndType methods. Their size can be defined using the
- setFirstEndLength and setSecondEndLength methods. Please note ends are not
- drawn if the required length for their drawing is longer than the line itself.
- In case there is room for a single end only, the first one get priority.
+ This class represents a line primitive which may be used to compose the
+ drawing of an electrical element within the element editor. Lines may have
+ specific visual ends (e.g. arrows) through the setFirstEndType and
+ setSecondEndType methods. Their size can be defined using the
+ setFirstEndLength and setSecondEndLength methods. Please note ends are not
+ drawn if the required length for their drawing is longer than the line itself.
+ In case there is room for a single end only, the first one get priority.
*/
class PartLine : public CustomElementGraphicPart
{
- Q_OBJECT
+ Q_OBJECT
- Q_PROPERTY(Qet::EndType end1 READ firstEndType WRITE setFirstEndType)
- Q_PROPERTY(Qet::EndType end2 READ secondEndType WRITE setSecondEndType)
- Q_PROPERTY(qreal length1 READ firstEndLength WRITE setFirstEndLength)
- Q_PROPERTY(qreal length2 READ secondEndLength WRITE setSecondEndLength)
- Q_PROPERTY(QLineF line READ line WRITE setLine)
+ Q_PROPERTY(Qet::EndType end1 READ firstEndType WRITE setFirstEndType)
+ Q_PROPERTY(Qet::EndType end2 READ secondEndType WRITE setSecondEndType)
+ Q_PROPERTY(qreal length1 READ firstEndLength WRITE setFirstEndLength)
+ Q_PROPERTY(qreal length2 READ secondEndLength WRITE setSecondEndLength)
+ Q_PROPERTY(QLineF line READ line WRITE setLine)
- // constructors, destructor
- public:
- PartLine(QETElementEditor *, QGraphicsItem * = nullptr);
- ~PartLine() override;
- private:
- PartLine(const PartLine &);
+ // constructors, destructor
+ public:
+ PartLine(QETElementEditor *, QGraphicsItem * = nullptr);
+ ~PartLine() override;
+ private:
+ PartLine(const PartLine &);
- signals:
- void lineChanged();
- void firstEndTypeChanged();
- void secondEndTypeChanged();
- void firstEndLengthChanged();
- void secondEndLengthChanged();
+ signals:
+ void lineChanged();
+ void firstEndTypeChanged();
+ void secondEndTypeChanged();
+ void firstEndLengthChanged();
+ void secondEndLengthChanged();
-
- // methods
- public:
- enum { Type = UserType + 1104 };
-
- /**
- Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartLine.
- @return the QGraphicsItem type
- */
- int type() const override { return Type; }
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
- QString name() const override { return(QObject::tr("ligne", "element part name")); }
- QString xmlName() const override { return(QString("line")); }
- const QDomElement toXml(QDomDocument &) const override;
- void fromXml(const QDomElement &) override;
- virtual QPointF sceneP1() const;
- virtual QPointF sceneP2() const;
- QPainterPath shape() const override;
- QPainterPath shadowShape() const override;
- QRectF boundingRect() const override;
- bool isUseless() const override;
- QRectF sceneGeometricRect() const override;
- void startUserTransformation(const QRectF &) override;
- void handleUserTransformation(const QRectF &, const QRectF &) override;
- static uint requiredLengthForEndType(const Qet::EndType &);
- static QList fourEndPoints(const QPointF &, const QPointF &, const qreal &);
+
+ // methods
+ public:
+ enum { Type = UserType + 1104 };
+
+ /**
+ Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartLine.
+ @return the QGraphicsItem type
+ */
+ int type() const override { return Type; }
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
+ QString name() const override { return(QObject::tr("ligne", "element part name")); }
+ QString xmlName() const override { return(QString("line")); }
+ const QDomElement toXml(QDomDocument &) const override;
+ void fromXml(const QDomElement &) override;
+ virtual QPointF sceneP1() const;
+ virtual QPointF sceneP2() const;
+ QPainterPath shape() const override;
+ QPainterPath shadowShape() const override;
+ QRectF boundingRect() const override;
+ bool isUseless() const override;
+ QRectF sceneGeometricRect() const override;
+ void startUserTransformation(const QRectF &) override;
+ void handleUserTransformation(const QRectF &, const QRectF &) override;
+ static uint requiredLengthForEndType(const Qet::EndType &);
+ static QList fourEndPoints(const QPointF &, const QPointF &, const qreal &);
- QLineF line() const;
- void setLine(const QLineF &line);
- Qet::EndType firstEndType() const {return first_end;}
- void setFirstEndType(const Qet::EndType &et);
- Qet::EndType secondEndType() const {return second_end;}
- void setSecondEndType(const Qet::EndType &et);
- qreal firstEndLength() const {return first_length;}
- void setFirstEndLength(const qreal &l);
- qreal secondEndLength() const {return second_length;}
- void setSecondEndLength(const qreal &l);
+ QLineF line() const;
+ void setLine(const QLineF &line);
+ Qet::EndType firstEndType() const {return first_end;}
+ void setFirstEndType(const Qet::EndType &et);
+ Qet::EndType secondEndType() const {return second_end;}
+ void setSecondEndType(const Qet::EndType &et);
+ qreal firstEndLength() const {return first_length;}
+ void setFirstEndLength(const qreal &l);
+ qreal secondEndLength() const {return second_length;}
+ void setSecondEndLength(const qreal &l);
- protected:
- QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
- bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
-
- private:
- void adjusteHandlerPos();
- void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
- void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
- void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
- void sceneSelectionChanged ();
-
- void addHandler();
- void removeHandler();
-
- QPainterPath path() const;
- QRectF firstEndCircleRect() const;
- QRectF secondEndCircleRect() const;
+ protected:
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
+ bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
+
+ private:
+ void adjusteHandlerPos();
+ void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
+ void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
+ void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
+ void sceneSelectionChanged ();
+
+ void addHandler();
+ void removeHandler();
+
+ QPainterPath path() const;
+ QRectF firstEndCircleRect() const;
+ QRectF secondEndCircleRect() const;
- /*****************/
- Qet::EndType first_end;
- qreal first_length;
+ /*****************/
+ Qet::EndType first_end;
+ qreal first_length;
- Qet::EndType second_end;
- qreal second_length;
- QList saved_points_;
- QLineF m_line;
- int m_vector_index = -1;
- QPropertyUndoCommand *m_undo_command;
- QVector m_handler_vector;
+ Qet::EndType second_end;
+ qreal second_length;
+ QList saved_points_;
+ QLineF m_line;
+ int m_vector_index = -1;
+ QPropertyUndoCommand *m_undo_command;
+ QVector m_handler_vector;
};
#endif
diff --git a/sources/editor/graphicspart/partpolygon.cpp b/sources/editor/graphicspart/partpolygon.cpp
index 89e21beb9..5b00d585f 100644
--- a/sources/editor/graphicspart/partpolygon.cpp
+++ b/sources/editor/graphicspart/partpolygon.cpp
@@ -1,19 +1,19 @@
/*
- Copyright 2006-2020 The QElectroTech Team
- This file is part of QElectroTech.
+ Copyright 2006-2020 The QElectroTech Team
+ This file is part of QElectroTech.
- QElectroTech is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
- QElectroTech is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with QElectroTech. If not, see .
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
*/
#include "partpolygon.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
@@ -25,593 +25,593 @@
/**
- @brief PartPolygon::PartPolygon
- Constructor
- @param editor : editor of this item
- @param parent : parent item
+ @brief PartPolygon::PartPolygon
+ Constructor
+ @param editor : editor of this item
+ @param parent : parent item
*/
PartPolygon::PartPolygon(QETElementEditor *editor, QGraphicsItem *parent) :
- CustomElementGraphicPart(editor, parent),
- m_closed(false),
- m_undo_command(nullptr)
+ CustomElementGraphicPart(editor, parent),
+ m_closed(false),
+ m_undo_command(nullptr)
{
- m_insert_point = new QAction(tr("Ajouter un point"), this);
- m_insert_point->setIcon(QET::Icons::Add);
- connect(m_insert_point, &QAction::triggered, this, &PartPolygon::insertPoint);
- m_remove_point = new QAction(tr("Supprimer ce point"), this);
- m_remove_point->setIcon(QET::Icons::Remove);
- connect(m_remove_point, &QAction::triggered, this, &PartPolygon::removePoint);
+ m_insert_point = new QAction(tr("Ajouter un point"), this);
+ m_insert_point->setIcon(QET::Icons::Add);
+ connect(m_insert_point, &QAction::triggered, this, &PartPolygon::insertPoint);
+ m_remove_point = new QAction(tr("Supprimer ce point"), this);
+ m_remove_point->setIcon(QET::Icons::Remove);
+ connect(m_remove_point, &QAction::triggered, this, &PartPolygon::removePoint);
}
/**
- @brief PartPolygon::~PartPolygon
+ @brief PartPolygon::~PartPolygon
*/
PartPolygon::~PartPolygon()
{
- if(m_undo_command) delete m_undo_command;
- removeHandler();
+ if(m_undo_command) delete m_undo_command;
+ removeHandler();
}
/**
- @brief PartPolygon::paint
- Draw this polygon
- @param painter
- @param options
- @param widget
+ @brief PartPolygon::paint
+ Draw this polygon
+ @param painter
+ @param options
+ @param widget
*/
void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget)
{
Q_UNUSED(widget)
- applyStylesToQPainter(*painter);
+ applyStylesToQPainter(*painter);
- QPen t = painter -> pen();
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
- t.setCosmetic(options && options -> levelOfDetail < 1.0);
+ QPen t = painter -> pen();
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
+ t.setCosmetic(options && options -> levelOfDetail < 1.0);
#else
#if TODO_LIST
#pragma message("@TODO remove code for QT 6 or later")
#endif
- t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
+ t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
#endif
- if (isSelected()) t.setColor(Qt::red);
- painter -> setPen(t);
+ if (isSelected()) t.setColor(Qt::red);
+ painter -> setPen(t);
- m_closed ? painter -> drawPolygon (m_polygon) :
- painter -> drawPolyline(m_polygon);
+ m_closed ? painter -> drawPolygon (m_polygon) :
+ painter -> drawPolyline(m_polygon);
- if (m_hovered)
- drawShadowShape(painter);
+ if (m_hovered)
+ drawShadowShape(painter);
}
/**
- @brief PartPolygon::fromXml
- Import the properties of this polygon from a xml element
- @param qde : Xml document to use
+ @brief PartPolygon::fromXml
+ Import the properties of this polygon from a xml element
+ @param qde : Xml document to use
*/
void PartPolygon::fromXml(const QDomElement &qde)
{
- stylesFromXml(qde);
+ stylesFromXml(qde);
- int i = 1;
- while(true)
- {
- if (QET::attributeIsAReal(qde, QString("x%1").arg(i)) &&\
- QET::attributeIsAReal(qde, QString("y%1").arg(i)))
- ++ i;
+ int i = 1;
+ while(true)
+ {
+ if (QET::attributeIsAReal(qde, QString("x%1").arg(i)) &&\
+ QET::attributeIsAReal(qde, QString("y%1").arg(i)))
+ ++ i;
- else break;
- }
+ else break;
+ }
- QPolygonF temp_polygon;
- for (int j = 1 ; j < i ; ++ j)
- {
- temp_polygon << QPointF(qde.attribute(QString("x%1").arg(j)).toDouble(),
- qde.attribute(QString("y%1").arg(j)).toDouble());
- }
- m_polygon = temp_polygon;
+ QPolygonF temp_polygon;
+ for (int j = 1 ; j < i ; ++ j)
+ {
+ temp_polygon << QPointF(qde.attribute(QString("x%1").arg(j)).toDouble(),
+ qde.attribute(QString("y%1").arg(j)).toDouble());
+ }
+ m_polygon = temp_polygon;
- m_closed = qde.attribute("closed") != "false";
+ m_closed = qde.attribute("closed") != "false";
}
/**
- @brief PartPolygon::toXml
- Export this polygin in xml
- @param xml_document : Xml document to use for create the xml element
- @return an xml element that describe this polygon
+ @brief PartPolygon::toXml
+ Export this polygin in xml
+ @param xml_document : Xml document to use for create the xml element
+ @return an xml element that describe this polygon
*/
const QDomElement PartPolygon::toXml(QDomDocument &xml_document) const
{
- QDomElement xml_element = xml_document.createElement("polygon");
- int i = 1;
- foreach(QPointF point, m_polygon) {
- point = mapToScene(point);
- xml_element.setAttribute(QString("x%1").arg(i), QString("%1").arg(point.x()));
- xml_element.setAttribute(QString("y%1").arg(i), QString("%1").arg(point.y()));
- ++ i;
- }
- if (!m_closed) xml_element.setAttribute("closed", "false");
- stylesToXml(xml_element);
- return(xml_element);
+ QDomElement xml_element = xml_document.createElement("polygon");
+ int i = 1;
+ foreach(QPointF point, m_polygon) {
+ point = mapToScene(point);
+ xml_element.setAttribute(QString("x%1").arg(i), QString("%1").arg(point.x()));
+ xml_element.setAttribute(QString("y%1").arg(i), QString("%1").arg(point.y()));
+ ++ i;
+ }
+ if (!m_closed) xml_element.setAttribute("closed", "false");
+ stylesToXml(xml_element);
+ return(xml_element);
}
/**
- @brief PartPolygon::isUseless
- @return true if this part is irrelevant and does not deserve to be Retained / registered.
- A polygon is relevant when he have 2 differents points
+ @brief PartPolygon::isUseless
+ @return true if this part is irrelevant and does not deserve to be Retained / registered.
+ A polygon is relevant when he have 2 differents points
*/
bool PartPolygon::isUseless() const
{
- if (m_polygon.count() < 2) return(true);
+ if (m_polygon.count() < 2) return(true);
- for (int i = 1 ; i < m_polygon.count() ; ++ i)
- if (m_polygon[i] != m_polygon[i-1]) return(false);
+ for (int i = 1 ; i < m_polygon.count() ; ++ i)
+ if (m_polygon[i] != m_polygon[i-1]) return(false);
- return(true);
+ return(true);
}
/**
- @brief PartPolygon::sceneGeometricRect
- @return the minimum, margin-less rectangle this part can fit into, in scene
- coordinates. It is different from boundingRect() because it is not supposed
- to imply any margin, and it is different from shape because it is a regular
- rectangle, not a complex shape.
+ @brief PartPolygon::sceneGeometricRect
+ @return the minimum, margin-less rectangle this part can fit into, in scene
+ coordinates. It is different from boundingRect() because it is not supposed
+ to imply any margin, and it is different from shape because it is a regular
+ rectangle, not a complex shape.
*/
QRectF PartPolygon::sceneGeometricRect() const
{
- return(mapToScene(m_polygon.boundingRect()).boundingRect());
+ return(mapToScene(m_polygon.boundingRect()).boundingRect());
}
/**
- @brief PartPolygon::startUserTransformation
- Start the user-induced transformation, provided this primitive is contained
- within the initial_selection_rect bounding rectangle.
- @param initial_selection_rect
+ @brief PartPolygon::startUserTransformation
+ Start the user-induced transformation, provided this primitive is contained
+ within the initial_selection_rect bounding rectangle.
+ @param initial_selection_rect
*/
void PartPolygon::startUserTransformation(const QRectF &initial_selection_rect)
{
- Q_UNUSED(initial_selection_rect)
- saved_points_ = mapToScene(m_polygon).toList();
+ Q_UNUSED(initial_selection_rect)
+ saved_points_ = mapToScene(m_polygon).toList();
}
/**
- @brief PartPolygon::handleUserTransformation
- Handle the user-induced transformation from initial_selection_rect to new_selection_rect
- @param initial_selection_rect
- @param new_selection_rect
+ @brief PartPolygon::handleUserTransformation
+ Handle the user-induced transformation from initial_selection_rect to new_selection_rect
+ @param initial_selection_rect
+ @param new_selection_rect
*/
void PartPolygon::handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect)
{
- QList mapped_points = mapPoints(initial_selection_rect, new_selection_rect, saved_points_);
- m_polygon = (mapFromScene(QPolygonF(mapped_points.toVector())));
+ QList mapped_points = mapPoints(initial_selection_rect, new_selection_rect, saved_points_);
+ m_polygon = (mapFromScene(QPolygonF(mapped_points.toVector())));
}
/**
- @brief PartPolygon::preferredScalingMethod
- This method is called by the decorator when it needs to determine the best
- way to interactively scale a primitive. It is typically called when only a
- single primitive is being scaled.
- @return : This reimplementation systematically returns QET::RoundScaleRatios.
+ @brief PartPolygon::preferredScalingMethod
+ This method is called by the decorator when it needs to determine the best
+ way to interactively scale a primitive. It is typically called when only a
+ single primitive is being scaled.
+ @return : This reimplementation systematically returns QET::RoundScaleRatios.
*/
QET::ScalingMethod PartPolygon::preferredScalingMethod() const
{
- return(QET::RoundScaleRatios);
+ return(QET::RoundScaleRatios);
}
/**
- @brief PartPolygon::polygon
- @return the item's polygon, or an empty polygon if no polygon has been set.
+ @brief PartPolygon::polygon
+ @return the item's polygon, or an empty polygon if no polygon has been set.
*/
QPolygonF PartPolygon::polygon() const
{
- return m_polygon;
+ return m_polygon;
}
/**
- @brief PartPolygon::setPolygon
- Sets the item's polygon to be the given polygon.
- @param polygon
+ @brief PartPolygon::setPolygon
+ Sets the item's polygon to be the given polygon.
+ @param polygon
*/
void PartPolygon::setPolygon(const QPolygonF &polygon)
{
- if (m_polygon == polygon) return;
- prepareGeometryChange();
- m_polygon = polygon;
- adjusteHandlerPos();
- emit polygonChanged();
+ if (m_polygon == polygon) return;
+ prepareGeometryChange();
+ m_polygon = polygon;
+ adjusteHandlerPos();
+ emit polygonChanged();
}
/**
- @brief PartPolygon::addPoint
- Add new point to polygon
- @param point
+ @brief PartPolygon::addPoint
+ Add new point to polygon
+ @param point
*/
void PartPolygon::addPoint(const QPointF &point)
{
- prepareGeometryChange();
- m_polygon << point;
+ prepareGeometryChange();
+ m_polygon << point;
}
/**
- @brief PartPolygon::setLastPoint
- Set the last point of polygon to point
- @param point
+ @brief PartPolygon::setLastPoint
+ Set the last point of polygon to point
+ @param point
*/
void PartPolygon::setLastPoint(const QPointF &point)
{
- if (m_polygon.size())
- m_polygon.pop_back();
+ if (m_polygon.size())
+ m_polygon.pop_back();
- prepareGeometryChange();
- m_polygon << point;
+ prepareGeometryChange();
+ m_polygon << point;
}
/**
- @brief PartPolygon::removeLastPoint
- Remove the last point of polygon
+ @brief PartPolygon::removeLastPoint
+ Remove the last point of polygon
*/
void PartPolygon::removeLastPoint()
{
- if (m_polygon.size())
- {
- prepareGeometryChange();
- m_polygon.pop_back();
- }
+ if (m_polygon.size())
+ {
+ prepareGeometryChange();
+ m_polygon.pop_back();
+ }
}
void PartPolygon::setClosed(bool close)
{
- if (m_closed == close) return;
- prepareGeometryChange();
- m_closed = close;
- emit closedChange();
+ if (m_closed == close) return;
+ prepareGeometryChange();
+ m_closed = close;
+ emit closedChange();
}
/**
- @brief PartPolygon::setHandlerColor
- Set the handler at pos pos (in polygon coordinate) to color color.
- @param pos
- @param color
+ @brief PartPolygon::setHandlerColor
+ Set the handler at pos pos (in polygon coordinate) to color color.
+ @param pos
+ @param color
*/
void PartPolygon::setHandlerColor(QPointF pos, const QColor &color)
{
- for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
- if (qghi->pos() == mapToScene(pos)) {
- qghi->setColor(color);
- }
- }
+ for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
+ if (qghi->pos() == mapToScene(pos)) {
+ qghi->setColor(color);
+ }
+ }
}
/**
- @brief PartPolygon::resetAllHandlerColor
- Reset the color of every handlers
+ @brief PartPolygon::resetAllHandlerColor
+ Reset the color of every handlers
*/
void PartPolygon::resetAllHandlerColor()
{
- for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
- qghi->setColor(Qt::blue);
- }
+ for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
+ qghi->setColor(Qt::blue);
+ }
}
/**
- @brief PartPolygon::itemChange
- @param change
- @param value
- @return
+ @brief PartPolygon::itemChange
+ @param change
+ @param value
+ @return
*/
QVariant PartPolygon::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
- if (change == ItemSelectedHasChanged && scene())
- {
- if (value.toBool() == true)
- {
- //When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler,
- //according to the number of selected items.
- connect(scene(), &QGraphicsScene::selectionChanged, this, &PartPolygon::sceneSelectionChanged);
+ if (change == ItemSelectedHasChanged && scene())
+ {
+ if (value.toBool() == true)
+ {
+ //When item is selected, he must to be up to date whene the selection in the scene change, for display or not the handler,
+ //according to the number of selected items.
+ connect(scene(), &QGraphicsScene::selectionChanged, this, &PartPolygon::sceneSelectionChanged);
- if (scene()->selectedItems().size() == 1)
- addHandler();
- }
- else
- {
- disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartPolygon::sceneSelectionChanged);
- removeHandler();
- }
- }
- else if (change == ItemPositionHasChanged)
- {
- adjusteHandlerPos();
- }
- else if (change == ItemSceneChange)
- {
- if(scene())
- disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartPolygon::sceneSelectionChanged);
+ if (scene()->selectedItems().size() == 1)
+ addHandler();
+ }
+ else
+ {
+ disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartPolygon::sceneSelectionChanged);
+ removeHandler();
+ }
+ }
+ else if (change == ItemPositionHasChanged)
+ {
+ adjusteHandlerPos();
+ }
+ else if (change == ItemSceneChange)
+ {
+ if(scene())
+ disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartPolygon::sceneSelectionChanged);
- setSelected(false); //This is item removed from scene, then we deselect this, and so, the handlers is also removed.
- }
+ setSelected(false); //This is item removed from scene, then we deselect this, and so, the handlers is also removed.
+ }
- return QGraphicsItem::itemChange(change, value);
+ return QGraphicsItem::itemChange(change, value);
}
/**
- @brief PartPolygon::sceneEventFilter
- @param watched
- @param event
- @return
+ @brief PartPolygon::sceneEventFilter
+ @param watched
+ @param event
+ @return
*/
bool PartPolygon::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
{
- //Watched must be an handler
- if(watched->type() == QetGraphicsHandlerItem::Type)
- {
- QetGraphicsHandlerItem *qghi = qgraphicsitem_cast(watched);
+ //Watched must be an handler
+ if(watched->type() == QetGraphicsHandlerItem::Type)
+ {
+ QetGraphicsHandlerItem *qghi = qgraphicsitem_cast(watched);
- if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
- {
- m_vector_index = m_handler_vector.indexOf(qghi);
- if (m_vector_index != -1)
- {
- if(event->type() == QEvent::GraphicsSceneMousePress) //Click
- {
- handlerMousePressEvent(qghi, static_cast