mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
replace 4 spaces by a tab
This commit is contained in:
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef QETGRAPHICSHANDLERITEM_H
|
#ifndef QETGRAPHICSHANDLERITEM_H
|
||||||
#define QETGRAPHICSHANDLERITEM_H
|
#define QETGRAPHICSHANDLERITEM_H
|
||||||
@@ -22,43 +22,43 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The QetGraphicsHandlerItem class
|
@brief The QetGraphicsHandlerItem class
|
||||||
This graphics item represents a point,
|
This graphics item represents a point,
|
||||||
destined to be used as an handler,
|
destined to be used as an handler,
|
||||||
for modifie the geometrie of a another graphics item (like shapes).
|
for modifie the geometrie of a another graphics item (like shapes).
|
||||||
The graphics item to be modified,
|
The graphics item to be modified,
|
||||||
must call "installSceneEventFilter"
|
must call "installSceneEventFilter"
|
||||||
of this item with itself for argument,.
|
of this item with itself for argument,.
|
||||||
The ghraphics item to be modified,
|
The ghraphics item to be modified,
|
||||||
need to reimplement "sceneEventFilter"
|
need to reimplement "sceneEventFilter"
|
||||||
for create the modification behavior.
|
for create the modification behavior.
|
||||||
*/
|
*/
|
||||||
class QetGraphicsHandlerItem : public QGraphicsItem
|
class QetGraphicsHandlerItem : public QGraphicsItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QetGraphicsHandlerItem(qreal size = 10);
|
QetGraphicsHandlerItem(qreal size = 10);
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
|
|
||||||
enum { Type = UserType + 1200};
|
enum { Type = UserType + 1200};
|
||||||
int type() const override {return Type;}
|
int type() const override {return Type;}
|
||||||
|
|
||||||
void setColor(QColor color);
|
void setColor(QColor color);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paint(QPainter *painter,
|
void paint(QPainter *painter,
|
||||||
const QStyleOptionGraphicsItem *option,
|
const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget) override;
|
QWidget *widget) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRectF m_handler_rect,
|
QRectF m_handler_rect,
|
||||||
m_br;
|
m_br;
|
||||||
qreal m_size;
|
qreal m_size;
|
||||||
QColor m_color{Qt::black};
|
QColor m_color{Qt::black};
|
||||||
QPen m_pen;
|
QPen m_pen;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QVector<QetGraphicsHandlerItem *> handlerForPoint(
|
static QVector<QetGraphicsHandlerItem *> handlerForPoint(
|
||||||
const QVector<QPointF> &points, int size = 10);
|
const QVector<QPointF> &points, int size = 10);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QETGRAPHICSHANDLERITEM_H
|
#endif // QETGRAPHICSHANDLERITEM_H
|
||||||
|
|||||||
@@ -1,192 +1,192 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "borderproperties.h"
|
#include "borderproperties.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief BorderProperties::BorderProperties
|
@brief BorderProperties::BorderProperties
|
||||||
constructor
|
constructor
|
||||||
Initializes a BorderProperties object with default properties
|
Initializes a BorderProperties object with default properties
|
||||||
|
|
||||||
Initializes a BorderProperties object
|
Initializes a BorderProperties object
|
||||||
with the following default properties:
|
with the following default properties:
|
||||||
- 17 columns of 60.0 px wide by 20.0px high
|
- 17 columns of 60.0 px wide by 20.0px high
|
||||||
- 8 lines of 80.0 px high by 20.0px wide
|
- 8 lines of 80.0 px high by 20.0px wide
|
||||||
|
|
||||||
\~French Initialise un objet BorderProperties avec les proprietes par
|
\~French Initialise un objet BorderProperties avec les proprietes par
|
||||||
defaut suivantes :
|
defaut suivantes :
|
||||||
- 17 colonnes affichees de 60.0 px de large pour 20.0px de haut
|
- 17 colonnes affichees de 60.0 px de large pour 20.0px de haut
|
||||||
- 8 lignes affichees de 80.0 px de haut pour 20.0px de large
|
- 8 lignes affichees de 80.0 px de haut pour 20.0px de large
|
||||||
*/
|
*/
|
||||||
BorderProperties::BorderProperties()
|
BorderProperties::BorderProperties()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief BorderProperties::~BorderProperties
|
@brief BorderProperties::~BorderProperties
|
||||||
destructor
|
destructor
|
||||||
*/
|
*/
|
||||||
BorderProperties::~BorderProperties()
|
BorderProperties::~BorderProperties()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief BorderProperties::operator ==
|
@brief BorderProperties::operator ==
|
||||||
|
|
||||||
\~ @param bp : Other BorderProperties container/class.
|
\~ @param bp : Other BorderProperties container/class.
|
||||||
\~French Autre conteneur BorderProperties
|
\~French Autre conteneur BorderProperties
|
||||||
\~ @return True if it and this container are identical, false otherwise.
|
\~ @return True if it and this container are identical, false otherwise.
|
||||||
\~French True si ip et ce conteneur sont identiques, false sinon
|
\~French True si ip et ce conteneur sont identiques, false sinon
|
||||||
*/
|
*/
|
||||||
bool BorderProperties::operator==(const BorderProperties &bp) {
|
bool BorderProperties::operator==(const BorderProperties &bp) {
|
||||||
return(
|
return(
|
||||||
bp.columns_count == columns_count &&\
|
bp.columns_count == columns_count &&\
|
||||||
bp.columns_width == columns_width &&\
|
bp.columns_width == columns_width &&\
|
||||||
bp.columns_header_height == columns_header_height &&\
|
bp.columns_header_height == columns_header_height &&\
|
||||||
bp.display_columns == display_columns &&\
|
bp.display_columns == display_columns &&\
|
||||||
bp.rows_count == rows_count &&\
|
bp.rows_count == rows_count &&\
|
||||||
bp.rows_height == rows_height &&\
|
bp.rows_height == rows_height &&\
|
||||||
bp.rows_header_width == rows_header_width &&\
|
bp.rows_header_width == rows_header_width &&\
|
||||||
bp.display_rows == display_rows
|
bp.display_rows == display_rows
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief BorderProperties::operator !=
|
@brief BorderProperties::operator !=
|
||||||
|
|
||||||
\~ @param bp :
|
\~ @param bp :
|
||||||
Other BorderProperties container/class.
|
Other BorderProperties container/class.
|
||||||
\~French Autre conteneur BorderProperties
|
\~French Autre conteneur BorderProperties
|
||||||
\~ @return
|
\~ @return
|
||||||
False if it and this container are identical, true otherwise.
|
False if it and this container are identical, true otherwise.
|
||||||
\~French False si bp et ce conteneur sont identiques, true sinon
|
\~French False si bp et ce conteneur sont identiques, true sinon
|
||||||
*/
|
*/
|
||||||
bool BorderProperties::operator!=(const BorderProperties &bp) {
|
bool BorderProperties::operator!=(const BorderProperties &bp) {
|
||||||
return(!(*this == bp));
|
return(!(*this == bp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief BorderProperties::toXml
|
@brief BorderProperties::toXml
|
||||||
Exports dimensions as XML attributes added to element e.
|
Exports dimensions as XML attributes added to element e.
|
||||||
\~French Exporte les dimensions sous formes d'attributs XML ajoutes a l'element e.
|
\~French Exporte les dimensions sous formes d'attributs XML ajoutes a l'element e.
|
||||||
|
|
||||||
\~ @param e :
|
\~ @param e :
|
||||||
XML element to which attributes will be added
|
XML element to which attributes will be added
|
||||||
\~French Element XML auquel seront ajoutes des attributs
|
\~French Element XML auquel seront ajoutes des attributs
|
||||||
*/
|
*/
|
||||||
QDomElement BorderProperties::toXml(QDomDocument &dom_doc) const {
|
QDomElement BorderProperties::toXml(QDomDocument &dom_doc) const {
|
||||||
|
|
||||||
QDomElement e = dom_doc.createElement("border");
|
QDomElement e = dom_doc.createElement("border");
|
||||||
|
|
||||||
e.appendChild(createXmlProperty(dom_doc, "cols", columns_count));
|
e.appendChild(createXmlProperty(dom_doc, "cols", columns_count));
|
||||||
e.appendChild(createXmlProperty(dom_doc, "colsize", columns_width));
|
e.appendChild(createXmlProperty(dom_doc, "colsize", columns_width));
|
||||||
e.appendChild(createXmlProperty(dom_doc, "rows", rows_count));
|
e.appendChild(createXmlProperty(dom_doc, "rows", rows_count));
|
||||||
e.appendChild(createXmlProperty(dom_doc, "rowsize", rows_height));
|
e.appendChild(createXmlProperty(dom_doc, "rowsize", rows_height));
|
||||||
e.appendChild(createXmlProperty(dom_doc, "displayrows", display_rows));
|
e.appendChild(createXmlProperty(dom_doc, "displayrows", display_rows));
|
||||||
e.appendChild(createXmlProperty(dom_doc, "displaycols", display_columns));
|
e.appendChild(createXmlProperty(dom_doc, "displaycols", display_columns));
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**RETURNS True
|
/**RETURNS True
|
||||||
@brief BorderProperties::fromXml
|
@brief BorderProperties::fromXml
|
||||||
Import dimensions from XML attributes of element e
|
Import dimensions from XML attributes of element e
|
||||||
\~French Importe les dimensions a partir des attributs XML de l'element e
|
\~French Importe les dimensions a partir des attributs XML de l'element e
|
||||||
|
|
||||||
\~ @param e :
|
\~ @param e :
|
||||||
XML element whose attributes will be read
|
XML element whose attributes will be read
|
||||||
\~French Element XML dont les attributs seront lus
|
\~French Element XML dont les attributs seront lus
|
||||||
*/
|
*/
|
||||||
bool BorderProperties::fromXml(const QDomElement &e) {
|
bool BorderProperties::fromXml(const QDomElement &e) {
|
||||||
|
|
||||||
if (propertyInteger(e, "cols", &columns_count) == PropertyFlags::NoValidConversion ||
|
if (propertyInteger(e, "cols", &columns_count) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(e, "colsize", &columns_width) == PropertyFlags::NoValidConversion ||
|
propertyDouble(e, "colsize", &columns_width) == PropertyFlags::NoValidConversion ||
|
||||||
propertyInteger(e, "rows", &rows_count) == PropertyFlags::NoValidConversion ||
|
propertyInteger(e, "rows", &rows_count) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(e, "rowsize", &rows_height) == PropertyFlags::NoValidConversion ||
|
propertyDouble(e, "rowsize", &rows_height) == PropertyFlags::NoValidConversion ||
|
||||||
propertyBool(e, "displaycols", &display_columns) == PropertyFlags::NoValidConversion ||
|
propertyBool(e, "displaycols", &display_columns) == PropertyFlags::NoValidConversion ||
|
||||||
propertyBool(e, "displayrows", &display_rows) == PropertyFlags::NoValidConversion)
|
propertyBool(e, "displayrows", &display_rows) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BorderProperties::valideXml(QDomElement& e) {
|
bool BorderProperties::valideXml(QDomElement& e) {
|
||||||
|
|
||||||
if (propertyInteger(e, "cols") == PropertyFlags::Success ||
|
if (propertyInteger(e, "cols") == PropertyFlags::Success ||
|
||||||
propertyDouble(e, "colsize") == PropertyFlags::Success ||
|
propertyDouble(e, "colsize") == PropertyFlags::Success ||
|
||||||
propertyInteger(e, "rows") == PropertyFlags::Success ||
|
propertyInteger(e, "rows") == PropertyFlags::Success ||
|
||||||
propertyDouble(e, "rowsize") == PropertyFlags::Success ||
|
propertyDouble(e, "rowsize") == PropertyFlags::Success ||
|
||||||
propertyBool(e, "displaycols") == PropertyFlags::Success ||
|
propertyBool(e, "displaycols") == PropertyFlags::Success ||
|
||||||
propertyBool(e, "displayrows") == PropertyFlags::Success)
|
propertyBool(e, "displayrows") == PropertyFlags::Success)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief BorderProperties::toSettings
|
@brief BorderProperties::toSettings
|
||||||
Export dimensions in a QSettings object.
|
Export dimensions in a QSettings object.
|
||||||
\~French Exporte les dimensions dans une configuration.
|
\~French Exporte les dimensions dans une configuration.
|
||||||
|
|
||||||
\~ @param settings :
|
\~ @param settings :
|
||||||
QSettings object to write
|
QSettings object to write
|
||||||
\~French Parametres a ecrire
|
\~French Parametres a ecrire
|
||||||
\~ @param prefix :
|
\~ @param prefix :
|
||||||
prefix to be added before the names of the parameters
|
prefix to be added before the names of the parameters
|
||||||
\~French prefixe a ajouter devant les noms des parametres
|
\~French prefixe a ajouter devant les noms des parametres
|
||||||
*/
|
*/
|
||||||
void BorderProperties::toSettings(QSettings &settings, const QString &prefix) const
|
void BorderProperties::toSettings(QSettings &settings, const QString &prefix) const
|
||||||
{
|
{
|
||||||
settings.setValue(prefix + "cols", columns_count);
|
settings.setValue(prefix + "cols", columns_count);
|
||||||
settings.setValue(prefix + "colsize", columns_width);
|
settings.setValue(prefix + "colsize", columns_width);
|
||||||
settings.setValue(prefix + "displaycols", display_columns);
|
settings.setValue(prefix + "displaycols", display_columns);
|
||||||
settings.setValue(prefix + "rows", rows_count);
|
settings.setValue(prefix + "rows", rows_count);
|
||||||
settings.setValue(prefix + "rowsize", rows_height);
|
settings.setValue(prefix + "rowsize", rows_height);
|
||||||
settings.setValue(prefix + "displayrows", display_rows);
|
settings.setValue(prefix + "displayrows", display_rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief BorderProperties::fromSettings
|
@brief BorderProperties::fromSettings
|
||||||
Import dimensions from a QSettings object.
|
Import dimensions from a QSettings object.
|
||||||
\~French Importe les dimensions depuis une configuration.
|
\~French Importe les dimensions depuis une configuration.
|
||||||
\~ @param settings : QSettings object to read
|
\~ @param settings : QSettings object to read
|
||||||
\~French Parametres a lire
|
\~French Parametres a lire
|
||||||
\~ @param prefix : prefix to be added before the names of the parameters
|
\~ @param prefix : prefix to be added before the names of the parameters
|
||||||
\~French prefixe a ajouter devant les noms des parametres
|
\~French prefixe a ajouter devant les noms des parametres
|
||||||
*/
|
*/
|
||||||
void BorderProperties::fromSettings(const QSettings &settings, const QString &prefix) {
|
void BorderProperties::fromSettings(const QSettings &settings, const QString &prefix) {
|
||||||
columns_count = settings.value(prefix + "cols", columns_count).toInt();
|
columns_count = settings.value(prefix + "cols", columns_count).toInt();
|
||||||
columns_width = qRound(settings.value(prefix + "colsize", columns_width).toDouble());
|
columns_width = qRound(settings.value(prefix + "colsize", columns_width).toDouble());
|
||||||
display_columns = settings.value(prefix + "displaycols", display_columns).toBool();
|
display_columns = settings.value(prefix + "displaycols", display_columns).toBool();
|
||||||
|
|
||||||
rows_count = settings.value(prefix + "rows", rows_count).toInt();
|
rows_count = settings.value(prefix + "rows", rows_count).toInt();
|
||||||
rows_height = qRound(settings.value(prefix + "rowsize", rows_height).toDouble());
|
rows_height = qRound(settings.value(prefix + "rowsize", rows_height).toDouble());
|
||||||
display_rows = settings.value(prefix + "displayrows", display_rows).toBool();
|
display_rows = settings.value(prefix + "displayrows", display_rows).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief BorderProperties::defaultProperties
|
@brief BorderProperties::defaultProperties
|
||||||
@return the default properties stored in the setting file
|
@return the default properties stored in the setting file
|
||||||
*/
|
*/
|
||||||
BorderProperties BorderProperties::defaultProperties()
|
BorderProperties BorderProperties::defaultProperties()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
BorderProperties def;
|
BorderProperties def;
|
||||||
def.fromSettings(settings, "diagrameditor/default");
|
def.fromSettings(settings, "diagrameditor/default");
|
||||||
|
|
||||||
return(def);
|
return(def);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef BORDER_PROPERTIES_H
|
#ifndef BORDER_PROPERTIES_H
|
||||||
#define BORDER_PROPERTIES_H
|
#define BORDER_PROPERTIES_H
|
||||||
@@ -23,37 +23,37 @@
|
|||||||
#include "propertiesinterface.h"
|
#include "propertiesinterface.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The BorderProperties class
|
@brief The BorderProperties class
|
||||||
This class is a container for dimensions and display properties of a
|
This class is a container for dimensions and display properties of a
|
||||||
diagram.
|
diagram.
|
||||||
@remark Attributes are public
|
@remark Attributes are public
|
||||||
*/
|
*/
|
||||||
class BorderProperties : public PropertiesInterface {
|
class BorderProperties : public PropertiesInterface {
|
||||||
public:
|
public:
|
||||||
// constructor, destructor, operators
|
// constructor, destructor, operators
|
||||||
BorderProperties();
|
BorderProperties();
|
||||||
virtual ~BorderProperties();
|
virtual ~BorderProperties();
|
||||||
|
|
||||||
bool operator==(const BorderProperties &);
|
bool operator==(const BorderProperties &);
|
||||||
bool operator!=(const BorderProperties &);
|
bool operator!=(const BorderProperties &);
|
||||||
|
|
||||||
QDomElement toXml(QDomDocument &dom_doc) const override;
|
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||||
bool fromXml(const QDomElement &) override;
|
bool fromXml(const QDomElement &) override;
|
||||||
static bool valideXml(QDomElement& e);
|
static bool valideXml(QDomElement& e);
|
||||||
void toSettings(QSettings &, const QString & = QString()) const;
|
void toSettings(QSettings &, const QString & = QString()) const;
|
||||||
void fromSettings(QSettings &, const QString & = QString());
|
void fromSettings(QSettings &, const QString & = QString());
|
||||||
|
|
||||||
static BorderProperties defaultProperties();
|
static BorderProperties defaultProperties();
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
int columns_count{17}; ///< Columns count
|
int columns_count{17}; ///< Columns count
|
||||||
qreal columns_width{60.0}; ///< Columns width
|
qreal columns_width{60.0}; ///< Columns width
|
||||||
qreal columns_header_height{20.0}; ///< Column headers height
|
qreal columns_header_height{20.0}; ///< Column headers height
|
||||||
bool display_columns{true}; ///< Whether to display column headers
|
bool display_columns{true}; ///< Whether to display column headers
|
||||||
|
|
||||||
int rows_count{8}; ///< Rows count
|
int rows_count{8}; ///< Rows count
|
||||||
qreal rows_height{80.0}; ///< Rows height
|
qreal rows_height{80.0}; ///< Rows height
|
||||||
qreal rows_header_width{20.0}; ///< Row headers width
|
qreal rows_header_width{20.0}; ///< Row headers width
|
||||||
bool display_rows{true}; ///< Whether to display row headers
|
bool display_rows{true}; ///< Whether to display row headers
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef BORDERTITLEBLOCK_H
|
#ifndef BORDERTITLEBLOCK_H
|
||||||
#define BORDERTITLEBLOCK_H
|
#define BORDERTITLEBLOCK_H
|
||||||
@@ -29,266 +29,266 @@ class DiagramPosition;
|
|||||||
class TitleBlockTemplate;
|
class TitleBlockTemplate;
|
||||||
class TitleBlockTemplateRenderer;
|
class TitleBlockTemplateRenderer;
|
||||||
/**
|
/**
|
||||||
@brief The BorderTitleBlock class
|
@brief The BorderTitleBlock class
|
||||||
This class represents the border and the titleblock which frame a
|
This class represents the border and the titleblock which frame a
|
||||||
particular electric diagram.
|
particular electric diagram.
|
||||||
*/
|
*/
|
||||||
class BorderTitleBlock : public QObject
|
class BorderTitleBlock : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BorderTitleBlock(QObject * = nullptr);
|
BorderTitleBlock(QObject * = nullptr);
|
||||||
~BorderTitleBlock() override;
|
~BorderTitleBlock() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BorderTitleBlock(const BorderTitleBlock &);
|
BorderTitleBlock(const BorderTitleBlock &);
|
||||||
|
|
||||||
//METHODS
|
//METHODS
|
||||||
public:
|
public:
|
||||||
void draw(QPainter *painter);
|
void draw(QPainter *painter);
|
||||||
void drawDxf(QString &, int);
|
void drawDxf(QString &, int);
|
||||||
|
|
||||||
//METHODS TO GET DIMENSION
|
//METHODS TO GET DIMENSION
|
||||||
//COLUMNS
|
//COLUMNS
|
||||||
/// @return the number of columns
|
/// @return the number of columns
|
||||||
int columnsCount() const { return(columns_count_); }
|
int columnsCount() const { return(columns_count_); }
|
||||||
/// @return the columns width, in pixels
|
/// @return the columns width, in pixels
|
||||||
qreal columnsWidth() const { return(columns_width_); }
|
qreal columnsWidth() const { return(columns_width_); }
|
||||||
/// @return the total width of all columns, headers excluded
|
/// @return the total width of all columns, headers excluded
|
||||||
qreal columnsTotalWidth() const {
|
qreal columnsTotalWidth() const {
|
||||||
return(columns_count_ * columns_width_); }
|
return(columns_count_ * columns_width_); }
|
||||||
/// @return the column headers height, in pixels
|
/// @return the column headers height, in pixels
|
||||||
qreal columnsHeaderHeight() const {
|
qreal columnsHeaderHeight() const {
|
||||||
return(columns_header_height_); }
|
return(columns_header_height_); }
|
||||||
|
|
||||||
//ROWS
|
//ROWS
|
||||||
/// @return the number of rows
|
/// @return the number of rows
|
||||||
int rowsCount() const { return(rows_count_); }
|
int rowsCount() const { return(rows_count_); }
|
||||||
/// @return the rows height, in pixels
|
/// @return the rows height, in pixels
|
||||||
qreal rowsHeight() const { return(rows_height_); }
|
qreal rowsHeight() const { return(rows_height_); }
|
||||||
/// @return the total height of all rows, headers excluded
|
/// @return the total height of all rows, headers excluded
|
||||||
qreal rowsTotalHeight() const {
|
qreal rowsTotalHeight() const {
|
||||||
return(rows_count_ * rows_height_); }
|
return(rows_count_ * rows_height_); }
|
||||||
/// @return la rows header width, in pixels
|
/// @return la rows header width, in pixels
|
||||||
qreal rowsHeaderWidth() const { return(rows_header_width_); }
|
qreal rowsHeaderWidth() const { return(rows_header_width_); }
|
||||||
|
|
||||||
// border - title block = diagram
|
// border - title block = diagram
|
||||||
/**
|
/**
|
||||||
@brief diagramWidth
|
@brief diagramWidth
|
||||||
@return the diagram width,
|
@return the diagram width,
|
||||||
i.e. the width of the border without title block
|
i.e. the width of the border without title block
|
||||||
*/
|
*/
|
||||||
qreal diagramWidth() const
|
qreal diagramWidth() const
|
||||||
{
|
{
|
||||||
return(columnsTotalWidth() + rowsHeaderWidth()); }
|
return(columnsTotalWidth() + rowsHeaderWidth()); }
|
||||||
/**
|
/**
|
||||||
@brief diagramHeight
|
@brief diagramHeight
|
||||||
@return the diagram height,
|
@return the diagram height,
|
||||||
i.e. the height of the border without title block
|
i.e. the height of the border without title block
|
||||||
*/
|
*/
|
||||||
qreal diagramHeight() const
|
qreal diagramHeight() const
|
||||||
{
|
{
|
||||||
return(rowsTotalHeight() + columnsHeaderHeight()); }
|
return(rowsTotalHeight() + columnsHeaderHeight()); }
|
||||||
|
|
||||||
QRectF titleBlockRect () const;
|
QRectF titleBlockRect () const;
|
||||||
|
|
||||||
DiagramContext titleblockInformation() const;
|
DiagramContext titleblockInformation() const;
|
||||||
private:
|
private:
|
||||||
QRectF titleBlockRectForQPainter () const;
|
QRectF titleBlockRectForQPainter () const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QRectF borderAndTitleBlockRect () const;
|
QRectF borderAndTitleBlockRect () const;
|
||||||
QRectF columnsRect () const;
|
QRectF columnsRect () const;
|
||||||
QRectF rowsRect () const;
|
QRectF rowsRect () const;
|
||||||
QRectF outsideBorderRect() const;
|
QRectF outsideBorderRect() const;
|
||||||
QRectF insideBorderRect() const;
|
QRectF insideBorderRect() const;
|
||||||
|
|
||||||
// methods to get title block basic data
|
// methods to get title block basic data
|
||||||
/// @return the value of the title block "Author" field
|
/// @return the value of the title block "Author" field
|
||||||
QString author() const { return(btb_author_); }
|
QString author() const { return(btb_author_); }
|
||||||
/// @return the value of the title block "Date" field
|
/// @return the value of the title block "Date" field
|
||||||
QDate date() const { return(btb_date_); }
|
QDate date() const { return(btb_date_); }
|
||||||
/// @return the value of the title block "Title" field
|
/// @return the value of the title block "Title" field
|
||||||
QString title() const { return(btb_title_); }
|
QString title() const { return(btb_title_); }
|
||||||
/// @return the value of the title block "Folio" field
|
/// @return the value of the title block "Folio" field
|
||||||
QString folio() const { return(btb_folio_); }
|
QString folio() const { return(btb_folio_); }
|
||||||
/// @return the value of the title block "Folio" field as displayed
|
/// @return the value of the title block "Folio" field as displayed
|
||||||
QString finalfolio() const { return(btb_final_folio_); }
|
QString finalfolio() const { return(btb_final_folio_); }
|
||||||
/// @return the value of the title block "Plant" field
|
/// @return the value of the title block "Plant" field
|
||||||
QString plant() const { return(btb_plant_); }
|
QString plant() const { return(btb_plant_); }
|
||||||
/// @return the value of the title block "Locmach" field
|
/// @return the value of the title block "Locmach" field
|
||||||
QString locmach() const { return(btb_locmach_); }
|
QString locmach() const { return(btb_locmach_); }
|
||||||
/// @return the value of the revision index block "Folio" field
|
/// @return the value of the revision index block "Folio" field
|
||||||
QString indexrev() const { return(btb_indexrev_); }
|
QString indexrev() const { return(btb_indexrev_); }
|
||||||
/// @return the value of the title block "File" field
|
/// @return the value of the title block "File" field
|
||||||
QString fileName() const { return(btb_filename_); }
|
QString fileName() const { return(btb_filename_); }
|
||||||
/// @return the value of the title block Additional Fields
|
/// @return the value of the title block Additional Fields
|
||||||
QString version() const { return(btb_version_); }
|
QString version() const { return(btb_version_); }
|
||||||
/// @return the value of the title block Additional Fields
|
/// @return the value of the title block Additional Fields
|
||||||
DiagramContext additionalFields() const {
|
DiagramContext additionalFields() const {
|
||||||
return (additional_fields_); }
|
return (additional_fields_); }
|
||||||
/// @return the value of the title block
|
/// @return the value of the title block
|
||||||
QString autoPageNum() const { return(btb_auto_page_num_); }
|
QString autoPageNum() const { return(btb_auto_page_num_); }
|
||||||
/// @return the value of the total number of folios
|
/// @return the value of the total number of folios
|
||||||
int folioTotal() const { return(folio_total_);}
|
int folioTotal() const { return(folio_total_);}
|
||||||
|
|
||||||
// methods to get display options
|
// methods to get display options
|
||||||
/// @return true si le cartouche est affiche, false sinon
|
/// @return true si le cartouche est affiche, false sinon
|
||||||
bool titleBlockIsDisplayed() const {
|
bool titleBlockIsDisplayed() const {
|
||||||
return(display_titleblock_); }
|
return(display_titleblock_); }
|
||||||
/// @return true si les entetes des colonnes sont affiches,
|
/// @return true si les entetes des colonnes sont affiches,
|
||||||
/// false sinon
|
/// false sinon
|
||||||
bool columnsAreDisplayed() const { return(display_columns_); }
|
bool columnsAreDisplayed() const { return(display_columns_); }
|
||||||
/// @return true si les entetes des lignes sont affiches,
|
/// @return true si les entetes des lignes sont affiches,
|
||||||
/// false sinon
|
/// false sinon
|
||||||
bool rowsAreDisplayed() const { return(display_rows_); }
|
bool rowsAreDisplayed() const { return(display_rows_); }
|
||||||
/// @return true si la bordure est affichee, false sinon
|
/// @return true si la bordure est affichee, false sinon
|
||||||
bool borderIsDisplayed() const { return(display_border_); }
|
bool borderIsDisplayed() const { return(display_border_); }
|
||||||
|
|
||||||
// methods to set dimensions
|
// methods to set dimensions
|
||||||
void setColumnsCount(int);
|
void setColumnsCount(int);
|
||||||
void setRowsCount(int);
|
void setRowsCount(int);
|
||||||
void setColumnsWidth(const qreal &);
|
void setColumnsWidth(const qreal &);
|
||||||
void setRowsHeight(const qreal &);
|
void setRowsHeight(const qreal &);
|
||||||
void setColumnsHeaderHeight(const qreal &);
|
void setColumnsHeaderHeight(const qreal &);
|
||||||
void setRowsHeaderWidth(const qreal &);
|
void setRowsHeaderWidth(const qreal &);
|
||||||
void setDiagramHeight(const qreal &);
|
void setDiagramHeight(const qreal &);
|
||||||
|
|
||||||
DiagramPosition convertPosition(const QPointF &);
|
DiagramPosition convertPosition(const QPointF &);
|
||||||
|
|
||||||
// methods to set title block basic data
|
// methods to set title block basic data
|
||||||
void setAuthor(const QString &author);
|
void setAuthor(const QString &author);
|
||||||
void setDate(const QDate &date);
|
void setDate(const QDate &date);
|
||||||
void setTitle(const QString &title);
|
void setTitle(const QString &title);
|
||||||
void setFolio(const QString &folio);
|
void setFolio(const QString &folio);
|
||||||
void setFolioData(int, int, const QString& = nullptr,
|
void setFolioData(int, int, const QString& = nullptr,
|
||||||
const DiagramContext & = DiagramContext());
|
const DiagramContext & = DiagramContext());
|
||||||
void setPlant(const QString &plant);
|
void setPlant(const QString &plant);
|
||||||
void setLocMach(const QString &locmach);
|
void setLocMach(const QString &locmach);
|
||||||
void setIndicerev(const QString &indexrev);
|
void setIndicerev(const QString &indexrev);
|
||||||
void setFileName(const QString &filename);
|
void setFileName(const QString &filename);
|
||||||
void setVersion(const QString &version);
|
void setVersion(const QString &version);
|
||||||
void setAutoPageNum(const QString &auto_page_num);
|
void setAutoPageNum(const QString &auto_page_num);
|
||||||
void setPreviousFolioNum(const QString &previous);
|
void setPreviousFolioNum(const QString &previous);
|
||||||
void setNextFolioNum(const QString &next);
|
void setNextFolioNum(const QString &next);
|
||||||
|
|
||||||
void titleBlockToXml(QDomElement &doc);
|
void titleBlockToXml(QDomElement &doc);
|
||||||
void titleBlockFromXml(const QDomElement &);
|
void titleBlockFromXml(const QDomElement &);
|
||||||
void borderToXml(QDomElement &);
|
void borderToXml(QDomElement &);
|
||||||
void borderFromXml(const QDomElement &);
|
void borderFromXml(const QDomElement &);
|
||||||
|
|
||||||
TitleBlockProperties exportTitleBlock();
|
TitleBlockProperties exportTitleBlock();
|
||||||
void importTitleBlock(const TitleBlockProperties &);
|
void importTitleBlock(const TitleBlockProperties &);
|
||||||
BorderProperties exportBorder();
|
BorderProperties exportBorder();
|
||||||
void importBorder(const BorderProperties &);
|
void importBorder(const BorderProperties &);
|
||||||
|
|
||||||
const TitleBlockTemplate *titleBlockTemplate();
|
const TitleBlockTemplate *titleBlockTemplate();
|
||||||
void setTitleBlockTemplate(const TitleBlockTemplate *);
|
void setTitleBlockTemplate(const TitleBlockTemplate *);
|
||||||
QString titleBlockTemplateName() const;
|
QString titleBlockTemplateName() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void titleBlockTemplateChanged(const QString &);
|
void titleBlockTemplateChanged(const QString &);
|
||||||
void titleBlockTemplateRemoved(
|
void titleBlockTemplateRemoved(
|
||||||
const QString &,
|
const QString &,
|
||||||
const TitleBlockTemplate * = nullptr);
|
const TitleBlockTemplate * = nullptr);
|
||||||
|
|
||||||
// methods to set display options
|
// methods to set display options
|
||||||
void displayTitleBlock(bool);
|
void displayTitleBlock(bool);
|
||||||
void displayColumns(bool);
|
void displayColumns(bool);
|
||||||
void displayRows(bool);
|
void displayRows(bool);
|
||||||
void displayBorder(bool);
|
void displayBorder(bool);
|
||||||
void slot_setAutoPageNum (QString);
|
void slot_setAutoPageNum (QString);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateRectangles();
|
void updateRectangles();
|
||||||
void updateDiagramContextForTitleBlock(
|
void updateDiagramContextForTitleBlock(
|
||||||
const DiagramContext & = DiagramContext());
|
const DiagramContext & = DiagramContext());
|
||||||
QString incrementLetters(const QString &);
|
QString incrementLetters(const QString &);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
@brief borderChanged
|
@brief borderChanged
|
||||||
Signal emitted after the border has changed
|
Signal emitted after the border has changed
|
||||||
@param old_border Former border
|
@param old_border Former border
|
||||||
@param new_border New border
|
@param new_border New border
|
||||||
*/
|
*/
|
||||||
void borderChanged(QRectF old_border, QRectF new_border);
|
void borderChanged(QRectF old_border, QRectF new_border);
|
||||||
/**
|
/**
|
||||||
@brief displayChanged
|
@brief displayChanged
|
||||||
Signal emitted after display options have changed
|
Signal emitted after display options have changed
|
||||||
*/
|
*/
|
||||||
void displayChanged();
|
void displayChanged();
|
||||||
/**
|
/**
|
||||||
@brief diagramTitleChanged
|
@brief diagramTitleChanged
|
||||||
Signal emitted after the title has changed
|
Signal emitted after the title has changed
|
||||||
*/
|
*/
|
||||||
void diagramTitleChanged(const QString &);
|
void diagramTitleChanged(const QString &);
|
||||||
/**
|
/**
|
||||||
@brief titleBlockFolioChanged
|
@brief titleBlockFolioChanged
|
||||||
Signal emitted after Folio has changed
|
Signal emitted after Folio has changed
|
||||||
*/
|
*/
|
||||||
void titleBlockFolioChanged(const QString &);
|
void titleBlockFolioChanged(const QString &);
|
||||||
/**
|
/**
|
||||||
@brief needFolioData
|
@brief needFolioData
|
||||||
Signal emitted when the title block
|
Signal emitted when the title block
|
||||||
requires its data to be updated
|
requires its data to be updated
|
||||||
in order to generate the folio field.
|
in order to generate the folio field.
|
||||||
*/
|
*/
|
||||||
void needFolioData();
|
void needFolioData();
|
||||||
/**
|
/**
|
||||||
@brief needTitleBlockTemplate
|
@brief needTitleBlockTemplate
|
||||||
Signal emitted when this object needs to
|
Signal emitted when this object needs to
|
||||||
set a specific title block template.
|
set a specific title block template.
|
||||||
This object cannot handle the job
|
This object cannot handle the job
|
||||||
since it does not know of its parent project.
|
since it does not know of its parent project.
|
||||||
*/
|
*/
|
||||||
void needTitleBlockTemplate(const QString &);
|
void needTitleBlockTemplate(const QString &);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
// titleblock basic data
|
// titleblock basic data
|
||||||
QString btb_author_; ///< titleblock author
|
QString btb_author_; ///< titleblock author
|
||||||
QDate btb_date_; ///< titleblock date
|
QDate btb_date_; ///< titleblock date
|
||||||
QString btb_title_; ///< titleblock title
|
QString btb_title_; ///< titleblock title
|
||||||
QString btb_folio_; ///< titleblock folio
|
QString btb_folio_; ///< titleblock folio
|
||||||
QString btb_plant_; ///< titleblock plant
|
QString btb_plant_; ///< titleblock plant
|
||||||
QString btb_locmach_; ///< titleblock locmach
|
QString btb_locmach_; ///< titleblock locmach
|
||||||
QString btb_indexrev_; ///< titleblock index rev
|
QString btb_indexrev_; ///< titleblock index rev
|
||||||
QString btb_final_folio_; ///< titleblock final folio
|
QString btb_final_folio_; ///< titleblock final folio
|
||||||
QString btb_auto_page_num_; ///< titleblock auto page num
|
QString btb_auto_page_num_; ///< titleblock auto page num
|
||||||
int folio_index_; ///< titleblock index
|
int folio_index_; ///< titleblock index
|
||||||
int folio_total_; ///< titleblock total
|
int folio_total_; ///< titleblock total
|
||||||
QString btb_filename_; ///< titleblock filename
|
QString btb_filename_; ///< titleblock filename
|
||||||
QString btb_version_; ///< titleblock version
|
QString btb_version_; ///< titleblock version
|
||||||
/// titleblock additional fields
|
/// titleblock additional fields
|
||||||
DiagramContext additional_fields_;
|
DiagramContext additional_fields_;
|
||||||
Qt::Edge m_edge; ///< titleblock edge
|
Qt::Edge m_edge; ///< titleblock edge
|
||||||
QString m_next_folio_num; ///< titleblock next folio num
|
QString m_next_folio_num; ///< titleblock next folio num
|
||||||
QString m_previous_folio_num; ///< titleblock previous folio num
|
QString m_previous_folio_num; ///< titleblock previous folio num
|
||||||
|
|
||||||
// border dimensions (rows and columns)
|
// border dimensions (rows and columns)
|
||||||
// columns: number and dimensions
|
// columns: number and dimensions
|
||||||
int columns_count_; ///< columns count
|
int columns_count_; ///< columns count
|
||||||
qreal columns_width_; ///< columns width
|
qreal columns_width_; ///< columns width
|
||||||
qreal columns_header_height_; ///< columns header height
|
qreal columns_header_height_; ///< columns header height
|
||||||
|
|
||||||
// rows: number and dimensions
|
// rows: number and dimensions
|
||||||
int rows_count_; ///< rows count
|
int rows_count_; ///< rows count
|
||||||
qreal rows_height_; ///< rows height
|
qreal rows_height_; ///< rows height
|
||||||
qreal rows_header_width_; ///< rows header width
|
qreal rows_header_width_; ///< rows header width
|
||||||
|
|
||||||
// title block dimensions
|
// title block dimensions
|
||||||
qreal titleblock_height_;
|
qreal titleblock_height_;
|
||||||
|
|
||||||
// rectangles used for drawing operations
|
// rectangles used for drawing operations
|
||||||
QRectF diagram_rect_;
|
QRectF diagram_rect_;
|
||||||
|
|
||||||
// display options
|
// display options
|
||||||
bool display_titleblock_;
|
bool display_titleblock_;
|
||||||
bool display_columns_;
|
bool display_columns_;
|
||||||
bool display_rows_;
|
bool display_rows_;
|
||||||
bool display_border_;
|
bool display_border_;
|
||||||
TitleBlockTemplateRenderer *m_titleblock_template_renderer;
|
TitleBlockTemplateRenderer *m_titleblock_template_renderer;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef CONDUCTOR_PROPERTIES_H
|
#ifndef CONDUCTOR_PROPERTIES_H
|
||||||
#define CONDUCTOR_PROPERTIES_H
|
#define CONDUCTOR_PROPERTIES_H
|
||||||
@@ -27,119 +27,119 @@
|
|||||||
class QPainter;
|
class QPainter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The SingleLineProperties class
|
@brief The SingleLineProperties class
|
||||||
This class represents the properties of a singleline conductor.
|
This class represents the properties of a singleline conductor.
|
||||||
*/
|
*/
|
||||||
class SingleLineProperties: public PropertiesInterface {
|
class SingleLineProperties: public PropertiesInterface {
|
||||||
public:
|
public:
|
||||||
SingleLineProperties();
|
SingleLineProperties();
|
||||||
virtual ~SingleLineProperties();
|
virtual ~SingleLineProperties();
|
||||||
|
|
||||||
void setPhasesCount(int);
|
void setPhasesCount(int);
|
||||||
unsigned short int phasesCount();
|
unsigned short int phasesCount();
|
||||||
bool isPen() const;
|
bool isPen() const;
|
||||||
void draw(QPainter *, QET::ConductorSegmentType, const QRectF &);
|
void draw(QPainter *, QET::ConductorSegmentType, const QRectF &);
|
||||||
QDomElement toXml(QDomDocument& doc) const override;
|
QDomElement toXml(QDomDocument& doc) const override;
|
||||||
bool fromXml(const QDomElement &) override;
|
bool fromXml(const QDomElement &) override;
|
||||||
static bool valideXml(QDomElement& element);
|
static bool valideXml(QDomElement& element);
|
||||||
void toSettings(QSettings &, const QString & = QString()) const;
|
void toSettings(QSettings &, const QString & = QString()) const;
|
||||||
void fromSettings(QSettings &, const QString & = QString());
|
void fromSettings(QSettings &, const QString & = QString());
|
||||||
|
|
||||||
/// Whether the singleline conductor should display the ground symbol
|
/// Whether the singleline conductor should display the ground symbol
|
||||||
bool hasGround{true};
|
bool hasGround{true};
|
||||||
/// Whether the singleline conductor should display the neutral symbol
|
/// Whether the singleline conductor should display the neutral symbol
|
||||||
bool hasNeutral{true};
|
bool hasNeutral{true};
|
||||||
/// Protective Earth Neutral: visually merge neutral and ground
|
/// Protective Earth Neutral: visually merge neutral and ground
|
||||||
bool is_pen{false};
|
bool is_pen{false};
|
||||||
|
|
||||||
int operator==(const SingleLineProperties &) const;
|
int operator==(const SingleLineProperties &) const;
|
||||||
int operator!=(const SingleLineProperties &) const;
|
int operator!=(const SingleLineProperties &) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned short int phases{1};
|
unsigned short int phases{1};
|
||||||
void drawGround (QPainter *, QET::ConductorSegmentType, QPointF, qreal);
|
void drawGround (QPainter *, QET::ConductorSegmentType, QPointF, qreal);
|
||||||
void drawNeutral(QPainter *, QPointF, qreal);
|
void drawNeutral(QPainter *, QPointF, qreal);
|
||||||
void drawPen(QPainter *, QET::ConductorSegmentType, QPointF, qreal);
|
void drawPen(QPainter *, QET::ConductorSegmentType, QPointF, qreal);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The ConductorProperties class
|
@brief The ConductorProperties class
|
||||||
This class represents the functional properties of a particular conductor,
|
This class represents the functional properties of a particular conductor,
|
||||||
i.e. properties other than path and terminals.
|
i.e. properties other than path and terminals.
|
||||||
*/
|
*/
|
||||||
class ConductorProperties: public PropertiesInterface
|
class ConductorProperties: public PropertiesInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConductorProperties();
|
ConductorProperties();
|
||||||
virtual ~ConductorProperties();
|
virtual ~ConductorProperties();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The ConductorType enum Represents
|
@brief The ConductorType enum Represents
|
||||||
the kind of a particular conductor:
|
the kind of a particular conductor:
|
||||||
Single: singleline symbols, no text input
|
Single: singleline symbols, no text input
|
||||||
Multi: text input, no symbol
|
Multi: text input, no symbol
|
||||||
*/
|
*/
|
||||||
enum ConductorType { Single, Multi };
|
enum ConductorType { Single, Multi };
|
||||||
|
|
||||||
|
|
||||||
//Attributes
|
//Attributes
|
||||||
ConductorType type{ConductorType::Single};
|
ConductorType type{ConductorType::Single};
|
||||||
|
|
||||||
// TODO: set default values!
|
// TODO: set default values!
|
||||||
QColor color{QColor(Qt::black)},
|
QColor color{QColor(Qt::black)},
|
||||||
m_color_2{QColor(Qt::black)},
|
m_color_2{QColor(Qt::black)},
|
||||||
text_color{QColor(Qt::black)};
|
text_color{QColor(Qt::black)};
|
||||||
|
|
||||||
QString
|
QString
|
||||||
text,
|
text,
|
||||||
m_function,
|
m_function,
|
||||||
m_tension_protocol,
|
m_tension_protocol,
|
||||||
m_wire_color,
|
m_wire_color,
|
||||||
m_wire_section,
|
m_wire_section,
|
||||||
m_formula,
|
m_formula,
|
||||||
m_bus,
|
m_bus,
|
||||||
m_cable;
|
m_cable;
|
||||||
|
|
||||||
int text_size{9},
|
int text_size{9},
|
||||||
text_size,
|
text_size,
|
||||||
m_dash_size = 1;
|
m_dash_size = 1;
|
||||||
|
|
||||||
double cond_size{1},
|
double cond_size{1},
|
||||||
cond_size,
|
cond_size,
|
||||||
verti_rotate_text,
|
verti_rotate_text,
|
||||||
horiz_rotate_text;
|
horiz_rotate_text;
|
||||||
|
|
||||||
bool m_show_text{true},
|
bool m_show_text{true},
|
||||||
m_one_text_per_folio{true},
|
m_one_text_per_folio{true},
|
||||||
m_bicolor = false;
|
m_bicolor = false;
|
||||||
|
|
||||||
Qt::Alignment
|
Qt::Alignment
|
||||||
m_horizontal_alignment = Qt::AlignBottom,
|
m_horizontal_alignment = Qt::AlignBottom,
|
||||||
m_horizontal_alignment = Qt::AlignBottom,
|
m_horizontal_alignment = Qt::AlignBottom,
|
||||||
m_vertical_alignment = Qt::AlignRight;
|
m_vertical_alignment = Qt::AlignRight;
|
||||||
|
|
||||||
Qt::PenStyle style{Qt::PenStyle::SolidLine};
|
Qt::PenStyle style{Qt::PenStyle::SolidLine};
|
||||||
|
|
||||||
SingleLineProperties singleLineProperties;
|
SingleLineProperties singleLineProperties;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
QDomElement toXml(QDomDocument &doc) const override;
|
QDomElement toXml(QDomDocument &doc) const override;
|
||||||
bool fromXml(const QDomElement &) override;
|
bool fromXml(const QDomElement &) override;
|
||||||
static bool valideXml(QDomElement& element);
|
static bool valideXml(QDomElement& element);
|
||||||
void toSettings(QSettings &, const QString & = QString()) const;
|
void toSettings(QSettings &, const QString & = QString()) const;
|
||||||
void fromSettings(QSettings &, const QString & = QString());
|
void fromSettings(QSettings &, const QString & = QString());
|
||||||
static QString typeToString(ConductorType);
|
static QString typeToString(ConductorType);
|
||||||
void applyForEqualAttributes(QList<ConductorProperties> list);
|
void applyForEqualAttributes(QList<ConductorProperties> list);
|
||||||
|
|
||||||
static ConductorProperties defaultProperties();
|
static ConductorProperties defaultProperties();
|
||||||
|
|
||||||
// operators
|
// operators
|
||||||
bool operator==(const ConductorProperties &) const;
|
bool operator==(const ConductorProperties &) const;
|
||||||
bool operator!=(const ConductorProperties &) const;
|
bool operator!=(const ConductorProperties &) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void readStyle(const QString &);
|
void readStyle(const QString &);
|
||||||
QString writeStyle() const;
|
QString writeStyle() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(ConductorProperties)
|
Q_DECLARE_METATYPE(ConductorProperties)
|
||||||
|
|||||||
3662
sources/diagram.cpp
3662
sources/diagram.cpp
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef DIAGRAM_H
|
#ifndef DIAGRAM_H
|
||||||
#define DIAGRAM_H
|
#define DIAGRAM_H
|
||||||
@@ -47,379 +47,379 @@ class DiagramFolioList;
|
|||||||
class QETProject;
|
class QETProject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The Diagram class
|
@brief The Diagram class
|
||||||
This class represents an electric diagram.
|
This class represents an electric diagram.
|
||||||
It manages its various child elements,
|
It manages its various child elements,
|
||||||
conductors and texts and handles their graphic rendering.
|
conductors and texts and handles their graphic rendering.
|
||||||
*/
|
*/
|
||||||
class Diagram : public QGraphicsScene
|
class Diagram : public QGraphicsScene
|
||||||
{
|
{
|
||||||
friend DiagramFolioList;
|
friend DiagramFolioList;
|
||||||
friend QETProject;
|
friend QETProject;
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
private:
|
private:
|
||||||
Diagram(QETProject *project);
|
Diagram(QETProject *project);
|
||||||
~Diagram() override;
|
~Diagram() override;
|
||||||
Diagram(const Diagram &diagram);
|
Diagram(const Diagram &diagram);
|
||||||
|
|
||||||
// ATTRIBUTES
|
// ATTRIBUTES
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@brief The BorderOptions enum
|
@brief The BorderOptions enum
|
||||||
Represents available options when rendering a particular diagram:
|
Represents available options when rendering a particular diagram:
|
||||||
EmptyBorder: display border only
|
EmptyBorder: display border only
|
||||||
TitleBlock: display title block
|
TitleBlock: display title block
|
||||||
Columns: display columns
|
Columns: display columns
|
||||||
*/
|
*/
|
||||||
enum BorderOptions { EmptyBorder, TitleBlock, Columns };
|
enum BorderOptions { EmptyBorder, TitleBlock, Columns };
|
||||||
/// Represents available option of Numerotation type.
|
/// Represents available option of Numerotation type.
|
||||||
enum NumerotationType { Conductors };
|
enum NumerotationType { Conductors };
|
||||||
/// Default properties for new conductors
|
/// Default properties for new conductors
|
||||||
ConductorProperties defaultConductorProperties;
|
ConductorProperties defaultConductorProperties;
|
||||||
/// Diagram dimensions and title block
|
/// Diagram dimensions and title block
|
||||||
BorderTitleBlock border_and_titleblock;
|
BorderTitleBlock border_and_titleblock;
|
||||||
/// abscissa grid step size
|
/// abscissa grid step size
|
||||||
static int xGrid;
|
static int xGrid;
|
||||||
/// ordinate grid step size
|
/// ordinate grid step size
|
||||||
static int yGrid;
|
static int yGrid;
|
||||||
/// Key grid x step size
|
/// Key grid x step size
|
||||||
static int xKeyGrid;
|
static int xKeyGrid;
|
||||||
/// Key grid y step size
|
/// Key grid y step size
|
||||||
static int yKeyGrid;
|
static int yKeyGrid;
|
||||||
/// Key grid fine x step size
|
/// Key grid fine x step size
|
||||||
static int xKeyGridFine;
|
static int xKeyGridFine;
|
||||||
/// Key grid fine y step size
|
/// Key grid fine y step size
|
||||||
static int yKeyGridFine;
|
static int yKeyGridFine;
|
||||||
/// margin around the diagram
|
/// margin around the diagram
|
||||||
static const qreal margin;
|
static const qreal margin;
|
||||||
/// background color of diagram
|
/// background color of diagram
|
||||||
static QColor background_color; // default value set in cpp file
|
static QColor background_color; // default value set in cpp file
|
||||||
/// Hash containing max values for folio sequential autonums in this diagram
|
/// Hash containing max values for folio sequential autonums in this diagram
|
||||||
QHash <QString, QStringList> m_elmt_unitfolio_max;
|
QHash <QString, QStringList> m_elmt_unitfolio_max;
|
||||||
QHash <QString, QStringList> m_elmt_tenfolio_max;
|
QHash <QString, QStringList> m_elmt_tenfolio_max;
|
||||||
QHash <QString, QStringList> m_elmt_hundredfolio_max;
|
QHash <QString, QStringList> m_elmt_hundredfolio_max;
|
||||||
/// Hash containing max values for folio sequential autonums in this diagram
|
/// Hash containing max values for folio sequential autonums in this diagram
|
||||||
QHash <QString, QStringList> m_cnd_unitfolio_max;
|
QHash <QString, QStringList> m_cnd_unitfolio_max;
|
||||||
QHash <QString, QStringList> m_cnd_tenfolio_max;
|
QHash <QString, QStringList> m_cnd_tenfolio_max;
|
||||||
QHash <QString, QStringList> m_cnd_hundredfolio_max;
|
QHash <QString, QStringList> m_cnd_hundredfolio_max;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGraphicsLineItem *conductor_setter_;
|
QGraphicsLineItem *conductor_setter_;
|
||||||
ElementsMover m_elements_mover;
|
ElementsMover m_elements_mover;
|
||||||
ElementTextsMover m_element_texts_mover;
|
ElementTextsMover m_element_texts_mover;
|
||||||
QGIManager *qgi_manager_;
|
QGIManager *qgi_manager_;
|
||||||
QETProject *m_project;
|
QETProject *m_project;
|
||||||
|
|
||||||
QDomDocument xml_document_;
|
QDomDocument xml_document_;
|
||||||
|
|
||||||
qreal diagram_qet_version_;
|
qreal diagram_qet_version_;
|
||||||
|
|
||||||
bool draw_grid_;
|
bool draw_grid_;
|
||||||
bool use_border_;
|
bool use_border_;
|
||||||
bool draw_terminals_;
|
bool draw_terminals_;
|
||||||
bool draw_colored_conductors_;
|
bool draw_colored_conductors_;
|
||||||
|
|
||||||
QString m_conductors_autonum_name;
|
QString m_conductors_autonum_name;
|
||||||
DiagramEventInterface *m_event_interface;
|
DiagramEventInterface *m_event_interface;
|
||||||
|
|
||||||
bool m_freeze_new_elements;
|
bool m_freeze_new_elements;
|
||||||
bool m_freeze_new_conductors_;
|
bool m_freeze_new_conductors_;
|
||||||
QUuid m_uuid = QUuid::createUuid();
|
QUuid m_uuid = QUuid::createUuid();
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
protected:
|
protected:
|
||||||
void drawBackground(QPainter *, const QRectF &) override;
|
void drawBackground(QPainter *, const QRectF &) override;
|
||||||
|
|
||||||
void mouseDoubleClickEvent (
|
void mouseDoubleClickEvent (
|
||||||
QGraphicsSceneMouseEvent *event) override;
|
QGraphicsSceneMouseEvent *event) override;
|
||||||
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
|
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseReleaseEvent (
|
void mouseReleaseEvent (
|
||||||
QGraphicsSceneMouseEvent *event) override;
|
QGraphicsSceneMouseEvent *event) override;
|
||||||
void wheelEvent (QGraphicsSceneWheelEvent *event) override;
|
void wheelEvent (QGraphicsSceneWheelEvent *event) override;
|
||||||
void keyPressEvent (QKeyEvent *event) override;
|
void keyPressEvent (QKeyEvent *event) override;
|
||||||
void keyReleaseEvent (QKeyEvent *) override;
|
void keyReleaseEvent (QKeyEvent *) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QUuid uuid();
|
QUuid uuid();
|
||||||
void setEventInterface (DiagramEventInterface *event_interface);
|
void setEventInterface (DiagramEventInterface *event_interface);
|
||||||
void clearEventInterface();
|
void clearEventInterface();
|
||||||
|
|
||||||
//methods related to autonum
|
//methods related to autonum
|
||||||
QString conductorsAutonumName() const;
|
QString conductorsAutonumName() const;
|
||||||
void setConductorsAutonumName(const QString &name);
|
void setConductorsAutonumName(const QString &name);
|
||||||
|
|
||||||
static bool clipboardMayContainDiagram();
|
static bool clipboardMayContainDiagram();
|
||||||
|
|
||||||
// methods related to parent project
|
// methods related to parent project
|
||||||
QETProject *project() const;
|
QETProject *project() const;
|
||||||
int folioIndex() const;
|
int folioIndex() const;
|
||||||
void showMe() {emit showDiagram(this);}
|
void showMe() {emit showDiagram(this);}
|
||||||
bool isReadOnly() const;
|
bool isReadOnly() const;
|
||||||
|
|
||||||
// methods related to conductor creation
|
// methods related to conductor creation
|
||||||
void setConductor(bool);
|
void setConductor(bool);
|
||||||
void setConductorStart (QPointF);
|
void setConductorStart (QPointF);
|
||||||
void setConductorStop(QPointF);
|
void setConductorStop(QPointF);
|
||||||
QList < QSet <Conductor *> > potentials();
|
QList < QSet <Conductor *> > potentials();
|
||||||
|
|
||||||
// methods related to XML import/export
|
// methods related to XML import/export
|
||||||
QDomDocument toXml(bool = true);
|
QDomDocument toXml(bool = true);
|
||||||
bool initFromXml(QDomElement &,
|
bool initFromXml(QDomElement &,
|
||||||
QPointF = QPointF(),
|
QPointF = QPointF(),
|
||||||
bool = true,
|
bool = true,
|
||||||
DiagramContent * = nullptr);
|
DiagramContent * = nullptr);
|
||||||
bool fromXml(QDomDocument &,
|
bool fromXml(QDomDocument &,
|
||||||
QPointF = QPointF(),
|
QPointF = QPointF(),
|
||||||
bool = true,
|
bool = true,
|
||||||
DiagramContent * = nullptr);
|
DiagramContent * = nullptr);
|
||||||
bool fromXml(QDomElement &,
|
bool fromXml(QDomElement &,
|
||||||
QPointF = QPointF(),
|
QPointF = QPointF(),
|
||||||
bool = true,
|
bool = true,
|
||||||
DiagramContent * = nullptr);
|
DiagramContent * = nullptr);
|
||||||
void folioSequentialsToXml(QHash<QString,
|
void folioSequentialsToXml(QHash<QString,
|
||||||
QStringList>*,
|
QStringList>*,
|
||||||
QDomElement *,
|
QDomElement *,
|
||||||
const QString&,
|
const QString&,
|
||||||
const QString&,
|
const QString&,
|
||||||
QDomDocument *);
|
QDomDocument *);
|
||||||
void folioSequentialsFromXml(const QDomElement&,
|
void folioSequentialsFromXml(const QDomElement&,
|
||||||
QHash<QString,
|
QHash<QString,
|
||||||
QStringList>*,
|
QStringList>*,
|
||||||
const QString&,
|
const QString&,
|
||||||
const QString&,
|
const QString&,
|
||||||
const QString&,
|
const QString&,
|
||||||
const QString&);
|
const QString&);
|
||||||
|
|
||||||
void refreshContents();
|
void refreshContents();
|
||||||
|
|
||||||
// methods related to graphics items addition/removal on the diagram
|
// methods related to graphics items addition/removal on the diagram
|
||||||
virtual void addItem (QGraphicsItem *item);
|
virtual void addItem (QGraphicsItem *item);
|
||||||
virtual void removeItem (QGraphicsItem *item);
|
virtual void removeItem (QGraphicsItem *item);
|
||||||
|
|
||||||
// methods related to graphics options
|
// methods related to graphics options
|
||||||
ExportProperties applyProperties(const ExportProperties &);
|
ExportProperties applyProperties(const ExportProperties &);
|
||||||
void setDisplayGrid(bool);
|
void setDisplayGrid(bool);
|
||||||
bool displayGrid();
|
bool displayGrid();
|
||||||
void setUseBorder(bool);
|
void setUseBorder(bool);
|
||||||
bool useBorder();
|
bool useBorder();
|
||||||
void setBorderOptions(BorderOptions);
|
void setBorderOptions(BorderOptions);
|
||||||
BorderOptions borderOptions();
|
BorderOptions borderOptions();
|
||||||
DiagramPosition convertPosition(const QPointF &);
|
DiagramPosition convertPosition(const QPointF &);
|
||||||
static QPointF snapToGrid(const QPointF &p);
|
static QPointF snapToGrid(const QPointF &p);
|
||||||
|
|
||||||
bool drawTerminals() const;
|
bool drawTerminals() const;
|
||||||
void setDrawTerminals(bool);
|
void setDrawTerminals(bool);
|
||||||
bool drawColoredConductors() const;
|
bool drawColoredConductors() const;
|
||||||
void setDrawColoredConductors(bool);
|
void setDrawColoredConductors(bool);
|
||||||
|
|
||||||
QString title() const;
|
QString title() const;
|
||||||
bool toPaintDevice(QPaintDevice &, int = -1, int = -1,
|
bool toPaintDevice(QPaintDevice &, int = -1, int = -1,
|
||||||
Qt::AspectRatioMode = Qt::KeepAspectRatio);
|
Qt::AspectRatioMode = Qt::KeepAspectRatio);
|
||||||
QSize imageSize() const;
|
QSize imageSize() const;
|
||||||
|
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
||||||
QList<Element *> elements() const;
|
QList<Element *> elements() const;
|
||||||
QList<Conductor *> conductors() const;
|
QList<Conductor *> conductors() const;
|
||||||
QSet<Conductor *> selectedConductors() const;
|
QSet<Conductor *> selectedConductors() const;
|
||||||
DiagramContent content() const;
|
DiagramContent content() const;
|
||||||
bool canRotateSelection() const;
|
bool canRotateSelection() const;
|
||||||
ElementsMover &elementsMover();
|
ElementsMover &elementsMover();
|
||||||
ElementTextsMover &elementTextsMover();
|
ElementTextsMover &elementTextsMover();
|
||||||
bool usesElement(const ElementsLocation &);
|
bool usesElement(const ElementsLocation &);
|
||||||
bool usesTitleBlockTemplate(const QString &);
|
bool usesTitleBlockTemplate(const QString &);
|
||||||
|
|
||||||
QUndoStack &undoStack();
|
QUndoStack &undoStack();
|
||||||
QGIManager &qgiManager();
|
QGIManager &qgiManager();
|
||||||
|
|
||||||
//methods related to element label Update Policy
|
//methods related to element label Update Policy
|
||||||
void freezeElements(bool freeze);
|
void freezeElements(bool freeze);
|
||||||
void unfreezeElements();
|
void unfreezeElements();
|
||||||
void setFreezeNewElements(bool);
|
void setFreezeNewElements(bool);
|
||||||
bool freezeNewElements();
|
bool freezeNewElements();
|
||||||
|
|
||||||
//methods related to conductor label Update Policy
|
//methods related to conductor label Update Policy
|
||||||
void freezeConductors(bool freeze);
|
void freezeConductors(bool freeze);
|
||||||
void setFreezeNewConductors(bool);
|
void setFreezeNewConductors(bool);
|
||||||
bool freezeNewConductors();
|
bool freezeNewConductors();
|
||||||
|
|
||||||
//methods related to insertion and loading of folio sequential
|
//methods related to insertion and loading of folio sequential
|
||||||
void insertFolioSeqHash (QHash<QString, QStringList> *hash,
|
void insertFolioSeqHash (QHash<QString, QStringList> *hash,
|
||||||
const QString& title,
|
const QString& title,
|
||||||
const QString& seq,
|
const QString& seq,
|
||||||
NumerotationContext *nc);
|
NumerotationContext *nc);
|
||||||
void loadFolioSeqHash (QHash<QString, QStringList> *hash,
|
void loadFolioSeqHash (QHash<QString, QStringList> *hash,
|
||||||
const QString& title, const QString& seq,
|
const QString& title, const QString& seq,
|
||||||
NumerotationContext *nc);
|
NumerotationContext *nc);
|
||||||
void changeZValue(QET::DepthOption option);
|
void changeZValue(QET::DepthOption option);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void adjustSceneRect ();
|
void adjustSceneRect ();
|
||||||
void titleChanged(const QString &);
|
void titleChanged(const QString &);
|
||||||
void titleBlockTemplateChanged(const QString &);
|
void titleBlockTemplateChanged(const QString &);
|
||||||
void titleBlockTemplateRemoved(const QString &,
|
void titleBlockTemplateRemoved(const QString &,
|
||||||
const QString & = QString());
|
const QString & = QString());
|
||||||
void setTitleBlockTemplate(const QString &);
|
void setTitleBlockTemplate(const QString &);
|
||||||
void updateLabels();
|
void updateLabels();
|
||||||
void loadElmtFolioSeq();
|
void loadElmtFolioSeq();
|
||||||
void loadCndFolioSeq();
|
void loadCndFolioSeq();
|
||||||
|
|
||||||
// methods related to graphics items selection
|
// methods related to graphics items selection
|
||||||
void selectAll();
|
void selectAll();
|
||||||
void deselectAll();
|
void deselectAll();
|
||||||
void invertSelection();
|
void invertSelection();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void showDiagram (Diagram *);
|
void showDiagram (Diagram *);
|
||||||
void usedTitleBlockTemplateChanged(const QString &);
|
void usedTitleBlockTemplateChanged(const QString &);
|
||||||
void diagramTitleChanged(Diagram *, const QString &);
|
void diagramTitleChanged(Diagram *, const QString &);
|
||||||
|
|
||||||
/// Signal emitted when users wish to locate an element
|
/// Signal emitted when users wish to locate an element
|
||||||
/// from the diagram within elements collection
|
/// from the diagram within elements collection
|
||||||
void findElementRequired(const ElementsLocation &);
|
void findElementRequired(const ElementsLocation &);
|
||||||
|
|
||||||
/// Signal emitted when users wish to edit an element from the diagram
|
/// Signal emitted when users wish to edit an element from the diagram
|
||||||
void editElementRequired(const ElementsLocation &);
|
void editElementRequired(const ElementsLocation &);
|
||||||
void diagramActivated();
|
void diagramActivated();
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(Diagram *)
|
Q_DECLARE_METATYPE(Diagram *)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Diagram::setConductor
|
@brief Diagram::setConductor
|
||||||
Display or hide the conductor setter,
|
Display or hide the conductor setter,
|
||||||
i.e. a dashed conductor stub which appears
|
i.e. a dashed conductor stub which appears
|
||||||
when creating a conductor between two terminals.
|
when creating a conductor between two terminals.
|
||||||
@param adding true add conductor ,false remove conductor
|
@param adding true add conductor ,false remove conductor
|
||||||
*/
|
*/
|
||||||
inline void Diagram::setConductor(bool adding) {
|
inline void Diagram::setConductor(bool adding) {
|
||||||
if (adding) {
|
if (adding) {
|
||||||
if (!conductor_setter_ -> scene()) addItem(conductor_setter_);
|
if (!conductor_setter_ -> scene()) addItem(conductor_setter_);
|
||||||
} else {
|
} else {
|
||||||
if (conductor_setter_ -> scene()) removeItem(conductor_setter_);
|
if (conductor_setter_ -> scene()) removeItem(conductor_setter_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Diagram::setConductorStart
|
@brief Diagram::setConductorStart
|
||||||
Set the start point of the conductor setter.
|
Set the start point of the conductor setter.
|
||||||
@param start the point (in scene coordinates) which the newly created
|
@param start the point (in scene coordinates) which the newly created
|
||||||
conductor should start from.
|
conductor should start from.
|
||||||
*/
|
*/
|
||||||
inline void Diagram::setConductorStart(QPointF start) {
|
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
|
@brief Diagram::setConductorStop
|
||||||
Set the end point of the conductor setter.
|
Set the end point of the conductor setter.
|
||||||
@param end the point (in scene coordinates) upon to which the newly created
|
@param end the point (in scene coordinates) upon to which the newly created
|
||||||
conductor should be drawn.
|
conductor should be drawn.
|
||||||
*/
|
*/
|
||||||
inline void Diagram::setConductorStop(QPointF end) {
|
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
|
@brief Diagram::setDisplayGrid
|
||||||
Set whether the diagram grid should be drawn.
|
Set whether the diagram grid should be drawn.
|
||||||
@param dg true to render the grid, false otherwise.
|
@param dg true to render the grid, false otherwise.
|
||||||
*/
|
*/
|
||||||
inline void Diagram::setDisplayGrid(bool dg) {
|
inline void Diagram::setDisplayGrid(bool dg) {
|
||||||
draw_grid_ = dg;
|
draw_grid_ = dg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Diagram::displayGrid
|
@brief Diagram::displayGrid
|
||||||
@return draw_grid_ true if the grid is drawn, false otherwise.
|
@return draw_grid_ true if the grid is drawn, false otherwise.
|
||||||
*/
|
*/
|
||||||
inline bool Diagram::displayGrid() {
|
inline bool Diagram::displayGrid() {
|
||||||
return(draw_grid_);
|
return(draw_grid_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Diagram::setUseBorder
|
@brief Diagram::setUseBorder
|
||||||
Set whether the diagram border (including rows/colums headers and the title
|
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
|
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
|
of the smallest rectangle containing all items is considered as the diagram
|
||||||
size.
|
size.
|
||||||
@param ub true to take the border into account, false otherwise
|
@param ub true to take the border into account, false otherwise
|
||||||
*/
|
*/
|
||||||
inline void Diagram::setUseBorder(bool ub) {
|
inline void Diagram::setUseBorder(bool ub) {
|
||||||
use_border_ = ub;
|
use_border_ = ub;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Diagram::useBorder
|
@brief Diagram::useBorder
|
||||||
@return use_border_ true if the border is rendered and take into account,
|
@return use_border_ true if the border is rendered and take into account,
|
||||||
false otherwise.
|
false otherwise.
|
||||||
*/
|
*/
|
||||||
inline bool Diagram::useBorder() {
|
inline bool Diagram::useBorder() {
|
||||||
return(use_border_);
|
return(use_border_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Diagram::setBorderOptions
|
@brief Diagram::setBorderOptions
|
||||||
Set the rendering options for the diagram border (including rows/colums
|
Set the rendering options for the diagram border (including rows/colums
|
||||||
headers and the title block)
|
headers and the title block)
|
||||||
@param bo Enabled options ORed together
|
@param bo Enabled options ORed together
|
||||||
@see BorderOptions
|
@see BorderOptions
|
||||||
*/
|
*/
|
||||||
inline void Diagram::setBorderOptions(Diagram::BorderOptions bo) {
|
inline void Diagram::setBorderOptions(Diagram::BorderOptions bo) {
|
||||||
border_and_titleblock.displayBorder(!(bo & EmptyBorder));
|
border_and_titleblock.displayBorder(!(bo & EmptyBorder));
|
||||||
border_and_titleblock.displayColumns(bo & Columns);
|
border_and_titleblock.displayColumns(bo & Columns);
|
||||||
border_and_titleblock.displayTitleBlock(bo & TitleBlock);
|
border_and_titleblock.displayTitleBlock(bo & TitleBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Diagram::borderOptions
|
@brief Diagram::borderOptions
|
||||||
@return The rendering optios for the diagram border
|
@return The rendering optios for the diagram border
|
||||||
@see setBorderOptions
|
@see setBorderOptions
|
||||||
*/
|
*/
|
||||||
inline Diagram::BorderOptions Diagram::borderOptions() {
|
inline Diagram::BorderOptions Diagram::borderOptions() {
|
||||||
BorderOptions options = EmptyBorder;
|
BorderOptions options = EmptyBorder;
|
||||||
if (border_and_titleblock.titleBlockIsDisplayed())
|
if (border_and_titleblock.titleBlockIsDisplayed())
|
||||||
options = (BorderOptions)(options|TitleBlock);
|
options = (BorderOptions)(options|TitleBlock);
|
||||||
if (border_and_titleblock.columnsAreDisplayed())
|
if (border_and_titleblock.columnsAreDisplayed())
|
||||||
options = (BorderOptions)(options|Columns);
|
options = (BorderOptions)(options|Columns);
|
||||||
return(options);
|
return(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Diagram::undoStack
|
@brief Diagram::undoStack
|
||||||
@return the diagram undo stack
|
@return the diagram undo stack
|
||||||
*/
|
*/
|
||||||
inline QUndoStack &Diagram::undoStack() {
|
inline QUndoStack &Diagram::undoStack() {
|
||||||
return *(project()->undoStack());
|
return *(project()->undoStack());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Diagram::qgiManager
|
@brief Diagram::qgiManager
|
||||||
@return the diagram graphics item manager
|
@return the diagram graphics item manager
|
||||||
*/
|
*/
|
||||||
inline QGIManager &Diagram::qgiManager() {
|
inline QGIManager &Diagram::qgiManager() {
|
||||||
return(*qgi_manager_);
|
return(*qgi_manager_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Diagram::drawTerminals
|
@brief Diagram::drawTerminals
|
||||||
@return true if terminals are rendered, false otherwise
|
@return true if terminals are rendered, false otherwise
|
||||||
*/
|
*/
|
||||||
inline bool Diagram::drawTerminals() const
|
inline bool Diagram::drawTerminals() const
|
||||||
{
|
{
|
||||||
return(draw_terminals_);
|
return(draw_terminals_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Diagram::drawColoredConductors
|
@brief Diagram::drawColoredConductors
|
||||||
@return true if conductors colors are rendered, false otherwise.
|
@return true if conductors colors are rendered, false otherwise.
|
||||||
*/
|
*/
|
||||||
inline bool Diagram::drawColoredConductors() const
|
inline bool Diagram::drawColoredConductors() const
|
||||||
{
|
{
|
||||||
return(draw_colored_conductors_);
|
return(draw_colored_conductors_);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "diagramcontext.h"
|
#include "diagramcontext.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
@@ -22,240 +22,240 @@
|
|||||||
#include <QRegularExpressionMatch>
|
#include <QRegularExpressionMatch>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief DiagramContext::add
|
@brief DiagramContext::add
|
||||||
Add all value of other to this.
|
Add all value of other to this.
|
||||||
If a key already exist, the value is replaced.
|
If a key already exist, the value is replaced.
|
||||||
If a key doesn't exist, she will be added.
|
If a key doesn't exist, she will be added.
|
||||||
All other keys of this context, which are not present in other, stay unchanged.
|
All other keys of this context, which are not present in other, stay unchanged.
|
||||||
@param other
|
@param other
|
||||||
*/
|
*/
|
||||||
void DiagramContext::add(DiagramContext other)
|
void DiagramContext::add(DiagramContext other)
|
||||||
{
|
{
|
||||||
for (QString key : other.keys()) {
|
for (QString key : other.keys()) {
|
||||||
addValue(key, other.value(key));
|
addValue(key, other.value(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief DiagramContext::remove
|
@brief DiagramContext::remove
|
||||||
@param key
|
@param key
|
||||||
*/
|
*/
|
||||||
void DiagramContext::remove(const QString &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<QString> DiagramContext::keys(DiagramContext::KeyOrder order) const
|
QList<QString> DiagramContext::keys(DiagramContext::KeyOrder order) const
|
||||||
{
|
{
|
||||||
if (order == None) {
|
if (order == None) {
|
||||||
return m_content.keys();
|
return m_content.keys();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QList<QString> keys_list = m_content.keys();
|
QList<QString> keys_list = m_content.keys();
|
||||||
if (order == Alphabetical) {
|
if (order == Alphabetical) {
|
||||||
std::sort(keys_list.begin(), keys_list.end());
|
std::sort(keys_list.begin(), keys_list.end());
|
||||||
} else {
|
} else {
|
||||||
std::sort(keys_list.begin(), keys_list.end(), DiagramContext::stringLongerThan);
|
std::sort(keys_list.begin(), keys_list.end(), DiagramContext::stringLongerThan);
|
||||||
}
|
}
|
||||||
return(keys_list);
|
return(keys_list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param key string key
|
@param key string key
|
||||||
@return true if that key is known to the diagram context, false otherwise
|
@return true if that key is known to the diagram context, false otherwise
|
||||||
*/
|
*/
|
||||||
bool DiagramContext::contains(const QString &key) const
|
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
|
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
|
@param key key to insert in the context - the key may only contain lowercase
|
||||||
letters and dashes.
|
letters and dashes.
|
||||||
If embedded key is set, key must be find it else value is not added.
|
If embedded key is set, key must be find it else value is not added.
|
||||||
@see DiagramContext::keyIsAcceptable()
|
@see DiagramContext::keyIsAcceptable()
|
||||||
@param value value to insert in the context
|
@param value value to insert in the context
|
||||||
@param show if value is used to be show on the diagram or somewhere else,
|
@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)
|
we can specify if he is show(true) or not(false)
|
||||||
@return true if the insertion succeeds, false otherwise
|
@return true if the insertion succeeds, false otherwise
|
||||||
*/
|
*/
|
||||||
bool DiagramContext::addValue(const QString &key, const QVariant &value, bool show) {
|
bool DiagramContext::addValue(const QString &key, const QVariant &value, bool show) {
|
||||||
if (keyIsAcceptable(key)) {
|
if (keyIsAcceptable(key)) {
|
||||||
m_content.insert(key, value);
|
m_content.insert(key, value);
|
||||||
m_content_show.insert(key, show);
|
m_content_show.insert(key, show);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DiagramContext::value(const QString &key) const
|
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()
|
void DiagramContext::clear()
|
||||||
{
|
{
|
||||||
m_content.clear();
|
m_content.clear();
|
||||||
m_content_show.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()
|
int DiagramContext::count()
|
||||||
{
|
{
|
||||||
return(m_content.count());
|
return(m_content.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief DiagramContext::keyMustShow
|
@brief DiagramContext::keyMustShow
|
||||||
@return the value pairs with key, if key no found, return false
|
@return the value pairs with key, if key no found, return false
|
||||||
*/
|
*/
|
||||||
bool DiagramContext::keyMustShow(const QString &key) const
|
bool DiagramContext::keyMustShow(const QString &key) const
|
||||||
{
|
{
|
||||||
if (m_content_show.contains(key))
|
if (m_content_show.contains(key))
|
||||||
return m_content_show[key];
|
return m_content_show[key];
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiagramContext::operator==(const DiagramContext &dc) const
|
bool DiagramContext::operator==(const DiagramContext &dc) const
|
||||||
{
|
{
|
||||||
return(m_content == dc.m_content &&
|
return(m_content == dc.m_content &&
|
||||||
m_content_show == dc.m_content_show);
|
m_content_show == dc.m_content_show);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiagramContext::operator!=(const DiagramContext &dc) const
|
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
|
Export this context properties under the \a e XML element, using tags
|
||||||
named \a tag_name (defaults to "property").
|
named \a tag_name (defaults to "property").
|
||||||
*/
|
*/
|
||||||
void DiagramContext::toXml(QDomElement &e, const QString &tag_name) const
|
void DiagramContext::toXml(QDomElement &e, const QString &tag_name) const
|
||||||
{
|
{
|
||||||
foreach (QString key, keys()) {
|
foreach (QString key, keys()) {
|
||||||
QDomElement property = e.ownerDocument().createElement(tag_name);
|
QDomElement property = e.ownerDocument().createElement(tag_name);
|
||||||
property.setAttribute("name", key);
|
property.setAttribute("name", key);
|
||||||
property.setAttribute("show",m_content_show[key]);
|
property.setAttribute("show",m_content_show[key]);
|
||||||
QDomText value = e.ownerDocument().createTextNode(m_content[key].toString());
|
QDomText value = e.ownerDocument().createTextNode(m_content[key].toString());
|
||||||
property.appendChild(value);
|
property.appendChild(value);
|
||||||
e.appendChild(property);
|
e.appendChild(property);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Read this context properties from the \a e XML element, looking for tags named
|
Read this context properties from the \a e XML element, looking for tags named
|
||||||
\a tag_name (defaults to "property").
|
\a tag_name (defaults to "property").
|
||||||
*/
|
*/
|
||||||
void DiagramContext::fromXml(const QDomElement &e, const QString &tag_name) {
|
void DiagramContext::fromXml(const QDomElement &e, const QString &tag_name) {
|
||||||
foreach (QDomElement property, QET::findInDomElement(e, tag_name)) {
|
foreach (QDomElement property, QET::findInDomElement(e, tag_name)) {
|
||||||
if (!property.hasAttribute("name")) continue;
|
if (!property.hasAttribute("name")) continue;
|
||||||
addValue(property.attribute("name"), QVariant(property.text()));
|
addValue(property.attribute("name"), QVariant(property.text()));
|
||||||
m_content_show.insert(property.attribute("name"), property.attribute("show", "1").toInt());
|
m_content_show.insert(property.attribute("name"), property.attribute("show", "1").toInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief DiagramContext::fromXml
|
@brief DiagramContext::fromXml
|
||||||
Read this context properties from the dom_element,
|
Read this context properties from the dom_element,
|
||||||
looking for tags named tag_name
|
looking for tags named tag_name
|
||||||
@param dom_element : dom element to parse
|
@param dom_element : dom element to parse
|
||||||
@param tag_name : tag name to find, by default "property"
|
@param tag_name : tag name to find, by default "property"
|
||||||
*/
|
*/
|
||||||
void DiagramContext::fromXml(const pugi::xml_node &dom_element, const QString &tag_name)
|
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()))
|
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()));
|
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());
|
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
|
Export this context properties to \a settings by creating an array named \a
|
||||||
array_name.
|
array_name.
|
||||||
*/
|
*/
|
||||||
void DiagramContext::toSettings(QSettings &settings, const QString &array_name) const
|
void DiagramContext::toSettings(QSettings &settings, const QString &array_name) const
|
||||||
{
|
{
|
||||||
settings.beginWriteArray(array_name);
|
settings.beginWriteArray(array_name);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (QString key, m_content.keys()) {
|
foreach (QString key, m_content.keys()) {
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
settings.setValue("name", key);
|
settings.setValue("name", key);
|
||||||
settings.setValue("value", m_content[key].toString());
|
settings.setValue("value", m_content[key].toString());
|
||||||
++ i;
|
++ i;
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Read this context properties from \a settings by running through the array
|
Read this context properties from \a settings by running through the array
|
||||||
named \a array_name.
|
named \a array_name.
|
||||||
*/
|
*/
|
||||||
void DiagramContext::fromSettings(const QSettings &settings, const QString &array_name) {
|
void DiagramContext::fromSettings(const QSettings &settings, const QString &array_name) {
|
||||||
int size = settings.beginReadArray(array_name);
|
int size = settings.beginReadArray(array_name);
|
||||||
QSettings& s = const_cast<QSettings&>(settings);
|
QSettings& s = const_cast<QSettings&>(settings);
|
||||||
int size = s.beginReadArray(array_name);
|
int size = s.beginReadArray(array_name);
|
||||||
for (int i = 0 ; i < size; ++ i) {
|
for (int i = 0 ; i < size; ++ i) {
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
QString key = settings.value("name").toString();
|
QString key = settings.value("name").toString();
|
||||||
if (key.isEmpty()) continue;
|
if (key.isEmpty()) continue;
|
||||||
addValue(key, settings.value("value").toString());
|
addValue(key, settings.value("value").toString());
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return the regular expression used to check whether a given key is acceptable.
|
@return the regular expression used to check whether a given key is acceptable.
|
||||||
@see keyIsAcceptable()
|
@see keyIsAcceptable()
|
||||||
*/
|
*/
|
||||||
QString DiagramContext::validKeyRegExp()
|
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) {
|
bool DiagramContext::stringLongerThan(const QString &a, const QString &b) {
|
||||||
return (a.length() > b.length());
|
return (a.length() > b.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param key a key string
|
@param key a key string
|
||||||
@return true if that key is acceptable, false otherwise
|
@return true if that key is acceptable, false otherwise
|
||||||
*/
|
*/
|
||||||
bool DiagramContext::keyIsAcceptable(const QString &key) const
|
bool DiagramContext::keyIsAcceptable(const QString &key) const
|
||||||
{
|
{
|
||||||
QRegularExpression re(DiagramContext::validKeyRegExp());
|
QRegularExpression re(DiagramContext::validKeyRegExp());
|
||||||
QRegularExpressionMatch match =re.match(key);
|
QRegularExpressionMatch match =re.match(key);
|
||||||
return match.hasMatch();
|
return match.hasMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator <<(QDebug debug, const DiagramContext &context)
|
QDebug operator <<(QDebug debug, const DiagramContext &context)
|
||||||
{
|
{
|
||||||
debug << "DiagramContext";
|
debug << "DiagramContext";
|
||||||
for (auto key : context.keys()) {
|
for (auto key : context.keys()) {
|
||||||
debug.nospace() << key << " : " << context.value(key) << "\n";
|
debug.nospace() << key << " : " << context.value(key) << "\n";
|
||||||
}
|
}
|
||||||
debug << " end DiagramContext";
|
debug << " end DiagramContext";
|
||||||
|
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef DIAGRAM_CONTEXT_H
|
#ifndef DIAGRAM_CONTEXT_H
|
||||||
#define DIAGRAM_CONTEXT_H
|
#define DIAGRAM_CONTEXT_H
|
||||||
@@ -26,69 +26,69 @@
|
|||||||
|
|
||||||
#include "pugixml.hpp"
|
#include "pugixml.hpp"
|
||||||
/**
|
/**
|
||||||
This class represents a diagram context, i.e. the data (a list of key/value
|
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
|
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
|
to fetch the informations they need to do their rendering, or element for retrieve information about itself
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key for element :
|
* Key for element :
|
||||||
* label -> label or identification of element
|
* label -> label or identification of element
|
||||||
* formula -> formula used to create the label (formula is make with variable)
|
* formula -> formula used to create the label (formula is make with variable)
|
||||||
* designation -> exhaustive comment used to explain what the element does.
|
* designation -> exhaustive comment used to explain what the element does.
|
||||||
* description -> exhaustive description used to explain what the element does.
|
* description -> exhaustive description used to explain what the element does.
|
||||||
* plant -> the plant assigned to the element
|
* plant -> the plant assigned to the element
|
||||||
* comment -> a little comment wich can be displayed in the folio
|
* comment -> a little comment wich can be displayed in the folio
|
||||||
* manufacturer -> the manufacturer of the element
|
* manufacturer -> the manufacturer of the element
|
||||||
* manufacturer_reference -> the manufacturer reference of the element
|
* manufacturer_reference -> the manufacturer reference of the element
|
||||||
* quantity -> quantity of the element
|
* quantity -> quantity of the element
|
||||||
* unity -> unity of the element
|
* unity -> unity of the element
|
||||||
* auxiliary1 -> auxiliary 1 of element
|
* auxiliary1 -> auxiliary 1 of element
|
||||||
* auxiliary2 -> auxiliary 2 of element
|
* auxiliary2 -> auxiliary 2 of element
|
||||||
* machine_manufacturer_reference -> reference of the machine manufacturer
|
* machine_manufacturer_reference -> reference of the machine manufacturer
|
||||||
* supplier -> the supplier of the element
|
* supplier -> the supplier of the element
|
||||||
* function -> the function of element
|
* function -> the function of element
|
||||||
* location -> the location assigned to the element
|
* location -> the location assigned to the element
|
||||||
* frozenLabel -> label locked at a given time
|
* frozenLabel -> label locked at a given time
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class DiagramContext
|
class DiagramContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum KeyOrder {
|
enum KeyOrder {
|
||||||
None,
|
None,
|
||||||
Alphabetical,
|
Alphabetical,
|
||||||
DecreasingLength
|
DecreasingLength
|
||||||
};
|
};
|
||||||
|
|
||||||
void add(DiagramContext other);
|
void add(DiagramContext other);
|
||||||
void remove(const QString &key);
|
void remove(const QString &key);
|
||||||
QList<QString> keys(KeyOrder = None) const;
|
QList<QString> keys(KeyOrder = None) const;
|
||||||
bool contains(const QString &) const;
|
bool contains(const QString &) const;
|
||||||
const QVariant operator[](const QString &) const;
|
const QVariant operator[](const QString &) const;
|
||||||
bool addValue(const QString &, const QVariant &, bool show = true);
|
bool addValue(const QString &, const QVariant &, bool show = true);
|
||||||
QVariant value(const QString &key) const;
|
QVariant value(const QString &key) const;
|
||||||
void clear();
|
void clear();
|
||||||
int count();
|
int count();
|
||||||
bool keyMustShow (const QString &) const;
|
bool keyMustShow (const QString &) const;
|
||||||
|
|
||||||
bool operator==(const DiagramContext &) const;
|
bool operator==(const DiagramContext &) const;
|
||||||
bool operator!=(const DiagramContext &) const;
|
bool operator!=(const DiagramContext &) const;
|
||||||
|
|
||||||
void toXml(QDomElement &, const QString & = "property") const;
|
void toXml(QDomElement &, const QString & = "property") const;
|
||||||
void fromXml(const QDomElement &, const QString & = "property");
|
void fromXml(const QDomElement &, const QString & = "property");
|
||||||
void fromXml(const pugi::xml_node &dom_element, const QString &tag_name = "property");
|
void fromXml(const pugi::xml_node &dom_element, const QString &tag_name = "property");
|
||||||
void toSettings(QSettings &, const QString &) const;
|
void toSettings(QSettings &, const QString &) const;
|
||||||
void fromSettings(QSettings &, const QString &);
|
void fromSettings(QSettings &, const QString &);
|
||||||
|
|
||||||
static QString validKeyRegExp();
|
static QString validKeyRegExp();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool stringLongerThan(const QString &, const QString &);
|
static bool stringLongerThan(const QString &, const QString &);
|
||||||
bool keyIsAcceptable(const QString &) const;
|
bool keyIsAcceptable(const QString &) const;
|
||||||
/// Diagram context data (key/value pairs)
|
/// Diagram context data (key/value pairs)
|
||||||
QHash<QString, QVariant> m_content;
|
QHash<QString, QVariant> m_content;
|
||||||
QHash<QString, bool> m_content_show;
|
QHash<QString, bool> m_content_show;
|
||||||
};
|
};
|
||||||
|
|
||||||
QDebug operator <<(QDebug debug, const DiagramContext &context);
|
QDebug operator <<(QDebug debug, const DiagramContext &context);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef CUSTOM_ELEMENT_GRAPHIC_PART_H
|
#ifndef CUSTOM_ELEMENT_GRAPHIC_PART_H
|
||||||
#define CUSTOM_ELEMENT_GRAPHIC_PART_H
|
#define CUSTOM_ELEMENT_GRAPHIC_PART_H
|
||||||
@@ -26,308 +26,308 @@ class QPainter;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The CustomElementGraphicPart class
|
@brief The CustomElementGraphicPart class
|
||||||
This class is the base for all home-made primitive like line,
|
This class is the base for all home-made primitive like line,
|
||||||
rectangle, ellipse etc....
|
rectangle, ellipse etc....
|
||||||
It provides methods and enums to manage style attributes available
|
It provides methods and enums to manage style attributes available
|
||||||
for primitive (color, pen style, etc...)
|
for primitive (color, pen style, etc...)
|
||||||
*/
|
*/
|
||||||
class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPart
|
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(LineStyle line_style READ lineStyle WRITE setLineStyle)
|
||||||
Q_PROPERTY(LineWeight line_weight READ lineWeight WRITE setLineWeight)
|
Q_PROPERTY(LineWeight line_weight READ lineWeight WRITE setLineWeight)
|
||||||
Q_PROPERTY(Filling filling READ filling WRITE setFilling)
|
Q_PROPERTY(Filling filling READ filling WRITE setFilling)
|
||||||
Q_PROPERTY(Color color READ color WRITE setColor)
|
Q_PROPERTY(Color color READ color WRITE setColor)
|
||||||
Q_PROPERTY(bool antialias READ antialiased WRITE setAntialiased)
|
Q_PROPERTY(bool antialias READ antialiased WRITE setAntialiased)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//Line style
|
//Line style
|
||||||
enum LineStyle {NormalStyle,
|
enum LineStyle {NormalStyle,
|
||||||
DashedStyle,
|
DashedStyle,
|
||||||
DottedStyle,
|
DottedStyle,
|
||||||
DashdottedStyle};
|
DashdottedStyle};
|
||||||
Q_ENUM (LineStyle)
|
Q_ENUM (LineStyle)
|
||||||
|
|
||||||
//Line weight : invisible, 0px, 1px, 2px, 5px
|
//Line weight : invisible, 0px, 1px, 2px, 5px
|
||||||
enum LineWeight {NoneWeight,
|
enum LineWeight {NoneWeight,
|
||||||
ThinWeight,
|
ThinWeight,
|
||||||
NormalWeight,
|
NormalWeight,
|
||||||
UltraWeight,
|
UltraWeight,
|
||||||
BigWeight};
|
BigWeight};
|
||||||
Q_ENUM (LineWeight)
|
Q_ENUM (LineWeight)
|
||||||
|
|
||||||
//Filling color of the part : NoneFilling -> No filling (i.e. transparent)
|
//Filling color of the part : NoneFilling -> No filling (i.e. transparent)
|
||||||
enum Filling { NoneFilling, BlackFilling, WhiteFilling,
|
enum Filling { NoneFilling, BlackFilling, WhiteFilling,
|
||||||
GreenFilling, RedFilling, BlueFilling,
|
GreenFilling, RedFilling, BlueFilling,
|
||||||
GrayFilling, BrunFilling, YellowFilling,
|
GrayFilling, BrunFilling, YellowFilling,
|
||||||
CyanFilling, MagentaFilling, LightgrayFilling,
|
CyanFilling, MagentaFilling, LightgrayFilling,
|
||||||
OrangeFilling, PurpleFilling,
|
OrangeFilling, PurpleFilling,
|
||||||
HTMLPinkPinkFilling, HTMLPinkLightPinkFilling,
|
HTMLPinkPinkFilling, HTMLPinkLightPinkFilling,
|
||||||
HTMLPinkHotPinkFilling, HTMLPinkDeepPinkFilling,
|
HTMLPinkHotPinkFilling, HTMLPinkDeepPinkFilling,
|
||||||
HTMLPinkPaleVioletRedFilling,
|
HTMLPinkPaleVioletRedFilling,
|
||||||
HTMLPinkMediumVioletRedFilling,
|
HTMLPinkMediumVioletRedFilling,
|
||||||
HTMLRedLightSalmonFilling, HTMLRedSalmonFilling,
|
HTMLRedLightSalmonFilling, HTMLRedSalmonFilling,
|
||||||
HTMLRedDarkSalmonFilling,
|
HTMLRedDarkSalmonFilling,
|
||||||
HTMLRedLightCoralFilling,
|
HTMLRedLightCoralFilling,
|
||||||
HTMLRedIndianRedFilling, HTMLRedCrimsonFilling,
|
HTMLRedIndianRedFilling, HTMLRedCrimsonFilling,
|
||||||
HTMLRedFirebrickFilling, HTMLRedDarkRedFilling,
|
HTMLRedFirebrickFilling, HTMLRedDarkRedFilling,
|
||||||
HTMLRedRedFilling, HTMLOrangeOrangeRedFilling,
|
HTMLRedRedFilling, HTMLOrangeOrangeRedFilling,
|
||||||
HTMLOrangeTomatoFilling, HTMLOrangeCoralFilling,
|
HTMLOrangeTomatoFilling, HTMLOrangeCoralFilling,
|
||||||
HTMLOrangeDarkOrangeFilling,
|
HTMLOrangeDarkOrangeFilling,
|
||||||
HTMLOrangeOrangeFilling, HTMLYellowYellowFilling,
|
HTMLOrangeOrangeFilling, HTMLYellowYellowFilling,
|
||||||
HTMLYellowLightYellowFilling,
|
HTMLYellowLightYellowFilling,
|
||||||
HTMLYellowLemonChiffonFilling,
|
HTMLYellowLemonChiffonFilling,
|
||||||
HTMLYellowLightGoldenrodYellowFilling,
|
HTMLYellowLightGoldenrodYellowFilling,
|
||||||
HTMLYellowPapayaWhipFilling,
|
HTMLYellowPapayaWhipFilling,
|
||||||
HTMLYellowMoccasinFilling,
|
HTMLYellowMoccasinFilling,
|
||||||
HTMLYellowPeachPuffFilling,
|
HTMLYellowPeachPuffFilling,
|
||||||
HTMLYellowPaleGoldenrodFilling,
|
HTMLYellowPaleGoldenrodFilling,
|
||||||
HTMLYellowKhakiFilling,
|
HTMLYellowKhakiFilling,
|
||||||
HTMLYellowDarkKhakiFilling,
|
HTMLYellowDarkKhakiFilling,
|
||||||
HTMLYellowGoldFilling, HTMLBrownCornsilkFilling,
|
HTMLYellowGoldFilling, HTMLBrownCornsilkFilling,
|
||||||
HTMLBrownBlanchedAlmondFilling,
|
HTMLBrownBlanchedAlmondFilling,
|
||||||
HTMLBrownBisqueFilling,
|
HTMLBrownBisqueFilling,
|
||||||
HTMLBrownNavajoWhiteFilling,
|
HTMLBrownNavajoWhiteFilling,
|
||||||
HTMLBrownWheatFilling, HTMLBrownBurlywoodFilling,
|
HTMLBrownWheatFilling, HTMLBrownBurlywoodFilling,
|
||||||
HTMLBrownTanFilling, HTMLBrownRosyBrownFilling,
|
HTMLBrownTanFilling, HTMLBrownRosyBrownFilling,
|
||||||
HTMLBrownSandyBrownFilling,
|
HTMLBrownSandyBrownFilling,
|
||||||
HTMLBrownGoldenrodFilling,
|
HTMLBrownGoldenrodFilling,
|
||||||
HTMLBrownDarkGoldenrodFilling,
|
HTMLBrownDarkGoldenrodFilling,
|
||||||
HTMLBrownPeruFilling, HTMLBrownChocolateFilling,
|
HTMLBrownPeruFilling, HTMLBrownChocolateFilling,
|
||||||
HTMLBrownSaddleBrownFilling,
|
HTMLBrownSaddleBrownFilling,
|
||||||
HTMLBrownSiennaFilling, HTMLBrownBrownFilling,
|
HTMLBrownSiennaFilling, HTMLBrownBrownFilling,
|
||||||
HTMLBrownMaroonFilling,
|
HTMLBrownMaroonFilling,
|
||||||
HTMLGreenDarkOliveGreenFilling,
|
HTMLGreenDarkOliveGreenFilling,
|
||||||
HTMLGreenOliveFilling, HTMLGreenOliveDrabFilling,
|
HTMLGreenOliveFilling, HTMLGreenOliveDrabFilling,
|
||||||
HTMLGreenYellowGreenFilling,
|
HTMLGreenYellowGreenFilling,
|
||||||
HTMLGreenLimeGreenFilling, HTMLGreenLimeFilling,
|
HTMLGreenLimeGreenFilling, HTMLGreenLimeFilling,
|
||||||
HTMLGreenLawnGreenFilling,
|
HTMLGreenLawnGreenFilling,
|
||||||
HTMLGreenChartreuseFilling,
|
HTMLGreenChartreuseFilling,
|
||||||
HTMLGreenGreenYellowFilling,
|
HTMLGreenGreenYellowFilling,
|
||||||
HTMLGreenSpringGreenFilling,
|
HTMLGreenSpringGreenFilling,
|
||||||
HTMLGreenMediumSpringGreenFilling,
|
HTMLGreenMediumSpringGreenFilling,
|
||||||
HTMLGreenLightGreenFilling,
|
HTMLGreenLightGreenFilling,
|
||||||
HTMLGreenPaleGreenFilling,
|
HTMLGreenPaleGreenFilling,
|
||||||
HTMLGreenDarkSeaGreenFilling,
|
HTMLGreenDarkSeaGreenFilling,
|
||||||
HTMLGreenMediumAquamarineFilling,
|
HTMLGreenMediumAquamarineFilling,
|
||||||
HTMLGreenMediumSeaGreenFilling,
|
HTMLGreenMediumSeaGreenFilling,
|
||||||
HTMLGreenSeaGreenFilling,
|
HTMLGreenSeaGreenFilling,
|
||||||
HTMLGreenForestGreenFilling,
|
HTMLGreenForestGreenFilling,
|
||||||
HTMLGreenGreenFilling, HTMLGreenDarkGreenFilling,
|
HTMLGreenGreenFilling, HTMLGreenDarkGreenFilling,
|
||||||
HTMLCyanAquaFilling, HTMLCyanCyanFilling,
|
HTMLCyanAquaFilling, HTMLCyanCyanFilling,
|
||||||
HTMLCyanLightCyanFilling,
|
HTMLCyanLightCyanFilling,
|
||||||
HTMLCyanPaleTurquoiseFilling,
|
HTMLCyanPaleTurquoiseFilling,
|
||||||
HTMLCyanAquamarineFilling,
|
HTMLCyanAquamarineFilling,
|
||||||
HTMLCyanTurquoiseFilling,
|
HTMLCyanTurquoiseFilling,
|
||||||
HTMLCyanMediumTurquoiseFilling,
|
HTMLCyanMediumTurquoiseFilling,
|
||||||
HTMLCyanDarkTurquoiseFilling,
|
HTMLCyanDarkTurquoiseFilling,
|
||||||
HTMLCyanLightSeaGreenFilling,
|
HTMLCyanLightSeaGreenFilling,
|
||||||
HTMLCyanCadetBlueFilling,
|
HTMLCyanCadetBlueFilling,
|
||||||
HTMLCyanDarkCyanFilling, HTMLCyanTealFilling,
|
HTMLCyanDarkCyanFilling, HTMLCyanTealFilling,
|
||||||
HTMLBlueLightSteelBlueFilling,
|
HTMLBlueLightSteelBlueFilling,
|
||||||
HTMLBluePowderBlueFilling,
|
HTMLBluePowderBlueFilling,
|
||||||
HTMLBlueLightBlueFilling, HTMLBlueSkyBlueFilling,
|
HTMLBlueLightBlueFilling, HTMLBlueSkyBlueFilling,
|
||||||
HTMLBlueLightSkyBlueFilling,
|
HTMLBlueLightSkyBlueFilling,
|
||||||
HTMLBlueDeepSkyBlueFilling,
|
HTMLBlueDeepSkyBlueFilling,
|
||||||
HTMLBlueDodgerBlueFilling,
|
HTMLBlueDodgerBlueFilling,
|
||||||
HTMLBlueCornflowerBlueFilling,
|
HTMLBlueCornflowerBlueFilling,
|
||||||
HTMLBlueSteelBlueFilling,
|
HTMLBlueSteelBlueFilling,
|
||||||
HTMLBlueRoyalBlueFilling, HTMLBlueBlueFilling,
|
HTMLBlueRoyalBlueFilling, HTMLBlueBlueFilling,
|
||||||
HTMLBlueMediumBlueFilling,
|
HTMLBlueMediumBlueFilling,
|
||||||
HTMLBlueDarkBlueFilling, HTMLBlueNavyFilling,
|
HTMLBlueDarkBlueFilling, HTMLBlueNavyFilling,
|
||||||
HTMLBlueMidnightBlueFilling,
|
HTMLBlueMidnightBlueFilling,
|
||||||
HTMLPurpleLavenderFilling,
|
HTMLPurpleLavenderFilling,
|
||||||
HTMLPurpleThistleFilling, HTMLPurplePlumFilling,
|
HTMLPurpleThistleFilling, HTMLPurplePlumFilling,
|
||||||
HTMLPurpleVioletFilling, HTMLPurpleOrchidFilling,
|
HTMLPurpleVioletFilling, HTMLPurpleOrchidFilling,
|
||||||
HTMLPurpleFuchsiaFilling,
|
HTMLPurpleFuchsiaFilling,
|
||||||
HTMLPurpleMagentaFilling,
|
HTMLPurpleMagentaFilling,
|
||||||
HTMLPurpleMediumOrchidFilling,
|
HTMLPurpleMediumOrchidFilling,
|
||||||
HTMLPurpleMediumPurpleFilling,
|
HTMLPurpleMediumPurpleFilling,
|
||||||
HTMLPurpleBlueVioletFilling,
|
HTMLPurpleBlueVioletFilling,
|
||||||
HTMLPurpleDarkVioletFilling,
|
HTMLPurpleDarkVioletFilling,
|
||||||
HTMLPurpleDarkOrchidFilling,
|
HTMLPurpleDarkOrchidFilling,
|
||||||
HTMLPurpleDarkMagentaFilling,
|
HTMLPurpleDarkMagentaFilling,
|
||||||
HTMLPurplePurpleFilling, HTMLPurpleIndigoFilling,
|
HTMLPurplePurpleFilling, HTMLPurpleIndigoFilling,
|
||||||
HTMLPurpleDarkSlateBlueFilling,
|
HTMLPurpleDarkSlateBlueFilling,
|
||||||
HTMLPurpleSlateBlueFilling,
|
HTMLPurpleSlateBlueFilling,
|
||||||
HTMLPurpleMediumSlateBlueFilling,
|
HTMLPurpleMediumSlateBlueFilling,
|
||||||
HTMLWhiteWhiteFilling, HTMLWhiteSnowFilling,
|
HTMLWhiteWhiteFilling, HTMLWhiteSnowFilling,
|
||||||
HTMLWhiteHoneydewFilling,
|
HTMLWhiteHoneydewFilling,
|
||||||
HTMLWhiteMintCreamFilling, HTMLWhiteAzureFilling,
|
HTMLWhiteMintCreamFilling, HTMLWhiteAzureFilling,
|
||||||
HTMLWhiteAliceBlueFilling,
|
HTMLWhiteAliceBlueFilling,
|
||||||
HTMLWhiteGhostWhiteFilling,
|
HTMLWhiteGhostWhiteFilling,
|
||||||
HTMLWhiteWhiteSmokeFilling,
|
HTMLWhiteWhiteSmokeFilling,
|
||||||
HTMLWhiteSeashellFilling, HTMLWhiteBeigeFilling,
|
HTMLWhiteSeashellFilling, HTMLWhiteBeigeFilling,
|
||||||
HTMLWhiteOldLaceFilling,
|
HTMLWhiteOldLaceFilling,
|
||||||
HTMLWhiteFloralWhiteFilling,
|
HTMLWhiteFloralWhiteFilling,
|
||||||
HTMLWhiteIvoryFilling,
|
HTMLWhiteIvoryFilling,
|
||||||
HTMLWhiteAntiqueWhiteFilling,
|
HTMLWhiteAntiqueWhiteFilling,
|
||||||
HTMLWhiteLinenFilling,
|
HTMLWhiteLinenFilling,
|
||||||
HTMLWhiteLavenderBlushFilling,
|
HTMLWhiteLavenderBlushFilling,
|
||||||
HTMLWhiteMistyRoseFilling,
|
HTMLWhiteMistyRoseFilling,
|
||||||
HTMLGrayGainsboroFilling,
|
HTMLGrayGainsboroFilling,
|
||||||
HTMLGrayLightGrayFilling, HTMLGraySilverFilling,
|
HTMLGrayLightGrayFilling, HTMLGraySilverFilling,
|
||||||
HTMLGrayDarkGrayFilling, HTMLGrayGrayFilling,
|
HTMLGrayDarkGrayFilling, HTMLGrayGrayFilling,
|
||||||
HTMLGrayDimGrayFilling,
|
HTMLGrayDimGrayFilling,
|
||||||
HTMLGrayLightSlateGrayFilling,
|
HTMLGrayLightSlateGrayFilling,
|
||||||
HTMLGraySlateGrayFilling,
|
HTMLGraySlateGrayFilling,
|
||||||
HTMLGrayDarkSlateGrayFilling,
|
HTMLGrayDarkSlateGrayFilling,
|
||||||
HTMLGrayBlackFilling, HorFilling, VerFilling,
|
HTMLGrayBlackFilling, HorFilling, VerFilling,
|
||||||
BdiagFilling, FdiagFilling};
|
BdiagFilling, FdiagFilling};
|
||||||
Q_ENUM (Filling)
|
Q_ENUM (Filling)
|
||||||
|
|
||||||
//Line color
|
//Line color
|
||||||
enum Color {
|
enum Color {
|
||||||
BlackColor, WhiteColor, GreenColor, RedColor, BlueColor,
|
BlackColor, WhiteColor, GreenColor, RedColor, BlueColor,
|
||||||
GrayColor, BrunColor, YellowColor, CyanColor,
|
GrayColor, BrunColor, YellowColor, CyanColor,
|
||||||
MagentaColor, LightgrayColor, OrangeColor, PurpleColor,
|
MagentaColor, LightgrayColor, OrangeColor, PurpleColor,
|
||||||
HTMLPinkPinkColor, HTMLPinkLightPinkColor,
|
HTMLPinkPinkColor, HTMLPinkLightPinkColor,
|
||||||
HTMLPinkHotPinkColor, HTMLPinkDeepPinkColor,
|
HTMLPinkHotPinkColor, HTMLPinkDeepPinkColor,
|
||||||
HTMLPinkPaleVioletRedColor,
|
HTMLPinkPaleVioletRedColor,
|
||||||
HTMLPinkMediumVioletRedColor, HTMLRedLightSalmonColor,
|
HTMLPinkMediumVioletRedColor, HTMLRedLightSalmonColor,
|
||||||
HTMLRedSalmonColor, HTMLRedDarkSalmonColor,
|
HTMLRedSalmonColor, HTMLRedDarkSalmonColor,
|
||||||
HTMLRedLightCoralColor, HTMLRedIndianRedColor,
|
HTMLRedLightCoralColor, HTMLRedIndianRedColor,
|
||||||
HTMLRedCrimsonColor, HTMLRedFirebrickColor,
|
HTMLRedCrimsonColor, HTMLRedFirebrickColor,
|
||||||
HTMLRedDarkRedColor, HTMLRedRedColor,
|
HTMLRedDarkRedColor, HTMLRedRedColor,
|
||||||
HTMLOrangeOrangeRedColor, HTMLOrangeTomatoColor,
|
HTMLOrangeOrangeRedColor, HTMLOrangeTomatoColor,
|
||||||
HTMLOrangeCoralColor, HTMLOrangeDarkOrangeColor,
|
HTMLOrangeCoralColor, HTMLOrangeDarkOrangeColor,
|
||||||
HTMLOrangeOrangeColor, HTMLYellowYellowColor,
|
HTMLOrangeOrangeColor, HTMLYellowYellowColor,
|
||||||
HTMLYellowLightYellowColor, HTMLYellowLemonChiffonColor,
|
HTMLYellowLightYellowColor, HTMLYellowLemonChiffonColor,
|
||||||
HTMLYellowLightGoldenrodYellowColor,
|
HTMLYellowLightGoldenrodYellowColor,
|
||||||
HTMLYellowPapayaWhipColor, HTMLYellowMoccasinColor,
|
HTMLYellowPapayaWhipColor, HTMLYellowMoccasinColor,
|
||||||
HTMLYellowPeachPuffColor, HTMLYellowPaleGoldenrodColor,
|
HTMLYellowPeachPuffColor, HTMLYellowPaleGoldenrodColor,
|
||||||
HTMLYellowKhakiColor, HTMLYellowDarkKhakiColor,
|
HTMLYellowKhakiColor, HTMLYellowDarkKhakiColor,
|
||||||
HTMLYellowGoldColor, HTMLBrownCornsilkColor,
|
HTMLYellowGoldColor, HTMLBrownCornsilkColor,
|
||||||
HTMLBrownBlanchedAlmondColor, HTMLBrownBisqueColor,
|
HTMLBrownBlanchedAlmondColor, HTMLBrownBisqueColor,
|
||||||
HTMLBrownNavajoWhiteColor, HTMLBrownWheatColor,
|
HTMLBrownNavajoWhiteColor, HTMLBrownWheatColor,
|
||||||
HTMLBrownBurlywoodColor, HTMLBrownTanColor,
|
HTMLBrownBurlywoodColor, HTMLBrownTanColor,
|
||||||
HTMLBrownRosyBrownColor, HTMLBrownSandyBrownColor,
|
HTMLBrownRosyBrownColor, HTMLBrownSandyBrownColor,
|
||||||
HTMLBrownGoldenrodColor, HTMLBrownDarkGoldenrodColor,
|
HTMLBrownGoldenrodColor, HTMLBrownDarkGoldenrodColor,
|
||||||
HTMLBrownPeruColor, HTMLBrownChocolateColor,
|
HTMLBrownPeruColor, HTMLBrownChocolateColor,
|
||||||
HTMLBrownSaddleBrownColor, HTMLBrownSiennaColor,
|
HTMLBrownSaddleBrownColor, HTMLBrownSiennaColor,
|
||||||
HTMLBrownBrownColor, HTMLBrownMaroonColor,
|
HTMLBrownBrownColor, HTMLBrownMaroonColor,
|
||||||
HTMLGreenDarkOliveGreenColor, HTMLGreenOliveColor,
|
HTMLGreenDarkOliveGreenColor, HTMLGreenOliveColor,
|
||||||
HTMLGreenOliveDrabColor, HTMLGreenYellowGreenColor,
|
HTMLGreenOliveDrabColor, HTMLGreenYellowGreenColor,
|
||||||
HTMLGreenLimeGreenColor, HTMLGreenLimeColor,
|
HTMLGreenLimeGreenColor, HTMLGreenLimeColor,
|
||||||
HTMLGreenLawnGreenColor, HTMLGreenChartreuseColor,
|
HTMLGreenLawnGreenColor, HTMLGreenChartreuseColor,
|
||||||
HTMLGreenGreenYellowColor, HTMLGreenSpringGreenColor,
|
HTMLGreenGreenYellowColor, HTMLGreenSpringGreenColor,
|
||||||
HTMLGreenMediumSpringGreenColor,
|
HTMLGreenMediumSpringGreenColor,
|
||||||
HTMLGreenLightGreenColor, HTMLGreenPaleGreenColor,
|
HTMLGreenLightGreenColor, HTMLGreenPaleGreenColor,
|
||||||
HTMLGreenDarkSeaGreenColor,
|
HTMLGreenDarkSeaGreenColor,
|
||||||
HTMLGreenMediumAquamarineColor,
|
HTMLGreenMediumAquamarineColor,
|
||||||
HTMLGreenMediumSeaGreenColor, HTMLGreenSeaGreenColor,
|
HTMLGreenMediumSeaGreenColor, HTMLGreenSeaGreenColor,
|
||||||
HTMLGreenForestGreenColor, HTMLGreenGreenColor,
|
HTMLGreenForestGreenColor, HTMLGreenGreenColor,
|
||||||
HTMLGreenDarkGreenColor, HTMLCyanAquaColor,
|
HTMLGreenDarkGreenColor, HTMLCyanAquaColor,
|
||||||
HTMLCyanCyanColor, HTMLCyanLightCyanColor,
|
HTMLCyanCyanColor, HTMLCyanLightCyanColor,
|
||||||
HTMLCyanPaleTurquoiseColor, HTMLCyanAquamarineColor,
|
HTMLCyanPaleTurquoiseColor, HTMLCyanAquamarineColor,
|
||||||
HTMLCyanTurquoiseColor, HTMLCyanMediumTurquoiseColor,
|
HTMLCyanTurquoiseColor, HTMLCyanMediumTurquoiseColor,
|
||||||
HTMLCyanDarkTurquoiseColor, HTMLCyanLightSeaGreenColor,
|
HTMLCyanDarkTurquoiseColor, HTMLCyanLightSeaGreenColor,
|
||||||
HTMLCyanCadetBlueColor, HTMLCyanDarkCyanColor,
|
HTMLCyanCadetBlueColor, HTMLCyanDarkCyanColor,
|
||||||
HTMLCyanTealColor, HTMLBlueLightSteelBlueColor,
|
HTMLCyanTealColor, HTMLBlueLightSteelBlueColor,
|
||||||
HTMLBluePowderBlueColor, HTMLBlueLightBlueColor,
|
HTMLBluePowderBlueColor, HTMLBlueLightBlueColor,
|
||||||
HTMLBlueSkyBlueColor, HTMLBlueLightSkyBlueColor,
|
HTMLBlueSkyBlueColor, HTMLBlueLightSkyBlueColor,
|
||||||
HTMLBlueDeepSkyBlueColor, HTMLBlueDodgerBlueColor,
|
HTMLBlueDeepSkyBlueColor, HTMLBlueDodgerBlueColor,
|
||||||
HTMLBlueCornflowerBlueColor, HTMLBlueSteelBlueColor,
|
HTMLBlueCornflowerBlueColor, HTMLBlueSteelBlueColor,
|
||||||
HTMLBlueRoyalBlueColor, HTMLBlueBlueColor,
|
HTMLBlueRoyalBlueColor, HTMLBlueBlueColor,
|
||||||
HTMLBlueMediumBlueColor, HTMLBlueDarkBlueColor,
|
HTMLBlueMediumBlueColor, HTMLBlueDarkBlueColor,
|
||||||
HTMLBlueNavyColor, HTMLBlueMidnightBlueColor,
|
HTMLBlueNavyColor, HTMLBlueMidnightBlueColor,
|
||||||
HTMLPurpleLavenderColor, HTMLPurpleThistleColor,
|
HTMLPurpleLavenderColor, HTMLPurpleThistleColor,
|
||||||
HTMLPurplePlumColor, HTMLPurpleVioletColor,
|
HTMLPurplePlumColor, HTMLPurpleVioletColor,
|
||||||
HTMLPurpleOrchidColor, HTMLPurpleFuchsiaColor,
|
HTMLPurpleOrchidColor, HTMLPurpleFuchsiaColor,
|
||||||
HTMLPurpleMagentaColor, HTMLPurpleMediumOrchidColor,
|
HTMLPurpleMagentaColor, HTMLPurpleMediumOrchidColor,
|
||||||
HTMLPurpleMediumPurpleColor, HTMLPurpleBlueVioletColor,
|
HTMLPurpleMediumPurpleColor, HTMLPurpleBlueVioletColor,
|
||||||
HTMLPurpleDarkVioletColor, HTMLPurpleDarkOrchidColor,
|
HTMLPurpleDarkVioletColor, HTMLPurpleDarkOrchidColor,
|
||||||
HTMLPurpleDarkMagentaColor, HTMLPurplePurpleColor,
|
HTMLPurpleDarkMagentaColor, HTMLPurplePurpleColor,
|
||||||
HTMLPurpleIndigoColor, HTMLPurpleDarkSlateBlueColor,
|
HTMLPurpleIndigoColor, HTMLPurpleDarkSlateBlueColor,
|
||||||
HTMLPurpleSlateBlueColor,
|
HTMLPurpleSlateBlueColor,
|
||||||
HTMLPurpleMediumSlateBlueColor,
|
HTMLPurpleMediumSlateBlueColor,
|
||||||
HTMLWhiteWhiteColor, HTMLWhiteSnowColor,
|
HTMLWhiteWhiteColor, HTMLWhiteSnowColor,
|
||||||
HTMLWhiteHoneydewColor, HTMLWhiteMintCreamColor,
|
HTMLWhiteHoneydewColor, HTMLWhiteMintCreamColor,
|
||||||
HTMLWhiteAzureColor, HTMLWhiteAliceBlueColor,
|
HTMLWhiteAzureColor, HTMLWhiteAliceBlueColor,
|
||||||
HTMLWhiteGhostWhiteColor, HTMLWhiteWhiteSmokeColor,
|
HTMLWhiteGhostWhiteColor, HTMLWhiteWhiteSmokeColor,
|
||||||
HTMLWhiteSeashellColor, HTMLWhiteBeigeColor,
|
HTMLWhiteSeashellColor, HTMLWhiteBeigeColor,
|
||||||
HTMLWhiteOldLaceColor, HTMLWhiteFloralWhiteColor,
|
HTMLWhiteOldLaceColor, HTMLWhiteFloralWhiteColor,
|
||||||
HTMLWhiteIvoryColor, HTMLWhiteAntiqueWhiteColor,
|
HTMLWhiteIvoryColor, HTMLWhiteAntiqueWhiteColor,
|
||||||
HTMLWhiteLinenColor, HTMLWhiteLavenderBlushColor,
|
HTMLWhiteLinenColor, HTMLWhiteLavenderBlushColor,
|
||||||
HTMLWhiteMistyRoseColor, HTMLGrayGainsboroColor,
|
HTMLWhiteMistyRoseColor, HTMLGrayGainsboroColor,
|
||||||
HTMLGrayLightGrayColor, HTMLGraySilverColor,
|
HTMLGrayLightGrayColor, HTMLGraySilverColor,
|
||||||
HTMLGrayDarkGrayColor, HTMLGrayGrayColor,
|
HTMLGrayDarkGrayColor, HTMLGrayGrayColor,
|
||||||
HTMLGrayDimGrayColor, HTMLGrayLightSlateGrayColor,
|
HTMLGrayDimGrayColor, HTMLGrayLightSlateGrayColor,
|
||||||
HTMLGraySlateGrayColor, HTMLGrayDarkSlateGrayColor,
|
HTMLGraySlateGrayColor, HTMLGrayDarkSlateGrayColor,
|
||||||
HTMLGrayBlackColor, NoneColor};
|
HTMLGrayBlackColor, NoneColor};
|
||||||
Q_ENUM (Color)
|
Q_ENUM (Color)
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CustomElementGraphicPart(QETElementEditor *editor,
|
CustomElementGraphicPart(QETElementEditor *editor,
|
||||||
QGraphicsItem *parent = nullptr);
|
QGraphicsItem *parent = nullptr);
|
||||||
~CustomElementGraphicPart() override;
|
~CustomElementGraphicPart() override;
|
||||||
|
|
||||||
static void drawCross (const QPointF ¢er,
|
static void drawCross (const QPointF ¢er,
|
||||||
QPainter *painter);
|
QPainter *painter);
|
||||||
|
|
||||||
//Getter and setter
|
//Getter and setter
|
||||||
LineStyle lineStyle () const {return _linestyle;}
|
LineStyle lineStyle () const {return _linestyle;}
|
||||||
void setLineStyle (const LineStyle ls);
|
void setLineStyle (const LineStyle ls);
|
||||||
|
|
||||||
LineWeight lineWeight () const {return _lineweight;}
|
LineWeight lineWeight () const {return _lineweight;}
|
||||||
void setLineWeight (const LineWeight lw);
|
void setLineWeight (const LineWeight lw);
|
||||||
qreal penWeight () const;
|
qreal penWeight () const;
|
||||||
|
|
||||||
Filling filling () const {return _filling;}
|
Filling filling () const {return _filling;}
|
||||||
void setFilling(const Filling f);
|
void setFilling(const Filling f);
|
||||||
|
|
||||||
Color color () const {return _color;}
|
Color color () const {return _color;}
|
||||||
void setColor(const Color c);
|
void setColor(const Color c);
|
||||||
|
|
||||||
bool antialiased () const {return _antialiased;}
|
bool antialiased () const {return _antialiased;}
|
||||||
void setAntialiased(const bool b);
|
void setAntialiased(const bool b);
|
||||||
//End of getter and setter
|
//End of getter and setter
|
||||||
|
|
||||||
|
|
||||||
//Rediriged to QObject Q_PROPERTY system
|
//Rediriged to QObject Q_PROPERTY system
|
||||||
void setProperty (const char *name,
|
void setProperty (const char *name,
|
||||||
const QVariant &value) override {
|
const QVariant &value) override {
|
||||||
QObject::setProperty(name, value);}
|
QObject::setProperty(name, value);}
|
||||||
QVariant property (const char *name) const override {
|
QVariant property (const char *name) const override {
|
||||||
return QObject::property(name);}
|
return QObject::property(name);}
|
||||||
|
|
||||||
virtual QPainterPath shadowShape ()const = 0;
|
virtual QPainterPath shadowShape ()const = 0;
|
||||||
virtual void setHandlerColor(QPointF /*pos*/,
|
virtual void setHandlerColor(QPointF /*pos*/,
|
||||||
const QColor &/*color*/) {}
|
const QColor &/*color*/) {}
|
||||||
virtual void resetAllHandlerColor() {}
|
virtual void resetAllHandlerColor() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void stylesToXml (QDomDocument &xml_document, QDomElement &) const;
|
void stylesToXml (QDomDocument &xml_document, QDomElement &) const;
|
||||||
void stylesFromXml(const QDomElement &);
|
void stylesFromXml(const QDomElement &);
|
||||||
void resetStyles ();
|
void resetStyles ();
|
||||||
void applyStylesToQPainter(QPainter &) const;
|
void applyStylesToQPainter(QPainter &) const;
|
||||||
void drawShadowShape (QPainter *painter);
|
void drawShadowShape (QPainter *painter);
|
||||||
|
|
||||||
QVariant itemChange(GraphicsItemChange change,
|
QVariant itemChange(GraphicsItemChange change,
|
||||||
const QVariant &value) override;
|
const QVariant &value) override;
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseReleaseEvent(
|
void mouseReleaseEvent(
|
||||||
QGraphicsSceneMouseEvent *event) override;
|
QGraphicsSceneMouseEvent *event) override;
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
bool m_hovered;
|
bool m_hovered;
|
||||||
private:
|
private:
|
||||||
LineStyle _linestyle;
|
LineStyle _linestyle;
|
||||||
LineWeight _lineweight;
|
LineWeight _lineweight;
|
||||||
Filling _filling ;
|
Filling _filling ;
|
||||||
Color _color;
|
Color _color;
|
||||||
bool _antialiased;
|
bool _antialiased;
|
||||||
QPointF m_origin_pos;
|
QPointF m_origin_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef CustomElementGraphicPart CEGP;
|
typedef CustomElementGraphicPart CEGP;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef CUSTOM_ELEMENT_PART_H
|
#ifndef CUSTOM_ELEMENT_PART_H
|
||||||
#define CUSTOM_ELEMENT_PART_H
|
#define CUSTOM_ELEMENT_PART_H
|
||||||
@@ -30,86 +30,86 @@ class QGraphicsItem;
|
|||||||
class QGraphicsSceneMouseEvent;
|
class QGraphicsSceneMouseEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The CustomElementPart class
|
@brief The CustomElementPart class
|
||||||
This abstract class represents a primitive of
|
This abstract class represents a primitive of
|
||||||
the visual representation of an electrical element.
|
the visual representation of an electrical element.
|
||||||
The Element, FixedElement and CustomElement classes do not embed
|
The Element, FixedElement and CustomElement classes do not embed
|
||||||
its attributes and methods in order to remain lightweight; indeed,
|
its attributes and methods in order to remain lightweight; indeed,
|
||||||
there is no point for those classes to store their visual representation
|
there is no point for those classes to store their visual representation
|
||||||
with anything more complex than a QImage.
|
with anything more complex than a QImage.
|
||||||
*/
|
*/
|
||||||
class CustomElementPart: public PropertiesInterface {
|
class CustomElementPart: public PropertiesInterface {
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@brief CustomElementPart
|
@brief CustomElementPart
|
||||||
Constructor
|
Constructor
|
||||||
@param editor Element editor this primitive is attached to
|
@param editor Element editor this primitive is attached to
|
||||||
*/
|
*/
|
||||||
CustomElementPart(QETElementEditor *editor) : element_editor(editor) {}
|
CustomElementPart(QETElementEditor *editor) : element_editor(editor) {}
|
||||||
/**
|
/**
|
||||||
@brief ~CustomElementPart
|
@brief ~CustomElementPart
|
||||||
Destructor
|
Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~CustomElementPart() {}
|
virtual ~CustomElementPart() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CustomElementPart(const CustomElementPart &);
|
CustomElementPart(const CustomElementPart &);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
QETElementEditor *element_editor;
|
QETElementEditor *element_editor;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
Set a specific property of the primitive
|
Set a specific property of the primitive
|
||||||
*/
|
*/
|
||||||
virtual void setProperty(const char *name, const QVariant &value) = 0;
|
virtual void setProperty(const char *name, const QVariant &value) = 0;
|
||||||
/**
|
/**
|
||||||
Get the current value of a specific primitive property
|
Get the current value of a specific primitive property
|
||||||
*/
|
*/
|
||||||
virtual QVariant property(const char *name) const = 0;
|
virtual QVariant property(const char *name) const = 0;
|
||||||
/**
|
/**
|
||||||
@return whether the primitive appears to be useless (e.g. 0-length line)
|
@return whether the primitive appears to be useless (e.g. 0-length line)
|
||||||
Typically, useless primitives are discarded when saving the element.
|
Typically, useless primitives are discarded when saving the element.
|
||||||
*/
|
*/
|
||||||
virtual bool isUseless() const = 0;
|
virtual bool isUseless() const = 0;
|
||||||
virtual QRectF sceneGeometricRect() const = 0;
|
virtual QRectF sceneGeometricRect() const = 0;
|
||||||
/**
|
/**
|
||||||
Inform this part a user-induced transformation is about to begin.
|
Inform this part a user-induced transformation is about to begin.
|
||||||
This method can be used to save data required by handleUserTransformation().
|
This method can be used to save data required by handleUserTransformation().
|
||||||
*/
|
*/
|
||||||
virtual void startUserTransformation(const QRectF &) = 0;
|
virtual void startUserTransformation(const QRectF &) = 0;
|
||||||
/**
|
/**
|
||||||
Make this part fit into the provided rectangle.
|
Make this part fit into the provided rectangle.
|
||||||
*/
|
*/
|
||||||
virtual void handleUserTransformation(const QRectF &,
|
virtual void handleUserTransformation(const QRectF &,
|
||||||
const QRectF &) = 0;
|
const QRectF &) = 0;
|
||||||
/// @return a pointer to the parent element editor
|
/// @return a pointer to the parent element editor
|
||||||
virtual QETElementEditor *elementEditor() const;
|
virtual QETElementEditor *elementEditor() const;
|
||||||
/**
|
/**
|
||||||
Call the updateCurrentPartEditor() slot of the editor
|
Call the updateCurrentPartEditor() slot of the editor
|
||||||
@see QETElementEditor::updateCurrentPartEditor()
|
@see QETElementEditor::updateCurrentPartEditor()
|
||||||
*/
|
*/
|
||||||
virtual void updateCurrentPartEditor() const;
|
virtual void updateCurrentPartEditor() const;
|
||||||
/// @return a pointer to the parent editing scene
|
/// @return a pointer to the parent editing scene
|
||||||
virtual ElementScene *elementScene() const;
|
virtual ElementScene *elementScene() const;
|
||||||
/// @return the element editor undo stack
|
/// @return the element editor undo stack
|
||||||
virtual QUndoStack &undoStack() const;
|
virtual QUndoStack &undoStack() const;
|
||||||
/// @return the name of the primitive
|
/// @return the name of the primitive
|
||||||
virtual QString name() const = 0;
|
virtual QString name() const = 0;
|
||||||
/// @return the name that will be used as XML tag when exporting the primitive
|
/// @return the name that will be used as XML tag when exporting the primitive
|
||||||
virtual QString xmlName() const = 0;
|
virtual QString xmlName() const = 0;
|
||||||
|
|
||||||
virtual QGraphicsItem *toItem();
|
virtual QGraphicsItem *toItem();
|
||||||
|
|
||||||
virtual QET::ScalingMethod preferredScalingMethod() const;
|
virtual QET::ScalingMethod preferredScalingMethod() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QList<QPointF> mapPoints(
|
QList<QPointF> mapPoints(
|
||||||
const QRectF &,
|
const QRectF &,
|
||||||
const QRectF &,
|
const QRectF &,
|
||||||
const QList<QPointF> &);
|
const QList<QPointF> &);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "partarc.h"
|
#include "partarc.h"
|
||||||
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||||
@@ -23,173 +23,173 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::PartArc
|
@brief PartArc::PartArc
|
||||||
Constructor
|
Constructor
|
||||||
@param editor : QETElementEditor of this part
|
@param editor : QETElementEditor of this part
|
||||||
@param parent : parent item
|
@param parent : parent item
|
||||||
*/
|
*/
|
||||||
PartArc::PartArc(QETElementEditor *editor, QGraphicsItem *parent) :
|
PartArc::PartArc(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||||
AbstractPartEllipse(editor, parent)
|
AbstractPartEllipse(editor, parent)
|
||||||
{
|
{
|
||||||
m_start_angle = 0;
|
m_start_angle = 0;
|
||||||
m_span_angle = -1440;
|
m_span_angle = -1440;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::~PartArc
|
@brief PartArc::~PartArc
|
||||||
Destructor
|
Destructor
|
||||||
*/
|
*/
|
||||||
PartArc::~PartArc()
|
PartArc::~PartArc()
|
||||||
{
|
{
|
||||||
if(m_undo_command) delete m_undo_command;
|
if(m_undo_command) delete m_undo_command;
|
||||||
removeHandler();
|
removeHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::paint
|
@brief PartArc::paint
|
||||||
Draw this arc
|
Draw this arc
|
||||||
@param painter
|
@param painter
|
||||||
@param options
|
@param options
|
||||||
@param widget
|
@param widget
|
||||||
*/
|
*/
|
||||||
void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *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
|
//Always remove the brush
|
||||||
painter -> setBrush(Qt::NoBrush);
|
painter -> setBrush(Qt::NoBrush);
|
||||||
QPen t = painter -> pen();
|
QPen t = painter -> pen();
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
||||||
#else
|
#else
|
||||||
#if TODO_LIST
|
#if TODO_LIST
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
#pragma message("@TODO remove code for QT 6 or later")
|
||||||
#endif
|
#endif
|
||||||
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
|
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
|
||||||
#endif
|
#endif
|
||||||
painter -> setPen(t);
|
painter -> setPen(t);
|
||||||
|
|
||||||
if (isSelected())
|
if (isSelected())
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
QPen pen(Qt::DotLine);
|
QPen pen(Qt::DotLine);
|
||||||
pen.setWidth(1);
|
pen.setWidth(1);
|
||||||
pen.setCosmetic(true);
|
pen.setCosmetic(true);
|
||||||
painter->setPen(pen);
|
painter->setPen(pen);
|
||||||
//Draw the ellipse in black
|
//Draw the ellipse in black
|
||||||
painter -> drawEllipse(rect());
|
painter -> drawEllipse(rect());
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
|
||||||
//Draw the arc in red
|
//Draw the arc in red
|
||||||
t.setColor(Qt::red);
|
t.setColor(Qt::red);
|
||||||
painter -> setPen(t);
|
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)
|
if (m_hovered)
|
||||||
drawShadowShape(painter);
|
drawShadowShape(painter);
|
||||||
|
|
||||||
if (isSelected())
|
if (isSelected())
|
||||||
drawCross(m_rect.center(), painter);
|
drawCross(m_rect.center(), painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::toXml
|
@brief PartArc::toXml
|
||||||
Export this arc in xml
|
Export this arc in xml
|
||||||
@param xml_document : Xml document to use for create the xml element.
|
@param xml_document : Xml document to use for create the xml element.
|
||||||
@return : an xml element that describe this arc
|
@return : an xml element that describe this arc
|
||||||
*/
|
*/
|
||||||
QDomElement PartArc::toXml(QDomDocument &xml_document) const {
|
QDomElement PartArc::toXml(QDomDocument &xml_document) const {
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement("arc");
|
QDomElement xml_element = xml_document.createElement("arc");
|
||||||
QPointF top_left(sceneTopLeft());
|
QPointF top_left(sceneTopLeft());
|
||||||
|
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "x", top_left.x()));
|
xml_element.appendChild(createXmlProperty(xml_document, "x", top_left.x()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "y", top_left.y()));
|
xml_element.appendChild(createXmlProperty(xml_document, "y", top_left.y()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "width", rect().width()));
|
xml_element.appendChild(createXmlProperty(xml_document, "width", rect().width()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "height", rect().height()));
|
xml_element.appendChild(createXmlProperty(xml_document, "height", rect().height()));
|
||||||
|
|
||||||
//to maintain compatibility with the previous version, we write the angle in degrees.
|
//to maintain compatibility with the previous version, we write the angle in degrees.
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "start", m_start_angle / 16));
|
xml_element.appendChild(createXmlProperty(xml_document, "start", m_start_angle / 16));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "angle", m_span_angle / 16));
|
xml_element.appendChild(createXmlProperty(xml_document, "angle", m_span_angle / 16));
|
||||||
|
|
||||||
|
|
||||||
stylesToXml(xml_document, xml_element);
|
stylesToXml(xml_document, xml_element);
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::fromXml
|
@brief PartArc::fromXml
|
||||||
Import the properties of this arc from a xml element.
|
Import the properties of this arc from a xml element.
|
||||||
@param qde : Xml document to use.
|
@param qde : Xml document to use.
|
||||||
*/
|
*/
|
||||||
bool PartArc::fromXml(const QDomElement &qde) {
|
bool PartArc::fromXml(const QDomElement &qde) {
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
|
|
||||||
double x=0, y=0, w=0, h=0;
|
double x=0, y=0, w=0, h=0;
|
||||||
if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion ||
|
propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion ||
|
propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "height", &h) == PropertyFlags::NoValidConversion)
|
propertyDouble(qde, "height", &h) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_rect = QRectF(mapFromScene(x, y), QSizeF(w, h) );
|
m_rect = QRectF(mapFromScene(x, y), QSizeF(w, h) );
|
||||||
|
|
||||||
m_start_angle = 0;
|
m_start_angle = 0;
|
||||||
if (propertyDouble(qde, "start", &m_start_angle) == PropertyFlags::NoValidConversion)
|
if (propertyDouble(qde, "start", &m_start_angle) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
m_start_angle *= 16;
|
m_start_angle *= 16;
|
||||||
|
|
||||||
m_span_angle = -1440;
|
m_span_angle = -1440;
|
||||||
if (propertyDouble(qde, "angle", &m_span_angle) == PropertyFlags::NoValidConversion)
|
if (propertyDouble(qde, "angle", &m_span_angle) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
m_span_angle *= 16;
|
m_span_angle *= 16;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PartArc::valideXml(QDomElement& element) {
|
bool PartArc::valideXml(QDomElement& element) {
|
||||||
|
|
||||||
if (propertyDouble(element, "x") == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(element, "x") == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(element, "y") == PropertyFlags::NoValidConversion ||
|
propertyDouble(element, "y") == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(element, "width") == PropertyFlags::NoValidConversion ||
|
propertyDouble(element, "width") == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(element, "height") == PropertyFlags::NoValidConversion ||
|
propertyDouble(element, "height") == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(element, "start") == PropertyFlags::NoValidConversion ||
|
propertyDouble(element, "start") == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(element, "angle") == PropertyFlags::NoValidConversion)
|
propertyDouble(element, "angle") == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::shape
|
@brief PartArc::shape
|
||||||
@return the shape of this item
|
@return the shape of this item
|
||||||
*/
|
*/
|
||||||
QPainterPath PartArc::shape() const
|
QPainterPath PartArc::shape() const
|
||||||
{
|
{
|
||||||
QPainterPath shape;
|
QPainterPath shape;
|
||||||
shape.arcMoveTo(m_rect, m_start_angle/16);
|
shape.arcMoveTo(m_rect, m_start_angle/16);
|
||||||
shape.arcTo(m_rect, m_start_angle /16, m_span_angle /16);
|
shape.arcTo(m_rect, m_start_angle /16, m_span_angle /16);
|
||||||
|
|
||||||
QPainterPathStroker pps;
|
QPainterPathStroker pps;
|
||||||
pps.setWidth(m_hovered? penWeight()+SHADOWS_HEIGHT : penWeight());
|
pps.setWidth(m_hovered? penWeight()+SHADOWS_HEIGHT : penWeight());
|
||||||
shape = pps.createStroke(shape);
|
shape = pps.createStroke(shape);
|
||||||
|
|
||||||
return shape;
|
return shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainterPath PartArc::shadowShape() const
|
QPainterPath PartArc::shadowShape() const
|
||||||
{
|
{
|
||||||
QPainterPath shape;
|
QPainterPath shape;
|
||||||
shape.arcMoveTo(m_rect, m_start_angle/16);
|
shape.arcMoveTo(m_rect, m_start_angle/16);
|
||||||
shape.arcTo(m_rect, m_start_angle /16, m_span_angle /16);
|
shape.arcTo(m_rect, m_start_angle /16, m_span_angle /16);
|
||||||
|
|
||||||
QPainterPathStroker pps;
|
QPainterPathStroker pps;
|
||||||
pps.setWidth(penWeight());
|
pps.setWidth(penWeight());
|
||||||
|
|
||||||
return (pps.createStroke(shape));
|
return (pps.createStroke(shape));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -203,327 +203,327 @@ QPainterPath PartArc::shadowShape() const
|
|||||||
*/
|
*/
|
||||||
QRectF PartArc::sceneGeometricRect() 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
|
@brief PartArc::mouseReleaseEvent
|
||||||
Handle mouse release event
|
Handle mouse release event
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void PartArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void PartArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && event->buttonDownPos(Qt::LeftButton) == event->pos())
|
if (event->button() == Qt::LeftButton && event->buttonDownPos(Qt::LeftButton) == event->pos())
|
||||||
switchResizeMode();
|
switchResizeMode();
|
||||||
|
|
||||||
CustomElementGraphicPart::mouseReleaseEvent(event);
|
CustomElementGraphicPart::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::itemChange
|
@brief PartArc::itemChange
|
||||||
@param change
|
@param change
|
||||||
@param value
|
@param value
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
QVariant PartArc::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
QVariant PartArc::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||||
{
|
{
|
||||||
if (change == ItemSelectedHasChanged && scene())
|
if (change == ItemSelectedHasChanged && scene())
|
||||||
{
|
{
|
||||||
if (value.toBool() == true)
|
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,
|
//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.
|
//according to the number of selected items.
|
||||||
connect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged);
|
connect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged);
|
||||||
|
|
||||||
if (scene()->selectedItems().size() == 1)
|
if (scene()->selectedItems().size() == 1)
|
||||||
addHandler();
|
addHandler();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged);
|
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged);
|
||||||
removeHandler();
|
removeHandler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (change == ItemPositionHasChanged)
|
else if (change == ItemPositionHasChanged)
|
||||||
{
|
{
|
||||||
adjusteHandlerPos();
|
adjusteHandlerPos();
|
||||||
}
|
}
|
||||||
else if (change == ItemSceneChange)
|
else if (change == ItemSceneChange)
|
||||||
{
|
{
|
||||||
if(scene())
|
if(scene())
|
||||||
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartArc::sceneSelectionChanged);
|
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
|
@brief PartArc::sceneEventFilter
|
||||||
@param watched
|
@param watched
|
||||||
@param event
|
@param event
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
bool PartArc::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
bool PartArc::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
//Watched must be an handler
|
//Watched must be an handler
|
||||||
if(watched->type() == QetGraphicsHandlerItem::Type)
|
if(watched->type() == QetGraphicsHandlerItem::Type)
|
||||||
{
|
{
|
||||||
QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched);
|
QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched);
|
||||||
|
|
||||||
if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
|
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);
|
m_vector_index = m_handler_vector.indexOf(qghi);
|
||||||
if (m_vector_index != -1)
|
if (m_vector_index != -1)
|
||||||
{
|
{
|
||||||
if(event->type() == QEvent::GraphicsSceneMousePress) //Click
|
if(event->type() == QEvent::GraphicsSceneMousePress) //Click
|
||||||
{
|
{
|
||||||
handlerMousePressEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
handlerMousePressEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(event->type() == QEvent::GraphicsSceneMouseMove) //Move
|
else if(event->type() == QEvent::GraphicsSceneMouseMove) //Move
|
||||||
{
|
{
|
||||||
handlerMouseMoveEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
handlerMouseMoveEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (event->type() == QEvent::GraphicsSceneMouseRelease) //Release
|
else if (event->type() == QEvent::GraphicsSceneMouseRelease) //Release
|
||||||
{
|
{
|
||||||
handlerMouseReleaseEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
handlerMouseReleaseEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::switchResizeMode
|
@brief PartArc::switchResizeMode
|
||||||
*/
|
*/
|
||||||
void PartArc::switchResizeMode()
|
void PartArc::switchResizeMode()
|
||||||
{
|
{
|
||||||
if (m_resize_mode == 1)
|
if (m_resize_mode == 1)
|
||||||
{
|
{
|
||||||
m_resize_mode = 2;
|
m_resize_mode = 2;
|
||||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||||
qghi->setColor(Qt::darkGreen);
|
qghi->setColor(Qt::darkGreen);
|
||||||
}
|
}
|
||||||
else if (m_resize_mode == 2)
|
else if (m_resize_mode == 2)
|
||||||
{
|
{
|
||||||
m_resize_mode = 3;
|
m_resize_mode = 3;
|
||||||
|
|
||||||
//From rect mode to angle mode, then numbers of handlers change
|
//From rect mode to angle mode, then numbers of handlers change
|
||||||
removeHandler();
|
removeHandler();
|
||||||
addHandler();
|
addHandler();
|
||||||
|
|
||||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||||
qghi->setColor(Qt::magenta);
|
qghi->setColor(Qt::magenta);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_resize_mode = 1;
|
m_resize_mode = 1;
|
||||||
|
|
||||||
//From angle mode to rect mode, then numbers of handlers change
|
//From angle mode to rect mode, then numbers of handlers change
|
||||||
removeHandler();
|
removeHandler();
|
||||||
addHandler();
|
addHandler();
|
||||||
|
|
||||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||||
qghi->setColor(Qt::blue);
|
qghi->setColor(Qt::blue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::adjusteHandlerPos
|
@brief PartArc::adjusteHandlerPos
|
||||||
*/
|
*/
|
||||||
void PartArc::adjusteHandlerPos()
|
void PartArc::adjusteHandlerPos()
|
||||||
{
|
{
|
||||||
if (m_handler_vector.isEmpty())
|
if (m_handler_vector.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QVector <QPointF> points_vector;
|
QVector <QPointF> points_vector;
|
||||||
|
|
||||||
if(m_resize_mode == 3)
|
if(m_resize_mode == 3)
|
||||||
points_vector = QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16);
|
points_vector = QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16);
|
||||||
else
|
else
|
||||||
points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect);
|
points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect);
|
||||||
|
|
||||||
|
|
||||||
if (m_handler_vector.size() == points_vector.size())
|
if (m_handler_vector.size() == points_vector.size())
|
||||||
{
|
{
|
||||||
points_vector = mapToScene(points_vector);
|
points_vector = mapToScene(points_vector);
|
||||||
for (int i = 0 ; i < points_vector.size() ; ++i)
|
for (int i = 0 ; i < points_vector.size() ; ++i)
|
||||||
m_handler_vector.at(i)->setPos(points_vector.at(i));
|
m_handler_vector.at(i)->setPos(points_vector.at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::handlerMousePressEvent
|
@brief PartArc::handlerMousePressEvent
|
||||||
@param qghi
|
@param qghi
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void PartArc::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
void PartArc::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(qghi)
|
Q_UNUSED(qghi)
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
|
|
||||||
if (m_resize_mode == 3) //Resize angle
|
if (m_resize_mode == 3) //Resize angle
|
||||||
{
|
{
|
||||||
if (m_vector_index == 0)
|
if (m_vector_index == 0)
|
||||||
{
|
{
|
||||||
m_span_point = QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16).at(1);
|
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 = new QPropertyUndoCommand(this, "startAngle", QVariant(m_start_angle));
|
||||||
m_undo_command->setText(tr("Modifier un arc"));
|
m_undo_command->setText(tr("Modifier un arc"));
|
||||||
m_undo_command->enableAnimation();
|
m_undo_command->enableAnimation();
|
||||||
|
|
||||||
m_undo_command2 = new QPropertyUndoCommand(this, "spanAngle", QVariant(m_span_angle), m_undo_command);
|
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->setText(tr("Modifier un arc"));
|
||||||
m_undo_command2->enableAnimation();
|
m_undo_command2->enableAnimation();
|
||||||
}
|
}
|
||||||
else if (m_vector_index == 1)
|
else if (m_vector_index == 1)
|
||||||
{
|
{
|
||||||
m_undo_command = new QPropertyUndoCommand(this, "spanAngle", QVariant(m_span_angle));
|
m_undo_command = new QPropertyUndoCommand(this, "spanAngle", QVariant(m_span_angle));
|
||||||
m_undo_command->setText(tr("Modifier un arc"));
|
m_undo_command->setText(tr("Modifier un arc"));
|
||||||
m_undo_command->enableAnimation();
|
m_undo_command->enableAnimation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else //resize rect
|
else //resize rect
|
||||||
{
|
{
|
||||||
m_undo_command = new QPropertyUndoCommand(this, "rect", QVariant(m_rect));
|
m_undo_command = new QPropertyUndoCommand(this, "rect", QVariant(m_rect));
|
||||||
m_undo_command->setText(tr("Modifier un arc"));
|
m_undo_command->setText(tr("Modifier un arc"));
|
||||||
m_undo_command->enableAnimation();
|
m_undo_command->enableAnimation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::handlerMouseMoveEvent
|
@brief PartArc::handlerMouseMoveEvent
|
||||||
@param qghi
|
@param qghi
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void PartArc::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
void PartArc::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(qghi)
|
Q_UNUSED(qghi)
|
||||||
|
|
||||||
QPointF new_pos = event->scenePos();
|
QPointF new_pos = event->scenePos();
|
||||||
if (event->modifiers() != Qt::ControlModifier)
|
if (event->modifiers() != Qt::ControlModifier)
|
||||||
new_pos = elementScene()->snapToGrid(event->scenePos());
|
new_pos = elementScene()->snapToGrid(event->scenePos());
|
||||||
new_pos = mapFromScene(new_pos);
|
new_pos = mapFromScene(new_pos);
|
||||||
|
|
||||||
if (m_resize_mode == 1)
|
if (m_resize_mode == 1)
|
||||||
setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index));
|
setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index));
|
||||||
else if (m_resize_mode == 2)
|
else if (m_resize_mode == 2)
|
||||||
setRect(QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(m_rect, new_pos, m_vector_index));
|
setRect(QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(m_rect, new_pos, m_vector_index));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QLineF line(m_rect.center(), mapFromScene(event->scenePos()));
|
QLineF line(m_rect.center(), mapFromScene(event->scenePos()));
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
if (m_vector_index == 0) {
|
if (m_vector_index == 0) {
|
||||||
setStartAngle(line.angle()*16);
|
setStartAngle(line.angle()*16);
|
||||||
setSpanAngle(line.angleTo(QLineF(m_rect.center(), m_span_point))*16);
|
setSpanAngle(line.angleTo(QLineF(m_rect.center(), m_span_point))*16);
|
||||||
}
|
}
|
||||||
else if (m_vector_index == 1) {
|
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));
|
QLineF line2(m_rect.center(), QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16).at(0));
|
||||||
setSpanAngle (line2.angleTo(line)*16);
|
setSpanAngle (line2.angleTo(line)*16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::handlerMouseReleaseEvent
|
@brief PartArc::handlerMouseReleaseEvent
|
||||||
@param qghi
|
@param qghi
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void PartArc::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
void PartArc::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(qghi)
|
Q_UNUSED(qghi)
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
|
|
||||||
if (m_resize_mode == 3)
|
if (m_resize_mode == 3)
|
||||||
{
|
{
|
||||||
if (m_vector_index == 0)
|
if (m_vector_index == 0)
|
||||||
{
|
{
|
||||||
m_undo_command->setNewValue(QVariant(m_start_angle));
|
m_undo_command->setNewValue(QVariant(m_start_angle));
|
||||||
m_undo_command2->setNewValue(QVariant(m_span_angle));
|
m_undo_command2->setNewValue(QVariant(m_span_angle));
|
||||||
elementScene()->undoStack().push(m_undo_command);
|
elementScene()->undoStack().push(m_undo_command);
|
||||||
m_undo_command = nullptr;
|
m_undo_command = nullptr;
|
||||||
m_undo_command2 = nullptr;
|
m_undo_command2 = nullptr;
|
||||||
m_vector_index = -1;
|
m_vector_index = -1;
|
||||||
}
|
}
|
||||||
else if (m_vector_index == 1)
|
else if (m_vector_index == 1)
|
||||||
{
|
{
|
||||||
m_undo_command->setNewValue(QVariant(m_span_angle));
|
m_undo_command->setNewValue(QVariant(m_span_angle));
|
||||||
elementScene()->undoStack().push(m_undo_command);
|
elementScene()->undoStack().push(m_undo_command);
|
||||||
m_undo_command = nullptr;
|
m_undo_command = nullptr;
|
||||||
m_vector_index = -1;
|
m_vector_index = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!m_rect.isValid())
|
if (!m_rect.isValid())
|
||||||
m_rect = m_rect.normalized();
|
m_rect = m_rect.normalized();
|
||||||
|
|
||||||
m_undo_command->setNewValue(QVariant(m_rect));
|
m_undo_command->setNewValue(QVariant(m_rect));
|
||||||
elementScene()->undoStack().push(m_undo_command);
|
elementScene()->undoStack().push(m_undo_command);
|
||||||
m_undo_command = nullptr;
|
m_undo_command = nullptr;
|
||||||
m_vector_index = -1;
|
m_vector_index = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::sceneSelectionChanged
|
@brief PartArc::sceneSelectionChanged
|
||||||
When the scene selection change, if there are several primitive selected, we remove the handler of this item
|
When the scene selection change, if there are several primitive selected, we remove the handler of this item
|
||||||
*/
|
*/
|
||||||
void PartArc::sceneSelectionChanged()
|
void PartArc::sceneSelectionChanged()
|
||||||
{
|
{
|
||||||
if (this->isSelected() && scene()->selectedItems().size() == 1)
|
if (this->isSelected() && scene()->selectedItems().size() == 1)
|
||||||
addHandler();
|
addHandler();
|
||||||
else
|
else
|
||||||
removeHandler();
|
removeHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::addHandler
|
@brief PartArc::addHandler
|
||||||
Add handlers for this item
|
Add handlers for this item
|
||||||
*/
|
*/
|
||||||
void PartArc::addHandler()
|
void PartArc::addHandler()
|
||||||
{
|
{
|
||||||
if (m_handler_vector.isEmpty() && scene())
|
if (m_handler_vector.isEmpty() && scene())
|
||||||
{
|
{
|
||||||
if(m_resize_mode == 3)
|
if(m_resize_mode == 3)
|
||||||
{
|
{
|
||||||
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16)));
|
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForArc(m_rect, m_start_angle/16, m_span_angle/16)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
|
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
|
||||||
|
|
||||||
for(QetGraphicsHandlerItem *handler : m_handler_vector)
|
for(QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||||
{
|
{
|
||||||
QColor color = Qt::blue;
|
QColor color = Qt::blue;
|
||||||
if (m_resize_mode == 2)
|
if (m_resize_mode == 2)
|
||||||
color = Qt::darkGreen;
|
color = Qt::darkGreen;
|
||||||
else if (m_resize_mode == 3)
|
else if (m_resize_mode == 3)
|
||||||
color = Qt::magenta;
|
color = Qt::magenta;
|
||||||
|
|
||||||
handler->setColor(color);
|
handler->setColor(color);
|
||||||
scene()->addItem(handler);
|
scene()->addItem(handler);
|
||||||
handler->installSceneEventFilter(this);
|
handler->installSceneEventFilter(this);
|
||||||
handler->setZValue(this->zValue()+1);
|
handler->setZValue(this->zValue()+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartArc::removeHandler
|
@brief PartArc::removeHandler
|
||||||
Remove the handlers of this item
|
Remove the handlers of this item
|
||||||
*/
|
*/
|
||||||
void PartArc::removeHandler()
|
void PartArc::removeHandler()
|
||||||
{
|
{
|
||||||
if (!m_handler_vector.isEmpty())
|
if (!m_handler_vector.isEmpty())
|
||||||
{
|
{
|
||||||
qDeleteAll(m_handler_vector);
|
qDeleteAll(m_handler_vector);
|
||||||
m_handler_vector.clear();
|
m_handler_vector.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef PART_ARC_H
|
#ifndef PART_ARC_H
|
||||||
#define PART_ARC_H
|
#define PART_ARC_H
|
||||||
@@ -24,66 +24,66 @@ class QPropertyUndoCommand;
|
|||||||
class QetGraphicsHandlerItem;
|
class QetGraphicsHandlerItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The PartArc class
|
@brief The PartArc class
|
||||||
This class represents an elliptical arc primitive which may be used to
|
This class represents an elliptical arc primitive which may be used to
|
||||||
compose the drawing of an electrical element within the element editor.
|
compose the drawing of an electrical element within the element editor.
|
||||||
*/
|
*/
|
||||||
class PartArc : public AbstractPartEllipse
|
class PartArc : public AbstractPartEllipse
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PartArc(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
|
PartArc(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
|
||||||
~PartArc() override;
|
~PartArc() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PartArc(const PartArc &);
|
PartArc(const PartArc &);
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1101 };
|
enum { Type = UserType + 1101 };
|
||||||
/**
|
/**
|
||||||
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartArc.
|
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartArc.
|
||||||
@return the QGraphicsItem type
|
@return the QGraphicsItem type
|
||||||
*/
|
*/
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||||
|
|
||||||
//Name and XML
|
//Name and XML
|
||||||
QString name() const override { return(QObject::tr("arc", "element part name")); }
|
QString name() const override { return(QObject::tr("arc", "element part name")); }
|
||||||
QString xmlName() const override { return(QString("arc")); }
|
QString xmlName() const override { return(QString("arc")); }
|
||||||
QDomElement toXml (QDomDocument &) const override;
|
QDomElement toXml (QDomDocument &) const override;
|
||||||
bool fromXml (const QDomElement &) override;
|
bool fromXml (const QDomElement &) override;
|
||||||
static bool valideXml(QDomElement& element);
|
static bool valideXml(QDomElement& element);
|
||||||
|
|
||||||
QPainterPath shape() const override;
|
QPainterPath shape() const override;
|
||||||
QPainterPath shadowShape() const override;
|
QPainterPath shadowShape() const override;
|
||||||
void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
|
void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
|
||||||
void setStartAngle(const int &start_angle) override {AbstractPartEllipse::setStartAngle(start_angle); 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();}
|
void setSpanAngle(const int &span_angle) override {AbstractPartEllipse::setSpanAngle(span_angle); adjusteHandlerPos();}
|
||||||
QRectF sceneGeometricRect() const override;
|
QRectF sceneGeometricRect() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void switchResizeMode();
|
void switchResizeMode();
|
||||||
void adjusteHandlerPos();
|
void adjusteHandlerPos();
|
||||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void sceneSelectionChanged ();
|
void sceneSelectionChanged ();
|
||||||
|
|
||||||
void addHandler();
|
void addHandler();
|
||||||
void removeHandler();
|
void removeHandler();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPropertyUndoCommand *m_undo_command = nullptr;
|
QPropertyUndoCommand *m_undo_command = nullptr;
|
||||||
QPropertyUndoCommand *m_undo_command2 = nullptr;
|
QPropertyUndoCommand *m_undo_command2 = nullptr;
|
||||||
int m_resize_mode = 1,
|
int m_resize_mode = 1,
|
||||||
m_vector_index = -1;
|
m_vector_index = -1;
|
||||||
QPointF m_span_point;
|
QPointF m_span_point;
|
||||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef PARTDYNAMICTEXTFIELD_H
|
#ifndef PARTDYNAMICTEXTFIELD_H
|
||||||
#define PARTDYNAMICTEXTFIELD_H
|
#define PARTDYNAMICTEXTFIELD_H
|
||||||
@@ -23,107 +23,107 @@
|
|||||||
#include "dynamicelementtextitem.h"
|
#include "dynamicelementtextitem.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The PartDynamicTextField class
|
@brief The PartDynamicTextField class
|
||||||
This class represents an editable dynamic text field
|
This class represents an editable dynamic text field
|
||||||
which may be used to compose the
|
which may be used to compose the
|
||||||
drawing of an electrical element within the element editor.
|
drawing of an electrical element within the element editor.
|
||||||
The field will remain editable once the element is added onto
|
The field will remain editable once the element is added onto
|
||||||
a diagram
|
a diagram
|
||||||
*/
|
*/
|
||||||
class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
||||||
Q_PROPERTY(DynamicElementTextItem::TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
|
Q_PROPERTY(DynamicElementTextItem::TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
|
||||||
Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
|
Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
|
||||||
Q_PROPERTY(QString compositeText READ compositeText WRITE setCompositeText NOTIFY compositeTextChanged)
|
Q_PROPERTY(QString compositeText READ compositeText WRITE setCompositeText NOTIFY compositeTextChanged)
|
||||||
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
||||||
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
|
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
|
||||||
Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
|
Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
|
||||||
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
||||||
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
|
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
///PROPERTY
|
///PROPERTY
|
||||||
void setProperty(const char *name, const QVariant &value) override {QGraphicsTextItem::setProperty(name, value);}
|
void setProperty(const char *name, const QVariant &value) override {QGraphicsTextItem::setProperty(name, value);}
|
||||||
QVariant property(const char *name) const override {return QGraphicsTextItem::property(name);}
|
QVariant property(const char *name) const override {return QGraphicsTextItem::property(name);}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void taggChanged(QString tagg);
|
void taggChanged(QString tagg);
|
||||||
void textChanged(QString text);
|
void textChanged(QString text);
|
||||||
void textFromChanged(DynamicElementTextItem::TextFrom text_from);
|
void textFromChanged(DynamicElementTextItem::TextFrom text_from);
|
||||||
void infoNameChanged(QString info);
|
void infoNameChanged(QString info);
|
||||||
void compositeTextChanged(QString text);
|
void compositeTextChanged(QString text);
|
||||||
void colorChanged(QColor color);
|
void colorChanged(QColor color);
|
||||||
void frameChanged(bool frame);
|
void frameChanged(bool frame);
|
||||||
void textWidthChanged(qreal width);
|
void textWidthChanged(qreal width);
|
||||||
void alignmentChanged(Qt::Alignment alignment);
|
void alignmentChanged(Qt::Alignment alignment);
|
||||||
void fontChanged(QFont font);
|
void fontChanged(QFont font);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PartDynamicTextField(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
|
PartDynamicTextField(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
|
||||||
|
|
||||||
enum {Type = UserType + 1110};
|
enum {Type = UserType + 1110};
|
||||||
int type() const override {return Type;}
|
int type() const override {return Type;}
|
||||||
|
|
||||||
QString name() const override;
|
QString name() const override;
|
||||||
QString xmlName() const override;
|
QString xmlName() const override;
|
||||||
static QString xmlTaggName() {return QString("dynamic_text");}
|
static QString xmlTaggName() {return QString("dynamic_text");}
|
||||||
bool isUseless() const override {return false;}
|
bool isUseless() const override {return false;}
|
||||||
QRectF sceneGeometricRect() const override {return sceneBoundingRect();}
|
QRectF sceneGeometricRect() const override {return sceneBoundingRect();}
|
||||||
void startUserTransformation(const QRectF &initial_selection_rect) override;
|
void startUserTransformation(const QRectF &initial_selection_rect) override;
|
||||||
void handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) override;
|
void handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) override;
|
||||||
|
|
||||||
QDomElement toXml(QDomDocument &dom_doc) const override;
|
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||||
bool fromXml(const QDomElement &dom_elmt) override;
|
bool fromXml(const QDomElement &dom_elmt) override;
|
||||||
void fromTextFieldXml(const QDomElement &dom_element);
|
void fromTextFieldXml(const QDomElement &dom_element);
|
||||||
static bool valideXml(QDomElement& dom_elmt);
|
static bool valideXml(QDomElement& dom_elmt);
|
||||||
|
|
||||||
DynamicElementTextItem::TextFrom textFrom() const;
|
DynamicElementTextItem::TextFrom textFrom() const;
|
||||||
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
||||||
QString text() const;
|
QString text() const;
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
void setInfoName(const QString &info_name);
|
void setInfoName(const QString &info_name);
|
||||||
QString infoName() const;
|
QString infoName() const;
|
||||||
void setCompositeText(const QString &text);
|
void setCompositeText(const QString &text);
|
||||||
QString compositeText() const;
|
QString compositeText() const;
|
||||||
void setColor(const QColor& color);
|
void setColor(const QColor& color);
|
||||||
QColor color() const;
|
QColor color() const;
|
||||||
void setFrame(bool frame);
|
void setFrame(bool frame);
|
||||||
bool frame() const;
|
bool frame() const;
|
||||||
void setTextWidth(qreal width);
|
void setTextWidth(qreal width);
|
||||||
void setPlainText(const QString &text);
|
void setPlainText(const QString &text);
|
||||||
void setAlignment(Qt::Alignment alignment);
|
void setAlignment(Qt::Alignment alignment);
|
||||||
Qt::Alignment alignment() const;
|
Qt::Alignment alignment() const;
|
||||||
void setFont(const QFont &font);
|
void setFont(const QFont &font);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void elementInfoChanged();
|
void elementInfoChanged();
|
||||||
void prepareAlignment();
|
void prepareAlignment();
|
||||||
void finishAlignment();
|
void finishAlignment();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointF m_origine_pos,
|
QPointF m_origine_pos,
|
||||||
m_saved_point;
|
m_saved_point;
|
||||||
QString m_text,
|
QString m_text,
|
||||||
m_info_name,
|
m_info_name,
|
||||||
m_composite_text;
|
m_composite_text;
|
||||||
DynamicElementTextItem::TextFrom m_text_from = DynamicElementTextItem::UserText;
|
DynamicElementTextItem::TextFrom m_text_from = DynamicElementTextItem::UserText;
|
||||||
QUuid m_uuid{QUuid::createUuid()};
|
QUuid m_uuid{QUuid::createUuid()};
|
||||||
bool m_frame = false,
|
bool m_frame = false,
|
||||||
m_first_add = true,
|
m_first_add = true,
|
||||||
m_block_alignment = false;
|
m_block_alignment = false;
|
||||||
qreal m_text_width = -1;
|
qreal m_text_width = -1;
|
||||||
Qt::Alignment m_alignment = Qt::AlignTop|Qt::AlignLeft;
|
Qt::Alignment m_alignment = Qt::AlignTop|Qt::AlignLeft;
|
||||||
QRectF m_alignment_rect;
|
QRectF m_alignment_rect;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PARTDYNAMICTEXTFIELD_H
|
#endif // PARTDYNAMICTEXTFIELD_H
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "partellipse.h"
|
#include "partellipse.h"
|
||||||
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||||
@@ -22,396 +22,396 @@
|
|||||||
#include "QetGraphicsItemModeler/qetgraphicshandlerutility.h"
|
#include "QetGraphicsItemModeler/qetgraphicshandlerutility.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::PartEllipse
|
@brief PartEllipse::PartEllipse
|
||||||
Constructor
|
Constructor
|
||||||
@param editor : QETElementEditor of this part
|
@param editor : QETElementEditor of this part
|
||||||
@param parent : parent item
|
@param parent : parent item
|
||||||
*/
|
*/
|
||||||
PartEllipse::PartEllipse(QETElementEditor *editor, QGraphicsItem *parent) :
|
PartEllipse::PartEllipse(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||||
AbstractPartEllipse(editor, parent),
|
AbstractPartEllipse(editor, parent),
|
||||||
m_undo_command(nullptr)
|
m_undo_command(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::~PartEllipse
|
@brief PartEllipse::~PartEllipse
|
||||||
Destructor
|
Destructor
|
||||||
*/
|
*/
|
||||||
PartEllipse::~PartEllipse()
|
PartEllipse::~PartEllipse()
|
||||||
{
|
{
|
||||||
if(m_undo_command) delete m_undo_command;
|
if(m_undo_command) delete m_undo_command;
|
||||||
removeHandler();
|
removeHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::paint
|
@brief PartEllipse::paint
|
||||||
Draw this ellpise
|
Draw this ellpise
|
||||||
@param painter
|
@param painter
|
||||||
@param options
|
@param options
|
||||||
@param widget
|
@param widget
|
||||||
*/
|
*/
|
||||||
void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget)
|
void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget)
|
||||||
{
|
{
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
applyStylesToQPainter(*painter);
|
applyStylesToQPainter(*painter);
|
||||||
|
|
||||||
QPen t = painter -> pen();
|
QPen t = painter -> pen();
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
||||||
#else
|
#else
|
||||||
#if TODO_LIST
|
#if TODO_LIST
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
#pragma message("@TODO remove code for QT 6 or later")
|
||||||
#endif
|
#endif
|
||||||
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
|
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
|
||||||
#endif
|
#endif
|
||||||
if (isSelected())
|
if (isSelected())
|
||||||
t.setColor(Qt::red);
|
t.setColor(Qt::red);
|
||||||
|
|
||||||
painter -> setPen(t);
|
painter -> setPen(t);
|
||||||
painter -> drawEllipse(rect());
|
painter -> drawEllipse(rect());
|
||||||
|
|
||||||
if (m_hovered)
|
if (m_hovered)
|
||||||
drawShadowShape(painter);
|
drawShadowShape(painter);
|
||||||
|
|
||||||
if (isSelected())
|
if (isSelected())
|
||||||
drawCross(m_rect.center(), painter);
|
drawCross(m_rect.center(), painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::toXml
|
@brief PartEllipse::toXml
|
||||||
Export this ellipse in xml
|
Export this ellipse in xml
|
||||||
@param xml_document : Xml document to use for create the xml element.
|
@param xml_document : Xml document to use for create the xml element.
|
||||||
@return : an xml element that describe this ellipse
|
@return : an xml element that describe this ellipse
|
||||||
*/
|
*/
|
||||||
QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element;
|
QDomElement xml_element;
|
||||||
if (qFuzzyCompare(rect().width(), rect().height()))
|
if (qFuzzyCompare(rect().width(), rect().height()))
|
||||||
{
|
{
|
||||||
xml_element = xml_document.createElement("circle");
|
xml_element = xml_document.createElement("circle");
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "diameter", rect().width()));
|
xml_element.appendChild(createXmlProperty(xml_document, "diameter", rect().width()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xml_element = xml_document.createElement("ellipse");
|
xml_element = xml_document.createElement("ellipse");
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "width", rect().width()));
|
xml_element.appendChild(createXmlProperty(xml_document, "width", rect().width()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "height", rect().height()));
|
xml_element.appendChild(createXmlProperty(xml_document, "height", rect().height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF top_left(sceneTopLeft());
|
QPointF top_left(sceneTopLeft());
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "x", top_left.x()));
|
xml_element.appendChild(createXmlProperty(xml_document, "x", top_left.x()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "y", top_left.y()));
|
xml_element.appendChild(createXmlProperty(xml_document, "y", top_left.y()));
|
||||||
|
|
||||||
stylesToXml(xml_document, xml_element);
|
stylesToXml(xml_document, xml_element);
|
||||||
|
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::fromXml
|
@brief PartEllipse::fromXml
|
||||||
Import the properties of this ellipse from a xml element.
|
Import the properties of this ellipse from a xml element.
|
||||||
@param qde : Xml document to use.
|
@param qde : Xml document to use.
|
||||||
*/
|
*/
|
||||||
bool PartEllipse::fromXml(const QDomElement &qde)
|
bool PartEllipse::fromXml(const QDomElement &qde)
|
||||||
{
|
{
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
double x=0, y=0, width=0, height=0;
|
double x=0, y=0, width=0, height=0;
|
||||||
|
|
||||||
if (qde.tagName() == "ellipse")
|
if (qde.tagName() == "ellipse")
|
||||||
{
|
{
|
||||||
if (propertyDouble(qde, "width", &width) == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(qde, "width", &width) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "height", &height) == PropertyFlags::NoValidConversion)
|
propertyDouble(qde, "height", &height) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (propertyDouble(qde, "diameter", &width) == PropertyFlags::NoValidConversion)
|
if (propertyDouble(qde, "diameter", &width) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
height = width;
|
height = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion)
|
propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_rect = QRectF(mapFromScene(x, y), QSizeF(width, height));
|
m_rect = QRectF(mapFromScene(x, y), QSizeF(width, height));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PartEllipse::valideXml(QDomElement& element) {
|
bool PartEllipse::valideXml(QDomElement& element) {
|
||||||
if (element.tagName() == "ellipse")
|
if (element.tagName() == "ellipse")
|
||||||
{
|
{
|
||||||
if (propertyDouble(element, "width") & PropertyFlags::NoValidConversion ||
|
if (propertyDouble(element, "width") & PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(element, "height") & PropertyFlags::NoValidConversion)
|
propertyDouble(element, "height") & PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (propertyDouble(element, "diameter") & PropertyFlags::NoValidConversion)
|
if (propertyDouble(element, "diameter") & PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((propertyDouble(element, "x") & PropertyFlags::NoValidConversion) ||
|
if ((propertyDouble(element, "x") & PropertyFlags::NoValidConversion) ||
|
||||||
(propertyDouble(element, "y") & PropertyFlags::NoValidConversion))
|
(propertyDouble(element, "y") & PropertyFlags::NoValidConversion))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::shape
|
@brief PartEllipse::shape
|
||||||
@return the shape of this item
|
@return the shape of this item
|
||||||
*/
|
*/
|
||||||
QPainterPath PartEllipse::shape() const
|
QPainterPath PartEllipse::shape() const
|
||||||
{
|
{
|
||||||
QPainterPath shape;
|
QPainterPath shape;
|
||||||
shape.addEllipse(m_rect);
|
shape.addEllipse(m_rect);
|
||||||
|
|
||||||
QPainterPathStroker pps;
|
QPainterPathStroker pps;
|
||||||
pps.setWidth(m_hovered? penWeight()+SHADOWS_HEIGHT : penWeight());
|
pps.setWidth(m_hovered? penWeight()+SHADOWS_HEIGHT : penWeight());
|
||||||
shape = pps.createStroke(shape);
|
shape = pps.createStroke(shape);
|
||||||
|
|
||||||
return shape;
|
return shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainterPath PartEllipse::shadowShape() const
|
QPainterPath PartEllipse::shadowShape() const
|
||||||
{
|
{
|
||||||
QPainterPath shape;
|
QPainterPath shape;
|
||||||
shape.addEllipse(m_rect);
|
shape.addEllipse(m_rect);
|
||||||
|
|
||||||
QPainterPathStroker pps;
|
QPainterPathStroker pps;
|
||||||
pps.setWidth(penWeight());
|
pps.setWidth(penWeight());
|
||||||
|
|
||||||
return (pps.createStroke(shape));
|
return (pps.createStroke(shape));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::mouseReleaseEvent
|
@brief PartEllipse::mouseReleaseEvent
|
||||||
Handle mouse release event
|
Handle mouse release event
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void PartEllipse::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void PartEllipse::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && event->buttonDownPos(Qt::LeftButton) == event->pos())
|
if (event->button() == Qt::LeftButton && event->buttonDownPos(Qt::LeftButton) == event->pos())
|
||||||
switchResizeMode();
|
switchResizeMode();
|
||||||
|
|
||||||
CustomElementGraphicPart::mouseReleaseEvent(event);
|
CustomElementGraphicPart::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::itemChange
|
@brief PartEllipse::itemChange
|
||||||
@param change
|
@param change
|
||||||
@param value
|
@param value
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
QVariant PartEllipse::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
QVariant PartEllipse::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||||
{
|
{
|
||||||
if (change == ItemSelectedHasChanged && scene())
|
if (change == ItemSelectedHasChanged && scene())
|
||||||
{
|
{
|
||||||
if (value.toBool() == true)
|
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,
|
//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.
|
//according to the number of selected items.
|
||||||
connect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged);
|
connect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged);
|
||||||
|
|
||||||
if (scene()->selectedItems().size() == 1)
|
if (scene()->selectedItems().size() == 1)
|
||||||
addHandler();
|
addHandler();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged);
|
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged);
|
||||||
removeHandler();
|
removeHandler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (change == ItemPositionHasChanged)
|
else if (change == ItemPositionHasChanged)
|
||||||
{
|
{
|
||||||
adjusteHandlerPos();
|
adjusteHandlerPos();
|
||||||
}
|
}
|
||||||
else if (change == ItemSceneChange)
|
else if (change == ItemSceneChange)
|
||||||
{
|
{
|
||||||
if(scene())
|
if(scene())
|
||||||
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartEllipse::sceneSelectionChanged);
|
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
|
@brief PartEllipse::sceneEventFilter
|
||||||
@param watched
|
@param watched
|
||||||
@param event
|
@param event
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
bool PartEllipse::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
bool PartEllipse::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
//Watched must be an handler
|
//Watched must be an handler
|
||||||
if(watched->type() == QetGraphicsHandlerItem::Type)
|
if(watched->type() == QetGraphicsHandlerItem::Type)
|
||||||
{
|
{
|
||||||
QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched);
|
QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched);
|
||||||
|
|
||||||
if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
|
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);
|
m_vector_index = m_handler_vector.indexOf(qghi);
|
||||||
if (m_vector_index != -1)
|
if (m_vector_index != -1)
|
||||||
{
|
{
|
||||||
if(event->type() == QEvent::GraphicsSceneMousePress) //Click
|
if(event->type() == QEvent::GraphicsSceneMousePress) //Click
|
||||||
{
|
{
|
||||||
handlerMousePressEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
handlerMousePressEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(event->type() == QEvent::GraphicsSceneMouseMove) //Move
|
else if(event->type() == QEvent::GraphicsSceneMouseMove) //Move
|
||||||
{
|
{
|
||||||
handlerMouseMoveEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
handlerMouseMoveEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (event->type() == QEvent::GraphicsSceneMouseRelease) //Release
|
else if (event->type() == QEvent::GraphicsSceneMouseRelease) //Release
|
||||||
{
|
{
|
||||||
handlerMouseReleaseEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
handlerMouseReleaseEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartEllipse::switchResizeMode()
|
void PartEllipse::switchResizeMode()
|
||||||
{
|
{
|
||||||
if (m_resize_mode == 1)
|
if (m_resize_mode == 1)
|
||||||
{
|
{
|
||||||
m_resize_mode = 2;
|
m_resize_mode = 2;
|
||||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||||
qghi->setColor(Qt::darkGreen);
|
qghi->setColor(Qt::darkGreen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_resize_mode = 1;
|
m_resize_mode = 1;
|
||||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||||
qghi->setColor(Qt::blue);
|
qghi->setColor(Qt::blue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::adjusteHandlerPos
|
@brief PartEllipse::adjusteHandlerPos
|
||||||
*/
|
*/
|
||||||
void PartEllipse::adjusteHandlerPos()
|
void PartEllipse::adjusteHandlerPos()
|
||||||
{
|
{
|
||||||
if (m_handler_vector.isEmpty())
|
if (m_handler_vector.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QVector <QPointF> points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect);
|
QVector <QPointF> points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect);
|
||||||
|
|
||||||
if (m_handler_vector.size() == points_vector.size())
|
if (m_handler_vector.size() == points_vector.size())
|
||||||
{
|
{
|
||||||
points_vector = mapToScene(points_vector);
|
points_vector = mapToScene(points_vector);
|
||||||
for (int i = 0 ; i < points_vector.size() ; ++i)
|
for (int i = 0 ; i < points_vector.size() ; ++i)
|
||||||
m_handler_vector.at(i)->setPos(points_vector.at(i));
|
m_handler_vector.at(i)->setPos(points_vector.at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::handlerMousePressEvent
|
@brief PartEllipse::handlerMousePressEvent
|
||||||
@param qghi
|
@param qghi
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void PartEllipse::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
void PartEllipse::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(qghi);
|
Q_UNUSED(qghi);
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
|
|
||||||
m_undo_command = new QPropertyUndoCommand(this, "rect", QVariant(m_rect));
|
m_undo_command = new QPropertyUndoCommand(this, "rect", QVariant(m_rect));
|
||||||
m_undo_command->setText(tr("Modifier un rectangle"));
|
m_undo_command->setText(tr("Modifier un rectangle"));
|
||||||
m_undo_command->enableAnimation();
|
m_undo_command->enableAnimation();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::handlerMouseMoveEvent
|
@brief PartEllipse::handlerMouseMoveEvent
|
||||||
@param qghi
|
@param qghi
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void PartEllipse::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
void PartEllipse::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(qghi);
|
Q_UNUSED(qghi);
|
||||||
|
|
||||||
QPointF new_pos = event->scenePos();
|
QPointF new_pos = event->scenePos();
|
||||||
if (event->modifiers() != Qt::ControlModifier)
|
if (event->modifiers() != Qt::ControlModifier)
|
||||||
new_pos = elementScene()->snapToGrid(event->scenePos());
|
new_pos = elementScene()->snapToGrid(event->scenePos());
|
||||||
new_pos = mapFromScene(new_pos);
|
new_pos = mapFromScene(new_pos);
|
||||||
|
|
||||||
if (m_resize_mode == 1)
|
if (m_resize_mode == 1)
|
||||||
setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index));
|
setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index));
|
||||||
else
|
else
|
||||||
setRect(QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(m_rect, new_pos, m_vector_index));
|
setRect(QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(m_rect, new_pos, m_vector_index));
|
||||||
|
|
||||||
adjusteHandlerPos();
|
adjusteHandlerPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::handlerMouseReleaseEvent
|
@brief PartEllipse::handlerMouseReleaseEvent
|
||||||
@param qghi
|
@param qghi
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void PartEllipse::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
void PartEllipse::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(qghi);
|
Q_UNUSED(qghi);
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
|
|
||||||
m_undo_command->setNewValue(QVariant(m_rect));
|
m_undo_command->setNewValue(QVariant(m_rect));
|
||||||
elementScene()->undoStack().push(m_undo_command);
|
elementScene()->undoStack().push(m_undo_command);
|
||||||
m_undo_command = nullptr;
|
m_undo_command = nullptr;
|
||||||
m_vector_index = -1;
|
m_vector_index = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::sceneSelectionChanged
|
@brief PartEllipse::sceneSelectionChanged
|
||||||
When the scene selection change, if there are several primitive selected, we remove the handler of this item
|
When the scene selection change, if there are several primitive selected, we remove the handler of this item
|
||||||
*/
|
*/
|
||||||
void PartEllipse::sceneSelectionChanged()
|
void PartEllipse::sceneSelectionChanged()
|
||||||
{
|
{
|
||||||
if (this->isSelected() && scene()->selectedItems().size() == 1)
|
if (this->isSelected() && scene()->selectedItems().size() == 1)
|
||||||
addHandler();
|
addHandler();
|
||||||
else
|
else
|
||||||
removeHandler();
|
removeHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::addHandler
|
@brief PartEllipse::addHandler
|
||||||
Add handlers for this item
|
Add handlers for this item
|
||||||
*/
|
*/
|
||||||
void PartEllipse::addHandler()
|
void PartEllipse::addHandler()
|
||||||
{
|
{
|
||||||
if (m_handler_vector.isEmpty() && scene())
|
if (m_handler_vector.isEmpty() && scene())
|
||||||
{
|
{
|
||||||
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
|
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
|
||||||
|
|
||||||
for(QetGraphicsHandlerItem *handler : m_handler_vector)
|
for(QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||||
{
|
{
|
||||||
QColor color = Qt::blue;
|
QColor color = Qt::blue;
|
||||||
if (m_resize_mode == 2)
|
if (m_resize_mode == 2)
|
||||||
color = Qt::darkGreen;
|
color = Qt::darkGreen;
|
||||||
|
|
||||||
handler->setColor(color);
|
handler->setColor(color);
|
||||||
scene()->addItem(handler);
|
scene()->addItem(handler);
|
||||||
handler->installSceneEventFilter(this);
|
handler->installSceneEventFilter(this);
|
||||||
handler->setZValue(this->zValue()+1);
|
handler->setZValue(this->zValue()+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartEllipse::removeHandler
|
@brief PartEllipse::removeHandler
|
||||||
Remove the handlers of this item
|
Remove the handlers of this item
|
||||||
*/
|
*/
|
||||||
void PartEllipse::removeHandler()
|
void PartEllipse::removeHandler()
|
||||||
{
|
{
|
||||||
if (!m_handler_vector.isEmpty())
|
if (!m_handler_vector.isEmpty())
|
||||||
{
|
{
|
||||||
qDeleteAll(m_handler_vector);
|
qDeleteAll(m_handler_vector);
|
||||||
m_handler_vector.clear();
|
m_handler_vector.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef PART_ELLIPSE_H
|
#ifndef PART_ELLIPSE_H
|
||||||
#define PART_ELLIPSE_H
|
#define PART_ELLIPSE_H
|
||||||
@@ -23,61 +23,61 @@
|
|||||||
class QPropertyUndoCommand;
|
class QPropertyUndoCommand;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The PartEllipse class
|
@brief The PartEllipse class
|
||||||
This class represents an ellipse primitive which may be used to compose the
|
This class represents an ellipse primitive which may be used to compose the
|
||||||
drawing of an electrical element within the element editor.
|
drawing of an electrical element within the element editor.
|
||||||
*/
|
*/
|
||||||
class PartEllipse : public AbstractPartEllipse
|
class PartEllipse : public AbstractPartEllipse
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
PartEllipse(QETElementEditor *editor, QGraphicsItem * parent = nullptr);
|
PartEllipse(QETElementEditor *editor, QGraphicsItem * parent = nullptr);
|
||||||
~PartEllipse() override;
|
~PartEllipse() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PartEllipse(const PartEllipse &);
|
PartEllipse(const PartEllipse &);
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1103 };
|
enum { Type = UserType + 1103 };
|
||||||
/**
|
/**
|
||||||
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartEllipse.
|
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartEllipse.
|
||||||
@return the QGraphicsItem type
|
@return the QGraphicsItem type
|
||||||
*/
|
*/
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||||
|
|
||||||
//Name and XML
|
//Name and XML
|
||||||
QString name() const override { return(QObject::tr("ellipse", "element part name")); }
|
QString name() const override { return(QObject::tr("ellipse", "element part name")); }
|
||||||
QString xmlName() const override { return(QString("ellipse")); }
|
QString xmlName() const override { return(QString("ellipse")); }
|
||||||
QDomElement toXml (QDomDocument &) const override;
|
QDomElement toXml (QDomDocument &) const override;
|
||||||
bool fromXml (const QDomElement &) override;
|
bool fromXml (const QDomElement &) override;
|
||||||
static bool valideXml(QDomElement& element);
|
static bool valideXml(QDomElement& element);
|
||||||
QPainterPath shape() const override;
|
QPainterPath shape() const override;
|
||||||
QPainterPath shadowShape() const override;
|
QPainterPath shadowShape() const override;
|
||||||
void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
|
void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void switchResizeMode();
|
void switchResizeMode();
|
||||||
void adjusteHandlerPos();
|
void adjusteHandlerPos();
|
||||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void sceneSelectionChanged ();
|
void sceneSelectionChanged ();
|
||||||
|
|
||||||
void addHandler();
|
void addHandler();
|
||||||
void removeHandler();
|
void removeHandler();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPropertyUndoCommand *m_undo_command;
|
QPropertyUndoCommand *m_undo_command;
|
||||||
int m_resize_mode = 1,
|
int m_resize_mode = 1,
|
||||||
m_vector_index = -1;
|
m_vector_index = -1;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef PART_LINE_H
|
#ifndef PART_LINE_H
|
||||||
#define PART_LINE_H
|
#define PART_LINE_H
|
||||||
@@ -25,105 +25,105 @@ class QPropertyUndoCommand;
|
|||||||
class QetGraphicsHandlerItem;
|
class QetGraphicsHandlerItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class represents a line primitive which may be used to compose the
|
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
|
drawing of an electrical element within the element editor. Lines may have
|
||||||
specific visual ends (e.g. arrows) through the setFirstEndType and
|
specific visual ends (e.g. arrows) through the setFirstEndType and
|
||||||
setSecondEndType methods. Their size can be defined using the
|
setSecondEndType methods. Their size can be defined using the
|
||||||
setFirstEndLength and setSecondEndLength methods. Please note ends are not
|
setFirstEndLength and setSecondEndLength methods. Please note ends are not
|
||||||
drawn if the required length for their drawing is longer than the line itself.
|
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.
|
In case there is room for a single end only, the first one get priority.
|
||||||
*/
|
*/
|
||||||
class PartLine : public CustomElementGraphicPart
|
class PartLine : public CustomElementGraphicPart
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(Qet::EndType end1 READ firstEndType WRITE setFirstEndType)
|
Q_PROPERTY(Qet::EndType end1 READ firstEndType WRITE setFirstEndType)
|
||||||
Q_PROPERTY(Qet::EndType end2 READ secondEndType WRITE setSecondEndType)
|
Q_PROPERTY(Qet::EndType end2 READ secondEndType WRITE setSecondEndType)
|
||||||
Q_PROPERTY(qreal length1 READ firstEndLength WRITE setFirstEndLength)
|
Q_PROPERTY(qreal length1 READ firstEndLength WRITE setFirstEndLength)
|
||||||
Q_PROPERTY(qreal length2 READ secondEndLength WRITE setSecondEndLength)
|
Q_PROPERTY(qreal length2 READ secondEndLength WRITE setSecondEndLength)
|
||||||
Q_PROPERTY(QLineF line READ line WRITE setLine)
|
Q_PROPERTY(QLineF line READ line WRITE setLine)
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
PartLine(QETElementEditor *, QGraphicsItem * = nullptr);
|
PartLine(QETElementEditor *, QGraphicsItem * = nullptr);
|
||||||
~PartLine() override;
|
~PartLine() override;
|
||||||
private:
|
private:
|
||||||
PartLine(const PartLine &);
|
PartLine(const PartLine &);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void lineChanged();
|
void lineChanged();
|
||||||
void firstEndTypeChanged();
|
void firstEndTypeChanged();
|
||||||
void secondEndTypeChanged();
|
void secondEndTypeChanged();
|
||||||
void firstEndLengthChanged();
|
void firstEndLengthChanged();
|
||||||
void secondEndLengthChanged();
|
void secondEndLengthChanged();
|
||||||
|
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1104 };
|
enum { Type = UserType + 1104 };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartLine.
|
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartLine.
|
||||||
@return the QGraphicsItem type
|
@return the QGraphicsItem type
|
||||||
*/
|
*/
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||||
QString name() const override { return(QObject::tr("ligne", "element part name")); }
|
QString name() const override { return(QObject::tr("ligne", "element part name")); }
|
||||||
QString xmlName() const override { return(QString("line")); }
|
QString xmlName() const override { return(QString("line")); }
|
||||||
QDomElement toXml(QDomDocument &) const override;
|
QDomElement toXml(QDomDocument &) const override;
|
||||||
bool fromXml(const QDomElement &) override;
|
bool fromXml(const QDomElement &) override;
|
||||||
bool valideXml(QDomElement& element) const;
|
bool valideXml(QDomElement& element) const;
|
||||||
virtual QPointF sceneP1() const;
|
virtual QPointF sceneP1() const;
|
||||||
virtual QPointF sceneP2() const;
|
virtual QPointF sceneP2() const;
|
||||||
QPainterPath shape() const override;
|
QPainterPath shape() const override;
|
||||||
QPainterPath shadowShape() const override;
|
QPainterPath shadowShape() const override;
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
bool isUseless() const override;
|
bool isUseless() const override;
|
||||||
QRectF sceneGeometricRect() const override;
|
QRectF sceneGeometricRect() const override;
|
||||||
void startUserTransformation(const QRectF &) override;
|
void startUserTransformation(const QRectF &) override;
|
||||||
void handleUserTransformation(const QRectF &, const QRectF &) override;
|
void handleUserTransformation(const QRectF &, const QRectF &) override;
|
||||||
static uint requiredLengthForEndType(const Qet::EndType &);
|
static uint requiredLengthForEndType(const Qet::EndType &);
|
||||||
static QList<QPointF> fourEndPoints(const QPointF &, const QPointF &, const qreal &);
|
static QList<QPointF> fourEndPoints(const QPointF &, const QPointF &, const qreal &);
|
||||||
|
|
||||||
QLineF line() const;
|
QLineF line() const;
|
||||||
void setLine(const QLineF &line);
|
void setLine(const QLineF &line);
|
||||||
Qet::EndType firstEndType() const {return first_end;}
|
Qet::EndType firstEndType() const {return first_end;}
|
||||||
void setFirstEndType(const Qet::EndType &et);
|
void setFirstEndType(const Qet::EndType &et);
|
||||||
Qet::EndType secondEndType() const {return second_end;}
|
Qet::EndType secondEndType() const {return second_end;}
|
||||||
void setSecondEndType(const Qet::EndType &et);
|
void setSecondEndType(const Qet::EndType &et);
|
||||||
qreal firstEndLength() const {return first_length;}
|
qreal firstEndLength() const {return first_length;}
|
||||||
void setFirstEndLength(const qreal &l);
|
void setFirstEndLength(const qreal &l);
|
||||||
qreal secondEndLength() const {return second_length;}
|
qreal secondEndLength() const {return second_length;}
|
||||||
void setSecondEndLength(const qreal &l);
|
void setSecondEndLength(const qreal &l);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void adjusteHandlerPos();
|
void adjusteHandlerPos();
|
||||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void sceneSelectionChanged ();
|
void sceneSelectionChanged ();
|
||||||
|
|
||||||
void addHandler();
|
void addHandler();
|
||||||
void removeHandler();
|
void removeHandler();
|
||||||
|
|
||||||
QPainterPath path() const;
|
QPainterPath path() const;
|
||||||
QRectF firstEndCircleRect() const;
|
QRectF firstEndCircleRect() const;
|
||||||
QRectF secondEndCircleRect() const;
|
QRectF secondEndCircleRect() const;
|
||||||
|
|
||||||
/*****************/
|
/*****************/
|
||||||
Qet::EndType first_end;
|
Qet::EndType first_end;
|
||||||
qreal first_length{1.5};
|
qreal first_length{1.5};
|
||||||
|
|
||||||
Qet::EndType second_end;
|
Qet::EndType second_end;
|
||||||
qreal second_length{1.5};
|
qreal second_length{1.5};
|
||||||
QList<QPointF> saved_points_;
|
QList<QPointF> saved_points_;
|
||||||
QLineF m_line;
|
QLineF m_line;
|
||||||
int m_vector_index = -1;
|
int m_vector_index = -1;
|
||||||
QPropertyUndoCommand *m_undo_command;
|
QPropertyUndoCommand *m_undo_command;
|
||||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef PART_POLYGON_H
|
#ifndef PART_POLYGON_H
|
||||||
#define PART_POLYGON_H
|
#define PART_POLYGON_H
|
||||||
@@ -26,95 +26,95 @@ class QetGraphicsHandlerItem;
|
|||||||
class QAction;
|
class QAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The PartPolygon class
|
@brief The PartPolygon class
|
||||||
This class represents a polygon primitive which may be used to compose the
|
This class represents a polygon primitive which may be used to compose the
|
||||||
drawing of an electrical element within the element editor.
|
drawing of an electrical element within the element editor.
|
||||||
*/
|
*/
|
||||||
class PartPolygon : public CustomElementGraphicPart
|
class PartPolygon : public CustomElementGraphicPart
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(bool closed READ isClosed WRITE setClosed)
|
Q_PROPERTY(bool closed READ isClosed WRITE setClosed)
|
||||||
Q_PROPERTY(QPolygonF polygon READ polygon WRITE setPolygon)
|
Q_PROPERTY(QPolygonF polygon READ polygon WRITE setPolygon)
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
PartPolygon(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
|
PartPolygon(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
|
||||||
~PartPolygon() override;
|
~PartPolygon() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PartPolygon(const PartPolygon &);
|
PartPolygon(const PartPolygon &);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void closedChange();
|
void closedChange();
|
||||||
void polygonChanged();
|
void polygonChanged();
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1105 };
|
enum { Type = UserType + 1105 };
|
||||||
/**
|
/**
|
||||||
* Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartPolygon.
|
* Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartPolygon.
|
||||||
* @return the QGraphicsItem type
|
* @return the QGraphicsItem type
|
||||||
*/
|
*/
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
|
||||||
|
|
||||||
QString name() const override { return(QObject::tr("polygone", "element part name")); }
|
QString name() const override { return(QObject::tr("polygone", "element part name")); }
|
||||||
QString xmlName() const override { return(QString("polygon")); }
|
QString xmlName() const override { return(QString("polygon")); }
|
||||||
bool fromXml(const QDomElement &) override;
|
bool fromXml(const QDomElement &) override;
|
||||||
QDomElement toXml(QDomDocument &) const override;
|
QDomElement toXml(QDomDocument &) const override;
|
||||||
static bool valideXml(QDomElement& element);
|
static bool valideXml(QDomElement& element);
|
||||||
|
|
||||||
|
|
||||||
QPainterPath shape () const override;
|
QPainterPath shape () const override;
|
||||||
QPainterPath shadowShape() const override;
|
QPainterPath shadowShape() const override;
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
bool isUseless() const override;
|
bool isUseless() const override;
|
||||||
QRectF sceneGeometricRect() const override;
|
QRectF sceneGeometricRect() const override;
|
||||||
|
|
||||||
void startUserTransformation(const QRectF &) override;
|
void startUserTransformation(const QRectF &) override;
|
||||||
void handleUserTransformation(const QRectF &, const QRectF &) override;
|
void handleUserTransformation(const QRectF &, const QRectF &) override;
|
||||||
QET::ScalingMethod preferredScalingMethod() const override;
|
QET::ScalingMethod preferredScalingMethod() const override;
|
||||||
|
|
||||||
QPolygonF polygon () const;
|
QPolygonF polygon () const;
|
||||||
void setPolygon (const QPolygonF &polygon);
|
void setPolygon (const QPolygonF &polygon);
|
||||||
|
|
||||||
void addPoint (const QPointF &point);
|
void addPoint (const QPointF &point);
|
||||||
void setLastPoint (const QPointF &point);
|
void setLastPoint (const QPointF &point);
|
||||||
void removeLastPoint ();
|
void removeLastPoint ();
|
||||||
|
|
||||||
bool isClosed () const {return m_closed;}
|
bool isClosed () const {return m_closed;}
|
||||||
void setClosed (bool close);
|
void setClosed (bool close);
|
||||||
|
|
||||||
void setHandlerColor(QPointF pos, const QColor &color) final;
|
void setHandlerColor(QPointF pos, const QColor &color) final;
|
||||||
void resetAllHandlerColor() final;
|
void resetAllHandlerColor() final;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
||||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void adjusteHandlerPos();
|
void adjusteHandlerPos();
|
||||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void sceneSelectionChanged ();
|
void sceneSelectionChanged ();
|
||||||
|
|
||||||
void addHandler();
|
void addHandler();
|
||||||
void removeHandler();
|
void removeHandler();
|
||||||
void insertPoint();
|
void insertPoint();
|
||||||
void removePoint();
|
void removePoint();
|
||||||
|
|
||||||
|
|
||||||
bool m_closed;
|
bool m_closed;
|
||||||
QList<QPointF> saved_points_;
|
QList<QPointF> saved_points_;
|
||||||
QPolygonF m_polygon;
|
QPolygonF m_polygon;
|
||||||
QPropertyUndoCommand *m_undo_command;
|
QPropertyUndoCommand *m_undo_command;
|
||||||
int m_vector_index = -1;
|
int m_vector_index = -1;
|
||||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||||
QAction *m_insert_point,
|
QAction *m_insert_point,
|
||||||
*m_remove_point;
|
*m_remove_point;
|
||||||
QPointF m_context_menu_pos;
|
QPointF m_context_menu_pos;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "partrectangle.h"
|
#include "partrectangle.h"
|
||||||
#include "elementscene.h"
|
#include "elementscene.h"
|
||||||
@@ -22,572 +22,572 @@
|
|||||||
#include "QetGraphicsItemModeler/qetgraphicshandlerutility.h"
|
#include "QetGraphicsItemModeler/qetgraphicshandlerutility.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::PartRectangle
|
@brief PartRectangle::PartRectangle
|
||||||
Constructor
|
Constructor
|
||||||
@param editor the QETElementEditor of this item
|
@param editor the QETElementEditor of this item
|
||||||
@param parent parent item
|
@param parent parent item
|
||||||
*/
|
*/
|
||||||
PartRectangle::PartRectangle(QETElementEditor *editor, QGraphicsItem *parent) :
|
PartRectangle::PartRectangle(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||||
CustomElementGraphicPart(editor, parent)
|
CustomElementGraphicPart(editor, parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::~PartRectangle
|
@brief PartRectangle::~PartRectangle
|
||||||
*/
|
*/
|
||||||
PartRectangle::~PartRectangle()
|
PartRectangle::~PartRectangle()
|
||||||
{
|
{
|
||||||
removeHandler();
|
removeHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::paint
|
@brief PartRectangle::paint
|
||||||
Draw this Rectangle
|
Draw this Rectangle
|
||||||
@param painter
|
@param painter
|
||||||
@param options
|
@param options
|
||||||
@param widget
|
@param widget
|
||||||
*/
|
*/
|
||||||
void PartRectangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget)
|
void PartRectangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget)
|
||||||
{
|
{
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
applyStylesToQPainter(*painter);
|
applyStylesToQPainter(*painter);
|
||||||
QPen t = painter -> pen();
|
QPen t = painter -> pen();
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
||||||
#else
|
#else
|
||||||
#if TODO_LIST
|
#if TODO_LIST
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
#pragma message("@TODO remove code for QT 6 or later")
|
||||||
#endif
|
#endif
|
||||||
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
|
t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0);
|
||||||
#endif
|
#endif
|
||||||
if (isSelected())
|
if (isSelected())
|
||||||
t.setColor(Qt::red);
|
t.setColor(Qt::red);
|
||||||
|
|
||||||
t.setJoinStyle(Qt::MiterJoin);
|
t.setJoinStyle(Qt::MiterJoin);
|
||||||
|
|
||||||
//Force the pen to width 0 if one of dimension is null
|
//Force the pen to width 0 if one of dimension is null
|
||||||
if (!rect().width() || !rect().height())
|
if (!rect().width() || !rect().height())
|
||||||
t.setWidth(0);
|
t.setWidth(0);
|
||||||
|
|
||||||
painter->setPen(t);
|
painter->setPen(t);
|
||||||
painter->drawRoundedRect(m_rect, m_xRadius, m_yRadius);
|
painter->drawRoundedRect(m_rect, m_xRadius, m_yRadius);
|
||||||
|
|
||||||
if (m_hovered)
|
if (m_hovered)
|
||||||
drawShadowShape(painter);
|
drawShadowShape(painter);
|
||||||
|
|
||||||
if (isSelected())
|
if (isSelected())
|
||||||
drawCross(m_rect.center(), painter);
|
drawCross(m_rect.center(), painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::toXml
|
@brief PartRectangle::toXml
|
||||||
Export this rectangle in xml
|
Export this rectangle in xml
|
||||||
@param xml_document : Xml document to use for create the xml element.
|
@param xml_document : Xml document to use for create the xml element.
|
||||||
@return an xml element that describe this ellipse
|
@return an xml element that describe this ellipse
|
||||||
*/
|
*/
|
||||||
QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement("rect");
|
QDomElement xml_element = xml_document.createElement("rect");
|
||||||
QPointF top_left(sceneTopLeft());
|
QPointF top_left(sceneTopLeft());
|
||||||
|
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "x", top_left.x()));
|
xml_element.appendChild(createXmlProperty(xml_document, "x", top_left.x()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "y", top_left.y()));
|
xml_element.appendChild(createXmlProperty(xml_document, "y", top_left.y()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "width", m_rect.width()));
|
xml_element.appendChild(createXmlProperty(xml_document, "width", m_rect.width()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "height", m_rect.height()));
|
xml_element.appendChild(createXmlProperty(xml_document, "height", m_rect.height()));
|
||||||
|
|
||||||
QRectF rect = m_rect.normalized();
|
QRectF rect = m_rect.normalized();
|
||||||
qreal x = m_xRadius;
|
qreal x = m_xRadius;
|
||||||
if (x > rect.width()/2) {
|
if (x > rect.width()/2) {
|
||||||
x = rect.width()/2;
|
x = rect.width()/2;
|
||||||
}
|
}
|
||||||
qreal y = m_yRadius;
|
qreal y = m_yRadius;
|
||||||
if (y > rect.height()/2) {
|
if (y > rect.height()/2) {
|
||||||
y = rect.height()/2;
|
y = rect.height()/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
xml_element.setAttribute("rx", QString::number(m_xRadius));
|
xml_element.setAttribute("rx", QString::number(m_xRadius));
|
||||||
xml_element.setAttribute("ry", QString::number(m_yRadius));
|
xml_element.setAttribute("ry", QString::number(m_yRadius));
|
||||||
|
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "rx", m_xRadius));
|
xml_element.appendChild(createXmlProperty(xml_document, "rx", m_xRadius));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "ry", m_yRadius));
|
xml_element.appendChild(createXmlProperty(xml_document, "ry", m_yRadius));
|
||||||
|
|
||||||
stylesToXml(xml_document, xml_element);
|
stylesToXml(xml_document, xml_element);
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::fromXml
|
@brief PartRectangle::fromXml
|
||||||
Import the properties of this rectangle from a xml element.
|
Import the properties of this rectangle from a xml element.
|
||||||
@param qde : Xml document to use.
|
@param qde : Xml document to use.
|
||||||
*/
|
*/
|
||||||
bool PartRectangle::fromXml(const QDomElement &qde)
|
bool PartRectangle::fromXml(const QDomElement &qde)
|
||||||
{
|
{
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
|
|
||||||
double x=0, y=0, w=0, h=0, rx=0, ry=0;
|
double x=0, y=0, w=0, h=0, rx=0, ry=0;
|
||||||
if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion)
|
propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
setPos(mapFromScene(x, y));
|
setPos(mapFromScene(x, y));
|
||||||
|
|
||||||
if (propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "width", &h) == PropertyFlags::NoValidConversion)
|
propertyDouble(qde, "width", &h) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QRectF rect(QPointF(x,y), QSizeF(w, h));
|
QRectF rect(QPointF(x,y), QSizeF(w, h));
|
||||||
|
|
||||||
setRect(rect.normalized());
|
setRect(rect.normalized());
|
||||||
|
|
||||||
if (propertyDouble(qde, "rx", &rx) == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(qde, "rx", &rx) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "ry", &ry) == PropertyFlags::NoValidConversion)
|
propertyDouble(qde, "ry", &ry) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
setXRadius(rx);
|
setXRadius(rx);
|
||||||
setYRadius(ry);
|
setYRadius(ry);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PartRectangle::valideXml(QDomElement& element) {
|
bool PartRectangle::valideXml(QDomElement& element) {
|
||||||
// parameters have default values so no value is not a non valid xml element
|
// parameters have default values so no value is not a non valid xml element
|
||||||
if ((propertyDouble(element, "x") & PropertyFlags::NoValidConversion) |
|
if ((propertyDouble(element, "x") & PropertyFlags::NoValidConversion) |
|
||||||
(propertyDouble(element, "y") & PropertyFlags::NoValidConversion) |
|
(propertyDouble(element, "y") & PropertyFlags::NoValidConversion) |
|
||||||
(propertyDouble(element, "width") & PropertyFlags::NoValidConversion) |
|
(propertyDouble(element, "width") & PropertyFlags::NoValidConversion) |
|
||||||
(propertyDouble(element, "width") & PropertyFlags::NoValidConversion) |
|
(propertyDouble(element, "width") & PropertyFlags::NoValidConversion) |
|
||||||
(propertyDouble(element, "rx") & PropertyFlags::NoValidConversion) |
|
(propertyDouble(element, "rx") & PropertyFlags::NoValidConversion) |
|
||||||
(propertyDouble(element, "ry") & PropertyFlags::NoValidConversion))
|
(propertyDouble(element, "ry") & PropertyFlags::NoValidConversion))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::rect
|
@brief PartRectangle::rect
|
||||||
@return : Returns the item's rectangle.
|
@return : Returns the item's rectangle.
|
||||||
*/
|
*/
|
||||||
QRectF PartRectangle::rect() const
|
QRectF PartRectangle::rect() const
|
||||||
{
|
{
|
||||||
return m_rect;
|
return m_rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::setRect
|
@brief PartRectangle::setRect
|
||||||
Sets the item's rectangle to be the given rectangle.
|
Sets the item's rectangle to be the given rectangle.
|
||||||
@param rect
|
@param rect
|
||||||
*/
|
*/
|
||||||
void PartRectangle::setRect(const QRectF &rect)
|
void PartRectangle::setRect(const QRectF &rect)
|
||||||
{
|
{
|
||||||
if (rect == m_rect) return;
|
if (rect == m_rect) return;
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
m_rect = rect;
|
m_rect = rect;
|
||||||
adjusteHandlerPos();
|
adjusteHandlerPos();
|
||||||
emit rectChanged();
|
emit rectChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartRectangle::setXRadius(qreal X)
|
void PartRectangle::setXRadius(qreal X)
|
||||||
{
|
{
|
||||||
m_xRadius = X;
|
m_xRadius = X;
|
||||||
update();
|
update();
|
||||||
adjusteHandlerPos();
|
adjusteHandlerPos();
|
||||||
emit XRadiusChanged();
|
emit XRadiusChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartRectangle::setYRadius(qreal Y)
|
void PartRectangle::setYRadius(qreal Y)
|
||||||
{
|
{
|
||||||
m_yRadius = Y;
|
m_yRadius = Y;
|
||||||
update();
|
update();
|
||||||
adjusteHandlerPos();
|
adjusteHandlerPos();
|
||||||
emit YRadiusChanged();
|
emit YRadiusChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::sceneGeometricRect
|
@brief PartRectangle::sceneGeometricRect
|
||||||
@return the minimum, margin-less rectangle this part can fit into, in scene
|
@return the minimum, margin-less rectangle this part can fit into, in scene
|
||||||
coordinates. It is different from boundingRect() because it is not supposed
|
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
|
to imply any margin, and it is different from shape because it is a regular
|
||||||
rectangle, not a complex shape.
|
rectangle, not a complex shape.
|
||||||
*/
|
*/
|
||||||
QRectF PartRectangle::sceneGeometricRect() const
|
QRectF PartRectangle::sceneGeometricRect() const
|
||||||
{
|
{
|
||||||
return(mapToScene(rect()).boundingRect());
|
return(mapToScene(rect()).boundingRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::sceneTopLeft
|
@brief PartRectangle::sceneTopLeft
|
||||||
@return the top left of rectangle, in scene coordinate
|
@return the top left of rectangle, in scene coordinate
|
||||||
*/
|
*/
|
||||||
QPointF PartRectangle::sceneTopLeft() const
|
QPointF PartRectangle::sceneTopLeft() const
|
||||||
{
|
{
|
||||||
return(mapToScene(rect().topLeft()));
|
return(mapToScene(rect().topLeft()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::shape
|
@brief PartRectangle::shape
|
||||||
@return the shape of this item
|
@return the shape of this item
|
||||||
*/
|
*/
|
||||||
QPainterPath PartRectangle::shape() const
|
QPainterPath PartRectangle::shape() const
|
||||||
{
|
{
|
||||||
QPainterPath shape;
|
QPainterPath shape;
|
||||||
shape.addRoundedRect(m_rect, m_xRadius, m_yRadius);
|
shape.addRoundedRect(m_rect, m_xRadius, m_yRadius);
|
||||||
|
|
||||||
QPainterPathStroker pps;
|
QPainterPathStroker pps;
|
||||||
pps.setWidth(m_hovered? penWeight()+SHADOWS_HEIGHT : penWeight());
|
pps.setWidth(m_hovered? penWeight()+SHADOWS_HEIGHT : penWeight());
|
||||||
shape = pps.createStroke(shape);
|
shape = pps.createStroke(shape);
|
||||||
|
|
||||||
return shape;
|
return shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainterPath PartRectangle::shadowShape() const
|
QPainterPath PartRectangle::shadowShape() const
|
||||||
{
|
{
|
||||||
QPainterPath shape;
|
QPainterPath shape;
|
||||||
shape.addRoundedRect(m_rect, m_xRadius, m_yRadius);
|
shape.addRoundedRect(m_rect, m_xRadius, m_yRadius);
|
||||||
|
|
||||||
QPainterPathStroker pps;
|
QPainterPathStroker pps;
|
||||||
pps.setWidth(penWeight());
|
pps.setWidth(penWeight());
|
||||||
|
|
||||||
return (pps.createStroke(shape));
|
return (pps.createStroke(shape));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::boundingRect
|
@brief PartRectangle::boundingRect
|
||||||
@return Bounding rectangle this part can fit into
|
@return Bounding rectangle this part can fit into
|
||||||
*/
|
*/
|
||||||
QRectF PartRectangle::boundingRect() const
|
QRectF PartRectangle::boundingRect() const
|
||||||
{
|
{
|
||||||
qreal adjust = (SHADOWS_HEIGHT + penWeight()) / 2;
|
qreal adjust = (SHADOWS_HEIGHT + penWeight()) / 2;
|
||||||
//We add 0.5 because CustomElementGraphicPart::drawShadowShape
|
//We add 0.5 because CustomElementGraphicPart::drawShadowShape
|
||||||
//draw a shape bigger of 0.5 when pen weight is to 0.
|
//draw a shape bigger of 0.5 when pen weight is to 0.
|
||||||
if (penWeight() == 0) adjust += 0.5;
|
if (penWeight() == 0) adjust += 0.5;
|
||||||
|
|
||||||
QRectF r = m_rect.normalized();
|
QRectF r = m_rect.normalized();
|
||||||
r.adjust(-adjust, -adjust, adjust, adjust);
|
r.adjust(-adjust, -adjust, adjust, adjust);
|
||||||
|
|
||||||
return(r);
|
return(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::isUseless
|
@brief PartRectangle::isUseless
|
||||||
@return true if this part is irrelevant and does not deserve to be Retained / registered.
|
@return true if this part is irrelevant and does not deserve to be Retained / registered.
|
||||||
An rectangle is relevant when he's not null.
|
An rectangle is relevant when he's not null.
|
||||||
*/
|
*/
|
||||||
bool PartRectangle::isUseless() const
|
bool PartRectangle::isUseless() const
|
||||||
{
|
{
|
||||||
return(rect().isNull());
|
return(rect().isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::startUserTransformation
|
@brief PartRectangle::startUserTransformation
|
||||||
Start the user-induced transformation, provided this primitive is contained
|
Start the user-induced transformation, provided this primitive is contained
|
||||||
within the initial_selection_rect bounding rectangle.
|
within the initial_selection_rect bounding rectangle.
|
||||||
@param initial_selection_rect
|
@param initial_selection_rect
|
||||||
*/
|
*/
|
||||||
void PartRectangle::startUserTransformation(const QRectF &initial_selection_rect)
|
void PartRectangle::startUserTransformation(const QRectF &initial_selection_rect)
|
||||||
{
|
{
|
||||||
Q_UNUSED(initial_selection_rect)
|
Q_UNUSED(initial_selection_rect)
|
||||||
// we keep track of our own rectangle at the moment in scene coordinates too
|
// we keep track of our own rectangle at the moment in scene coordinates too
|
||||||
saved_points_.clear();
|
saved_points_.clear();
|
||||||
saved_points_ << mapToScene(rect().topLeft()) << mapToScene(rect().bottomRight());
|
saved_points_ << mapToScene(rect().topLeft()) << mapToScene(rect().bottomRight());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::handleUserTransformation
|
@brief PartRectangle::handleUserTransformation
|
||||||
Handle the user-induced transformation from \a initial_selection_rect to \a new_selection_rect
|
Handle the user-induced transformation from \a initial_selection_rect to \a new_selection_rect
|
||||||
@param initial_selection_rect
|
@param initial_selection_rect
|
||||||
@param new_selection_rect
|
@param new_selection_rect
|
||||||
*/
|
*/
|
||||||
void PartRectangle::handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect)
|
void PartRectangle::handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect)
|
||||||
{
|
{
|
||||||
QList<QPointF> mapped_points = mapPoints(initial_selection_rect, new_selection_rect, saved_points_);
|
QList<QPointF> mapped_points = mapPoints(initial_selection_rect, new_selection_rect, saved_points_);
|
||||||
setRect(QRectF(mapFromScene(mapped_points.at(0)), mapFromScene(mapped_points.at(1))));
|
setRect(QRectF(mapFromScene(mapped_points.at(0)), mapFromScene(mapped_points.at(1))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::mouseReleaseEvent
|
@brief PartRectangle::mouseReleaseEvent
|
||||||
Handle mouse release event
|
Handle mouse release event
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void PartRectangle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void PartRectangle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && event->buttonDownPos(Qt::LeftButton) == event->pos())
|
if (event->button() == Qt::LeftButton && event->buttonDownPos(Qt::LeftButton) == event->pos())
|
||||||
switchResizeMode();
|
switchResizeMode();
|
||||||
|
|
||||||
CustomElementGraphicPart::mouseReleaseEvent(event);
|
CustomElementGraphicPart::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::itemChange
|
@brief PartRectangle::itemChange
|
||||||
@param change
|
@param change
|
||||||
@param value
|
@param value
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
QVariant PartRectangle::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
QVariant PartRectangle::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||||
{
|
{
|
||||||
if (change == ItemSelectedHasChanged && scene())
|
if (change == ItemSelectedHasChanged && scene())
|
||||||
{
|
{
|
||||||
if (value.toBool() == true)
|
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,
|
//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.
|
//according to the number of selected items.
|
||||||
connect(scene(), &QGraphicsScene::selectionChanged, this, &PartRectangle::sceneSelectionChanged);
|
connect(scene(), &QGraphicsScene::selectionChanged, this, &PartRectangle::sceneSelectionChanged);
|
||||||
|
|
||||||
if (scene()->selectedItems().size() == 1)
|
if (scene()->selectedItems().size() == 1)
|
||||||
addHandler();
|
addHandler();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartRectangle::sceneSelectionChanged);
|
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartRectangle::sceneSelectionChanged);
|
||||||
removeHandler();
|
removeHandler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (change == ItemPositionHasChanged)
|
else if (change == ItemPositionHasChanged)
|
||||||
{
|
{
|
||||||
adjusteHandlerPos();
|
adjusteHandlerPos();
|
||||||
}
|
}
|
||||||
else if (change == ItemSceneChange)
|
else if (change == ItemSceneChange)
|
||||||
{
|
{
|
||||||
if(scene())
|
if(scene())
|
||||||
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartRectangle::sceneSelectionChanged);
|
disconnect(scene(), &QGraphicsScene::selectionChanged, this, &PartRectangle::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 PartRectangle::sceneEventFilter
|
@brief PartRectangle::sceneEventFilter
|
||||||
@param watched
|
@param watched
|
||||||
@param event
|
@param event
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
bool PartRectangle::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
bool PartRectangle::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
//Watched must be an handler
|
//Watched must be an handler
|
||||||
if(watched->type() == QetGraphicsHandlerItem::Type)
|
if(watched->type() == QetGraphicsHandlerItem::Type)
|
||||||
{
|
{
|
||||||
QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched);
|
QetGraphicsHandlerItem *qghi = qgraphicsitem_cast<QetGraphicsHandlerItem *>(watched);
|
||||||
|
|
||||||
if(m_handler_vector.contains(qghi)) //Handler must be in m_vector_index, then we can start resize
|
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);
|
m_vector_index = m_handler_vector.indexOf(qghi);
|
||||||
if (m_vector_index != -1)
|
if (m_vector_index != -1)
|
||||||
{
|
{
|
||||||
if(event->type() == QEvent::GraphicsSceneMousePress) //Click
|
if(event->type() == QEvent::GraphicsSceneMousePress) //Click
|
||||||
{
|
{
|
||||||
handlerMousePressEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
handlerMousePressEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(event->type() == QEvent::GraphicsSceneMouseMove) //Move
|
else if(event->type() == QEvent::GraphicsSceneMouseMove) //Move
|
||||||
{
|
{
|
||||||
handlerMouseMoveEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
handlerMouseMoveEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (event->type() == QEvent::GraphicsSceneMouseRelease) //Release
|
else if (event->type() == QEvent::GraphicsSceneMouseRelease) //Release
|
||||||
{
|
{
|
||||||
handlerMouseReleaseEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
handlerMouseReleaseEvent(qghi, static_cast<QGraphicsSceneMouseEvent *>(event));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::switchResizeMode
|
@brief PartRectangle::switchResizeMode
|
||||||
*/
|
*/
|
||||||
void PartRectangle::switchResizeMode()
|
void PartRectangle::switchResizeMode()
|
||||||
{
|
{
|
||||||
if (m_resize_mode == 1)
|
if (m_resize_mode == 1)
|
||||||
{
|
{
|
||||||
m_resize_mode = 2;
|
m_resize_mode = 2;
|
||||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
for (QetGraphicsHandlerItem *qghi : m_handler_vector)
|
||||||
qghi->setColor(Qt::darkGreen);
|
qghi->setColor(Qt::darkGreen);
|
||||||
}
|
}
|
||||||
else if (m_resize_mode == 2)
|
else if (m_resize_mode == 2)
|
||||||
{
|
{
|
||||||
m_resize_mode = 3;
|
m_resize_mode = 3;
|
||||||
qDeleteAll(m_handler_vector);
|
qDeleteAll(m_handler_vector);
|
||||||
m_handler_vector.clear();
|
m_handler_vector.clear();
|
||||||
addHandler();
|
addHandler();
|
||||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
||||||
qghi->setColor(Qt::magenta);
|
qghi->setColor(Qt::magenta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_resize_mode == 3)
|
else if (m_resize_mode == 3)
|
||||||
{
|
{
|
||||||
m_resize_mode = 1;
|
m_resize_mode = 1;
|
||||||
qDeleteAll(m_handler_vector);
|
qDeleteAll(m_handler_vector);
|
||||||
m_handler_vector.clear();
|
m_handler_vector.clear();
|
||||||
addHandler();
|
addHandler();
|
||||||
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
for (QetGraphicsHandlerItem *qghi : m_handler_vector) {
|
||||||
qghi->setColor(Qt::blue);
|
qghi->setColor(Qt::blue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::adjusteHandlerPos
|
@brief PartRectangle::adjusteHandlerPos
|
||||||
*/
|
*/
|
||||||
void PartRectangle::adjusteHandlerPos()
|
void PartRectangle::adjusteHandlerPos()
|
||||||
{
|
{
|
||||||
if (m_handler_vector.isEmpty()) {
|
if (m_handler_vector.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector <QPointF> points_vector;
|
QVector <QPointF> points_vector;
|
||||||
|
|
||||||
if(m_resize_mode != 3) {
|
if(m_resize_mode != 3) {
|
||||||
points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect);
|
points_vector = QetGraphicsHandlerUtility::pointsForRect(m_rect);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
points_vector = QetGraphicsHandlerUtility::pointForRadiusRect(m_rect, m_xRadius, m_yRadius);
|
points_vector = QetGraphicsHandlerUtility::pointForRadiusRect(m_rect, m_xRadius, m_yRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_handler_vector.size() == points_vector.size())
|
if (m_handler_vector.size() == points_vector.size())
|
||||||
{
|
{
|
||||||
points_vector = mapToScene(points_vector);
|
points_vector = mapToScene(points_vector);
|
||||||
for (int i = 0 ; i < points_vector.size() ; ++i)
|
for (int i = 0 ; i < points_vector.size() ; ++i)
|
||||||
m_handler_vector.at(i)->setPos(points_vector.at(i));
|
m_handler_vector.at(i)->setPos(points_vector.at(i));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDeleteAll(m_handler_vector);
|
qDeleteAll(m_handler_vector);
|
||||||
m_handler_vector.clear();
|
m_handler_vector.clear();
|
||||||
addHandler();
|
addHandler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::handlerMousePressEvent
|
@brief PartRectangle::handlerMousePressEvent
|
||||||
@param qghi
|
@param qghi
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void PartRectangle::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
void PartRectangle::handlerMousePressEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(qghi)
|
Q_UNUSED(qghi)
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
|
|
||||||
m_old_rect = m_rect;
|
m_old_rect = m_rect;
|
||||||
m_old_xRadius = m_xRadius;
|
m_old_xRadius = m_xRadius;
|
||||||
m_old_yRadius = m_yRadius;
|
m_old_yRadius = m_yRadius;
|
||||||
if(m_xRadius == 0 && m_yRadius == 0) {
|
if(m_xRadius == 0 && m_yRadius == 0) {
|
||||||
m_modifie_radius_equaly = true;
|
m_modifie_radius_equaly = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::handlerMouseMoveEvent
|
@brief PartRectangle::handlerMouseMoveEvent
|
||||||
@param qghi
|
@param qghi
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void PartRectangle::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
void PartRectangle::handlerMouseMoveEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(qghi)
|
Q_UNUSED(qghi)
|
||||||
|
|
||||||
QPointF new_pos = event->scenePos();
|
QPointF new_pos = event->scenePos();
|
||||||
if (event->modifiers() != Qt::ControlModifier)
|
if (event->modifiers() != Qt::ControlModifier)
|
||||||
new_pos = elementScene()->snapToGrid(event->scenePos());
|
new_pos = elementScene()->snapToGrid(event->scenePos());
|
||||||
new_pos = mapFromScene(new_pos);
|
new_pos = mapFromScene(new_pos);
|
||||||
|
|
||||||
if (m_resize_mode == 1)
|
if (m_resize_mode == 1)
|
||||||
setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index));
|
setRect(QetGraphicsHandlerUtility::rectForPosAtIndex(m_rect, new_pos, m_vector_index));
|
||||||
else if (m_resize_mode == 2)
|
else if (m_resize_mode == 2)
|
||||||
setRect(QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(m_rect, new_pos, m_vector_index));
|
setRect(QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(m_rect, new_pos, m_vector_index));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qreal radius = QetGraphicsHandlerUtility::radiusForPosAtIndex(m_rect, new_pos, m_vector_index);
|
qreal radius = QetGraphicsHandlerUtility::radiusForPosAtIndex(m_rect, new_pos, m_vector_index);
|
||||||
if(m_modifie_radius_equaly) {
|
if(m_modifie_radius_equaly) {
|
||||||
setXRadius(radius);
|
setXRadius(radius);
|
||||||
setYRadius(radius);
|
setYRadius(radius);
|
||||||
}
|
}
|
||||||
else if(m_vector_index == 0) {
|
else if(m_vector_index == 0) {
|
||||||
setXRadius(radius);
|
setXRadius(radius);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setYRadius(radius);
|
setYRadius(radius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
adjusteHandlerPos();
|
adjusteHandlerPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartRectangle::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
void PartRectangle::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(qghi)
|
Q_UNUSED(qghi)
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
|
|
||||||
m_modifie_radius_equaly = false;
|
m_modifie_radius_equaly = false;
|
||||||
|
|
||||||
QUndoCommand *undo = new QUndoCommand("Modifier un rectangle");
|
QUndoCommand *undo = new QUndoCommand("Modifier un rectangle");
|
||||||
if (m_old_rect != m_rect) {
|
if (m_old_rect != m_rect) {
|
||||||
QPropertyUndoCommand *u = new QPropertyUndoCommand(this, "rect", QVariant(m_old_rect.normalized()), QVariant(m_rect.normalized()), undo);
|
QPropertyUndoCommand *u = new QPropertyUndoCommand(this, "rect", QVariant(m_old_rect.normalized()), QVariant(m_rect.normalized()), undo);
|
||||||
u->setAnimated(true, false);
|
u->setAnimated(true, false);
|
||||||
}
|
}
|
||||||
if (m_old_xRadius != m_xRadius) {
|
if (m_old_xRadius != m_xRadius) {
|
||||||
QPropertyUndoCommand *u = new QPropertyUndoCommand(this, "xRadius", QVariant(m_old_xRadius), QVariant(m_xRadius), undo);
|
QPropertyUndoCommand *u = new QPropertyUndoCommand(this, "xRadius", QVariant(m_old_xRadius), QVariant(m_xRadius), undo);
|
||||||
u->setAnimated();
|
u->setAnimated();
|
||||||
}
|
}
|
||||||
if (m_old_yRadius != m_yRadius) {
|
if (m_old_yRadius != m_yRadius) {
|
||||||
QPropertyUndoCommand *u = new QPropertyUndoCommand(this, "yRadius", QVariant(m_old_yRadius), QVariant(m_yRadius), undo);
|
QPropertyUndoCommand *u = new QPropertyUndoCommand(this, "yRadius", QVariant(m_old_yRadius), QVariant(m_yRadius), undo);
|
||||||
u->setAnimated();
|
u->setAnimated();
|
||||||
}
|
}
|
||||||
|
|
||||||
elementScene()->undoStack().push(undo);
|
elementScene()->undoStack().push(undo);
|
||||||
m_vector_index = -1;
|
m_vector_index = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::sceneSelectionChanged
|
@brief PartRectangle::sceneSelectionChanged
|
||||||
When the scene selection change, if there are several primitive selected, we remove the handler of this item
|
When the scene selection change, if there are several primitive selected, we remove the handler of this item
|
||||||
*/
|
*/
|
||||||
void PartRectangle::sceneSelectionChanged()
|
void PartRectangle::sceneSelectionChanged()
|
||||||
{
|
{
|
||||||
if (this->isSelected() && scene()->selectedItems().size() == 1)
|
if (this->isSelected() && scene()->selectedItems().size() == 1)
|
||||||
addHandler();
|
addHandler();
|
||||||
else
|
else
|
||||||
removeHandler();
|
removeHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::addHandler
|
@brief PartRectangle::addHandler
|
||||||
Add handlers for this item
|
Add handlers for this item
|
||||||
*/
|
*/
|
||||||
void PartRectangle::addHandler()
|
void PartRectangle::addHandler()
|
||||||
{
|
{
|
||||||
if (m_handler_vector.isEmpty() && scene())
|
if (m_handler_vector.isEmpty() && scene())
|
||||||
{
|
{
|
||||||
if (m_resize_mode != 3) {
|
if (m_resize_mode != 3) {
|
||||||
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
|
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointsForRect(m_rect)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointForRadiusRect(m_rect, m_xRadius, m_yRadius)));
|
m_handler_vector = QetGraphicsHandlerItem::handlerForPoint(mapToScene(QetGraphicsHandlerUtility::pointForRadiusRect(m_rect, m_xRadius, m_yRadius)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QetGraphicsHandlerItem *handler : m_handler_vector)
|
for (QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||||
{
|
{
|
||||||
QColor color;
|
QColor color;
|
||||||
if(m_resize_mode == 1) {color = Qt::blue;}
|
if(m_resize_mode == 1) {color = Qt::blue;}
|
||||||
else if (m_resize_mode == 2) {color = Qt::darkGreen;}
|
else if (m_resize_mode == 2) {color = Qt::darkGreen;}
|
||||||
else {color = Qt::magenta;}
|
else {color = Qt::magenta;}
|
||||||
|
|
||||||
handler->setColor(color);
|
handler->setColor(color);
|
||||||
scene()->addItem(handler);
|
scene()->addItem(handler);
|
||||||
handler->installSceneEventFilter(this);
|
handler->installSceneEventFilter(this);
|
||||||
handler->setZValue(this->zValue()+1);
|
handler->setZValue(this->zValue()+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartRectangle::removeHandler
|
@brief PartRectangle::removeHandler
|
||||||
Remove the handlers of this item
|
Remove the handlers of this item
|
||||||
*/
|
*/
|
||||||
void PartRectangle::removeHandler()
|
void PartRectangle::removeHandler()
|
||||||
{
|
{
|
||||||
if (!m_handler_vector.isEmpty())
|
if (!m_handler_vector.isEmpty())
|
||||||
{
|
{
|
||||||
qDeleteAll(m_handler_vector);
|
qDeleteAll(m_handler_vector);
|
||||||
m_handler_vector.clear();
|
m_handler_vector.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef PART_RECTANGLE_H
|
#ifndef PART_RECTANGLE_H
|
||||||
#define PART_RECTANGLE_H
|
#define PART_RECTANGLE_H
|
||||||
@@ -23,92 +23,92 @@
|
|||||||
class QetGraphicsHandlerItem;
|
class QetGraphicsHandlerItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class represents a rectangle primitive which may be used to compose the
|
This class represents a rectangle primitive which may be used to compose the
|
||||||
drawing of an electrical element within the element editor.
|
drawing of an electrical element within the element editor.
|
||||||
All coordinates is in item coordinate, except pos()
|
All coordinates is in item coordinate, except pos()
|
||||||
*/
|
*/
|
||||||
class PartRectangle : public CustomElementGraphicPart
|
class PartRectangle : public CustomElementGraphicPart
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QRectF rect READ rect WRITE setRect)
|
Q_PROPERTY(QRectF rect READ rect WRITE setRect)
|
||||||
Q_PROPERTY(qreal xRadius READ XRadius WRITE setXRadius NOTIFY XRadiusChanged)
|
Q_PROPERTY(qreal xRadius READ XRadius WRITE setXRadius NOTIFY XRadiusChanged)
|
||||||
Q_PROPERTY(qreal yRadius READ YRadius WRITE setYRadius NOTIFY YRadiusChanged)
|
Q_PROPERTY(qreal yRadius READ YRadius WRITE setYRadius NOTIFY YRadiusChanged)
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
PartRectangle(QETElementEditor *, QGraphicsItem *parent = nullptr);
|
PartRectangle(QETElementEditor *, QGraphicsItem *parent = nullptr);
|
||||||
~PartRectangle() override;
|
~PartRectangle() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PartRectangle(const PartRectangle &);
|
PartRectangle(const PartRectangle &);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void rectChanged();
|
void rectChanged();
|
||||||
void XRadiusChanged();
|
void XRadiusChanged();
|
||||||
void YRadiusChanged();
|
void YRadiusChanged();
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1109 };
|
enum { Type = UserType + 1109 };
|
||||||
/**
|
/**
|
||||||
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartRectangle.
|
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartRectangle.
|
||||||
@return the QGraphicsItem type
|
@return the QGraphicsItem type
|
||||||
*/
|
*/
|
||||||
int type () const override { return Type; }
|
int type () const override { return Type; }
|
||||||
void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||||
QString name () const override { return(QObject::tr("rectangle", "element part name")); }
|
QString name () const override { return(QObject::tr("rectangle", "element part name")); }
|
||||||
|
|
||||||
QString xmlName () const override { return(QString("rect")); }
|
QString xmlName () const override { return(QString("rect")); }
|
||||||
QDomElement toXml (QDomDocument &) const override;
|
QDomElement toXml (QDomDocument &) const override;
|
||||||
bool fromXml (const QDomElement &) override;
|
bool fromXml (const QDomElement &) override;
|
||||||
static bool valideXml(QDomElement& element);
|
static bool valideXml(QDomElement& element);
|
||||||
|
|
||||||
QRectF rect() const;
|
QRectF rect() const;
|
||||||
void setRect(const QRectF &rect);
|
void setRect(const QRectF &rect);
|
||||||
qreal XRadius() const {return m_xRadius;}
|
qreal XRadius() const {return m_xRadius;}
|
||||||
void setXRadius(qreal X);
|
void setXRadius(qreal X);
|
||||||
qreal YRadius() const {return m_yRadius;}
|
qreal YRadius() const {return m_yRadius;}
|
||||||
void setYRadius(qreal Y);
|
void setYRadius(qreal Y);
|
||||||
|
|
||||||
QRectF sceneGeometricRect() const override;
|
QRectF sceneGeometricRect() const override;
|
||||||
virtual QPointF sceneTopLeft() const;
|
virtual QPointF sceneTopLeft() const;
|
||||||
|
|
||||||
QPainterPath shape () const override;
|
QPainterPath shape () const override;
|
||||||
QPainterPath shadowShape() const override;
|
QPainterPath shadowShape() const override;
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
bool isUseless() const override;
|
bool isUseless() const override;
|
||||||
|
|
||||||
void startUserTransformation(const QRectF &) override;
|
void startUserTransformation(const QRectF &) override;
|
||||||
void handleUserTransformation(const QRectF &, const QRectF &) override;
|
void handleUserTransformation(const QRectF &, const QRectF &) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void switchResizeMode();
|
void switchResizeMode();
|
||||||
void adjusteHandlerPos();
|
void adjusteHandlerPos();
|
||||||
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event);
|
||||||
void sceneSelectionChanged ();
|
void sceneSelectionChanged ();
|
||||||
|
|
||||||
void addHandler();
|
void addHandler();
|
||||||
void removeHandler();
|
void removeHandler();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRectF m_rect,
|
QRectF m_rect,
|
||||||
m_old_rect;
|
m_old_rect;
|
||||||
QList<QPointF> saved_points_;
|
QList<QPointF> saved_points_;
|
||||||
int m_resize_mode = 1,
|
int m_resize_mode = 1,
|
||||||
m_vector_index = -1;
|
m_vector_index = -1;
|
||||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||||
qreal m_xRadius = 0,
|
qreal m_xRadius = 0,
|
||||||
m_yRadius = 0,
|
m_yRadius = 0,
|
||||||
m_old_xRadius,
|
m_old_xRadius,
|
||||||
m_old_yRadius;
|
m_old_yRadius;
|
||||||
bool m_modifie_radius_equaly = false;
|
bool m_modifie_radius_equaly = false;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,39 +1,39 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "partterminal.h"
|
#include "partterminal.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartTerminal::PartTerminal
|
@brief PartTerminal::PartTerminal
|
||||||
@param editor :
|
@param editor :
|
||||||
L'editeur d'element concerne
|
L'editeur d'element concerne
|
||||||
@param parent :
|
@param parent :
|
||||||
Le QGraphicsItem parent de cette borne
|
Le QGraphicsItem parent de cette borne
|
||||||
*/
|
*/
|
||||||
PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent) :
|
PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||||
CustomElementGraphicPart(editor, parent)
|
CustomElementGraphicPart(editor, parent)
|
||||||
{
|
{
|
||||||
d = new TerminalData(this);
|
d = new TerminalData(this);
|
||||||
d->m_name = tr("terminal");
|
d->m_name = tr("terminal");
|
||||||
d -> m_orientation = Qet::North;
|
d -> m_orientation = Qet::North;
|
||||||
d -> m_uuid = QUuid::createUuid(); // if part is loaded this uuid will be overwritten, but being sure that terminal has a uuid
|
d -> m_uuid = QUuid::createUuid(); // if part is loaded this uuid will be overwritten, but being sure that terminal has a uuid
|
||||||
updateSecondPoint();
|
updateSecondPoint();
|
||||||
setZValue(100000);
|
setZValue(100000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
@@ -42,208 +42,208 @@ PartTerminal::~PartTerminal()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Importe les proprietes d'une borne depuis un element XML
|
Importe les proprietes d'une borne depuis un element XML
|
||||||
@param xml_elmt Element XML a lire
|
@param xml_elmt Element XML a lire
|
||||||
*/
|
*/
|
||||||
bool PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
bool PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
||||||
|
|
||||||
QUuid uuid;
|
QUuid uuid;
|
||||||
// update part and add uuid, which is used in the new version to connect terminals together
|
// update part and add uuid, which is used in the new version to connect terminals together
|
||||||
// if the attribute not exists, means, the element is created with an older version of qet. So use the legacy approach
|
// if the attribute not exists, means, the element is created with an older version of qet. So use the legacy approach
|
||||||
// to identify terminals
|
// to identify terminals
|
||||||
propertyUuid(xml_elmt, "uuid", &d->m_uuid);
|
propertyUuid(xml_elmt, "uuid", &d->m_uuid);
|
||||||
|
|
||||||
if (!d->fromXml(xml_elmt))
|
if (!d->fromXml(xml_elmt))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
setPos(d -> m_pos);
|
setPos(d -> m_pos);
|
||||||
updateSecondPoint();
|
updateSecondPoint();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Exporte la borne en XML
|
Exporte la borne en XML
|
||||||
@param xml_document Document XML a utiliser pour creer l'element XML
|
@param xml_document Document XML a utiliser pour creer l'element XML
|
||||||
@return un element XML decrivant la borne
|
@return un element XML decrivant la borne
|
||||||
*/
|
*/
|
||||||
QDomElement PartTerminal::toXml(QDomDocument &xml_document) const {
|
QDomElement PartTerminal::toXml(QDomDocument &xml_document) const {
|
||||||
|
|
||||||
QDomElement qdo = xml_document.createElement("terminal");
|
QDomElement qdo = xml_document.createElement("terminal");
|
||||||
|
|
||||||
qdo.appendChild(createXmlProperty(xml_document, "uuid", d->m_uuid));
|
qdo.appendChild(createXmlProperty(xml_document, "uuid", d->m_uuid));
|
||||||
|
|
||||||
d->m_pos = pos();
|
d->m_pos = pos();
|
||||||
|
|
||||||
// Do not store terminal data in its own child
|
// Do not store terminal data in its own child
|
||||||
QDomElement terminalDataElement = d->toXml(xml_document);
|
QDomElement terminalDataElement = d->toXml(xml_document);
|
||||||
for (int i=0; i < terminalDataElement.childNodes().length(); i++) {
|
for (int i=0; i < terminalDataElement.childNodes().length(); i++) {
|
||||||
qdo.appendChild(terminalDataElement.childNodes().at(i).cloneNode()); // cloneNode() is important, otherwise no deep clone is made
|
qdo.appendChild(terminalDataElement.childNodes().at(i).cloneNode()); // cloneNode() is important, otherwise no deep clone is made
|
||||||
}
|
}
|
||||||
|
|
||||||
return qdo;
|
return qdo;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PartTerminal::valideXml(QDomElement& element) {
|
bool PartTerminal::valideXml(QDomElement& element) {
|
||||||
return TerminalData::valideXml(element);
|
return TerminalData::valideXml(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Dessine la borne
|
Dessine la borne
|
||||||
@param painter QPainter a utiliser pour rendre le dessin
|
@param painter QPainter a utiliser pour rendre le dessin
|
||||||
@param options Options pour affiner le rendu
|
@param options Options pour affiner le rendu
|
||||||
@param widget Widget sur lequel le rendu est effectue
|
@param widget Widget sur lequel le rendu est effectue
|
||||||
*/
|
*/
|
||||||
void PartTerminal::paint(
|
void PartTerminal::paint(
|
||||||
QPainter *painter,
|
QPainter *painter,
|
||||||
const QStyleOptionGraphicsItem *options,
|
const QStyleOptionGraphicsItem *options,
|
||||||
QWidget *widget)
|
QWidget *widget)
|
||||||
{
|
{
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
painter -> save();
|
painter -> save();
|
||||||
|
|
||||||
// annulation des renderhints
|
// annulation des renderhints
|
||||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||||
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||||
|
|
||||||
QPen t;
|
QPen t;
|
||||||
t.setWidthF(1.0);
|
t.setWidthF(1.0);
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
||||||
#else
|
#else
|
||||||
#if TODO_LIST
|
#if TODO_LIST
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
#pragma message("@TODO remove code for QT 6 or later")
|
||||||
#endif
|
#endif
|
||||||
t.setCosmetic(
|
t.setCosmetic(
|
||||||
options
|
options
|
||||||
&& options->levelOfDetailFromTransform(
|
&& options->levelOfDetailFromTransform(
|
||||||
painter->worldTransform())
|
painter->worldTransform())
|
||||||
< 1.0);
|
< 1.0);
|
||||||
#endif
|
#endif
|
||||||
// dessin de la borne en rouge
|
// dessin de la borne en rouge
|
||||||
t.setColor(isSelected() ? Terminal::neutralColor : Qt::red);
|
t.setColor(isSelected() ? Terminal::neutralColor : Qt::red);
|
||||||
painter -> setPen(t);
|
painter -> setPen(t);
|
||||||
painter -> drawLine(QPointF(0.0, 0.0), d -> second_point);
|
painter -> drawLine(QPointF(0.0, 0.0), d -> second_point);
|
||||||
|
|
||||||
// dessin du point d'amarrage au conducteur en bleu
|
// dessin du point d'amarrage au conducteur en bleu
|
||||||
t.setColor(isSelected() ? Qt::red : Terminal::neutralColor);
|
t.setColor(isSelected() ? Qt::red : Terminal::neutralColor);
|
||||||
painter -> setPen(t);
|
painter -> setPen(t);
|
||||||
painter -> setBrush(Terminal::neutralColor);
|
painter -> setBrush(Terminal::neutralColor);
|
||||||
painter -> drawPoint(QPointF(0.0, 0.0));
|
painter -> drawPoint(QPointF(0.0, 0.0));
|
||||||
painter -> restore();
|
painter -> restore();
|
||||||
|
|
||||||
if (m_hovered)
|
if (m_hovered)
|
||||||
drawShadowShape(painter);
|
drawShadowShape(painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartTerminal::shape
|
@brief PartTerminal::shape
|
||||||
@return the shape of this item
|
@return the shape of this item
|
||||||
*/
|
*/
|
||||||
QPainterPath PartTerminal::shape() const
|
QPainterPath PartTerminal::shape() const
|
||||||
{
|
{
|
||||||
QPainterPath shape;
|
QPainterPath shape;
|
||||||
shape.lineTo(d -> second_point);
|
shape.lineTo(d -> second_point);
|
||||||
|
|
||||||
QPainterPathStroker pps;
|
QPainterPathStroker pps;
|
||||||
pps.setWidth(1);
|
pps.setWidth(1);
|
||||||
|
|
||||||
return (pps.createStroke(shape));
|
return (pps.createStroke(shape));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartTerminal::boundingRect
|
@brief PartTerminal::boundingRect
|
||||||
@return the bounding rect of this item
|
@return the bounding rect of this item
|
||||||
*/
|
*/
|
||||||
QRectF PartTerminal::boundingRect() const
|
QRectF PartTerminal::boundingRect() const
|
||||||
{
|
{
|
||||||
QRectF br(QPointF(0, 0), d -> second_point);
|
QRectF br(QPointF(0, 0), d -> second_point);
|
||||||
br = br.normalized();
|
br = br.normalized();
|
||||||
|
|
||||||
qreal adjust = (SHADOWS_HEIGHT + 1) / 2;
|
qreal adjust = (SHADOWS_HEIGHT + 1) / 2;
|
||||||
br.adjust(-adjust, -adjust, adjust, adjust);
|
br.adjust(-adjust, -adjust, adjust, adjust);
|
||||||
return(br);
|
return(br);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Definit l'orientation de la borne
|
Definit l'orientation de la borne
|
||||||
@param ori la nouvelle orientation de la borne
|
@param ori la nouvelle orientation de la borne
|
||||||
*/
|
*/
|
||||||
void PartTerminal::setOrientation(Qet::Orientation ori) {
|
void PartTerminal::setOrientation(Qet::Orientation ori) {
|
||||||
if (d -> m_orientation == ori) return;
|
if (d -> m_orientation == ori) return;
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
d -> m_orientation = ori;
|
d -> m_orientation = ori;
|
||||||
updateSecondPoint();
|
updateSecondPoint();
|
||||||
emit orientationChanged();
|
emit orientationChanged();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@brief PartTerminal::setName
|
@brief PartTerminal::setName
|
||||||
@param name
|
@param name
|
||||||
*/
|
*/
|
||||||
void PartTerminal::setName(QString& name) {
|
void PartTerminal::setName(QString& name) {
|
||||||
if (d -> m_name == name) return;
|
if (d -> m_name == name) return;
|
||||||
d -> m_name = name;
|
d -> m_name = name;
|
||||||
emit nameChanged();
|
emit nameChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartTerminal::setNewUuid()
|
void PartTerminal::setNewUuid()
|
||||||
{
|
{
|
||||||
d -> m_uuid = QUuid::createUuid();
|
d -> m_uuid = QUuid::createUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Met a jour la position du second point en fonction de la position et de
|
Met a jour la position du second point en fonction de la position et de
|
||||||
l'orientation de la borne.
|
l'orientation de la borne.
|
||||||
*/
|
*/
|
||||||
void PartTerminal::updateSecondPoint()
|
void PartTerminal::updateSecondPoint()
|
||||||
{
|
{
|
||||||
qreal ts = 4.0; // terminal size
|
qreal ts = 4.0; // terminal size
|
||||||
switch(d -> m_orientation) {
|
switch(d -> m_orientation) {
|
||||||
case Qet::North: d -> second_point = QPointF(0.0, ts); break;
|
case Qet::North: d -> second_point = QPointF(0.0, ts); break;
|
||||||
case Qet::East : d -> second_point = QPointF(-ts, 0.0); break;
|
case Qet::East : d -> second_point = QPointF(-ts, 0.0); break;
|
||||||
case Qet::South: d -> second_point = QPointF(0.0, -ts); break;
|
case Qet::South: d -> second_point = QPointF(0.0, -ts); break;
|
||||||
case Qet::West : d -> second_point = QPointF(ts, 0.0); break;
|
case Qet::West : d -> second_point = QPointF(ts, 0.0); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return true si cette partie n'est pas pertinente et ne merite pas d'etre
|
@return true si cette partie n'est pas pertinente et ne merite pas d'etre
|
||||||
conservee / enregistree.
|
conservee / enregistree.
|
||||||
Une borne est toujours pertinente ; cette fonction renvoie donc
|
Une borne est toujours pertinente ; cette fonction renvoie donc
|
||||||
toujours false
|
toujours false
|
||||||
*/
|
*/
|
||||||
bool PartTerminal::isUseless() const
|
bool PartTerminal::isUseless() const
|
||||||
{
|
{
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return the minimum, margin-less rectangle this part can fit into, in scene
|
@return the minimum, margin-less rectangle this part can fit into, in scene
|
||||||
coordinates. It is different from boundingRect() because it is not supposed
|
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
|
to imply any margin, and it is different from shape because it is a regular
|
||||||
rectangle, not a complex shape.
|
rectangle, not a complex shape.
|
||||||
*/
|
*/
|
||||||
QRectF PartTerminal::sceneGeometricRect() const
|
QRectF PartTerminal::sceneGeometricRect() const
|
||||||
{
|
{
|
||||||
return(sceneBoundingRect());
|
return(sceneBoundingRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Start the user-induced transformation, provided this primitive is contained
|
Start the user-induced transformation, provided this primitive is contained
|
||||||
within the \a initial_selection_rect bounding rectangle.
|
within the \a initial_selection_rect bounding rectangle.
|
||||||
*/
|
*/
|
||||||
void PartTerminal::startUserTransformation(const QRectF &initial_selection_rect) {
|
void PartTerminal::startUserTransformation(const QRectF &initial_selection_rect) {
|
||||||
Q_UNUSED(initial_selection_rect)
|
Q_UNUSED(initial_selection_rect)
|
||||||
saved_position_ = scenePos();
|
saved_position_ = scenePos();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Handle the user-induced transformation from \a initial_selection_rect to \a new_selection_rect
|
Handle the user-induced transformation from \a initial_selection_rect to \a new_selection_rect
|
||||||
*/
|
*/
|
||||||
void PartTerminal::handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) {
|
void PartTerminal::handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) {
|
||||||
QPointF mapped_point = mapPoints(
|
QPointF mapped_point = mapPoints(
|
||||||
initial_selection_rect, new_selection_rect, QList<QPointF>() << saved_position_).first();
|
initial_selection_rect, new_selection_rect, QList<QPointF>() << saved_position_).first();
|
||||||
setPos(mapped_point);
|
setPos(mapped_point);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef PART_TERMINAL_H
|
#ifndef PART_TERMINAL_H
|
||||||
#define PART_TERMINAL_H
|
#define PART_TERMINAL_H
|
||||||
@@ -24,62 +24,62 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class represents a terminal which may be used to compose the drawing of
|
This class represents a terminal which may be used to compose the drawing of
|
||||||
an electrical element within the element editor.
|
an electrical element within the element editor.
|
||||||
*/
|
*/
|
||||||
class PartTerminal : public CustomElementGraphicPart {
|
class PartTerminal : public CustomElementGraphicPart {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Qet::Orientation orientation READ orientation WRITE setOrientation)
|
Q_PROPERTY(Qet::Orientation orientation READ orientation WRITE setOrientation)
|
||||||
Q_PROPERTY(QString name READ name WRITE setName)
|
Q_PROPERTY(QString name READ name WRITE setName)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
PartTerminal(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
|
PartTerminal(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
|
||||||
~PartTerminal() override;
|
~PartTerminal() override;
|
||||||
private:
|
private:
|
||||||
PartTerminal(const PartTerminal &);
|
PartTerminal(const PartTerminal &);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void orientationChanged();
|
void orientationChanged();
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1106 };
|
enum { Type = UserType + 1106 };
|
||||||
/**
|
/**
|
||||||
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartTerminal.
|
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartTerminal.
|
||||||
@return the QGraphicsItem type
|
@return the QGraphicsItem type
|
||||||
*/
|
*/
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
QString name() const override { return d -> m_name; }
|
QString name() const override { return d -> m_name; }
|
||||||
QString xmlName() const override { return(QString("terminal")); }
|
QString xmlName() const override { return(QString("terminal")); }
|
||||||
bool fromXml(const QDomElement &) override;
|
bool fromXml(const QDomElement &) override;
|
||||||
QDomElement toXml(QDomDocument &) const override;
|
QDomElement toXml(QDomDocument &) const override;
|
||||||
static bool valideXml(QDomElement& element);
|
static bool valideXml(QDomElement& element);
|
||||||
void paint(
|
void paint(
|
||||||
QPainter *painter,
|
QPainter *painter,
|
||||||
const QStyleOptionGraphicsItem *,
|
const QStyleOptionGraphicsItem *,
|
||||||
QWidget *) override;
|
QWidget *) override;
|
||||||
|
|
||||||
QPainterPath shape() const override;
|
QPainterPath shape() const override;
|
||||||
QPainterPath shadowShape() const override {return shape();}
|
QPainterPath shadowShape() const override {return shape();}
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
bool isUseless() const override;
|
bool isUseless() const override;
|
||||||
QRectF sceneGeometricRect() const override;
|
QRectF sceneGeometricRect() const override;
|
||||||
void startUserTransformation(const QRectF &) override;
|
void startUserTransformation(const QRectF &) override;
|
||||||
void handleUserTransformation(const QRectF &, const QRectF &) override;
|
void handleUserTransformation(const QRectF &, const QRectF &) override;
|
||||||
|
|
||||||
Qet::Orientation orientation() const {return d -> m_orientation;}
|
Qet::Orientation orientation() const {return d -> m_orientation;}
|
||||||
void setOrientation(Qet::Orientation ori);
|
void setOrientation(Qet::Orientation ori);
|
||||||
|
|
||||||
void setName(QString& name);
|
void setName(QString& name);
|
||||||
void setNewUuid();
|
void setNewUuid();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateSecondPoint();
|
void updateSecondPoint();
|
||||||
TerminalData* d; // pointer to the terminal data
|
TerminalData* d; // pointer to the terminal data
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointF saved_position_;
|
QPointF saved_position_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "parttext.h"
|
#include "parttext.h"
|
||||||
#include "texteditor.h"
|
#include "texteditor.h"
|
||||||
@@ -23,38 +23,38 @@
|
|||||||
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@param editor L'editeur d'element concerne
|
@param editor L'editeur d'element concerne
|
||||||
@param parent Le QGraphicsItem parent de ce texte statique
|
@param parent Le QGraphicsItem parent de ce texte statique
|
||||||
*/
|
*/
|
||||||
PartText::PartText(QETElementEditor *editor, QGraphicsItem *parent) :
|
PartText::PartText(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||||
QGraphicsTextItem(parent),
|
QGraphicsTextItem(parent),
|
||||||
CustomElementPart(editor),
|
CustomElementPart(editor),
|
||||||
previous_text()
|
previous_text()
|
||||||
{
|
{
|
||||||
document() -> setDocumentMargin(1.0);
|
document() -> setDocumentMargin(1.0);
|
||||||
setDefaultTextColor(Qt::black);
|
setDefaultTextColor(Qt::black);
|
||||||
setFont(QETApp::diagramTextsFont());
|
setFont(QETApp::diagramTextsFont());
|
||||||
real_font_size_ = font().pointSize();
|
real_font_size_ = font().pointSize();
|
||||||
setFlags(QGraphicsItem::ItemIsSelectable
|
setFlags(QGraphicsItem::ItemIsSelectable
|
||||||
| QGraphicsItem::ItemSendsGeometryChanges
|
| QGraphicsItem::ItemSendsGeometryChanges
|
||||||
| QGraphicsItem::ItemIsMovable);
|
| QGraphicsItem::ItemIsMovable);
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
setDefaultTextColor(Qt::black);
|
setDefaultTextColor(Qt::black);
|
||||||
setPlainText(QObject::tr(
|
setPlainText(QObject::tr(
|
||||||
"T",
|
"T",
|
||||||
"default text when adding a text in the element editor"));
|
"default text when adding a text in the element editor"));
|
||||||
|
|
||||||
adjustItemPosition(1);
|
adjustItemPosition(1);
|
||||||
// adjust textfield position after line additions/deletions
|
// adjust textfield position after line additions/deletions
|
||||||
connect(document(),
|
connect(document(),
|
||||||
SIGNAL(blockCountChanged(int)),
|
SIGNAL(blockCountChanged(int)),
|
||||||
this,
|
this,
|
||||||
SLOT(adjustItemPosition(int)));
|
SLOT(adjustItemPosition(int)));
|
||||||
connect(document(),
|
connect(document(),
|
||||||
SIGNAL(contentsChanged()),
|
SIGNAL(contentsChanged()),
|
||||||
this,
|
this,
|
||||||
SLOT(adjustItemPosition()));
|
SLOT(adjustItemPosition()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
@@ -63,346 +63,346 @@ PartText::~PartText()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Importe les proprietes d'un texte statique depuis un element XML
|
Importe les proprietes d'un texte statique depuis un element XML
|
||||||
@param xml_element Element XML a lire
|
@param xml_element Element XML a lire
|
||||||
*/
|
*/
|
||||||
bool PartText::fromXml(const QDomElement &xml_element)
|
bool PartText::fromXml(const QDomElement &xml_element)
|
||||||
int size;
|
int size;
|
||||||
QString font;
|
QString font;
|
||||||
|
|
||||||
if (propertyInteger(xml_element, "size", &size) != PropertyFlags::NotFound)
|
if (propertyInteger(xml_element, "size", &size) != PropertyFlags::NotFound)
|
||||||
{
|
{
|
||||||
if (size < 1) {
|
if (size < 1) {
|
||||||
size = 20;
|
size = 20;
|
||||||
}
|
}
|
||||||
QFont font_ = this -> font();
|
QFont font_ = this -> font();
|
||||||
font_.setPointSize(size);
|
font_.setPointSize(size);
|
||||||
setFont(font_);
|
setFont(font_);
|
||||||
}
|
}
|
||||||
else if (propertyString(xml_element, "font", &font) != PropertyFlags::NotFound)
|
else if (propertyString(xml_element, "font", &font) != PropertyFlags::NotFound)
|
||||||
{
|
{
|
||||||
QFont font_;
|
QFont font_;
|
||||||
font_.fromString(font);
|
font_.fromString(font);
|
||||||
setFont(font_);
|
setFont(font_);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor color;
|
QColor color;
|
||||||
QString text;
|
QString text;
|
||||||
propertyColor(xml_element, "color", &color);
|
propertyColor(xml_element, "color", &color);
|
||||||
setDefaultTextColor(color);
|
setDefaultTextColor(color);
|
||||||
|
|
||||||
|
|
||||||
propertyString(xml_element, "text", &text);
|
propertyString(xml_element, "text", &text);
|
||||||
setPlainText(text);
|
setPlainText(text);
|
||||||
|
|
||||||
double x=0, y=0, rot=0;
|
double x=0, y=0, rot=0;
|
||||||
if (propertyDouble(xml_element, "x", &x) == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(xml_element, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(xml_element, "y", &y) == PropertyFlags::NoValidConversion)
|
propertyDouble(xml_element, "y", &y) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
setPos(x, y);
|
setPos(x, y);
|
||||||
|
|
||||||
if (propertyDouble(xml_element, "rotation", &rot) == PropertyFlags::NoValidConversion)
|
if (propertyDouble(xml_element, "rotation", &rot) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
setRotation(rot);
|
setRotation(rot);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Exporte le texte statique en XML
|
Exporte le texte statique en XML
|
||||||
@param xml_document Document XML a utiliser pour creer l'element XML
|
@param xml_document Document XML a utiliser pour creer l'element XML
|
||||||
@return un element XML decrivant le texte statique
|
@return un element XML decrivant le texte statique
|
||||||
*/
|
*/
|
||||||
QDomElement PartText::toXml(QDomDocument &xml_document) const
|
QDomElement PartText::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement(xmlName());
|
QDomElement xml_element = xml_document.createElement(xmlName());
|
||||||
|
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "x", pos().x()));
|
xml_element.appendChild(createXmlProperty(xml_document, "x", pos().x()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "y", pos().y()));
|
xml_element.appendChild(createXmlProperty(xml_document, "y", pos().y()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "text", toPlainText()));
|
xml_element.appendChild(createXmlProperty(xml_document, "text", toPlainText()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "font", font().toString()));
|
xml_element.appendChild(createXmlProperty(xml_document, "font", font().toString()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "rotation", rotation()));
|
xml_element.appendChild(createXmlProperty(xml_document, "rotation", rotation()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "color", defaultTextColor().name()));
|
xml_element.appendChild(createXmlProperty(xml_document, "color", defaultTextColor().name()));
|
||||||
|
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PartText::valideXml(QDomElement& element) {
|
bool PartText::valideXml(QDomElement& element) {
|
||||||
|
|
||||||
if (propertyInteger(element, "size") == PropertyFlags::NotFound ||
|
if (propertyInteger(element, "size") == PropertyFlags::NotFound ||
|
||||||
propertyString(element, "font") == PropertyFlags::NotFound) {
|
propertyString(element, "font") == PropertyFlags::NotFound) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (propertyString(element, "color") == PropertyFlags::NoValidConversion)
|
if (propertyString(element, "color") == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
if (propertyString(element, "text"))
|
if (propertyString(element, "text"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (propertyDouble(element, "x") == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(element, "x") == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(element, "y") == PropertyFlags::NoValidConversion)
|
propertyDouble(element, "y") == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (propertyDouble(element, "rotation", 0) == PropertyFlags::NoValidConversion)
|
if (propertyDouble(element, "rotation", 0) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return Les coordonnees du point situe en bas a gauche du texte.
|
@return Les coordonnees du point situe en bas a gauche du texte.
|
||||||
*/
|
*/
|
||||||
QPointF PartText::margin() const
|
QPointF PartText::margin() const
|
||||||
{
|
{
|
||||||
QFont used_font = font();
|
QFont used_font = font();
|
||||||
QFontMetrics qfm(used_font);
|
QFontMetrics qfm(used_font);
|
||||||
qreal document_margin = document() -> documentMargin();
|
qreal document_margin = document() -> documentMargin();
|
||||||
|
|
||||||
QPointF margin(
|
QPointF margin(
|
||||||
// marge autour du texte
|
// marge autour du texte
|
||||||
document_margin,
|
document_margin,
|
||||||
// marge au-dessus du texte + distance entre le plafond du texte et la baseline
|
// marge au-dessus du texte + distance entre le plafond du texte et la baseline
|
||||||
document_margin + qfm.ascent()
|
document_margin + qfm.ascent()
|
||||||
);
|
);
|
||||||
return(margin);
|
return(margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartText::focusInEvent
|
@brief PartText::focusInEvent
|
||||||
@param e : The QFocusEvent object describing the focus gain.
|
@param e : The QFocusEvent object describing the focus gain.
|
||||||
Start text edition when the item gains focus.
|
Start text edition when the item gains focus.
|
||||||
@see QGraphicsItem::focusInEvent(QFocusEvent *)
|
@see QGraphicsItem::focusInEvent(QFocusEvent *)
|
||||||
*/
|
*/
|
||||||
void PartText::focusInEvent(QFocusEvent *e) {
|
void PartText::focusInEvent(QFocusEvent *e) {
|
||||||
startEdition();
|
startEdition();
|
||||||
QGraphicsTextItem::focusInEvent(e);
|
QGraphicsTextItem::focusInEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartText::focusOutEvent
|
@brief PartText::focusOutEvent
|
||||||
@param e : The QFocusEvent object describing the focus loss.
|
@param e : The QFocusEvent object describing the focus loss.
|
||||||
End text edition when the item loses focus.
|
End text edition when the item loses focus.
|
||||||
@see QGraphicsItem::focusOutEvent(QFocusEvent *)
|
@see QGraphicsItem::focusOutEvent(QFocusEvent *)
|
||||||
*/
|
*/
|
||||||
void PartText::focusOutEvent(QFocusEvent *e) {
|
void PartText::focusOutEvent(QFocusEvent *e) {
|
||||||
QGraphicsTextItem::focusOutEvent(e);
|
QGraphicsTextItem::focusOutEvent(e);
|
||||||
endEdition();
|
endEdition();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartText::keyPressEvent
|
@brief PartText::keyPressEvent
|
||||||
Used to handle the escape key when the event is delivered to the field,
|
Used to handle the escape key when the event is delivered to the field,
|
||||||
not to the decorator.
|
not to the decorator.
|
||||||
@param event
|
@param event
|
||||||
@see QGraphicsTextItem::keyPressEvent()
|
@see QGraphicsTextItem::keyPressEvent()
|
||||||
*/
|
*/
|
||||||
void PartText::keyPressEvent(QKeyEvent *event) {
|
void PartText::keyPressEvent(QKeyEvent *event) {
|
||||||
if (event -> key() == Qt::Key_Escape) {
|
if (event -> key() == Qt::Key_Escape) {
|
||||||
endEdition();
|
endEdition();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QGraphicsTextItem::keyPressEvent(event);
|
QGraphicsTextItem::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet a l'element texte de devenir editable lorsqu'on double-clique dessus
|
Permet a l'element texte de devenir editable lorsqu'on double-clique dessus
|
||||||
@param e Le QGraphicsSceneMouseEvent qui decrit le double-clic
|
@param e Le QGraphicsSceneMouseEvent qui decrit le double-clic
|
||||||
*/
|
*/
|
||||||
void PartText::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) {
|
void PartText::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) {
|
||||||
QGraphicsTextItem::mouseDoubleClickEvent(e);
|
QGraphicsTextItem::mouseDoubleClickEvent(e);
|
||||||
if (e -> button() == Qt::LeftButton) {
|
if (e -> button() == Qt::LeftButton) {
|
||||||
setEditable(true);
|
setEditable(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gere les changements intervenant sur cette partie
|
Gere les changements intervenant sur cette partie
|
||||||
@param change Type de changement
|
@param change Type de changement
|
||||||
@param value Valeur numerique relative au changement
|
@param value Valeur numerique relative au changement
|
||||||
*/
|
*/
|
||||||
QVariant PartText::itemChange(GraphicsItemChange change, const QVariant &value) {
|
QVariant PartText::itemChange(GraphicsItemChange change, const QVariant &value) {
|
||||||
if (change == QGraphicsItem::ItemPositionHasChanged ||
|
if (change == QGraphicsItem::ItemPositionHasChanged ||
|
||||||
change == QGraphicsItem::ItemSceneHasChanged ||
|
change == QGraphicsItem::ItemSceneHasChanged ||
|
||||||
change == QGraphicsItem::ItemSelectedHasChanged) {
|
change == QGraphicsItem::ItemSelectedHasChanged) {
|
||||||
updateCurrentPartEditor();
|
updateCurrentPartEditor();
|
||||||
}
|
}
|
||||||
return(QGraphicsTextItem::itemChange(change, value));
|
return(QGraphicsTextItem::itemChange(change, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return le rectangle delimitant cette partie.
|
@return le rectangle delimitant cette partie.
|
||||||
*/
|
*/
|
||||||
QRectF PartText::boundingRect() const
|
QRectF PartText::boundingRect() const
|
||||||
{
|
{
|
||||||
QRectF r = QGraphicsTextItem::boundingRect();
|
QRectF r = QGraphicsTextItem::boundingRect();
|
||||||
r.adjust(0.0, -1.1, 0.0, 0.0);
|
r.adjust(0.0, -1.1, 0.0, 0.0);
|
||||||
return(r);
|
return(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return true si cette partie n'est pas pertinente et ne merite pas d'etre
|
@return true si cette partie n'est pas pertinente et ne merite pas d'etre
|
||||||
conservee / enregistree.
|
conservee / enregistree.
|
||||||
Un texte statique n'est pas pertinent lorsque son texte est vide.
|
Un texte statique n'est pas pertinent lorsque son texte est vide.
|
||||||
*/
|
*/
|
||||||
bool PartText::isUseless() const
|
bool PartText::isUseless() const
|
||||||
{
|
{
|
||||||
return(toPlainText().isEmpty());
|
return(toPlainText().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return the minimum, margin-less rectangle this part can fit into, in scene
|
@return the minimum, margin-less rectangle this part can fit into, in scene
|
||||||
coordinates. It is different from boundingRect() because it is not supposed
|
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
|
to imply any margin, and it is different from shape because it is a regular
|
||||||
rectangle, not a complex shape.
|
rectangle, not a complex shape.
|
||||||
*/
|
*/
|
||||||
QRectF PartText::sceneGeometricRect() const
|
QRectF PartText::sceneGeometricRect() const
|
||||||
{
|
{
|
||||||
return(sceneBoundingRect());
|
return(sceneBoundingRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Start the user-induced transformation, provided this primitive is contained
|
Start the user-induced transformation, provided this primitive is contained
|
||||||
within the \a rect bounding rectangle.
|
within the \a rect bounding rectangle.
|
||||||
*/
|
*/
|
||||||
void PartText::startUserTransformation(const QRectF &rect) {
|
void PartText::startUserTransformation(const QRectF &rect) {
|
||||||
Q_UNUSED(rect)
|
Q_UNUSED(rect)
|
||||||
saved_point_ = pos(); // scene coordinates, no need to mapFromScene()
|
saved_point_ = pos(); // scene coordinates, no need to mapFromScene()
|
||||||
saved_font_size_ = real_font_size_;
|
saved_font_size_ = real_font_size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Handle the user-induced transformation from \a initial_selection_rect to \a new_selection_rect
|
Handle the user-induced transformation from \a initial_selection_rect to \a new_selection_rect
|
||||||
*/
|
*/
|
||||||
void PartText::handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) {
|
void PartText::handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) {
|
||||||
// let's try the naive approach
|
// let's try the naive approach
|
||||||
QPointF new_pos = mapPoints(initial_selection_rect, new_selection_rect, QList<QPointF>() << saved_point_).first();
|
QPointF new_pos = mapPoints(initial_selection_rect, new_selection_rect, QList<QPointF>() << saved_point_).first();
|
||||||
setPos(new_pos);
|
setPos(new_pos);
|
||||||
|
|
||||||
// adjust the font size following the vertical scale factor
|
// adjust the font size following the vertical scale factor
|
||||||
qreal sy = new_selection_rect.height() / initial_selection_rect.height();
|
qreal sy = new_selection_rect.height() / initial_selection_rect.height();
|
||||||
qreal new_font_size = saved_font_size_ * sy;
|
qreal new_font_size = saved_font_size_ * sy;
|
||||||
setProperty("real_size", qMax(1, qRound(new_font_size)));
|
setProperty("real_size", qMax(1, qRound(new_font_size)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartText::setDefaultTextColor(const QColor &color) {
|
void PartText::setDefaultTextColor(const QColor &color) {
|
||||||
if (color != this -> defaultTextColor()) {
|
if (color != this -> defaultTextColor()) {
|
||||||
QGraphicsTextItem::setDefaultTextColor(color);
|
QGraphicsTextItem::setDefaultTextColor(color);
|
||||||
emit colorChanged(color);
|
emit colorChanged(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartText::setPlainText(const QString &text) {
|
void PartText::setPlainText(const QString &text) {
|
||||||
if (text != this -> toPlainText()) {
|
if (text != this -> toPlainText()) {
|
||||||
QGraphicsTextItem::setPlainText(text);
|
QGraphicsTextItem::setPlainText(text);
|
||||||
emit plainTextChanged(text);
|
emit plainTextChanged(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartText::setFont(const QFont &font) {
|
void PartText::setFont(const QFont &font) {
|
||||||
if (font != this -> font()) {
|
if (font != this -> font()) {
|
||||||
QGraphicsTextItem::setFont(font);
|
QGraphicsTextItem::setFont(font);
|
||||||
emit fontChanged(font);
|
emit fontChanged(font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartText::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
void PartText::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
if((event -> buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable)) {
|
if((event -> buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable)) {
|
||||||
QPointF pos = event -> scenePos() + (m_origine_pos - event -> buttonDownScenePos(Qt::LeftButton));
|
QPointF pos = event -> scenePos() + (m_origine_pos - event -> buttonDownScenePos(Qt::LeftButton));
|
||||||
event -> modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene() -> snapToGrid(pos));
|
event -> modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene() -> snapToGrid(pos));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QGraphicsObject::mouseMoveEvent(event);
|
QGraphicsObject::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartText::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
void PartText::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
if(event -> button() == Qt::LeftButton)
|
if(event -> button() == Qt::LeftButton)
|
||||||
m_origine_pos = this -> pos();
|
m_origine_pos = this -> pos();
|
||||||
|
|
||||||
QGraphicsObject::mousePressEvent(event);
|
QGraphicsObject::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartText::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
void PartText::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
if((event -> button() & Qt::LeftButton) &&
|
if((event -> button() & Qt::LeftButton) &&
|
||||||
(flags() & QGraphicsItem::ItemIsMovable) &&
|
(flags() & QGraphicsItem::ItemIsMovable) &&
|
||||||
m_origine_pos != pos())
|
m_origine_pos != pos())
|
||||||
{
|
{
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "pos", QVariant(m_origine_pos), QVariant(pos()));
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "pos", QVariant(m_origine_pos), QVariant(pos()));
|
||||||
undo -> setText(tr("Déplacer un texte"));
|
undo -> setText(tr("Déplacer un texte"));
|
||||||
undo -> enableAnimation();
|
undo -> enableAnimation();
|
||||||
elementScene() -> undoStack().push(undo);
|
elementScene() -> undoStack().push(undo);
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsObject::mouseReleaseEvent(event);
|
QGraphicsObject::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Cette methode s'assure que la position du champ de texte est coherente
|
Cette methode s'assure que la position du champ de texte est coherente
|
||||||
en repositionnant son origine (c-a-d le milieu du bord gauche du champ de
|
en repositionnant son origine (c-a-d le milieu du bord gauche du champ de
|
||||||
texte) a la position originale. Cela est notamment utile lorsque le champ
|
texte) a la position originale. Cela est notamment utile lorsque le champ
|
||||||
de texte est agrandi ou retreci verticalement (ajout ou retrait de lignes).
|
de texte est agrandi ou retreci verticalement (ajout ou retrait de lignes).
|
||||||
@param new_block_count Nombre de blocs dans le PartText
|
@param new_block_count Nombre de blocs dans le PartText
|
||||||
*/
|
*/
|
||||||
void PartText::adjustItemPosition(int new_block_count) {
|
void PartText::adjustItemPosition(int new_block_count) {
|
||||||
Q_UNUSED(new_block_count);
|
Q_UNUSED(new_block_count);
|
||||||
QPointF origin_offset = margin();
|
QPointF origin_offset = margin();
|
||||||
|
|
||||||
QTransform base_translation;
|
QTransform base_translation;
|
||||||
base_translation.translate(-origin_offset.x(), -origin_offset.y());
|
base_translation.translate(-origin_offset.x(), -origin_offset.y());
|
||||||
setTransform(base_translation, false);
|
setTransform(base_translation, false);
|
||||||
setTransformOriginPoint(origin_offset);
|
setTransformOriginPoint(origin_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param editable Whether this text item should be interactively editable.
|
@param editable Whether this text item should be interactively editable.
|
||||||
*/
|
*/
|
||||||
void PartText::setEditable(bool editable) {
|
void PartText::setEditable(bool editable) {
|
||||||
if (editable) {
|
if (editable) {
|
||||||
setFlag(QGraphicsItem::ItemIsFocusable, true);
|
setFlag(QGraphicsItem::ItemIsFocusable, true);
|
||||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||||
setFocus(Qt::MouseFocusReason);
|
setFocus(Qt::MouseFocusReason);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setTextInteractionFlags(Qt::NoTextInteraction);
|
setTextInteractionFlags(Qt::NoTextInteraction);
|
||||||
setFlag(QGraphicsItem::ItemIsFocusable, false);
|
setFlag(QGraphicsItem::ItemIsFocusable, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Start text edition by storing the former value of the text.
|
Start text edition by storing the former value of the text.
|
||||||
*/
|
*/
|
||||||
void PartText::startEdition()
|
void PartText::startEdition()
|
||||||
{
|
{
|
||||||
// !previous_text.isNull() means the text is being edited
|
// !previous_text.isNull() means the text is being edited
|
||||||
previous_text = toPlainText();
|
previous_text = toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
End text edition, potentially generating a ChangePartCommand if the text
|
End text edition, potentially generating a ChangePartCommand if the text
|
||||||
has changed.
|
has changed.
|
||||||
*/
|
*/
|
||||||
void PartText::endEdition()
|
void PartText::endEdition()
|
||||||
{
|
{
|
||||||
if (!previous_text.isNull()) {
|
if (!previous_text.isNull()) {
|
||||||
// the text was being edited
|
// the text was being edited
|
||||||
QString new_text = toPlainText();
|
QString new_text = toPlainText();
|
||||||
if (previous_text != new_text) {
|
if (previous_text != new_text) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "text", previous_text, new_text);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "text", previous_text, new_text);
|
||||||
undo -> setText(tr("Modifier un champ texte"));
|
undo -> setText(tr("Modifier un champ texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
previous_text = QString();
|
previous_text = QString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// deselectionne le texte
|
// deselectionne le texte
|
||||||
QTextCursor qtc = textCursor();
|
QTextCursor qtc = textCursor();
|
||||||
qtc.clearSelection();
|
qtc.clearSelection();
|
||||||
setTextCursor(qtc);
|
setTextCursor(qtc);
|
||||||
|
|
||||||
setEditable(false);
|
setEditable(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef PART_TEXT_H
|
#ifndef PART_TEXT_H
|
||||||
#define PART_TEXT_H
|
#define PART_TEXT_H
|
||||||
@@ -24,82 +24,82 @@
|
|||||||
class TextEditor;
|
class TextEditor;
|
||||||
class ElementPrimitiveDecorator;
|
class ElementPrimitiveDecorator;
|
||||||
/**
|
/**
|
||||||
This class represents an static text primitive which may be used to compose
|
This class represents an static text primitive which may be used to compose
|
||||||
the drawing of an electrical element within the element editor.
|
the drawing of an electrical element within the element editor.
|
||||||
*/
|
*/
|
||||||
class PartText : public QGraphicsTextItem, public CustomElementPart {
|
class PartText : public QGraphicsTextItem, public CustomElementPart {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(qreal real_size READ realSize WRITE setRealSize)
|
Q_PROPERTY(qreal real_size READ realSize WRITE setRealSize)
|
||||||
Q_PROPERTY(QColor color READ defaultTextColor WRITE setDefaultTextColor NOTIFY colorChanged)
|
Q_PROPERTY(QColor color READ defaultTextColor WRITE setDefaultTextColor NOTIFY colorChanged)
|
||||||
Q_PROPERTY(QString text READ toPlainText WRITE setPlainText NOTIFY plainTextChanged)
|
Q_PROPERTY(QString text READ toPlainText WRITE setPlainText NOTIFY plainTextChanged)
|
||||||
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
|
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void fontChanged(const QFont &font);
|
void fontChanged(const QFont &font);
|
||||||
void colorChanged(const QColor &color);
|
void colorChanged(const QColor &color);
|
||||||
void plainTextChanged(const QString &text);
|
void plainTextChanged(const QString &text);
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
PartText(QETElementEditor *, QGraphicsItem * = nullptr);
|
PartText(QETElementEditor *, QGraphicsItem * = nullptr);
|
||||||
~PartText() override;
|
~PartText() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PartText(const PartText &);
|
PartText(const PartText &);
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1107 };
|
enum { Type = UserType + 1107 };
|
||||||
/**
|
/**
|
||||||
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a
|
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a
|
||||||
PartText.
|
PartText.
|
||||||
@return the QGraphicsItem type
|
@return the QGraphicsItem type
|
||||||
*/
|
*/
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
QString name() const override { return(QObject::tr("texte", "element part name")); }
|
QString name() const override { return(QObject::tr("texte", "element part name")); }
|
||||||
QString xmlName() const override { return(QString("text")); }
|
QString xmlName() const override { return(QString("text")); }
|
||||||
bool fromXml(const QDomElement &) override;
|
bool fromXml(const QDomElement &) override;
|
||||||
static bool valideXml(QDomElement& element);
|
static bool valideXml(QDomElement& element);
|
||||||
QDomElement toXml(QDomDocument &) const override;
|
QDomElement toXml(QDomDocument &) const override;
|
||||||
void setRotation(qreal angle) {(QGraphicsObject::setRotation(QET::correctAngle(angle)));}
|
void setRotation(qreal angle) {(QGraphicsObject::setRotation(QET::correctAngle(angle)));}
|
||||||
bool isUseless() const override;
|
bool isUseless() const override;
|
||||||
QRectF sceneGeometricRect() const override;
|
QRectF sceneGeometricRect() const override;
|
||||||
void startUserTransformation(const QRectF &) override;
|
void startUserTransformation(const QRectF &) override;
|
||||||
void handleUserTransformation(const QRectF &, const QRectF &) override;
|
void handleUserTransformation(const QRectF &, const QRectF &) override;
|
||||||
|
|
||||||
void setProperty(const char *name, const QVariant &value) override {QGraphicsTextItem::setProperty(name, value);}
|
void setProperty(const char *name, const QVariant &value) override {QGraphicsTextItem::setProperty(name, value);}
|
||||||
QVariant property(const char *name) const override {return QGraphicsTextItem::property(name);}
|
QVariant property(const char *name) const override {return QGraphicsTextItem::property(name);}
|
||||||
|
|
||||||
qreal realSize() const {return real_font_size_;}
|
qreal realSize() const {return real_font_size_;}
|
||||||
void setRealSize(qreal rs) {real_font_size_ = rs;}
|
void setRealSize(qreal rs) {real_font_size_ = rs;}
|
||||||
void setDefaultTextColor(const QColor &color);
|
void setDefaultTextColor(const QColor &color);
|
||||||
void setPlainText(const QString &text);
|
void setPlainText(const QString &text);
|
||||||
void setFont(const QFont &font);
|
void setFont(const QFont &font);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void adjustItemPosition(int = 0);
|
void adjustItemPosition(int = 0);
|
||||||
void setEditable(bool);
|
void setEditable(bool);
|
||||||
void startEdition();
|
void startEdition();
|
||||||
void endEdition();
|
void endEdition();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void focusInEvent(QFocusEvent *) override;
|
void focusInEvent(QFocusEvent *) override;
|
||||||
void focusOutEvent(QFocusEvent *) override;
|
void focusOutEvent(QFocusEvent *) override;
|
||||||
void keyPressEvent(QKeyEvent *) override;
|
void keyPressEvent(QKeyEvent *) override;
|
||||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) override;
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) override;
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &) override;
|
QVariant itemChange(GraphicsItemChange, const QVariant &) override;
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointF margin() const;
|
QPointF margin() const;
|
||||||
QString previous_text;
|
QString previous_text;
|
||||||
qreal real_font_size_;
|
qreal real_font_size_;
|
||||||
QPointF saved_point_;
|
QPointF saved_point_;
|
||||||
qreal saved_font_size_;
|
qreal saved_font_size_;
|
||||||
QGraphicsItem *decorator_;
|
QGraphicsItem *decorator_;
|
||||||
QPointF m_origine_pos;
|
QPointF m_origine_pos;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "elementtextpattern.h"
|
#include "elementtextpattern.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
@@ -35,238 +35,238 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ExportElementTextPattern::ExportElementTextPattern
|
@brief ExportElementTextPattern::ExportElementTextPattern
|
||||||
Constructor
|
Constructor
|
||||||
@param elmt
|
@param elmt
|
||||||
*/
|
*/
|
||||||
ExportElementTextPattern::ExportElementTextPattern(Element *elmt) :
|
ExportElementTextPattern::ExportElementTextPattern(Element *elmt) :
|
||||||
m_element(elmt)
|
m_element(elmt)
|
||||||
{
|
{
|
||||||
//Create the conf dir if not yet.
|
//Create the conf dir if not yet.
|
||||||
QDir dir(QETApp::configDir()+ "/element_texts_pattern");
|
QDir dir(QETApp::configDir()+ "/element_texts_pattern");
|
||||||
if(!dir.exists())
|
if(!dir.exists())
|
||||||
{
|
{
|
||||||
dir.cdUp();
|
dir.cdUp();
|
||||||
dir.mkdir("element_texts_pattern");
|
dir.mkdir("element_texts_pattern");
|
||||||
dir.cd("element_texts_pattern");
|
dir.cd("element_texts_pattern");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get the name of conf
|
//Get the name of conf
|
||||||
bool ok;
|
bool ok;
|
||||||
m_name = getName(ok);
|
m_name = getName(ok);
|
||||||
if(ok == false)
|
if(ok == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Check if a conf with the same name already exist
|
//Check if a conf with the same name already exist
|
||||||
if (QFileInfo::exists(dir.absoluteFilePath(m_name + ".xml")))
|
if (QFileInfo::exists(dir.absoluteFilePath(m_name + ".xml")))
|
||||||
{
|
{
|
||||||
bool r = QMessageBox::question(parentWidget(),
|
bool r = QMessageBox::question(parentWidget(),
|
||||||
QObject::tr("Configuration de textes"),
|
QObject::tr("Configuration de textes"),
|
||||||
QObject::tr("Une configuration de textes nommée << %1 >> existe déjà.\n"
|
QObject::tr("Une configuration de textes nommée << %1 >> existe déjà.\n"
|
||||||
"Voulez-vous la remplacer ?").arg(m_name));
|
"Voulez-vous la remplacer ?").arg(m_name));
|
||||||
|
|
||||||
if(r == false)
|
if(r == false)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomDocument doc = xmlConf();
|
QDomDocument doc = xmlConf();
|
||||||
QET::writeXmlFile(doc, dir.absoluteFilePath(m_name + ".xml"));
|
QET::writeXmlFile(doc, dir.absoluteFilePath(m_name + ".xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ExportElementTextConf::getName
|
@brief ExportElementTextConf::getName
|
||||||
Open a dialog to let user set the name of the conf and return it
|
Open a dialog to let user set the name of the conf and return it
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
QString ExportElementTextPattern::getName(bool &ok) const
|
QString ExportElementTextPattern::getName(bool &ok) const
|
||||||
{
|
{
|
||||||
QString text = QInputDialog::getText(parentWidget(),
|
QString text = QInputDialog::getText(parentWidget(),
|
||||||
QObject::tr("Nom de la configuration"),
|
QObject::tr("Nom de la configuration"),
|
||||||
QObject::tr("Entrer le nom de la configuration à créer"),
|
QObject::tr("Entrer le nom de la configuration à créer"),
|
||||||
QLineEdit::Normal,
|
QLineEdit::Normal,
|
||||||
QString(),
|
QString(),
|
||||||
&ok);
|
&ok);
|
||||||
|
|
||||||
text.replace(" ", "_");
|
text.replace(" ", "_");
|
||||||
text.replace(".","");
|
text.replace(".","");
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *ExportElementTextPattern::parentWidget() const
|
QWidget *ExportElementTextPattern::parentWidget() const
|
||||||
{
|
{
|
||||||
QWidget *parent = nullptr;
|
QWidget *parent = nullptr;
|
||||||
if(m_element->scene() && !m_element->scene()->views().isEmpty())
|
if(m_element->scene() && !m_element->scene()->views().isEmpty())
|
||||||
parent = m_element->scene()->views().first();
|
parent = m_element->scene()->views().first();
|
||||||
|
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomDocument ExportElementTextPattern::xmlConf() const
|
QDomDocument ExportElementTextPattern::xmlConf() const
|
||||||
{
|
{
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
QDomElement root = doc.createElement("Element_texts_pattern");
|
QDomElement root = doc.createElement("Element_texts_pattern");
|
||||||
root.setAttribute("name", m_name);
|
root.setAttribute("name", m_name);
|
||||||
doc.appendChild(root);
|
doc.appendChild(root);
|
||||||
|
|
||||||
QDomElement elmt = m_element->toXml(doc);
|
QDomElement elmt = m_element->toXml(doc);
|
||||||
QDomElement texts = elmt.firstChildElement("dynamic_texts");
|
QDomElement texts = elmt.firstChildElement("dynamic_texts");
|
||||||
QDomElement groups = elmt.firstChildElement("texts_groups");
|
QDomElement groups = elmt.firstChildElement("texts_groups");
|
||||||
|
|
||||||
if(texts.tagName() == "dynamic_texts")
|
if(texts.tagName() == "dynamic_texts")
|
||||||
root.appendChild(texts);
|
root.appendChild(texts);
|
||||||
if(groups.tagName() == "texts_groups")
|
if(groups.tagName() == "texts_groups")
|
||||||
root.appendChild(groups);
|
root.appendChild(groups);
|
||||||
|
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
//*******************//
|
//*******************//
|
||||||
//******IMPORT*******//
|
//******IMPORT*******//
|
||||||
//*******************//
|
//*******************//
|
||||||
ImportElementTextPattern::ImportElementTextPattern(Element *elmt):
|
ImportElementTextPattern::ImportElementTextPattern(Element *elmt):
|
||||||
m_element(elmt)
|
m_element(elmt)
|
||||||
{
|
{
|
||||||
bool exist = true;
|
bool exist = true;
|
||||||
QDir dir(QETApp::configDir()+ "/element_texts_pattern");
|
QDir dir(QETApp::configDir()+ "/element_texts_pattern");
|
||||||
|
|
||||||
if(!dir.exists())
|
if(!dir.exists())
|
||||||
exist = false;
|
exist = false;
|
||||||
|
|
||||||
QStringList entry = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);
|
QStringList entry = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);
|
||||||
QStringList result = entry.filter(".xml");
|
QStringList result = entry.filter(".xml");
|
||||||
if(result.isEmpty())
|
if(result.isEmpty())
|
||||||
exist = false;
|
exist = false;
|
||||||
|
|
||||||
if(!exist)
|
if(!exist)
|
||||||
{
|
{
|
||||||
QMessageBox::information(
|
QMessageBox::information(
|
||||||
parentWidget(),
|
parentWidget(),
|
||||||
QObject::tr("Configuration de textes"),
|
QObject::tr("Configuration de textes"),
|
||||||
QObject::tr("Aucune configuration de textes existante."));
|
QObject::tr("Aucune configuration de textes existante."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok=false;
|
bool ok=false;
|
||||||
bool erase = false;
|
bool erase = false;
|
||||||
//Remove the .xml extention of the files
|
//Remove the .xml extention of the files
|
||||||
result.replaceInStrings(".xml", "");
|
result.replaceInStrings(".xml", "");
|
||||||
QString name = getName(result, &ok, &erase);
|
QString name = getName(result, &ok, &erase);
|
||||||
|
|
||||||
if(!ok || name.isEmpty())
|
if(!ok || name.isEmpty())
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
apply(name, erase);
|
apply(name, erase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ImportElementTextPattern::getName
|
@brief ImportElementTextPattern::getName
|
||||||
Open a dialog to let user select a conf
|
Open a dialog to let user select a conf
|
||||||
@param list
|
@param list
|
||||||
@param ok
|
@param ok
|
||||||
@param erase
|
@param erase
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
QString ImportElementTextPattern::getName(const QStringList& list,
|
QString ImportElementTextPattern::getName(const QStringList& list,
|
||||||
bool *ok,
|
bool *ok,
|
||||||
bool *erase) const
|
bool *erase) const
|
||||||
{
|
{
|
||||||
return ImportElementTextPatternDialog::getItem(
|
return ImportElementTextPatternDialog::getItem(
|
||||||
parentWidget(),
|
parentWidget(),
|
||||||
QObject::tr("Sélectionner une configuration de textes"),
|
QObject::tr("Sélectionner une configuration de textes"),
|
||||||
QObject::tr("Sélectionner la configuration de textes à ajouter à l'élément"),
|
QObject::tr("Sélectionner la configuration de textes à ajouter à l'élément"),
|
||||||
list,
|
list,
|
||||||
ok,
|
ok,
|
||||||
erase);
|
erase);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *ImportElementTextPattern::parentWidget() const
|
QWidget *ImportElementTextPattern::parentWidget() const
|
||||||
{
|
{
|
||||||
QWidget *parent = nullptr;
|
QWidget *parent = nullptr;
|
||||||
if(m_element->scene() && !m_element->scene()->views().isEmpty())
|
if(m_element->scene() && !m_element->scene()->views().isEmpty())
|
||||||
parent = m_element->scene()->views().first();
|
parent = m_element->scene()->views().first();
|
||||||
|
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ImportElementTextPattern::apply
|
@brief ImportElementTextPattern::apply
|
||||||
Apply the user choice
|
Apply the user choice
|
||||||
@param name : the name of the selected pattern
|
@param name : the name of the selected pattern
|
||||||
@param erase : erase the existing texts and groups of element.
|
@param erase : erase the existing texts and groups of element.
|
||||||
*/
|
*/
|
||||||
void ImportElementTextPattern::apply(QString name, bool erase) const
|
void ImportElementTextPattern::apply(QString name, bool erase) const
|
||||||
{
|
{
|
||||||
if(!name.endsWith(".xml"))
|
if(!name.endsWith(".xml"))
|
||||||
name.append(".xml");
|
name.append(".xml");
|
||||||
|
|
||||||
QFile conf_file(QETApp::configDir() + "/element_texts_pattern/" + name);
|
QFile conf_file(QETApp::configDir() + "/element_texts_pattern/" + name);
|
||||||
if(!conf_file.open(QIODevice::ReadOnly | QIODevice::Text))
|
if(!conf_file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Load the content of the xml file
|
//Load the content of the xml file
|
||||||
QDomDocument xml_conf;
|
QDomDocument xml_conf;
|
||||||
if(!xml_conf.setContent(&conf_file))
|
if(!xml_conf.setContent(&conf_file))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QDomElement root = xml_conf.firstChildElement("Element_texts_pattern");
|
QDomElement root = xml_conf.firstChildElement("Element_texts_pattern");
|
||||||
|
|
||||||
//Get the text
|
//Get the text
|
||||||
QList <QDomElement> texts = QET::findInDomElement(root, "dynamic_texts", "dynamic_elmt_text");
|
QList <QDomElement> texts = QET::findInDomElement(root, "dynamic_texts", "dynamic_elmt_text");
|
||||||
if (texts.isEmpty())
|
if (texts.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Replace the original uuid of texts in the xml description, by a new one for every texts
|
//Replace the original uuid of texts in the xml description, by a new one for every texts
|
||||||
QHash<QUuid, QUuid> uuid_hash;
|
QHash<QUuid, QUuid> uuid_hash;
|
||||||
for(QDomElement text : texts)
|
for(QDomElement text : texts)
|
||||||
{
|
{
|
||||||
QUuid original_uuid(text.attribute("uuid"));
|
QUuid original_uuid(text.attribute("uuid"));
|
||||||
QUuid new_uuid = QUuid::createUuid();
|
QUuid new_uuid = QUuid::createUuid();
|
||||||
text.setAttribute("uuid", new_uuid.toString());
|
text.setAttribute("uuid", new_uuid.toString());
|
||||||
|
|
||||||
uuid_hash.insert(original_uuid, new_uuid);
|
uuid_hash.insert(original_uuid, new_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
//In each group of the xml description, replace the original uuids, by the news created upper.
|
//In each group of the xml description, replace the original uuids, by the news created upper.
|
||||||
QList <QDomElement> groups = QET::findInDomElement(root, "texts_groups", "texts_group");
|
QList <QDomElement> groups = QET::findInDomElement(root, "texts_groups", "texts_group");
|
||||||
for(const QDomElement& group : groups)
|
for(const QDomElement& group : groups)
|
||||||
{
|
{
|
||||||
for(QDomElement text : QET::findInDomElement(group, "texts", "text"))
|
for(QDomElement text : QET::findInDomElement(group, "texts", "text"))
|
||||||
{
|
{
|
||||||
QUuid original_uuid(text.attribute("uuid"));
|
QUuid original_uuid(text.attribute("uuid"));
|
||||||
QUuid new_uuid = uuid_hash.value(original_uuid);
|
QUuid new_uuid = uuid_hash.value(original_uuid);
|
||||||
if(!new_uuid.isNull())
|
if(!new_uuid.isNull())
|
||||||
text.setAttribute("uuid", new_uuid.toString());
|
text.setAttribute("uuid", new_uuid.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoStack &undo_stack = m_element->diagram()->undoStack();
|
QUndoStack &undo_stack = m_element->diagram()->undoStack();
|
||||||
undo_stack.beginMacro(QObject::tr("Importer la configuration de texte : %1").arg(name.remove(".xml")));
|
undo_stack.beginMacro(QObject::tr("Importer la configuration de texte : %1").arg(name.remove(".xml")));
|
||||||
|
|
||||||
//erase existing texts and groups
|
//erase existing texts and groups
|
||||||
if (erase)
|
if (erase)
|
||||||
{
|
{
|
||||||
for (ElementTextItemGroup *group : m_element->textGroups()) {
|
for (ElementTextItemGroup *group : m_element->textGroups()) {
|
||||||
undo_stack.push(new RemoveTextsGroupCommand(m_element, group));
|
undo_stack.push(new RemoveTextsGroupCommand(m_element, group));
|
||||||
}
|
}
|
||||||
for (DynamicElementTextItem *deti : m_element->dynamicTextItems())
|
for (DynamicElementTextItem *deti : m_element->dynamicTextItems())
|
||||||
{
|
{
|
||||||
DiagramContent dc;
|
DiagramContent dc;
|
||||||
dc.m_element_texts << deti;
|
dc.m_element_texts << deti;
|
||||||
undo_stack.push(new DeleteQGraphicsItemCommand(m_element->diagram(), dc));
|
undo_stack.push(new DeleteQGraphicsItemCommand(m_element->diagram(), dc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add the texts to element
|
//Add the texts to element
|
||||||
for(const QDomElement& text : texts)
|
for(const QDomElement& text : texts)
|
||||||
{
|
{
|
||||||
DynamicElementTextItem *deti = new DynamicElementTextItem(m_element);
|
DynamicElementTextItem *deti = new DynamicElementTextItem(m_element);
|
||||||
undo_stack.push(new AddElementTextCommand(m_element, deti));
|
undo_stack.push(new AddElementTextCommand(m_element, deti));
|
||||||
deti->fromXml(text);
|
deti->fromXml(text);
|
||||||
}
|
}
|
||||||
//Add the groups to element
|
//Add the groups to element
|
||||||
for(const QDomElement& xml_group : groups)
|
for(const QDomElement& xml_group : groups)
|
||||||
undo_stack.push(new AddTextsGroupCommand(m_element, xml_group));
|
undo_stack.push(new AddTextsGroupCommand(m_element, xml_group));
|
||||||
|
|
||||||
undo_stack.endMacro();
|
undo_stack.endMacro();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "propertiesinterface.h"
|
#include "propertiesinterface.h"
|
||||||
|
|
||||||
@@ -21,99 +21,99 @@
|
|||||||
* Available property types
|
* Available property types
|
||||||
*/
|
*/
|
||||||
namespace {
|
namespace {
|
||||||
const QString integerS = "int";
|
const QString integerS = "int";
|
||||||
const QString doubleS = "double";
|
const QString doubleS = "double";
|
||||||
const QString boolS = "bool";
|
const QString boolS = "bool";
|
||||||
const QString stringS = "string";
|
const QString stringS = "string";
|
||||||
const QString uuidS = "uuid";
|
const QString uuidS = "uuid";
|
||||||
const QString colorS = "color";
|
const QString colorS = "color";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PropertiesInterface::PropertiesInterface
|
@brief PropertiesInterface::PropertiesInterface
|
||||||
*/
|
*/
|
||||||
PropertiesInterface::PropertiesInterface()
|
PropertiesInterface::PropertiesInterface()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PropertiesInterface::~PropertiesInterface
|
@brief PropertiesInterface::~PropertiesInterface
|
||||||
*/
|
*/
|
||||||
PropertiesInterface::~PropertiesInterface()
|
PropertiesInterface::~PropertiesInterface()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PropertiesInterface::valideXml(QDomElement& element) {
|
bool PropertiesInterface::valideXml(QDomElement& element) {
|
||||||
qDebug(QString("ValideXml() is not implemented. File: %1, Line: %2").arg(__FILE__).arg(__LINE__).toStdString().data());
|
qDebug(QString("ValideXml() is not implemented. File: %1, Line: %2").arg(__FILE__).arg(__LINE__).toStdString().data());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument &doc, const QString& name, const QString value) {
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument &doc, const QString& name, const QString value) {
|
||||||
QDomElement p = doc.createElement("property");
|
QDomElement p = doc.createElement("property");
|
||||||
p.setAttribute("name", name);
|
p.setAttribute("name", name);
|
||||||
p.setAttribute("type", stringS);
|
p.setAttribute("type", stringS);
|
||||||
p.setAttribute("value", value);
|
p.setAttribute("value", value);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument &doc, const QString& name, const char* value) {
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument &doc, const QString& name, const char* value) {
|
||||||
QDomElement p = doc.createElement("property");
|
QDomElement p = doc.createElement("property");
|
||||||
p.setAttribute("name", name);
|
p.setAttribute("name", name);
|
||||||
p.setAttribute("type", stringS);
|
p.setAttribute("type", stringS);
|
||||||
p.setAttribute("value", value);
|
p.setAttribute("value", value);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const int value) {
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const int value) {
|
||||||
QDomElement p = doc.createElement("property");
|
QDomElement p = doc.createElement("property");
|
||||||
p.setAttribute("name", name);
|
p.setAttribute("name", name);
|
||||||
p.setAttribute("type", integerS);
|
p.setAttribute("type", integerS);
|
||||||
p.setAttribute("value", QString::number(value));
|
p.setAttribute("value", QString::number(value));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const double value) {
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const double value) {
|
||||||
QDomElement p = doc.createElement("property");
|
QDomElement p = doc.createElement("property");
|
||||||
p.setAttribute("name", name);
|
p.setAttribute("name", name);
|
||||||
p.setAttribute("type", doubleS);
|
p.setAttribute("type", doubleS);
|
||||||
p.setAttribute("value", QString::number(value));
|
p.setAttribute("value", QString::number(value));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const bool value) {
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const bool value) {
|
||||||
QDomElement p = doc.createElement("property");
|
QDomElement p = doc.createElement("property");
|
||||||
p.setAttribute("name", name);
|
p.setAttribute("name", name);
|
||||||
p.setAttribute("type", boolS);
|
p.setAttribute("type", boolS);
|
||||||
p.setAttribute("value", QString::number(value));
|
p.setAttribute("value", QString::number(value));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const QUuid value) {
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const QUuid value) {
|
||||||
QDomElement p = doc.createElement("property");
|
QDomElement p = doc.createElement("property");
|
||||||
p.setAttribute("name", name);
|
p.setAttribute("name", name);
|
||||||
p.setAttribute("type", uuidS);
|
p.setAttribute("type", uuidS);
|
||||||
p.setAttribute("value", value.toString());
|
p.setAttribute("value", value.toString());
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const QColor value) {
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const QColor value) {
|
||||||
QDomElement p = doc.createElement("property");
|
QDomElement p = doc.createElement("property");
|
||||||
p.setAttribute("name", name);
|
p.setAttribute("name", name);
|
||||||
p.setAttribute("type", colorS);
|
p.setAttribute("type", colorS);
|
||||||
p.setAttribute("value", value.name());
|
p.setAttribute("value", value.name());
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement PropertiesInterface::property(const QDomElement& e, const QString& name) {
|
QDomElement PropertiesInterface::property(const QDomElement& e, const QString& name) {
|
||||||
for (int i=0; i < e.childNodes().count(); i++) {
|
for (int i=0; i < e.childNodes().count(); i++) {
|
||||||
QDomElement child = e.childNodes().at(i).toElement();
|
QDomElement child = e.childNodes().at(i).toElement();
|
||||||
if (!validXmlProperty(child))
|
if (!validXmlProperty(child))
|
||||||
continue; // there might also non property childs
|
continue; // there might also non property childs
|
||||||
|
|
||||||
if (child.attribute("name") == name)
|
if (child.attribute("name") == name)
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
return QDomElement();
|
return QDomElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -126,27 +126,27 @@ QDomElement PropertiesInterface::property(const QDomElement& e, const QString& n
|
|||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
bool PropertiesInterface::attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr) {
|
bool PropertiesInterface::attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr) {
|
||||||
QDomElement p = property(e, attribute_name);
|
QDomElement p = property(e, attribute_name);
|
||||||
if (p.isNull()) {
|
if (p.isNull()) {
|
||||||
// check if legacy property is available,
|
// check if legacy property is available,
|
||||||
// where the property is inside the element as attribute
|
// where the property is inside the element as attribute
|
||||||
if (!e.hasAttribute(attribute_name)) {
|
if (!e.hasAttribute(attribute_name)) {
|
||||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "Property " << attribute_name << "is not available";
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "Property " << attribute_name << "is not available";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*attr = e.attribute(attribute_name);
|
*attr = e.attribute(attribute_name);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (p.attribute("type") != type) {
|
if (p.attribute("type") != type) {
|
||||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ", Property: " << attribute_name << "(" << p.attribute("type") << ") has not type: " << type;
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ", Property: " << attribute_name << "(" << p.attribute("type") << ") has not type: " << type;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*attr = p.attribute("value");
|
*attr = p.attribute("value");
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -156,132 +156,132 @@ bool PropertiesInterface::attribute(const QDomElement& e, const QString& attribu
|
|||||||
* \param attribute_name Name of the attribute
|
* \param attribute_name Name of the attribute
|
||||||
* \param entier Return value if success
|
* \param entier Return value if success
|
||||||
* \return True if reading an integer was successful, else False. If the attribute was not found,
|
* \return True if reading an integer was successful, else False. If the attribute was not found,
|
||||||
* \p entier is not valid and the return value is False
|
* \p entier is not valid and the return value is False
|
||||||
*/
|
*/
|
||||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier) {
|
PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier) {
|
||||||
|
|
||||||
QString attr;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, integerS, &attr)) {
|
if (!attribute(e, attribute_name, integerS, &attr)) {
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
// verifie la validite de l'attribut
|
// verifie la validite de l'attribut
|
||||||
bool ok;
|
bool ok;
|
||||||
int tmp = attr.toInt(&ok);
|
int tmp = attr.toInt(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << integerS << ". value: " << attr;
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << integerS << ". value: " << attr;
|
||||||
return PropertyFlags::NoValidConversion;
|
return PropertyFlags::NoValidConversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entier != nullptr)
|
if (entier != nullptr)
|
||||||
*entier = tmp;
|
*entier = tmp;
|
||||||
|
|
||||||
return PropertyFlags::Success;
|
return PropertyFlags::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDomElement &e, const QString& attribute_name, double* reel) {
|
PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDomElement &e, const QString& attribute_name, double* reel) {
|
||||||
|
|
||||||
QString attr;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, doubleS, &attr)) {
|
if (!attribute(e, attribute_name, doubleS, &attr)) {
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
// verifie la validite de l'attribut
|
// verifie la validite de l'attribut
|
||||||
bool ok;
|
bool ok;
|
||||||
double tmp = attr.toDouble(&ok);
|
double tmp = attr.toDouble(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << doubleS << ". value: " << attr;
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << doubleS << ". value: " << attr;
|
||||||
return PropertyFlags::NoValidConversion;
|
return PropertyFlags::NoValidConversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reel != nullptr)
|
if (reel != nullptr)
|
||||||
*reel = tmp;
|
*reel = tmp;
|
||||||
|
|
||||||
return PropertyFlags::Success;
|
return PropertyFlags::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean) {
|
PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean) {
|
||||||
|
|
||||||
QString attr;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, boolS, &attr)) {
|
if (!attribute(e, attribute_name, boolS, &attr)) {
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
// verifie la validite de l'attribut
|
// verifie la validite de l'attribut
|
||||||
bool ok;
|
bool ok;
|
||||||
bool tmp = attr.toInt(&ok);
|
bool tmp = attr.toInt(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
if (attr == "true" || attr == "1")
|
if (attr == "true" || attr == "1")
|
||||||
tmp = true;
|
tmp = true;
|
||||||
else if (attr == "false" || attr == "0")
|
else if (attr == "false" || attr == "0")
|
||||||
tmp = false;
|
tmp = false;
|
||||||
else {
|
else {
|
||||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << integerS << ". value: " << attr;
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << integerS << ". value: " << attr;
|
||||||
return PropertyFlags::NoValidConversion;
|
return PropertyFlags::NoValidConversion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boolean != nullptr)
|
if (boolean != nullptr)
|
||||||
*boolean = tmp;
|
*boolean = tmp;
|
||||||
|
|
||||||
return PropertyFlags::Success;
|
return PropertyFlags::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color) {
|
PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color) {
|
||||||
|
|
||||||
QString attr;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, colorS, &attr)) {
|
if (!attribute(e, attribute_name, colorS, &attr)) {
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
// verifie la validite de l'attribut
|
// verifie la validite de l'attribut
|
||||||
QColor tmp = QColor(attr);
|
QColor tmp = QColor(attr);
|
||||||
if (!tmp.isValid()) {
|
if (!tmp.isValid()) {
|
||||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << colorS << ". value: " << attr;
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << colorS << ". value: " << attr;
|
||||||
return PropertyFlags::NoValidConversion;
|
return PropertyFlags::NoValidConversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (color != nullptr)
|
if (color != nullptr)
|
||||||
*color = tmp;
|
*color = tmp;
|
||||||
|
|
||||||
return PropertyFlags::Success;
|
return PropertyFlags::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid) {
|
PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid) {
|
||||||
QString attr;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, uuidS, &attr)) {
|
if (!attribute(e, attribute_name, uuidS, &attr)) {
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QUuid(attr).isNull()){
|
if (QUuid(attr).isNull()){
|
||||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << uuidS << ". value: " << attr;
|
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << uuidS << ". value: " << attr;
|
||||||
return PropertyFlags::NoValidConversion;
|
return PropertyFlags::NoValidConversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (uuid != nullptr)
|
if (uuid != nullptr)
|
||||||
*uuid = QUuid(attr);
|
*uuid = QUuid(attr);
|
||||||
|
|
||||||
return PropertyFlags::Success;
|
return PropertyFlags::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyString(const QDomElement& e, const QString& attribute_name, QString* string) {
|
PropertiesInterface::PropertyFlags PropertiesInterface::propertyString(const QDomElement& e, const QString& attribute_name, QString* string) {
|
||||||
|
|
||||||
QString attr;
|
QString attr;
|
||||||
if (!attribute(e, attribute_name, stringS, &attr)) {
|
if (!attribute(e, attribute_name, stringS, &attr)) {
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
// verifie la validite de l'attribut
|
// verifie la validite de l'attribut
|
||||||
if (string != nullptr)
|
if (string != nullptr)
|
||||||
*string = attr;
|
*string = attr;
|
||||||
|
|
||||||
return PropertyFlags::Success;
|
return PropertyFlags::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -291,47 +291,47 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyString(const QDo
|
|||||||
* \return True if name, type, value attribute are available, else false
|
* \return True if name, type, value attribute are available, else false
|
||||||
*/
|
*/
|
||||||
bool PropertiesInterface::validXmlProperty(const QDomElement& e) {
|
bool PropertiesInterface::validXmlProperty(const QDomElement& e) {
|
||||||
if (!e.hasAttribute("name"))
|
if (!e.hasAttribute("name"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!e.hasAttribute("type"))
|
if (!e.hasAttribute("type"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!e.hasAttribute("value"))
|
if (!e.hasAttribute("value"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
||||||
en orientation. Si la chaine fait plusieurs caracteres, seul le
|
en orientation. Si la chaine fait plusieurs caracteres, seul le
|
||||||
premier est pris en compte. En cas d'incoherence, Qet::North est
|
premier est pris en compte. En cas d'incoherence, Qet::North est
|
||||||
retourne.
|
retourne.
|
||||||
@param s Chaine de caractere cense representer une orientation
|
@param s Chaine de caractere cense representer une orientation
|
||||||
@return l'orientation designee par la chaine de caractere
|
@return l'orientation designee par la chaine de caractere
|
||||||
*/
|
*/
|
||||||
Qet::Orientation PropertiesInterface::orientationFromString(const QString &s) {
|
Qet::Orientation PropertiesInterface::orientationFromString(const QString &s) {
|
||||||
QChar c = s[0];
|
QChar c = s[0];
|
||||||
// in some cases/ old projects? (affuteuse_250h.qet) numbers instead of characters are
|
// in some cases/ old projects? (affuteuse_250h.qet) numbers instead of characters are
|
||||||
// used for the orientation
|
// used for the orientation
|
||||||
if (c == 'e' || c == '1') return(Qet::East);
|
if (c == 'e' || c == '1') return(Qet::East);
|
||||||
else if (c == 's' || c == '2') return(Qet::South);
|
else if (c == 's' || c == '2') return(Qet::South);
|
||||||
else if (c == 'w' || c == '3') return (Qet::West);
|
else if (c == 'w' || c == '3') return (Qet::West);
|
||||||
else return(Qet::North); // c == '0'
|
else return(Qet::North); // c == '0'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param o une orientation
|
@param o une orientation
|
||||||
@return une chaine de caractere representant l'orientation
|
@return une chaine de caractere representant l'orientation
|
||||||
*/
|
*/
|
||||||
QString PropertiesInterface::orientationToString(Qet::Orientation o) {
|
QString PropertiesInterface::orientationToString(Qet::Orientation o) {
|
||||||
QString ret;
|
QString ret;
|
||||||
switch(o) {
|
switch(o) {
|
||||||
case Qet::North: ret = "n"; break;
|
case Qet::North: ret = "n"; break;
|
||||||
case Qet::East : ret = "e"; break;
|
case Qet::East : ret = "e"; break;
|
||||||
case Qet::South: ret = "s"; break;
|
case Qet::South: ret = "s"; break;
|
||||||
case Qet::West : ret = "w"; break;
|
case Qet::West : ret = "w"; break;
|
||||||
}
|
}
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef PROPERTIESINTERFACE_H
|
#ifndef PROPERTIESINTERFACE_H
|
||||||
#define PROPERTIESINTERFACE_H
|
#define PROPERTIESINTERFACE_H
|
||||||
@@ -27,100 +27,100 @@
|
|||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The PropertiesInterface class
|
@brief The PropertiesInterface class
|
||||||
This class is an interface for have common way
|
This class is an interface for have common way
|
||||||
to use properties in QElectroTech
|
to use properties in QElectroTech
|
||||||
*/
|
*/
|
||||||
class PropertiesInterface
|
class PropertiesInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PropertiesInterface();
|
PropertiesInterface();
|
||||||
virtual ~PropertiesInterface();
|
virtual ~PropertiesInterface();
|
||||||
/**
|
/**
|
||||||
@brief toSettings
|
@brief toSettings
|
||||||
Save properties to setting file.
|
Save properties to setting file.
|
||||||
@param settings : is use for prefix a word
|
@param settings : is use for prefix a word
|
||||||
befor the name of each paramètre
|
befor the name of each paramètre
|
||||||
@param QString
|
@param QString
|
||||||
*/
|
*/
|
||||||
virtual void toSettings (QSettings &settings,
|
virtual void toSettings (QSettings &settings,
|
||||||
const QString = QString()) const =0;
|
const QString = QString()) const =0;
|
||||||
/**
|
/**
|
||||||
@brief fromSettings
|
@brief fromSettings
|
||||||
load properties to setting file.
|
load properties to setting file.
|
||||||
@param settings : is use for prefix a word
|
@param settings : is use for prefix a word
|
||||||
befor the name of each paramètre
|
befor the name of each paramètre
|
||||||
@param QString
|
@param QString
|
||||||
*/
|
*/
|
||||||
virtual void fromSettings (const QSettings &settings,
|
virtual void fromSettings (const QSettings &settings,
|
||||||
const QString = QString()) =0;
|
const QString = QString()) =0;
|
||||||
/**
|
/**
|
||||||
@brief toXml
|
@brief toXml
|
||||||
Save properties to xml element
|
Save properties to xml element
|
||||||
@param xml_document
|
@param xml_document
|
||||||
@return QDomElement
|
@return QDomElement
|
||||||
*/
|
*/
|
||||||
virtual QDomElement toXml (QDomDocument &xml_document) const =0;
|
virtual QDomElement toXml (QDomDocument &xml_document) const =0;
|
||||||
/**
|
/**
|
||||||
@brief fromXml
|
@brief fromXml
|
||||||
load properties to xml element
|
load properties to xml element
|
||||||
@param xml_element
|
@param xml_element
|
||||||
@return true / false
|
@return true / false
|
||||||
*/
|
*/
|
||||||
virtual bool fromXml (const QDomElement &xml_element) =0;
|
virtual bool fromXml (const QDomElement &xml_element) =0;
|
||||||
static bool valideXml(QDomElement& element);
|
static bool valideXml(QDomElement& element);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Use this functions to add properties to the xml document
|
* Use this functions to add properties to the xml document
|
||||||
*/
|
*/
|
||||||
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const QString value);
|
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const QString value);
|
||||||
static QDomElement createXmlProperty(QDomDocument &doc, const QString& name, const char* value);
|
static QDomElement createXmlProperty(QDomDocument &doc, const QString& name, const char* value);
|
||||||
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const int value);
|
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const int value);
|
||||||
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const double value);
|
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const double value);
|
||||||
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const bool value);
|
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const bool value);
|
||||||
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const QUuid value);
|
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const QUuid value);
|
||||||
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const QColor value);
|
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const QColor value);
|
||||||
|
|
||||||
static QDomElement property(const QDomElement& e, const QString& name);
|
static QDomElement property(const QDomElement& e, const QString& name);
|
||||||
static bool attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr);
|
static bool attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr);
|
||||||
|
|
||||||
enum PropertyFlags {
|
enum PropertyFlags {
|
||||||
Success = 0,
|
Success = 0,
|
||||||
NotFound = 1,
|
NotFound = 1,
|
||||||
NoValidConversion = 2,
|
NoValidConversion = 2,
|
||||||
// = 4
|
// = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Try not using the default Value feature. It is better to initialize the class members in the class definition!
|
* Try not using the default Value feature. It is better to initialize the class members in the class definition!
|
||||||
*/
|
*/
|
||||||
static PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr);
|
static PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr);
|
||||||
static PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr);
|
static PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr);
|
||||||
static PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr);
|
static PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr);
|
||||||
static PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr);
|
static PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr);
|
||||||
static PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr);
|
static PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr);
|
||||||
static PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr);
|
static PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr);
|
||||||
|
|
||||||
|
|
||||||
static bool validXmlProperty(const QDomElement& e);
|
static bool validXmlProperty(const QDomElement& e);
|
||||||
|
|
||||||
QVariant XmlProperty(const QDomElement& element);
|
QVariant XmlProperty(const QDomElement& element);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
||||||
en orientation. Si la chaine fait plusieurs caracteres, seul le
|
en orientation. Si la chaine fait plusieurs caracteres, seul le
|
||||||
premier est pris en compte. En cas d'incoherence, Qet::North est
|
premier est pris en compte. En cas d'incoherence, Qet::North est
|
||||||
retourne.
|
retourne.
|
||||||
@param s Chaine de caractere cense representer une orientation
|
@param s Chaine de caractere cense representer une orientation
|
||||||
@return l'orientation designee par la chaine de caractere
|
@return l'orientation designee par la chaine de caractere
|
||||||
*/
|
*/
|
||||||
static Qet::Orientation orientationFromString(const QString &s);
|
static Qet::Orientation orientationFromString(const QString &s);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param o une orientation
|
@param o une orientation
|
||||||
@return une chaine de caractere representant l'orientation
|
@return une chaine de caractere representant l'orientation
|
||||||
*/
|
*/
|
||||||
static QString orientationToString(Qet::Orientation o);
|
static QString orientationToString(Qet::Orientation o);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROPERTIESINTERFACE_H
|
#endif // PROPERTIESINTERFACE_H
|
||||||
|
|||||||
@@ -3,16 +3,16 @@
|
|||||||
#include <QGraphicsObject>
|
#include <QGraphicsObject>
|
||||||
|
|
||||||
TerminalData::TerminalData():
|
TerminalData::TerminalData():
|
||||||
PropertiesInterface()
|
PropertiesInterface()
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminalData::TerminalData(QGraphicsObject *parent):
|
TerminalData::TerminalData(QGraphicsObject *parent):
|
||||||
PropertiesInterface(),
|
PropertiesInterface(),
|
||||||
q(parent)
|
q(parent)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerminalData::init()
|
void TerminalData::init()
|
||||||
@@ -25,135 +25,135 @@ TerminalData::~TerminalData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief TerminalData::setParent
|
@brief TerminalData::setParent
|
||||||
@param parent
|
@param parent
|
||||||
*/
|
*/
|
||||||
void TerminalData::setParent(QGraphicsObject* parent)
|
void TerminalData::setParent(QGraphicsObject* parent)
|
||||||
{
|
{
|
||||||
q = parent;
|
q = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief TerminalData::toSettings
|
@brief TerminalData::toSettings
|
||||||
Save properties to setting file.
|
Save properties to setting file.
|
||||||
|
|
||||||
QString is use for prefix a word befor the name of each paramètre
|
QString is use for prefix a word befor the name of each paramètre
|
||||||
@param settings UNUSED
|
@param settings UNUSED
|
||||||
@param prefix UNUSED
|
@param prefix UNUSED
|
||||||
*/
|
*/
|
||||||
void TerminalData::toSettings(QSettings &settings, const QString prefix) const
|
void TerminalData::toSettings(QSettings &settings, const QString prefix) const
|
||||||
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(settings);
|
Q_UNUSED(settings);
|
||||||
Q_UNUSED(prefix);
|
Q_UNUSED(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief TerminalData::fromSettings
|
@brief TerminalData::fromSettings
|
||||||
load properties to setting file.
|
load properties to setting file.
|
||||||
|
|
||||||
QString is use for prefix a word befor the name of each paramètre
|
QString is use for prefix a word befor the name of each paramètre
|
||||||
@param settings UNUSED
|
@param settings UNUSED
|
||||||
@param prefix UNUSED
|
@param prefix UNUSED
|
||||||
*/
|
*/
|
||||||
void TerminalData::fromSettings(const QSettings &settings, const QString prefix)
|
void TerminalData::fromSettings(const QSettings &settings, const QString prefix)
|
||||||
{
|
{
|
||||||
Q_UNUSED(settings);
|
Q_UNUSED(settings);
|
||||||
Q_UNUSED(prefix);
|
Q_UNUSED(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief TerminalData::toXml
|
@brief TerminalData::toXml
|
||||||
Save properties to xml element
|
Save properties to xml element
|
||||||
write the name, number, position and orientation of the terminal
|
write the name, number, position and orientation of the terminal
|
||||||
to xml_element
|
to xml_element
|
||||||
|
|
||||||
@note This method is only called from the PartTerminal
|
@note This method is only called from the PartTerminal
|
||||||
and should never called from the Terminal class
|
and should never called from the Terminal class
|
||||||
@param xml_document
|
@param xml_document
|
||||||
@return xml_element : DomElement with
|
@return xml_element : DomElement with
|
||||||
the name, number, position and orientation of the terminal
|
the name, number, position and orientation of the terminal
|
||||||
*/
|
*/
|
||||||
QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement("terminaldata");
|
QDomElement xml_element = xml_document.createElement("terminaldata");
|
||||||
|
|
||||||
// write the position of the terminal
|
// write the position of the terminal
|
||||||
// Write name and number to XML
|
// Write name and number to XML
|
||||||
// m_pos cannot be stored, because in the partterminal it will not be updated.
|
// m_pos cannot be stored, because in the partterminal it will not be updated.
|
||||||
// In PartTerminal m_pos is the position of the dock, in Terminal m_pos is the second side of the terminal
|
// In PartTerminal m_pos is the position of the dock, in Terminal m_pos is the second side of the terminal
|
||||||
// This is hold for legacy compability reason
|
// This is hold for legacy compability reason
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "x", m_pos.x()));
|
xml_element.appendChild(createXmlProperty(xml_document, "x", m_pos.x()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "y", m_pos.y()));
|
xml_element.appendChild(createXmlProperty(xml_document, "y", m_pos.y()));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "name", m_name));
|
xml_element.appendChild(createXmlProperty(xml_document, "name", m_name));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "orientation", orientationToString(m_orientation)));
|
xml_element.appendChild(createXmlProperty(xml_document, "orientation", orientationToString(m_orientation)));
|
||||||
|
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@brief TerminalData::fromXml
|
@brief TerminalData::fromXml
|
||||||
load properties to xml element
|
load properties to xml element
|
||||||
|
|
||||||
@note This method is only called from the PartTerminal
|
@note This method is only called from the PartTerminal
|
||||||
and should never called from the Terminal class
|
and should never called from the Terminal class
|
||||||
@param xml_element
|
@param xml_element
|
||||||
@return true if succeeded / false if the attribute is not real
|
@return true if succeeded / false if the attribute is not real
|
||||||
*/
|
*/
|
||||||
bool TerminalData::fromXml (const QDomElement &xml_element) // RETURNS True
|
bool TerminalData::fromXml (const QDomElement &xml_element) // RETURNS True
|
||||||
{
|
{
|
||||||
qreal term_x = 0.0;
|
qreal term_x = 0.0;
|
||||||
qreal term_y = 0.0;
|
qreal term_y = 0.0;
|
||||||
|
|
||||||
// reads the position of the terminal
|
// reads the position of the terminal
|
||||||
// lit la position de la borne
|
// lit la position de la borne
|
||||||
|
|
||||||
if (propertyDouble(xml_element, "x", &term_x))
|
if (propertyDouble(xml_element, "x", &term_x))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (propertyDouble(xml_element, "y", &term_y))
|
if (propertyDouble(xml_element, "y", &term_y))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_pos = QPointF(term_x, term_y);
|
m_pos = QPointF(term_x, term_y);
|
||||||
|
|
||||||
// emit posFromXML(QPointF(term_x, term_y));
|
// emit posFromXML(QPointF(term_x, term_y));
|
||||||
|
|
||||||
// do not write uuid from this class, because only PartTerminal::fromXml need
|
// do not write uuid from this class, because only PartTerminal::fromXml need
|
||||||
// to write it to xml file. Terminal::fromXml does not need.
|
// to write it to xml file. Terminal::fromXml does not need.
|
||||||
// if the attribute not exists, means, the element is created with an
|
// if the attribute not exists, means, the element is created with an
|
||||||
// older version of qet. So use the legacy approach
|
// older version of qet. So use the legacy approach
|
||||||
|
|
||||||
|
|
||||||
//if (propertyString(xml_element, "name", &m_name))
|
//if (propertyString(xml_element, "name", &m_name))
|
||||||
// return false;
|
// return false;
|
||||||
propertyString(xml_element, "name", &m_name); // some parts do not have a name. Example: affuteuse_250h.qet, Terminal at x="0" y="-20"
|
propertyString(xml_element, "name", &m_name); // some parts do not have a name. Example: affuteuse_250h.qet, Terminal at x="0" y="-20"
|
||||||
|
|
||||||
QString o;
|
QString o;
|
||||||
if (propertyString(xml_element, "orientation", &o))
|
if (propertyString(xml_element, "orientation", &o))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// read the orientation of the terminal
|
// read the orientation of the terminal
|
||||||
// lit l'orientation de la borne
|
// lit l'orientation de la borne
|
||||||
m_orientation = Qet::orientationFromString(
|
m_orientation = Qet::orientationFromString(
|
||||||
xml_element.attribute("orientation"));
|
xml_element.attribute("orientation"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TerminalData::valideXml(const QDomElement& xml_element) {
|
bool TerminalData::valideXml(const QDomElement& xml_element) {
|
||||||
if (propertyDouble(xml_element, "x"))
|
if (propertyDouble(xml_element, "x"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (propertyDouble(xml_element, "y"))
|
if (propertyDouble(xml_element, "y"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// legacy elements do not have an uuid
|
// legacy elements do not have an uuid
|
||||||
// if (propertyUuid(xml_element, "uuid"))
|
// if (propertyUuid(xml_element, "uuid"))
|
||||||
// return false;
|
// return false;
|
||||||
|
|
||||||
//if (propertyString(xml_element, "name")) // some parts do not have a name. Example: affuteuse_250h.qet, Terminal at x="0" y="-20"
|
//if (propertyString(xml_element, "name")) // some parts do not have a name. Example: affuteuse_250h.qet, Terminal at x="0" y="-20"
|
||||||
// return false;
|
// return false;
|
||||||
|
|
||||||
if (propertyString(xml_element, "orientation"))
|
if (propertyString(xml_element, "orientation"))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,78 +10,78 @@
|
|||||||
class QGraphicsObject;
|
class QGraphicsObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The TerminalData class
|
@brief The TerminalData class
|
||||||
Data of the terminal.
|
Data of the terminal.
|
||||||
Stored in extra class so it can be used by PartTerminal
|
Stored in extra class so it can be used by PartTerminal
|
||||||
and Terminal without defining everything again.
|
and Terminal without defining everything again.
|
||||||
@note tis class needs to be work on
|
@note tis class needs to be work on
|
||||||
*/
|
*/
|
||||||
class TerminalData : public PropertiesInterface
|
class TerminalData : public PropertiesInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TerminalData();
|
TerminalData();
|
||||||
TerminalData(QGraphicsObject* parent);
|
TerminalData(QGraphicsObject* parent);
|
||||||
~TerminalData();
|
~TerminalData();
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void setParent(QGraphicsObject* parent);
|
void setParent(QGraphicsObject* parent);
|
||||||
void toSettings(QSettings &settings,
|
void toSettings(QSettings &settings,
|
||||||
const QString prefix = QString()) const override;
|
const QString prefix = QString()) const override;
|
||||||
void toSettings(QSettings &settings, const QString& = QString()) const override;
|
void toSettings(QSettings &settings, const QString& = QString()) const override;
|
||||||
void fromSettings(const QSettings &settings, const QString& = QString()) override;
|
void fromSettings(const QSettings &settings, const QString& = QString()) override;
|
||||||
QDomElement toXml(QDomDocument &xml_element) const override;
|
QDomElement toXml(QDomDocument &xml_element) const override;
|
||||||
bool fromXml(const QDomElement &xml_element) override;
|
bool fromXml(const QDomElement &xml_element) override;
|
||||||
|
|
||||||
static bool valideXml(const QDomElement &xml_element);
|
static bool valideXml(const QDomElement &xml_element);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@brief m_orientation
|
@brief m_orientation
|
||||||
Orientation of the terminal
|
Orientation of the terminal
|
||||||
*/
|
*/
|
||||||
Qet::Orientation m_orientation{Qet::Orientation::North};
|
Qet::Orientation m_orientation{Qet::Orientation::North};
|
||||||
/**
|
/**
|
||||||
@brief second_point
|
@brief second_point
|
||||||
Position of the second point of the terminal
|
Position of the second point of the terminal
|
||||||
in scene coordinates
|
in scene coordinates
|
||||||
*/
|
*/
|
||||||
QPointF second_point{0,0};
|
QPointF second_point{0,0};
|
||||||
/**
|
/**
|
||||||
@brief m_uuid
|
@brief m_uuid
|
||||||
Uuid of the terminal.
|
Uuid of the terminal.
|
||||||
|
|
||||||
In elementscene.cpp an element gets a new uuid when
|
In elementscene.cpp an element gets a new uuid when
|
||||||
saving the element. In the current state
|
saving the element. In the current state
|
||||||
each connection is made by using the local position
|
each connection is made by using the local position
|
||||||
of the terminal and a dynamic id. In the new
|
of the terminal and a dynamic id. In the new
|
||||||
case, each terminal should have it's own uuid to
|
case, each terminal should have it's own uuid to
|
||||||
identify it uniquely. When changing each time this
|
identify it uniquely. When changing each time this
|
||||||
uuid, the conductor after updating the part is anymore
|
uuid, the conductor after updating the part is anymore
|
||||||
valid. So if in the loaded document a uuid exists,
|
valid. So if in the loaded document a uuid exists,
|
||||||
use this one and don't create a new one.
|
use this one and don't create a new one.
|
||||||
*/
|
*/
|
||||||
QUuid m_uuid; // default is an invalid uuid.
|
QUuid m_uuid; // default is an invalid uuid.
|
||||||
/**
|
/**
|
||||||
@brief m_name
|
@brief m_name
|
||||||
Name of the element.
|
Name of the element.
|
||||||
It can be used to create wiring harness tables
|
It can be used to create wiring harness tables
|
||||||
*/
|
*/
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief m_pos
|
@brief m_pos
|
||||||
Position of the terminal. The second point is calculated
|
Position of the terminal. The second point is calculated
|
||||||
from this position and the orientation
|
from this position and the orientation
|
||||||
@note
|
@note
|
||||||
Important: this variable is only updated during read
|
Important: this variable is only updated during read
|
||||||
from xml and not during mouse move!
|
from xml and not during mouse move!
|
||||||
It is used to store the initial position so that
|
It is used to store the initial position so that
|
||||||
PartTerminal and Terminal have access to it.
|
PartTerminal and Terminal have access to it.
|
||||||
*/
|
*/
|
||||||
QPointF m_pos{0,0};
|
QPointF m_pos{0,0};
|
||||||
private:
|
private:
|
||||||
QGraphicsObject* q{nullptr};
|
QGraphicsObject* q{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TERMINALDATA_H
|
#endif // TERMINALDATA_H
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
@@ -22,176 +22,176 @@
|
|||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief XRefProperties::XRefProperties
|
@brief XRefProperties::XRefProperties
|
||||||
Default Constructor
|
Default Constructor
|
||||||
*/
|
*/
|
||||||
XRefProperties::XRefProperties()
|
XRefProperties::XRefProperties()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief XRefProperties::toSettings
|
@brief XRefProperties::toSettings
|
||||||
Save to settings
|
Save to settings
|
||||||
@param settings: QSettings to use
|
@param settings: QSettings to use
|
||||||
@param prefix: prefix before properties name
|
@param prefix: prefix before properties name
|
||||||
*/
|
*/
|
||||||
void XRefProperties::toSettings(QSettings &settings,
|
void XRefProperties::toSettings(QSettings &settings,
|
||||||
const QString prefix) const
|
const QString prefix) const
|
||||||
{
|
{
|
||||||
settings.setValue(prefix + "showpowerctc", m_show_power_ctc);
|
settings.setValue(prefix + "showpowerctc", m_show_power_ctc);
|
||||||
QString display = m_display == Cross? "cross" : "contacts";
|
QString display = m_display == Cross? "cross" : "contacts";
|
||||||
settings.setValue(prefix + "displayhas", display);
|
settings.setValue(prefix + "displayhas", display);
|
||||||
QString snap = m_snap_to == Bottom? "bottom" : "label";
|
QString snap = m_snap_to == Bottom? "bottom" : "label";
|
||||||
settings.setValue(prefix + "snapto", snap);
|
settings.setValue(prefix + "snapto", snap);
|
||||||
int offset = m_offset;
|
int offset = m_offset;
|
||||||
settings.setValue(prefix + "offset", offset);
|
settings.setValue(prefix + "offset", offset);
|
||||||
QString master_label = m_master_label;
|
QString master_label = m_master_label;
|
||||||
settings.setValue(prefix + "master_label", master_label);
|
settings.setValue(prefix + "master_label", master_label);
|
||||||
QString slave_label = m_slave_label;
|
QString slave_label = m_slave_label;
|
||||||
settings.setValue(prefix + "slave_label", slave_label);
|
settings.setValue(prefix + "slave_label", slave_label);
|
||||||
|
|
||||||
|
|
||||||
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
settings.setValue(prefix + "xrefpos", var.valueToKey(m_xref_pos));
|
settings.setValue(prefix + "xrefpos", var.valueToKey(m_xref_pos));
|
||||||
|
|
||||||
foreach (QString key, m_prefix.keys()) {
|
foreach (QString key, m_prefix.keys()) {
|
||||||
settings.setValue(prefix + key + "prefix", m_prefix.value(key));
|
settings.setValue(prefix + key + "prefix", m_prefix.value(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief XRefProperties::fromSettings
|
@brief XRefProperties::fromSettings
|
||||||
load from settings
|
load from settings
|
||||||
@param settings: QSettings to use
|
@param settings: QSettings to use
|
||||||
@param prefix: prefix before properties name
|
@param prefix: prefix before properties name
|
||||||
*/
|
*/
|
||||||
void XRefProperties::fromSettings(const QSettings &settings,
|
void XRefProperties::fromSettings(const QSettings &settings,
|
||||||
const QString prefix)
|
const QString prefix)
|
||||||
{
|
{
|
||||||
m_show_power_ctc = settings.value(prefix + "showpowerctc", true).toBool();
|
m_show_power_ctc = settings.value(prefix + "showpowerctc", true).toBool();
|
||||||
QString display = settings.value(prefix + "displayhas", "cross").toString();
|
QString display = settings.value(prefix + "displayhas", "cross").toString();
|
||||||
display == "cross"? m_display = Cross : m_display = Contacts;
|
display == "cross"? m_display = Cross : m_display = Contacts;
|
||||||
QString snap = settings.value(prefix + "snapto", "label").toString();
|
QString snap = settings.value(prefix + "snapto", "label").toString();
|
||||||
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
|
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
|
||||||
m_offset = settings.value(prefix + "offset", "0").toInt();
|
m_offset = settings.value(prefix + "offset", "0").toInt();
|
||||||
m_master_label = settings.value(prefix + "master_label", "%f-%l%c").toString();
|
m_master_label = settings.value(prefix + "master_label", "%f-%l%c").toString();
|
||||||
m_slave_label = settings.value(prefix + "slave_label", "(%f-%l%c)").toString();
|
m_slave_label = settings.value(prefix + "slave_label", "(%f-%l%c)").toString();
|
||||||
|
|
||||||
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
m_xref_pos = Qt::AlignmentFlag(var.keyToValue((settings.value(prefix + "xrefpos").toString()).toStdString().data()));
|
m_xref_pos = Qt::AlignmentFlag(var.keyToValue((settings.value(prefix + "xrefpos").toString()).toStdString().data()));
|
||||||
|
|
||||||
for (QString key : m_prefix_keys) {
|
for (QString key : m_prefix_keys) {
|
||||||
m_prefix.insert(key, settings.value(prefix + key + "prefix").toString());
|
m_prefix.insert(key, settings.value(prefix + key + "prefix").toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief XRefProperties::toXml
|
@brief XRefProperties::toXml
|
||||||
Save to xml
|
Save to xml
|
||||||
@param xml_document : QDomElement to use for saving
|
@param xml_document : QDomElement to use for saving
|
||||||
@return QDomElement
|
@return QDomElement
|
||||||
*/
|
*/
|
||||||
QDomElement XRefProperties::toXml(QDomDocument &xml_document) const
|
QDomElement XRefProperties::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
|
|
||||||
QDomElement xml_element = xml_document.createElement("xref");
|
QDomElement xml_element = xml_document.createElement("xref");
|
||||||
|
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "type", m_key));
|
xml_element.appendChild(createXmlProperty(xml_document, "type", m_key));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "showpowerctc", m_show_power_ctc));
|
xml_element.appendChild(createXmlProperty(xml_document, "showpowerctc", m_show_power_ctc));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "displayhas", m_display == Cross? "cross" : "contacts"));
|
xml_element.appendChild(createXmlProperty(xml_document, "displayhas", m_display == Cross? "cross" : "contacts"));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "snapto", m_snap_to == Bottom? "bottom" : "label"));
|
xml_element.appendChild(createXmlProperty(xml_document, "snapto", m_snap_to == Bottom? "bottom" : "label"));
|
||||||
|
|
||||||
|
|
||||||
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "xrefpos", var.valueToKey(m_xref_pos)));
|
xml_element.appendChild(createXmlProperty(xml_document, "xrefpos", var.valueToKey(m_xref_pos)));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "offset", m_offset));
|
xml_element.appendChild(createXmlProperty(xml_document, "offset", m_offset));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "master_label", m_master_label));
|
xml_element.appendChild(createXmlProperty(xml_document, "master_label", m_master_label));
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, "slave_label", m_slave_label));
|
xml_element.appendChild(createXmlProperty(xml_document, "slave_label", m_slave_label));
|
||||||
|
|
||||||
foreach (QString key, m_prefix.keys()) {
|
foreach (QString key, m_prefix.keys()) {
|
||||||
xml_element.appendChild(createXmlProperty(xml_document, key + "prefix", m_prefix.value(key)));
|
xml_element.appendChild(createXmlProperty(xml_document, key + "prefix", m_prefix.value(key)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return xml_element;
|
return xml_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** RETURNS True
|
/** RETURNS True
|
||||||
@brief XRefProperties::fromXml
|
@brief XRefProperties::fromXml
|
||||||
Load from xml
|
Load from xml
|
||||||
@param xml_element: QDomElement to use for load
|
@param xml_element: QDomElement to use for load
|
||||||
*/
|
*/
|
||||||
bool XRefProperties::fromXml(const QDomElement &xml_element) {
|
bool XRefProperties::fromXml(const QDomElement &xml_element) {
|
||||||
|
|
||||||
if (propertyBool(xml_element, "showpowerctc", &m_show_power_ctc))
|
if (propertyBool(xml_element, "showpowerctc", &m_show_power_ctc))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QString display;
|
QString display;
|
||||||
if (propertyString(xml_element, "displayhas", &display) != PropertyFlags::NotFound) {
|
if (propertyString(xml_element, "displayhas", &display) != PropertyFlags::NotFound) {
|
||||||
display == "cross"? m_display = Cross : m_display = Contacts;
|
display == "cross"? m_display = Cross : m_display = Contacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString snap;
|
QString snap;
|
||||||
if (propertyString(xml_element, "snapto", &snap) != PropertyFlags::NotFound) {
|
if (propertyString(xml_element, "snapto", &snap) != PropertyFlags::NotFound) {
|
||||||
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
|
snap == "bottom"? m_snap_to = Bottom : m_snap_to = Label;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString xrefpos;
|
QString xrefpos;
|
||||||
if (propertyString(xml_element, "xrefpos", &xrefpos) != PropertyFlags::NotFound) {
|
if (propertyString(xml_element, "xrefpos", &xrefpos) != PropertyFlags::NotFound) {
|
||||||
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
m_xref_pos = Qt::AlignmentFlag(var.keyToValue(xrefpos.toStdString().data()));
|
m_xref_pos = Qt::AlignmentFlag(var.keyToValue(xrefpos.toStdString().data()));
|
||||||
}
|
}
|
||||||
// TODO: why it compiles without this true??
|
// TODO: why it compiles without this true??
|
||||||
propertyInteger(xml_element, "offset", &m_offset);
|
propertyInteger(xml_element, "offset", &m_offset);
|
||||||
propertyString(xml_element, "master_label", &m_master_label);
|
propertyString(xml_element, "master_label", &m_master_label);
|
||||||
propertyString(xml_element, "slave_label", &m_slave_label);
|
propertyString(xml_element, "slave_label", &m_slave_label);
|
||||||
QString value;
|
QString value;
|
||||||
foreach (QString key, m_prefix_keys) {
|
foreach (QString key, m_prefix_keys) {
|
||||||
if (!propertyString(xml_element, key + "prefix", &value));
|
if (!propertyString(xml_element, key + "prefix", &value));
|
||||||
m_prefix.insert(key, value);
|
m_prefix.insert(key, value);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief XRefProperties::defaultProperties
|
@brief XRefProperties::defaultProperties
|
||||||
@return the default properties stored in the setting file
|
@return the default properties stored in the setting file
|
||||||
For the xref, there is 2 propreties.
|
For the xref, there is 2 propreties.
|
||||||
For coil, stored with the string "coil" in the returned QHash.
|
For coil, stored with the string "coil" in the returned QHash.
|
||||||
For protection, stored with the string "protection" in the returned QHash.
|
For protection, stored with the string "protection" in the returned QHash.
|
||||||
*/
|
*/
|
||||||
QHash<QString, XRefProperties> XRefProperties::defaultProperties()
|
QHash<QString, XRefProperties> XRefProperties::defaultProperties()
|
||||||
{
|
{
|
||||||
QHash <QString, XRefProperties> hash;
|
QHash <QString, XRefProperties> hash;
|
||||||
QStringList keys;
|
QStringList keys;
|
||||||
keys << "coil" << "protection" << "commutator";
|
keys << "coil" << "protection" << "commutator";
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
foreach (QString key, keys)
|
foreach (QString key, keys)
|
||||||
{
|
{
|
||||||
XRefProperties properties;
|
XRefProperties properties;
|
||||||
QString str("diagrameditor/defaultxref");
|
QString str("diagrameditor/defaultxref");
|
||||||
properties.fromSettings(settings, str += key);
|
properties.fromSettings(settings, str += key);
|
||||||
hash.insert(key, properties);
|
hash.insert(key, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XRefProperties::operator ==(const XRefProperties &xrp) const{
|
bool XRefProperties::operator ==(const XRefProperties &xrp) const{
|
||||||
return (m_show_power_ctc == xrp.m_show_power_ctc &&
|
return (m_show_power_ctc == xrp.m_show_power_ctc &&
|
||||||
m_display == xrp.m_display &&
|
m_display == xrp.m_display &&
|
||||||
m_snap_to == xrp.m_snap_to &&
|
m_snap_to == xrp.m_snap_to &&
|
||||||
m_prefix == xrp.m_prefix &&
|
m_prefix == xrp.m_prefix &&
|
||||||
m_master_label == xrp.m_master_label &&
|
m_master_label == xrp.m_master_label &&
|
||||||
m_offset == xrp.m_offset &&
|
m_offset == xrp.m_offset &&
|
||||||
m_xref_pos == xrp.m_xref_pos );
|
m_xref_pos == xrp.m_xref_pos );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XRefProperties::operator !=(const XRefProperties &xrp) const
|
bool XRefProperties::operator !=(const XRefProperties &xrp) const
|
||||||
{
|
{
|
||||||
return (! (*this == xrp));
|
return (! (*this == xrp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef XREFPROPERTIES_H
|
#ifndef XREFPROPERTIES_H
|
||||||
#define XREFPROPERTIES_H
|
#define XREFPROPERTIES_H
|
||||||
@@ -24,72 +24,72 @@
|
|||||||
#include "propertiesinterface.h"
|
#include "propertiesinterface.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The XRefProperties class
|
@brief The XRefProperties class
|
||||||
this class store properties used by XrefItem
|
this class store properties used by XrefItem
|
||||||
*/
|
*/
|
||||||
class XRefProperties : public PropertiesInterface
|
class XRefProperties : public PropertiesInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XRefProperties();
|
XRefProperties();
|
||||||
|
|
||||||
enum DisplayHas {
|
enum DisplayHas {
|
||||||
Cross,
|
Cross,
|
||||||
Contacts
|
Contacts
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SnapTo {
|
enum SnapTo {
|
||||||
Bottom,
|
Bottom,
|
||||||
Label
|
Label
|
||||||
};
|
};
|
||||||
|
|
||||||
void toSettings (QSettings &settings, const QString& = QString()) const override;
|
void toSettings (QSettings &settings, const QString& = QString()) const override;
|
||||||
void fromSettings (const QSettings &settings, const QString& = QString()) override;
|
void fromSettings (const QSettings &settings, const QString& = QString()) override;
|
||||||
void fromSettings (const QSettings &settings,
|
void fromSettings (const QSettings &settings,
|
||||||
const QString = QString()) override;
|
const QString = QString()) override;
|
||||||
QDomElement toXml (QDomDocument &xml_document) const override;
|
QDomElement toXml (QDomDocument &xml_document) const override;
|
||||||
bool fromXml(const QDomElement &xml_element) override;
|
bool fromXml(const QDomElement &xml_element) override;
|
||||||
|
|
||||||
static QHash<QString, XRefProperties> defaultProperties();
|
static QHash<QString, XRefProperties> defaultProperties();
|
||||||
|
|
||||||
bool operator == (const XRefProperties &xrp) const;
|
bool operator == (const XRefProperties &xrp) const;
|
||||||
bool operator != (const XRefProperties &xrp) const;
|
bool operator != (const XRefProperties &xrp) const;
|
||||||
|
|
||||||
void setShowPowerContac (const bool a) {m_show_power_ctc = a;}
|
void setShowPowerContac (const bool a) {m_show_power_ctc = a;}
|
||||||
bool showPowerContact () const {return m_show_power_ctc;}
|
bool showPowerContact () const {return m_show_power_ctc;}
|
||||||
|
|
||||||
void setDisplayHas (const DisplayHas dh) {m_display = dh;}
|
void setDisplayHas (const DisplayHas dh) {m_display = dh;}
|
||||||
DisplayHas displayHas () const {return m_display;}
|
DisplayHas displayHas () const {return m_display;}
|
||||||
|
|
||||||
void setSnapTo (const SnapTo st) {m_snap_to = st;}
|
void setSnapTo (const SnapTo st) {m_snap_to = st;}
|
||||||
SnapTo snapTo () const {return m_snap_to;}
|
SnapTo snapTo () const {return m_snap_to;}
|
||||||
|
|
||||||
void setXrefPos(const Qt::AlignmentFlag xref) {m_xref_pos = xref;}
|
void setXrefPos(const Qt::AlignmentFlag xref) {m_xref_pos = xref;}
|
||||||
Qt::AlignmentFlag getXrefPos() const {return m_xref_pos;}
|
Qt::AlignmentFlag getXrefPos() const {return m_xref_pos;}
|
||||||
void setPrefix (const QString &key, const QString &value) {m_prefix.insert(key, value);}
|
void setPrefix (const QString &key, const QString &value) {m_prefix.insert(key, value);}
|
||||||
QString prefix (const QString &key) const {return m_prefix.value(key);}
|
QString prefix (const QString &key) const {return m_prefix.value(key);}
|
||||||
|
|
||||||
void setMasterLabel (const QString master) {m_master_label = master;}
|
void setMasterLabel (const QString master) {m_master_label = master;}
|
||||||
QString masterLabel () const {return m_master_label;}
|
QString masterLabel () const {return m_master_label;}
|
||||||
|
|
||||||
void setSlaveLabel(const QString slave) {m_slave_label = slave;}
|
void setSlaveLabel(const QString slave) {m_slave_label = slave;}
|
||||||
QString slaveLabel () const {return m_slave_label;}
|
QString slaveLabel () const {return m_slave_label;}
|
||||||
|
|
||||||
void setOffset(const int offset) {m_offset = offset;}
|
void setOffset(const int offset) {m_offset = offset;}
|
||||||
int offset() const {return m_offset;}
|
int offset() const {return m_offset;}
|
||||||
|
|
||||||
void setKey(QString& key) {m_key = key;}
|
void setKey(QString& key) {m_key = key;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_show_power_ctc{true};
|
bool m_show_power_ctc{true};
|
||||||
DisplayHas m_display{Cross};
|
DisplayHas m_display{Cross};
|
||||||
SnapTo m_snap_to{Bottom};
|
SnapTo m_snap_to{Bottom};
|
||||||
Qt::AlignmentFlag m_xref_pos{Qt::AlignBottom};
|
Qt::AlignmentFlag m_xref_pos{Qt::AlignBottom};
|
||||||
QHash <QString, QString> m_prefix;
|
QHash <QString, QString> m_prefix;
|
||||||
QStringList m_prefix_keys{"power","delay","switch"};
|
QStringList m_prefix_keys{"power","delay","switch"};
|
||||||
QString m_master_label{"%f-%l%c"};
|
QString m_master_label{"%f-%l%c"};
|
||||||
QString m_slave_label{"(%f-%l%c)"};
|
QString m_slave_label{"(%f-%l%c)"};
|
||||||
int m_offset{0};
|
int m_offset{0};
|
||||||
QString m_key;
|
QString m_key;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // XREFPROPERTIES_H
|
#endif // XREFPROPERTIES_H
|
||||||
|
|||||||
996
sources/qet.cpp
996
sources/qet.cpp
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef CONDUCTOR_H
|
#ifndef CONDUCTOR_H
|
||||||
#define CONDUCTOR_H
|
#define CONDUCTOR_H
|
||||||
@@ -37,198 +37,198 @@ class QetGraphicsHandlerItem;
|
|||||||
typedef QPair<QPointF, Qt::Corner> ConductorBend;
|
typedef QPair<QPointF, Qt::Corner> ConductorBend;
|
||||||
typedef QHash<Qt::Corner, ConductorProfile> ConductorProfilesGroup;
|
typedef QHash<Qt::Corner, ConductorProfile> ConductorProfilesGroup;
|
||||||
/**
|
/**
|
||||||
This class represents a conductor, i.e. a wire between two element
|
This class represents a conductor, i.e. a wire between two element
|
||||||
terminals.
|
terminals.
|
||||||
*/
|
*/
|
||||||
class Conductor : public QGraphicsObject, public PropertiesInterface
|
class Conductor : public QGraphicsObject, public PropertiesInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
||||||
Q_PROPERTY(int animPath READ fakePath WRITE updatePathAnimate)
|
Q_PROPERTY(int animPath READ fakePath WRITE updatePathAnimate)
|
||||||
Q_PROPERTY(ConductorProperties properties READ properties WRITE setProperties)
|
Q_PROPERTY(ConductorProperties properties READ properties WRITE setProperties)
|
||||||
Q_PROPERTY(autonum::sequentialNumbers sequenceNum READ sequenceNum WRITE setSequenceNum)
|
Q_PROPERTY(autonum::sequentialNumbers sequenceNum READ sequenceNum WRITE setSequenceNum)
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void propertiesChange();
|
void propertiesChange();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Conductor(Terminal *, Terminal *);
|
Conductor(Terminal *, Terminal *);
|
||||||
~Conductor() override;
|
~Conductor() override;
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Conductor(const Conductor &);
|
Conductor(const Conductor &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1001 };
|
enum { Type = UserType + 1001 };
|
||||||
enum Highlight { None, Normal, Alert };
|
enum Highlight { None, Normal, Alert };
|
||||||
|
|
||||||
Terminal *terminal1;
|
Terminal *terminal1;
|
||||||
Terminal *terminal2;
|
Terminal *terminal2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@brief type
|
@brief type
|
||||||
Enable the use of qgraphicsitem_cast
|
Enable the use of qgraphicsitem_cast
|
||||||
to safely cast a QGraphicsItem into a conductor.
|
to safely cast a QGraphicsItem into a conductor.
|
||||||
@return the QGraphicsItem type
|
@return the QGraphicsItem type
|
||||||
*/
|
*/
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
Diagram *diagram() const;
|
Diagram *diagram() const;
|
||||||
ConductorTextItem *textItem() const;
|
ConductorTextItem *textItem() const;
|
||||||
void updatePath(const QRectF & = QRectF());
|
void updatePath(const QRectF & = QRectF());
|
||||||
|
|
||||||
//This method do nothing, it's only made to be used with Q_PROPERTY
|
//This method do nothing, it's only made to be used with Q_PROPERTY
|
||||||
//It's used to anim the path when is change
|
//It's used to anim the path when is change
|
||||||
void updatePathAnimate(const int = 1) {updatePath();}
|
void updatePathAnimate(const int = 1) {updatePath();}
|
||||||
int fakePath() {return 1;}
|
int fakePath() {return 1;}
|
||||||
|
|
||||||
void paint(
|
void paint(
|
||||||
QPainter *,
|
QPainter *,
|
||||||
const QStyleOptionGraphicsItem *,
|
const QStyleOptionGraphicsItem *,
|
||||||
QWidget *) override;
|
QWidget *) override;
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
QPainterPath shape() const override;
|
QPainterPath shape() const override;
|
||||||
virtual QPainterPath nearShape() const;
|
virtual QPainterPath nearShape() const;
|
||||||
qreal length() const;
|
qreal length() const;
|
||||||
ConductorSegment *middleSegment();
|
ConductorSegment *middleSegment();
|
||||||
QPointF posForText(Qt::Orientations &flag);
|
QPointF posForText(Qt::Orientations &flag);
|
||||||
void refreshText();
|
void refreshText();
|
||||||
void setPath(const QPainterPath &path);
|
void setPath(const QPainterPath &path);
|
||||||
QPainterPath path() const;
|
QPainterPath path() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static bool valideXml (QDomElement &);
|
static bool valideXml (QDomElement &);
|
||||||
bool fromXml (const QDomElement &) override;
|
bool fromXml (const QDomElement &) override;
|
||||||
//QDomElement toXml (QDomDocument &, QHash<Terminal *, int> &) const;
|
//QDomElement toXml (QDomDocument &, QHash<Terminal *, int> &) const;
|
||||||
QDomElement toXml (QDomDocument &doc) const override;
|
QDomElement toXml (QDomDocument &doc) const override;
|
||||||
private:
|
private:
|
||||||
bool pathFromXml(const QDomElement &);
|
bool pathFromXml(const QDomElement &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QVector <QPointF> handlerPoints() const;
|
QVector <QPointF> handlerPoints() const;
|
||||||
const QList<ConductorSegment *> segmentsList() const;
|
const QList<ConductorSegment *> segmentsList() const;
|
||||||
|
|
||||||
void setPropertyToPotential(
|
void setPropertyToPotential(
|
||||||
const ConductorProperties &property,
|
const ConductorProperties &property,
|
||||||
bool only_text = false);
|
bool only_text = false);
|
||||||
void setProperties(const ConductorProperties &property);
|
void setProperties(const ConductorProperties &property);
|
||||||
ConductorProperties properties() const;
|
ConductorProperties properties() const;
|
||||||
|
|
||||||
void setProfile(const ConductorProfile &, Qt::Corner);
|
void setProfile(const ConductorProfile &, Qt::Corner);
|
||||||
ConductorProfile profile(Qt::Corner) const;
|
ConductorProfile profile(Qt::Corner) const;
|
||||||
void setProfiles(const ConductorProfilesGroup &);
|
void setProfiles(const ConductorProfilesGroup &);
|
||||||
ConductorProfilesGroup profiles() const;
|
ConductorProfilesGroup profiles() const;
|
||||||
void calculateTextItemPosition();
|
void calculateTextItemPosition();
|
||||||
virtual Highlight highlight() const;
|
virtual Highlight highlight() const;
|
||||||
virtual void setHighlighted(Highlight);
|
virtual void setHighlighted(Highlight);
|
||||||
QSet<Conductor *> relatedPotentialConductors(
|
QSet<Conductor *> relatedPotentialConductors(
|
||||||
const bool all_diagram = true,
|
const bool all_diagram = true,
|
||||||
QList <Terminal *> *t_list=nullptr);
|
QList <Terminal *> *t_list=nullptr);
|
||||||
QETDiagramEditor* diagramEditor() const;
|
QETDiagramEditor* diagramEditor() const;
|
||||||
void editProperty ();
|
void editProperty ();
|
||||||
|
|
||||||
autonum::sequentialNumbers sequenceNum () const
|
autonum::sequentialNumbers sequenceNum () const
|
||||||
{return m_autoNum_seq;}
|
{return m_autoNum_seq;}
|
||||||
autonum::sequentialNumbers& rSequenceNum()
|
autonum::sequentialNumbers& rSequenceNum()
|
||||||
{return m_autoNum_seq;}
|
{return m_autoNum_seq;}
|
||||||
void setSequenceNum(const autonum::sequentialNumbers& sn);
|
void setSequenceNum(const autonum::sequentialNumbers& sn);
|
||||||
|
|
||||||
QList<QPointF> junctions() const;
|
QList<QPointF> junctions() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setUpConnectionForFormula(
|
void setUpConnectionForFormula(
|
||||||
QString old_formula, QString new_formula);
|
QString old_formula, QString new_formula);
|
||||||
autonum::sequentialNumbers m_autoNum_seq;
|
autonum::sequentialNumbers m_autoNum_seq;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setFreezeLabel(bool freeze);
|
void setFreezeLabel(bool freeze);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void displayedTextChanged();
|
void displayedTextChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseDoubleClickEvent(
|
void mouseDoubleClickEvent(
|
||||||
QGraphicsSceneMouseEvent *event) override;
|
QGraphicsSceneMouseEvent *event) override;
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseReleaseEvent(
|
void mouseReleaseEvent(
|
||||||
QGraphicsSceneMouseEvent *event) override;
|
QGraphicsSceneMouseEvent *event) override;
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
QVariant itemChange(
|
QVariant itemChange(
|
||||||
GraphicsItemChange, const QVariant &) override;
|
GraphicsItemChange, const QVariant &) override;
|
||||||
bool sceneEventFilter(
|
bool sceneEventFilter(
|
||||||
QGraphicsItem *watched, QEvent *event) override;
|
QGraphicsItem *watched, QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void adjusteHandlerPos();
|
void adjusteHandlerPos();
|
||||||
|
|
||||||
void handlerMousePressEvent(
|
void handlerMousePressEvent(
|
||||||
QetGraphicsHandlerItem *qghi,
|
QetGraphicsHandlerItem *qghi,
|
||||||
QGraphicsSceneMouseEvent *event);
|
QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseMoveEvent(
|
void handlerMouseMoveEvent(
|
||||||
QetGraphicsHandlerItem *qghi,
|
QetGraphicsHandlerItem *qghi,
|
||||||
QGraphicsSceneMouseEvent *event);
|
QGraphicsSceneMouseEvent *event);
|
||||||
void handlerMouseReleaseEvent(
|
void handlerMouseReleaseEvent(
|
||||||
QetGraphicsHandlerItem *qghi,
|
QetGraphicsHandlerItem *qghi,
|
||||||
QGraphicsSceneMouseEvent *event);
|
QGraphicsSceneMouseEvent *event);
|
||||||
void addHandler();
|
void addHandler();
|
||||||
void removeHandler();
|
void removeHandler();
|
||||||
|
|
||||||
|
|
||||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||||
int m_vector_index = -1;
|
int m_vector_index = -1;
|
||||||
bool m_mouse_over{false};
|
bool m_mouse_over{false};
|
||||||
/// Functional properties
|
/// Functional properties
|
||||||
ConductorProperties m_properties;
|
ConductorProperties m_properties;
|
||||||
/// Text input for non simple, non-singleline conductors
|
/// Text input for non simple, non-singleline conductors
|
||||||
ConductorTextItem *m_text_item{nullptr};
|
ConductorTextItem *m_text_item{nullptr};
|
||||||
/// Segments composing the conductor
|
/// Segments composing the conductor
|
||||||
ConductorSegment *segments{nullptr};
|
ConductorSegment *segments{nullptr};
|
||||||
/// Attributs related to mouse interaction
|
/// Attributs related to mouse interaction
|
||||||
bool m_moving_segment{false};
|
bool m_moving_segment{false};
|
||||||
int moved_point;
|
int moved_point;
|
||||||
qreal m_previous_z_value;
|
qreal m_previous_z_value;
|
||||||
ConductorSegment *m_moved_segment;
|
ConductorSegment *m_moved_segment;
|
||||||
QPointF before_mov_text_pos_;
|
QPointF before_mov_text_pos_;
|
||||||
/// Whether the conductor was manually modified by users
|
/// Whether the conductor was manually modified by users
|
||||||
bool modified_path{false};
|
bool modified_path{false};
|
||||||
/// Whether the current profile should be saved as soon as possible
|
/// Whether the current profile should be saved as soon as possible
|
||||||
bool has_to_save_profile{false};
|
bool has_to_save_profile{false};
|
||||||
/// conductor profile: "photography" of what the conductor is supposed to look
|
/// conductor profile: "photography" of what the conductor is supposed to look
|
||||||
/// like - there is one profile per kind of traject
|
/// like - there is one profile per kind of traject
|
||||||
ConductorProfilesGroup conductor_profiles;
|
ConductorProfilesGroup conductor_profiles;
|
||||||
/// Define whether and how the conductor should be highlighted
|
/// Define whether and how the conductor should be highlighted
|
||||||
Highlight must_highlight_{Conductor::None};
|
Highlight must_highlight_{Conductor::None};
|
||||||
bool m_valid;
|
bool m_valid;
|
||||||
bool m_freeze_label = false;
|
bool m_freeze_label = false;
|
||||||
|
|
||||||
/// QPen et QBrush objects used to draw conductors
|
/// QPen et QBrush objects used to draw conductors
|
||||||
static QPen conductor_pen;
|
static QPen conductor_pen;
|
||||||
static QBrush conductor_brush;
|
static QBrush conductor_brush;
|
||||||
static bool pen_and_brush_initialized;
|
static bool pen_and_brush_initialized;
|
||||||
QPainterPath m_path;
|
QPainterPath m_path;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void segmentsToPath();
|
void segmentsToPath();
|
||||||
void saveProfile(bool = true);
|
void saveProfile(bool = true);
|
||||||
void generateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
|
void generateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
|
||||||
void updateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
|
void updateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
|
||||||
uint segmentsCount(QET::ConductorSegmentType = QET::Both) const;
|
uint segmentsCount(QET::ConductorSegmentType = QET::Both) const;
|
||||||
QList<QPointF> segmentsToPoints() const;
|
QList<QPointF> segmentsToPoints() const;
|
||||||
QList<ConductorBend> bends() const;
|
QList<ConductorBend> bends() const;
|
||||||
|
|
||||||
void pointsToSegments(const QList<QPointF>&);
|
void pointsToSegments(const QList<QPointF>&);
|
||||||
Qt::Corner currentPathType() const;
|
Qt::Corner currentPathType() const;
|
||||||
void deleteSegments();
|
void deleteSegments();
|
||||||
static int getCoeff(const qreal &, const qreal &);
|
static int getCoeff(const qreal &, const qreal &);
|
||||||
static int getSign(const qreal &);
|
static int getSign(const qreal &);
|
||||||
QHash<ConductorSegmentProfile *, qreal> shareOffsetBetweenSegments(const qreal &offset, const QList<ConductorSegmentProfile *> &, const qreal & = 0.01) const;
|
QHash<ConductorSegmentProfile *, qreal> shareOffsetBetweenSegments(const qreal &offset, const QList<ConductorSegmentProfile *> &, const qreal & = 0.01) const;
|
||||||
static QPointF extendTerminal(const QPointF &, Qet::Orientation, qreal = 9.0);
|
static QPointF extendTerminal(const QPointF &, Qet::Orientation, qreal = 9.0);
|
||||||
static Qt::Corner movementType(const QPointF &, const QPointF &);
|
static Qt::Corner movementType(const QPointF &, const QPointF &);
|
||||||
static QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &);
|
static QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &);
|
||||||
};
|
};
|
||||||
|
|
||||||
Conductor * longuestConductorInPotential (Conductor *conductor, bool all_diagram = false);
|
Conductor * longuestConductorInPotential (Conductor *conductor, bool all_diagram = false);
|
||||||
@@ -238,7 +238,7 @@ QList <Conductor *> relatedConductors (const Conductor *conductor);
|
|||||||
//return true if @a is between or at @b and @c.
|
//return true if @a is between or at @b and @c.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool isBetween (const T a, const T b, const T c) {
|
bool isBetween (const T a, const T b, const T c) {
|
||||||
return (b <= c)? (a >= b && a <= c) : (a <= b && a >= c);
|
return (b <= c)? (a >= b && a <= c) : (a <= b && a >= c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "conductortextitem.h"
|
#include "conductortextitem.h"
|
||||||
#include "conductor.h"
|
#include "conductor.h"
|
||||||
@@ -21,258 +21,258 @@
|
|||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@param parent_conductor Conducteur auquel ce texte est rattache
|
@param parent_conductor Conducteur auquel ce texte est rattache
|
||||||
*/
|
*/
|
||||||
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
|
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
|
||||||
DiagramTextItem(parent_conductor),
|
DiagramTextItem(parent_conductor),
|
||||||
parent_conductor_(parent_conductor)
|
parent_conductor_(parent_conductor)
|
||||||
{
|
{
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@param text Le texte affiche par le champ de texte
|
@param text Le texte affiche par le champ de texte
|
||||||
@param parent_conductor Conducteur auquel ce texte est rattache
|
@param parent_conductor Conducteur auquel ce texte est rattache
|
||||||
*/
|
*/
|
||||||
ConductorTextItem::ConductorTextItem(
|
ConductorTextItem::ConductorTextItem(
|
||||||
const QString &text, Conductor *parent_conductor) :
|
const QString &text, Conductor *parent_conductor) :
|
||||||
DiagramTextItem(text, parent_conductor),
|
DiagramTextItem(text, parent_conductor),
|
||||||
parent_conductor_(parent_conductor),
|
parent_conductor_(parent_conductor),
|
||||||
moved_by_user_(false),
|
moved_by_user_(false),
|
||||||
rotate_by_user_(false)
|
rotate_by_user_(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destructeur
|
Destructeur
|
||||||
*/
|
*/
|
||||||
ConductorTextItem::~ConductorTextItem()
|
ConductorTextItem::~ConductorTextItem()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return le conducteur parent de ce champ de texte, ou 0 si celui-ci n'en a
|
@return le conducteur parent de ce champ de texte, ou 0 si celui-ci n'en a
|
||||||
pas
|
pas
|
||||||
*/
|
*/
|
||||||
Conductor *ConductorTextItem::parentConductor() const
|
Conductor *ConductorTextItem::parentConductor() const
|
||||||
{
|
{
|
||||||
return(parent_conductor_);
|
return(parent_conductor_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConductorTextItem::toXml(QDomDocument& doc, QDomElement& e) {
|
void ConductorTextItem::toXml(QDomDocument& doc, QDomElement& e) {
|
||||||
if(moved_by_user_)
|
if(moved_by_user_)
|
||||||
{
|
{
|
||||||
e.appendChild(PropertiesInterface::createXmlProperty(doc, "userx", pos().x()));
|
e.appendChild(PropertiesInterface::createXmlProperty(doc, "userx", pos().x()));
|
||||||
e.appendChild(PropertiesInterface::createXmlProperty(doc, "usery", pos().y()));
|
e.appendChild(PropertiesInterface::createXmlProperty(doc, "usery", pos().y()));
|
||||||
}
|
}
|
||||||
if(rotate_by_user_)
|
if(rotate_by_user_)
|
||||||
e.appendChild(PropertiesInterface::createXmlProperty(doc, "rotation", rotation()));
|
e.appendChild(PropertiesInterface::createXmlProperty(doc, "rotation", rotation()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ConductorTextItem::fromXml
|
@brief ConductorTextItem::fromXml
|
||||||
Read the properties stored in the xml element given in parameter
|
Read the properties stored in the xml element given in parameter
|
||||||
@param e
|
@param e
|
||||||
*/
|
*/
|
||||||
void ConductorTextItem::fromXml(const QDomElement &e) {
|
void ConductorTextItem::fromXml(const QDomElement &e) {
|
||||||
|
|
||||||
double userx=0, usery=0;
|
double userx=0, usery=0;
|
||||||
if (PropertiesInterface::propertyDouble(e, "userx", &userx) == PropertiesInterface::PropertyFlags::Success &&
|
if (PropertiesInterface::propertyDouble(e, "userx", &userx) == PropertiesInterface::PropertyFlags::Success &&
|
||||||
PropertiesInterface::propertyDouble(e, "usery", &usery) == PropertiesInterface::PropertyFlags::Success) {
|
PropertiesInterface::propertyDouble(e, "usery", &usery) == PropertiesInterface::PropertyFlags::Success) {
|
||||||
setPos(userx, usery);
|
setPos(userx, usery);
|
||||||
moved_by_user_ = true;
|
moved_by_user_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
double rotation;
|
double rotation;
|
||||||
if (PropertiesInterface::propertyDouble(e, "rotation", &rotation) == PropertiesInterface::PropertyFlags::Success) {
|
if (PropertiesInterface::propertyDouble(e, "rotation", &rotation) == PropertiesInterface::PropertyFlags::Success) {
|
||||||
setRotation(rotation);
|
setRotation(rotation);
|
||||||
rotate_by_user_ = true;
|
rotate_by_user_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return true si ce champ de texte a ete explictement deplace par
|
@return true si ce champ de texte a ete explictement deplace par
|
||||||
l'utilisateur, false sinon
|
l'utilisateur, false sinon
|
||||||
*/
|
*/
|
||||||
bool ConductorTextItem::wasMovedByUser() const
|
bool ConductorTextItem::wasMovedByUser() const
|
||||||
{
|
{
|
||||||
return(moved_by_user_);
|
return(moved_by_user_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ConductorTextItem::wasRotateByUser
|
@brief ConductorTextItem::wasRotateByUser
|
||||||
@return true if text was explicit moved by user else false
|
@return true if text was explicit moved by user else false
|
||||||
*/
|
*/
|
||||||
bool ConductorTextItem::wasRotateByUser() const
|
bool ConductorTextItem::wasRotateByUser() const
|
||||||
{
|
{
|
||||||
return(rotate_by_user_);
|
return(rotate_by_user_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param moved_by_user true pour que la position du texte soit consideree
|
@param moved_by_user true pour que la position du texte soit consideree
|
||||||
comme ayant ete definie par l'utilisateur (et donc soit sauvegardee), false
|
comme ayant ete definie par l'utilisateur (et donc soit sauvegardee), false
|
||||||
pour remettre le texte a sa position originelle
|
pour remettre le texte a sa position originelle
|
||||||
*/
|
*/
|
||||||
void ConductorTextItem::forceMovedByUser(bool moved_by_user) {
|
void ConductorTextItem::forceMovedByUser(bool moved_by_user) {
|
||||||
if (moved_by_user == moved_by_user_) return;
|
if (moved_by_user == moved_by_user_) return;
|
||||||
|
|
||||||
moved_by_user_ = moved_by_user;
|
moved_by_user_ = moved_by_user;
|
||||||
if (!moved_by_user && parent_conductor_) {
|
if (!moved_by_user && parent_conductor_) {
|
||||||
parent_conductor_ -> calculateTextItemPosition();
|
parent_conductor_ -> calculateTextItemPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ConductorTextItem::forceRotateByUser
|
@brief ConductorTextItem::forceRotateByUser
|
||||||
@param rotate_by_user true pour que la rotation du texte soit consideree
|
@param rotate_by_user true pour que la rotation du texte soit consideree
|
||||||
comme ayant ete definie par l'utilisateur (et donc soit sauvegardee), false
|
comme ayant ete definie par l'utilisateur (et donc soit sauvegardee), false
|
||||||
pour remettre le texte a sont angle originelle
|
pour remettre le texte a sont angle originelle
|
||||||
*/
|
*/
|
||||||
void ConductorTextItem::forceRotateByUser(bool rotate_by_user) {
|
void ConductorTextItem::forceRotateByUser(bool rotate_by_user) {
|
||||||
if (rotate_by_user == rotate_by_user_) return;
|
if (rotate_by_user == rotate_by_user_) return;
|
||||||
|
|
||||||
rotate_by_user_ = rotate_by_user;
|
rotate_by_user_ = rotate_by_user;
|
||||||
if (!rotate_by_user && parent_conductor_) {
|
if (!rotate_by_user && parent_conductor_) {
|
||||||
parent_conductor_ -> calculateTextItemPosition();
|
parent_conductor_ -> calculateTextItemPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ConductorTextItem::setPos
|
@brief ConductorTextItem::setPos
|
||||||
@param pos
|
@param pos
|
||||||
*/
|
*/
|
||||||
void ConductorTextItem::setPos(const QPointF &pos)
|
void ConductorTextItem::setPos(const QPointF &pos)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* In some condition the conductor text item is outside the border of folio in the left.
|
* In some condition the conductor text item is outside the border of folio in the left.
|
||||||
* They cause a margin on the left of folio and in most case this margin is unwanted and annoying the user.
|
* They cause a margin on the left of folio and in most case this margin is unwanted and annoying the user.
|
||||||
* If the text is empty and the scene position is outside the border (left and top),
|
* If the text is empty and the scene position is outside the border (left and top),
|
||||||
* we can say that this position, is unwanted by user.
|
* we can say that this position, is unwanted by user.
|
||||||
* So we move this text item to the top left of the bounding rect of parent conductors, because we sure this position is wanted by user.
|
* So we move this text item to the top left of the bounding rect of parent conductors, because we sure this position is wanted by user.
|
||||||
*/
|
*/
|
||||||
DiagramTextItem::setPos(pos);
|
DiagramTextItem::setPos(pos);
|
||||||
if(toPlainText().isEmpty() && (scenePos().x() < 0 || scenePos().y() < 0))
|
if(toPlainText().isEmpty() && (scenePos().x() < 0 || scenePos().y() < 0))
|
||||||
{
|
{
|
||||||
Conductor *cond = parentConductor();
|
Conductor *cond = parentConductor();
|
||||||
if(cond)
|
if(cond)
|
||||||
DiagramTextItem::setPos(cond->boundingRect().topLeft());
|
DiagramTextItem::setPos(cond->boundingRect().topLeft());
|
||||||
else
|
else
|
||||||
DiagramTextItem::setPos(0,0);
|
DiagramTextItem::setPos(0,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ConductorTextItem::setPos
|
@brief ConductorTextItem::setPos
|
||||||
@param x
|
@param x
|
||||||
@param y
|
@param y
|
||||||
*/
|
*/
|
||||||
void ConductorTextItem::setPos(qreal x, qreal y)
|
void ConductorTextItem::setPos(qreal x, qreal y)
|
||||||
{
|
{
|
||||||
QPointF p(x,y);
|
QPointF p(x,y);
|
||||||
setPos(p);
|
setPos(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ConductorTextItem::mousePressEvent
|
@brief ConductorTextItem::mousePressEvent
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void ConductorTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
void ConductorTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
before_mov_pos_ = pos();
|
before_mov_pos_ = pos();
|
||||||
DiagramTextItem::mousePressEvent(event);
|
DiagramTextItem::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ConductorTextItem::mouseMoveEvent
|
@brief ConductorTextItem::mouseMoveEvent
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void ConductorTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
void ConductorTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
if (textInteractionFlags() & Qt::TextEditable) QGraphicsTextItem::mouseMoveEvent(event);
|
if (textInteractionFlags() & Qt::TextEditable) QGraphicsTextItem::mouseMoveEvent(event);
|
||||||
|
|
||||||
else if ((flags() & QGraphicsItem::ItemIsMovable) && (event -> buttons() & Qt::LeftButton)) {
|
else if ((flags() & QGraphicsItem::ItemIsMovable) && (event -> buttons() & Qt::LeftButton)) {
|
||||||
|
|
||||||
QPointF intended_pos = event ->scenePos() + m_mouse_to_origin_movement;
|
QPointF intended_pos = event ->scenePos() + m_mouse_to_origin_movement;
|
||||||
|
|
||||||
if (parent_conductor_) {
|
if (parent_conductor_) {
|
||||||
if (parent_conductor_->nearShape().contains(intended_pos)) {
|
if (parent_conductor_->nearShape().contains(intended_pos)) {
|
||||||
event->modifiers() == Qt::ControlModifier ? setPos(intended_pos) : setPos(Diagram::snapToGrid(intended_pos));
|
event->modifiers() == Qt::ControlModifier ? setPos(intended_pos) : setPos(Diagram::snapToGrid(intended_pos));
|
||||||
parent_conductor_ -> setHighlighted(Conductor::Normal);
|
parent_conductor_ -> setHighlighted(Conductor::Normal);
|
||||||
} else {
|
} else {
|
||||||
parent_conductor_ -> setHighlighted(Conductor::Alert);
|
parent_conductor_ -> setHighlighted(Conductor::Alert);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else event -> ignore();
|
else event -> ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief ConductorTextItem::mouseReleaseEvent
|
@brief ConductorTextItem::mouseReleaseEvent
|
||||||
@param e
|
@param e
|
||||||
*/
|
*/
|
||||||
void ConductorTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
void ConductorTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
||||||
if (flags() & QGraphicsItem::ItemIsMovable) {
|
if (flags() & QGraphicsItem::ItemIsMovable) {
|
||||||
|
|
||||||
if (Diagram *diagram_ptr = diagram()) {
|
if (Diagram *diagram_ptr = diagram()) {
|
||||||
QPointF applied_movement = pos() - before_mov_pos_;
|
QPointF applied_movement = pos() - before_mov_pos_;
|
||||||
|
|
||||||
if (!applied_movement.isNull()) {
|
if (!applied_movement.isNull()) {
|
||||||
//Create an undo object
|
//Create an undo object
|
||||||
MoveConductorsTextsCommand *undo_object = new MoveConductorsTextsCommand(diagram_ptr);
|
MoveConductorsTextsCommand *undo_object = new MoveConductorsTextsCommand(diagram_ptr);
|
||||||
undo_object -> addTextMovement(this, before_mov_pos_, pos(), moved_by_user_);
|
undo_object -> addTextMovement(this, before_mov_pos_, pos(), moved_by_user_);
|
||||||
|
|
||||||
moved_by_user_ = true;
|
moved_by_user_ = true;
|
||||||
|
|
||||||
diagram_ptr -> undoStack().push(undo_object);
|
diagram_ptr -> undoStack().push(undo_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent_conductor_) {
|
if (parent_conductor_) {
|
||||||
parent_conductor_ -> setHighlighted(Conductor::None);
|
parent_conductor_ -> setHighlighted(Conductor::None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
||||||
QGraphicsTextItem::mouseReleaseEvent(e);
|
QGraphicsTextItem::mouseReleaseEvent(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
When mouse over element
|
When mouse over element
|
||||||
change m_mouse_hover to true (used in paint() function )
|
change m_mouse_hover to true (used in paint() function )
|
||||||
@param e QGraphicsSceneHoverEvent
|
@param e QGraphicsSceneHoverEvent
|
||||||
*/
|
*/
|
||||||
void ConductorTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
void ConductorTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
|
|
||||||
m_mouse_hover = true;
|
m_mouse_hover = true;
|
||||||
QString str_ToolTip = toPlainText();
|
QString str_ToolTip = toPlainText();
|
||||||
setToolTip( str_ToolTip );
|
setToolTip( str_ToolTip );
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
When mouse over element leave the position
|
When mouse over element leave the position
|
||||||
change m_mouse_hover to false(used in paint() function )
|
change m_mouse_hover to false(used in paint() function )
|
||||||
@param e QGraphicsSceneHoverEvent
|
@param e QGraphicsSceneHoverEvent
|
||||||
*/
|
*/
|
||||||
void ConductorTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
|
void ConductorTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
|
||||||
{
|
{
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
qDebug() << "Leave mouse over";
|
qDebug() << "Leave mouse over";
|
||||||
m_mouse_hover = false;
|
m_mouse_hover = false;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Do nothing default function .
|
Do nothing default function .
|
||||||
@param e QGraphicsSceneHoverEvent
|
@param e QGraphicsSceneHoverEvent
|
||||||
*/
|
*/
|
||||||
void ConductorTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *e)
|
void ConductorTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *e)
|
||||||
{
|
{
|
||||||
QGraphicsTextItem::hoverMoveEvent(e);
|
QGraphicsTextItem::hoverMoveEvent(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,69 +1,69 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef CONDUCTOR_TEXT_ITEM_H
|
#ifndef CONDUCTOR_TEXT_ITEM_H
|
||||||
#define CONDUCTOR_TEXT_ITEM_H
|
#define CONDUCTOR_TEXT_ITEM_H
|
||||||
#include "diagramtextitem.h"
|
#include "diagramtextitem.h"
|
||||||
class Conductor;
|
class Conductor;
|
||||||
/**
|
/**
|
||||||
This class represents a text item attached to a parent conductor.
|
This class represents a text item attached to a parent conductor.
|
||||||
It may be moved and edited by users.
|
It may be moved and edited by users.
|
||||||
It may also be rotated to any angle.
|
It may also be rotated to any angle.
|
||||||
Its movements are however limited to a particular distance around its
|
Its movements are however limited to a particular distance around its
|
||||||
parent conductor.
|
parent conductor.
|
||||||
*/
|
*/
|
||||||
class ConductorTextItem : public DiagramTextItem
|
class ConductorTextItem : public DiagramTextItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
ConductorTextItem(Conductor * = nullptr);
|
ConductorTextItem(Conductor * = nullptr);
|
||||||
ConductorTextItem(const QString &, Conductor * = nullptr);
|
ConductorTextItem(const QString &, Conductor * = nullptr);
|
||||||
~ConductorTextItem() override;
|
~ConductorTextItem() override;
|
||||||
private:
|
private:
|
||||||
ConductorTextItem(const ConductorTextItem &);
|
ConductorTextItem(const ConductorTextItem &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1006 };
|
enum { Type = UserType + 1006 };
|
||||||
Conductor *parentConductor() const;
|
Conductor *parentConductor() const;
|
||||||
void fromXml(const QDomElement &) override;
|
void fromXml(const QDomElement &) override;
|
||||||
void toXml(QDomDocument& doc, QDomElement& e);
|
void toXml(QDomDocument& doc, QDomElement& e);
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
virtual bool wasMovedByUser() const;
|
virtual bool wasMovedByUser() const;
|
||||||
virtual bool wasRotateByUser() const;
|
virtual bool wasRotateByUser() const;
|
||||||
virtual void forceMovedByUser(bool);
|
virtual void forceMovedByUser(bool);
|
||||||
virtual void forceRotateByUser(bool);
|
virtual void forceRotateByUser(bool);
|
||||||
virtual void setPos(const QPointF &pos);
|
virtual void setPos(const QPointF &pos);
|
||||||
virtual void setPos(qreal x, qreal y);
|
virtual void setPos(qreal x, qreal y);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
|
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override;
|
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override;
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override;
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override;
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override;
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override;
|
||||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *) override;
|
void hoverMoveEvent(QGraphicsSceneHoverEvent *) override;
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
Conductor *parent_conductor_;
|
Conductor *parent_conductor_;
|
||||||
bool moved_by_user_{false};
|
bool moved_by_user_{false};
|
||||||
bool rotate_by_user_{false};
|
bool rotate_by_user_{false};
|
||||||
QPointF before_mov_pos_;
|
QPointF before_mov_pos_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef DYNAMICELEMENTTEXTITEM_H
|
#ifndef DYNAMICELEMENTTEXTITEM_H
|
||||||
#define DYNAMICELEMENTTEXTITEM_H
|
#define DYNAMICELEMENTTEXTITEM_H
|
||||||
@@ -30,136 +30,136 @@ class ElementTextItemGroup;
|
|||||||
class CrossRefItem;
|
class CrossRefItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The DynamicElementTextItem class
|
@brief The DynamicElementTextItem class
|
||||||
This class provide a simple text field of element who can be added or removed directly from the diagram editor.
|
This class provide a simple text field of element who can be added or removed directly from the diagram editor.
|
||||||
This text is created to compensate a big lack of the ElementTextItem : ElementTextItem can't be added or removed directly in the diagram editor
|
This text is created to compensate a big lack of the ElementTextItem : ElementTextItem can't be added or removed directly in the diagram editor
|
||||||
|
|
||||||
*/
|
*/
|
||||||
class DynamicElementTextItem : public DiagramTextItem
|
class DynamicElementTextItem : public DiagramTextItem
|
||||||
{
|
{
|
||||||
friend class DynamicTextItemDelegate;
|
friend class DynamicTextItemDelegate;
|
||||||
friend class CompositeTextEditDialog;
|
friend class CompositeTextEditDialog;
|
||||||
friend class Element;
|
friend class Element;
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
||||||
Q_PROPERTY(TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
|
Q_PROPERTY(TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
|
||||||
Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
|
Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
|
||||||
Q_PROPERTY(QString compositeText READ compositeText WRITE setCompositeText NOTIFY compositeTextChanged)
|
Q_PROPERTY(QString compositeText READ compositeText WRITE setCompositeText NOTIFY compositeTextChanged)
|
||||||
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
|
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
|
||||||
Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
|
Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum TextFrom {
|
enum TextFrom {
|
||||||
UserText,
|
UserText,
|
||||||
ElementInfo,
|
ElementInfo,
|
||||||
CompositeText
|
CompositeText
|
||||||
};
|
};
|
||||||
Q_ENUM (TextFrom)
|
Q_ENUM (TextFrom)
|
||||||
enum {Type = UserType + 1010};
|
enum {Type = UserType + 1010};
|
||||||
int type() const override {return Type;}
|
int type() const override {return Type;}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void textChanged(QString text);
|
void textChanged(QString text);
|
||||||
void textFromChanged(DynamicElementTextItem::TextFrom text_from);
|
void textFromChanged(DynamicElementTextItem::TextFrom text_from);
|
||||||
void infoNameChanged(QString info);
|
void infoNameChanged(QString info);
|
||||||
void compositeTextChanged(QString text);
|
void compositeTextChanged(QString text);
|
||||||
void frameChanged(bool frame);
|
void frameChanged(bool frame);
|
||||||
void plainTextChanged();
|
void plainTextChanged();
|
||||||
void textWidthChanged(qreal width);
|
void textWidthChanged(qreal width);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DynamicElementTextItem(Element *parent_element);
|
DynamicElementTextItem(Element *parent_element);
|
||||||
~DynamicElementTextItem() override;
|
~DynamicElementTextItem() override;
|
||||||
static QMetaEnum textFromMetaEnum();
|
static QMetaEnum textFromMetaEnum();
|
||||||
private:
|
private:
|
||||||
DynamicElementTextItem ();
|
DynamicElementTextItem ();
|
||||||
DynamicElementTextItem(const DynamicElementTextItem &);
|
DynamicElementTextItem(const DynamicElementTextItem &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QDomElement toXml(QDomDocument &dom_doc) const override;
|
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||||
void fromXml(const QDomElement &dom_elmt) override;
|
void fromXml(const QDomElement &dom_elmt) override;
|
||||||
|
|
||||||
Element *parentElement() const;
|
Element *parentElement() const;
|
||||||
ElementTextItemGroup *parentGroup() const;
|
ElementTextItemGroup *parentGroup() const;
|
||||||
Element *elementUseForInfo() const;
|
Element *elementUseForInfo() const;
|
||||||
void refreshLabelConnection();
|
void refreshLabelConnection();
|
||||||
|
|
||||||
DynamicElementTextItem::TextFrom textFrom() const;
|
DynamicElementTextItem::TextFrom textFrom() const;
|
||||||
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
||||||
QString text() const;
|
QString text() const;
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
static QString xmlTagName() {return QString("dynamic_elmt_text");}
|
static QString xmlTagName() {return QString("dynamic_elmt_text");}
|
||||||
void setInfoName(const QString &info_name);
|
void setInfoName(const QString &info_name);
|
||||||
QString infoName() const;
|
QString infoName() const;
|
||||||
void setCompositeText(const QString &text);
|
void setCompositeText(const QString &text);
|
||||||
QString compositeText() const;
|
QString compositeText() const;
|
||||||
void setFrame(const bool frame);
|
void setFrame(const bool frame);
|
||||||
bool frame() const;
|
bool frame() const;
|
||||||
QUuid uuid() const;
|
QUuid uuid() const;
|
||||||
void updateXref();
|
void updateXref();
|
||||||
void setPlainText(const QString &text);
|
void setPlainText(const QString &text);
|
||||||
void setTextWidth(qreal width);
|
void setTextWidth(qreal width);
|
||||||
void setXref_item(Qt::AlignmentFlag m_exHrefPos);
|
void setXref_item(Qt::AlignmentFlag m_exHrefPos);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void elementInfoChanged();
|
void elementInfoChanged();
|
||||||
void masterChanged();
|
void masterChanged();
|
||||||
void reportChanged();
|
void reportChanged();
|
||||||
void reportFormulaChanged();
|
void reportFormulaChanged();
|
||||||
void setConnectionForReportFormula(const QString &formula);
|
void setConnectionForReportFormula(const QString &formula);
|
||||||
void removeConnectionForReportFormula(const QString &formula);
|
void removeConnectionForReportFormula(const QString &formula);
|
||||||
void setupFormulaConnection();
|
void setupFormulaConnection();
|
||||||
void clearFormulaConnection();
|
void clearFormulaConnection();
|
||||||
void updateReportFormulaConnection();
|
void updateReportFormulaConnection();
|
||||||
void updateReportText();
|
void updateReportText();
|
||||||
void updateLabel();
|
void updateLabel();
|
||||||
void conductorWasAdded(Conductor *conductor);
|
void conductorWasAdded(Conductor *conductor);
|
||||||
void conductorWasRemoved(Conductor *conductor);
|
void conductorWasRemoved(Conductor *conductor);
|
||||||
void setPotentialConductor();
|
void setPotentialConductor();
|
||||||
void conductorPropertiesChanged();
|
void conductorPropertiesChanged();
|
||||||
QString reportReplacedCompositeText() const;
|
QString reportReplacedCompositeText() const;
|
||||||
void zoomToLinkedElement();
|
void zoomToLinkedElement();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer <Element>
|
QPointer <Element>
|
||||||
m_parent_element,
|
m_parent_element,
|
||||||
m_master_element,
|
m_master_element,
|
||||||
m_other_report;
|
m_other_report;
|
||||||
QPointer <Conductor> m_watched_conductor;
|
QPointer <Conductor> m_watched_conductor;
|
||||||
QString
|
QString
|
||||||
m_text,
|
m_text,
|
||||||
m_info_name,
|
m_info_name,
|
||||||
m_composite_text,
|
m_composite_text,
|
||||||
m_report_formula,
|
m_report_formula,
|
||||||
m_F_str;
|
m_F_str;
|
||||||
DynamicElementTextItem::TextFrom m_text_from = UserText;
|
DynamicElementTextItem::TextFrom m_text_from = UserText;
|
||||||
QUuid m_uuid;
|
QUuid m_uuid;
|
||||||
QMetaObject::Connection m_report_formula_con;
|
QMetaObject::Connection m_report_formula_con;
|
||||||
QList<QMetaObject::Connection>
|
QList<QMetaObject::Connection>
|
||||||
m_formula_connection,
|
m_formula_connection,
|
||||||
m_update_slave_Xref_connection;
|
m_update_slave_Xref_connection;
|
||||||
QColor m_user_color{QColor()};
|
QColor m_user_color{QColor()};
|
||||||
bool
|
bool
|
||||||
m_frame = false,
|
m_frame = false,
|
||||||
m_first_scene_change = true;
|
m_first_scene_change = true;
|
||||||
CrossRefItem *m_Xref_item = nullptr;
|
CrossRefItem *m_Xref_item = nullptr;
|
||||||
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
||||||
qreal m_text_width = -1;
|
qreal m_text_width = -1;
|
||||||
QPointF m_initial_position;
|
QPointF m_initial_position;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DYNAMICELEMENTTEXTITEM_H
|
#endif // DYNAMICELEMENTTEXTITEM_H
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef ELEMENT_H
|
#ifndef ELEMENT_H
|
||||||
#define ELEMENT_H
|
#define ELEMENT_H
|
||||||
@@ -36,203 +36,203 @@ class DynamicElementTextItem;
|
|||||||
class ElementTextItemGroup;
|
class ElementTextItemGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This is the base class for electrical elements.
|
This is the base class for electrical elements.
|
||||||
*/
|
*/
|
||||||
class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
|
class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
|
||||||
{
|
{
|
||||||
friend class DiagramEventAddElement;
|
friend class DiagramEventAddElement;
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@brief The kind enum
|
@brief The kind enum
|
||||||
Used to know the kind of this element
|
Used to know the kind of this element
|
||||||
(master, slave, report ect...)
|
(master, slave, report ect...)
|
||||||
*/
|
*/
|
||||||
enum kind {
|
enum kind {
|
||||||
Simple = 1,
|
Simple = 1,
|
||||||
NextReport = 2,
|
NextReport = 2,
|
||||||
PreviousReport = 4,
|
PreviousReport = 4,
|
||||||
AllReport = 6,
|
AllReport = 6,
|
||||||
Master = 8,
|
Master = 8,
|
||||||
Slave = 16,
|
Slave = 16,
|
||||||
Terminale = 32};
|
Terminale = 32};
|
||||||
|
|
||||||
Element(const ElementsLocation &location,
|
Element(const ElementsLocation &location,
|
||||||
QGraphicsItem * = nullptr,
|
QGraphicsItem * = nullptr,
|
||||||
int *state = nullptr,
|
int *state = nullptr,
|
||||||
Element::kind link_type = Element::Simple);
|
Element::kind link_type = Element::Simple);
|
||||||
~Element() override;
|
~Element() override;
|
||||||
private:
|
private:
|
||||||
Element(const Element &);
|
Element(const Element &);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
Enable the use of qgraphicsitem_cast
|
Enable the use of qgraphicsitem_cast
|
||||||
to safely cast a QGraphicsItem into an Element.
|
to safely cast a QGraphicsItem into an Element.
|
||||||
@return the QGraphicsItem type
|
@return the QGraphicsItem type
|
||||||
*/
|
*/
|
||||||
enum { Type = UserType + 1000 };
|
enum { Type = UserType + 1000 };
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void linkedElementChanged(); //This signal is emited when the linked elements with this element change
|
void linkedElementChanged(); //This signal is emited when the linked elements with this element change
|
||||||
void elementInfoChange(
|
void elementInfoChange(
|
||||||
DiagramContext old_info,
|
DiagramContext old_info,
|
||||||
DiagramContext new_info);
|
DiagramContext new_info);
|
||||||
void textAdded(DynamicElementTextItem *deti);
|
void textAdded(DynamicElementTextItem *deti);
|
||||||
void textRemoved(DynamicElementTextItem *deti);
|
void textRemoved(DynamicElementTextItem *deti);
|
||||||
void textsGroupAdded(ElementTextItemGroup *group);
|
void textsGroupAdded(ElementTextItemGroup *group);
|
||||||
void textsGroupAboutToBeRemoved(ElementTextItemGroup *group);
|
void textsGroupAboutToBeRemoved(ElementTextItemGroup *group);
|
||||||
void textAddedToGroup(
|
void textAddedToGroup(
|
||||||
DynamicElementTextItem *text,
|
DynamicElementTextItem *text,
|
||||||
ElementTextItemGroup *group);
|
ElementTextItemGroup *group);
|
||||||
void textRemovedFromGroup(
|
void textRemovedFromGroup(
|
||||||
DynamicElementTextItem *text,
|
DynamicElementTextItem *text,
|
||||||
ElementTextItemGroup *group);
|
ElementTextItemGroup *group);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QList<Terminal *> terminals() const;
|
QList<Terminal *> terminals() const;
|
||||||
QList<Conductor *> conductors() const;
|
QList<Conductor *> conductors() const;
|
||||||
QList<QPair<Terminal *,Terminal *>> AlignedFreeTerminals() const;
|
QList<QPair<Terminal *,Terminal *>> AlignedFreeTerminals() const;
|
||||||
|
|
||||||
//METHODS related to information
|
//METHODS related to information
|
||||||
DiagramContext elementInformations()const
|
DiagramContext elementInformations()const
|
||||||
{return m_element_informations;}
|
{return m_element_informations;}
|
||||||
virtual void setElementInformations(DiagramContext dc);
|
virtual void setElementInformations(DiagramContext dc);
|
||||||
DiagramContext kindInformations() const
|
DiagramContext kindInformations() const
|
||||||
{return m_kind_informations;}
|
{return m_kind_informations;}
|
||||||
//@kind_information_ is used to store more information
|
//@kind_information_ is used to store more information
|
||||||
//about the herited class like contactelement for know
|
//about the herited class like contactelement for know
|
||||||
// kind of contact (simple tempo) or number of contact show by the element.
|
// kind of contact (simple tempo) or number of contact show by the element.
|
||||||
|
|
||||||
autonum::sequentialNumbers sequenceStruct() const
|
autonum::sequentialNumbers sequenceStruct() const
|
||||||
{return m_autoNum_seq;}
|
{return m_autoNum_seq;}
|
||||||
autonum::sequentialNumbers& rSequenceStruct()
|
autonum::sequentialNumbers& rSequenceStruct()
|
||||||
{return m_autoNum_seq;}
|
{return m_autoNum_seq;}
|
||||||
void setUpFormula(bool code_letter = true);
|
void setUpFormula(bool code_letter = true);
|
||||||
void setPrefix(QString);
|
void setPrefix(QString);
|
||||||
QString getPrefix() const;
|
QString getPrefix() const;
|
||||||
void freezeLabel(bool freeze);
|
void freezeLabel(bool freeze);
|
||||||
bool isFreezeLabel() const {return m_freeze_label;}
|
bool isFreezeLabel() const {return m_freeze_label;}
|
||||||
void freezeNewAddedElement();
|
void freezeNewAddedElement();
|
||||||
QString actualLabel();
|
QString actualLabel();
|
||||||
|
|
||||||
QString name() const override;
|
QString name() const override;
|
||||||
ElementsLocation location() const;
|
ElementsLocation location() const;
|
||||||
virtual void setHighlighted(bool);
|
virtual void setHighlighted(bool);
|
||||||
void displayHelpLine(bool b = true);
|
void displayHelpLine(bool b = true);
|
||||||
QSize size() const;
|
QSize size() const;
|
||||||
QPixmap pixmap();
|
QPixmap pixmap();
|
||||||
QPoint setHotspot(QPoint);
|
QPoint setHotspot(QPoint);
|
||||||
QPoint hotspot() const;
|
QPoint hotspot() const;
|
||||||
void editProperty() override;
|
void editProperty() override;
|
||||||
static bool valideXml(QDomElement &);
|
static bool valideXml(QDomElement &);
|
||||||
virtual bool fromXml(QDomElement &, QHash<int, Terminal *> &, bool = false);
|
virtual bool fromXml(QDomElement &, QHash<int, Terminal *> &, bool = false);
|
||||||
virtual QDomElement toXml(QDomDocument &) const;
|
virtual QDomElement toXml(QDomDocument &) const;
|
||||||
QUuid uuid() const;
|
QUuid uuid() const;
|
||||||
int orientation() const;
|
int orientation() const;
|
||||||
|
|
||||||
//METHODS related to texts
|
//METHODS related to texts
|
||||||
void addDynamicTextItem(DynamicElementTextItem *deti = nullptr);
|
void addDynamicTextItem(DynamicElementTextItem *deti = nullptr);
|
||||||
void removeDynamicTextItem(DynamicElementTextItem *deti);
|
void removeDynamicTextItem(DynamicElementTextItem *deti);
|
||||||
QList<DynamicElementTextItem *> dynamicTextItems() const;
|
QList<DynamicElementTextItem *> dynamicTextItems() const;
|
||||||
ElementTextItemGroup *addTextGroup(const QString &name);
|
ElementTextItemGroup *addTextGroup(const QString &name);
|
||||||
void addTextGroup(ElementTextItemGroup *group);
|
void addTextGroup(ElementTextItemGroup *group);
|
||||||
void removeTextGroup(ElementTextItemGroup *group);
|
void removeTextGroup(ElementTextItemGroup *group);
|
||||||
ElementTextItemGroup *textGroup(const QString &name) const;
|
ElementTextItemGroup *textGroup(const QString &name) const;
|
||||||
QList<ElementTextItemGroup *> textGroups() const;
|
QList<ElementTextItemGroup *> textGroups() const;
|
||||||
bool addTextToGroup(
|
bool addTextToGroup(
|
||||||
DynamicElementTextItem *text,
|
DynamicElementTextItem *text,
|
||||||
ElementTextItemGroup *group);
|
ElementTextItemGroup *group);
|
||||||
bool removeTextFromGroup(
|
bool removeTextFromGroup(
|
||||||
DynamicElementTextItem *text,
|
DynamicElementTextItem *text,
|
||||||
ElementTextItemGroup *group);
|
ElementTextItemGroup *group);
|
||||||
|
|
||||||
//METHODS related to linked element
|
//METHODS related to linked element
|
||||||
bool isFree() const;
|
bool isFree() const;
|
||||||
virtual void linkToElement(Element *) {}
|
virtual void linkToElement(Element *) {}
|
||||||
virtual void unlinkAllElements() {}
|
virtual void unlinkAllElements() {}
|
||||||
virtual void unlinkElement(Element *) {}
|
virtual void unlinkElement(Element *) {}
|
||||||
virtual void initLink(QETProject *);
|
virtual void initLink(QETProject *);
|
||||||
QList<Element *> linkedElements ();
|
QList<Element *> linkedElements ();
|
||||||
virtual kind linkType() const {return m_link_type;} // return the linkable type
|
virtual kind linkType() const {return m_link_type;} // return the linkable type
|
||||||
QString linkTypeToString() const;
|
QString linkTypeToString() const;
|
||||||
void newUuid() {m_uuid = QUuid::createUuid();} //create new uuid for this element
|
void newUuid() {m_uuid = QUuid::createUuid();} //create new uuid for this element
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
||||||
void setSize(int, int);
|
void setSize(int, int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void drawSelection(
|
void drawSelection(
|
||||||
QPainter *,
|
QPainter *,
|
||||||
const QStyleOptionGraphicsItem *);
|
const QStyleOptionGraphicsItem *);
|
||||||
void drawHighlight(
|
void drawHighlight(
|
||||||
QPainter *,
|
QPainter *,
|
||||||
const QStyleOptionGraphicsItem *);
|
const QStyleOptionGraphicsItem *);
|
||||||
bool buildFromXml(const QDomElement &, int * = nullptr);
|
bool buildFromXml(const QDomElement &, int * = nullptr);
|
||||||
bool parseElement(const QDomElement &dom);
|
bool parseElement(const QDomElement &dom);
|
||||||
bool parseInput(const QDomElement &dom_element);
|
bool parseInput(const QDomElement &dom_element);
|
||||||
DynamicElementTextItem *parseDynamicText(
|
DynamicElementTextItem *parseDynamicText(
|
||||||
const QDomElement &dom_element);
|
const QDomElement &dom_element);
|
||||||
Terminal *parseTerminal(const QDomElement &dom_element);
|
Terminal *parseTerminal(const QDomElement &dom_element);
|
||||||
|
|
||||||
//Reimplemented from QGraphicsItem
|
//Reimplemented from QGraphicsItem
|
||||||
public:
|
public:
|
||||||
void paint(
|
void paint(
|
||||||
QPainter *,
|
QPainter *,
|
||||||
const QStyleOptionGraphicsItem *,
|
const QStyleOptionGraphicsItem *,
|
||||||
QWidget *) override;
|
QWidget *) override;
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseReleaseEvent(
|
void mouseReleaseEvent(
|
||||||
QGraphicsSceneMouseEvent *event) override;
|
QGraphicsSceneMouseEvent *event) override;
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override;
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override;
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override;
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// m_converted_text_from_description,
|
// m_converted_text_from_description,
|
||||||
// when a element is created from his description,
|
// when a element is created from his description,
|
||||||
// the old element text item (tagged as 'input' in the xml)
|
// the old element text item (tagged as 'input' in the xml)
|
||||||
// are converted to dynamic text field,
|
// are converted to dynamic text field,
|
||||||
// the QPointF is the original position of the text item,
|
// the QPointF is the original position of the text item,
|
||||||
// because the origin transformation point of text item
|
// because the origin transformation point of text item
|
||||||
// and dynamic text item are not the same,
|
// and dynamic text item are not the same,
|
||||||
// so we must to keep a track of this value,
|
// so we must to keep a track of this value,
|
||||||
// to be use in the function element::fromXml
|
// to be use in the function element::fromXml
|
||||||
QHash <DynamicElementTextItem *, QPointF>
|
QHash <DynamicElementTextItem *, QPointF>
|
||||||
m_converted_text_from_xml_description;
|
m_converted_text_from_xml_description;
|
||||||
|
|
||||||
//ATTRIBUTES related to linked element
|
//ATTRIBUTES related to linked element
|
||||||
QList <Element *> connected_elements;
|
QList <Element *> connected_elements;
|
||||||
QList <QUuid> tmp_uuids_link;
|
QList <QUuid> tmp_uuids_link;
|
||||||
QUuid m_uuid;
|
QUuid m_uuid;
|
||||||
kind m_link_type = Element::Simple;
|
kind m_link_type = Element::Simple;
|
||||||
|
|
||||||
//ATTRIBUTES related to informations
|
//ATTRIBUTES related to informations
|
||||||
DiagramContext m_element_informations, m_kind_informations;
|
DiagramContext m_element_informations, m_kind_informations;
|
||||||
autonum::sequentialNumbers m_autoNum_seq;
|
autonum::sequentialNumbers m_autoNum_seq;
|
||||||
bool m_freeze_label = false;
|
bool m_freeze_label = false;
|
||||||
QString m_F_str;
|
QString m_F_str;
|
||||||
|
|
||||||
ElementsLocation m_location;
|
ElementsLocation m_location;
|
||||||
NamesList m_names;
|
NamesList m_names;
|
||||||
QList <Terminal *> m_terminals;
|
QList <Terminal *> m_terminals;
|
||||||
const QPicture m_picture;
|
const QPicture m_picture;
|
||||||
const QPicture m_low_zoom_picture;
|
const QPicture m_low_zoom_picture;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_must_highlight = false;
|
bool m_must_highlight = false;
|
||||||
QSize dimensions;
|
QSize dimensions;
|
||||||
QPoint hotspot_coord;
|
QPoint hotspot_coord;
|
||||||
bool m_mouse_over = false;
|
bool m_mouse_over = false;
|
||||||
QString m_prefix;
|
QString m_prefix;
|
||||||
QList <DynamicElementTextItem *> m_dynamic_text_list;
|
QList <DynamicElementTextItem *> m_dynamic_text_list;
|
||||||
QList <ElementTextItemGroup *> m_texts_group;
|
QList <ElementTextItemGroup *> m_texts_group;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -240,40 +240,40 @@ bool comparPos(const Element * elmt1, const Element * elmt2);
|
|||||||
|
|
||||||
inline bool Element::isFree() const
|
inline bool Element::isFree() const
|
||||||
{
|
{
|
||||||
return (connected_elements.isEmpty());
|
return (connected_elements.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Indicate the current orientation of this element
|
Indicate the current orientation of this element
|
||||||
O = 0°
|
O = 0°
|
||||||
1 = 90°
|
1 = 90°
|
||||||
2 = 180°
|
2 = 180°
|
||||||
3 = 270°
|
3 = 270°
|
||||||
@return the current orientation of this element
|
@return the current orientation of this element
|
||||||
*/
|
*/
|
||||||
inline int Element::orientation() const
|
inline int Element::orientation() const
|
||||||
{
|
{
|
||||||
return(QET::correctAngle(rotation())/90);
|
return(QET::correctAngle(rotation())/90);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Element::uuid
|
@brief Element::uuid
|
||||||
@return the uuid of this element
|
@return the uuid of this element
|
||||||
*/
|
*/
|
||||||
inline QUuid Element::uuid() const
|
inline QUuid Element::uuid() const
|
||||||
{return m_uuid;}
|
{return m_uuid;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Element::linkedElements
|
@brief Element::linkedElements
|
||||||
@return the list of linked elements, the list is sorted by position
|
@return the list of linked elements, the list is sorted by position
|
||||||
*/
|
*/
|
||||||
inline QList <Element *> Element::linkedElements()
|
inline QList <Element *> Element::linkedElements()
|
||||||
{
|
{
|
||||||
std::sort(
|
std::sort(
|
||||||
connected_elements.begin(),
|
connected_elements.begin(),
|
||||||
connected_elements.end(),
|
connected_elements.end(),
|
||||||
comparPos);
|
comparPos);
|
||||||
return connected_elements;
|
return connected_elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef ELEMENTTEXTITEMGROUP_H
|
#ifndef ELEMENTTEXTITEMGROUP_H
|
||||||
#define ELEMENTTEXTITEMGROUP_H
|
#define ELEMENTTEXTITEMGROUP_H
|
||||||
@@ -28,98 +28,98 @@ class Diagram;
|
|||||||
class CrossRefItem;
|
class CrossRefItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The ElementTextItemGroup class
|
@brief The ElementTextItemGroup class
|
||||||
This class represent a group of element text
|
This class represent a group of element text
|
||||||
Texts in the group can be aligned left / center /right
|
Texts in the group can be aligned left / center /right
|
||||||
*/
|
*/
|
||||||
class ElementTextItemGroup : public QObject, public QGraphicsItemGroup // TODO: derive from PropertiesInterface
|
class ElementTextItemGroup : public QObject, public QGraphicsItemGroup // TODO: derive from PropertiesInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
||||||
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
|
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
|
||||||
Q_PROPERTY(int verticalAdjustment READ verticalAdjustment WRITE setVerticalAdjustment NOTIFY verticalAdjustmentChanged)
|
Q_PROPERTY(int verticalAdjustment READ verticalAdjustment WRITE setVerticalAdjustment NOTIFY verticalAdjustmentChanged)
|
||||||
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
||||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||||
Q_PROPERTY(bool holdToBottomPage READ holdToBottomPage WRITE setHoldToBottomPage NOTIFY holdToBottomPageChanged)
|
Q_PROPERTY(bool holdToBottomPage READ holdToBottomPage WRITE setHoldToBottomPage NOTIFY holdToBottomPageChanged)
|
||||||
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
|
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
signals:
|
signals:
|
||||||
void rotationChanged(qreal);
|
void rotationChanged(qreal);
|
||||||
void verticalAdjustmentChanged(int);
|
void verticalAdjustmentChanged(int);
|
||||||
void alignmentChanged(Qt::Alignment);
|
void alignmentChanged(Qt::Alignment);
|
||||||
void nameChanged(QString);
|
void nameChanged(QString);
|
||||||
void holdToBottomPageChanged(bool);
|
void holdToBottomPageChanged(bool);
|
||||||
void xChanged();
|
void xChanged();
|
||||||
void yChanged();
|
void yChanged();
|
||||||
void frameChanged(bool frame);
|
void frameChanged(bool frame);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ElementTextItemGroup(const QString &name, Element *parent);
|
ElementTextItemGroup(const QString &name, Element *parent);
|
||||||
~ElementTextItemGroup() override;
|
~ElementTextItemGroup() override;
|
||||||
void addToGroup(QGraphicsItem *item);
|
void addToGroup(QGraphicsItem *item);
|
||||||
void removeFromGroup(QGraphicsItem *item);
|
void removeFromGroup(QGraphicsItem *item);
|
||||||
void blockAlignmentUpdate(bool block);
|
void blockAlignmentUpdate(bool block);
|
||||||
|
|
||||||
void setAlignment(Qt::Alignment alignement);
|
void setAlignment(Qt::Alignment alignement);
|
||||||
Qt::Alignment alignment() const;
|
Qt::Alignment alignment() const;
|
||||||
void updateAlignment();
|
void updateAlignment();
|
||||||
int verticalAdjustment() const {return m_vertical_adjustment;}
|
int verticalAdjustment() const {return m_vertical_adjustment;}
|
||||||
void setVerticalAdjustment(int v);
|
void setVerticalAdjustment(int v);
|
||||||
void setName(QString name);
|
void setName(QString name);
|
||||||
QString name() const {return m_name;}
|
QString name() const {return m_name;}
|
||||||
void setHoldToBottomPage(bool hold);
|
void setHoldToBottomPage(bool hold);
|
||||||
bool holdToBottomPage() const {return m_hold_to_bottom_of_page;}
|
bool holdToBottomPage() const {return m_hold_to_bottom_of_page;}
|
||||||
void setFrame(const bool frame);
|
void setFrame(const bool frame);
|
||||||
bool frame() const;
|
bool frame() const;
|
||||||
QList<DynamicElementTextItem *> texts() const;
|
QList<DynamicElementTextItem *> texts() const;
|
||||||
Diagram *diagram() const;
|
Diagram *diagram() const;
|
||||||
Element *parentElement() const;
|
Element *parentElement() const;
|
||||||
|
|
||||||
QDomElement toXml(QDomDocument &dom_document) const;
|
QDomElement toXml(QDomDocument &dom_document) const;
|
||||||
void fromXml(QDomElement &dom_element);
|
void fromXml(QDomElement &dom_element);
|
||||||
static QString xmlTaggName() {return QString("texts_group");}
|
static QString xmlTaggName() {return QString("texts_group");}
|
||||||
|
|
||||||
void paint(QPainter *painter,
|
void paint(QPainter *painter,
|
||||||
const QStyleOptionGraphicsItem *option,
|
const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget) override;
|
QWidget *widget) override;
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
void setRotation(qreal angle);
|
void setRotation(qreal angle);
|
||||||
void setPos(const QPointF &pos);
|
void setPos(const QPointF &pos);
|
||||||
void setPos(qreal x, qreal y);
|
void setPos(qreal x, qreal y);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseReleaseEvent(
|
void mouseReleaseEvent(
|
||||||
QGraphicsSceneMouseEvent *event) override;
|
QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseDoubleClickEvent(
|
void mouseDoubleClickEvent(
|
||||||
QGraphicsSceneMouseEvent *event) override;
|
QGraphicsSceneMouseEvent *event) override;
|
||||||
void keyPressEvent(QKeyEvent *event) override;
|
void keyPressEvent(QKeyEvent *event) override;
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateXref();
|
void updateXref();
|
||||||
void adjustSlaveXrefPos();
|
void adjustSlaveXrefPos();
|
||||||
void autoPos();
|
void autoPos();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Qt::Alignment m_alignment = Qt::AlignJustify;
|
Qt::Alignment m_alignment = Qt::AlignJustify;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
bool m_first_move = true,
|
bool m_first_move = true,
|
||||||
m_hold_to_bottom_of_page = false,
|
m_hold_to_bottom_of_page = false,
|
||||||
m_block_alignment_update = false,
|
m_block_alignment_update = false,
|
||||||
m_frame = false;
|
m_frame = false;
|
||||||
QPointF m_initial_position{QPointF(0,0)};
|
QPointF m_initial_position{QPointF(0,0)};
|
||||||
int m_vertical_adjustment = 0;
|
int m_vertical_adjustment = 0;
|
||||||
CrossRefItem *m_Xref_item = nullptr;
|
CrossRefItem *m_Xref_item = nullptr;
|
||||||
Element *m_parent_element = nullptr;
|
Element *m_parent_element = nullptr;
|
||||||
QList<QMetaObject::Connection> m_update_slave_Xref_connection;
|
QList<QMetaObject::Connection> m_update_slave_Xref_connection;
|
||||||
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
||||||
QMetaObject::Connection m_XrefChanged_timer,
|
QMetaObject::Connection m_XrefChanged_timer,
|
||||||
m_linked_changed_timer;
|
m_linked_changed_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ELEMENTTEXTITEMGROUP_H
|
#endif // ELEMENTTEXTITEMGROUP_H
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "independenttextitem.h"
|
#include "independenttextitem.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
@@ -25,24 +25,24 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@param parent_diagram Le schema auquel est rattache le champ de texte
|
@param parent_diagram Le schema auquel est rattache le champ de texte
|
||||||
*/
|
*/
|
||||||
IndependentTextItem::IndependentTextItem() :
|
IndependentTextItem::IndependentTextItem() :
|
||||||
DiagramTextItem(nullptr)
|
DiagramTextItem(nullptr)
|
||||||
{
|
{
|
||||||
setFont(QETApp::indiTextsItemFont());
|
setFont(QETApp::indiTextsItemFont());
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
setRotation(settings.value("diagrameditor/independent_text_rotation", 0).toInt());
|
setRotation(settings.value("diagrameditor/independent_text_rotation", 0).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief IndependentTextItem::IndependentTextItem
|
@brief IndependentTextItem::IndependentTextItem
|
||||||
Constructeur
|
Constructeur
|
||||||
@param text Le texte affiche par le champ de texte
|
@param text Le texte affiche par le champ de texte
|
||||||
*/
|
*/
|
||||||
IndependentTextItem::IndependentTextItem(const QString &text) :
|
IndependentTextItem::IndependentTextItem(const QString &text) :
|
||||||
DiagramTextItem(text, nullptr)
|
DiagramTextItem(text, nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
@@ -52,43 +52,43 @@ IndependentTextItem::~IndependentTextItem()
|
|||||||
|
|
||||||
// TODO: inherit from PropertiesInterface
|
// TODO: inherit from PropertiesInterface
|
||||||
/**
|
/**
|
||||||
Permet de lire le texte a mettre dans le champ a partir d'un element XML.
|
Permet de lire le texte a mettre dans le champ a partir d'un element XML.
|
||||||
Cette methode se base sur la position du champ pour assigner ou non la
|
Cette methode se base sur la position du champ pour assigner ou non la
|
||||||
valeur a ce champ.
|
valeur a ce champ.
|
||||||
@param e L'element XML representant le champ de texte
|
@param e L'element XML representant le champ de texte
|
||||||
*/
|
*/
|
||||||
void IndependentTextItem::fromXml(const QDomElement &e) {
|
void IndependentTextItem::fromXml(const QDomElement &e) {
|
||||||
setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
|
setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
|
||||||
setHtml(e.attribute("text"));
|
setHtml(e.attribute("text"));
|
||||||
setRotation(e.attribute("rotation").toDouble());
|
setRotation(e.attribute("rotation").toDouble());
|
||||||
if (e.hasAttribute("font"))
|
if (e.hasAttribute("font"))
|
||||||
{
|
{
|
||||||
QFont font;
|
QFont font;
|
||||||
font.fromString(e.attribute("font"));
|
font.fromString(e.attribute("font"));
|
||||||
setFont(font);
|
setFont(font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param document Le document XML a utiliser
|
@param document Le document XML a utiliser
|
||||||
@return L'element XML representant ce champ de texte
|
@return L'element XML representant ce champ de texte
|
||||||
*/
|
*/
|
||||||
QDomElement IndependentTextItem::toXml(QDomDocument &document) const
|
QDomElement IndependentTextItem::toXml(QDomDocument &document) const
|
||||||
{
|
{
|
||||||
QDomElement result = document.createElement("input");
|
QDomElement result = document.createElement("input");
|
||||||
result.setAttribute("x", QString("%1").arg(pos().x()));
|
result.setAttribute("x", QString("%1").arg(pos().x()));
|
||||||
result.setAttribute("y", QString("%1").arg(pos().y()));
|
result.setAttribute("y", QString("%1").arg(pos().y()));
|
||||||
result.setAttribute("text", toHtml());
|
result.setAttribute("text", toHtml());
|
||||||
result.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
|
result.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
|
||||||
result.setAttribute("font", font().toString());
|
result.setAttribute("font", font().toString());
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IndependentTextItem::focusOutEvent(QFocusEvent *event)
|
void IndependentTextItem::focusOutEvent(QFocusEvent *event)
|
||||||
{
|
{
|
||||||
DiagramTextItem::focusOutEvent(event);
|
DiagramTextItem::focusOutEvent(event);
|
||||||
if (diagram() && (m_previous_html_text != this->toHtml())) {
|
if (diagram() && (m_previous_html_text != this->toHtml())) {
|
||||||
diagram()->undoStack().push(new ChangeDiagramTextCommand(this, m_previous_html_text, this->toHtml()));
|
diagram()->undoStack().push(new ChangeDiagramTextCommand(this, m_previous_html_text, this->toHtml()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,153 +1,153 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "qetgraphicsitem.h"
|
#include "qetgraphicsitem.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QetGraphicsItem::QetGraphicsItem
|
@brief QetGraphicsItem::QetGraphicsItem
|
||||||
Default constructor
|
Default constructor
|
||||||
@param parent : Parent Item
|
@param parent : Parent Item
|
||||||
*/
|
*/
|
||||||
QetGraphicsItem::QetGraphicsItem(QGraphicsItem *parent):
|
QetGraphicsItem::QetGraphicsItem(QGraphicsItem *parent):
|
||||||
QGraphicsObject(parent)
|
QGraphicsObject(parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QetGraphicsItem::~QetGraphicsItem()
|
QetGraphicsItem::~QetGraphicsItem()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QetGraphicsItem::diagram
|
@brief QetGraphicsItem::diagram
|
||||||
*return the diagram of this item
|
*return the diagram of this item
|
||||||
*/
|
*/
|
||||||
Diagram* QetGraphicsItem::diagram() const{
|
Diagram* QetGraphicsItem::diagram() const{
|
||||||
return(qobject_cast<Diagram *>(scene()));
|
return(qobject_cast<Diagram *>(scene()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QetGraphicsItem::setPos
|
@brief QetGraphicsItem::setPos
|
||||||
*set the position of the item to p
|
*set the position of the item to p
|
||||||
@param p the new position of item
|
@param p the new position of item
|
||||||
*/
|
*/
|
||||||
void QetGraphicsItem::setPos(const QPointF &p) {
|
void QetGraphicsItem::setPos(const QPointF &p) {
|
||||||
QPointF pp = Diagram::snapToGrid(p);
|
QPointF pp = Diagram::snapToGrid(p);
|
||||||
if (pp == pos() || !is_movable_)
|
if (pp == pos() || !is_movable_)
|
||||||
return;
|
return;
|
||||||
QGraphicsItem::setPos(pp);
|
QGraphicsItem::setPos(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QetGraphicsItem::setPos
|
@brief QetGraphicsItem::setPos
|
||||||
*set the position of the item
|
*set the position of the item
|
||||||
@param x new abscisse of item
|
@param x new abscisse of item
|
||||||
@param y new ordonne of item
|
@param y new ordonne of item
|
||||||
*/
|
*/
|
||||||
void QetGraphicsItem::setPos(qreal x, qreal y) {
|
void QetGraphicsItem::setPos(qreal x, qreal y) {
|
||||||
setPos(QPointF(x, y));
|
setPos(QPointF(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QetGraphicsItem::state
|
@brief QetGraphicsItem::state
|
||||||
@return the current state of this item
|
@return the current state of this item
|
||||||
*/
|
*/
|
||||||
QET::GraphicsItemState QetGraphicsItem::state() const
|
QET::GraphicsItemState QetGraphicsItem::state() const
|
||||||
{
|
{
|
||||||
return m_state;
|
return m_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QetGraphicsItem::mousePressEvent
|
@brief QetGraphicsItem::mousePressEvent
|
||||||
*handle the mouse click
|
*handle the mouse click
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void QetGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void QetGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton)
|
if (event->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
m_first_move = true;
|
m_first_move = true;
|
||||||
if (event->modifiers() & Qt::ControlModifier) {
|
if (event->modifiers() & Qt::ControlModifier) {
|
||||||
setSelected(!isSelected());
|
setSelected(!isSelected());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsItem::mousePressEvent(event);
|
QGraphicsItem::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QetGraphicsItem::mouseDoubleClickEvent
|
@brief QetGraphicsItem::mouseDoubleClickEvent
|
||||||
*handle the mouse double click
|
*handle the mouse double click
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void QetGraphicsItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
void QetGraphicsItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
editProperty();
|
editProperty();
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QetGraphicsItem::mouseMoveEvent
|
@brief QetGraphicsItem::mouseMoveEvent
|
||||||
*handle mouse movement
|
*handle mouse movement
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void QetGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
void QetGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (isSelected() && event->buttons() & Qt::LeftButton)
|
if (isSelected() && event->buttons() & Qt::LeftButton)
|
||||||
{
|
{
|
||||||
//Item is moving
|
//Item is moving
|
||||||
if(diagram() && m_first_move) {
|
if(diagram() && m_first_move) {
|
||||||
//It's the first movement, we signal it to parent diagram
|
//It's the first movement, we signal it to parent diagram
|
||||||
diagram()->elementsMover().beginMovement(diagram(), this);
|
diagram()->elementsMover().beginMovement(diagram(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//we apply the mouse movement
|
//we apply the mouse movement
|
||||||
QPointF old_pos = pos();
|
QPointF old_pos = pos();
|
||||||
if (m_first_move) {
|
if (m_first_move) {
|
||||||
m_mouse_to_origin_movement = old_pos - event -> buttonDownScenePos(Qt::LeftButton);
|
m_mouse_to_origin_movement = old_pos - event -> buttonDownScenePos(Qt::LeftButton);
|
||||||
}
|
}
|
||||||
QPointF expected_pos = event->scenePos() + m_mouse_to_origin_movement;
|
QPointF expected_pos = event->scenePos() + m_mouse_to_origin_movement;
|
||||||
setPos(expected_pos); // setPos() will snap the expected position to the grid
|
setPos(expected_pos); // setPos() will snap the expected position to the grid
|
||||||
|
|
||||||
//we calcul the real movement apply by setPos()
|
//we calcul the real movement apply by setPos()
|
||||||
QPointF effective_movement = pos() - old_pos;
|
QPointF effective_movement = pos() - old_pos;
|
||||||
if (diagram()) {
|
if (diagram()) {
|
||||||
//we signal the real movement apply to diagram,
|
//we signal the real movement apply to diagram,
|
||||||
//who he apply to other selected item
|
//who he apply to other selected item
|
||||||
diagram()->elementsMover().continueMovement(effective_movement);
|
diagram()->elementsMover().continueMovement(effective_movement);
|
||||||
}
|
}
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_first_move) {
|
if (m_first_move) {
|
||||||
m_first_move = false;
|
m_first_move = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QetGraphicsItem::mouseReleaseEvent
|
@brief QetGraphicsItem::mouseReleaseEvent
|
||||||
handle mouse release click
|
handle mouse release click
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void QetGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void QetGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (diagram()) {
|
if (diagram()) {
|
||||||
diagram()->elementsMover().endMovement();
|
diagram()->elementsMover().endMovement();
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef QETGRAPHICSITEM_H
|
#ifndef QETGRAPHICSITEM_H
|
||||||
#define QETGRAPHICSITEM_H
|
#define QETGRAPHICSITEM_H
|
||||||
@@ -25,41 +25,41 @@ class Diagram;
|
|||||||
|
|
||||||
class QetGraphicsItem : public QGraphicsObject
|
class QetGraphicsItem : public QGraphicsObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//constructor destructor
|
//constructor destructor
|
||||||
QetGraphicsItem(QGraphicsItem *parent = nullptr);
|
QetGraphicsItem(QGraphicsItem *parent = nullptr);
|
||||||
~QetGraphicsItem() override = 0;
|
~QetGraphicsItem() override = 0;
|
||||||
|
|
||||||
//public methode
|
//public methode
|
||||||
Diagram *diagram () const;
|
Diagram *diagram () const;
|
||||||
virtual void setPos (const QPointF &p);
|
virtual void setPos (const QPointF &p);
|
||||||
virtual void setPos (qreal x, qreal y);
|
virtual void setPos (qreal x, qreal y);
|
||||||
|
|
||||||
virtual bool isMovable () const
|
virtual bool isMovable () const
|
||||||
{return is_movable_;}
|
{return is_movable_;}
|
||||||
virtual void setMovable (bool movable) { is_movable_ = movable;}
|
virtual void setMovable (bool movable) { is_movable_ = movable;}
|
||||||
|
|
||||||
virtual void editProperty () {}
|
virtual void editProperty () {}
|
||||||
virtual QString name ()const
|
virtual QString name ()const
|
||||||
{return QString("");}
|
{return QString("");}
|
||||||
|
|
||||||
QET::GraphicsItemState state() const;
|
QET::GraphicsItemState state() const;
|
||||||
|
|
||||||
//protected method
|
//protected method
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool is_movable_{true};
|
bool is_movable_{true};
|
||||||
bool m_first_move{true};
|
bool m_first_move{true};
|
||||||
bool snap_to_grid_{true};
|
bool snap_to_grid_{true};
|
||||||
QPointF m_mouse_to_origin_movement{QPointF(0,0)};
|
QPointF m_mouse_to_origin_movement{QPointF(0,0)};
|
||||||
QET::GraphicsItemState m_state = QET:: GIOK;
|
QET::GraphicsItemState m_state = QET:: GIOK;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "slaveelement.h"
|
#include "slaveelement.h"
|
||||||
#include "diagramposition.h"
|
#include "diagramposition.h"
|
||||||
@@ -22,79 +22,79 @@
|
|||||||
#include "dynamicelementtextitem.h"
|
#include "dynamicelementtextitem.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief SlaveElement::SlaveElement
|
@brief SlaveElement::SlaveElement
|
||||||
Default constructor
|
Default constructor
|
||||||
@param location location of xml definition
|
@param location location of xml definition
|
||||||
@param qgi parent QGraphicItem
|
@param qgi parent QGraphicItem
|
||||||
@param state int used to know if the creation of element have error
|
@param state int used to know if the creation of element have error
|
||||||
*/
|
*/
|
||||||
SlaveElement::SlaveElement(const ElementsLocation &location,
|
SlaveElement::SlaveElement(const ElementsLocation &location,
|
||||||
QGraphicsItem *qgi,
|
QGraphicsItem *qgi,
|
||||||
int *state) :
|
int *state) :
|
||||||
Element(location, qgi, state, Element::Slave)
|
Element(location, qgi, state, Element::Slave)
|
||||||
{
|
{
|
||||||
m_xref_item = nullptr;
|
m_xref_item = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief SlaveElement::~SlaveElement
|
@brief SlaveElement::~SlaveElement
|
||||||
default destructor
|
default destructor
|
||||||
*/
|
*/
|
||||||
SlaveElement::~SlaveElement()
|
SlaveElement::~SlaveElement()
|
||||||
{
|
{
|
||||||
unlinkAllElements();
|
unlinkAllElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief SlaveElement::linkToElement
|
@brief SlaveElement::linkToElement
|
||||||
Link this slave to another element
|
Link this slave to another element
|
||||||
For this class element must be a master
|
For this class element must be a master
|
||||||
@param elmt
|
@param elmt
|
||||||
*/
|
*/
|
||||||
void SlaveElement::linkToElement(Element *elmt)
|
void SlaveElement::linkToElement(Element *elmt)
|
||||||
{
|
{
|
||||||
// check if element is master and if isn't already linked
|
// check if element is master and if isn't already linked
|
||||||
if (elmt->linkType() == Master && !connected_elements.contains(elmt))
|
if (elmt->linkType() == Master && !connected_elements.contains(elmt))
|
||||||
{
|
{
|
||||||
if(!isFree())
|
if(!isFree())
|
||||||
unlinkAllElements();
|
unlinkAllElements();
|
||||||
|
|
||||||
connected_elements << elmt;
|
connected_elements << elmt;
|
||||||
|
|
||||||
elmt -> linkToElement(this);
|
elmt -> linkToElement(this);
|
||||||
emit linkedElementChanged();
|
emit linkedElementChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief SlaveElement::unlinkAllElements
|
@brief SlaveElement::unlinkAllElements
|
||||||
Unlink all of the element in the QList connected_elements
|
Unlink all of the element in the QList connected_elements
|
||||||
*/
|
*/
|
||||||
void SlaveElement::unlinkAllElements()
|
void SlaveElement::unlinkAllElements()
|
||||||
{
|
{
|
||||||
// if this element is free no need to do something
|
// if this element is free no need to do something
|
||||||
if (!isFree())
|
if (!isFree())
|
||||||
{
|
{
|
||||||
foreach(Element *elmt, connected_elements)
|
foreach(Element *elmt, connected_elements)
|
||||||
unlinkElement(elmt);
|
unlinkElement(elmt);
|
||||||
emit linkedElementChanged();
|
emit linkedElementChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief SlaveElement::unlinkElement
|
@brief SlaveElement::unlinkElement
|
||||||
Unlink the given elmt in parametre
|
Unlink the given elmt in parametre
|
||||||
@param elmt
|
@param elmt
|
||||||
*/
|
*/
|
||||||
void SlaveElement::unlinkElement(Element *elmt)
|
void SlaveElement::unlinkElement(Element *elmt)
|
||||||
{
|
{
|
||||||
//Ensure elmt is linked to this element
|
//Ensure elmt is linked to this element
|
||||||
if (connected_elements.contains(elmt))
|
if (connected_elements.contains(elmt))
|
||||||
{
|
{
|
||||||
connected_elements.removeOne(elmt);
|
connected_elements.removeOne(elmt);
|
||||||
|
|
||||||
elmt -> unlinkElement (this) ;
|
elmt -> unlinkElement (this) ;
|
||||||
elmt -> setHighlighted (false);
|
elmt -> setHighlighted (false);
|
||||||
emit linkedElementChanged();
|
emit linkedElementChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef SLAVEELEMENT_H
|
#ifndef SLAVEELEMENT_H
|
||||||
#define SLAVEELEMENT_H
|
#define SLAVEELEMENT_H
|
||||||
@@ -23,19 +23,19 @@
|
|||||||
|
|
||||||
class SlaveElement : public Element
|
class SlaveElement : public Element
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SlaveElement (
|
explicit SlaveElement (
|
||||||
const ElementsLocation &,
|
const ElementsLocation &,
|
||||||
QGraphicsItem * = nullptr,
|
QGraphicsItem * = nullptr,
|
||||||
int * = nullptr);
|
int * = nullptr);
|
||||||
~SlaveElement() override;
|
~SlaveElement() override;
|
||||||
void linkToElement(Element *elmt) override;
|
void linkToElement(Element *elmt) override;
|
||||||
void unlinkAllElements() override;
|
void unlinkAllElements() override;
|
||||||
void unlinkElement(Element *elmt) override;
|
void unlinkElement(Element *elmt) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGraphicsTextItem *m_xref_item{nullptr};
|
QGraphicsTextItem *m_xref_item{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SLAVEELEMENT_H
|
#endif // SLAVEELEMENT_H
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef TERMINAL_H
|
#ifndef TERMINAL_H
|
||||||
#define TERMINAL_H
|
#define TERMINAL_H
|
||||||
@@ -28,165 +28,165 @@ class Element;
|
|||||||
class TerminalData;
|
class TerminalData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The Terminal class
|
@brief The Terminal class
|
||||||
This class represents a terminal of an electrical element, i.e. a possible
|
This class represents a terminal of an electrical element, i.e. a possible
|
||||||
plug point for conductors.
|
plug point for conductors.
|
||||||
This class handles all mouse events for connecting conductors
|
This class handles all mouse events for connecting conductors
|
||||||
*/
|
*/
|
||||||
class Terminal : public QGraphicsObject, public PropertiesInterface
|
class Terminal : public QGraphicsObject, public PropertiesInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void conductorWasAdded(Conductor *conductor);
|
void conductorWasAdded(Conductor *conductor);
|
||||||
void conductorWasRemoved(Conductor *conductor);
|
void conductorWasRemoved(Conductor *conductor);
|
||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
|
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
|
||||||
Terminal(qreal, qreal, Qet::Orientation, Element * = nullptr);
|
Terminal(qreal, qreal, Qet::Orientation, Element * = nullptr);
|
||||||
Terminal(TerminalData* data, Element *e = nullptr);
|
Terminal(TerminalData* data, Element *e = nullptr);
|
||||||
Terminal(QPointF, Qet::Orientation, QString number,
|
Terminal(QPointF, Qet::Orientation, QString number,
|
||||||
QString name, bool hiddenName, Element * = nullptr);
|
QString name, bool hiddenName, Element * = nullptr);
|
||||||
~Terminal() override;
|
~Terminal() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Terminal(const Terminal &);
|
Terminal(const Terminal &);
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@brief type
|
@brief type
|
||||||
Enable the use of qgraphicsitem_cast to safely
|
Enable the use of qgraphicsitem_cast to safely
|
||||||
cast a QGraphicsItem into a Terminal
|
cast a QGraphicsItem into a Terminal
|
||||||
@return the QGraphicsItem type
|
@return the QGraphicsItem type
|
||||||
*/
|
*/
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
|
|
||||||
void paint(
|
void paint(
|
||||||
QPainter *painter,
|
QPainter *painter,
|
||||||
const QStyleOptionGraphicsItem *,
|
const QStyleOptionGraphicsItem *,
|
||||||
QWidget *) override;
|
QWidget *) override;
|
||||||
void drawHelpLine (bool draw = true);
|
void drawHelpLine (bool draw = true);
|
||||||
QLineF HelpLine () const;
|
QLineF HelpLine () const;
|
||||||
QRectF boundingRect () const override;
|
QRectF boundingRect () const override;
|
||||||
|
|
||||||
// methods to manage conductors attached to the terminal
|
// methods to manage conductors attached to the terminal
|
||||||
Terminal* alignedWithTerminal () const;
|
Terminal* alignedWithTerminal () const;
|
||||||
bool addConductor (Conductor *conductor);
|
bool addConductor (Conductor *conductor);
|
||||||
void removeConductor (Conductor *conductor);
|
void removeConductor (Conductor *conductor);
|
||||||
int conductorsCount () const;
|
int conductorsCount () const;
|
||||||
Diagram *diagram () const;
|
Diagram *diagram () const;
|
||||||
Element *parentElement () const;
|
Element *parentElement () const;
|
||||||
QUuid uuid () const;
|
QUuid uuid () const;
|
||||||
int ID() const;
|
int ID() const;
|
||||||
QPointF dockPos();
|
QPointF dockPos();
|
||||||
QPointF originPos();
|
QPointF originPos();
|
||||||
|
|
||||||
QList<Conductor *> conductors() const;
|
QList<Conductor *> conductors() const;
|
||||||
Qet::Orientation orientation() const;
|
Qet::Orientation orientation() const;
|
||||||
QPointF dockConductor() const;
|
QPointF dockConductor() const;
|
||||||
QString number() const;
|
QString number() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void setNumber(QString number);
|
void setNumber(QString number);
|
||||||
void setName(QString name, bool hiddenName);
|
void setName(QString name, bool hiddenName);
|
||||||
void updateConductor();
|
void updateConductor();
|
||||||
bool isLinkedTo(Terminal *);
|
bool isLinkedTo(Terminal *);
|
||||||
bool canBeLinkedTo(Terminal *);
|
bool canBeLinkedTo(Terminal *);
|
||||||
void setID(int id);
|
void setID(int id);
|
||||||
|
|
||||||
// methods related to XML import/export
|
// methods related to XML import/export
|
||||||
static bool valideXml(const QDomElement &);
|
static bool valideXml(const QDomElement &);
|
||||||
bool fromXml (const QDomElement &) override;
|
bool fromXml (const QDomElement &) override;
|
||||||
QDomElement toXml (QDomDocument &) const override;
|
QDomElement toXml (QDomDocument &) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// methods related to events management
|
// methods related to events management
|
||||||
void hoverEnterEvent (QGraphicsSceneHoverEvent *) override;
|
void hoverEnterEvent (QGraphicsSceneHoverEvent *) override;
|
||||||
void hoverMoveEvent (QGraphicsSceneHoverEvent *) override;
|
void hoverMoveEvent (QGraphicsSceneHoverEvent *) override;
|
||||||
void hoverLeaveEvent (QGraphicsSceneHoverEvent *) override;
|
void hoverLeaveEvent (QGraphicsSceneHoverEvent *) override;
|
||||||
void mousePressEvent (QGraphicsSceneMouseEvent *) override;
|
void mousePressEvent (QGraphicsSceneMouseEvent *) override;
|
||||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override;
|
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override;
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1002 };
|
enum { Type = UserType + 1002 };
|
||||||
|
|
||||||
static const qreal terminalSize;
|
static const qreal terminalSize;
|
||||||
static const qreal Z;
|
static const qreal Z;
|
||||||
// Various static colors used for hover effects
|
// Various static colors used for hover effects
|
||||||
// The assignement is in the cpp file
|
// The assignement is in the cpp file
|
||||||
/// default color
|
/// default color
|
||||||
static QColor neutralColor;
|
static QColor neutralColor;
|
||||||
/// color for legal actions
|
/// color for legal actions
|
||||||
static QColor allowedColor;
|
static QColor allowedColor;
|
||||||
/// color for allowed but fuzzy or not recommended actions
|
/// color for allowed but fuzzy or not recommended actions
|
||||||
static QColor warningColor;
|
static QColor warningColor;
|
||||||
/// color for forbidden actions
|
/// color for forbidden actions
|
||||||
static QColor forbiddenColor;
|
static QColor forbiddenColor;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_draw_help_line{false};
|
bool m_draw_help_line{false};
|
||||||
QGraphicsLineItem *m_help_line{nullptr};
|
QGraphicsLineItem *m_help_line{nullptr};
|
||||||
QGraphicsLineItem *m_help_line_a{nullptr};
|
QGraphicsLineItem *m_help_line_a{nullptr};
|
||||||
|
|
||||||
|
|
||||||
TerminalData* d;
|
TerminalData* d;
|
||||||
|
|
||||||
/// Parent electrical element
|
/// Parent electrical element
|
||||||
Element *parent_element_{nullptr};
|
Element *parent_element_{nullptr};
|
||||||
public:
|
public:
|
||||||
/// docking point for parent element
|
/// docking point for parent element
|
||||||
QPointF dock_elmt_;
|
QPointF dock_elmt_;
|
||||||
private:
|
private:
|
||||||
/// List of conductors attached to the terminal
|
/// List of conductors attached to the terminal
|
||||||
QList<Conductor *> conductors_;
|
QList<Conductor *> conductors_;
|
||||||
/**
|
/**
|
||||||
Pointer to a rectangle representing the terminal bounding rect;
|
Pointer to a rectangle representing the terminal bounding rect;
|
||||||
used to calculate the bounding rect once only;
|
used to calculate the bounding rect once only;
|
||||||
used a pointer because boundingRect() is supposed to be const.
|
used a pointer because boundingRect() is supposed to be const.
|
||||||
*/
|
*/
|
||||||
QRectF *br_{nullptr};
|
QRectF *br_{nullptr};
|
||||||
/// Last terminal seen through an attached conductor
|
/// Last terminal seen through an attached conductor
|
||||||
Terminal *previous_terminal_{nullptr};
|
Terminal *previous_terminal_{nullptr};
|
||||||
/// Whether the mouse pointer is hovering the terminal
|
/// Whether the mouse pointer is hovering the terminal
|
||||||
bool hovered_{false};
|
bool hovered_{false};
|
||||||
/// Color used for the hover effect
|
/// Color used for the hover effect
|
||||||
QColor hovered_color_{Terminal::hovered_color_};
|
QColor hovered_color_{Terminal::hovered_color_};
|
||||||
/// Number of Terminal
|
/// Number of Terminal
|
||||||
QString number_terminal_;
|
QString number_terminal_;
|
||||||
bool name_terminal_hidden{true};
|
bool name_terminal_hidden{true};
|
||||||
|
|
||||||
/// legacy id used by the conductor to find the terminal. From 0.8x on the uuid is used instead.
|
/// legacy id used by the conductor to find the terminal. From 0.8x on the uuid is used instead.
|
||||||
int m_id{-1};
|
int m_id{-1};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init(QString number, QString name, bool hiddenName);
|
void init(QString number, QString name, bool hiddenName);
|
||||||
void init(QPointF pf, Qet::Orientation o, QString number,
|
void init(QPointF pf, Qet::Orientation o, QString number,
|
||||||
QString name, bool hiddenName);
|
QString name, bool hiddenName);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Terminal::conductorsCount
|
@brief Terminal::conductorsCount
|
||||||
@return the number of conductors attached to the terminal.
|
@return the number of conductors attached to the terminal.
|
||||||
*/
|
*/
|
||||||
inline int Terminal::conductorsCount() const
|
inline int Terminal::conductorsCount() const
|
||||||
{
|
{
|
||||||
return(conductors_.size());
|
return(conductors_.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Terminal::number
|
@brief Terminal::number
|
||||||
@return the number of terminal.
|
@return the number of terminal.
|
||||||
*/
|
*/
|
||||||
inline QString Terminal::number() const
|
inline QString Terminal::number() const
|
||||||
{
|
{
|
||||||
return(number_terminal_);
|
return(number_terminal_);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
|
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
|
||||||
const bool all_diagram = true);
|
const bool all_diagram = true);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,157 +1,157 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "helpercell.h"
|
#include "helpercell.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructor
|
Constructor
|
||||||
@param parent Parent QGraphicsItem
|
@param parent Parent QGraphicsItem
|
||||||
*/
|
*/
|
||||||
HelperCell::HelperCell(QGraphicsItem *parent) :
|
HelperCell::HelperCell(QGraphicsItem *parent) :
|
||||||
QGraphicsObject(parent),
|
QGraphicsObject(parent),
|
||||||
QGraphicsLayoutItem(),
|
QGraphicsLayoutItem(),
|
||||||
background_color(Qt::white),
|
background_color(Qt::white),
|
||||||
foreground_color(Qt::black),
|
foreground_color(Qt::black),
|
||||||
label(),
|
label(),
|
||||||
orientation(Qt::Horizontal),
|
orientation(Qt::Horizontal),
|
||||||
index(-1)
|
index(-1)
|
||||||
{
|
{
|
||||||
setGraphicsItem(this);
|
setGraphicsItem(this);
|
||||||
setFlag(QGraphicsItem::ItemIsSelectable, false);
|
setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destructor
|
Destructor
|
||||||
*/
|
*/
|
||||||
HelperCell::~HelperCell()
|
HelperCell::~HelperCell()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Ensure geometry changes are handled for both QGraphicsObject and
|
Ensure geometry changes are handled for both QGraphicsObject and
|
||||||
QGraphicsLayoutItem.
|
QGraphicsLayoutItem.
|
||||||
@param g New geometry
|
@param g New geometry
|
||||||
*/
|
*/
|
||||||
void HelperCell::setGeometry(const QRectF &g) {
|
void HelperCell::setGeometry(const QRectF &g) {
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
QGraphicsLayoutItem::setGeometry(g);
|
QGraphicsLayoutItem::setGeometry(g);
|
||||||
setPos(g.topLeft());
|
setPos(g.topLeft());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param which Size hint to be modified
|
@param which Size hint to be modified
|
||||||
@param constraint New value for the size hint
|
@param constraint New value for the size hint
|
||||||
@return the size hint for \a which using the width or height of \a constraint
|
@return the size hint for \a which using the width or height of \a constraint
|
||||||
*/
|
*/
|
||||||
QSizeF HelperCell::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
|
QSizeF HelperCell::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(which);
|
Q_UNUSED(which);
|
||||||
return(constraint);
|
return(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return the bounding rect of this helper cell
|
@return the bounding rect of this helper cell
|
||||||
*/
|
*/
|
||||||
QRectF HelperCell::boundingRect() const
|
QRectF HelperCell::boundingRect() const
|
||||||
{
|
{
|
||||||
return QRectF(QPointF(0,0), geometry().size());
|
return QRectF(QPointF(0,0), geometry().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Handles the helper cell visual rendering
|
Handles the helper cell visual rendering
|
||||||
@param painter QPainter to be used for the rendering
|
@param painter QPainter to be used for the rendering
|
||||||
@param option Rendering options
|
@param option Rendering options
|
||||||
@param widget QWidget being painted, if any
|
@param widget QWidget being painted, if any
|
||||||
*/
|
*/
|
||||||
void HelperCell::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
void HelperCell::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
QRectF drawing_rectangle(QPointF(0, 0), geometry().size());
|
QRectF drawing_rectangle(QPointF(0, 0), geometry().size());
|
||||||
|
|
||||||
painter -> setPen(Qt::black);
|
painter -> setPen(Qt::black);
|
||||||
painter -> setBrush(background_color);
|
painter -> setBrush(background_color);
|
||||||
painter -> drawRect(drawing_rectangle);
|
painter -> drawRect(drawing_rectangle);
|
||||||
|
|
||||||
painter -> setPen(foreground_color);
|
painter -> setPen(foreground_color);
|
||||||
painter -> drawText(drawing_rectangle, Qt::AlignHCenter | Qt::AlignVCenter, label);
|
painter -> drawText(drawing_rectangle, Qt::AlignHCenter | Qt::AlignVCenter, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param type new type of this helper cell -- @see QET::TitleBlockColumnLength
|
@param type new type of this helper cell -- @see QET::TitleBlockColumnLength
|
||||||
*/
|
*/
|
||||||
void HelperCell::setType(QET::TitleBlockColumnLength type) {
|
void HelperCell::setType(QET::TitleBlockColumnLength type) {
|
||||||
if (type == QET::Absolute) {
|
if (type == QET::Absolute) {
|
||||||
background_color = QColor("#C0FFFF");
|
background_color = QColor("#C0FFFF");
|
||||||
foreground_color = Qt::black;
|
foreground_color = Qt::black;
|
||||||
} else if (type == QET::RelativeToTotalLength) {
|
} else if (type == QET::RelativeToTotalLength) {
|
||||||
background_color = QColor("#FFA858");
|
background_color = QColor("#FFA858");
|
||||||
foreground_color = Qt::black;
|
foreground_color = Qt::black;
|
||||||
} else if (type == QET::RelativeToRemainingLength) {
|
} else if (type == QET::RelativeToRemainingLength) {
|
||||||
background_color = QColor("#FFC0C0");
|
background_color = QColor("#FFC0C0");
|
||||||
foreground_color = Qt::black;
|
foreground_color = Qt::black;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set the list of actions displayed by the context menu of this helper cell.
|
Set the list of actions displayed by the context menu of this helper cell.
|
||||||
*/
|
*/
|
||||||
void HelperCell::setActions(const QList<QAction *> &actions) {
|
void HelperCell::setActions(const QList<QAction *> &actions) {
|
||||||
actions_ = actions;
|
actions_ = actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return the list of actions displayed by the context menu of this helper cell.
|
@return the list of actions displayed by the context menu of this helper cell.
|
||||||
*/
|
*/
|
||||||
QList<QAction *> HelperCell::actions() const
|
QList<QAction *> HelperCell::actions() const
|
||||||
{
|
{
|
||||||
return actions_;
|
return actions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param text New label displayed by this helper cell
|
@param text New label displayed by this helper cell
|
||||||
@param set_as_tooltip If true, the text is also used as tooltip.
|
@param set_as_tooltip If true, the text is also used as tooltip.
|
||||||
*/
|
*/
|
||||||
void HelperCell::setLabel(const QString &text, bool set_as_tooltip) {
|
void HelperCell::setLabel(const QString &text, bool set_as_tooltip) {
|
||||||
label = text;
|
label = text;
|
||||||
if (set_as_tooltip) {
|
if (set_as_tooltip) {
|
||||||
setToolTip(text);
|
setToolTip(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Handle context menu events.
|
Handle context menu events.
|
||||||
@param event Context menu event.
|
@param event Context menu event.
|
||||||
*/
|
*/
|
||||||
void HelperCell::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
void HelperCell::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
|
||||||
if (actions_.isEmpty()) return;
|
if (actions_.isEmpty()) return;
|
||||||
|
|
||||||
QMenu context_menu;
|
QMenu context_menu;
|
||||||
foreach (QAction *action, actions_) {
|
foreach (QAction *action, actions_) {
|
||||||
context_menu.addAction(action);
|
context_menu.addAction(action);
|
||||||
}
|
}
|
||||||
emit(contextMenuTriggered(this));
|
emit(contextMenuTriggered(this));
|
||||||
context_menu.exec(event -> screenPos());
|
context_menu.exec(event -> screenPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Handle double click events.
|
Handle double click events.
|
||||||
*/
|
*/
|
||||||
void HelperCell::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) {
|
void HelperCell::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) {
|
||||||
|
|
||||||
emit(doubleClicked(this));
|
emit(doubleClicked(this));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef TITLEBLOCK_SLASH_HELPER_CELL_H
|
#ifndef TITLEBLOCK_SLASH_HELPER_CELL_H
|
||||||
#define TITLEBLOCK_SLASH_HELPER_CELL_H
|
#define TITLEBLOCK_SLASH_HELPER_CELL_H
|
||||||
@@ -21,48 +21,48 @@
|
|||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class implements a helper widget for cells that indicate the length of
|
This class implements a helper widget for cells that indicate the length of
|
||||||
columns and rows.
|
columns and rows.
|
||||||
*/
|
*/
|
||||||
class HelperCell : public QGraphicsObject, public QGraphicsLayoutItem {
|
class HelperCell : public QGraphicsObject, public QGraphicsLayoutItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(QGraphicsLayoutItem)
|
Q_INTERFACES(QGraphicsLayoutItem)
|
||||||
|
|
||||||
// constructor, destructor
|
// constructor, destructor
|
||||||
public:
|
public:
|
||||||
HelperCell(QGraphicsItem * = nullptr);
|
HelperCell(QGraphicsItem * = nullptr);
|
||||||
~HelperCell() override;
|
~HelperCell() override;
|
||||||
private:
|
private:
|
||||||
HelperCell(const HelperCell &);
|
HelperCell(const HelperCell &);
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
public:
|
public:
|
||||||
QColor background_color{Qt::white}; ///< Background color when rendering this cell
|
QColor background_color{Qt::white}; ///< Background color when rendering this cell
|
||||||
QColor foreground_color{Qt::black}; ///< Text color when rendering this cell
|
QColor foreground_color{Qt::black}; ///< Text color when rendering this cell
|
||||||
QString label; ///< Label displayed in this cell
|
QString label; ///< Label displayed in this cell
|
||||||
Qt::Orientation orientation{Qt::Horizontal}; ///< Orientation of this cell
|
Qt::Orientation orientation{Qt::Horizontal}; ///< Orientation of this cell
|
||||||
int index{-1}; ///< Index of this cell
|
int index{-1}; ///< Index of this cell
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
void setGeometry(const QRectF &) override;
|
void setGeometry(const QRectF &) override;
|
||||||
QSizeF sizeHint(Qt::SizeHint, const QSizeF & = QSizeF()) const override;
|
QSizeF sizeHint(Qt::SizeHint, const QSizeF & = QSizeF()) const override;
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||||
virtual void setType(QET::TitleBlockColumnLength);
|
virtual void setType(QET::TitleBlockColumnLength);
|
||||||
virtual void setActions(const QList<QAction *> &);
|
virtual void setActions(const QList<QAction *> &);
|
||||||
virtual QList<QAction *> actions() const;
|
virtual QList<QAction *> actions() const;
|
||||||
virtual void setLabel(const QString &text, bool = true);
|
virtual void setLabel(const QString &text, bool = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *) override;
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *) override;
|
||||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) override;
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void contextMenuTriggered(HelperCell *);
|
void contextMenuTriggered(HelperCell *);
|
||||||
void doubleClicked(HelperCell *);
|
void doubleClicked(HelperCell *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QAction *> actions_; ///< List of actions displayed by the context menu
|
QList<QAction *> actions_; ///< List of actions displayed by the context menu
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,46 +1,46 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef TITLEBLOCK_SLASH_SPLITTED_HELPER_CELL_H
|
#ifndef TITLEBLOCK_SLASH_SPLITTED_HELPER_CELL_H
|
||||||
#define TITLEBLOCK_SLASH_SPLITTED_HELPER_CELL_H
|
#define TITLEBLOCK_SLASH_SPLITTED_HELPER_CELL_H
|
||||||
#include "helpercell.h"
|
#include "helpercell.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class is a variant of HelperCell having the ability to display two
|
This class is a variant of HelperCell having the ability to display two
|
||||||
labels, with a split line between them.
|
labels, with a split line between them.
|
||||||
*/
|
*/
|
||||||
class SplittedHelperCell : public HelperCell {
|
class SplittedHelperCell : public HelperCell {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SplittedHelperCell(QGraphicsItem * = nullptr);
|
SplittedHelperCell(QGraphicsItem * = nullptr);
|
||||||
~SplittedHelperCell() override;
|
~SplittedHelperCell() override;
|
||||||
private:
|
private:
|
||||||
SplittedHelperCell(const SplittedHelperCell &);
|
SplittedHelperCell(const SplittedHelperCell &);
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
// colors are set in the constructor
|
// colors are set in the constructor
|
||||||
QColor split_background_color; ///< Background color on the split side
|
QColor split_background_color; ///< Background color on the split side
|
||||||
QColor split_foreground_color; ///< Text color on the split side
|
QColor split_foreground_color; ///< Text color on the split side
|
||||||
QString split_label; ///< Text displayed on the split side
|
QString split_label; ///< Text displayed on the split side
|
||||||
int split_size; ///< Length of the split side
|
int split_size; ///< Length of the split side
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,252 +1,252 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "titleblockproperties.h"
|
#include "titleblockproperties.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur. Initialise un objet TitleBlockProperties avec tous les champs
|
Constructeur. Initialise un objet TitleBlockProperties avec tous les champs
|
||||||
vides (date vide + useDate a UseDateValue).
|
vides (date vide + useDate a UseDateValue).
|
||||||
*/
|
*/
|
||||||
TitleBlockProperties::TitleBlockProperties()
|
TitleBlockProperties::TitleBlockProperties()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destructeur
|
Destructeur
|
||||||
*/
|
*/
|
||||||
TitleBlockProperties::~TitleBlockProperties()
|
TitleBlockProperties::~TitleBlockProperties()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param ip autre conteneur TitleBlockProperties
|
@param ip autre conteneur TitleBlockProperties
|
||||||
@return true si ip et ce conteneur sont identiques, false sinon
|
@return true si ip et ce conteneur sont identiques, false sinon
|
||||||
*/
|
*/
|
||||||
bool TitleBlockProperties::operator==(const TitleBlockProperties &ip) {
|
bool TitleBlockProperties::operator==(const TitleBlockProperties &ip) {
|
||||||
return(
|
return(
|
||||||
ip.title == title &&\
|
ip.title == title &&\
|
||||||
ip.author == author &&\
|
ip.author == author &&\
|
||||||
ip.date == date &&\
|
ip.date == date &&\
|
||||||
ip.filename == filename &&\
|
ip.filename == filename &&\
|
||||||
ip.plant == plant &&\
|
ip.plant == plant &&\
|
||||||
ip.locmach == locmach &&\
|
ip.locmach == locmach &&\
|
||||||
ip.indexrev == indexrev &&\
|
ip.indexrev == indexrev &&\
|
||||||
ip.version == version &&\
|
ip.version == version &&\
|
||||||
ip.folio == folio &&\
|
ip.folio == folio &&\
|
||||||
ip.auto_page_num == auto_page_num &&\
|
ip.auto_page_num == auto_page_num &&\
|
||||||
ip.template_name == template_name &&\
|
ip.template_name == template_name &&\
|
||||||
ip.context == context &&\
|
ip.context == context &&\
|
||||||
ip.display_at == display_at &&\
|
ip.display_at == display_at &&\
|
||||||
ip.collection == collection
|
ip.collection == collection
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param ip autre conteneur TitleBlockProperties
|
@param ip autre conteneur TitleBlockProperties
|
||||||
@return false si ip et ce conteneur sont identiques, true sinon
|
@return false si ip et ce conteneur sont identiques, true sinon
|
||||||
*/
|
*/
|
||||||
bool TitleBlockProperties::operator!=(const TitleBlockProperties &ip) {
|
bool TitleBlockProperties::operator!=(const TitleBlockProperties &ip) {
|
||||||
return(!(*this == ip));
|
return(!(*this == ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Exporte le cartouche sous formes d'attributs XML ajoutes a l'element e.
|
Exporte le cartouche sous formes d'attributs XML ajoutes a l'element e.
|
||||||
@param e Element XML auquel seront ajoutes des attributs
|
@param e Element XML auquel seront ajoutes des attributs
|
||||||
*/
|
*/
|
||||||
void TitleBlockProperties::toXml(QDomElement &e) const
|
void TitleBlockProperties::toXml(QDomElement &e) const
|
||||||
{
|
{
|
||||||
e.setAttribute("author", author);
|
e.setAttribute("author", author);
|
||||||
e.setAttribute("title", title);
|
e.setAttribute("title", title);
|
||||||
e.setAttribute("filename", filename);
|
e.setAttribute("filename", filename);
|
||||||
e.setAttribute("plant", plant);
|
e.setAttribute("plant", plant);
|
||||||
e.setAttribute("locmach", locmach);
|
e.setAttribute("locmach", locmach);
|
||||||
e.setAttribute("indexrev",indexrev);
|
e.setAttribute("indexrev",indexrev);
|
||||||
e.setAttribute("version", version);
|
e.setAttribute("version", version);
|
||||||
e.setAttribute("folio", folio);
|
e.setAttribute("folio", folio);
|
||||||
e.setAttribute("auto_page_num", auto_page_num);
|
e.setAttribute("auto_page_num", auto_page_num);
|
||||||
e.setAttribute("date", exportDate());
|
e.setAttribute("date", exportDate());
|
||||||
e.setAttribute("displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
|
e.setAttribute("displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
|
||||||
if (!template_name.isEmpty())
|
if (!template_name.isEmpty())
|
||||||
{
|
{
|
||||||
e.setAttribute("titleblocktemplate", template_name);
|
e.setAttribute("titleblocktemplate", template_name);
|
||||||
e.setAttribute("titleblocktemplateCollection", QET::qetCollectionToString(collection));
|
e.setAttribute("titleblocktemplateCollection", QET::qetCollectionToString(collection));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.keys().count()) {
|
if (context.keys().count()) {
|
||||||
QDomElement properties = e.ownerDocument().createElement("properties");
|
QDomElement properties = e.ownerDocument().createElement("properties");
|
||||||
context.toXml(properties);
|
context.toXml(properties);
|
||||||
e.appendChild(properties);
|
e.appendChild(properties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement TitleBlockProperties::toXml(QDomDocument &d) const {
|
QDomElement TitleBlockProperties::toXml(QDomDocument &d) const {
|
||||||
Q_UNUSED(d)
|
Q_UNUSED(d)
|
||||||
qDebug() << "NOT IMPLEMENTED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
|
qDebug() << "NOT IMPLEMENTED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
|
||||||
return QDomElement();
|
return QDomElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** RETURNS True
|
/** RETURNS True
|
||||||
Importe le cartouche a partir des attributs XML de l'element e
|
Importe le cartouche a partir des attributs XML de l'element e
|
||||||
@param e Element XML dont les attributs seront lus
|
@param e Element XML dont les attributs seront lus
|
||||||
*/
|
*/
|
||||||
bool TitleBlockProperties::fromXml(const QDomElement &e) {
|
bool TitleBlockProperties::fromXml(const QDomElement &e) {
|
||||||
|
|
||||||
|
|
||||||
// reads the historical fields
|
// reads the historical fields
|
||||||
propertyString(e, "author", &author);
|
propertyString(e, "author", &author);
|
||||||
propertyString(e, "title", &title);
|
propertyString(e, "title", &title);
|
||||||
propertyString(e, "filename", &filename);
|
propertyString(e, "filename", &filename);
|
||||||
propertyString(e, "plant", &plant);
|
propertyString(e, "plant", &plant);
|
||||||
propertyString(e, "locmach", &locmach);
|
propertyString(e, "locmach", &locmach);
|
||||||
propertyString(e, "indexrev", &indexrev);
|
propertyString(e, "indexrev", &indexrev);
|
||||||
propertyString(e, "version", &version);
|
propertyString(e, "version", &version);
|
||||||
propertyString(e, "folio", &folio);
|
propertyString(e, "folio", &folio);
|
||||||
propertyString(e, "auto_page_num", &auto_page_num);
|
propertyString(e, "auto_page_num", &auto_page_num);
|
||||||
QString date;
|
QString date;
|
||||||
propertyString(e, "date", &date);
|
propertyString(e, "date", &date);
|
||||||
setDateFromString(date);
|
setDateFromString(date);
|
||||||
|
|
||||||
QString display_at_temp;
|
QString display_at_temp;
|
||||||
if (propertyString(e, "displayAt", &display_at_temp) == PropertyFlags::Success)
|
if (propertyString(e, "displayAt", &display_at_temp) == PropertyFlags::Success)
|
||||||
display_at = (display_at_temp == "bottom" ? Qt::BottomEdge : Qt::RightEdge); // otherwise it gets default in header file
|
display_at = (display_at_temp == "bottom" ? Qt::BottomEdge : Qt::RightEdge); // otherwise it gets default in header file
|
||||||
|
|
||||||
// reads the template used to render the title block
|
// reads the template used to render the title block
|
||||||
if (propertyString(e, "titleblocktemplate", &template_name) == PropertyFlags::Success) {
|
if (propertyString(e, "titleblocktemplate", &template_name) == PropertyFlags::Success) {
|
||||||
QString tbc;
|
QString tbc;
|
||||||
if (propertyString(e, "titleblocktemplateCollection", &tbc) == PropertyFlags::Success)
|
if (propertyString(e, "titleblocktemplateCollection", &tbc) == PropertyFlags::Success)
|
||||||
collection = QET::qetCollectionFromString(tbc);
|
collection = QET::qetCollectionFromString(tbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reads the additional fields used to fill the title block
|
// reads the additional fields used to fill the title block
|
||||||
context.clear();
|
context.clear();
|
||||||
foreach (QDomElement e, QET::findInDomElement(e, "properties")) {
|
foreach (QDomElement e, QET::findInDomElement(e, "properties")) {
|
||||||
context.fromXml(e);
|
context.fromXml(e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief TitleBlockProperties::toSettings
|
@brief TitleBlockProperties::toSettings
|
||||||
Export the TitleBlockProperties into a QSettings
|
Export the TitleBlockProperties into a QSettings
|
||||||
@param settings : setting to use
|
@param settings : setting to use
|
||||||
@param prefix : name to use as prefix for this property
|
@param prefix : name to use as prefix for this property
|
||||||
*/
|
*/
|
||||||
void TitleBlockProperties::toSettings(QSettings &settings, const QString &prefix) const
|
void TitleBlockProperties::toSettings(QSettings &settings, const QString &prefix) const
|
||||||
{
|
{
|
||||||
settings.setValue(prefix + "title", title);
|
settings.setValue(prefix + "title", title);
|
||||||
settings.setValue(prefix + "author", author);
|
settings.setValue(prefix + "author", author);
|
||||||
settings.setValue(prefix + "filename", filename);
|
settings.setValue(prefix + "filename", filename);
|
||||||
settings.setValue(prefix + "plant", plant);
|
settings.setValue(prefix + "plant", plant);
|
||||||
settings.setValue(prefix + "locmach", locmach);
|
settings.setValue(prefix + "locmach", locmach);
|
||||||
settings.setValue(prefix + "indexrev", indexrev);
|
settings.setValue(prefix + "indexrev", indexrev);
|
||||||
settings.setValue(prefix + "version", version);
|
settings.setValue(prefix + "version", version);
|
||||||
settings.setValue(prefix + "folio", folio);
|
settings.setValue(prefix + "folio", folio);
|
||||||
settings.setValue(prefix + "auto_page_num", auto_page_num);
|
settings.setValue(prefix + "auto_page_num", auto_page_num);
|
||||||
settings.setValue(prefix + "date", exportDate());
|
settings.setValue(prefix + "date", exportDate());
|
||||||
settings.setValue(prefix + "displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
|
settings.setValue(prefix + "displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
|
||||||
settings.setValue(prefix + "titleblocktemplate", template_name.isEmpty()? QString() : template_name);
|
settings.setValue(prefix + "titleblocktemplate", template_name.isEmpty()? QString() : template_name);
|
||||||
settings.setValue(prefix + "titleblocktemplateCollection", QET::qetCollectionToString(collection));
|
settings.setValue(prefix + "titleblocktemplateCollection", QET::qetCollectionToString(collection));
|
||||||
context.toSettings(settings, prefix + "properties");
|
context.toSettings(settings, prefix + "properties");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Importe le cartouche depuis une configuration.
|
Importe le cartouche depuis une configuration.
|
||||||
@param settings Parametres a lire
|
@param settings Parametres a lire
|
||||||
@param prefix prefixe a ajouter devant les noms des parametres
|
@param prefix prefixe a ajouter devant les noms des parametres
|
||||||
*/
|
*/
|
||||||
void TitleBlockProperties::fromSettings(const QSettings &settings, const QString &prefix) {
|
void TitleBlockProperties::fromSettings(const QSettings &settings, const QString &prefix) {
|
||||||
title = settings.value(prefix + "title").toString();
|
title = settings.value(prefix + "title").toString();
|
||||||
author = settings.value(prefix + "author").toString();
|
author = settings.value(prefix + "author").toString();
|
||||||
filename = settings.value(prefix + "filename").toString();
|
filename = settings.value(prefix + "filename").toString();
|
||||||
plant = settings.value(prefix + "plant").toString();
|
plant = settings.value(prefix + "plant").toString();
|
||||||
locmach = settings.value(prefix + "locmach").toString();
|
locmach = settings.value(prefix + "locmach").toString();
|
||||||
indexrev = settings.value(prefix + "indexrev").toString();
|
indexrev = settings.value(prefix + "indexrev").toString();
|
||||||
version = settings.value(prefix + "version").toString();
|
version = settings.value(prefix + "version").toString();
|
||||||
folio = settings.value(prefix + "folio", "%id/%total").toString();
|
folio = settings.value(prefix + "folio", "%id/%total").toString();
|
||||||
auto_page_num = settings.value(prefix + "auto_page_num").toString();
|
auto_page_num = settings.value(prefix + "auto_page_num").toString();
|
||||||
setDateFromString(settings.value(prefix + "date").toString());
|
setDateFromString(settings.value(prefix + "date").toString());
|
||||||
display_at = (settings.value(prefix + "displayAt", QVariant("bottom")).toString() == "bottom" ? Qt::BottomEdge : Qt::RightEdge);
|
display_at = (settings.value(prefix + "displayAt", QVariant("bottom")).toString() == "bottom" ? Qt::BottomEdge : Qt::RightEdge);
|
||||||
template_name = settings.value(prefix + "titleblocktemplate").toString();
|
template_name = settings.value(prefix + "titleblocktemplate").toString();
|
||||||
collection = QET::qetCollectionFromString(settings.value(prefix + "titleblocktemplateCollection").toString());
|
collection = QET::qetCollectionFromString(settings.value(prefix + "titleblocktemplateCollection").toString());
|
||||||
context.fromSettings(settings, prefix + "properties");
|
context.fromSettings(settings, prefix + "properties");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief TitleBlockProperties::defaultProperties
|
@brief TitleBlockProperties::defaultProperties
|
||||||
Return the default properties stored in the setting file
|
Return the default properties stored in the setting file
|
||||||
*/
|
*/
|
||||||
TitleBlockProperties TitleBlockProperties::defaultProperties()
|
TitleBlockProperties TitleBlockProperties::defaultProperties()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
TitleBlockProperties def;
|
TitleBlockProperties def;
|
||||||
def.fromSettings(settings, "diagrameditor/default");
|
def.fromSettings(settings, "diagrameditor/default");
|
||||||
|
|
||||||
return(def);
|
return(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return La date a utiliser
|
@return La date a utiliser
|
||||||
*/
|
*/
|
||||||
QDate TitleBlockProperties::finalDate() const
|
QDate TitleBlockProperties::finalDate() const
|
||||||
{
|
{
|
||||||
if (useDate == UseDateValue) {
|
if (useDate == UseDateValue) {
|
||||||
return(date);
|
return(date);
|
||||||
} else {
|
} else {
|
||||||
return(QDate::currentDate());
|
return(QDate::currentDate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return une chaine de caracteres decrivant comment gerer la date dans le
|
@return une chaine de caracteres decrivant comment gerer la date dans le
|
||||||
cartouche : la chaine peut valoir :
|
cartouche : la chaine peut valoir :
|
||||||
* null pour ne pas afficher de date
|
* null pour ne pas afficher de date
|
||||||
* now pour afficher la date courante (a la creation du schema)
|
* now pour afficher la date courante (a la creation du schema)
|
||||||
* une date au format yyyyMMdd pour utiliser une date fixe
|
* une date au format yyyyMMdd pour utiliser une date fixe
|
||||||
*/
|
*/
|
||||||
QString TitleBlockProperties::exportDate() const
|
QString TitleBlockProperties::exportDate() const
|
||||||
{
|
{
|
||||||
QString date_setting_value;
|
QString date_setting_value;
|
||||||
if (useDate == UseDateValue) {
|
if (useDate == UseDateValue) {
|
||||||
if (date.isNull()) date_setting_value = "null";
|
if (date.isNull()) date_setting_value = "null";
|
||||||
else date_setting_value = date.toString("yyyyMMdd");
|
else date_setting_value = date.toString("yyyyMMdd");
|
||||||
} else {
|
} else {
|
||||||
date_setting_value = "now";
|
date_setting_value = "now";
|
||||||
}
|
}
|
||||||
return(date_setting_value);
|
return(date_setting_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Charge les attributs date et useDate a partir d'une chaine de caracteres.
|
Charge les attributs date et useDate a partir d'une chaine de caracteres.
|
||||||
@param date_string Chaine de caracteres a analyser
|
@param date_string Chaine de caracteres a analyser
|
||||||
@see exportDate
|
@see exportDate
|
||||||
*/
|
*/
|
||||||
void TitleBlockProperties::setDateFromString(const QString &date_string) {
|
void TitleBlockProperties::setDateFromString(const QString &date_string) {
|
||||||
if (date_string == "now") {
|
if (date_string == "now") {
|
||||||
date = QDate::currentDate();
|
date = QDate::currentDate();
|
||||||
useDate = CurrentDate;
|
useDate = CurrentDate;
|
||||||
} else if (date_string.isEmpty() || date_string == "null") {
|
} else if (date_string.isEmpty() || date_string == "null") {
|
||||||
date = QDate();
|
date = QDate();
|
||||||
useDate = UseDateValue;
|
useDate = UseDateValue;
|
||||||
} else {
|
} else {
|
||||||
date = QDate::fromString(date_string, "yyyyMMdd");
|
date = QDate::fromString(date_string, "yyyyMMdd");
|
||||||
useDate = UseDateValue;
|
useDate = UseDateValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef TITLEBLOCK_PROPERTIES_H
|
#ifndef TITLEBLOCK_PROPERTIES_H
|
||||||
#define TITLEBLOCK_PROPERTIES_H
|
#define TITLEBLOCK_PROPERTIES_H
|
||||||
@@ -24,54 +24,54 @@
|
|||||||
#include "propertiesinterface.h"
|
#include "propertiesinterface.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class provides a container for the properties of a particular title
|
This class provides a container for the properties of a particular title
|
||||||
block, i.e. title, author, date, filename, folio, template, custom
|
block, i.e. title, author, date, filename, folio, template, custom
|
||||||
properties, ...
|
properties, ...
|
||||||
*/
|
*/
|
||||||
class TitleBlockProperties: public PropertiesInterface {
|
class TitleBlockProperties: public PropertiesInterface {
|
||||||
public:
|
public:
|
||||||
TitleBlockProperties();
|
TitleBlockProperties();
|
||||||
virtual ~TitleBlockProperties();
|
virtual ~TitleBlockProperties();
|
||||||
/// Lists the various ways to handle the date
|
/// Lists the various ways to handle the date
|
||||||
enum DateManagement {
|
enum DateManagement {
|
||||||
UseDateValue, ///< use the date attribute
|
UseDateValue, ///< use the date attribute
|
||||||
CurrentDate ///< use the current date
|
CurrentDate ///< use the current date
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator==(const TitleBlockProperties &);
|
bool operator==(const TitleBlockProperties &);
|
||||||
bool operator!=(const TitleBlockProperties &);
|
bool operator!=(const TitleBlockProperties &);
|
||||||
|
|
||||||
QDomElement toXml(QDomDocument &e) const override;
|
QDomElement toXml(QDomDocument &e) const override;
|
||||||
void toXml(QDomElement &e) const;
|
void toXml(QDomElement &e) const;
|
||||||
bool fromXml(const QDomElement &) override;
|
bool fromXml(const QDomElement &) override;
|
||||||
void toSettings(QSettings &, const QString & = QString()) const override;
|
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||||
void fromSettings(const QSettings &, const QString & = QString()) override;
|
void fromSettings(const QSettings &, const QString & = QString()) override;
|
||||||
|
|
||||||
void setAutoPageNum(QString autonum) {auto_page_num = autonum;}
|
void setAutoPageNum(QString autonum) {auto_page_num = autonum;}
|
||||||
|
|
||||||
static TitleBlockProperties defaultProperties();
|
static TitleBlockProperties defaultProperties();
|
||||||
|
|
||||||
QDate finalDate() const ;
|
QDate finalDate() const ;
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
QString title; ///< Folio title (displayed by the default template)
|
QString title; ///< Folio title (displayed by the default template)
|
||||||
QString author; ///< Author of the diagram/folio (displayed by the default template)
|
QString author; ///< Author of the diagram/folio (displayed by the default template)
|
||||||
QDate date; ///< Date (displayed by the default template)
|
QDate date; ///< Date (displayed by the default template)
|
||||||
QString filename; ///< Filename (displayed by the default template)
|
QString filename; ///< Filename (displayed by the default template)
|
||||||
QString plant; ///< Plant (displayed by the default template)
|
QString plant; ///< Plant (displayed by the default template)
|
||||||
QString locmach; ///< Location(displayed by the default template)
|
QString locmach; ///< Location(displayed by the default template)
|
||||||
QString indexrev; ///< Revision Index (displayed by the default template)
|
QString indexrev; ///< Revision Index (displayed by the default template)
|
||||||
QString version; ///< Version (displayed by the default template)
|
QString version; ///< Version (displayed by the default template)
|
||||||
QString folio; ///< Folio information (displayed by the default template)
|
QString folio; ///< Folio information (displayed by the default template)
|
||||||
QString auto_page_num;
|
QString auto_page_num;
|
||||||
DateManagement useDate{UseDateValue}; ///< Wheter to use the date attribute
|
DateManagement useDate{UseDateValue}; ///< Wheter to use the date attribute
|
||||||
QString template_name; ///< Name of the template used to render the title block - an empty string means "the default template provided by the application"
|
QString template_name; ///< Name of the template used to render the title block - an empty string means "the default template provided by the application"
|
||||||
DiagramContext context; ///< Container for the additional, user-defined fields
|
DiagramContext context; ///< Container for the additional, user-defined fields
|
||||||
Qt::Edge display_at{Qt::Edge::BottomEdge}; ///< Edge to display the titleblock
|
Qt::Edge display_at{Qt::Edge::BottomEdge}; ///< Edge to display the titleblock
|
||||||
QET::QetCollection collection{QET::QetCollection::Common}; ///<Specify the location of the title block
|
QET::QetCollection collection{QET::QetCollection::Common}; ///<Specify the location of the title block
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString exportDate() const;
|
QString exportDate() const;
|
||||||
void setDateFromString(const QString &);
|
void setDateFromString(const QString &);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user