mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-06-11 05:13:13 +02:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ada65f10e7 | |||
| 33328b30cd | |||
| b0a6b8fd05 | |||
| af83e8bf1b | |||
| 4a7772b003 | |||
| 253ac4d816 | |||
| a54b6192d0 | |||
| 0873904598 | |||
| 229bc2f9d9 | |||
| 31f05c58b9 | |||
| a65675b53e | |||
| c39ef0a999 | |||
| ff84a71d97 | |||
| 434c3dfbfb | |||
| 096f8f58e1 |
+465
-411
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+533
-477
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+465
-411
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+469
-415
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+464
-410
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
+469
-415
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+465
-411
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
+468
-411
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
+469
-415
File diff suppressed because it is too large
Load Diff
+469
-415
File diff suppressed because it is too large
Load Diff
+469
-415
File diff suppressed because it is too large
Load Diff
+465
-411
File diff suppressed because it is too large
Load Diff
+469
-415
File diff suppressed because it is too large
Load Diff
@@ -40,8 +40,8 @@ FileElementCollectionItem::FileElementCollectionItem()
|
||||
@return true if path exist.
|
||||
*/
|
||||
bool FileElementCollectionItem::setRootPath(const QString& path,
|
||||
bool set_data,
|
||||
bool hide_element)
|
||||
bool set_data,
|
||||
bool hide_element)
|
||||
{
|
||||
QDir dir(path);
|
||||
if (dir.exists())
|
||||
@@ -190,16 +190,16 @@ QString FileElementCollectionItem::name() const
|
||||
*/
|
||||
QString FileElementCollectionItem::collectionPath() const
|
||||
{
|
||||
QStandardItem* parent_ = parent();
|
||||
if (isCollectionRoot()) {
|
||||
if (m_path == QETApp::commonElementsDirN())
|
||||
return "common://";
|
||||
else
|
||||
return "custom://";
|
||||
}
|
||||
else if (parent_ && parent()->type() == FileElementCollectionItem::Type)
|
||||
{
|
||||
ElementCollectionItem *eci = static_cast<ElementCollectionItem*>(parent());
|
||||
else if (parent() && parent()->type()
|
||||
== FileElementCollectionItem::Type) {
|
||||
ElementCollectionItem *eci =
|
||||
static_cast<ElementCollectionItem*>(parent());
|
||||
if (eci->isCollectionRoot())
|
||||
return eci->collectionPath() + m_path;
|
||||
else
|
||||
@@ -276,7 +276,7 @@ void FileElementCollectionItem::setUpData()
|
||||
setFlags(Qt::ItemIsSelectable
|
||||
| Qt::ItemIsDragEnabled
|
||||
| Qt::ItemIsEnabled);
|
||||
|
||||
|
||||
//Set the local name and all informations of the element
|
||||
//in the data Qt::UserRole+1, these data will be use for search.
|
||||
ElementsLocation loc(collectionPath());
|
||||
@@ -331,8 +331,8 @@ void FileElementCollectionItem::setUpIcon()
|
||||
@param hide_element
|
||||
*/
|
||||
void FileElementCollectionItem::setPathName(const QString& path_name,
|
||||
bool set_data,
|
||||
bool hide_element)
|
||||
bool set_data,
|
||||
bool hide_element)
|
||||
{
|
||||
m_path = path_name;
|
||||
|
||||
@@ -353,7 +353,7 @@ void FileElementCollectionItem::populate(bool set_data, bool hide_element)
|
||||
|
||||
//Get all directory in this directory.
|
||||
for(auto str : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot,
|
||||
QDir::Name))
|
||||
QDir::Name))
|
||||
{
|
||||
FileElementCollectionItem *feci = new FileElementCollectionItem();
|
||||
appendRow(feci);
|
||||
@@ -368,7 +368,7 @@ void FileElementCollectionItem::populate(bool set_data, bool hide_element)
|
||||
//Get all elmt file in this directory
|
||||
dir.setNameFilters(QStringList() << "*.elmt");
|
||||
for(auto str : dir.entryList(QDir::Files | QDir::NoDotAndDotDot,
|
||||
QDir::Name))
|
||||
QDir::Name))
|
||||
{
|
||||
FileElementCollectionItem *feci = new FileElementCollectionItem();
|
||||
appendRow(feci);
|
||||
|
||||
@@ -25,17 +25,17 @@
|
||||
@param size : the size of the handler
|
||||
*/
|
||||
QetGraphicsHandlerItem::QetGraphicsHandlerItem(qreal size) :
|
||||
m_size(size)
|
||||
m_size(size)
|
||||
{
|
||||
setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
||||
|
||||
|
||||
m_handler_rect.setRect(0-m_size/2, 0-m_size/2, m_size, m_size);
|
||||
m_br.setRect(-1-m_size/2, -1-m_size/2, m_size+2, m_size+2);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QetGraphicsHandlerItem::boundingRect
|
||||
@return
|
||||
@return
|
||||
*/
|
||||
QRectF QetGraphicsHandlerItem::boundingRect() const
|
||||
{
|
||||
|
||||
@@ -38,10 +38,10 @@ class QetGraphicsHandlerItem : public QGraphicsItem
|
||||
public:
|
||||
QetGraphicsHandlerItem(qreal size = 10);
|
||||
QRectF boundingRect() const override;
|
||||
|
||||
|
||||
enum { Type = UserType + 1200};
|
||||
int type() const override {return Type;}
|
||||
|
||||
|
||||
void setColor(QColor color);
|
||||
|
||||
protected:
|
||||
@@ -50,11 +50,12 @@ class QetGraphicsHandlerItem : public QGraphicsItem
|
||||
QWidget *widget) override;
|
||||
|
||||
private:
|
||||
QRectF m_handler_rect,m_br;
|
||||
QRectF m_handler_rect,
|
||||
m_br;
|
||||
qreal m_size;
|
||||
QColor m_color{Qt::black};
|
||||
QPen m_pen;
|
||||
|
||||
|
||||
public:
|
||||
static QVector<QetGraphicsHandlerItem *> handlerForPoint(
|
||||
const QVector<QPointF> &points, int size = 10);
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -25,12 +25,12 @@
|
||||
Initializes a BorderProperties object
|
||||
with the following default properties:
|
||||
- 17 columns of 60.0 px wide by 20.0px high
|
||||
- 8 lines of 80.0 px high by 20.0px wide
|
||||
- 8 lines of 80.0 px high by 20.0px wide
|
||||
|
||||
\~French Initialise un objet BorderProperties avec les proprietes par
|
||||
defaut suivantes :
|
||||
- 17 colonnes affichees de 60.0 px de large pour 20.0px de haut
|
||||
- 8 lignes affichees de 80.0 px de haut pour 20.0px de large
|
||||
- 8 lignes affichees de 80.0 px de haut pour 20.0px de large
|
||||
*/
|
||||
BorderProperties::BorderProperties()
|
||||
{
|
||||
@@ -78,10 +78,15 @@ bool BorderProperties::operator==(const BorderProperties &bp) {
|
||||
bool BorderProperties::operator!=(const BorderProperties &bp) {
|
||||
return(!(*this == bp));
|
||||
}
|
||||
|
||||
/**
|
||||
@brief BorderProperties::toXml
|
||||
@param dom_doc
|
||||
@return
|
||||
Exports dimensions as XML attributes added to element e.
|
||||
\~French Exporte les dimensions sous formes d'attributs XML ajoutes a l'element e.
|
||||
|
||||
\~ @param e :
|
||||
XML element to which attributes will be added
|
||||
\~French Element XML auquel seront ajoutes des attributs
|
||||
*/
|
||||
QDomElement BorderProperties::toXml(QDomDocument &dom_doc) const {
|
||||
|
||||
@@ -145,11 +150,11 @@ bool BorderProperties::valideXml(QDomElement& e) {
|
||||
*/
|
||||
void BorderProperties::toSettings(QSettings &settings, const QString &prefix) const
|
||||
{
|
||||
settings.setValue(prefix + "cols", columns_count);
|
||||
settings.setValue(prefix + "colsize", columns_width);
|
||||
settings.setValue(prefix + "cols", columns_count);
|
||||
settings.setValue(prefix + "colsize", columns_width);
|
||||
settings.setValue(prefix + "displaycols", display_columns);
|
||||
settings.setValue(prefix + "rows", rows_count);
|
||||
settings.setValue(prefix + "rowsize", rows_height);
|
||||
settings.setValue(prefix + "rows", rows_count);
|
||||
settings.setValue(prefix + "rowsize", rows_height);
|
||||
settings.setValue(prefix + "displayrows", display_rows);
|
||||
}
|
||||
|
||||
@@ -162,14 +167,14 @@ void BorderProperties::toSettings(QSettings &settings, const QString &prefix) co
|
||||
\~ @param prefix : prefix to be added before the names of the parameters
|
||||
\~French prefixe a ajouter devant les noms des parametres
|
||||
*/
|
||||
void BorderProperties::fromSettings(const QSettings &settings, const QString &prefix) {
|
||||
columns_count = settings.value(prefix + "cols", columns_count).toInt();
|
||||
void BorderProperties::fromSettings(QSettings &settings, const QString &prefix) {
|
||||
columns_count = settings.value(prefix + "cols", columns_count).toInt();
|
||||
columns_width = qRound(settings.value(prefix + "colsize", columns_width).toDouble());
|
||||
display_columns = settings.value(prefix + "displaycols", display_columns).toBool();
|
||||
|
||||
rows_count = settings.value(prefix + "rows", rows_count).toInt();
|
||||
rows_height = qRound(settings.value(prefix + "rowsize", rows_height).toDouble());
|
||||
display_rows = settings.value(prefix + "displayrows", display_rows).toBool();
|
||||
display_columns = settings.value(prefix + "displaycols", display_columns).toBool();
|
||||
|
||||
rows_count = settings.value(prefix + "rows", rows_count).toInt();
|
||||
rows_height = qRound(settings.value(prefix + "rowsize", rows_height).toDouble());
|
||||
display_rows = settings.value(prefix + "displayrows", display_rows).toBool();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+12
-12
@@ -37,23 +37,23 @@ class BorderProperties : public PropertiesInterface {
|
||||
bool operator==(const BorderProperties &);
|
||||
bool operator!=(const BorderProperties &);
|
||||
|
||||
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& e);
|
||||
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& e);
|
||||
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||
void fromSettings(const QSettings &, const QString & = QString()) override;
|
||||
void fromSettings(QSettings &, const QString & = QString()) override;
|
||||
|
||||
static BorderProperties defaultProperties();
|
||||
|
||||
// attributes
|
||||
int columns_count{17}; ///< Columns count
|
||||
qreal columns_width{60.0}; ///< Columns width
|
||||
qreal columns_header_height{20.0}; ///< Column headers height
|
||||
bool display_columns{true}; ///< Whether to display column headers
|
||||
int columns_count{17}; ///< Columns count
|
||||
qreal columns_width{60.0}; ///< Columns width
|
||||
qreal columns_header_height{20.0}; ///< Column headers height
|
||||
bool display_columns{true}; ///< Whether to display column headers
|
||||
|
||||
int rows_count{8}; ///< Rows count
|
||||
qreal rows_height{80.0}; ///< Rows height
|
||||
qreal rows_header_width{20.0}; ///< Row headers width
|
||||
bool display_rows{true}; ///< Whether to display row headers
|
||||
int rows_count{8}; ///< Rows count
|
||||
qreal rows_height{80.0}; ///< Rows height
|
||||
qreal rows_header_width{20.0}; ///< Row headers width
|
||||
bool display_rows{true}; ///< Whether to display row headers
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -86,14 +86,14 @@ QRectF BorderTitleBlock::titleBlockRect() const
|
||||
{
|
||||
if (m_edge == Qt::BottomEdge)
|
||||
return QRectF(diagram_rect_.bottomLeft(),
|
||||
QSize(diagram_rect_.width(),
|
||||
m_titleblock_template_renderer -> height()
|
||||
));
|
||||
QSize(diagram_rect_.width(),
|
||||
m_titleblock_template_renderer -> height()
|
||||
));
|
||||
else
|
||||
return QRectF(diagram_rect_.topRight(),
|
||||
QSize(m_titleblock_template_renderer -> height(),
|
||||
diagram_rect_.height()
|
||||
));
|
||||
QSize(m_titleblock_template_renderer -> height(),
|
||||
diagram_rect_.height()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,9 +124,9 @@ QRectF BorderTitleBlock::titleBlockRectForQPainter() const
|
||||
return titleBlockRect();
|
||||
else
|
||||
return QRectF (diagram_rect_.bottomRight(),
|
||||
QSize(diagram_rect_.height(),
|
||||
m_titleblock_template_renderer -> height()
|
||||
));
|
||||
QSize(diagram_rect_.height(),
|
||||
m_titleblock_template_renderer -> height()
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
@@ -150,9 +150,9 @@ QRectF BorderTitleBlock::columnsRect() const
|
||||
{
|
||||
if (!display_columns_) return QRectF();
|
||||
return QRectF (Diagram::margin,
|
||||
Diagram::margin,
|
||||
(columns_count_*columns_width_) + rows_header_width_,
|
||||
columns_header_height_);
|
||||
Diagram::margin,
|
||||
(columns_count_*columns_width_) + rows_header_width_,
|
||||
columns_header_height_);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,9 +164,9 @@ QRectF BorderTitleBlock::rowsRect() const
|
||||
{
|
||||
if (!display_rows_) return QRectF();
|
||||
return QRectF (Diagram::margin,
|
||||
Diagram::margin,
|
||||
rows_header_width_,
|
||||
(rows_count_*rows_height_) + columns_header_height_);
|
||||
Diagram::margin,
|
||||
rows_header_width_,
|
||||
(rows_count_*rows_height_) + columns_header_height_);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,9 +177,9 @@ QRectF BorderTitleBlock::rowsRect() const
|
||||
QRectF BorderTitleBlock::outsideBorderRect() const
|
||||
{
|
||||
return QRectF (Diagram::margin,
|
||||
Diagram::margin,
|
||||
(columns_width_*columns_count_) + rows_header_width_,
|
||||
(rows_height_*rows_count_) + columns_header_height_);
|
||||
Diagram::margin,
|
||||
(columns_width_*columns_count_) + rows_header_width_,
|
||||
(rows_height_*rows_count_) + columns_header_height_);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,7 +207,7 @@ QRectF BorderTitleBlock::insideBorderRect() const
|
||||
@param xml_elmt the XML element attributes will be added to
|
||||
*/
|
||||
void BorderTitleBlock::titleBlockToXml(QDomElement& doc) {
|
||||
exportTitleBlock().toXml(doc);
|
||||
exportTitleBlock().toXml(doc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,12 +227,12 @@ void BorderTitleBlock::titleBlockFromXml(const QDomElement &xml_elmt) {
|
||||
@param xml_elmt the XML element attributes will be added to
|
||||
*/
|
||||
void BorderTitleBlock::borderToXml(QDomElement &xml_elmt) {
|
||||
xml_elmt.setAttribute("cols", columnsCount());
|
||||
xml_elmt.setAttribute("colsize", QString("%1").arg(columnsWidth()));
|
||||
xml_elmt.setAttribute("cols", columnsCount());
|
||||
xml_elmt.setAttribute("colsize", QString("%1").arg(columnsWidth()));
|
||||
xml_elmt.setAttribute("displaycols", columnsAreDisplayed() ? "true" : "false");
|
||||
|
||||
xml_elmt.setAttribute("rows", rowsCount());
|
||||
xml_elmt.setAttribute("rowsize", QString("%1").arg(rowsHeight()));
|
||||
xml_elmt.setAttribute("rows", rowsCount());
|
||||
xml_elmt.setAttribute("rowsize", QString("%1").arg(rowsHeight()));
|
||||
xml_elmt.setAttribute("displayrows", rowsAreDisplayed() ? "true" : "false");
|
||||
|
||||
// attribut datant de la version 0.1 - laisse pour retrocompatibilite
|
||||
@@ -499,9 +499,9 @@ void BorderTitleBlock::updateRectangles()
|
||||
{
|
||||
QRectF previous_diagram = diagram_rect_;
|
||||
diagram_rect_ = QRectF(Diagram::margin,
|
||||
Diagram::margin,
|
||||
diagramWidth(),
|
||||
diagramHeight());
|
||||
Diagram::margin,
|
||||
diagramWidth(),
|
||||
diagramHeight());
|
||||
if (diagram_rect_ != previous_diagram)
|
||||
emit(borderChanged(previous_diagram, diagram_rect_));
|
||||
}
|
||||
@@ -553,14 +553,14 @@ void BorderTitleBlock::draw(QPainter *painter)
|
||||
painter -> drawRect(numbered_rectangle);
|
||||
if (settings.value("border-columns_0", true).toBool()){
|
||||
painter -> drawText(numbered_rectangle,
|
||||
Qt::AlignVCenter
|
||||
| Qt::AlignCenter,
|
||||
QString("%1").arg(i - 1));
|
||||
Qt::AlignVCenter
|
||||
| Qt::AlignCenter,
|
||||
QString("%1").arg(i - 1));
|
||||
}else{
|
||||
painter -> drawText(numbered_rectangle,
|
||||
Qt::AlignVCenter
|
||||
| Qt::AlignCenter,
|
||||
QString("%1").arg(i));
|
||||
Qt::AlignVCenter
|
||||
| Qt::AlignCenter,
|
||||
QString("%1").arg(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -581,9 +581,9 @@ void BorderTitleBlock::draw(QPainter *painter)
|
||||
);
|
||||
painter -> drawRect(lettered_rectangle);
|
||||
painter -> drawText(lettered_rectangle,
|
||||
Qt::AlignVCenter
|
||||
| Qt::AlignCenter,
|
||||
row_string);
|
||||
Qt::AlignVCenter
|
||||
| Qt::AlignCenter,
|
||||
row_string);
|
||||
row_string = incrementLetters(row_string);
|
||||
}
|
||||
}
|
||||
@@ -625,9 +625,9 @@ void BorderTitleBlock::drawDxf(
|
||||
{
|
||||
// Transform to DXF scale.
|
||||
columns_header_height_ *= Createdxf::yScale;
|
||||
rows_height_ *= Createdxf::yScale;
|
||||
rows_header_width_ *= Createdxf::xScale;
|
||||
columns_width_ *= Createdxf::xScale;
|
||||
rows_height_ *= Createdxf::yScale;
|
||||
rows_header_width_ *= Createdxf::xScale;
|
||||
columns_width_ *= Createdxf::xScale;
|
||||
|
||||
// draw the empty box that appears as soon as there is a header
|
||||
// dessine la case vide qui apparait des qu'il y a un entete
|
||||
@@ -656,11 +656,11 @@ void BorderTitleBlock::drawDxf(
|
||||
display_columns_) {
|
||||
int offset = settings.value("border-columns_0", true).toBool() ? -1 : 0;
|
||||
for (int i = 1 ; i <= columns_count_ ; ++ i) {
|
||||
double xCoord = diagram_rect_.topLeft().x() * Createdxf::xScale +
|
||||
double xCoord = diagram_rect_.topLeft().x() * Createdxf::xScale +
|
||||
(rows_header_width_ + ((i - 1) *
|
||||
columns_width_));
|
||||
double yCoord = Createdxf::sheetHeight
|
||||
- diagram_rect_.topLeft().y()*Createdxf::yScale
|
||||
- diagram_rect_.topLeft().y()*Createdxf::yScale
|
||||
- columns_header_height_;
|
||||
double recWidth = columns_width_;
|
||||
double recHeight = columns_header_height_;
|
||||
@@ -689,8 +689,8 @@ void BorderTitleBlock::drawDxf(
|
||||
for (int i = 1 ; i <= rows_count_ ; ++ i) {
|
||||
double xCoord = diagram_rect_.topLeft().x()
|
||||
* Createdxf::xScale;
|
||||
double yCoord = Createdxf::sheetHeight
|
||||
- diagram_rect_.topLeft().y()
|
||||
double yCoord = Createdxf::sheetHeight
|
||||
- diagram_rect_.topLeft().y()
|
||||
*Createdxf::yScale
|
||||
- (
|
||||
columns_header_height_
|
||||
@@ -722,17 +722,17 @@ void BorderTitleBlock::drawDxf(
|
||||
//qp -> translate(titleblock_rect_.topLeft());
|
||||
QRectF rect = titleBlockRect();
|
||||
m_titleblock_template_renderer -> renderDxf(rect,
|
||||
rect.width(),
|
||||
file_path,
|
||||
color);
|
||||
rect.width(),
|
||||
file_path,
|
||||
color);
|
||||
//qp -> translate(-titleblock_rect_.topLeft());
|
||||
}
|
||||
|
||||
// Transform back to QET scale
|
||||
columns_header_height_ /= Createdxf::yScale;
|
||||
rows_height_ /= Createdxf::yScale;
|
||||
rows_header_width_ /= Createdxf::xScale;
|
||||
columns_width_ /= Createdxf::xScale;
|
||||
rows_header_width_ /= Createdxf::xScale;
|
||||
columns_width_ /= Createdxf::xScale;
|
||||
|
||||
}
|
||||
|
||||
@@ -852,7 +852,7 @@ void BorderTitleBlock::setRowsHeaderWidth(const qreal &new_rhw) {
|
||||
\~ @param height :
|
||||
*/
|
||||
void BorderTitleBlock::setDiagramHeight(const qreal &height) {
|
||||
// size of rows to use = rows_height
|
||||
// size of rows to use = rows_height
|
||||
// taille des lignes a utiliser = rows_height
|
||||
setRowsCount(qRound(ceil(height / rows_height_)));
|
||||
}
|
||||
@@ -870,7 +870,7 @@ DiagramPosition BorderTitleBlock::convertPosition(const QPointF &pos)
|
||||
return (DiagramPosition("", 0));
|
||||
|
||||
QPointF relative_pos = pos - insideBorderRect().topLeft();
|
||||
int row_number = int(ceil(relative_pos.x() / columnsWidth()));
|
||||
int row_number = int(ceil(relative_pos.x() / columnsWidth()));
|
||||
int column_number = int(ceil(relative_pos.y() / rowsHeight()));
|
||||
|
||||
QString letter = "A";
|
||||
@@ -938,18 +938,18 @@ void BorderTitleBlock::updateDiagramContextForTitleBlock(
|
||||
// ... overridden by the historical and/or dynamically generated fields
|
||||
QLocale var;
|
||||
var.dateFormat(QLocale::ShortFormat);
|
||||
context.addValue("author", btb_author_);
|
||||
context.addValue("author", btb_author_);
|
||||
context.addValue(
|
||||
"date",
|
||||
QLocale::system().toString(btb_date_, QLocale::ShortFormat));
|
||||
context.addValue("title", btb_title_);
|
||||
context.addValue("filename", btb_filename_);
|
||||
context.addValue("plant", btb_plant_);
|
||||
context.addValue("locmach", btb_locmach_);
|
||||
context.addValue("indexrev", btb_indexrev_);
|
||||
context.addValue("version", btb_version_);
|
||||
context.addValue("folio", btb_final_folio_);
|
||||
context.addValue("folio-id", folio_index_);
|
||||
context.addValue("title", btb_title_);
|
||||
context.addValue("filename", btb_filename_);
|
||||
context.addValue("plant", btb_plant_);
|
||||
context.addValue("locmach", btb_locmach_);
|
||||
context.addValue("indexrev", btb_indexrev_);
|
||||
context.addValue("version", btb_version_);
|
||||
context.addValue("folio", btb_final_folio_);
|
||||
context.addValue("folio-id", folio_index_);
|
||||
context.addValue("folio-total", folio_total_);
|
||||
context.addValue("auto_page_num", btb_auto_page_num_);
|
||||
context.addValue("previous-folio-num", m_previous_folio_num);
|
||||
@@ -1020,7 +1020,7 @@ void BorderTitleBlock::setFolioData(
|
||||
btb_final_folio_.replace("%autonum", autonum);
|
||||
btb_folio_ = btb_final_folio_;
|
||||
}
|
||||
btb_final_folio_.replace("%id", QString::number(folio_index_));
|
||||
btb_final_folio_.replace("%id", QString::number(folio_index_));
|
||||
btb_final_folio_.replace("%total", QString::number(folio_total_));
|
||||
|
||||
updateDiagramContextForTitleBlock(project_properties);
|
||||
|
||||
+18
-18
@@ -173,7 +173,7 @@ class BorderTitleBlock : public QObject
|
||||
void setPreviousFolioNum(const QString &previous);
|
||||
void setNextFolioNum(const QString &next);
|
||||
|
||||
void titleBlockToXml(QDomElement &doc);
|
||||
void titleBlockToXml(QDomElement &doc);
|
||||
void titleBlockFromXml(const QDomElement &);
|
||||
void borderToXml(QDomElement &);
|
||||
void borderFromXml(const QDomElement &);
|
||||
@@ -248,34 +248,34 @@ class BorderTitleBlock : public QObject
|
||||
// attributes
|
||||
private:
|
||||
// titleblock basic data
|
||||
QString btb_author_; ///< titleblock author
|
||||
QDate btb_date_; ///< titleblock date
|
||||
QString btb_title_; ///< titleblock title
|
||||
QString btb_folio_; ///< titleblock folio
|
||||
QString btb_plant_; ///< titleblock plant
|
||||
QString btb_locmach_; ///< titleblock locmach
|
||||
QString btb_indexrev_; ///< titleblock index rev
|
||||
QString btb_author_; ///< titleblock author
|
||||
QDate btb_date_; ///< titleblock date
|
||||
QString btb_title_; ///< titleblock title
|
||||
QString btb_folio_; ///< titleblock folio
|
||||
QString btb_plant_; ///< titleblock plant
|
||||
QString btb_locmach_; ///< titleblock locmach
|
||||
QString btb_indexrev_; ///< titleblock index rev
|
||||
QString btb_final_folio_; ///< titleblock final folio
|
||||
QString btb_auto_page_num_; ///< titleblock auto page num
|
||||
int folio_index_; ///< titleblock index
|
||||
int folio_total_; ///< titleblock total
|
||||
QString btb_filename_; ///< titleblock filename
|
||||
QString btb_version_; ///< titleblock version
|
||||
int folio_index_; ///< titleblock index
|
||||
int folio_total_; ///< titleblock total
|
||||
QString btb_filename_; ///< titleblock filename
|
||||
QString btb_version_; ///< titleblock version
|
||||
/// titleblock additional fields
|
||||
DiagramContext additional_fields_;
|
||||
Qt::Edge m_edge; ///< titleblock edge
|
||||
QString m_next_folio_num; ///< titleblock next folio num
|
||||
Qt::Edge m_edge; ///< titleblock edge
|
||||
QString m_next_folio_num; ///< titleblock next folio num
|
||||
QString m_previous_folio_num; ///< titleblock previous folio num
|
||||
|
||||
// border dimensions (rows and columns)
|
||||
// columns: number and dimensions
|
||||
int columns_count_; ///< columns count
|
||||
qreal columns_width_; ///< columns width
|
||||
int columns_count_; ///< columns count
|
||||
qreal columns_width_; ///< columns width
|
||||
qreal columns_header_height_; ///< columns header height
|
||||
|
||||
// rows: number and dimensions
|
||||
int rows_count_; ///< rows count
|
||||
qreal rows_height_; ///< rows height
|
||||
int rows_count_; ///< rows count
|
||||
qreal rows_height_; ///< rows height
|
||||
qreal rows_header_width_; ///< rows header width
|
||||
|
||||
// title block dimensions
|
||||
|
||||
@@ -207,12 +207,12 @@ void SingleLineProperties::drawPen(QPainter *painter,
|
||||
}
|
||||
|
||||
/**
|
||||
@brief SingleLineProperties::toXml
|
||||
@param doc
|
||||
@return
|
||||
Exporte les parametres du conducteur unifilaire sous formes d'attributs XML
|
||||
ajoutes a l'element e.
|
||||
@param e Element XML auquel seront ajoutes des attributs
|
||||
*/
|
||||
QDomElement SingleLineProperties::toXml(QDomDocument &doc) const
|
||||
{
|
||||
QDomElement SingleLineProperties::toXml(QDomDocument &doc) const {
|
||||
|
||||
QDomElement e = doc.createElement("SingleLine");
|
||||
e.appendChild(createXmlProperty(doc, "ground", hasGround));
|
||||
e.appendChild(createXmlProperty(doc, "neutral", hasNeutral));
|
||||
@@ -294,6 +294,7 @@ ConductorProperties::~ConductorProperties()
|
||||
*/
|
||||
QDomElement ConductorProperties::toXml(QDomDocument& doc) const
|
||||
{
|
||||
|
||||
QDomElement e = doc.createElement("defaultconductor");
|
||||
|
||||
e.appendChild(createXmlProperty(doc, "type", typeToString(type)));
|
||||
@@ -319,7 +320,9 @@ QDomElement ConductorProperties::toXml(QDomDocument& doc) const
|
||||
e.appendChild(createXmlProperty(doc, "onetextperfolio", m_one_text_per_folio));
|
||||
e.appendChild(createXmlProperty(doc, "onetextperfolio", verti_rotate_text));
|
||||
e.appendChild(createXmlProperty(doc, "horizrotatetext", horiz_rotate_text));
|
||||
|
||||
// TODO: implement
|
||||
//e.setAttribute("cable", m_cable);
|
||||
// e.setAttribute("bus", m_bus);
|
||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
e.appendChild(createXmlProperty(doc, "horizontal-alignment", me.valueToKey(m_horizontal_alignment)));
|
||||
e.appendChild(createXmlProperty(doc, "vertical-alignment", me.valueToKey(m_vertical_alignment)));
|
||||
@@ -339,41 +342,40 @@ QDomElement ConductorProperties::toXml(QDomDocument& doc) const
|
||||
*/
|
||||
bool ConductorProperties::fromXml(const QDomElement &e)
|
||||
{
|
||||
// get conductor color
|
||||
// get conductor color
|
||||
propertyColor(e, "color", &color);
|
||||
propertyBool(e, "bicolor", &m_bicolor);
|
||||
propertyColor(e, "color2", &m_color_2);
|
||||
propertyInteger(e, "dash-size", &m_dash_size);
|
||||
|
||||
// read style of conductor
|
||||
// read style of conductor
|
||||
QString style_string;
|
||||
propertyString(e, "style", &style_string);
|
||||
readStyle(style_string);
|
||||
|
||||
QString type_t;
|
||||
if (propertyString(e, "type", &type_t) == PropertyFlags::Success)
|
||||
{
|
||||
if (propertyString(e, "type", &type_t) == PropertyFlags::Success) {
|
||||
if (type_t == typeToString(Single))
|
||||
{
|
||||
{
|
||||
// get specific properties for single conductor
|
||||
singleLineProperties.fromXml(e);
|
||||
type = Single;
|
||||
}
|
||||
singleLineProperties.fromXml(e);
|
||||
type = Single;
|
||||
}
|
||||
else if (type_t == typeToString(Multi))
|
||||
type = Multi;
|
||||
type = Multi;
|
||||
else {
|
||||
//Keep retrocompatible with version older than 0,4
|
||||
//If the propertie @type is simple (removed since QET 0,4), we set text no visible.
|
||||
//@TODO remove this code for qet 0.6 or later
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove this code for qet 0.6 or later")
|
||||
#endif
|
||||
|
||||
if (type_t == "simple") m_show_text = false;
|
||||
}
|
||||
}
|
||||
|
||||
propertyString(e, "num", &text);
|
||||
|
||||
// TODO: implement:
|
||||
//m_cable = e.attribute("cable");
|
||||
//m_bus = e.attribute("bus");
|
||||
// get text color
|
||||
propertyColor(e, "text_color", &text_color);
|
||||
propertyString(e, "formula", &m_formula);
|
||||
@@ -399,13 +401,7 @@ bool ConductorProperties::fromXml(const QDomElement &e)
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ConductorProperties::valideXml
|
||||
@param e
|
||||
@return
|
||||
*/
|
||||
bool ConductorProperties::valideXml(QDomElement& e)
|
||||
{
|
||||
bool ConductorProperties::valideXml(QDomElement& e) {
|
||||
if (propertyColor(e, "color") ||
|
||||
propertyBool(e, "bicolor") ||
|
||||
propertyColor(e, "color2") ||
|
||||
@@ -445,8 +441,8 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix)
|
||||
settings.setValue(prefix + "text", text);
|
||||
settings.setValue(prefix + "text_color", text_color.name());
|
||||
settings.setValue(prefix + "formula", m_formula);
|
||||
//settings.setValue(prefix + "cable", m_cable);
|
||||
//settings.setValue(prefix + "bus", m_bus);
|
||||
settings.setValue(prefix + "cable", m_cable);
|
||||
settings.setValue(prefix + "bus", m_bus);
|
||||
settings.setValue(prefix + "function", m_function);
|
||||
settings.setValue(prefix + "tension_protocol", m_tension_protocol);
|
||||
settings.setValue(prefix + "conductor_color", m_wire_color);
|
||||
@@ -469,7 +465,7 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix)
|
||||
@param settings Parametres a lire
|
||||
@param prefix prefixe a ajouter devant les noms des parametres
|
||||
*/
|
||||
void ConductorProperties::fromSettings(const QSettings &settings, const QString &prefix)
|
||||
void ConductorProperties::fromSettings(QSettings &settings, const QString &prefix)
|
||||
{
|
||||
QColor settings_color = QColor(settings.value(prefix + "color").toString());
|
||||
color = (settings_color.isValid()? settings_color : QColor(Qt::black));
|
||||
@@ -485,22 +481,22 @@ void ConductorProperties::fromSettings(const QSettings &settings, const QString
|
||||
|
||||
singleLineProperties.fromSettings(settings, prefix);
|
||||
|
||||
text = settings.value(prefix + "text", "_").toString();
|
||||
text = settings.value(prefix + "text", "_").toString();
|
||||
QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString());
|
||||
text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black));
|
||||
m_formula = settings.value(prefix + "formula", "").toString();
|
||||
//m_cable = settings.value(prefix + "cable", "").toString();
|
||||
//m_bus = settings.value(prefix + "bus", "").toString();
|
||||
m_function = settings.value(prefix + "function", "").toString();
|
||||
m_formula = settings.value(prefix + "formula", "").toString();
|
||||
m_cable = settings.value(prefix + "cable", "").toString();
|
||||
m_bus = settings.value(prefix + "bus", "").toString();
|
||||
m_function = settings.value(prefix + "function", "").toString();
|
||||
m_tension_protocol = settings.value(prefix + "tension_protocol", "").toString();
|
||||
m_wire_color = settings.value(prefix + "conductor_color", "").toString();
|
||||
m_wire_section = settings.value(prefix + "conductor_section", "").toString();
|
||||
text_size = settings.value(prefix + "textsize", "7").toInt();
|
||||
cond_size = settings.value(prefix + "size", "1").toInt();
|
||||
m_show_text = settings.value(prefix + "displaytext", true).toBool();
|
||||
m_wire_color = settings.value(prefix + "conductor_color", "").toString();
|
||||
m_wire_section = settings.value(prefix + "conductor_section", "").toString();
|
||||
text_size = settings.value(prefix + "textsize", "7").toInt();
|
||||
cond_size = settings.value(prefix + "size", "1").toInt();
|
||||
m_show_text = settings.value(prefix + "displaytext", true).toBool();
|
||||
m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
|
||||
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
||||
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
||||
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
||||
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
||||
|
||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "horizontal-alignment", "AlignBottom").toString().toStdString().data()));
|
||||
@@ -538,25 +534,25 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
|
||||
if (clist.size() == 1)
|
||||
{
|
||||
ConductorProperties cp = clist.first();
|
||||
color = cp.color;
|
||||
m_bicolor = cp.m_bicolor;
|
||||
m_color_2 = cp.m_color_2;
|
||||
m_dash_size = cp.m_dash_size;
|
||||
text = cp.text;
|
||||
text_color = cp.text_color;
|
||||
m_formula = cp.m_formula;
|
||||
//m_cable = cp.m_cable;
|
||||
//m_bus = cp.m_bus;
|
||||
m_function = cp.m_function;
|
||||
color = cp.color;
|
||||
m_bicolor = cp.m_bicolor;
|
||||
m_color_2 = cp.m_color_2;
|
||||
m_dash_size = cp.m_dash_size;
|
||||
text = cp.text;
|
||||
text_color = cp.text_color;
|
||||
m_formula = cp.m_formula;
|
||||
m_cable = cp.m_cable;
|
||||
m_bus = cp.m_bus;
|
||||
m_function = cp.m_function;
|
||||
m_tension_protocol = cp.m_tension_protocol;
|
||||
m_wire_color = cp.m_wire_color;
|
||||
m_wire_section = cp.m_wire_section;
|
||||
text_size = cp.text_size;
|
||||
cond_size = cp.cond_size;
|
||||
m_show_text = cp.m_show_text;
|
||||
m_wire_color = cp.m_wire_color;
|
||||
m_wire_section = cp.m_wire_section;
|
||||
text_size = cp.text_size;
|
||||
cond_size = cp.cond_size;
|
||||
m_show_text = cp.m_show_text;
|
||||
m_one_text_per_folio = cp.m_one_text_per_folio;
|
||||
verti_rotate_text = cp.verti_rotate_text;
|
||||
horiz_rotate_text = cp.horiz_rotate_text;
|
||||
verti_rotate_text = cp.verti_rotate_text;
|
||||
horiz_rotate_text = cp.horiz_rotate_text;
|
||||
m_vertical_alignment = cp.m_vertical_alignment;
|
||||
m_horizontal_alignment = cp.m_horizontal_alignment;
|
||||
|
||||
@@ -648,27 +644,27 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
|
||||
m_formula = s_value;
|
||||
equal = true;
|
||||
|
||||
// //cable
|
||||
// s_value = clist.first().m_cable;
|
||||
// for(ConductorProperties cp : clist)
|
||||
// {
|
||||
// if (cp.m_cable != s_value)
|
||||
// equal = false;
|
||||
// }
|
||||
// if (equal)
|
||||
// m_cable = s_value;
|
||||
// equal = true;
|
||||
//cable
|
||||
s_value = clist.first().m_cable;
|
||||
for(ConductorProperties cp : clist)
|
||||
{
|
||||
if (cp.m_cable != s_value)
|
||||
equal = false;
|
||||
}
|
||||
if (equal)
|
||||
m_cable = s_value;
|
||||
equal = true;
|
||||
|
||||
// //bus
|
||||
// s_value = clist.first().m_bus;
|
||||
// for(ConductorProperties cp : clist)
|
||||
// {
|
||||
// if (cp.m_bus != s_value)
|
||||
// equal = false;
|
||||
// }
|
||||
// if (equal)
|
||||
// m_bus = s_value;
|
||||
// equal = true;
|
||||
//bus
|
||||
s_value = clist.first().m_bus;
|
||||
for(ConductorProperties cp : clist)
|
||||
{
|
||||
if (cp.m_bus != s_value)
|
||||
equal = false;
|
||||
}
|
||||
if (equal)
|
||||
m_bus = s_value;
|
||||
equal = true;
|
||||
|
||||
//function
|
||||
s_value = clist.first().m_function;
|
||||
@@ -835,9 +831,8 @@ bool ConductorProperties::operator==(const ConductorProperties &other) const
|
||||
other.text == text &&\
|
||||
other.text_color == text_color &&\
|
||||
other.m_formula == m_formula &&\
|
||||
/* other.m_cable == m_cable &&\
|
||||
other.m_cable == m_cable &&\
|
||||
other.m_bus == m_bus &&\
|
||||
*/
|
||||
other.m_function == m_function &&\
|
||||
other.m_tension_protocol == m_tension_protocol &&\
|
||||
other.m_wire_color == m_wire_color && \
|
||||
@@ -959,19 +954,18 @@ void SingleLineProperties::toSettings(QSettings &settings,
|
||||
{
|
||||
settings.setValue(prefix + "hasGround", hasGround);
|
||||
settings.setValue(prefix + "hasNeutral", hasNeutral);
|
||||
settings.setValue(prefix + "phases", phases);
|
||||
settings.setValue(prefix + "pen", is_pen);
|
||||
settings.setValue(prefix + "phases", phases);
|
||||
settings.setValue(prefix + "pen", is_pen);
|
||||
}
|
||||
|
||||
/**
|
||||
@param settings Parametres a lire
|
||||
@param prefix prefix a ajouter devant les noms des parametres
|
||||
*/
|
||||
void SingleLineProperties::fromSettings(
|
||||
const QSettings &settings, const QString &prefix)
|
||||
{
|
||||
void SingleLineProperties::fromSettings(QSettings &settings,
|
||||
const QString &prefix) {
|
||||
hasGround = settings.value(prefix + "hasGround", true).toBool();
|
||||
hasNeutral = settings.value(prefix + "hasNeutral", true).toBool();
|
||||
phases = settings.value(prefix + "phases", 1).toInt();
|
||||
is_pen = settings.value(prefix + "pen", false).toBool();
|
||||
phases = settings.value(prefix + "phases", 1).toInt();
|
||||
is_pen = settings.value(prefix + "pen", false).toBool();
|
||||
}
|
||||
|
||||
@@ -42,15 +42,14 @@ class SingleLineProperties: public PropertiesInterface {
|
||||
QDomElement toXml(QDomDocument& doc) const override;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||
void fromSettings(const QSettings &, const QString & = QString()) override;
|
||||
void toSettings(QSettings &, const QString & = QString()) const;
|
||||
void fromSettings(QSettings &, const QString & = QString());
|
||||
|
||||
/// Whether the singleline conductor should display the ground symbol
|
||||
bool hasGround{true};
|
||||
/// Whether the singleline conductor should display the neutral symbol
|
||||
bool hasNeutral{true};
|
||||
/// Protective Earth Neutral: visually merge neutral and ground
|
||||
|
||||
bool is_pen{false};
|
||||
|
||||
int operator==(const SingleLineProperties &) const;
|
||||
@@ -82,7 +81,8 @@ class ConductorProperties: public PropertiesInterface
|
||||
*/
|
||||
enum ConductorType { Single, Multi };
|
||||
|
||||
//Attributes
|
||||
|
||||
//Attributes
|
||||
ConductorType type{ConductorType::Single};
|
||||
|
||||
// TODO: set default values!
|
||||
@@ -90,37 +90,42 @@ class ConductorProperties: public PropertiesInterface
|
||||
m_color_2{QColor(Qt::black)},
|
||||
text_color{QColor(Qt::black)};
|
||||
|
||||
QString text,
|
||||
m_function,
|
||||
m_tension_protocol,
|
||||
m_wire_color,
|
||||
m_wire_section,
|
||||
m_formula;
|
||||
QString
|
||||
text,
|
||||
m_function,
|
||||
m_tension_protocol,
|
||||
m_wire_color,
|
||||
m_wire_section,
|
||||
m_formula,
|
||||
m_bus,
|
||||
m_cable;
|
||||
|
||||
int text_size{9},
|
||||
m_dash_size = 1;
|
||||
int text_size{9},
|
||||
m_dash_size = 1;
|
||||
|
||||
double cond_size{1},
|
||||
verti_rotate_text,
|
||||
horiz_rotate_text;
|
||||
double
|
||||
cond_size{1},
|
||||
verti_rotate_text,
|
||||
horiz_rotate_text;
|
||||
|
||||
bool m_show_text{true},
|
||||
m_one_text_per_folio{true},
|
||||
m_bicolor = false;
|
||||
m_one_text_per_folio{true},
|
||||
m_bicolor = false;
|
||||
|
||||
Qt::Alignment m_horizontal_alignment = Qt::AlignBottom,
|
||||
m_vertical_alignment = Qt::AlignRight;
|
||||
Qt::Alignment
|
||||
m_horizontal_alignment = Qt::AlignBottom,
|
||||
m_vertical_alignment = Qt::AlignRight;
|
||||
|
||||
Qt::PenStyle style{Qt::PenStyle::SolidLine};
|
||||
|
||||
SingleLineProperties singleLineProperties;
|
||||
|
||||
// methods
|
||||
// methods
|
||||
QDomElement toXml(QDomDocument &doc) const override;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||
void fromSettings(const QSettings &, const QString & = QString()) override;
|
||||
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||
void fromSettings(QSettings &, const QString & = QString()) override;
|
||||
static QString typeToString(ConductorType);
|
||||
void applyForEqualAttributes(QList<ConductorProperties> list);
|
||||
|
||||
|
||||
+96
-92
@@ -62,11 +62,11 @@ QColor Diagram::background_color = Qt::white;
|
||||
@param project : The project of this diagram and also parent QObject
|
||||
*/
|
||||
Diagram::Diagram(QETProject *project) :
|
||||
QGraphicsScene (project),
|
||||
m_project (project),
|
||||
draw_grid_ (true),
|
||||
use_border_ (true),
|
||||
draw_terminals_ (true),
|
||||
QGraphicsScene (project),
|
||||
m_project (project),
|
||||
draw_grid_ (true),
|
||||
use_border_ (true),
|
||||
draw_terminals_ (true),
|
||||
draw_colored_conductors_ (true),
|
||||
m_event_interface (nullptr),
|
||||
m_freeze_new_elements (false),
|
||||
@@ -734,20 +734,19 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
||||
|
||||
// schema properties
|
||||
// proprietes du schema
|
||||
if (whole_content)
|
||||
{
|
||||
if (whole_content) {
|
||||
// TODO: compare with old version
|
||||
border_and_titleblock.titleBlockToXml(dom_root);
|
||||
border_and_titleblock.borderToXml(dom_root);
|
||||
|
||||
// Default conductor properties
|
||||
dom_root.appendChild(defaultConductorProperties.toXml(document));
|
||||
document.createElement("defaultconductor");
|
||||
|
||||
// Conductor autonum
|
||||
if (!m_conductors_autonum_name.isEmpty())
|
||||
{
|
||||
dom_root.setAttribute(
|
||||
"conductorAutonum",m_conductors_autonum_name);
|
||||
if (!m_conductors_autonum_name.isEmpty()) {
|
||||
dom_root.setAttribute("conductorAutonum",
|
||||
m_conductors_autonum_name);
|
||||
}
|
||||
|
||||
//Default New Element
|
||||
@@ -914,12 +913,12 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
||||
}
|
||||
}
|
||||
|
||||
// table de correspondance entre les adresses des bornes et leurs ids
|
||||
// correspondence table between the addresses of the terminals and their ids
|
||||
// table de correspondance entre les adresses des bornes et leurs ids
|
||||
|
||||
if (!list_elements.isEmpty()) {
|
||||
auto dom_elements = document.createElement("elements");
|
||||
for (auto elmt : list_elements)
|
||||
{
|
||||
for (auto elmt : list_elements) {
|
||||
dom_elements.appendChild(elmt->toXml(document));
|
||||
}
|
||||
dom_root.appendChild(dom_elements);
|
||||
@@ -927,8 +926,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
||||
|
||||
if (!list_conductors.isEmpty()) {
|
||||
auto dom_conductors = document.createElement("conductors");
|
||||
for (auto cond : list_conductors)
|
||||
{
|
||||
for (auto cond : list_conductors) {
|
||||
dom_conductors.appendChild(cond->toXml(document));
|
||||
}
|
||||
dom_root.appendChild(dom_conductors);
|
||||
@@ -989,7 +987,7 @@ void Diagram::folioSequentialsToXml(QHash<QString,
|
||||
QDomElement folioseq = doc->createElement(type);
|
||||
folioseq.setAttribute("title", i.key());
|
||||
for (int j = 0; j < i.value().size(); j++) {
|
||||
folioseq.setAttribute(seq_type + QString::number(j+1),
|
||||
folioseq.setAttribute(seq_type + QString::number(j+1),
|
||||
i.value().at(j));
|
||||
}
|
||||
domElement->appendChild(folioseq);
|
||||
@@ -1084,28 +1082,25 @@ bool Diagram::initFromXml(QDomElement &document,
|
||||
|
||||
/**
|
||||
@brief findTerminal
|
||||
@param conductor_index
|
||||
@param conductor
|
||||
@param table_adr_id
|
||||
@param added_elements
|
||||
Find terminal to which the conductor should be connected
|
||||
@param conductor_index 1 or 2 depending on which terminal is searched
|
||||
@param f Conductor xml element
|
||||
@param table_adr_id Hash table to all terminal id assignement (legacy)
|
||||
@param added_elements Elements found in the xml file
|
||||
@return
|
||||
*/
|
||||
Terminal* findTerminal(
|
||||
int conductor_index,
|
||||
QDomElement& conductor,
|
||||
QHash<int, Terminal *>& table_adr_id,
|
||||
QList<Element *>& added_elements)
|
||||
{
|
||||
Terminal* findTerminal(int conductor_index,
|
||||
QDomElement& conductor,
|
||||
QHash<int,
|
||||
Terminal *>& table_adr_id,
|
||||
QList<Element *>& added_elements) {
|
||||
assert(conductor_index == 1 || conductor_index == 2);
|
||||
|
||||
QString element_index = "element" + QString::number(conductor_index);
|
||||
QString terminal_index = "terminal" + QString::number(conductor_index);
|
||||
|
||||
QUuid element_uuid;
|
||||
if (PropertiesInterface::propertyUuid(
|
||||
conductor, element_index, &element_uuid)
|
||||
== PropertiesInterface::PropertyFlags::Success)
|
||||
{
|
||||
if (PropertiesInterface::propertyUuid(conductor, element_index, &element_uuid) == PropertiesInterface::PropertyFlags::Success) {
|
||||
// element1 did not exist in the conductor part of the xml until prior 0.7
|
||||
// It is used as an indicator that uuid's are used to identify terminals
|
||||
bool element_found = false;
|
||||
@@ -1114,8 +1109,7 @@ Terminal* findTerminal(
|
||||
continue;
|
||||
element_found = true;
|
||||
QUuid terminal_uuid;
|
||||
PropertiesInterface::propertyUuid(
|
||||
conductor, terminal_index, &terminal_uuid);
|
||||
PropertiesInterface::propertyUuid(conductor, terminal_index, &terminal_uuid);
|
||||
for (auto terminal: element->terminals()) {
|
||||
if (terminal->uuid() != terminal_uuid)
|
||||
continue;
|
||||
@@ -1140,12 +1134,8 @@ Terminal* findTerminal(
|
||||
<< "not found";
|
||||
} else {
|
||||
// Backward compatibility. Until version 0.7 a generated id is used to link the terminal.
|
||||
int id_p1 = -1;
|
||||
if (
|
||||
PropertiesInterface::propertyInteger(
|
||||
conductor, terminal_index, &id_p1)
|
||||
!= PropertiesInterface::PropertyFlags::Success)
|
||||
{
|
||||
int id_p1 = -1;
|
||||
if (PropertiesInterface::propertyInteger(conductor, terminal_index, &id_p1) != PropertiesInterface::PropertyFlags::Success) {
|
||||
qDebug() << "diagramm.cpp:findTerminal(): Reading Id was not successfull";
|
||||
}
|
||||
if (!table_adr_id.contains(id_p1)) {
|
||||
@@ -1161,33 +1151,48 @@ Terminal* findTerminal(
|
||||
|
||||
/**
|
||||
@brief Diagram::fromXml
|
||||
@param document
|
||||
@param position
|
||||
@param consider_informations
|
||||
@param content_ptr
|
||||
@return
|
||||
Imports the described schema in an XML element. If a position is
|
||||
specified, the imported elements are positioned in such a way that the
|
||||
upper left corner of the smallest rectangle that can surround them all
|
||||
(the bounding rect) either at this position.
|
||||
\~French Importe le schema decrit dans un element XML.
|
||||
Si une position est precisee,
|
||||
les elements importes sont positionnes de maniere a ce que le
|
||||
coin superieur gauche du plus petit rectangle pouvant les entourant tous
|
||||
(le bounding rect) soit a cette position.
|
||||
\~ @param document :
|
||||
The XML document to analyze
|
||||
\~French Le document XML a analyser
|
||||
\~ @param position :
|
||||
The position of the diagram matters
|
||||
\~French La position du schema importe
|
||||
\~ @param consider_informations :
|
||||
If true, additional information
|
||||
(author, title, ...) will be taken into account
|
||||
\~French Si vrai, les informations complementaires
|
||||
(auteur, titre, ...) seront prises en compte
|
||||
\~ @param content_ptr :
|
||||
if this pointer to a DiagramContent is different from 0,
|
||||
it will be filled with the content added to the schema by the fromXml
|
||||
\~French si ce pointeur vers un DiagramContent est different de 0,
|
||||
il sera rempli avec le contenu ajoute au schema par le fromXml
|
||||
\~ @return
|
||||
true if the import was successful, false otherwise
|
||||
\~French true si l'import a reussi, false sinon
|
||||
*/
|
||||
bool Diagram::fromXml(
|
||||
QDomElement &document,
|
||||
QPointF position,
|
||||
bool consider_informations,
|
||||
DiagramContent *content_ptr)
|
||||
{
|
||||
bool Diagram::fromXml(QDomElement &document,
|
||||
QPointF position,
|
||||
bool consider_informations,
|
||||
DiagramContent *content_ptr) {
|
||||
const QDomElement& root = document;
|
||||
// The first element must be a diagram
|
||||
if (root.tagName() != "diagram") return(false);
|
||||
|
||||
qDebug() << "Diagram::fromXml; Diagram: " << root.attribute("title");
|
||||
|
||||
// Read attributes of this diagram
|
||||
if (consider_informations) {
|
||||
// Version of diagram
|
||||
bool conv_ok;
|
||||
qreal version_value = root.attribute("version").toDouble(&conv_ok);
|
||||
if (conv_ok) {
|
||||
diagram_qet_version_ = version_value;
|
||||
}
|
||||
|
||||
|
||||
// Read attributes of this diagram
|
||||
if (consider_informations)
|
||||
{
|
||||
// Load border and titleblock
|
||||
border_and_titleblock.titleBlockFromXml(root);
|
||||
border_and_titleblock.borderFromXml(root);
|
||||
@@ -1282,11 +1287,11 @@ bool Diagram::fromXml(
|
||||
}
|
||||
}
|
||||
}
|
||||
//Load all elements from the collection in the XML
|
||||
//Load all elements from the XML
|
||||
QList<Element *> added_elements;
|
||||
QHash<int, Terminal *> table_adr_id;
|
||||
foreach (QDomElement element_xml,
|
||||
QET::findInDomElement(root, "elements", "element")) // read all elements from the diagram
|
||||
QET::findInDomElement(root, "elements", "element"))
|
||||
{
|
||||
if (!Element::valideXml(element_xml)) continue;
|
||||
|
||||
@@ -1301,9 +1306,9 @@ bool Diagram::fromXml(
|
||||
}
|
||||
|
||||
int state = 0;
|
||||
|
||||
// Create element from the collection
|
||||
Element *nvel_elmt = ElementFactory::Instance() -> createElement(element_location, nullptr, &state); // read element definition from the collection!
|
||||
Element *nvel_elmt =
|
||||
ElementFactory::Instance() -> createElement(
|
||||
element_location, nullptr, &state);
|
||||
if (state)
|
||||
{
|
||||
QString debug_message =
|
||||
@@ -1317,9 +1322,8 @@ bool Diagram::fromXml(
|
||||
}
|
||||
|
||||
addItem(nvel_elmt);
|
||||
|
||||
//Loading fail, remove item from the diagram
|
||||
if (!nvel_elmt->fromXml(element_xml, table_adr_id)) // load element definition from the diagram
|
||||
//Loading fail, remove item from the diagram
|
||||
if (!nvel_elmt->fromXml(element_xml, table_adr_id))
|
||||
{
|
||||
removeItem(nvel_elmt);
|
||||
delete nvel_elmt;
|
||||
@@ -1365,24 +1369,24 @@ bool Diagram::fromXml(
|
||||
|
||||
// Load conductor
|
||||
QList<Conductor *> added_conductors;
|
||||
|
||||
foreach (QDomElement conductorElement,
|
||||
QET::findInDomElement(root, "conductors", "conductor"))
|
||||
foreach (QDomElement f, QET::findInDomElement(root,
|
||||
"conductors",
|
||||
"conductor"))
|
||||
{
|
||||
if (!Conductor::valideXml(conductorElement)) continue;
|
||||
if (!Conductor::valideXml(f)) continue;
|
||||
|
||||
//Check if terminal that conductor must be linked is know
|
||||
|
||||
Terminal* p1 = findTerminal(1, conductorElement, table_adr_id, added_elements);
|
||||
Terminal* p2 = findTerminal(2, conductorElement, table_adr_id, added_elements);
|
||||
Terminal* p1 = findTerminal(1, f, table_adr_id, added_elements);
|
||||
Terminal* p2 = findTerminal(2, f, table_adr_id, added_elements);
|
||||
|
||||
if (p1 && p2 && p1 != p2) // why the condition for unequal is required?
|
||||
if (p1 && p2 && p1 != p2)// TODO: why the condition for unequal is required?
|
||||
{
|
||||
Conductor *c = new Conductor(p1, p2);
|
||||
if (c->isValid())
|
||||
{
|
||||
addItem(c);
|
||||
c -> fromXml(conductorElement);
|
||||
c -> fromXml(f);
|
||||
added_conductors << c;
|
||||
}
|
||||
else
|
||||
@@ -1410,11 +1414,11 @@ bool Diagram::fromXml(
|
||||
{
|
||||
QVector <QGraphicsItem *> added_items;
|
||||
for (auto element : added_elements ) added_items << element;
|
||||
for (auto cond : added_conductors) added_items << cond;
|
||||
for (auto shape : added_shapes ) added_items << shape;
|
||||
for (auto text : added_texts ) added_items << text;
|
||||
for (auto image : added_images ) added_items << image;
|
||||
for (auto table : added_tables ) added_items << table;
|
||||
for (auto cond : added_conductors) added_items << cond;
|
||||
for (auto shape : added_shapes ) added_items << shape;
|
||||
for (auto text : added_texts ) added_items << text;
|
||||
for (auto image : added_images ) added_items << image;
|
||||
for (auto table : added_tables ) added_items << table;
|
||||
|
||||
//Get the top left corner of the rectangle that contain all added items
|
||||
QRectF items_rect;
|
||||
@@ -1436,12 +1440,12 @@ bool Diagram::fromXml(
|
||||
|
||||
//Filling of falculatory lists
|
||||
if (content_ptr) {
|
||||
content_ptr -> m_elements = added_elements;
|
||||
content_ptr -> m_elements = added_elements;
|
||||
content_ptr -> m_conductors_to_move = added_conductors;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||
content_ptr -> m_text_fields = added_texts.toSet();
|
||||
content_ptr -> m_images = added_images.toSet();
|
||||
content_ptr -> m_shapes = added_shapes.toSet();
|
||||
content_ptr -> m_text_fields = added_texts.toSet();
|
||||
content_ptr -> m_images = added_images.toSet();
|
||||
content_ptr -> m_shapes = added_shapes.toSet();
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 5.14 or later")
|
||||
@@ -1456,7 +1460,7 @@ bool Diagram::fromXml(
|
||||
added_shapes.begin(),
|
||||
added_shapes.end());
|
||||
#endif
|
||||
content_ptr -> m_tables = added_tables;
|
||||
content_ptr -> m_tables = added_tables;
|
||||
}
|
||||
|
||||
adjustSceneRect();
|
||||
@@ -1528,7 +1532,7 @@ void Diagram::refreshContents()
|
||||
|
||||
/**
|
||||
@brief Diagram::addItem
|
||||
Réimplemented from QGraphicsScene::addItem(QGraphicsItem *item)
|
||||
R??implemented from QGraphicsScene::addItem(QGraphicsItem *item)
|
||||
Do some specific operation if item need it (for exemple an element)
|
||||
@param item
|
||||
*/
|
||||
@@ -2186,20 +2190,20 @@ ExportProperties Diagram::applyProperties(
|
||||
// exports current rendering options
|
||||
// exporte les options de rendu en cours
|
||||
ExportProperties old_properties;
|
||||
old_properties.draw_grid = displayGrid();
|
||||
old_properties.draw_grid = displayGrid();
|
||||
old_properties.draw_border = border_and_titleblock.borderIsDisplayed();
|
||||
old_properties.draw_titleblock = border_and_titleblock.titleBlockIsDisplayed();
|
||||
old_properties.draw_terminals = drawTerminals();
|
||||
old_properties.draw_terminals = drawTerminals();
|
||||
old_properties.draw_colored_conductors = drawColoredConductors();
|
||||
old_properties.exported_area = useBorder() ? QET::BorderArea
|
||||
: QET::ElementsArea;
|
||||
|
||||
// apply the new rendering options
|
||||
// applique les nouvelles options de rendu
|
||||
setUseBorder (new_properties.exported_area == QET::BorderArea);
|
||||
setDrawTerminals (new_properties.draw_terminals);
|
||||
setUseBorder (new_properties.exported_area == QET::BorderArea);
|
||||
setDrawTerminals (new_properties.draw_terminals);
|
||||
setDrawColoredConductors (new_properties.draw_colored_conductors);
|
||||
setDisplayGrid (new_properties.draw_grid);
|
||||
setDisplayGrid (new_properties.draw_grid);
|
||||
border_and_titleblock.displayBorder(new_properties.draw_border);
|
||||
border_and_titleblock.displayTitleBlock (new_properties.draw_titleblock);
|
||||
|
||||
|
||||
+56
-43
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -58,13 +58,13 @@ class Diagram : public QGraphicsScene
|
||||
friend QETProject;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
// constructors, destructor
|
||||
private:
|
||||
Diagram(QETProject *project);
|
||||
~Diagram() override;
|
||||
Diagram(const Diagram &diagram);
|
||||
|
||||
|
||||
// ATTRIBUTES
|
||||
public:
|
||||
/**
|
||||
@@ -108,10 +108,10 @@ class Diagram : public QGraphicsScene
|
||||
|
||||
private:
|
||||
QGraphicsLineItem *conductor_setter_;
|
||||
ElementsMover m_elements_mover;
|
||||
ElementsMover m_elements_mover;
|
||||
ElementTextsMover m_element_texts_mover;
|
||||
QGIManager *qgi_manager_;
|
||||
QETProject *m_project;
|
||||
QGIManager *qgi_manager_;
|
||||
QETProject *m_project;
|
||||
|
||||
QDomDocument xml_document_;
|
||||
|
||||
@@ -128,7 +128,7 @@ class Diagram : public QGraphicsScene
|
||||
bool m_freeze_new_elements;
|
||||
bool m_freeze_new_conductors_;
|
||||
QUuid m_uuid = QUuid::createUuid();
|
||||
|
||||
|
||||
// METHODS
|
||||
protected:
|
||||
void drawBackground(QPainter *, const QRectF &) override;
|
||||
@@ -142,7 +142,7 @@ class Diagram : public QGraphicsScene
|
||||
void wheelEvent (QGraphicsSceneWheelEvent *event) override;
|
||||
void keyPressEvent (QKeyEvent *event) override;
|
||||
void keyReleaseEvent (QKeyEvent *) override;
|
||||
|
||||
|
||||
public:
|
||||
QUuid uuid();
|
||||
void setEventInterface (DiagramEventInterface *event_interface);
|
||||
@@ -153,42 +153,53 @@ class Diagram : public QGraphicsScene
|
||||
void setConductorsAutonumName(const QString &name);
|
||||
|
||||
static bool clipboardMayContainDiagram();
|
||||
|
||||
|
||||
// methods related to parent project
|
||||
QETProject *project() const;
|
||||
int folioIndex() const;
|
||||
void showMe() {emit showDiagram(this);}
|
||||
bool isReadOnly() const;
|
||||
|
||||
int folioIndex() const;
|
||||
void showMe() {emit showDiagram(this);}
|
||||
bool isReadOnly() const;
|
||||
|
||||
// methods related to conductor creation
|
||||
void setConductor(bool);
|
||||
void setConductorStart (QPointF);
|
||||
void setConductorStop(QPointF);
|
||||
QList < QSet <Conductor *> > potentials();
|
||||
|
||||
|
||||
// methods related to XML import/export
|
||||
QDomDocument toXml(bool = true);
|
||||
bool initFromXml(QDomElement &, QPointF = QPointF(),
|
||||
bool = true, DiagramContent * = nullptr);
|
||||
bool fromXml(
|
||||
QDomDocument &, QPointF = QPointF(),
|
||||
bool = true, DiagramContent * = nullptr);
|
||||
bool fromXml(
|
||||
QDomElement &, QPointF = QPointF(),
|
||||
bool = true, DiagramContent * = nullptr);
|
||||
void folioSequentialsToXml(
|
||||
QHash<QString, QStringList>*, QDomElement *, const QString&,
|
||||
const QString&, QDomDocument *);
|
||||
void folioSequentialsFromXml(
|
||||
const QDomElement&, QHash<QString,QStringList>*, const QString&,
|
||||
const QString&, const QString&,const QString&);
|
||||
|
||||
bool initFromXml(QDomElement &,
|
||||
QPointF = QPointF(),
|
||||
bool = true,
|
||||
DiagramContent * = nullptr);
|
||||
bool fromXml(QDomDocument &,
|
||||
QPointF = QPointF(),
|
||||
bool = true,
|
||||
DiagramContent * = nullptr);
|
||||
bool fromXml(QDomElement &,
|
||||
QPointF = QPointF(),
|
||||
bool = true,
|
||||
DiagramContent * = nullptr);
|
||||
void folioSequentialsToXml(QHash<QString,
|
||||
QStringList>*,
|
||||
QDomElement *,
|
||||
const QString&,
|
||||
const QString&,
|
||||
QDomDocument *);
|
||||
void folioSequentialsFromXml(const QDomElement&,
|
||||
QHash<QString,
|
||||
QStringList>*,
|
||||
const QString&,
|
||||
const QString&,
|
||||
const QString&,
|
||||
const QString&);
|
||||
|
||||
void refreshContents();
|
||||
|
||||
|
||||
// methods related to graphics items addition/removal on the diagram
|
||||
virtual void addItem (QGraphicsItem *item);
|
||||
virtual void addItem (QGraphicsItem *item);
|
||||
virtual void removeItem (QGraphicsItem *item);
|
||||
|
||||
|
||||
// methods related to graphics options
|
||||
ExportProperties applyProperties(const ExportProperties &);
|
||||
void setDisplayGrid(bool);
|
||||
@@ -199,19 +210,19 @@ class Diagram : public QGraphicsScene
|
||||
BorderOptions borderOptions();
|
||||
DiagramPosition convertPosition(const QPointF &);
|
||||
static QPointF snapToGrid(const QPointF &p);
|
||||
|
||||
|
||||
bool drawTerminals() const;
|
||||
void setDrawTerminals(bool);
|
||||
bool drawColoredConductors() const;
|
||||
void setDrawColoredConductors(bool);
|
||||
|
||||
|
||||
QString title() const;
|
||||
bool toPaintDevice(QPaintDevice &, int = -1, int = -1,
|
||||
Qt::AspectRatioMode = Qt::KeepAspectRatio);
|
||||
QSize imageSize() const;
|
||||
|
||||
|
||||
bool isEmpty() const;
|
||||
|
||||
|
||||
QList<Element *> elements() const;
|
||||
QList<Conductor *> conductors() const;
|
||||
QSet<Conductor *> selectedConductors() const;
|
||||
@@ -221,21 +232,21 @@ class Diagram : public QGraphicsScene
|
||||
ElementTextsMover &elementTextsMover();
|
||||
bool usesElement(const ElementsLocation &);
|
||||
bool usesTitleBlockTemplate(const QString &);
|
||||
|
||||
|
||||
QUndoStack &undoStack();
|
||||
QGIManager &qgiManager();
|
||||
|
||||
|
||||
//methods related to element label Update Policy
|
||||
void freezeElements(bool freeze);
|
||||
void unfreezeElements();
|
||||
void setFreezeNewElements(bool);
|
||||
bool freezeNewElements();
|
||||
|
||||
|
||||
//methods related to conductor label Update Policy
|
||||
void freezeConductors(bool freeze);
|
||||
void setFreezeNewConductors(bool);
|
||||
bool freezeNewConductors();
|
||||
|
||||
|
||||
//methods related to insertion and loading of folio sequential
|
||||
void insertFolioSeqHash (QHash<QString, QStringList> *hash,
|
||||
const QString& title,
|
||||
@@ -256,7 +267,7 @@ class Diagram : public QGraphicsScene
|
||||
void updateLabels();
|
||||
void loadElmtFolioSeq();
|
||||
void loadCndFolioSeq();
|
||||
|
||||
|
||||
// methods related to graphics items selection
|
||||
void selectAll();
|
||||
void deselectAll();
|
||||
@@ -271,6 +282,8 @@ class Diagram : public QGraphicsScene
|
||||
/// from the diagram within elements collection
|
||||
void findElementRequired(const ElementsLocation &);
|
||||
|
||||
/// Signal emitted when users wish to edit an element from the diagram
|
||||
void editElementRequired(const ElementsLocation &);
|
||||
void diagramActivated();
|
||||
};
|
||||
Q_DECLARE_METATYPE(Diagram *)
|
||||
|
||||
@@ -135,7 +135,7 @@ bool DiagramContext::keyMustShow(const QString &key) 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);
|
||||
}
|
||||
|
||||
@@ -209,17 +209,15 @@ void DiagramContext::toSettings(QSettings &settings, const QString &array_name)
|
||||
Read this context properties from \a settings by running through the array
|
||||
named \a array_name.
|
||||
*/
|
||||
void DiagramContext::fromSettings(const QSettings &settings, const QString &array_name) {
|
||||
// TODO: find better solution than const cast
|
||||
QSettings& s = const_cast<QSettings&>(settings);
|
||||
int size = s.beginReadArray(array_name);
|
||||
void DiagramContext::fromSettings(QSettings &settings, const QString &array_name) {
|
||||
int size = settings.beginReadArray(array_name);
|
||||
for (int i = 0 ; i < size; ++ i) {
|
||||
s.setArrayIndex(i);
|
||||
settings.setArrayIndex(i);
|
||||
QString key = settings.value("name").toString();
|
||||
if (key.isEmpty()) continue;
|
||||
addValue(key, settings.value("value").toString());
|
||||
}
|
||||
s.endArray();
|
||||
settings.endArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+17
-17
@@ -33,23 +33,23 @@
|
||||
|
||||
/**
|
||||
* Key for element :
|
||||
* label -> label or identification of element
|
||||
* formula -> formula used to create the label (formula is make with variable)
|
||||
* designation -> exhaustive comment used to explain what the element does.
|
||||
* description -> exhaustive description used to explain what the element does.
|
||||
* plant -> the plant assigned to the element
|
||||
* comment -> a little comment wich can be displayed in the folio
|
||||
* manufacturer -> the manufacturer of the element
|
||||
* manufacturer_reference -> the manufacturer reference of the element
|
||||
* quantity -> quantity of the element
|
||||
* unity -> unity of the element
|
||||
* auxiliary1 -> auxiliary 1 of element
|
||||
* auxiliary2 -> auxiliary 2 of element
|
||||
* label -> label or identification of element
|
||||
* formula -> formula used to create the label (formula is make with variable)
|
||||
* designation -> exhaustive comment used to explain what the element does.
|
||||
* description -> exhaustive description used to explain what the element does.
|
||||
* plant -> the plant assigned to the element
|
||||
* comment -> a little comment wich can be displayed in the folio
|
||||
* manufacturer -> the manufacturer of the element
|
||||
* manufacturer_reference -> the manufacturer reference of the element
|
||||
* quantity -> quantity of the element
|
||||
* unity -> unity of the element
|
||||
* auxiliary1 -> auxiliary 1 of element
|
||||
* auxiliary2 -> auxiliary 2 of element
|
||||
* machine_manufacturer_reference -> reference of the machine manufacturer
|
||||
* supplier -> the supplier of the element
|
||||
* function -> the function of element
|
||||
* location -> the location assigned to the element
|
||||
* frozenLabel -> label locked at a given time
|
||||
* supplier -> the supplier of the element
|
||||
* function -> the function of element
|
||||
* location -> the location assigned to the element
|
||||
* frozenLabel -> label locked at a given time
|
||||
*
|
||||
*/
|
||||
class DiagramContext
|
||||
@@ -79,7 +79,7 @@ class DiagramContext
|
||||
void fromXml(const QDomElement &, const QString & = "property");
|
||||
void fromXml(const pugi::xml_node &dom_element, const QString &tag_name = "property");
|
||||
void toSettings(QSettings &, const QString &) const;
|
||||
void fromSettings(const QSettings &, const QString &);
|
||||
void fromSettings(QSettings &, const QString &);
|
||||
|
||||
static QString validKeyRegExp();
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ qreal CustomElementGraphicPart::penWeight() const
|
||||
if (_lineweight == NoneWeight || _lineweight == ThinWeight) return 0;
|
||||
else if (_lineweight == NormalWeight) return 1;
|
||||
else if (_lineweight == UltraWeight) return 2;
|
||||
else if (_lineweight == BigWeight) return 5;
|
||||
else if (_lineweight == BigWeight) return 5;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -161,27 +161,26 @@ void CustomElementGraphicPart::setAntialiased(const bool b)
|
||||
Each style separate by ; and name-style/value are separate by :
|
||||
@param qde : QDOmElement used to write the style.
|
||||
*/
|
||||
void CustomElementGraphicPart::stylesToXml(
|
||||
QDomDocument &xml_document, QDomElement &qde) const
|
||||
void CustomElementGraphicPart::stylesToXml(QDomDocument &xml_document, QDomElement &qde) const
|
||||
{
|
||||
QString css_like_styles;
|
||||
|
||||
css_like_styles += "line-style:";
|
||||
if (_linestyle == DashedStyle) css_like_styles += "dashed";
|
||||
else if (_linestyle == DottedStyle) css_like_styles += "dotted";
|
||||
if (_linestyle == DashedStyle) css_like_styles += "dashed";
|
||||
else if (_linestyle == DottedStyle) css_like_styles += "dotted";
|
||||
else if (_linestyle == DashdottedStyle) css_like_styles += "dashdotted";
|
||||
else if (_linestyle == NormalStyle) css_like_styles += "normal";
|
||||
else if (_linestyle == NormalStyle) css_like_styles += "normal";
|
||||
|
||||
css_like_styles += ";line-weight:";
|
||||
if (_lineweight == NoneWeight) css_like_styles += "none";
|
||||
if (_lineweight == NoneWeight) css_like_styles += "none";
|
||||
else if (_lineweight == ThinWeight) css_like_styles += "thin";
|
||||
else if (_lineweight == NormalWeight) css_like_styles += "normal";
|
||||
else if (_lineweight == UltraWeight) css_like_styles += "hight";
|
||||
else if (_lineweight == BigWeight) css_like_styles += "eleve";
|
||||
else if (_lineweight == BigWeight) css_like_styles += "eleve";
|
||||
|
||||
|
||||
css_like_styles += ";filling:";
|
||||
if (_filling == NoneFilling) css_like_styles += "none";
|
||||
if (_filling == NoneFilling) css_like_styles += "none";
|
||||
else if (_filling == BlackFilling) css_like_styles += "black";
|
||||
else if (_filling == WhiteFilling) css_like_styles += "white";
|
||||
else if (_filling == GreenFilling) css_like_styles += "green";
|
||||
@@ -342,7 +341,7 @@ void CustomElementGraphicPart::stylesToXml(
|
||||
|
||||
|
||||
css_like_styles += ";color:";
|
||||
if (_color == WhiteColor) css_like_styles += "white";
|
||||
if (_color == WhiteColor) css_like_styles += "white";
|
||||
else if (_color == BlackColor) css_like_styles += "black";
|
||||
else if (_color == GreenColor) css_like_styles += "green";
|
||||
else if (_color == RedColor) css_like_styles += "red";
|
||||
@@ -513,15 +512,19 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
||||
|
||||
QString style_string;
|
||||
propertyString(qde, "style", &style_string);
|
||||
|
||||
//Get the list of pair style/value
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
||||
QStringList styles = style_string.split(";", QString::SkipEmptyParts);
|
||||
QStringList styles = qde.attribute("style").split(";", QString::SkipEmptyParts);
|
||||
#else
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove code for QT 5.14 or later")
|
||||
#endif
|
||||
QStringList styles = qde.attribute("style").split(";", Qt::SkipEmptyParts);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//Check each pair of style
|
||||
QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
|
||||
foreach (QString style, styles)
|
||||
@@ -531,14 +534,14 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
||||
QString style_value = rx.namedCaptureGroups().at(2);
|
||||
if (style_name == "line-style")
|
||||
{
|
||||
if (style_value == "dashed") _linestyle = DashedStyle;
|
||||
else if (style_value == "dotted") _linestyle = DottedStyle;
|
||||
if (style_value == "dashed") _linestyle = DashedStyle;
|
||||
else if (style_value == "dotted") _linestyle = DottedStyle;
|
||||
else if (style_value == "dashdotted") _linestyle = DashdottedStyle;
|
||||
else if (style_value == "normal") _linestyle = NormalStyle;
|
||||
else if (style_value == "normal") _linestyle = NormalStyle;
|
||||
}
|
||||
else if (style_name == "line-weight")
|
||||
{
|
||||
if (style_value == "none") _lineweight = NoneWeight;
|
||||
if (style_value == "none") _lineweight = NoneWeight;
|
||||
else if (style_value == "thin") _lineweight = ThinWeight;
|
||||
else if (style_value == "normal") _lineweight = NormalWeight;
|
||||
else if (style_value == "hight") _lineweight = UltraWeight;
|
||||
@@ -546,7 +549,7 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
||||
}
|
||||
else if (style_name == "filling")
|
||||
{
|
||||
if (style_value == "white") _filling = WhiteFilling;
|
||||
if (style_value == "white") _filling = WhiteFilling;
|
||||
else if (style_value == "black") _filling = BlackFilling;
|
||||
else if (style_value == "red") _filling = RedFilling;
|
||||
else if (style_value == "green") _filling = GreenFilling;
|
||||
@@ -707,7 +710,7 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
|
||||
}
|
||||
else if (style_name == "color")
|
||||
{
|
||||
if (style_value == "black") _color = BlackColor;
|
||||
if (style_value == "black") _color = BlackColor;
|
||||
else if (style_value == "white") _color = WhiteColor;
|
||||
else if (style_value == "green") _color = GreenColor;
|
||||
else if (style_value == "red") _color = RedColor;
|
||||
@@ -896,17 +899,17 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
||||
QBrush brush = painter.brush();
|
||||
|
||||
//Apply pen style
|
||||
if (_linestyle == DashedStyle) pen.setStyle(Qt::DashLine);
|
||||
if (_linestyle == DashedStyle) pen.setStyle(Qt::DashLine);
|
||||
else if (_linestyle == DashdottedStyle) pen.setStyle(Qt::DashDotLine);
|
||||
else if (_linestyle == DottedStyle) pen.setStyle(Qt::DotLine);
|
||||
else if (_linestyle == NormalStyle) pen.setStyle(Qt::SolidLine);
|
||||
else if (_linestyle == DottedStyle) pen.setStyle(Qt::DotLine);
|
||||
else if (_linestyle == NormalStyle) pen.setStyle(Qt::SolidLine);
|
||||
|
||||
//Apply pen width
|
||||
if (_lineweight == NoneWeight) pen.setColor(QColor(0, 0, 0, 0));
|
||||
if (_lineweight == NoneWeight) pen.setColor(QColor(0, 0, 0, 0));
|
||||
else if (_lineweight == ThinWeight) pen.setWidth(0);
|
||||
else if (_lineweight == NormalWeight) pen.setWidthF(1.0);
|
||||
else if (_lineweight == UltraWeight) pen.setWidthF(2.0);
|
||||
else if (_lineweight == BigWeight) pen.setWidthF(5.0);
|
||||
else if (_lineweight == BigWeight) pen.setWidthF(5.0);
|
||||
|
||||
//Apply brush color
|
||||
if (_filling == NoneFilling) brush.setStyle(Qt::NoBrush);
|
||||
@@ -917,7 +920,7 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
||||
else
|
||||
{
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
if (_filling == BlackFilling) brush.setColor(Qt::black);
|
||||
if (_filling == BlackFilling) brush.setColor(Qt::black);
|
||||
else if (_filling == WhiteFilling) brush.setColor(Qt::white);
|
||||
else if (_filling == GreenFilling) brush.setColor(Qt::green);
|
||||
else if (_filling == RedFilling) brush.setColor(Qt::red);
|
||||
@@ -1073,7 +1076,7 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
||||
}
|
||||
|
||||
//Apply pen color
|
||||
if (_color == WhiteColor) pen.setColor(QColor(255, 255, 255, pen.color().alpha()));
|
||||
if (_color == WhiteColor) pen.setColor(QColor(255, 255, 255, pen.color().alpha()));
|
||||
else if (_color == BlackColor) pen.setColor(QColor( 0, 0, 0, pen.color().alpha()));
|
||||
else if (_color == GreenColor) pen.setColor(QColor(Qt::green));
|
||||
else if (_color == RedColor) pen.setColor(QColor(Qt::red));
|
||||
@@ -1229,8 +1232,8 @@ void CustomElementGraphicPart::applyStylesToQPainter(QPainter &painter) const
|
||||
else if (_color == NoneColor) pen.setBrush(Qt::transparent);
|
||||
|
||||
//Apply antialiasing
|
||||
painter.setRenderHint(QPainter::Antialiasing, _antialiased);
|
||||
painter.setRenderHint(QPainter::TextAntialiasing, _antialiased);
|
||||
painter.setRenderHint(QPainter::Antialiasing, _antialiased);
|
||||
painter.setRenderHint(QPainter::TextAntialiasing, _antialiased);
|
||||
painter.setRenderHint(QPainter::SmoothPixmapTransform, _antialiased);
|
||||
|
||||
painter.setPen(pen);
|
||||
@@ -1327,7 +1330,7 @@ void CustomElementGraphicPart::mouseReleaseEvent(QGraphicsSceneMouseEvent *event
|
||||
if((event->button() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable) && m_origin_pos != pos())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "pos", QVariant(m_origin_pos), QVariant(pos()));
|
||||
undo->setText(tr("Déplacer une primitive"));
|
||||
undo->setText(tr("D??placer une primitive"));
|
||||
undo->enableAnimation();
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
||||
|
||||
Q_PROPERTY(LineStyle line_style READ lineStyle WRITE setLineStyle)
|
||||
Q_PROPERTY(LineWeight line_weight READ lineWeight WRITE setLineWeight)
|
||||
Q_PROPERTY(Filling filling READ filling WRITE setFilling)
|
||||
Q_PROPERTY(Color color READ color WRITE setColor)
|
||||
Q_PROPERTY(bool antialias READ antialiased WRITE setAntialiased)
|
||||
Q_PROPERTY(Filling filling READ filling WRITE setFilling)
|
||||
Q_PROPERTY(Color color READ color WRITE setColor)
|
||||
Q_PROPERTY(bool antialias READ antialiased WRITE setAntialiased)
|
||||
|
||||
public:
|
||||
//Line style
|
||||
@@ -62,122 +62,122 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
||||
|
||||
//Filling color of the part : NoneFilling -> No filling (i.e. transparent)
|
||||
enum Filling { NoneFilling, BlackFilling, WhiteFilling,
|
||||
GreenFilling, RedFilling, BlueFilling,
|
||||
GrayFilling, BrunFilling, YellowFilling,
|
||||
CyanFilling, MagentaFilling, LightgrayFilling,
|
||||
OrangeFilling, PurpleFilling,
|
||||
HTMLPinkPinkFilling, HTMLPinkLightPinkFilling,
|
||||
HTMLPinkHotPinkFilling, HTMLPinkDeepPinkFilling,
|
||||
HTMLPinkPaleVioletRedFilling,
|
||||
HTMLPinkMediumVioletRedFilling,
|
||||
HTMLRedLightSalmonFilling, HTMLRedSalmonFilling,
|
||||
HTMLRedDarkSalmonFilling,
|
||||
HTMLRedLightCoralFilling,
|
||||
HTMLRedIndianRedFilling, HTMLRedCrimsonFilling,
|
||||
HTMLRedFirebrickFilling, HTMLRedDarkRedFilling,
|
||||
HTMLRedRedFilling, HTMLOrangeOrangeRedFilling,
|
||||
HTMLOrangeTomatoFilling, HTMLOrangeCoralFilling,
|
||||
HTMLOrangeDarkOrangeFilling,
|
||||
HTMLOrangeOrangeFilling, HTMLYellowYellowFilling,
|
||||
HTMLYellowLightYellowFilling,
|
||||
HTMLYellowLemonChiffonFilling,
|
||||
HTMLYellowLightGoldenrodYellowFilling,
|
||||
HTMLYellowPapayaWhipFilling,
|
||||
HTMLYellowMoccasinFilling,
|
||||
HTMLYellowPeachPuffFilling,
|
||||
HTMLYellowPaleGoldenrodFilling,
|
||||
HTMLYellowKhakiFilling,
|
||||
HTMLYellowDarkKhakiFilling,
|
||||
HTMLYellowGoldFilling, HTMLBrownCornsilkFilling,
|
||||
HTMLBrownBlanchedAlmondFilling,
|
||||
HTMLBrownBisqueFilling,
|
||||
HTMLBrownNavajoWhiteFilling,
|
||||
HTMLBrownWheatFilling, HTMLBrownBurlywoodFilling,
|
||||
HTMLBrownTanFilling, HTMLBrownRosyBrownFilling,
|
||||
HTMLBrownSandyBrownFilling,
|
||||
HTMLBrownGoldenrodFilling,
|
||||
HTMLBrownDarkGoldenrodFilling,
|
||||
HTMLBrownPeruFilling, HTMLBrownChocolateFilling,
|
||||
HTMLBrownSaddleBrownFilling,
|
||||
HTMLBrownSiennaFilling, HTMLBrownBrownFilling,
|
||||
HTMLBrownMaroonFilling,
|
||||
HTMLGreenDarkOliveGreenFilling,
|
||||
HTMLGreenOliveFilling, HTMLGreenOliveDrabFilling,
|
||||
HTMLGreenYellowGreenFilling,
|
||||
HTMLGreenLimeGreenFilling, HTMLGreenLimeFilling,
|
||||
HTMLGreenLawnGreenFilling,
|
||||
HTMLGreenChartreuseFilling,
|
||||
HTMLGreenGreenYellowFilling,
|
||||
HTMLGreenSpringGreenFilling,
|
||||
HTMLGreenMediumSpringGreenFilling,
|
||||
HTMLGreenLightGreenFilling,
|
||||
HTMLGreenPaleGreenFilling,
|
||||
HTMLGreenDarkSeaGreenFilling,
|
||||
HTMLGreenMediumAquamarineFilling,
|
||||
HTMLGreenMediumSeaGreenFilling,
|
||||
HTMLGreenSeaGreenFilling,
|
||||
HTMLGreenForestGreenFilling,
|
||||
HTMLGreenGreenFilling, HTMLGreenDarkGreenFilling,
|
||||
HTMLCyanAquaFilling, HTMLCyanCyanFilling,
|
||||
HTMLCyanLightCyanFilling,
|
||||
HTMLCyanPaleTurquoiseFilling,
|
||||
HTMLCyanAquamarineFilling,
|
||||
HTMLCyanTurquoiseFilling,
|
||||
HTMLCyanMediumTurquoiseFilling,
|
||||
HTMLCyanDarkTurquoiseFilling,
|
||||
HTMLCyanLightSeaGreenFilling,
|
||||
HTMLCyanCadetBlueFilling,
|
||||
HTMLCyanDarkCyanFilling, HTMLCyanTealFilling,
|
||||
HTMLBlueLightSteelBlueFilling,
|
||||
HTMLBluePowderBlueFilling,
|
||||
HTMLBlueLightBlueFilling, HTMLBlueSkyBlueFilling,
|
||||
HTMLBlueLightSkyBlueFilling,
|
||||
HTMLBlueDeepSkyBlueFilling,
|
||||
HTMLBlueDodgerBlueFilling,
|
||||
HTMLBlueCornflowerBlueFilling,
|
||||
HTMLBlueSteelBlueFilling,
|
||||
HTMLBlueRoyalBlueFilling, HTMLBlueBlueFilling,
|
||||
HTMLBlueMediumBlueFilling,
|
||||
HTMLBlueDarkBlueFilling, HTMLBlueNavyFilling,
|
||||
HTMLBlueMidnightBlueFilling,
|
||||
HTMLPurpleLavenderFilling,
|
||||
HTMLPurpleThistleFilling, HTMLPurplePlumFilling,
|
||||
HTMLPurpleVioletFilling, HTMLPurpleOrchidFilling,
|
||||
HTMLPurpleFuchsiaFilling,
|
||||
HTMLPurpleMagentaFilling,
|
||||
HTMLPurpleMediumOrchidFilling,
|
||||
HTMLPurpleMediumPurpleFilling,
|
||||
HTMLPurpleBlueVioletFilling,
|
||||
HTMLPurpleDarkVioletFilling,
|
||||
HTMLPurpleDarkOrchidFilling,
|
||||
HTMLPurpleDarkMagentaFilling,
|
||||
HTMLPurplePurpleFilling, HTMLPurpleIndigoFilling,
|
||||
HTMLPurpleDarkSlateBlueFilling,
|
||||
HTMLPurpleSlateBlueFilling,
|
||||
HTMLPurpleMediumSlateBlueFilling,
|
||||
HTMLWhiteWhiteFilling, HTMLWhiteSnowFilling,
|
||||
HTMLWhiteHoneydewFilling,
|
||||
HTMLWhiteMintCreamFilling, HTMLWhiteAzureFilling,
|
||||
HTMLWhiteAliceBlueFilling,
|
||||
HTMLWhiteGhostWhiteFilling,
|
||||
HTMLWhiteWhiteSmokeFilling,
|
||||
HTMLWhiteSeashellFilling, HTMLWhiteBeigeFilling,
|
||||
HTMLWhiteOldLaceFilling,
|
||||
HTMLWhiteFloralWhiteFilling,
|
||||
HTMLWhiteIvoryFilling,
|
||||
HTMLWhiteAntiqueWhiteFilling,
|
||||
HTMLWhiteLinenFilling,
|
||||
HTMLWhiteLavenderBlushFilling,
|
||||
HTMLWhiteMistyRoseFilling,
|
||||
HTMLGrayGainsboroFilling,
|
||||
HTMLGrayLightGrayFilling, HTMLGraySilverFilling,
|
||||
HTMLGrayDarkGrayFilling, HTMLGrayGrayFilling,
|
||||
HTMLGrayDimGrayFilling,
|
||||
HTMLGrayLightSlateGrayFilling,
|
||||
HTMLGraySlateGrayFilling,
|
||||
HTMLGrayDarkSlateGrayFilling,
|
||||
HTMLGrayBlackFilling, HorFilling, VerFilling,
|
||||
BdiagFilling, FdiagFilling};
|
||||
GreenFilling, RedFilling, BlueFilling,
|
||||
GrayFilling, BrunFilling, YellowFilling,
|
||||
CyanFilling, MagentaFilling, LightgrayFilling,
|
||||
OrangeFilling, PurpleFilling,
|
||||
HTMLPinkPinkFilling, HTMLPinkLightPinkFilling,
|
||||
HTMLPinkHotPinkFilling, HTMLPinkDeepPinkFilling,
|
||||
HTMLPinkPaleVioletRedFilling,
|
||||
HTMLPinkMediumVioletRedFilling,
|
||||
HTMLRedLightSalmonFilling, HTMLRedSalmonFilling,
|
||||
HTMLRedDarkSalmonFilling,
|
||||
HTMLRedLightCoralFilling,
|
||||
HTMLRedIndianRedFilling, HTMLRedCrimsonFilling,
|
||||
HTMLRedFirebrickFilling, HTMLRedDarkRedFilling,
|
||||
HTMLRedRedFilling, HTMLOrangeOrangeRedFilling,
|
||||
HTMLOrangeTomatoFilling, HTMLOrangeCoralFilling,
|
||||
HTMLOrangeDarkOrangeFilling,
|
||||
HTMLOrangeOrangeFilling, HTMLYellowYellowFilling,
|
||||
HTMLYellowLightYellowFilling,
|
||||
HTMLYellowLemonChiffonFilling,
|
||||
HTMLYellowLightGoldenrodYellowFilling,
|
||||
HTMLYellowPapayaWhipFilling,
|
||||
HTMLYellowMoccasinFilling,
|
||||
HTMLYellowPeachPuffFilling,
|
||||
HTMLYellowPaleGoldenrodFilling,
|
||||
HTMLYellowKhakiFilling,
|
||||
HTMLYellowDarkKhakiFilling,
|
||||
HTMLYellowGoldFilling, HTMLBrownCornsilkFilling,
|
||||
HTMLBrownBlanchedAlmondFilling,
|
||||
HTMLBrownBisqueFilling,
|
||||
HTMLBrownNavajoWhiteFilling,
|
||||
HTMLBrownWheatFilling, HTMLBrownBurlywoodFilling,
|
||||
HTMLBrownTanFilling, HTMLBrownRosyBrownFilling,
|
||||
HTMLBrownSandyBrownFilling,
|
||||
HTMLBrownGoldenrodFilling,
|
||||
HTMLBrownDarkGoldenrodFilling,
|
||||
HTMLBrownPeruFilling, HTMLBrownChocolateFilling,
|
||||
HTMLBrownSaddleBrownFilling,
|
||||
HTMLBrownSiennaFilling, HTMLBrownBrownFilling,
|
||||
HTMLBrownMaroonFilling,
|
||||
HTMLGreenDarkOliveGreenFilling,
|
||||
HTMLGreenOliveFilling, HTMLGreenOliveDrabFilling,
|
||||
HTMLGreenYellowGreenFilling,
|
||||
HTMLGreenLimeGreenFilling, HTMLGreenLimeFilling,
|
||||
HTMLGreenLawnGreenFilling,
|
||||
HTMLGreenChartreuseFilling,
|
||||
HTMLGreenGreenYellowFilling,
|
||||
HTMLGreenSpringGreenFilling,
|
||||
HTMLGreenMediumSpringGreenFilling,
|
||||
HTMLGreenLightGreenFilling,
|
||||
HTMLGreenPaleGreenFilling,
|
||||
HTMLGreenDarkSeaGreenFilling,
|
||||
HTMLGreenMediumAquamarineFilling,
|
||||
HTMLGreenMediumSeaGreenFilling,
|
||||
HTMLGreenSeaGreenFilling,
|
||||
HTMLGreenForestGreenFilling,
|
||||
HTMLGreenGreenFilling, HTMLGreenDarkGreenFilling,
|
||||
HTMLCyanAquaFilling, HTMLCyanCyanFilling,
|
||||
HTMLCyanLightCyanFilling,
|
||||
HTMLCyanPaleTurquoiseFilling,
|
||||
HTMLCyanAquamarineFilling,
|
||||
HTMLCyanTurquoiseFilling,
|
||||
HTMLCyanMediumTurquoiseFilling,
|
||||
HTMLCyanDarkTurquoiseFilling,
|
||||
HTMLCyanLightSeaGreenFilling,
|
||||
HTMLCyanCadetBlueFilling,
|
||||
HTMLCyanDarkCyanFilling, HTMLCyanTealFilling,
|
||||
HTMLBlueLightSteelBlueFilling,
|
||||
HTMLBluePowderBlueFilling,
|
||||
HTMLBlueLightBlueFilling, HTMLBlueSkyBlueFilling,
|
||||
HTMLBlueLightSkyBlueFilling,
|
||||
HTMLBlueDeepSkyBlueFilling,
|
||||
HTMLBlueDodgerBlueFilling,
|
||||
HTMLBlueCornflowerBlueFilling,
|
||||
HTMLBlueSteelBlueFilling,
|
||||
HTMLBlueRoyalBlueFilling, HTMLBlueBlueFilling,
|
||||
HTMLBlueMediumBlueFilling,
|
||||
HTMLBlueDarkBlueFilling, HTMLBlueNavyFilling,
|
||||
HTMLBlueMidnightBlueFilling,
|
||||
HTMLPurpleLavenderFilling,
|
||||
HTMLPurpleThistleFilling, HTMLPurplePlumFilling,
|
||||
HTMLPurpleVioletFilling, HTMLPurpleOrchidFilling,
|
||||
HTMLPurpleFuchsiaFilling,
|
||||
HTMLPurpleMagentaFilling,
|
||||
HTMLPurpleMediumOrchidFilling,
|
||||
HTMLPurpleMediumPurpleFilling,
|
||||
HTMLPurpleBlueVioletFilling,
|
||||
HTMLPurpleDarkVioletFilling,
|
||||
HTMLPurpleDarkOrchidFilling,
|
||||
HTMLPurpleDarkMagentaFilling,
|
||||
HTMLPurplePurpleFilling, HTMLPurpleIndigoFilling,
|
||||
HTMLPurpleDarkSlateBlueFilling,
|
||||
HTMLPurpleSlateBlueFilling,
|
||||
HTMLPurpleMediumSlateBlueFilling,
|
||||
HTMLWhiteWhiteFilling, HTMLWhiteSnowFilling,
|
||||
HTMLWhiteHoneydewFilling,
|
||||
HTMLWhiteMintCreamFilling, HTMLWhiteAzureFilling,
|
||||
HTMLWhiteAliceBlueFilling,
|
||||
HTMLWhiteGhostWhiteFilling,
|
||||
HTMLWhiteWhiteSmokeFilling,
|
||||
HTMLWhiteSeashellFilling, HTMLWhiteBeigeFilling,
|
||||
HTMLWhiteOldLaceFilling,
|
||||
HTMLWhiteFloralWhiteFilling,
|
||||
HTMLWhiteIvoryFilling,
|
||||
HTMLWhiteAntiqueWhiteFilling,
|
||||
HTMLWhiteLinenFilling,
|
||||
HTMLWhiteLavenderBlushFilling,
|
||||
HTMLWhiteMistyRoseFilling,
|
||||
HTMLGrayGainsboroFilling,
|
||||
HTMLGrayLightGrayFilling, HTMLGraySilverFilling,
|
||||
HTMLGrayDarkGrayFilling, HTMLGrayGrayFilling,
|
||||
HTMLGrayDimGrayFilling,
|
||||
HTMLGrayLightSlateGrayFilling,
|
||||
HTMLGraySlateGrayFilling,
|
||||
HTMLGrayDarkSlateGrayFilling,
|
||||
HTMLGrayBlackFilling, HorFilling, VerFilling,
|
||||
BdiagFilling, FdiagFilling};
|
||||
Q_ENUM (Filling)
|
||||
|
||||
//Line color
|
||||
@@ -269,18 +269,18 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
||||
~CustomElementGraphicPart() override;
|
||||
|
||||
static void drawCross (const QPointF ¢er,
|
||||
QPainter *painter);
|
||||
QPainter *painter);
|
||||
|
||||
//Getter and setter
|
||||
LineStyle lineStyle () const {return _linestyle;}
|
||||
void setLineStyle (const LineStyle ls);
|
||||
LineStyle lineStyle () const {return _linestyle;}
|
||||
void setLineStyle (const LineStyle ls);
|
||||
|
||||
LineWeight lineWeight () const {return _lineweight;}
|
||||
void setLineWeight (const LineWeight lw);
|
||||
qreal penWeight () const;
|
||||
LineWeight lineWeight () const {return _lineweight;}
|
||||
void setLineWeight (const LineWeight lw);
|
||||
qreal penWeight () const;
|
||||
|
||||
Filling filling () const {return _filling;}
|
||||
void setFilling(const Filling f);
|
||||
void setFilling(const Filling f);
|
||||
|
||||
Color color () const {return _color;}
|
||||
void setColor(const Color c);
|
||||
@@ -299,18 +299,18 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
||||
|
||||
virtual QPainterPath shadowShape ()const = 0;
|
||||
virtual void setHandlerColor(QPointF /*pos*/,
|
||||
const QColor &/*color*/) {}
|
||||
const QColor &/*color*/) {}
|
||||
virtual void resetAllHandlerColor() {}
|
||||
|
||||
protected:
|
||||
void stylesToXml (QDomDocument &xml_document, QDomElement &) const;
|
||||
void stylesToXml (QDomDocument &xml_document, QDomElement &) const;
|
||||
void stylesFromXml(const QDomElement &);
|
||||
void resetStyles ();
|
||||
void applyStylesToQPainter(QPainter &) const;
|
||||
void drawShadowShape (QPainter *painter);
|
||||
|
||||
QVariant itemChange(GraphicsItemChange change,
|
||||
const QVariant &value) override;
|
||||
const QVariant &value) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class CustomElementPart: public PropertiesInterface {
|
||||
Make this part fit into the provided rectangle.
|
||||
*/
|
||||
virtual void handleUserTransformation(const QRectF &,
|
||||
const QRectF &) = 0;
|
||||
const QRectF &) = 0;
|
||||
/// @return a pointer to the parent element editor
|
||||
virtual QETElementEditor *elementEditor() const;
|
||||
/**
|
||||
|
||||
@@ -97,13 +97,13 @@ void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartArc::toXml
|
||||
* Export this arc in xml
|
||||
* @param xml_document : Xml document to use for create the xml element.
|
||||
* @return : an xml element that describe this arc
|
||||
*/
|
||||
@brief PartArc::toXml
|
||||
Export this arc in xml
|
||||
@param xml_document : Xml document to use for create the xml element.
|
||||
@return : an xml element that describe this arc
|
||||
*/
|
||||
QDomElement PartArc::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
{
|
||||
QDomElement xml_element = xml_document.createElement("arc");
|
||||
QPointF top_left(sceneTopLeft());
|
||||
|
||||
@@ -112,7 +112,7 @@ QDomElement PartArc::toXml(QDomDocument &xml_document) const
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "width", rect().width()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "height", rect().height()));
|
||||
|
||||
//to maintain compatibility with the previous version, we write the angle in degrees.
|
||||
//to maintain compatibility with the previous version, we write the angle in degrees.
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "start", m_start_angle / 16));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "angle", m_span_angle / 16));
|
||||
|
||||
@@ -122,10 +122,10 @@ QDomElement PartArc::toXml(QDomDocument &xml_document) const
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartArc::fromXml
|
||||
* Import the properties of this arc from a xml element.
|
||||
* @param qde : Xml document to use.
|
||||
*/
|
||||
@brief PartArc::fromXml
|
||||
Import the properties of this arc from a xml element.
|
||||
@param qde : Xml document to use.
|
||||
*/
|
||||
bool PartArc::fromXml(const QDomElement &qde) {
|
||||
stylesFromXml(qde);
|
||||
|
||||
|
||||
@@ -49,11 +49,13 @@ class PartArc : public AbstractPartEllipse
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||
|
||||
//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")); }
|
||||
QDomElement toXml (QDomDocument &) const override;
|
||||
bool fromXml (const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
QDomElement toXml (QDomDocument &) const override;
|
||||
bool fromXml (const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
|
||||
QPainterPath shape() const override;
|
||||
QPainterPath shadowShape() const override;
|
||||
@@ -71,7 +73,7 @@ class PartArc : public AbstractPartEllipse
|
||||
void switchResizeMode();
|
||||
void adjusteHandlerPos();
|
||||
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 sceneSelectionChanged ();
|
||||
|
||||
|
||||
@@ -88,10 +88,10 @@ void PartDynamicTextField::handleUserTransformation(
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartDynamicTextField::toXml
|
||||
* @param document
|
||||
* @return
|
||||
*/
|
||||
@brief PartDynamicTextField::toXml
|
||||
@param dom_doc
|
||||
@return
|
||||
*/
|
||||
QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
||||
{
|
||||
QDomElement root_element = dom_doc.createElement(xmlName());
|
||||
@@ -106,28 +106,28 @@ QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "frame", m_frame));
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "text_width", m_text_width));
|
||||
|
||||
|
||||
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "text_from", me.valueToKey(m_text_from)));
|
||||
|
||||
me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
if(this->alignment() &Qt::AlignRight)
|
||||
if(this -> alignment() &Qt::AlignRight)
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "Halignment", me.valueToKey(Qt::AlignRight)));
|
||||
else if(this->alignment() &Qt::AlignLeft)
|
||||
else if(this -> alignment() &Qt::AlignLeft)
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "Halignment", me.valueToKey(Qt::AlignLeft)));
|
||||
else if(this->alignment() &Qt::AlignHCenter)
|
||||
else if(this -> alignment() &Qt::AlignHCenter)
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "Halignment", me.valueToKey(Qt::AlignHCenter)));
|
||||
|
||||
if(this->alignment() &Qt::AlignBottom)
|
||||
if(this -> alignment() &Qt::AlignBottom)
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "Valignment", me.valueToKey(Qt::AlignBottom)));
|
||||
else if(this->alignment() & Qt::AlignTop)
|
||||
else if(this -> alignment() & Qt::AlignTop)
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "Valignment", me.valueToKey(Qt::AlignTop)));
|
||||
else if(this->alignment() &Qt::AlignVCenter)
|
||||
else if(this -> alignment() &Qt::AlignVCenter)
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "Valignment", me.valueToKey(Qt::AlignVCenter)));
|
||||
|
||||
QDomElement dom_text = dom_doc.createElement("text");
|
||||
dom_text.appendChild(dom_doc.createTextNode(toPlainText()));
|
||||
root_element.appendChild(dom_text);
|
||||
|
||||
//Info name
|
||||
if(!m_info_name.isEmpty()) {
|
||||
QDomElement dom_info_name = dom_doc.createElement("info_name");
|
||||
@@ -153,23 +153,23 @@ QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartDynamicTextField::fromXml
|
||||
* @param element
|
||||
*/
|
||||
@brief PartDynamicTextField::fromXml
|
||||
@param dom_elmt
|
||||
*/
|
||||
bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
|
||||
{
|
||||
if (dom_elmt.tagName() != xmlName()) {
|
||||
qDebug() << "PartDynamicTextField::fromXml : Wrong tagg name";
|
||||
return false;
|
||||
}
|
||||
double x=0, y=0, z=0, rot=0;
|
||||
|
||||
double x=0, y=0, z=0, rot=0;
|
||||
if (propertyDouble(dom_elmt, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(dom_elmt, "y", &y) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(dom_elmt, "z", &z) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(dom_elmt, "rotation", &rot) == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
|
||||
QGraphicsTextItem::setPos(x, y);
|
||||
setZValue(z);
|
||||
QGraphicsTextItem::setRotation(rot);
|
||||
@@ -180,8 +180,7 @@ bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
|
||||
QFont font_;
|
||||
font_.fromString(font);
|
||||
setFont(font_);
|
||||
}
|
||||
else {
|
||||
} else { //Keep compatibility TODO remove in futur
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO remove in futur")
|
||||
#endif
|
||||
@@ -207,7 +206,8 @@ bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
|
||||
if(propertyString(dom_elmt, "Halignment", &alignment) != PropertyFlags::NotFound)
|
||||
setAlignment(Qt::Alignment(me.keyToValue(alignment.toStdString().data())));
|
||||
if(propertyString(dom_elmt, "Valignment", &alignment) != PropertyFlags::NotFound)
|
||||
setAlignment(Qt::Alignment(me.keyToValue(alignment.toStdString().data())) | this->alignment());
|
||||
setAlignment(Qt::Alignment(
|
||||
me.keyToValue(dom_elmt.attribute("Valignment").toStdString().data())) | this -> alignment());
|
||||
|
||||
//Text
|
||||
QDomElement dom_text = dom_elmt.firstChildElement("text");
|
||||
@@ -498,7 +498,7 @@ void PartDynamicTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||
m_origine_pos != pos()) {
|
||||
QPropertyUndoCommand *undo =\
|
||||
new QPropertyUndoCommand(this, "pos", QVariant(m_origine_pos), QVariant(pos()));
|
||||
undo -> setText(tr("Déplacer un champ texte"));
|
||||
undo -> setText(tr("D??placer un champ texte"));
|
||||
undo -> enableAnimation();
|
||||
elementScene() -> undoStack().push(undo);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -79,6 +79,9 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
||||
bool fromXml(const QDomElement &dom_elmt) override;
|
||||
void fromTextFieldXml(const QDomElement &dom_element);
|
||||
static bool valideXml(QDomElement& dom_elmt);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
|
||||
DynamicElementTextItem::TextFrom textFrom() const;
|
||||
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
||||
QString text() const;
|
||||
|
||||
@@ -78,11 +78,11 @@ void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartEllipse::toXml
|
||||
* Export this ellipse in xml
|
||||
* @param xml_document : Xml document to use for create the xml element.
|
||||
* @return : an xml element that describe this ellipse
|
||||
*/
|
||||
@brief PartEllipse::toXml
|
||||
Export this ellipse in xml
|
||||
@param xml_document : Xml document to use for create the xml element.
|
||||
@return : an xml element that describe this ellipse
|
||||
*/
|
||||
QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
QDomElement xml_element;
|
||||
@@ -108,10 +108,10 @@ QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartEllipse::fromXml
|
||||
* Import the properties of this ellipse from a xml element.
|
||||
* @param qde : Xml document to use.
|
||||
*/
|
||||
@brief PartEllipse::fromXml
|
||||
Import the properties of this ellipse from a xml element.
|
||||
@param qde : Xml document to use.
|
||||
*/
|
||||
bool PartEllipse::fromXml(const QDomElement &qde)
|
||||
{
|
||||
stylesFromXml(qde);
|
||||
|
||||
@@ -50,11 +50,13 @@ class PartEllipse : public AbstractPartEllipse
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||
|
||||
//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")); }
|
||||
QDomElement toXml (QDomDocument &) const override;
|
||||
bool fromXml (const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
QDomElement toXml (QDomDocument &) const override;
|
||||
bool fromXml (const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
QPainterPath shape() const override;
|
||||
QPainterPath shadowShape() const override;
|
||||
void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
|
||||
@@ -68,7 +70,7 @@ class PartEllipse : public AbstractPartEllipse
|
||||
void switchResizeMode();
|
||||
void adjusteHandlerPos();
|
||||
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 sceneSelectionChanged ();
|
||||
|
||||
|
||||
@@ -104,11 +104,11 @@ void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartLine::toXml
|
||||
* Export this line in xml
|
||||
* @param xml_document : Xml document to use for create the xml element.
|
||||
* @return an xml element that describe this line
|
||||
*/
|
||||
@brief PartLine::toXml
|
||||
Export this line in xml
|
||||
@param xml_document : Xml document to use for create the xml element.
|
||||
@return an xml element that describe this line
|
||||
*/
|
||||
QDomElement PartLine::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
QPointF p1(sceneP1());
|
||||
@@ -125,18 +125,17 @@ QDomElement PartLine::toXml(QDomDocument &xml_document) const
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "length1", first_length));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "end2", Qet::endTypeToString(second_end)));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "length2", second_length));
|
||||
|
||||
|
||||
stylesToXml(xml_document, xml_element);
|
||||
return(xml_element);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartLine::fromXml
|
||||
* Import the properties of this line from a xml element.
|
||||
* @param qde : Xml document to use
|
||||
*/
|
||||
bool PartLine::fromXml(const QDomElement &qde)
|
||||
{
|
||||
@brief PartLine::fromXml
|
||||
Import the properties of this line from a xml element.
|
||||
@param qde : Xml document to use
|
||||
*/
|
||||
bool PartLine::fromXml(const QDomElement &qde) {
|
||||
stylesFromXml(qde);
|
||||
|
||||
double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
|
||||
|
||||
@@ -70,9 +70,11 @@ class PartLine : public CustomElementGraphicPart
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||
QString name() const override { return(QObject::tr("ligne", "element part name")); }
|
||||
QString xmlName() const override { return(QString("line")); }
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
bool valideXml(QDomElement& element) const;
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
bool valideXml(QDomElement& element) const;
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
virtual QPointF sceneP1() const;
|
||||
virtual QPointF sceneP2() const;
|
||||
QPainterPath shape() const override;
|
||||
@@ -103,7 +105,7 @@ class PartLine : public CustomElementGraphicPart
|
||||
private:
|
||||
void adjusteHandlerPos();
|
||||
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 sceneSelectionChanged ();
|
||||
|
||||
@@ -116,10 +118,10 @@ class PartLine : public CustomElementGraphicPart
|
||||
|
||||
/*****************/
|
||||
Qet::EndType first_end;
|
||||
qreal first_length{1.5};
|
||||
qreal first_length{1.5};
|
||||
|
||||
Qet::EndType second_end;
|
||||
qreal second_length{1.5};
|
||||
qreal second_length{1.5};
|
||||
QList<QPointF> saved_points_;
|
||||
QLineF m_line;
|
||||
int m_vector_index = -1;
|
||||
|
||||
@@ -85,10 +85,10 @@ void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartPolygon::fromXml
|
||||
* Import the properties of this polygon from a xml element
|
||||
* @param qde : Xml document to use
|
||||
*/
|
||||
@brief PartPolygon::fromXml
|
||||
Import the properties of this polygon from a xml element
|
||||
@param qde : Xml document to use
|
||||
*/
|
||||
bool PartPolygon::fromXml(const QDomElement &qde)
|
||||
{
|
||||
stylesFromXml(qde);
|
||||
@@ -123,11 +123,11 @@ bool PartPolygon::fromXml(const QDomElement &qde)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartPolygon::toXml
|
||||
* Export this polygin in xml
|
||||
* @param xml_document : Xml document to use for create the xml element
|
||||
* @return an xml element that describe this polygon
|
||||
*/
|
||||
@brief PartPolygon::toXml
|
||||
Export this polygin in xml
|
||||
@param xml_document : Xml document to use for create the xml element
|
||||
@return an xml element that describe this polygon
|
||||
*/
|
||||
QDomElement PartPolygon::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
QDomElement xml_element = xml_document.createElement("polygon");
|
||||
@@ -540,7 +540,7 @@ void PartPolygon::insertPoint()
|
||||
if(new_polygon != m_polygon)
|
||||
{
|
||||
//Wrap the undo for avoid to merge the undo commands when user add several points.
|
||||
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point à un polygone"));
|
||||
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point ?? un polygone"));
|
||||
new QPropertyUndoCommand(this, "polygon", m_polygon, new_polygon, undo);
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
|
||||
@@ -61,9 +61,11 @@ class PartPolygon : public CustomElementGraphicPart
|
||||
|
||||
QString name() const override { return(QObject::tr("polygone", "element part name")); }
|
||||
QString xmlName() const override { return(QString("polygon")); }
|
||||
bool fromXml(const QDomElement &) override;
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
bool fromXml(const QDomElement &) override;
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
|
||||
|
||||
QPainterPath shape () const override;
|
||||
@@ -79,8 +81,8 @@ class PartPolygon : public CustomElementGraphicPart
|
||||
QPolygonF polygon () const;
|
||||
void setPolygon (const QPolygonF &polygon);
|
||||
|
||||
void addPoint (const QPointF &point);
|
||||
void setLastPoint (const QPointF &point);
|
||||
void addPoint (const QPointF &point);
|
||||
void setLastPoint (const QPointF &point);
|
||||
void removeLastPoint ();
|
||||
|
||||
bool isClosed () const {return m_closed;}
|
||||
@@ -97,7 +99,7 @@ class PartPolygon : public CustomElementGraphicPart
|
||||
private:
|
||||
void adjusteHandlerPos();
|
||||
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 sceneSelectionChanged ();
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
||||
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, "height", m_rect.height()));
|
||||
|
||||
QRectF rect = m_rect.normalized();
|
||||
qreal x = m_xRadius;
|
||||
if (x > rect.width()/2) {
|
||||
@@ -108,7 +109,7 @@ QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
||||
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "rx", m_xRadius));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "ry", m_yRadius));
|
||||
|
||||
|
||||
stylesToXml(xml_document, xml_element);
|
||||
return(xml_element);
|
||||
}
|
||||
@@ -130,10 +131,10 @@ bool PartRectangle::fromXml(const QDomElement &qde)
|
||||
setPos(mapFromScene(x, y));
|
||||
|
||||
if (propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "width", &h) == PropertyFlags::NoValidConversion)
|
||||
propertyDouble(qde, "height", &h) == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
QRectF rect(QPointF(x,y), QSizeF(w, h));
|
||||
QRectF rect(QPointF(0,0), QSizeF(w, h));
|
||||
|
||||
setRect(rect.normalized());
|
||||
|
||||
@@ -152,7 +153,7 @@ bool PartRectangle::valideXml(QDomElement& element) {
|
||||
if ((propertyDouble(element, "x") & PropertyFlags::NoValidConversion) |
|
||||
(propertyDouble(element, "y") & PropertyFlags::NoValidConversion) |
|
||||
(propertyDouble(element, "width") & PropertyFlags::NoValidConversion) |
|
||||
(propertyDouble(element, "width") & PropertyFlags::NoValidConversion) |
|
||||
(propertyDouble(element, "height") & PropertyFlags::NoValidConversion) |
|
||||
(propertyDouble(element, "rx") & PropertyFlags::NoValidConversion) |
|
||||
(propertyDouble(element, "ry") & PropertyFlags::NoValidConversion))
|
||||
return false;
|
||||
@@ -566,9 +567,9 @@ void PartRectangle::addHandler()
|
||||
for (QetGraphicsHandlerItem *handler : m_handler_vector)
|
||||
{
|
||||
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 {color = Qt::magenta;}
|
||||
else {color = Qt::magenta;}
|
||||
|
||||
handler->setColor(color);
|
||||
scene()->addItem(handler);
|
||||
|
||||
@@ -55,14 +55,16 @@ class PartRectangle : public CustomElementGraphicPart
|
||||
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartRectangle.
|
||||
@return the QGraphicsItem type
|
||||
*/
|
||||
int type () const override { return Type; }
|
||||
void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||
int type () const override { return Type; }
|
||||
void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||
QString name () const override { return(QObject::tr("rectangle", "element part name")); }
|
||||
|
||||
QString xmlName () const override { return(QString("rect")); }
|
||||
QDomElement toXml (QDomDocument &) const override;
|
||||
bool fromXml (const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
QString xmlName () const override { return(QString("rect")); }
|
||||
QDomElement toXml (QDomDocument &) const override;
|
||||
bool fromXml (const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
|
||||
QRectF rect() const;
|
||||
void setRect(const QRectF &rect);
|
||||
@@ -91,7 +93,7 @@ class PartRectangle : public CustomElementGraphicPart
|
||||
void switchResizeMode();
|
||||
void adjusteHandlerPos();
|
||||
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 sceneSelectionChanged ();
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
{
|
||||
d = new TerminalData(this);
|
||||
d->m_name = tr("terminal");
|
||||
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_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
|
||||
updateSecondPoint();
|
||||
setZValue(100000);
|
||||
}
|
||||
@@ -47,7 +47,6 @@ PartTerminal::~PartTerminal()
|
||||
*/
|
||||
bool PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
||||
|
||||
QUuid uuid;
|
||||
// update part and add uuid, which is used in the new version to connect terminals together
|
||||
// if the attribute not exists, means, the element is created with an older version of qet. So use the legacy approach
|
||||
// to identify terminals
|
||||
@@ -56,7 +55,7 @@ bool PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
||||
if (!d->fromXml(xml_elmt))
|
||||
return false;
|
||||
|
||||
setPos(d->m_pos);
|
||||
setPos(d -> m_pos);
|
||||
updateSecondPoint();
|
||||
|
||||
return true;
|
||||
@@ -67,8 +66,8 @@ bool PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
||||
@param xml_document Document XML a utiliser pour creer l'element XML
|
||||
@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");
|
||||
|
||||
qdo.appendChild(createXmlProperty(xml_document, "uuid", d->m_uuid));
|
||||
@@ -84,8 +83,7 @@ QDomElement PartTerminal::toXml(QDomDocument &xml_document) const
|
||||
return qdo;
|
||||
}
|
||||
|
||||
bool PartTerminal::valideXml(QDomElement& element)
|
||||
{
|
||||
bool PartTerminal::valideXml(QDomElement& element) {
|
||||
return TerminalData::valideXml(element);
|
||||
}
|
||||
|
||||
@@ -104,8 +102,8 @@ void PartTerminal::paint(
|
||||
painter -> save();
|
||||
|
||||
// annulation des renderhints
|
||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||
|
||||
QPen t;
|
||||
|
||||
@@ -56,8 +56,12 @@ class PartTerminal : public CustomElementGraphicPart {
|
||||
bool fromXml(const QDomElement &) override;
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
void paint(
|
||||
QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *,
|
||||
QWidget *) override;
|
||||
|
||||
QPainterPath shape() const override;
|
||||
QPainterPath shadowShape() const override {return shape();}
|
||||
@@ -75,7 +79,7 @@ class PartTerminal : public CustomElementGraphicPart {
|
||||
|
||||
private:
|
||||
void updateSecondPoint();
|
||||
TerminalData* d; // pointer to the terminal data
|
||||
TerminalData* d{nullptr}; // pointer to the terminal data
|
||||
|
||||
private:
|
||||
QPointF saved_position_;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -76,7 +76,7 @@ bool PartText::fromXml(const QDomElement &xml_element)
|
||||
if (size < 1) {
|
||||
size = 20;
|
||||
}
|
||||
QFont font_ = this->font();
|
||||
QFont font_ = this -> font();
|
||||
font_.setPointSize(size);
|
||||
setFont(font_);
|
||||
}
|
||||
|
||||
@@ -58,9 +58,11 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
||||
int type() const override { return Type; }
|
||||
QString name() const override { return(QObject::tr("texte", "element part name")); }
|
||||
QString xmlName() const override { return(QString("text")); }
|
||||
bool fromXml(const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
void setRotation(qreal angle) {(QGraphicsObject::setRotation(QET::correctAngle(angle)));}
|
||||
bool isUseless() const override;
|
||||
QRectF sceneGeometricRect() const override;
|
||||
|
||||
@@ -108,7 +108,7 @@ QDomDocument ExportElementTextPattern::xmlConf() const
|
||||
root.setAttribute("name", m_name);
|
||||
doc.appendChild(root);
|
||||
|
||||
QDomElement elmt = m_element->toXml(doc);
|
||||
QDomElement elmt = m_element->toXml(doc);
|
||||
QDomElement texts = elmt.firstChildElement("dynamic_texts");
|
||||
QDomElement groups = elmt.firstChildElement("texts_groups");
|
||||
|
||||
|
||||
@@ -147,7 +147,15 @@ void Machine_info::send_info_to_debug()
|
||||
+ " x "
|
||||
+ QString::number(pc.screen.height[ii])
|
||||
+ " )";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Machine_info::~Machine_info
|
||||
destructor
|
||||
*/
|
||||
Machine_info::~Machine_info()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
int32_t i_max_screen_height();
|
||||
QString compilation_info();
|
||||
void send_info_to_debug();
|
||||
~Machine_info();
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "propertiesinterface.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
/*!
|
||||
@@ -31,10 +30,20 @@ namespace {
|
||||
const QString colorS = "color";
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PropertiesInterface::PropertiesInterface
|
||||
*/
|
||||
PropertiesInterface::PropertiesInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PropertiesInterface::~PropertiesInterface
|
||||
*/
|
||||
PropertiesInterface::~PropertiesInterface()
|
||||
{
|
||||
}
|
||||
|
||||
bool PropertiesInterface::valideXml(QDomElement& element) {
|
||||
qDebug(QString("ValideXml() is not implemented. File: %1, Line: %2").arg(__FILE__).arg(__LINE__).toStdString().data());
|
||||
return false;
|
||||
@@ -148,7 +157,7 @@ bool PropertiesInterface::attribute(const QDomElement& e, const QString& attribu
|
||||
* \param attribute_name Name of the attribute
|
||||
* \param entier Return value if success
|
||||
* \return True if reading an integer was successful, else False. If the attribute was not found,
|
||||
* \p entier is not valid and the return value is False
|
||||
* \p entier is not valid and the return value is False
|
||||
*/
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier) {
|
||||
|
||||
|
||||
@@ -34,13 +34,40 @@
|
||||
class PropertiesInterface
|
||||
{
|
||||
public:
|
||||
PropertiesInterface();
|
||||
// Save/load properties to setting file. QString is use for prefix a word befor the name of each paramètre
|
||||
virtual void toSettings (QSettings &settings, const QString& = QString()) const {Q_UNUSED(settings)};
|
||||
virtual void fromSettings (const QSettings &settings, const QString& = QString()) {Q_UNUSED(settings)};
|
||||
// Save/load properties to xml element
|
||||
virtual QDomElement toXml (QDomDocument &xml_document) const =0;
|
||||
virtual bool fromXml (const QDomElement &xml_element) =0;
|
||||
PropertiesInterface();
|
||||
virtual ~PropertiesInterface();
|
||||
/**
|
||||
@brief toSettings
|
||||
Save properties to setting file.
|
||||
@param settings : is use for prefix a word
|
||||
befor the name of each paramètre
|
||||
@param QString
|
||||
*/
|
||||
virtual void toSettings(QSettings &,
|
||||
const QString & = QString()) const =0;
|
||||
/**
|
||||
@brief fromSettings
|
||||
load properties to setting file.
|
||||
@param settings : is use for prefix a word
|
||||
befor the name of each paramètre
|
||||
@param QString
|
||||
*/
|
||||
virtual void fromSettings(QSettings &,
|
||||
const QString & = QString()) = 0;
|
||||
/**
|
||||
@brief toXml
|
||||
Save properties to xml element
|
||||
@param xml_document
|
||||
@return QDomElement
|
||||
*/
|
||||
virtual QDomElement toXml (QDomDocument &xml_document) const =0;
|
||||
/**
|
||||
@brief fromXml
|
||||
load properties to xml element
|
||||
@param xml_element
|
||||
@return true / false
|
||||
*/
|
||||
virtual bool fromXml (const QDomElement &xml_element) =0;
|
||||
static bool valideXml(QDomElement& element);
|
||||
|
||||
/*!
|
||||
|
||||
@@ -33,15 +33,33 @@ void TerminalData::setParent(QGraphicsObject* parent)
|
||||
q = parent;
|
||||
}
|
||||
|
||||
void TerminalData::toSettings(QSettings& settings, const QString&) const
|
||||
/**
|
||||
@brief TerminalData::toSettings
|
||||
Save properties to setting file.
|
||||
|
||||
QString is use for prefix a word befor the name of each paramètre
|
||||
@param settings UNUSED
|
||||
@param prefix UNUSED
|
||||
*/
|
||||
void TerminalData::toSettings(QSettings &settings, const QString &prefix) const
|
||||
|
||||
{
|
||||
Q_UNUSED(settings);
|
||||
Q_UNUSED(prefix);
|
||||
}
|
||||
|
||||
void TerminalData::fromSettings(const QSettings& settings, const QString&)
|
||||
/**
|
||||
@brief TerminalData::fromSettings
|
||||
load properties to setting file.
|
||||
|
||||
QString is use for prefix a word befor the name of each paramètre
|
||||
@param settings UNUSED
|
||||
@param prefix UNUSED
|
||||
*/
|
||||
void TerminalData::fromSettings(QSettings &settings, const QString& prefix)
|
||||
{
|
||||
Q_UNUSED(settings);
|
||||
Q_UNUSED(prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +78,8 @@ QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
QDomElement xml_element = xml_document.createElement("terminaldata");
|
||||
|
||||
|
||||
// write the position of the terminal
|
||||
// Write name and number to XML
|
||||
// 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
|
||||
// This is hold for legacy compability reason
|
||||
@@ -72,10 +91,22 @@ QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
||||
return(xml_element);
|
||||
}
|
||||
|
||||
/*
|
||||
@brief TerminalData::fromXml
|
||||
load properties to xml element
|
||||
|
||||
@note This method is only called from the PartTerminal
|
||||
and should never called from the Terminal class
|
||||
@param xml_element
|
||||
@return true if succeeded / false if the attribute is not real
|
||||
*/
|
||||
bool TerminalData::fromXml (const QDomElement &xml_element) // RETURNS True
|
||||
{
|
||||
qreal term_x = 0.0;
|
||||
qreal term_y = 0.0;
|
||||
|
||||
// reads the position of the terminal
|
||||
// lit la position de la borne
|
||||
qreal term_x = 0.0, term_y = 0.0;
|
||||
|
||||
if (propertyDouble(xml_element, "x", &term_x))
|
||||
return false;
|
||||
@@ -85,23 +116,25 @@ bool TerminalData::fromXml (const QDomElement &xml_element) // RETURNS True
|
||||
|
||||
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
|
||||
// to write it to xml file. Terminal::fromXml does not need.
|
||||
// if the attribute not exists, means, the element is created with an
|
||||
// older version of qet. So use the legacy approach
|
||||
|
||||
|
||||
//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"
|
||||
|
||||
QString o;
|
||||
if (propertyString(xml_element, "orientation", &o))
|
||||
return false;
|
||||
|
||||
// read the orientation of the terminal
|
||||
// lit l'orientation de la borne
|
||||
m_orientation = orientationFromString(o);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -113,11 +146,11 @@ bool TerminalData::valideXml(const QDomElement& xml_element) {
|
||||
return false;
|
||||
|
||||
// legacy elements do not have an uuid
|
||||
// if (propertyUuid(xml_element, "uuid"))
|
||||
// return false;
|
||||
// if (propertyUuid(xml_element, "uuid"))
|
||||
// return false;
|
||||
|
||||
//if (propertyString(xml_element, "name")) // some parts do not have a name. Example: affuteuse_250h.qet, Terminal at x="0" y="-20"
|
||||
// return false;
|
||||
// return false;
|
||||
|
||||
if (propertyString(xml_element, "orientation"))
|
||||
return false;
|
||||
|
||||
@@ -26,58 +26,62 @@ class TerminalData : public PropertiesInterface
|
||||
void init();
|
||||
|
||||
void setParent(QGraphicsObject* parent);
|
||||
|
||||
// Save/load properties to setting file. QString is use for prefix a word befor the name of each paramètre
|
||||
void toSettings(
|
||||
QSettings &settings, const QString& = QString()) const override;
|
||||
void fromSettings(
|
||||
const QSettings &settings, const QString& = QString()) override;
|
||||
// Save/load properties to xml element
|
||||
// This method is only called from the PartTerminal and should never called from the Terminal class
|
||||
QDomElement toXml(QDomDocument &xml_element) const override;
|
||||
bool fromXml(const QDomElement &xml_element) override;
|
||||
void toSettings(QSettings &settings,
|
||||
const QString& prefix = QString()) const override;
|
||||
void fromSettings(QSettings &settings,
|
||||
const QString& = QString()) override;
|
||||
QDomElement toXml(QDomDocument &xml_element) const override;
|
||||
bool fromXml(const QDomElement &xml_element) override;
|
||||
|
||||
static bool valideXml(const QDomElement &xml_element);
|
||||
|
||||
// must be public, because this class is a private member of PartTerminal/Terminal and they must
|
||||
// access this data
|
||||
public:
|
||||
/*!
|
||||
* \brief m_orientation
|
||||
* Orientation of the terminal
|
||||
*/
|
||||
public:
|
||||
/**
|
||||
@brief m_orientation
|
||||
Orientation of the terminal
|
||||
*/
|
||||
Qet::Orientation m_orientation{Qet::Orientation::North};
|
||||
/*!
|
||||
* \brief second_point
|
||||
* Position of the second point of the terminal in scene coordinates
|
||||
*/
|
||||
/**
|
||||
@brief second_point
|
||||
Position of the second point of the terminal
|
||||
in scene coordinates
|
||||
*/
|
||||
QPointF second_point{0,0};
|
||||
/*!
|
||||
* \brief m_uuid
|
||||
* Uuid of the terminal.
|
||||
*
|
||||
* In elementscene.cpp an element gets a new uuid when saving the element. In the current state
|
||||
* each connection is made by using the local position of the terminal and a dynamic id. In the new
|
||||
* case, each terminal should have it's own uuid to identify it uniquely. When changing each time this
|
||||
* uuid, the conductor after updating the part is anymore valid. So if in the loaded document a uuid exists,
|
||||
* use this one and don't create a new one.
|
||||
*/
|
||||
QUuid m_uuid; // default is an invalid uuid.
|
||||
/*!
|
||||
* \brief m_name
|
||||
* Name of the element. It can be used to create wiring harness tables
|
||||
*/
|
||||
QString m_name;
|
||||
/**
|
||||
@brief m_uuid
|
||||
Uuid of the terminal.
|
||||
|
||||
/*!
|
||||
* \brief m_pos
|
||||
* Position of the terminal. The second point is calculated from this position and the orientation
|
||||
* Important: this variable is only updated during read from xml and not during mouse move!
|
||||
* It is used to store the initial position so that PartTerminal and Terminal have access to it.
|
||||
*/
|
||||
In elementscene.cpp an element gets a new uuid when
|
||||
saving the element. In the current state
|
||||
each connection is made by using the local position
|
||||
of the terminal and a dynamic id. In the new
|
||||
case, each terminal should have it's own uuid to
|
||||
identify it uniquely. When changing each time this
|
||||
uuid, the conductor after updating the part is anymore
|
||||
valid. So if in the loaded document a uuid exists,
|
||||
use this one and don't create a new one.
|
||||
*/
|
||||
QUuid m_uuid; // default is an invalid uuid.
|
||||
/**
|
||||
@brief m_name
|
||||
Name of the element.
|
||||
It can be used to create wiring harness tables
|
||||
*/
|
||||
QString m_name;
|
||||
|
||||
/**
|
||||
@brief m_pos
|
||||
Position of the terminal. The second point is calculated
|
||||
from this position and the orientation
|
||||
@note
|
||||
Important: this variable is only updated during read
|
||||
from xml and not during mouse move!
|
||||
It is used to store the initial position so that
|
||||
PartTerminal and Terminal have access to it.
|
||||
*/
|
||||
QPointF m_pos{0,0};
|
||||
private:
|
||||
QGraphicsObject* q{nullptr};
|
||||
private:
|
||||
QGraphicsObject* q{nullptr};
|
||||
};
|
||||
|
||||
#endif // TERMINALDATA_H
|
||||
|
||||
@@ -35,9 +35,8 @@ XRefProperties::XRefProperties()
|
||||
@param settings: QSettings to use
|
||||
@param prefix: prefix before properties name
|
||||
*/
|
||||
void XRefProperties::toSettings(
|
||||
QSettings &settings,
|
||||
const QString &prefix) const
|
||||
void XRefProperties::toSettings(QSettings &settings,
|
||||
const QString &prefix) const
|
||||
{
|
||||
settings.setValue(prefix + "showpowerctc", m_show_power_ctc);
|
||||
QString display = m_display == Cross? "cross" : "contacts";
|
||||
@@ -66,7 +65,8 @@ void XRefProperties::toSettings(
|
||||
@param settings: QSettings to use
|
||||
@param prefix: prefix before properties name
|
||||
*/
|
||||
void XRefProperties::fromSettings(const QSettings &settings, const QString &prefix)
|
||||
void XRefProperties::fromSettings(QSettings &settings,
|
||||
const QString &prefix)
|
||||
{
|
||||
m_show_power_ctc = settings.value(prefix + "showpowerctc", true).toBool();
|
||||
QString display = settings.value(prefix + "displayhas", "cross").toString();
|
||||
@@ -101,6 +101,7 @@ QDomElement XRefProperties::toXml(QDomDocument &xml_document) const
|
||||
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"));
|
||||
|
||||
|
||||
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "xrefpos", var.valueToKey(m_xref_pos)));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "offset", m_offset));
|
||||
@@ -146,7 +147,7 @@ bool XRefProperties::fromXml(const QDomElement &xml_element) {
|
||||
propertyString(xml_element, "slave_label", &m_slave_label);
|
||||
QString value;
|
||||
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);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -42,9 +42,10 @@ class XRefProperties : public PropertiesInterface
|
||||
Label
|
||||
};
|
||||
|
||||
void toSettings (QSettings &settings, const QString& = QString()) const override;
|
||||
void fromSettings (const QSettings &settings, const QString& = QString()) override;
|
||||
QDomElement toXml (QDomDocument &xml_document) const override;
|
||||
void toSettings (QSettings &settings, const QString& = QString()) const override;
|
||||
void fromSettings (QSettings &settings,
|
||||
const QString& = QString()) override;
|
||||
QDomElement toXml (QDomDocument &xml_document) const override;
|
||||
bool fromXml(const QDomElement &xml_element) override;
|
||||
|
||||
static QHash<QString, XRefProperties> defaultProperties();
|
||||
@@ -86,7 +87,7 @@ class XRefProperties : public PropertiesInterface
|
||||
QStringList m_prefix_keys{"power","delay","switch"};
|
||||
QString m_master_label{"%f-%l%c"};
|
||||
QString m_slave_label{"(%f-%l%c)"};
|
||||
int m_offset{0};
|
||||
int m_offset{0};
|
||||
QString m_key;
|
||||
};
|
||||
|
||||
|
||||
+10
-4
@@ -28,6 +28,12 @@
|
||||
#include <QActionGroup>
|
||||
|
||||
/**
|
||||
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
||||
en orientation. Si la chaine fait plusieurs caracteres, seul le
|
||||
premier est pris en compte. En cas d'incoherence, Qet::North est
|
||||
retourne.
|
||||
@param s Chaine de caractere cense representer une orientation
|
||||
@return l'orientation designee par la chaine de caractere
|
||||
Indique si deux orientations de Borne sont sur le meme axe (Vertical / Horizontal).
|
||||
@param a La premiere orientation de Borne
|
||||
@param b La seconde orientation de Borne
|
||||
@@ -501,7 +507,7 @@ QString Qet::endTypeToString(const Qet::EndType &end_type) {
|
||||
QET::None est retourne.
|
||||
*/
|
||||
Qet::EndType Qet::endTypeFromString(const QString &string) {
|
||||
if (string == "simple") return(Qet::Simple);
|
||||
if (string == "simple") return(Qet::Simple);
|
||||
else if (string == "triangle") return(Qet::Triangle);
|
||||
else if (string == "circle") return(Qet::Circle);
|
||||
else if (string == "diamond") return(Qet::Diamond);
|
||||
@@ -684,9 +690,9 @@ QActionGroup *QET::depthActionGroup(QObject *parent)
|
||||
QActionGroup *action_group = new QActionGroup(parent);
|
||||
|
||||
QAction *edit_forward = new QAction(QET::Icons::BringForward, QObject::tr("Amener au premier plan"), action_group);
|
||||
QAction *edit_raise = new QAction(QET::Icons::Raise, QObject::tr("Rapprocher"), action_group);
|
||||
QAction *edit_lower = new QAction(QET::Icons::Lower, QObject::tr("Éloigner"), action_group);
|
||||
QAction *edit_backward = new QAction(QET::Icons::SendBackward, QObject::tr("Envoyer au fond"), action_group);
|
||||
QAction *edit_raise = new QAction(QET::Icons::Raise, QObject::tr("Rapprocher"), action_group);
|
||||
QAction *edit_lower = new QAction(QET::Icons::Lower, QObject::tr("Éloigner"), action_group);
|
||||
QAction *edit_backward = new QAction(QET::Icons::SendBackward, QObject::tr("Envoyer au fond"), action_group);
|
||||
|
||||
edit_forward ->setStatusTip(QObject::tr("Ramène la ou les sélections au premier plan"));
|
||||
edit_raise ->setStatusTip(QObject::tr("Rapproche la ou les sélections"));
|
||||
|
||||
@@ -102,8 +102,8 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
||||
}
|
||||
|
||||
//By default, the 4 profils are nuls -> we must to use priv_calculeConductor
|
||||
conductor_profiles.insert(Qt::TopLeftCorner, ConductorProfile());
|
||||
conductor_profiles.insert(Qt::TopRightCorner, ConductorProfile());
|
||||
conductor_profiles.insert(Qt::TopLeftCorner, ConductorProfile());
|
||||
conductor_profiles.insert(Qt::TopRightCorner, ConductorProfile());
|
||||
conductor_profiles.insert(Qt::BottomLeftCorner, ConductorProfile());
|
||||
conductor_profiles.insert(Qt::BottomRightCorner, ConductorProfile());
|
||||
|
||||
@@ -216,7 +216,7 @@ void Conductor::updateConductorPath(const QPointF &p1, Qet::Orientation o1, cons
|
||||
ConductorProfile &conductor_profile = conductor_profiles[currentPathType()];
|
||||
|
||||
Q_ASSERT_X(conductor_profile.segmentsCount(QET::Both) > 1, "Conductor::priv_modifieConductor", "pas de points a modifier");
|
||||
Q_ASSERT_X(!conductor_profile.isNull(), "Conductor::priv_modifieConductor", "pas de profil utilisable");
|
||||
Q_ASSERT_X(!conductor_profile.isNull(), "Conductor::priv_modifieConductor", "pas de profil utilisable");
|
||||
|
||||
// recupere les coordonnees fournies des bornes
|
||||
QPointF new_p1 = mapFromScene(p1);
|
||||
@@ -320,10 +320,10 @@ QHash<ConductorSegmentProfile *, qreal> Conductor::shareOffsetBetweenSegments(
|
||||
|
||||
// on remet le trop-plein dans la reserve d'offset
|
||||
remaining_offset += qAbs(segments_hash[csp]) * getSign(local_offset);
|
||||
//qDebug() << " trop-plein de" << qAbs(segments_hash[csp]) * getSign(local_offset) << "remaining_offset =" << remaining_offset;
|
||||
//qDebug() << " trop-plein de" << qAbs(segments_hash[csp]) * getSign(local_offset) << "remaining_offset =" << remaining_offset;
|
||||
segments_hash[csp] = 0.0;
|
||||
} else {
|
||||
//qDebug() << " offset local de" << local_offset << "accepte";
|
||||
//qDebug() << " offset local de" << local_offset << "accepte";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -355,17 +355,17 @@ void Conductor::generateConductorPath(const QPointF &p1, Qet::Orientation o1, co
|
||||
|
||||
// distingue le depart de l'arrivee : le trajet se fait toujours de gauche a droite (apres prolongation)
|
||||
if (newp1.x() <= newp2.x()) {
|
||||
depart = newp1;
|
||||
arrivee = newp2;
|
||||
depart0 = sp1;
|
||||
arrivee0 = sp2;
|
||||
depart = newp1;
|
||||
arrivee = newp2;
|
||||
depart0 = sp1;
|
||||
arrivee0 = sp2;
|
||||
ori_depart = o1;
|
||||
ori_arrivee = o2;
|
||||
} else {
|
||||
depart = newp2;
|
||||
arrivee = newp1;
|
||||
depart0 = sp2;
|
||||
arrivee0 = sp1;
|
||||
depart = newp2;
|
||||
arrivee = newp1;
|
||||
depart0 = sp2;
|
||||
arrivee0 = sp1;
|
||||
ori_depart = o2;
|
||||
ori_arrivee = o1;
|
||||
}
|
||||
@@ -573,12 +573,20 @@ ConductorTextItem *Conductor::textItem() const
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Conductor::valideXml
|
||||
@param e
|
||||
@return true
|
||||
Methode de validation d'element XML
|
||||
@param e Un element XML sense represente un Conducteur
|
||||
@return true si l'element XML represente bien un Conducteur ; false sinon
|
||||
*/
|
||||
bool Conductor::valideXml(QDomElement &e)
|
||||
{
|
||||
bool Conductor::valideXml(QDomElement &e){
|
||||
|
||||
// // TODO: seems to short! (see fromXML)
|
||||
// if (propertyDouble(e, "x") ||
|
||||
// propertyDouble(e, "y"))
|
||||
// return false;
|
||||
|
||||
// if (propertyBool(e, "freezeLabel"))
|
||||
// return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -949,7 +957,7 @@ void Conductor::pointsToSegments(const QList<QPointF>& points_list) {
|
||||
/**
|
||||
@brief Conductor::fromXml
|
||||
Load the conductor and her information from xml element
|
||||
@param e
|
||||
@param dom_element
|
||||
@return true is loading success else return false
|
||||
*/
|
||||
bool Conductor::fromXml(const QDomElement &dom_element)
|
||||
@@ -978,13 +986,21 @@ bool Conductor::fromXml(const QDomElement &dom_element)
|
||||
return return_;
|
||||
}
|
||||
|
||||
|
||||
// does not support legacy method
|
||||
// dom_element.setAttribute("terminal1", table_adr_id.value(terminal1));
|
||||
QDomElement Conductor::toXml(QDomDocument & doc) const
|
||||
{
|
||||
/*!
|
||||
@brief Conductor::toXml
|
||||
Exporte les caracteristiques du conducteur sous forme d'une element XML.
|
||||
@param dom_document :
|
||||
Le document XML a utiliser pour creer l'element XML
|
||||
@param table_adr_id :
|
||||
Hash stockant les correspondances entre les ids des
|
||||
bornes dans le document XML et leur adresse en memoire
|
||||
@return Un element XML representant le conducteur
|
||||
*/
|
||||
QDomElement Conductor::toXml(QDomDocument & doc) const {
|
||||
QDomElement dom_element = doc.createElement("conductor");
|
||||
|
||||
|
||||
dom_element.appendChild(createXmlProperty(doc, "x", pos().x()));
|
||||
dom_element.appendChild(createXmlProperty(doc, "y", pos().y()));
|
||||
|
||||
@@ -1046,11 +1062,69 @@ QDomElement Conductor::toXml(QDomDocument & doc) const
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Conductor::pathFromXml
|
||||
Generate the path (of the line) from xml file by checking
|
||||
the segments in the xml file
|
||||
@param e
|
||||
@return true if generate path success else return false
|
||||
Exporte les caracteristiques du conducteur sous forme d'une element XML.
|
||||
@param d Le document XML a utiliser pour creer l'element XML
|
||||
@param table_adr_id Hash stockant les correspondances entre les ids des
|
||||
bornes dans le document XML et leur adresse en memoire
|
||||
@return Un element XML representant le conducteur
|
||||
*/
|
||||
//QDomElement Conductor::toXml(QDomDocument &dom_document, QHash<Terminal *, int> &table_adr_id) const
|
||||
//{
|
||||
// QDomElement dom_element = dom_document.createElement("conductor");
|
||||
|
||||
// dom_element.setAttribute("x", QString::number(pos().x()));
|
||||
// dom_element.setAttribute("y", QString::number(pos().y()));
|
||||
|
||||
// // Terminal is uniquely identified by the uuid of the terminal and the element
|
||||
// if (terminal1->uuid().isNull()) {
|
||||
// // legacy method to identify the terminal
|
||||
// dom_element.setAttribute("terminal1", table_adr_id.value(terminal1)); // for backward compability
|
||||
// } else {
|
||||
// dom_element.setAttribute("element1", terminal1->parentElement()->uuid().toString());
|
||||
// dom_element.setAttribute("terminal1", terminal1->uuid().toString());
|
||||
// }
|
||||
|
||||
// if (terminal2->uuid().isNull()) {
|
||||
// // legacy method to identify the terminal
|
||||
// dom_element.setAttribute("terminal2", table_adr_id.value(terminal2)); // for backward compability
|
||||
// } else {
|
||||
// dom_element.setAttribute("element2", terminal2->parentElement()->uuid().toString());
|
||||
// dom_element.setAttribute("terminal2", terminal2->uuid().toString());
|
||||
// }
|
||||
// dom_element.setAttribute("freezeLabel", m_freeze_label? "true" : "false");
|
||||
|
||||
// // on n'exporte les segments du conducteur que si ceux-ci ont
|
||||
// // ete modifies par l'utilisateur
|
||||
// if (modified_path)
|
||||
// {
|
||||
// // parcours et export des segments
|
||||
// QDomElement current_segment;
|
||||
// foreach(ConductorSegment *segment, segmentsList())
|
||||
// {
|
||||
// current_segment = dom_document.createElement("segment");
|
||||
// current_segment.setAttribute("orientation", segment -> isHorizontal() ? "horizontal" : "vertical");
|
||||
// current_segment.setAttribute("length", QString("%1").arg(segment -> length()));
|
||||
// dom_element.appendChild(current_segment);
|
||||
// }
|
||||
// }
|
||||
|
||||
// QDomElement dom_seq = m_autoNum_seq.toXml(dom_document);
|
||||
// dom_element.appendChild(dom_seq);
|
||||
|
||||
// // Export the properties and text
|
||||
// m_properties.toXml(dom_document);
|
||||
// if(m_text_item->wasMovedByUser())
|
||||
// {
|
||||
// dom_element.setAttribute("userx", QString::number(m_text_item->pos().x()));
|
||||
// dom_element.setAttribute("usery", QString::number(m_text_item->pos().y()));
|
||||
// }
|
||||
// if(m_text_item->wasRotateByUser())
|
||||
// dom_element.setAttribute("rotation", QString::number(m_text_item->rotation()));
|
||||
|
||||
// return(dom_element);
|
||||
//}
|
||||
|
||||
/**
|
||||
*/
|
||||
bool Conductor::pathFromXml(const QDomElement &e) {
|
||||
// parcourt les elements XML "segment" et en extrait deux listes de longueurs
|
||||
@@ -1208,7 +1282,7 @@ ConductorSegment *Conductor::middleSegment()
|
||||
QPointF Conductor::posForText(Qt::Orientations &flag)
|
||||
{
|
||||
|
||||
ConductorSegment *segment = segments;
|
||||
ConductorSegment *segment = segments;
|
||||
bool all_segment_is_vertical = true;
|
||||
bool all_segment_is_horizontal = true;
|
||||
|
||||
@@ -1327,7 +1401,7 @@ void Conductor::calculateTextItemPosition()
|
||||
}
|
||||
|
||||
//Adjust the position of text if his rotation
|
||||
//is 0° or 270°, to be exactly centered to the conductor
|
||||
//is 0?? or 270??, to be exactly centered to the conductor
|
||||
if (m_text_item -> rotation() == 0)
|
||||
{
|
||||
text_pos.rx() -= m_text_item -> boundingRect().width()/2;
|
||||
@@ -1604,12 +1678,12 @@ void Conductor::displayedTextChanged()
|
||||
new_value.setValue(new_properties);
|
||||
|
||||
|
||||
QUndoCommand *undo = new QUndoCommand(tr("Modifier les propriétés d'un conducteur", "undo caption"));
|
||||
QUndoCommand *undo = new QUndoCommand(tr("Modifier les propri??t??s d'un conducteur", "undo caption"));
|
||||
new QPropertyUndoCommand(this, "properties", old_value, new_value, undo);
|
||||
|
||||
if (!relatedPotentialConductors().isEmpty())
|
||||
{
|
||||
undo->setText(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
|
||||
undo->setText(tr("Modifier les propri??t??s de plusieurs conducteurs", "undo caption"));
|
||||
|
||||
foreach (Conductor *potential_conductor, relatedPotentialConductors())
|
||||
{
|
||||
@@ -1695,7 +1769,7 @@ QSet<Conductor *> Conductor::relatedPotentialConductors(const bool all_diagram,
|
||||
*/
|
||||
QETDiagramEditor* Conductor::diagramEditor() const
|
||||
{
|
||||
if (!diagram()) return nullptr;
|
||||
if (!diagram()) return nullptr;
|
||||
if (diagram() -> views().isEmpty()) return nullptr;
|
||||
|
||||
QWidget *w = const_cast<QGraphicsView *>(diagram() -> views().at(0));
|
||||
@@ -1986,7 +2060,7 @@ QPointF Conductor::movePointIntoPolygon(const QPointF &point, const QPainterPath
|
||||
qreal length = qAbs(QLineF(points.at(i), point).length());
|
||||
if (minimum_length < 0 || length < minimum_length) {
|
||||
minimum_length = length;
|
||||
point_index = i;
|
||||
point_index = i;
|
||||
}
|
||||
}
|
||||
// on connait desormais le coin le plus proche du texte
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -51,13 +51,13 @@ class Conductor : public QGraphicsObject, public PropertiesInterface
|
||||
|
||||
signals:
|
||||
void propertiesChange();
|
||||
|
||||
|
||||
public:
|
||||
Conductor(Terminal *, Terminal *);
|
||||
~Conductor() override;
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
|
||||
private:
|
||||
Conductor(const Conductor &);
|
||||
|
||||
@@ -67,7 +67,7 @@ class Conductor : public QGraphicsObject, public PropertiesInterface
|
||||
|
||||
Terminal *terminal1;
|
||||
Terminal *terminal2;
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
@brief type
|
||||
@@ -101,9 +101,10 @@ class Conductor : public QGraphicsObject, public PropertiesInterface
|
||||
|
||||
public:
|
||||
static bool valideXml (QDomElement &);
|
||||
bool fromXml (const QDomElement &) override;
|
||||
//QDomElement toXml (QDomDocument &, QHash<Terminal *, int> &) const;
|
||||
QDomElement toXml (QDomDocument &doc) const override;
|
||||
bool fromXml (const QDomElement &) override;
|
||||
QDomElement toXml (QDomDocument &doc) const override;
|
||||
void toSettings(QSettings &, const QString & = QString()) const override {}
|
||||
void fromSettings(QSettings &, const QString & = QString()) override {}
|
||||
private:
|
||||
bool pathFromXml(const QDomElement &);
|
||||
|
||||
@@ -145,10 +146,10 @@ class Conductor : public QGraphicsObject, public PropertiesInterface
|
||||
|
||||
public:
|
||||
void setFreezeLabel(bool freeze);
|
||||
|
||||
|
||||
public slots:
|
||||
void displayedTextChanged();
|
||||
|
||||
|
||||
protected:
|
||||
void mouseDoubleClickEvent(
|
||||
QGraphicsSceneMouseEvent *event) override;
|
||||
@@ -164,7 +165,7 @@ class Conductor : public QGraphicsObject, public PropertiesInterface
|
||||
|
||||
private:
|
||||
void adjusteHandlerPos();
|
||||
|
||||
|
||||
void handlerMousePressEvent(
|
||||
QetGraphicsHandlerItem *qghi,
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
@@ -176,8 +177,8 @@ class Conductor : public QGraphicsObject, public PropertiesInterface
|
||||
QGraphicsSceneMouseEvent *event);
|
||||
void addHandler();
|
||||
void removeHandler();
|
||||
|
||||
|
||||
|
||||
|
||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||
int m_vector_index = -1;
|
||||
bool m_mouse_over{false};
|
||||
@@ -210,7 +211,7 @@ class Conductor : public QGraphicsObject, public PropertiesInterface
|
||||
static QBrush conductor_brush;
|
||||
static bool pen_and_brush_initialized;
|
||||
QPainterPath m_path;
|
||||
|
||||
|
||||
private:
|
||||
void segmentsToPath();
|
||||
void saveProfile(bool = true);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
*/
|
||||
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
|
||||
DiagramTextItem(parent_conductor),
|
||||
parent_conductor_(parent_conductor)
|
||||
parent_conductor_(parent_conductor)
|
||||
{
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
@@ -61,13 +61,13 @@ Conductor *ConductorTextItem::parentConductor() const
|
||||
}
|
||||
|
||||
void ConductorTextItem::toXml(QDomDocument& doc, QDomElement& e) {
|
||||
if(moved_by_user_)
|
||||
{
|
||||
e.appendChild(PropertiesInterface::createXmlProperty(doc, "userx", pos().x()));
|
||||
e.appendChild(PropertiesInterface::createXmlProperty(doc, "usery", pos().y()));
|
||||
}
|
||||
if(rotate_by_user_)
|
||||
e.appendChild(PropertiesInterface::createXmlProperty(doc, "rotation", rotation()));
|
||||
if(moved_by_user_)
|
||||
{
|
||||
e.appendChild(PropertiesInterface::createXmlProperty(doc, "userx", pos().x()));
|
||||
e.appendChild(PropertiesInterface::createXmlProperty(doc, "usery", pos().y()));
|
||||
}
|
||||
if(rotate_by_user_)
|
||||
e.appendChild(PropertiesInterface::createXmlProperty(doc, "rotation", rotation()));
|
||||
}
|
||||
|
||||
|
||||
@@ -78,18 +78,18 @@ void ConductorTextItem::toXml(QDomDocument& doc, QDomElement& e) {
|
||||
*/
|
||||
void ConductorTextItem::fromXml(const QDomElement &e) {
|
||||
|
||||
double userx=0, usery=0;
|
||||
if (PropertiesInterface::propertyDouble(e, "userx", &userx) == PropertiesInterface::PropertyFlags::Success &&
|
||||
PropertiesInterface::propertyDouble(e, "usery", &usery) == PropertiesInterface::PropertyFlags::Success) {
|
||||
setPos(userx, usery);
|
||||
moved_by_user_ = true;
|
||||
}
|
||||
double userx=0, usery=0;
|
||||
if (PropertiesInterface::propertyDouble(e, "userx", &userx) == PropertiesInterface::PropertyFlags::Success &&
|
||||
PropertiesInterface::propertyDouble(e, "usery", &usery) == PropertiesInterface::PropertyFlags::Success) {
|
||||
setPos(userx, usery);
|
||||
moved_by_user_ = true;
|
||||
}
|
||||
|
||||
double rotation;
|
||||
if (PropertiesInterface::propertyDouble(e, "rotation", &rotation) == PropertiesInterface::PropertyFlags::Success) {
|
||||
setRotation(rotation);
|
||||
rotate_by_user_ = true;
|
||||
}
|
||||
double rotation;
|
||||
if (PropertiesInterface::propertyDouble(e, "rotation", &rotation) == PropertiesInterface::PropertyFlags::Success) {
|
||||
setRotation(rotation);
|
||||
rotate_by_user_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -53,7 +53,7 @@ class ConductorTextItem : public DiagramTextItem
|
||||
|
||||
protected:
|
||||
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *) override;
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
#include "qetapp.h"
|
||||
#include "richtext/richtexteditor_p.h"
|
||||
#include "diagram.h"
|
||||
#include "dynamicelementtextitem.h"
|
||||
|
||||
|
||||
/**
|
||||
@brief DiagramTextItem::DiagramTextItem
|
||||
@@ -220,24 +218,12 @@ QRectF DiagramTextItem::frameRect() const
|
||||
|
||||
void DiagramTextItem::setHtml(const QString &text)
|
||||
{
|
||||
DynamicElementTextItem* abc = dynamic_cast<DynamicElementTextItem*>(this);
|
||||
if (abc) {
|
||||
if (abc->searchedElement) {
|
||||
int stop = 1;
|
||||
}
|
||||
}
|
||||
QGraphicsTextItem::setHtml(text);
|
||||
m_is_html = true;
|
||||
}
|
||||
|
||||
void DiagramTextItem::setPlainText(const QString &text)
|
||||
{
|
||||
DynamicElementTextItem* abc = dynamic_cast<DynamicElementTextItem*>(this);
|
||||
if (abc) {
|
||||
if (abc->searchedElement) {
|
||||
int stop = 1;
|
||||
}
|
||||
}
|
||||
QGraphicsTextItem::setPlainText(text);
|
||||
m_is_html = false;
|
||||
}
|
||||
@@ -257,16 +243,6 @@ bool DiagramTextItem::isHtml() const
|
||||
*/
|
||||
void DiagramTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
|
||||
DynamicElementTextItem* abc = dynamic_cast<DynamicElementTextItem*>(this);
|
||||
if (abc) {
|
||||
if (abc->searchedElement) {
|
||||
int stop = 1;
|
||||
QString text = toPlainText();
|
||||
qDebug() << text;
|
||||
}
|
||||
}
|
||||
|
||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||
QGraphicsTextItem::paint(painter, option, widget);
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -54,7 +54,7 @@ DynamicElementTextItem::DynamicElementTextItem(Element *parent_element) :
|
||||
this->m_parent_element->diagram()->undoStack().push(undo);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Option when text is displayed in multiple line
|
||||
QTextOption option = document()->defaultTextOption();
|
||||
option.setAlignment(Qt::AlignHCenter);
|
||||
@@ -87,7 +87,7 @@ DynamicElementTextItem::DynamicElementTextItem()
|
||||
QDomElement DynamicElementTextItem::toXml(QDomDocument &dom_doc) const
|
||||
{
|
||||
QDomElement root_element = dom_doc.createElement(xmlTagName());
|
||||
|
||||
|
||||
root_element.setAttribute("x", QString::number(pos().x()));
|
||||
root_element.setAttribute("y", QString::number(pos().y()));
|
||||
root_element.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
|
||||
@@ -95,10 +95,10 @@ QDomElement DynamicElementTextItem::toXml(QDomDocument &dom_doc) const
|
||||
root_element.setAttribute("frame", m_frame? "true" : "false");
|
||||
root_element.setAttribute("text_width", QString::number(m_text_width));
|
||||
root_element.setAttribute("font", font().toString());
|
||||
|
||||
|
||||
QMetaEnum me = textFromMetaEnum();
|
||||
root_element.setAttribute("text_from", me.valueToKey(m_text_from));
|
||||
|
||||
|
||||
me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
if(this->alignment() &Qt::AlignRight)
|
||||
root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignRight));
|
||||
@@ -106,19 +106,19 @@ QDomElement DynamicElementTextItem::toXml(QDomDocument &dom_doc) const
|
||||
root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignLeft));
|
||||
else if(this->alignment() &Qt::AlignHCenter)
|
||||
root_element.setAttribute("Halignment", me.valueToKey(Qt::AlignHCenter));
|
||||
|
||||
|
||||
if(this->alignment() &Qt::AlignBottom)
|
||||
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignBottom));
|
||||
else if(this->alignment() & Qt::AlignTop)
|
||||
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignTop));
|
||||
else if(this->alignment() &Qt::AlignVCenter)
|
||||
root_element.setAttribute("Valignment", me.valueToKey(Qt::AlignVCenter));
|
||||
|
||||
|
||||
|
||||
|
||||
QDomElement dom_text = dom_doc.createElement("text");
|
||||
dom_text.appendChild(dom_doc.createTextNode(toPlainText()));
|
||||
root_element.appendChild(dom_text);
|
||||
|
||||
|
||||
//Info name
|
||||
if(!m_info_name.isEmpty())
|
||||
{
|
||||
@@ -126,7 +126,7 @@ QDomElement DynamicElementTextItem::toXml(QDomDocument &dom_doc) const
|
||||
dom_info_name.appendChild(dom_doc.createTextNode(m_info_name));
|
||||
root_element.appendChild(dom_info_name);
|
||||
}
|
||||
|
||||
|
||||
//Composite text
|
||||
if(!m_composite_text.isEmpty())
|
||||
{
|
||||
@@ -134,7 +134,7 @@ QDomElement DynamicElementTextItem::toXml(QDomDocument &dom_doc) const
|
||||
dom_comp_text.appendChild(dom_doc.createTextNode(m_composite_text));
|
||||
root_element.appendChild(dom_comp_text);
|
||||
}
|
||||
|
||||
|
||||
//Color
|
||||
if(color() != QColor(Qt::black))
|
||||
{
|
||||
@@ -142,7 +142,7 @@ QDomElement DynamicElementTextItem::toXml(QDomDocument &dom_doc) const
|
||||
dom_color.appendChild(dom_doc.createTextNode(color().name()));
|
||||
root_element.appendChild(dom_color);
|
||||
}
|
||||
|
||||
|
||||
return root_element;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ void DynamicElementTextItem::fromXml(const QDomElement &dom_elmt)
|
||||
qDebug() << "DynamicElementTextItem::fromXml : Wrong tagg name";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QGraphicsTextItem::setRotation(dom_elmt.attribute("rotation", QString::number(0)).toDouble());
|
||||
|
||||
if (dom_elmt.hasAttribute("font"))
|
||||
@@ -177,11 +177,11 @@ void DynamicElementTextItem::fromXml(const QDomElement &dom_elmt)
|
||||
m_uuid = QUuid(dom_elmt.attribute("uuid", QUuid::createUuid().toString()));
|
||||
setFrame(dom_elmt.attribute("frame", "false") == "true"? true : false);
|
||||
setTextWidth(dom_elmt.attribute("text_width", QString::number(-1)).toDouble());
|
||||
|
||||
|
||||
//Text from
|
||||
QMetaEnum me = textFromMetaEnum();
|
||||
setTextFrom(DynamicElementTextItem::TextFrom(me.keyToValue(dom_elmt.attribute("text_from").toStdString().data())));
|
||||
|
||||
|
||||
me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
if(dom_elmt.hasAttribute("Halignment"))
|
||||
setAlignment(Qt::Alignment(me.keyToValue(dom_elmt.attribute("Halignment").toStdString().data())));
|
||||
@@ -200,7 +200,7 @@ void DynamicElementTextItem::fromXml(const QDomElement &dom_elmt)
|
||||
QDomElement dom_info_name = dom_elmt.firstChildElement("info_name");
|
||||
if(!dom_info_name.isNull())
|
||||
setInfoName(dom_info_name.text());
|
||||
|
||||
|
||||
//Composite text
|
||||
QDomElement dom_comp_text = dom_elmt.firstChildElement("composite_text");
|
||||
if(!dom_comp_text.isNull())
|
||||
@@ -210,10 +210,10 @@ void DynamicElementTextItem::fromXml(const QDomElement &dom_elmt)
|
||||
QDomElement dom_color = dom_elmt.firstChildElement("color");
|
||||
if(!dom_color.isNull())
|
||||
setColor(QColor(dom_color.text()));
|
||||
|
||||
|
||||
//Force the update of the displayed text
|
||||
setTextFrom(m_text_from); // TODO: does not update because there is a retrun inside if the textfrom argument is the same as m_text_from
|
||||
|
||||
|
||||
QGraphicsTextItem::setPos(dom_elmt.attribute("x", QString::number(0)).toDouble(),
|
||||
dom_elmt.attribute("y", QString::number(0)).toDouble());
|
||||
}
|
||||
@@ -241,7 +241,7 @@ ElementTextItemGroup *DynamicElementTextItem::parentGroup() const
|
||||
if(ElementTextItemGroup *grp = dynamic_cast<ElementTextItemGroup *>(parentItem()))
|
||||
return grp;
|
||||
}
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ Element *DynamicElementTextItem::elementUseForInfo() const
|
||||
Element *elmt = parentElement();
|
||||
if(!elmt)
|
||||
return nullptr;
|
||||
|
||||
|
||||
switch (elmt->linkType())
|
||||
{
|
||||
case Element::Simple:
|
||||
@@ -325,18 +325,15 @@ DynamicElementTextItem::TextFrom DynamicElementTextItem::textFrom() const
|
||||
*/
|
||||
void DynamicElementTextItem::setTextFrom(DynamicElementTextItem::TextFrom text_from)
|
||||
{
|
||||
|
||||
if (searchedElement)
|
||||
int stop = true;
|
||||
if(m_text_from == text_from)
|
||||
return;
|
||||
|
||||
|
||||
setNoEditable(text_from == UserText? false : true);
|
||||
clearFormulaConnection();
|
||||
|
||||
|
||||
TextFrom old_text_from = m_text_from;
|
||||
m_text_from = text_from;
|
||||
|
||||
|
||||
if(m_text_from == UserText)
|
||||
{
|
||||
setPlainText(m_text);
|
||||
@@ -351,7 +348,7 @@ void DynamicElementTextItem::setTextFrom(DynamicElementTextItem::TextFrom text_f
|
||||
}
|
||||
else
|
||||
setPlainText(elementUseForInfo()->elementInformations().value(m_info_name).toString());
|
||||
|
||||
|
||||
if(old_text_from == UserText)
|
||||
connect(elementUseForInfo(), &Element::elementInfoChange, this, &DynamicElementTextItem::elementInfoChanged);
|
||||
}
|
||||
@@ -364,15 +361,15 @@ void DynamicElementTextItem::setTextFrom(DynamicElementTextItem::TextFrom text_f
|
||||
}
|
||||
else
|
||||
setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, elementUseForInfo()->elementInformations()));
|
||||
|
||||
|
||||
if(old_text_from == UserText)
|
||||
connect(elementUseForInfo(), &Element::elementInfoChange, this, &DynamicElementTextItem::elementInfoChanged);
|
||||
}
|
||||
|
||||
|
||||
if(m_parent_element.data()->linkType() == Element::Master ||
|
||||
m_parent_element.data()->linkType() == Element::Slave)
|
||||
updateXref();
|
||||
|
||||
|
||||
emit textFromChanged(m_text_from);
|
||||
}
|
||||
|
||||
@@ -392,9 +389,6 @@ QString DynamicElementTextItem::text() const
|
||||
*/
|
||||
void DynamicElementTextItem::setText(const QString &text)
|
||||
{
|
||||
if (m_text == "14" && text == "")
|
||||
int a = 54;
|
||||
m_text_old = m_text;
|
||||
m_text = text;
|
||||
if(m_text_from == DynamicElementTextItem::UserText)
|
||||
setPlainText(m_text);
|
||||
@@ -411,10 +405,7 @@ void DynamicElementTextItem::setInfoName(const QString &info_name)
|
||||
QString old_info_name = m_info_name;
|
||||
m_info_name = info_name;
|
||||
|
||||
if (searchedElement)
|
||||
int stop = true;
|
||||
|
||||
|
||||
|
||||
if(old_info_name == "label")
|
||||
{
|
||||
clearFormulaConnection();
|
||||
@@ -438,7 +429,7 @@ void DynamicElementTextItem::setInfoName(const QString &info_name)
|
||||
}
|
||||
}
|
||||
else if (m_info_name == "label" && elementUseForInfo())
|
||||
{
|
||||
{
|
||||
setupFormulaConnection();
|
||||
updateLabel();
|
||||
updateXref();
|
||||
@@ -446,7 +437,7 @@ void DynamicElementTextItem::setInfoName(const QString &info_name)
|
||||
else if(elementUseForInfo() && m_text_from == DynamicElementTextItem::ElementInfo) {
|
||||
setPlainText(elementUseForInfo()->elementInformations().value(info_name).toString());
|
||||
}
|
||||
|
||||
|
||||
emit infoNameChanged(info_name);
|
||||
}
|
||||
|
||||
@@ -468,7 +459,7 @@ void DynamicElementTextItem::setCompositeText(const QString &text)
|
||||
{
|
||||
QString old_composite_text = m_composite_text;
|
||||
m_composite_text = text;
|
||||
|
||||
|
||||
if(old_composite_text.contains("%{label}"))
|
||||
{
|
||||
clearFormulaConnection();
|
||||
@@ -487,7 +478,7 @@ void DynamicElementTextItem::setCompositeText(const QString &text)
|
||||
removeConnectionForReportFormula(m_report_formula);
|
||||
if(m_composite_text.contains("%{label}"))
|
||||
setConnectionForReportFormula(m_report_formula);
|
||||
|
||||
|
||||
updateReportText();
|
||||
}
|
||||
else if (m_composite_text.contains("%{label}") && elementUseForInfo())
|
||||
@@ -503,7 +494,7 @@ void DynamicElementTextItem::setCompositeText(const QString &text)
|
||||
dc = elementUseForInfo()->elementInformations();
|
||||
setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, dc));
|
||||
}
|
||||
|
||||
|
||||
emit compositeTextChanged(m_composite_text);
|
||||
}
|
||||
|
||||
@@ -548,7 +539,7 @@ void DynamicElementTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
if(m_slave_Xref_item)
|
||||
m_slave_Xref_item->setDefaultTextColor(Qt::black);
|
||||
}
|
||||
|
||||
|
||||
DiagramTextItem::mousePressEvent(event);
|
||||
}
|
||||
|
||||
@@ -557,33 +548,33 @@ void DynamicElementTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
@param event
|
||||
*/
|
||||
void DynamicElementTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
{
|
||||
if((event->buttons() & Qt::LeftButton) && (flags() & ItemIsMovable))
|
||||
{
|
||||
if(diagram() && m_first_move)
|
||||
diagram()->elementTextsMover().beginMovement(diagram(), this);
|
||||
|
||||
|
||||
if(m_first_move)
|
||||
{
|
||||
m_initial_position = pos();
|
||||
if(parentElement())
|
||||
parentElement()->setHighlighted(true);
|
||||
}
|
||||
|
||||
|
||||
QPointF current_parent_pos;
|
||||
QPointF button_down_parent_pos;
|
||||
current_parent_pos = mapToParent(mapFromScene(event->scenePos()));
|
||||
button_down_parent_pos = mapToParent(mapFromScene(event->buttonDownScenePos(Qt::LeftButton)));
|
||||
|
||||
|
||||
QPointF new_pos = m_initial_position + current_parent_pos - button_down_parent_pos;
|
||||
event->modifiers() == Qt::ControlModifier ? setPos(new_pos) : setPos(Diagram::snapToGrid(new_pos));
|
||||
|
||||
|
||||
if(diagram())
|
||||
diagram()->elementTextsMover().continueMovement(event);
|
||||
} else {
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
|
||||
if(m_first_move)
|
||||
m_first_move = false;
|
||||
}
|
||||
@@ -596,10 +587,10 @@ void DynamicElementTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (m_parent_element)
|
||||
m_parent_element->setHighlighted(false);
|
||||
|
||||
|
||||
if(m_parent_element && m_parent_element->diagram())
|
||||
m_parent_element.data()->diagram()->elementTextsMover().endMovement();
|
||||
|
||||
|
||||
if(!(event->modifiers() & Qt::ControlModifier))
|
||||
QGraphicsTextItem::mouseReleaseEvent(event);
|
||||
}
|
||||
@@ -627,12 +618,12 @@ void DynamicElementTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *eve
|
||||
void DynamicElementTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
DiagramTextItem::hoverEnterEvent(event);
|
||||
|
||||
|
||||
//If the text is selected we set the real color, otherwise the editor will display the color of text as blue,
|
||||
//but this is not the color set by the user.
|
||||
if(isSelected())
|
||||
return;
|
||||
|
||||
|
||||
if ((parentElement()->linkType() & Element::AllReport) && m_other_report)
|
||||
{
|
||||
if( (m_text_from == ElementInfo && m_info_name == "label") ||
|
||||
@@ -651,25 +642,25 @@ void DynamicElementTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
void DynamicElementTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
DiagramTextItem::hoverLeaveEvent(event);
|
||||
|
||||
|
||||
if(m_user_color.isValid())
|
||||
{
|
||||
setDefaultTextColor(m_user_color);
|
||||
m_user_color = QColor(); //m_user_color is now invalid
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void DynamicElementTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
DiagramTextItem::paint(painter, option, widget);
|
||||
|
||||
|
||||
if (m_frame)
|
||||
{
|
||||
painter->save();
|
||||
painter->setFont(QETApp::dynamicTextsItemFont(font().pointSize()));
|
||||
|
||||
//Adjust the thickness according to the font size,
|
||||
|
||||
//Adjust the thickness according to the font size,
|
||||
qreal w=0.3;
|
||||
if(font().pointSize() >= 5)
|
||||
{
|
||||
@@ -677,7 +668,7 @@ void DynamicElementTextItem::paint(QPainter *painter, const QStyleOptionGraphics
|
||||
if(w > 2.5)
|
||||
w = 2.5;
|
||||
}
|
||||
|
||||
|
||||
QPen pen;
|
||||
pen.setColor(color());
|
||||
pen.setWidthF(w);
|
||||
@@ -687,7 +678,7 @@ void DynamicElementTextItem::paint(QPainter *painter, const QStyleOptionGraphics
|
||||
//Adjust the rounding of the rectangle according to the size of the font
|
||||
qreal ro = font().pointSizeF()/3;
|
||||
painter->drawRoundedRect(frameRect(), ro, ro);
|
||||
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
@@ -700,7 +691,7 @@ QVariant DynamicElementTextItem::itemChange(QGraphicsItem::GraphicsItemChange ch
|
||||
{
|
||||
if(m_parent_element.isNull())
|
||||
return QGraphicsObject::itemChange(change, value);
|
||||
|
||||
|
||||
//If the parent is slave, we keep aware about the changement of master.
|
||||
if(m_parent_element.data()->linkType() == Element::Slave)
|
||||
{
|
||||
@@ -717,13 +708,13 @@ QVariant DynamicElementTextItem::itemChange(QGraphicsItem::GraphicsItemChange ch
|
||||
m_report_formula = m_parent_element.data()->diagram()->project()->defaultReportProperties();
|
||||
m_report_formula_con = connect(m_parent_element.data()->diagram()->project(), &QETProject::reportPropertiesChanged, this, &DynamicElementTextItem::reportFormulaChanged);
|
||||
}
|
||||
|
||||
|
||||
//Add connection to keep up to date the status of the element linked to the parent folio report of this text.
|
||||
connect(m_parent_element.data(), &Element::linkedElementChanged, this, &DynamicElementTextItem::reportChanged);
|
||||
//The parent is already linked, we call reportChanged for init the connection
|
||||
if(!m_parent_element.data()->linkedElements().isEmpty())
|
||||
reportChanged();
|
||||
|
||||
|
||||
if(m_parent_element.data()->terminals().size())
|
||||
{
|
||||
//Add connection to keep up date the conductors added or removed to the parent folio report element
|
||||
@@ -741,7 +732,7 @@ QVariant DynamicElementTextItem::itemChange(QGraphicsItem::GraphicsItemChange ch
|
||||
if(!m_parent_element.data()->linkedElements().isEmpty())
|
||||
updateXref();
|
||||
}
|
||||
|
||||
|
||||
m_first_scene_change = false;
|
||||
return QGraphicsObject::itemChange(change, value);
|
||||
}
|
||||
@@ -750,7 +741,7 @@ QVariant DynamicElementTextItem::itemChange(QGraphicsItem::GraphicsItemChange ch
|
||||
updateXref();
|
||||
updateXref();
|
||||
}
|
||||
|
||||
|
||||
return QGraphicsObject::itemChange(change, value);
|
||||
}
|
||||
|
||||
@@ -758,7 +749,7 @@ bool DynamicElementTextItem::sceneEventFilter(QGraphicsItem *watched, QEvent *ev
|
||||
{
|
||||
if(watched != m_slave_Xref_item)
|
||||
return false;
|
||||
|
||||
|
||||
if(event->type() == QEvent::GraphicsSceneHoverEnter) {
|
||||
m_slave_Xref_item->setDefaultTextColor(Qt::blue);
|
||||
return true;
|
||||
@@ -771,7 +762,7 @@ bool DynamicElementTextItem::sceneEventFilter(QGraphicsItem *watched, QEvent *ev
|
||||
zoomToLinkedElement();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -782,7 +773,7 @@ void DynamicElementTextItem::elementInfoChanged()
|
||||
if(element) {
|
||||
dc = element->elementInformations();
|
||||
}
|
||||
|
||||
|
||||
QString final_text;
|
||||
|
||||
|
||||
@@ -808,12 +799,12 @@ void DynamicElementTextItem::elementInfoChanged()
|
||||
//connection if the label is created from a formula
|
||||
if (m_composite_text.contains("%{label}"))
|
||||
setupFormulaConnection();
|
||||
|
||||
|
||||
final_text = autonum::AssignVariables::replaceVariable(m_composite_text, dc);
|
||||
}
|
||||
else if (m_text_from == UserText)
|
||||
final_text = m_text;
|
||||
|
||||
|
||||
setPlainText(final_text);
|
||||
emit plainTextChanged();
|
||||
}
|
||||
@@ -832,16 +823,16 @@ void DynamicElementTextItem::masterChanged()
|
||||
m_master_element.clear();
|
||||
updateXref();
|
||||
}
|
||||
|
||||
|
||||
if(elementUseForInfo())
|
||||
{
|
||||
m_master_element = elementUseForInfo();
|
||||
if(m_text_from == ElementInfo || m_text_from == CompositeText)
|
||||
connect(m_master_element.data(), &Element::elementInfoChange, this, &DynamicElementTextItem::elementInfoChanged);
|
||||
|
||||
|
||||
updateXref();
|
||||
}
|
||||
|
||||
|
||||
//Because master changed we update this text
|
||||
elementInfoChanged();
|
||||
}
|
||||
@@ -868,23 +859,23 @@ void DynamicElementTextItem::reportChanged()
|
||||
m_report_formula_con = connect(parentElement()->diagram()->project(), &QETProject::reportPropertiesChanged, this, &DynamicElementTextItem::reportFormulaChanged);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool text_have_label = false;
|
||||
|
||||
|
||||
if((textFrom() == ElementInfo && m_info_name == "label") ||
|
||||
(textFrom() == CompositeText && m_composite_text.contains("%{label}")))
|
||||
text_have_label = true;
|
||||
|
||||
|
||||
if(text_have_label)
|
||||
removeConnectionForReportFormula(m_report_formula);
|
||||
|
||||
|
||||
m_other_report.clear();
|
||||
if(!m_parent_element.data()->linkedElements().isEmpty())
|
||||
m_other_report = m_parent_element.data()->linkedElements().first();
|
||||
|
||||
|
||||
//Because linked report was changed, we ensure there is a conductor watched
|
||||
setPotentialConductor();
|
||||
|
||||
|
||||
if(text_have_label)
|
||||
{
|
||||
setConnectionForReportFormula(m_report_formula);
|
||||
@@ -899,7 +890,7 @@ void DynamicElementTextItem::reportChanged()
|
||||
void DynamicElementTextItem::reportFormulaChanged()
|
||||
{
|
||||
m_report_formula = parentElement()->diagram()->project()->defaultReportProperties();
|
||||
|
||||
|
||||
if(m_text_from == ElementInfo && m_info_name == "label")
|
||||
updateReportText();
|
||||
}
|
||||
@@ -908,11 +899,11 @@ void DynamicElementTextItem::setConnectionForReportFormula(const QString &formul
|
||||
{
|
||||
if(m_other_report.isNull() || formula.isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
Element *other_elmt = m_other_report.data();
|
||||
QString string = formula;
|
||||
Diagram *other_diagram = m_other_report.data()->diagram();
|
||||
|
||||
|
||||
//Because the variable %F is a reference to another text which can contain variables,
|
||||
//we must to replace %F by the real text, to check if the real text contain the variable %id
|
||||
if (other_diagram && string.contains("%F"))
|
||||
@@ -921,7 +912,7 @@ void DynamicElementTextItem::setConnectionForReportFormula(const QString &formul
|
||||
string.replace("%F", other_diagram->border_and_titleblock.folio());
|
||||
connect(&other_diagram->border_and_titleblock, &BorderTitleBlock::titleBlockFolioChanged, this, &DynamicElementTextItem::updateReportFormulaConnection);
|
||||
}
|
||||
|
||||
|
||||
if (other_diagram && (string.contains("%f") || string.contains("%id")))
|
||||
{
|
||||
connect(other_diagram->project(), &QETProject::projectDiagramsOrderChanged, this, &DynamicElementTextItem::updateReportText);
|
||||
@@ -937,11 +928,11 @@ void DynamicElementTextItem::removeConnectionForReportFormula(const QString &for
|
||||
{
|
||||
if(m_other_report.isNull() || formula.isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
Element *other_element = m_other_report.data();
|
||||
QString string = formula;
|
||||
Diagram *other_diagram = m_other_report.data()->diagram();
|
||||
|
||||
|
||||
//Because the variable %F is a reference to another text which can contain variables,
|
||||
//we must to replace %F by the real text, to check if the real text contain the variable %id
|
||||
if (other_diagram && string.contains("%F"))
|
||||
@@ -949,14 +940,14 @@ void DynamicElementTextItem::removeConnectionForReportFormula(const QString &for
|
||||
string.replace("%F", m_F_str);
|
||||
disconnect(&other_diagram->border_and_titleblock, &BorderTitleBlock::titleBlockFolioChanged, this, &DynamicElementTextItem::updateReportFormulaConnection);
|
||||
}
|
||||
|
||||
|
||||
if (other_diagram && (string.contains("%f") || string.contains("%id")))
|
||||
disconnect(other_diagram->project(), &QETProject::projectDiagramsOrderChanged, this, &DynamicElementTextItem::updateReportText);
|
||||
if (string.contains("%l"))
|
||||
disconnect(other_element, &Element::yChanged, this, &DynamicElementTextItem::updateReportText);
|
||||
if (string.contains("%c"))
|
||||
disconnect(other_element, &Element::xChanged, this, &DynamicElementTextItem::updateReportText);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -969,25 +960,25 @@ void DynamicElementTextItem::setupFormulaConnection()
|
||||
(m_text_from == CompositeText && m_composite_text.contains("%{label}")))
|
||||
{
|
||||
clearFormulaConnection();
|
||||
|
||||
|
||||
Element *element = elementUseForInfo();
|
||||
if (!element)
|
||||
return;
|
||||
|
||||
|
||||
Diagram *diagram = element->diagram();
|
||||
QString formula = element->elementInformations().value("formula").toString();
|
||||
|
||||
//Label is frozen, so we don't update it.
|
||||
if (element->isFreezeLabel())
|
||||
return;
|
||||
|
||||
|
||||
if (diagram && formula.contains("%F"))
|
||||
{
|
||||
m_F_str = diagram->border_and_titleblock.folio();
|
||||
formula.replace("%F", m_F_str);
|
||||
m_formula_connection << connect(&diagram->border_and_titleblock, &BorderTitleBlock::titleBlockFolioChanged, this, &DynamicElementTextItem::updateLabel);
|
||||
}
|
||||
|
||||
|
||||
if (diagram && (formula.contains("%f") || formula.contains("%id")))
|
||||
{
|
||||
m_formula_connection << connect(diagram->project(), &QETProject::projectDiagramsOrderChanged, this, &DynamicElementTextItem::updateLabel);
|
||||
@@ -997,7 +988,7 @@ void DynamicElementTextItem::setupFormulaConnection()
|
||||
m_formula_connection << connect(element, &Element::yChanged, this, &DynamicElementTextItem::updateLabel);
|
||||
if (formula.contains("%c"))
|
||||
m_formula_connection << connect(element, &Element::xChanged, this, &DynamicElementTextItem::updateLabel);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1012,7 +1003,7 @@ void DynamicElementTextItem::updateReportFormulaConnection()
|
||||
{
|
||||
if(!(m_parent_element.data()->linkType() & Element::AllReport))
|
||||
return;
|
||||
|
||||
|
||||
removeConnectionForReportFormula(m_report_formula);
|
||||
setConnectionForReportFormula(m_report_formula);
|
||||
updateReportText();
|
||||
@@ -1026,7 +1017,7 @@ void DynamicElementTextItem::updateReportText()
|
||||
{
|
||||
if(!(m_parent_element.data()->linkType() & Element::AllReport))
|
||||
return;
|
||||
|
||||
|
||||
if (m_text_from == ElementInfo && m_info_name == "label")
|
||||
{
|
||||
if(m_other_report)
|
||||
@@ -1062,7 +1053,7 @@ void DynamicElementTextItem::updateLabel()
|
||||
if(element) {
|
||||
dc = element->elementInformations();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(m_text_from == ElementInfo && element) {
|
||||
setPlainText(element->actualLabel());
|
||||
@@ -1110,7 +1101,7 @@ void DynamicElementTextItem::setPotentialConductor()
|
||||
{
|
||||
if(parentElement()->terminals().isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
/*
|
||||
* #First case, if m_watched_conductor is a conductor of the parent report, everything is ok
|
||||
* #Second case, if the conductors list of parent report element is not empty,
|
||||
@@ -1120,14 +1111,14 @@ void DynamicElementTextItem::setPotentialConductor()
|
||||
* #third case, if m_watched_conductor is null, we set a conductor of the linked report, if any.
|
||||
*/
|
||||
QList<Conductor *> c_list = parentElement()->terminals().first()->conductors();
|
||||
|
||||
|
||||
if(!c_list.isEmpty() && c_list.contains(m_watched_conductor.data()))
|
||||
return;
|
||||
else if(!c_list.isEmpty())
|
||||
{
|
||||
if(!m_watched_conductor.isNull())
|
||||
disconnect(m_watched_conductor.data(), &Conductor::propertiesChange, this, &DynamicElementTextItem::conductorPropertiesChanged);
|
||||
|
||||
|
||||
m_watched_conductor = c_list.first();
|
||||
connect(m_watched_conductor.data(), &Conductor::propertiesChange, this, &DynamicElementTextItem::conductorPropertiesChanged);
|
||||
}
|
||||
@@ -1144,7 +1135,7 @@ void DynamicElementTextItem::setPotentialConductor()
|
||||
{
|
||||
if(!m_watched_conductor.isNull())
|
||||
disconnect(m_watched_conductor.data(), &Conductor::propertiesChange, this, &DynamicElementTextItem::conductorPropertiesChanged);
|
||||
|
||||
|
||||
m_watched_conductor.clear();
|
||||
}
|
||||
}
|
||||
@@ -1183,11 +1174,11 @@ void DynamicElementTextItem::conductorPropertiesChanged()
|
||||
QString DynamicElementTextItem::reportReplacedCompositeText() const
|
||||
{
|
||||
QString string;
|
||||
|
||||
|
||||
if(m_parent_element.data()->linkType() & Element::AllReport)
|
||||
{
|
||||
string = m_composite_text;
|
||||
|
||||
|
||||
if (string.contains("%{label}") && m_other_report)
|
||||
{
|
||||
Element *elmt = m_other_report.data();
|
||||
@@ -1207,7 +1198,7 @@ QString DynamicElementTextItem::reportReplacedCompositeText() const
|
||||
string.replace("%{conductor_section}", m_watched_conductor.data()->properties().m_wire_section);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@@ -1220,9 +1211,9 @@ void DynamicElementTextItem::zoomToLinkedElement()
|
||||
{
|
||||
if(!parentElement())
|
||||
return;
|
||||
|
||||
|
||||
Element *zoomed_element = nullptr;
|
||||
|
||||
|
||||
if(parentElement()->linkType() == Element::Slave && m_master_element)
|
||||
{
|
||||
if ((m_text_from == ElementInfo && m_info_name == "label") ||
|
||||
@@ -1235,18 +1226,18 @@ void DynamicElementTextItem::zoomToLinkedElement()
|
||||
(m_text_from == CompositeText && m_composite_text.contains("%{label}")))
|
||||
zoomed_element = m_other_report.data();
|
||||
}
|
||||
|
||||
|
||||
if(zoomed_element)
|
||||
{
|
||||
//Unselect and ungrab mouse to prevent unwanted
|
||||
//move when linked element is in the same scene of this.
|
||||
setSelected(false);
|
||||
ungrabMouse();
|
||||
|
||||
|
||||
if(scene() != zoomed_element->scene())
|
||||
zoomed_element->diagram()->showMe();
|
||||
zoomed_element->setSelected(true);
|
||||
|
||||
|
||||
//Zoom to the element
|
||||
for(QGraphicsView *view : zoomed_element->scene()->views())
|
||||
{
|
||||
@@ -1268,7 +1259,7 @@ void DynamicElementTextItem::updateXref()
|
||||
if(m_parent_element.data()->linkType() == Element::Master)
|
||||
{
|
||||
XRefProperties xrp = diagram()->project()->defaultXRefProperties(m_parent_element.data()->kindInformations()["type"].toString());
|
||||
|
||||
|
||||
if(m_text_from == DynamicElementTextItem::ElementInfo &&
|
||||
m_info_name == "label" &&
|
||||
!m_parent_element.data()->linkedElements().isEmpty() &&
|
||||
@@ -1295,19 +1286,19 @@ void DynamicElementTextItem::updateXref()
|
||||
XRefProperties xrp = diagram()->project()->defaultXRefProperties(m_master_element.data()->kindInformations()["type"].toString());
|
||||
QString xref_label = xrp.slaveLabel();
|
||||
xref_label = autonum::AssignVariables::formulaToLabel(xref_label, m_master_element.data()->rSequenceStruct(), m_master_element.data()->diagram(), m_master_element.data());
|
||||
|
||||
|
||||
if(!m_slave_Xref_item)
|
||||
{
|
||||
m_slave_Xref_item = new QGraphicsTextItem(xref_label, this);
|
||||
m_slave_Xref_item->setFont(QETApp::diagramTextsFont(5));
|
||||
m_slave_Xref_item->installSceneEventFilter(this);
|
||||
|
||||
m_update_slave_Xref_connection << connect(m_master_element.data(), &Element::xChanged, this, &DynamicElementTextItem::updateXref);
|
||||
m_update_slave_Xref_connection << connect(m_master_element.data(), &Element::yChanged, this, &DynamicElementTextItem::updateXref);
|
||||
m_update_slave_Xref_connection << connect(m_master_element.data(), &Element::elementInfoChange, this, &DynamicElementTextItem::updateXref);
|
||||
m_update_slave_Xref_connection << connect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &DynamicElementTextItem::updateXref);
|
||||
m_update_slave_Xref_connection << connect(diagram()->project(), &QETProject::diagramRemoved, this, &DynamicElementTextItem::updateXref);
|
||||
m_update_slave_Xref_connection << connect(diagram()->project(), &QETProject::XRefPropertiesChanged, this, &DynamicElementTextItem::updateXref);
|
||||
|
||||
m_update_slave_Xref_connection << connect(m_master_element.data(), &Element::xChanged, this, &DynamicElementTextItem::updateXref);
|
||||
m_update_slave_Xref_connection << connect(m_master_element.data(), &Element::yChanged, this, &DynamicElementTextItem::updateXref);
|
||||
m_update_slave_Xref_connection << connect(m_master_element.data(), &Element::elementInfoChange, this, &DynamicElementTextItem::updateXref);
|
||||
m_update_slave_Xref_connection << connect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &DynamicElementTextItem::updateXref);
|
||||
m_update_slave_Xref_connection << connect(diagram()->project(), &QETProject::diagramRemoved, this, &DynamicElementTextItem::updateXref);
|
||||
m_update_slave_Xref_connection << connect(diagram()->project(), &QETProject::XRefPropertiesChanged, this, &DynamicElementTextItem::updateXref);
|
||||
}
|
||||
else
|
||||
m_slave_Xref_item->setPlainText(xref_label);
|
||||
@@ -1323,7 +1314,7 @@ void DynamicElementTextItem::updateXref()
|
||||
delete m_Xref_item;
|
||||
m_Xref_item = nullptr;
|
||||
}
|
||||
|
||||
|
||||
if(m_slave_Xref_item)
|
||||
{
|
||||
delete m_slave_Xref_item;
|
||||
@@ -1334,8 +1325,6 @@ void DynamicElementTextItem::updateXref()
|
||||
|
||||
void DynamicElementTextItem::setPlainText(const QString &text)
|
||||
{
|
||||
if (text == "14")
|
||||
searchedElement = true;
|
||||
if (toPlainText() == text)
|
||||
return;
|
||||
|
||||
@@ -1346,13 +1335,13 @@ void DynamicElementTextItem::setPlainText(const QString &text)
|
||||
if (m_parent_element.data()->state() == QET::GIBuildingFromXml ||
|
||||
m_parent_element.data()->state() == QET::GILoadingFromXml)
|
||||
update_alignment = false;
|
||||
|
||||
|
||||
if (update_alignment) {
|
||||
prepareAlignment();
|
||||
}
|
||||
|
||||
|
||||
DiagramTextItem::setPlainText(text);
|
||||
|
||||
|
||||
//User define a text width
|
||||
if (m_text_width > 0)
|
||||
{
|
||||
@@ -1365,11 +1354,11 @@ void DynamicElementTextItem::setPlainText(const QString &text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (update_alignment) {
|
||||
finishAlignment();
|
||||
}
|
||||
|
||||
|
||||
if (m_Xref_item) {
|
||||
m_Xref_item->autoPos();
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -33,7 +33,7 @@ class CrossRefItem;
|
||||
@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 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
|
||||
{
|
||||
@@ -77,7 +77,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
||||
private:
|
||||
DynamicElementTextItem ();
|
||||
DynamicElementTextItem(const DynamicElementTextItem &);
|
||||
|
||||
|
||||
public:
|
||||
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||
void fromXml(const QDomElement &dom_elmt) override;
|
||||
@@ -104,7 +104,6 @@ class DynamicElementTextItem : public DiagramTextItem
|
||||
void setTextWidth(qreal width);
|
||||
void setXref_item(Qt::AlignmentFlag m_exHrefPos);
|
||||
|
||||
bool searchedElement{false};
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
@@ -141,20 +140,22 @@ class DynamicElementTextItem : public DiagramTextItem
|
||||
m_master_element,
|
||||
m_other_report;
|
||||
QPointer <Conductor> m_watched_conductor;
|
||||
QString m_text,
|
||||
m_text_old,
|
||||
m_info_name,
|
||||
m_composite_text,
|
||||
m_report_formula,
|
||||
m_F_str;
|
||||
QString
|
||||
m_text,
|
||||
m_info_name,
|
||||
m_composite_text,
|
||||
m_report_formula,
|
||||
m_F_str;
|
||||
DynamicElementTextItem::TextFrom m_text_from = UserText;
|
||||
QUuid m_uuid;
|
||||
QMetaObject::Connection m_report_formula_con;
|
||||
QList<QMetaObject::Connection> m_formula_connection,
|
||||
m_update_slave_Xref_connection;
|
||||
QList<QMetaObject::Connection>
|
||||
m_formula_connection,
|
||||
m_update_slave_Xref_connection;
|
||||
QColor m_user_color{QColor()};
|
||||
bool m_frame = false,
|
||||
m_first_scene_change = true;
|
||||
bool
|
||||
m_frame = false,
|
||||
m_first_scene_change = true;
|
||||
CrossRefItem *m_Xref_item = nullptr;
|
||||
QGraphicsTextItem *m_slave_Xref_item = nullptr;
|
||||
qreal m_text_width = -1;
|
||||
|
||||
@@ -73,15 +73,16 @@ class ElementXmlRetroCompatibility
|
||||
|
||||
/**
|
||||
@brief Element::Element
|
||||
New element from xml
|
||||
@param location, location of this element
|
||||
@param parent, parent graphics item
|
||||
@param state, state of the instanciation
|
||||
@param location : location of this element
|
||||
@param parent : parent graphics item
|
||||
@param state : state of the instanciation
|
||||
@param link_type
|
||||
*/
|
||||
Element::Element(
|
||||
const ElementsLocation &location,
|
||||
QGraphicsItem *parent,
|
||||
int *state, kind link_type) :
|
||||
int *state,
|
||||
kind link_type) :
|
||||
QetGraphicsItem(parent),
|
||||
m_link_type (link_type),
|
||||
m_location (location)
|
||||
@@ -337,8 +338,8 @@ void Element::drawSelection(
|
||||
Q_UNUSED(options);
|
||||
painter -> save();
|
||||
// Annulation des renderhints
|
||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||
// Dessin du cadre de selection en gris
|
||||
QPen t;
|
||||
@@ -420,9 +421,9 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
||||
if (conv_ok && QET::version.toDouble() < element_version)
|
||||
{
|
||||
std::cerr << qPrintable(
|
||||
QObject::tr("Avertissement : l'élément "
|
||||
" a été enregistré avec une version"
|
||||
" ultérieure de QElectroTech.")
|
||||
QObject::tr("Avertissement : l'??l??ment "
|
||||
" a ??t?? enregistr?? avec une version"
|
||||
" ult??rieure de QElectroTech.")
|
||||
) << std::endl;
|
||||
}
|
||||
}
|
||||
@@ -476,8 +477,7 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
||||
if (elmts.tagName() == "description")
|
||||
{
|
||||
//Minor workaround to find if there is a "input" tagg as label.
|
||||
//If not, we set the tagg "label" to the first "input. Why one must have a tagg label?
|
||||
// is label a required field?
|
||||
//If not, we set the tagg "label" to the first "input.
|
||||
QList <QDomElement> input_field;
|
||||
bool have_label = false;
|
||||
for (QDomElement input_node = node.firstChildElement("input") ;
|
||||
@@ -506,7 +506,7 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
||||
continue;
|
||||
|
||||
qDebug() << "\t\tElement.cpp:buildFromXml;parseElement: " << qde.tagName();
|
||||
|
||||
|
||||
if (parseElement(qde)) { // TODO: why lines are not parsed here?
|
||||
qDebug() << "\t\t\tParsing Element success";
|
||||
++ parsed_elements_count;
|
||||
@@ -540,10 +540,10 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
||||
return(false);
|
||||
}
|
||||
|
||||
if (state)
|
||||
*state = 0;
|
||||
m_state = QET::GIOK;
|
||||
return(true);
|
||||
if (state)
|
||||
*state = 0;
|
||||
m_state = QET::GIOK;
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -554,8 +554,8 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
||||
*/
|
||||
bool Element::parseElement(const QDomElement &dom)
|
||||
{
|
||||
if (dom.tagName() == "terminal") return(parseTerminal(dom));
|
||||
else if (dom.tagName() == "input") return(parseInput(dom));
|
||||
if (dom.tagName() == "terminal") return(parseTerminal(dom));
|
||||
else if (dom.tagName() == "input") return(parseInput(dom));
|
||||
else if (dom.tagName() == "dynamic_text") return(parseDynamicText(dom));
|
||||
else return(true);
|
||||
}
|
||||
@@ -647,12 +647,6 @@ DynamicElementTextItem *Element::parseDynamicText(
|
||||
*/
|
||||
Terminal *Element::parseTerminal(const QDomElement &dom_element)
|
||||
{
|
||||
TerminalData* data = new TerminalData();
|
||||
if (!data->fromXml(dom_element)) {
|
||||
delete data;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!Terminal::valideXml(dom_element))
|
||||
return nullptr;
|
||||
|
||||
@@ -671,7 +665,8 @@ Terminal *Element::parseTerminal(const QDomElement &dom_element)
|
||||
else
|
||||
return (a->dockConductor().y() < b->dockConductor().y());
|
||||
});
|
||||
return(new_terminal); // TODO: makes not sense
|
||||
|
||||
return(new_terminal); // TODO: makes no sense
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -685,8 +680,8 @@ bool Element::valideXml(QDomElement &e) {
|
||||
|
||||
// verifie la presence des attributs minimaux
|
||||
if (!e.hasAttribute("type")) return(false);
|
||||
if (!e.hasAttribute("x")) return(false);
|
||||
if (!e.hasAttribute("y")) return(false);
|
||||
if (!e.hasAttribute("x")) return(false);
|
||||
if (!e.hasAttribute("y")) return(false);
|
||||
|
||||
bool conv_ok;
|
||||
// parse l'abscisse
|
||||
@@ -713,8 +708,7 @@ bool Element::valideXml(QDomElement &e) {
|
||||
*/
|
||||
bool Element::fromXml(
|
||||
QDomElement &e,
|
||||
QHash<int,
|
||||
Terminal *> &table_id_adr)
|
||||
QHash<int, Terminal *> &table_id_adr)
|
||||
{
|
||||
m_state = QET::GILoadingFromXml;
|
||||
/*
|
||||
@@ -722,7 +716,8 @@ bool Element::fromXml(
|
||||
ce recensement servira lors de la mise en place des fils
|
||||
*/
|
||||
QList<QDomElement> liste_terminals; // terminals in the element in the diagram
|
||||
foreach(QDomElement qde, QET::findInDomElement(e, "terminals", "terminal")) {
|
||||
foreach(QDomElement qde,
|
||||
QET::findInDomElement(e, "terminals", "terminal")) {
|
||||
if (Terminal::valideXml(qde)) liste_terminals << qde;
|
||||
}
|
||||
|
||||
@@ -733,8 +728,7 @@ bool Element::fromXml(
|
||||
for(QGraphicsItem *qgi: childItems()) { // TODO: Where the Terminals are added as childs?
|
||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) {
|
||||
bool terminal_trouvee = false;
|
||||
for(QDomElement qde: liste_terminals)
|
||||
{
|
||||
for(QDomElement qde: liste_terminals) {
|
||||
// The position in the collection element definition is the origin position (originPos).
|
||||
// The position in the diagram element definition is the position where the conductor is connected (dock position)
|
||||
// Therefore a simple operator overloading is not possible.
|
||||
@@ -782,15 +776,15 @@ bool Element::fromXml(
|
||||
}
|
||||
// copie des associations id / adr
|
||||
foreach(int id_trouve, priv_id_adr.keys()) {
|
||||
table_id_adr.insert(id_trouve,
|
||||
table_id_adr.insert(id_trouve,
|
||||
priv_id_adr.value(id_trouve));
|
||||
}
|
||||
}
|
||||
|
||||
//load uuid of connected elements
|
||||
QList <QDomElement> uuid_list = QET::findInDomElement(e,
|
||||
"links_uuids",
|
||||
"link_uuid");
|
||||
QList <QDomElement> uuid_list = QET::findInDomElement(e, "links_uuids", "link_uuid");
|
||||
foreach (QDomElement qdo, uuid_list) tmp_uuids_link << qdo.attribute("uuid");
|
||||
|
||||
foreach (QDomElement qdo, uuid_list)
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
tmp_uuids_link << qdo.attribute("uuid");
|
||||
@@ -809,8 +803,6 @@ bool Element::fromXml(
|
||||
QString fl = e.attribute("freezeLabel", "false");
|
||||
m_freeze_label = fl == "false"? false : true;
|
||||
|
||||
// TODO: why element information is not read?
|
||||
|
||||
//Load Sequential Values
|
||||
if (e.hasAttribute("sequ_1")
|
||||
|| e.hasAttribute("sequf_1")
|
||||
@@ -846,10 +838,11 @@ bool Element::fromXml(
|
||||
|
||||
//************************//
|
||||
//***Dynamic texts item***//
|
||||
//************************//
|
||||
// read from the diagram section
|
||||
// this is not done in the older versions, because there only inputs are available.
|
||||
for (const QDomElement& qde : QET::findInDomElement(e, "dynamic_texts", DynamicElementTextItem::xmlTagName()))
|
||||
//************************// read from the diagram section
|
||||
for (const QDomElement& qde : QET::findInDomElement(
|
||||
e,
|
||||
"dynamic_texts",
|
||||
DynamicElementTextItem::xmlTagName()))
|
||||
{
|
||||
DynamicElementTextItem *deti = new DynamicElementTextItem(this);
|
||||
addDynamicTextItem(deti);
|
||||
@@ -859,27 +852,27 @@ bool Element::fromXml(
|
||||
//************************//
|
||||
//***Element texts item***//
|
||||
//************************//
|
||||
|
||||
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input"); // inputs in diagram section
|
||||
|
||||
//First case, we check for the text item converted to dynamic text item
|
||||
const QList <DynamicElementTextItem *> conv_deti_list =
|
||||
m_converted_text_from_xml_description.keys();
|
||||
QList <DynamicElementTextItem *> successfully_converted;
|
||||
const QList <QDomElement> dom_inputs = inputs;
|
||||
|
||||
// TODO: Legacy (0.7 and prior)
|
||||
for (DynamicElementTextItem *deti : conv_deti_list) // elements read from the element collection definition
|
||||
for (DynamicElementTextItem *deti : conv_deti_list)
|
||||
{
|
||||
for(const QDomElement& dom_input : dom_inputs) // elements in the diagram section
|
||||
for(const QDomElement& dom_input : dom_inputs)
|
||||
{
|
||||
|
||||
//we use the same method used in ElementTextItem::fromXml to compar and know if the input dom element is for one of the text stored.
|
||||
//The comparaison is made from the text position : if the position of the text is the same as the position stored in 'input' dom element
|
||||
//that mean this is the good text
|
||||
// This is only used when in the diagram description the text elements are stored in the "inputs" section. In 0.8 and higher,
|
||||
// texts are stored in directly in the "dynamic_elmt_text" section
|
||||
if (qFuzzyCompare(qreal(dom_input.attribute("x").toDouble()), m_converted_text_from_xml_description.value(deti).x()) &&
|
||||
qFuzzyCompare(qreal(dom_input.attribute("y").toDouble()), m_converted_text_from_xml_description.value(deti).y()))
|
||||
//we use the same method used in ElementTextItem::fromXml
|
||||
//to compar and know if the input dom element is for one of the text stored.
|
||||
//The comparaison is made from the text position :
|
||||
//if the position of the text is the same as the position stored in 'input' dom element
|
||||
//that mean this is the good text
|
||||
if (qFuzzyCompare(qreal(dom_input.attribute("x").toDouble()),
|
||||
m_converted_text_from_xml_description.value(deti).x()) &&
|
||||
qFuzzyCompare(qreal(dom_input.attribute("y").toDouble()),
|
||||
m_converted_text_from_xml_description.value(deti).y()))
|
||||
{
|
||||
//Once again this 'if', is only for retrocompatibility with old old old project
|
||||
//when element text with tagg "label" is not null, but the element information "label" is.
|
||||
@@ -1083,6 +1076,7 @@ bool Element::fromXml(
|
||||
}
|
||||
|
||||
QPointF pos = deti->pos();
|
||||
// TODO: check
|
||||
if (m_link_type !=PreviousReport
|
||||
|| m_link_type !=NextReport)
|
||||
{
|
||||
@@ -1186,8 +1180,8 @@ bool Element::fromXml(
|
||||
\~ @return The XML element representing this electrical element
|
||||
\~French L'element XML representant cet element electrique
|
||||
*/
|
||||
|
||||
QDomElement Element::toXml(QDomDocument &document) const
|
||||
QDomElement Element::toXml(
|
||||
QDomDocument &document) const
|
||||
{
|
||||
QDomElement element = document.createElement("element");
|
||||
|
||||
@@ -1214,6 +1208,7 @@ QDomElement Element::toXml(QDomDocument &document) const
|
||||
element.setAttribute("z", QString::number(this->zValue()));
|
||||
element.setAttribute("orientation", QString::number(orientation()));
|
||||
|
||||
// registration of device terminals
|
||||
// enregistrement des bornes de l'appareil
|
||||
QDomElement xml_terminals = document.createElement("terminals");
|
||||
// for each child of the element
|
||||
|
||||
@@ -46,20 +46,22 @@ class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
|
||||
public:
|
||||
/**
|
||||
@brief The kind enum
|
||||
Used to know the kind of this element (master, slave, report ect...)
|
||||
Used to know the kind of this element
|
||||
(master, slave, report ect...)
|
||||
*/
|
||||
enum kind {Simple = 1,
|
||||
NextReport = 2,
|
||||
PreviousReport = 4,
|
||||
AllReport = 6,
|
||||
Master = 8,
|
||||
Slave = 16,
|
||||
Terminale = 32};
|
||||
enum kind {
|
||||
Simple = 1,
|
||||
NextReport = 2,
|
||||
PreviousReport = 4,
|
||||
AllReport = 6,
|
||||
Master = 8,
|
||||
Slave = 16,
|
||||
Terminale = 32};
|
||||
|
||||
Element(
|
||||
const ElementsLocation &location,
|
||||
QGraphicsItem * parent= nullptr, int *state = nullptr,
|
||||
Element::kind link_type = Element::Simple);
|
||||
Element(const ElementsLocation &location,
|
||||
QGraphicsItem * = nullptr,
|
||||
int *state = nullptr,
|
||||
Element::kind link_type = Element::Simple);
|
||||
~Element() override;
|
||||
private:
|
||||
Element(const Element &);
|
||||
@@ -128,10 +130,11 @@ class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
|
||||
QPoint hotspot() const;
|
||||
void editProperty() override;
|
||||
static bool valideXml(QDomElement &);
|
||||
virtual bool fromXml(QDomElement &, QHash<int, Terminal *> &);
|
||||
virtual bool fromXml(QDomElement &, QHash<int, Terminal *> &);
|
||||
virtual QDomElement toXml(QDomDocument &) const;
|
||||
QUuid uuid() const;
|
||||
int orientation() const;
|
||||
|
||||
//METHODS related to texts
|
||||
void addDynamicTextItem(DynamicElementTextItem *deti = nullptr);
|
||||
void removeDynamicTextItem(DynamicElementTextItem *deti);
|
||||
@@ -157,7 +160,7 @@ class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
|
||||
QList<Element *> linkedElements ();
|
||||
virtual kind linkType() const {return m_link_type;} // return the linkable type
|
||||
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:
|
||||
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
@@ -206,9 +209,9 @@ class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
|
||||
|
||||
//ATTRIBUTES related to linked element
|
||||
QList <Element *> connected_elements;
|
||||
QList <QUuid> tmp_uuids_link;
|
||||
QUuid m_uuid;
|
||||
kind m_link_type = Element::Simple;
|
||||
QList <QUuid> tmp_uuids_link;
|
||||
QUuid m_uuid;
|
||||
kind m_link_type = Element::Simple;
|
||||
|
||||
//ATTRIBUTES related to informations
|
||||
DiagramContext m_element_informations, m_kind_informations;
|
||||
|
||||
@@ -316,8 +316,8 @@ void ElementTextItemGroup::setHoldToBottomPage(bool hold)
|
||||
&Element::linkedElementChanged,
|
||||
[this]()
|
||||
{QTimer::singleShot(200,
|
||||
this,
|
||||
&ElementTextItemGroup::autoPos);}
|
||||
this,
|
||||
&ElementTextItemGroup::autoPos);}
|
||||
);
|
||||
if(m_parent_element->diagram())
|
||||
m_XrefChanged_timer = connect(
|
||||
@@ -325,8 +325,8 @@ void ElementTextItemGroup::setHoldToBottomPage(bool hold)
|
||||
&QETProject::XRefPropertiesChanged,
|
||||
[this]()
|
||||
{QTimer::singleShot(200,
|
||||
this,
|
||||
&ElementTextItemGroup::autoPos);}
|
||||
this,
|
||||
&ElementTextItemGroup::autoPos);}
|
||||
);
|
||||
}
|
||||
autoPos();
|
||||
@@ -623,7 +623,7 @@ void ElementTextItemGroup::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if(diagram() && m_first_move)
|
||||
diagram()->elementTextsMover().beginMovement(diagram(),
|
||||
this);
|
||||
this);
|
||||
|
||||
if(m_first_move)
|
||||
{
|
||||
@@ -706,7 +706,7 @@ void ElementTextItemGroup::mouseDoubleClickEvent(
|
||||
*/
|
||||
void ElementTextItemGroup::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if(event->modifiers() == Qt::ControlModifier)
|
||||
if(event->modifiers() == Qt::ControlModifier)
|
||||
{
|
||||
if(event->key() == Qt::Key_Left && m_alignment != Qt::AlignLeft)
|
||||
{
|
||||
@@ -800,12 +800,12 @@ void ElementTextItemGroup::updateXref()
|
||||
m_slave_Xref_item = new QGraphicsTextItem(xref_label, this);
|
||||
m_slave_Xref_item->setFont(QETApp::diagramTextsFont(5));
|
||||
|
||||
m_update_slave_Xref_connection << connect(master_elmt, &Element::xChanged, this, &ElementTextItemGroup::updateXref);
|
||||
m_update_slave_Xref_connection << connect(master_elmt, &Element::yChanged, this, &ElementTextItemGroup::updateXref);
|
||||
m_update_slave_Xref_connection << connect(master_elmt, &Element::elementInfoChange, this, &ElementTextItemGroup::updateXref);
|
||||
m_update_slave_Xref_connection << connect(project, &QETProject::projectDiagramsOrderChanged, this, &ElementTextItemGroup::updateXref);
|
||||
m_update_slave_Xref_connection << connect(project, &QETProject::diagramRemoved, this, &ElementTextItemGroup::updateXref);
|
||||
m_update_slave_Xref_connection << connect(project, &QETProject::XRefPropertiesChanged, this, &ElementTextItemGroup::updateXref);
|
||||
m_update_slave_Xref_connection << connect(master_elmt, &Element::xChanged, this, &ElementTextItemGroup::updateXref);
|
||||
m_update_slave_Xref_connection << connect(master_elmt, &Element::yChanged, this, &ElementTextItemGroup::updateXref);
|
||||
m_update_slave_Xref_connection << connect(master_elmt, &Element::elementInfoChange, this, &ElementTextItemGroup::updateXref);
|
||||
m_update_slave_Xref_connection << connect(project, &QETProject::projectDiagramsOrderChanged, this, &ElementTextItemGroup::updateXref);
|
||||
m_update_slave_Xref_connection << connect(project, &QETProject::diagramRemoved, this, &ElementTextItemGroup::updateXref);
|
||||
m_update_slave_Xref_connection << connect(project, &QETProject::XRefPropertiesChanged, this, &ElementTextItemGroup::updateXref);
|
||||
}
|
||||
else
|
||||
m_slave_Xref_item->setPlainText(xref_label);
|
||||
|
||||
@@ -35,7 +35,7 @@ class CrossRefItem;
|
||||
class ElementTextItemGroup : public QObject, public QGraphicsItemGroup // TODO: derive from PropertiesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
|
||||
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
|
||||
Q_PROPERTY(int verticalAdjustment READ verticalAdjustment WRITE setVerticalAdjustment NOTIFY verticalAdjustmentChanged)
|
||||
@@ -43,7 +43,7 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup // TODO:
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
Q_PROPERTY(bool holdToBottomPage READ holdToBottomPage WRITE setHoldToBottomPage NOTIFY holdToBottomPageChanged)
|
||||
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
|
||||
|
||||
|
||||
public:
|
||||
signals:
|
||||
void rotationChanged(qreal);
|
||||
@@ -54,14 +54,14 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup // TODO:
|
||||
void xChanged();
|
||||
void yChanged();
|
||||
void frameChanged(bool frame);
|
||||
|
||||
|
||||
public:
|
||||
ElementTextItemGroup(const QString &name, Element *parent);
|
||||
~ElementTextItemGroup() override;
|
||||
void addToGroup(QGraphicsItem *item);
|
||||
void removeFromGroup(QGraphicsItem *item);
|
||||
void blockAlignmentUpdate(bool block);
|
||||
|
||||
|
||||
void setAlignment(Qt::Alignment alignement);
|
||||
Qt::Alignment alignment() const;
|
||||
void updateAlignment();
|
||||
@@ -76,11 +76,11 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup // TODO:
|
||||
QList<DynamicElementTextItem *> texts() const;
|
||||
Diagram *diagram() const;
|
||||
Element *parentElement() const;
|
||||
|
||||
|
||||
QDomElement toXml(QDomDocument &dom_document) const;
|
||||
void fromXml(QDomElement &dom_element);
|
||||
static QString xmlTaggName() {return QString("texts_group");}
|
||||
|
||||
|
||||
void paint(QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget) override;
|
||||
@@ -88,7 +88,7 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup // TODO:
|
||||
void setRotation(qreal angle);
|
||||
void setPos(const QPointF &pos);
|
||||
void setPos(qreal x, qreal y);
|
||||
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
@@ -99,7 +99,7 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup // TODO:
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
|
||||
|
||||
private:
|
||||
void updateXref();
|
||||
void adjustSlaveXrefPos();
|
||||
@@ -108,8 +108,7 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup // TODO:
|
||||
private:
|
||||
Qt::Alignment m_alignment = Qt::AlignJustify;
|
||||
QString m_name;
|
||||
bool
|
||||
m_first_move = true,
|
||||
bool m_first_move = true,
|
||||
m_hold_to_bottom_of_page = false,
|
||||
m_block_alignment_update = false,
|
||||
m_frame = false;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
@param parent : Parent Item
|
||||
*/
|
||||
QetGraphicsItem::QetGraphicsItem(QGraphicsItem *parent):
|
||||
QGraphicsObject(parent)
|
||||
QGraphicsObject(parent)
|
||||
{}
|
||||
|
||||
QetGraphicsItem::~QetGraphicsItem()
|
||||
|
||||
@@ -55,10 +55,10 @@ class QetGraphicsItem : public QGraphicsObject
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
||||
protected:
|
||||
bool is_movable_{true};
|
||||
bool m_first_move{true};
|
||||
bool snap_to_grid_{true};
|
||||
QPointF m_mouse_to_origin_movement{QPointF(0,0)};
|
||||
bool is_movable_{true};
|
||||
bool m_first_move{true};
|
||||
bool snap_to_grid_{true};
|
||||
QPointF m_mouse_to_origin_movement{QPointF(0,0)};
|
||||
QET::GraphicsItemState m_state = QET:: GIOK;
|
||||
|
||||
};
|
||||
|
||||
@@ -325,7 +325,7 @@ void QetShapeItem::paint(
|
||||
|
||||
switch (m_shapeType)
|
||||
{
|
||||
case Line: painter->drawLine(QLineF(m_P1, m_P2)); break;
|
||||
case Line: painter->drawLine(QLineF(m_P1, m_P2)); break;
|
||||
case Rectangle: painter->drawRoundedRect(QRectF(m_P1, m_P2),
|
||||
m_xRadius,
|
||||
m_yRadius); break;
|
||||
@@ -662,7 +662,7 @@ void QetShapeItem::insertPoint()
|
||||
if(new_polygon != m_polygon)
|
||||
{
|
||||
//Wrap the undo for avoid to merge the undo commands when user add several points.
|
||||
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point à un polygone"));
|
||||
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point ?? un polygone"));
|
||||
new QPropertyUndoCommand(this, "polygon", m_polygon, new_polygon, undo);
|
||||
diagram()->undoStack().push(undo);
|
||||
}
|
||||
@@ -853,20 +853,20 @@ bool QetShapeItem::fromXml(const QDomElement &e)
|
||||
|
||||
QString type = e.attribute("type");
|
||||
#if TODO_LIST
|
||||
#pragma message("@TODO Compatibility for version older than N°4075, shape type was stored with an int")
|
||||
#pragma message("@TODO Compatibility for version older than N??4075, shape type was stored with an int")
|
||||
#endif
|
||||
//@TODO Compatibility for version older than N°4075, shape type was stored with an int
|
||||
//@TODO Compatibility for version older than N??4075, shape type was stored with an int
|
||||
if (type.size() == 1)
|
||||
{
|
||||
switch(e.attribute("type","0").toInt())
|
||||
{
|
||||
case 0: m_shapeType = Line; break;
|
||||
case 0: m_shapeType = Line; break;
|
||||
case 1: m_shapeType = Rectangle; break;
|
||||
case 2: m_shapeType = Ellipse; break;
|
||||
case 3: m_shapeType = Polygon; break;
|
||||
}
|
||||
}
|
||||
//For version after N°4075, shape is stored with a string
|
||||
//For version after N??4075, shape is stored with a string
|
||||
else
|
||||
{
|
||||
QMetaEnum me = metaObject()->enumerator(metaObject()->indexOfEnumerator("ShapeType"));
|
||||
@@ -969,28 +969,28 @@ bool QetShapeItem::toDXF(const QString &filepath,const QPen &pen)
|
||||
switch (m_shapeType)
|
||||
{
|
||||
case Line:
|
||||
Createdxf::drawLine(filepath,
|
||||
Createdxf::drawLine(filepath,
|
||||
QLineF( mapToScene(m_P1),
|
||||
mapToScene(m_P2)),
|
||||
Createdxf::dxfColor(pen));
|
||||
return true;
|
||||
return true;
|
||||
case Rectangle:
|
||||
Createdxf::drawRectangle(filepath,
|
||||
Createdxf::drawRectangle(filepath,
|
||||
QRectF(mapToScene(m_P1),
|
||||
mapToScene(m_P2)).normalized(),
|
||||
Createdxf::dxfColor(pen));
|
||||
return true;
|
||||
return true;
|
||||
case Ellipse:
|
||||
Createdxf::drawEllipse(filepath,
|
||||
Createdxf::drawEllipse(filepath,
|
||||
QRectF(mapToScene(m_P1),
|
||||
mapToScene(m_P2)).normalized(),
|
||||
Createdxf::dxfColor(pen));
|
||||
return true;
|
||||
return true;
|
||||
case Polygon:
|
||||
Createdxf::drawPolygon(filepath,m_polygon,Createdxf::dxfColor(pen));
|
||||
return true;
|
||||
Createdxf::drawPolygon(filepath,m_polygon,Createdxf::dxfColor(pen));
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1013,10 +1013,10 @@ void QetShapeItem::editProperty()
|
||||
QString QetShapeItem::name() const
|
||||
{
|
||||
switch (m_shapeType) {
|
||||
case Line: return tr("une ligne");
|
||||
case Line: return tr("une ligne");
|
||||
case Rectangle: return tr("un rectangle");
|
||||
case Ellipse: return tr("une éllipse");
|
||||
case Ellipse: return tr("une ??llipse");
|
||||
case Polygon: return tr("une polyligne");
|
||||
default: return tr("une shape");
|
||||
default: return tr("une shape");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,13 +26,14 @@
|
||||
Default constructor
|
||||
@param location location of xml definition
|
||||
@param qgi parent QGraphicItem
|
||||
@param s parent diagram
|
||||
@param state int used to know if the creation of element have error
|
||||
*/
|
||||
SlaveElement::SlaveElement(
|
||||
const ElementsLocation &location, QGraphicsItem *parent, int *state) :
|
||||
Element(location, parent, state, Element::Slave)
|
||||
SlaveElement::SlaveElement(const ElementsLocation &location,
|
||||
QGraphicsItem *qgi,
|
||||
int *state) :
|
||||
Element(location, qgi, state, Element::Slave)
|
||||
{
|
||||
m_xref_item = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,15 +25,15 @@ class SlaveElement : public Element
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SlaveElement (
|
||||
explicit SlaveElement (
|
||||
const ElementsLocation &,
|
||||
QGraphicsItem * parent= nullptr,
|
||||
QGraphicsItem * = nullptr,
|
||||
int * = nullptr);
|
||||
~SlaveElement() override;
|
||||
void linkToElement(Element *elmt) override;
|
||||
void unlinkAllElements() override;
|
||||
void unlinkElement(Element *elmt) override;
|
||||
|
||||
|
||||
private:
|
||||
QGraphicsTextItem *m_xref_item{nullptr};
|
||||
};
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
#include "conductortextitem.h"
|
||||
#include "terminaldata.h"
|
||||
|
||||
QColor Terminal::neutralColor = QColor(Qt::blue);
|
||||
QColor Terminal::allowedColor = QColor(Qt::darkGreen);
|
||||
QColor Terminal::warningColor = QColor("#ff8000");
|
||||
QColor Terminal::forbiddenColor = QColor(Qt::red);
|
||||
QColor Terminal::neutralColor = QColor(Qt::blue);
|
||||
QColor Terminal::allowedColor = QColor(Qt::darkGreen);
|
||||
QColor Terminal::warningColor = QColor("#ff8000");
|
||||
QColor Terminal::forbiddenColor = QColor(Qt::red);
|
||||
const qreal Terminal::terminalSize = 4.0; // TODO: store terminalSize in terminaldata, because in PartTerminal there is the same parameter. So only one is needed
|
||||
const qreal Terminal::Z = 1000;
|
||||
|
||||
@@ -40,7 +40,8 @@ const qreal Terminal::Z = 1000;
|
||||
@param name of terminal
|
||||
@param hiddenName
|
||||
*/
|
||||
void Terminal::init(QString number, QString name, bool hiddenName)
|
||||
void Terminal::init(
|
||||
QString number, QString name, bool hiddenName)
|
||||
{
|
||||
// calcul de la position du point d'amarrage a l'element
|
||||
dock_elmt_ = d->m_pos;
|
||||
@@ -49,7 +50,7 @@ void Terminal::init(QString number, QString name, bool hiddenName)
|
||||
case Qet::East : dock_elmt_ += QPointF(-Terminal::terminalSize, 0); break;
|
||||
case Qet::West : dock_elmt_ += QPointF(Terminal::terminalSize, 0); break;
|
||||
case Qet::South:
|
||||
default : dock_elmt_ += QPointF(0, -Terminal::terminalSize);
|
||||
default : dock_elmt_ += QPointF(0, -Terminal::terminalSize);
|
||||
}
|
||||
// Number of terminal
|
||||
number_terminal_ = std::move(number);
|
||||
@@ -111,8 +112,8 @@ Terminal::Terminal(QPointF pf, Qet::Orientation o, Element *e) :
|
||||
initialise une borne
|
||||
@param pf_x Abscisse du point d'amarrage pour un conducteur
|
||||
@param pf_y Ordonnee du point d'amarrage pour un conducteur
|
||||
@param o orientation de la borne : Qt::Horizontal ou Qt::Vertical
|
||||
@param e Element auquel cette borne appartient
|
||||
@param o orientation de la borne : Qt::Horizontal ou Qt::Vertical
|
||||
@param e Element auquel cette borne appartient
|
||||
*/
|
||||
Terminal::Terminal(qreal pf_x, qreal pf_y, Qet::Orientation o, Element *e) :
|
||||
QGraphicsObject(e),
|
||||
@@ -138,7 +139,7 @@ Terminal::Terminal(
|
||||
QString name,
|
||||
bool hiddenName,
|
||||
Element *e) :
|
||||
QGraphicsObject (e),
|
||||
QGraphicsObject (e),
|
||||
d(new TerminalData(this)),
|
||||
parent_element_ (e)
|
||||
{
|
||||
@@ -286,8 +287,8 @@ void Terminal::paint(
|
||||
painter -> save();
|
||||
|
||||
//annulation des renderhints
|
||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||
painter -> setRenderHint(QPainter::TextAntialiasing, false);
|
||||
painter -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||
|
||||
// on travaille avec les coordonnees de l'element parent
|
||||
@@ -421,7 +422,7 @@ void Terminal::drawHelpLine(bool draw)
|
||||
QLineF Terminal::HelpLine() const
|
||||
{
|
||||
QPointF scene_dock = dockConductor();
|
||||
QRectF rect = diagram() -> border_and_titleblock.insideBorderRect();
|
||||
QRectF rect = diagram() -> border_and_titleblock.insideBorderRect();
|
||||
|
||||
QLineF line(scene_dock , QPointF());
|
||||
|
||||
@@ -512,7 +513,7 @@ Terminal* Terminal::alignedWithTerminal() const
|
||||
|
||||
//Available_terminals have several terminals, we get the nearest terminal
|
||||
line.setP2(available_terminals.first() -> dockConductor());
|
||||
qreal current_lenght = line.length();
|
||||
qreal current_lenght = line.length();
|
||||
Terminal *nearest_terminal = available_terminals.takeFirst();
|
||||
|
||||
//Search the nearest terminal to this one
|
||||
@@ -635,7 +636,7 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
|
||||
void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
||||
{
|
||||
previous_terminal_ = nullptr;
|
||||
hovered_color_ = neutralColor;
|
||||
hovered_color_ = neutralColor;
|
||||
|
||||
if (!diagram()) return;
|
||||
|
||||
@@ -651,7 +652,7 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
||||
if (!other_terminal) return;
|
||||
|
||||
other_terminal -> hovered_color_ = neutralColor;
|
||||
other_terminal -> hovered_ = false;
|
||||
other_terminal -> hovered_ = false;
|
||||
|
||||
//We stop her if we can't link this terminal with other terminal
|
||||
if (!canBeLinkedTo(other_terminal)) return;
|
||||
@@ -798,15 +799,16 @@ QDomElement Terminal::toXml(QDomDocument &doc) const
|
||||
@param terminal Le QDomElement a analyser
|
||||
@return true si le QDomElement passe en parametre est une borne, false sinon
|
||||
*/
|
||||
bool Terminal::valideXml(const QDomElement &terminal) {
|
||||
bool Terminal::valideXml(const QDomElement &terminal)
|
||||
{
|
||||
if (terminal.tagName() != "terminal") return(false);
|
||||
|
||||
// affuteuse_250h.qet contains in line 8398 terminals which do not have this
|
||||
// if (propertyString(terminal, "number"))
|
||||
// return false;
|
||||
// if (propertyString(terminal, "number"))
|
||||
// return false;
|
||||
// affuteuse_250h.qet contains in line 8398 terminals which do not have this
|
||||
// if (propertyBool(terminal, "nameHidden"))
|
||||
// return false;
|
||||
// if (propertyBool(terminal, "nameHidden"))
|
||||
// return false;
|
||||
|
||||
if (!TerminalData::valideXml(terminal))
|
||||
return false;
|
||||
@@ -823,8 +825,7 @@ bool Terminal::valideXml(const QDomElement &terminal) {
|
||||
@return true si la borne "se reconnait"
|
||||
(memes coordonnes, meme orientation), false sinon
|
||||
*/
|
||||
bool Terminal::fromXml(const QDomElement &terminal)
|
||||
{
|
||||
bool Terminal::fromXml(const QDomElement &terminal) {
|
||||
propertyString(terminal, "number", &number_terminal_);
|
||||
|
||||
propertyBool(terminal, "nameHidden", &name_terminal_hidden);
|
||||
@@ -832,6 +833,7 @@ bool Terminal::fromXml(const QDomElement &terminal)
|
||||
if(!d->fromXml(terminal))
|
||||
return false;
|
||||
|
||||
|
||||
init(number_terminal_, d->m_name, name_terminal_hidden); // initialize dock_elmt_. This must be done after Terminal data is initialized
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
|
||||
|
||||
// constructors, destructor
|
||||
public:
|
||||
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
|
||||
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
|
||||
Terminal(qreal, qreal, Qet::Orientation, Element * = 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);
|
||||
~Terminal() override;
|
||||
|
||||
@@ -68,18 +68,17 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
|
||||
const QStyleOptionGraphicsItem *,
|
||||
QWidget *) override;
|
||||
void drawHelpLine (bool draw = true);
|
||||
QLineF HelpLine () const;
|
||||
QLineF HelpLine () const;
|
||||
QRectF boundingRect () const override;
|
||||
|
||||
// methods to manage conductors attached to the terminal
|
||||
Terminal* alignedWithTerminal () const;
|
||||
bool addConductor (Conductor *conductor);
|
||||
void removeConductor (Conductor *conductor);
|
||||
int conductorsCount () const;
|
||||
Diagram *diagram () const;
|
||||
Element *parentElement () const;
|
||||
QUuid uuid () const;
|
||||
|
||||
bool addConductor (Conductor *conductor);
|
||||
void removeConductor (Conductor *conductor);
|
||||
int conductorsCount () const;
|
||||
Diagram *diagram () const;
|
||||
Element *parentElement () const;
|
||||
QUuid uuid () const;
|
||||
int ID() const;
|
||||
QPointF dockPos();
|
||||
QPointF originPos();
|
||||
@@ -94,7 +93,6 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
|
||||
void updateConductor();
|
||||
bool isLinkedTo(Terminal *);
|
||||
bool canBeLinkedTo(Terminal *);
|
||||
|
||||
void setID(int id);
|
||||
|
||||
// methods related to XML import/export
|
||||
@@ -102,6 +100,9 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
|
||||
bool fromXml (const QDomElement &) override;
|
||||
QDomElement toXml (QDomDocument &) const override;
|
||||
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
|
||||
protected:
|
||||
// methods related to events management
|
||||
void hoverEnterEvent (QGraphicsSceneHoverEvent *) override;
|
||||
@@ -117,7 +118,7 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
|
||||
|
||||
static const qreal terminalSize;
|
||||
static const qreal Z;
|
||||
// Various static colors used for hover effects.
|
||||
// Various static colors used for hover effects
|
||||
// The assignement is in the cpp file
|
||||
/// default color
|
||||
static QColor neutralColor;
|
||||
@@ -129,12 +130,12 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
|
||||
static QColor forbiddenColor;
|
||||
|
||||
private:
|
||||
bool m_draw_help_line{false};
|
||||
bool m_draw_help_line{false};
|
||||
QGraphicsLineItem *m_help_line{nullptr};
|
||||
QGraphicsLineItem *m_help_line_a{nullptr};
|
||||
|
||||
|
||||
TerminalData* d;
|
||||
TerminalData* d{nullptr};
|
||||
|
||||
/// Parent electrical element
|
||||
Element *parent_element_{nullptr};
|
||||
@@ -155,10 +156,9 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
|
||||
/// Whether the mouse pointer is hovering the terminal
|
||||
bool hovered_{false};
|
||||
/// Color used for the hover effect
|
||||
QColor hovered_color_{Terminal::hovered_color_};
|
||||
QColor hovered_color_{Terminal::neutralColor};
|
||||
/// Number of Terminal
|
||||
QString number_terminal_;
|
||||
|
||||
bool name_terminal_hidden{true};
|
||||
|
||||
/// legacy id used by the conductor to find the terminal. From 0.8x on the uuid is used instead.
|
||||
@@ -187,6 +187,8 @@ inline QString Terminal::number() const
|
||||
{
|
||||
return(number_terminal_);
|
||||
}
|
||||
|
||||
|
||||
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
|
||||
const bool all_diagram = true);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ static int BACKUP_INTERVAL = 120000; //interval in ms of backup = 2min
|
||||
@param parent
|
||||
*/
|
||||
QETProject::QETProject(QObject *parent) :
|
||||
QObject (parent),
|
||||
QObject (parent),
|
||||
m_titleblocks_collection(this),
|
||||
m_data_base(this, this)
|
||||
{
|
||||
@@ -64,7 +64,7 @@ QETProject::QETProject(QObject *parent) :
|
||||
@param parent : parent QObject
|
||||
*/
|
||||
QETProject::QETProject(const QString &path, QObject *parent) :
|
||||
QObject (parent),
|
||||
QObject (parent),
|
||||
m_titleblocks_collection(this),
|
||||
m_data_base(this, this)
|
||||
{
|
||||
@@ -83,7 +83,7 @@ QETProject::QETProject(const QString &path, QObject *parent) :
|
||||
@param parent : parent QObject
|
||||
*/
|
||||
QETProject::QETProject(KAutoSaveFile *backup, QObject *parent) :
|
||||
QObject (parent),
|
||||
QObject (parent),
|
||||
m_titleblocks_collection(this),
|
||||
m_data_base(this, this)
|
||||
{
|
||||
@@ -1459,11 +1459,11 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
|
||||
QDomElement newdiagrams_elmt = newdiagrams_nodes.at(0).toElement();
|
||||
|
||||
// By default, use value find in the global conf of QElectroTech
|
||||
default_border_properties_ = BorderProperties:: defaultProperties();
|
||||
default_border_properties_ = BorderProperties:: defaultProperties();
|
||||
default_titleblock_properties_ = TitleBlockProperties::defaultProperties();
|
||||
default_conductor_properties_ = ConductorProperties:: defaultProperties();
|
||||
m_default_report_properties = ReportProperties:: defaultProperties();
|
||||
m_default_xref_properties = XRefProperties:: defaultProperties();
|
||||
m_default_report_properties = ReportProperties:: defaultProperties();
|
||||
m_default_xref_properties = XRefProperties:: defaultProperties();
|
||||
|
||||
//Read values indicate in project
|
||||
QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt, conds_autonums, folio_autonums, element_autonums;
|
||||
@@ -1742,8 +1742,8 @@ void QETProject::setProjectProperties(const DiagramContext &context) {
|
||||
bool QETProject::projectWasModified()
|
||||
{
|
||||
|
||||
if ( projectOptionsWereModified() ||
|
||||
!m_undo_stack -> isClean() ||
|
||||
if ( projectOptionsWereModified() ||
|
||||
!m_undo_stack -> isClean() ||
|
||||
m_titleblocks_collection.templates().count() )
|
||||
return(true);
|
||||
|
||||
|
||||
@@ -23,7 +23,12 @@
|
||||
*/
|
||||
HelperCell::HelperCell(QGraphicsItem *parent) :
|
||||
QGraphicsObject(parent),
|
||||
QGraphicsLayoutItem()
|
||||
QGraphicsLayoutItem(),
|
||||
background_color(Qt::white),
|
||||
foreground_color(Qt::black),
|
||||
label(),
|
||||
orientation(Qt::Horizontal),
|
||||
index(-1)
|
||||
{
|
||||
setGraphicsItem(this);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
|
||||
@@ -37,11 +37,11 @@ class HelperCell : public QGraphicsObject, public QGraphicsLayoutItem {
|
||||
|
||||
// attributes
|
||||
public:
|
||||
QColor background_color{Qt::white}; ///< Background color when rendering this cell
|
||||
QColor foreground_color{Qt::black}; ///< Text color when rendering this cell
|
||||
QString label; ///< Label displayed in this cell
|
||||
Qt::Orientation orientation{Qt::Horizontal}; ///< Orientation of this cell
|
||||
int index{-1}; ///< Index of this cell
|
||||
QColor background_color{Qt::white}; ///< Background color when rendering this cell
|
||||
QColor foreground_color{Qt::black}; ///< Text color when rendering this cell
|
||||
QString label; ///< Label displayed in this cell
|
||||
Qt::Orientation orientation{Qt::Horizontal}; ///< Orientation of this cell
|
||||
int index{-1}; ///< Index of this cell
|
||||
|
||||
// methods
|
||||
public:
|
||||
|
||||
@@ -36,11 +36,11 @@ class SplittedHelperCell : public HelperCell {
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||
|
||||
// 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_foreground_color; ///< Text color on the split side
|
||||
QString split_label; ///< Text displayed on the split side
|
||||
int split_size; ///< Length of the split side
|
||||
QString split_label; ///< Text displayed on the split side
|
||||
int split_size; ///< Length of the split side
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -65,29 +65,30 @@ bool TitleBlockProperties::operator!=(const TitleBlockProperties &ip) {
|
||||
return(!(*this == ip));
|
||||
}
|
||||
|
||||
/**
|
||||
@brief TitleBlockProperties::toXml
|
||||
@param e
|
||||
*/
|
||||
void TitleBlockProperties::toXml(QDomElement &e) const {
|
||||
|
||||
/**
|
||||
Exporte le cartouche sous formes d'attributs XML ajoutes a l'element e.
|
||||
@param e Element XML auquel seront ajoutes des attributs
|
||||
*/
|
||||
void TitleBlockProperties::toXml(QDomElement &e) const
|
||||
{
|
||||
e.setAttribute("author", author);
|
||||
e.setAttribute("title", title);
|
||||
e.setAttribute("title", title);
|
||||
e.setAttribute("filename", filename);
|
||||
e.setAttribute("plant", plant);
|
||||
e.setAttribute("locmach", locmach);
|
||||
e.setAttribute("indexrev",indexrev);
|
||||
e.setAttribute("version", version);
|
||||
e.setAttribute("folio", folio);
|
||||
e.setAttribute("folio", folio);
|
||||
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"));
|
||||
if (!template_name.isEmpty())
|
||||
{
|
||||
e.setAttribute("titleblocktemplate", template_name);
|
||||
e.setAttribute("titleblocktemplateCollection", QET::qetCollectionToString(collection));
|
||||
}
|
||||
|
||||
|
||||
if (context.keys().count()) {
|
||||
QDomElement properties = e.ownerDocument().createElement("properties");
|
||||
context.toXml(properties);
|
||||
@@ -125,14 +126,14 @@ bool TitleBlockProperties::fromXml(const QDomElement &e) {
|
||||
QString display_at_temp;
|
||||
if (propertyString(e, "displayAt", &display_at_temp) == PropertyFlags::Success)
|
||||
display_at = (display_at_temp == "bottom" ? Qt::BottomEdge : Qt::RightEdge); // otherwise it gets default in header file
|
||||
|
||||
// reads the template used to render the title block
|
||||
|
||||
// reads the template used to render the title block
|
||||
if (propertyString(e, "titleblocktemplate", &template_name) == PropertyFlags::Success) {
|
||||
QString tbc;
|
||||
if (propertyString(e, "titleblocktemplateCollection", &tbc) == PropertyFlags::Success)
|
||||
collection = QET::qetCollectionFromString(tbc);
|
||||
}
|
||||
|
||||
|
||||
// reads the additional fields used to fill the title block
|
||||
context.clear();
|
||||
foreach (QDomElement e, QET::findInDomElement(e, "properties")) {
|
||||
@@ -149,16 +150,16 @@ bool TitleBlockProperties::fromXml(const QDomElement &e) {
|
||||
*/
|
||||
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 + "filename", filename);
|
||||
settings.setValue(prefix + "plant", plant);
|
||||
settings.setValue(prefix + "locmach", locmach);
|
||||
settings.setValue(prefix + "indexrev", indexrev);
|
||||
settings.setValue(prefix + "version", version);
|
||||
settings.setValue(prefix + "folio", folio);
|
||||
settings.setValue(prefix + "auto_page_num", auto_page_num);
|
||||
settings.setValue(prefix + "date", exportDate());
|
||||
settings.setValue(prefix + "folio", folio);
|
||||
settings.setValue(prefix + "auto_page_num", auto_page_num);
|
||||
settings.setValue(prefix + "date", exportDate());
|
||||
settings.setValue(prefix + "displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
|
||||
settings.setValue(prefix + "titleblocktemplate", template_name.isEmpty()? QString() : template_name);
|
||||
settings.setValue(prefix + "titleblocktemplateCollection", QET::qetCollectionToString(collection));
|
||||
@@ -170,15 +171,15 @@ void TitleBlockProperties::toSettings(QSettings &settings, const QString &prefix
|
||||
@param settings Parametres a lire
|
||||
@param prefix prefixe a ajouter devant les noms des parametres
|
||||
*/
|
||||
void TitleBlockProperties::fromSettings(const QSettings &settings, const QString &prefix) {
|
||||
title = settings.value(prefix + "title").toString();
|
||||
void TitleBlockProperties::fromSettings(QSettings &settings, const QString &prefix) {
|
||||
title = settings.value(prefix + "title").toString();
|
||||
author = settings.value(prefix + "author").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();
|
||||
indexrev = settings.value(prefix + "indexrev").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();
|
||||
setDateFromString(settings.value(prefix + "date").toString());
|
||||
display_at = (settings.value(prefix + "displayAt", QVariant("bottom")).toString() == "bottom" ? Qt::BottomEdge : Qt::RightEdge);
|
||||
|
||||
@@ -41,11 +41,11 @@ class TitleBlockProperties: public PropertiesInterface {
|
||||
bool operator==(const TitleBlockProperties &);
|
||||
bool operator!=(const TitleBlockProperties &);
|
||||
|
||||
QDomElement toXml(QDomDocument &e) const override;
|
||||
void toXml(QDomElement &e) const;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||
void fromSettings(const QSettings &, const QString & = QString()) override;
|
||||
QDomElement toXml(QDomDocument &e) const override;
|
||||
void toXml(QDomElement &e) const;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||
void fromSettings(QSettings &, const QString & = QString()) override;
|
||||
|
||||
void setAutoPageNum(QString autonum) {auto_page_num = autonum;}
|
||||
|
||||
@@ -54,21 +54,21 @@ class TitleBlockProperties: public PropertiesInterface {
|
||||
QDate finalDate() const ;
|
||||
|
||||
// attributes
|
||||
QString title; ///< Folio title (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)
|
||||
QString filename; ///< Filename (displayed by the default template)
|
||||
QString plant; ///< Plant (displayed by the default template)
|
||||
QString locmach; ///< Location(displayed by the default template)
|
||||
QString indexrev; ///< Revision Index (displayed by the default template)
|
||||
QString version; ///< Version (displayed by the default template)
|
||||
QString folio; ///< Folio information (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)
|
||||
QDate date; ///< Date (displayed by the default template)
|
||||
QString filename; ///< Filename (displayed by the default template)
|
||||
QString plant; ///< Plant (displayed by the default template)
|
||||
QString locmach; ///< Location(displayed by the default template)
|
||||
QString indexrev; ///< Revision Index (displayed by the default template)
|
||||
QString version; ///< Version (displayed by the default template)
|
||||
QString folio; ///< Folio information (displayed by the default template)
|
||||
QString auto_page_num;
|
||||
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"
|
||||
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"
|
||||
DiagramContext context; ///< Container for the additional, user-defined fields
|
||||
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
|
||||
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
|
||||
|
||||
private:
|
||||
QString exportDate() const;
|
||||
|
||||
@@ -84,8 +84,8 @@ void ConductorPropertiesWidget::setProperties(
|
||||
ui->m_formula_le -> setText (m_properties.m_formula);
|
||||
ui->m_text_le -> setText (m_properties.text);
|
||||
ui->m_function_le -> setText (m_properties.m_function);
|
||||
// ui->m_cable_le -> setText (m_properties.m_cable);
|
||||
// ui->m_bus_le -> setText (m_properties.m_bus);
|
||||
ui->m_cable_le -> setText (m_properties.m_cable);
|
||||
ui->m_bus_le -> setText (m_properties.m_bus);
|
||||
ui->m_tension_protocol_le -> setText (m_properties.m_tension_protocol);
|
||||
ui->m_wire_color_le -> setText (m_properties.m_wire_color);
|
||||
ui->m_wire_section_le -> setText (m_properties.m_wire_section);
|
||||
@@ -130,8 +130,8 @@ ConductorProperties ConductorPropertiesWidget::properties() const
|
||||
properties_.text = ui -> m_text_le -> text();
|
||||
properties_.text_color = ui -> m_text_color_kpb->color();
|
||||
properties_.m_function = ui -> m_function_le->text();
|
||||
// properties_.m_cable = ui -> m_cable_le->text();
|
||||
// properties_.m_bus = ui -> m_bus_le->text();
|
||||
properties_.m_cable = ui -> m_cable_le->text();
|
||||
properties_.m_bus = ui -> m_bus_le->text();
|
||||
properties_.m_tension_protocol = ui -> m_tension_protocol_le->text();
|
||||
properties_.m_wire_color = ui -> m_wire_color_le->text();
|
||||
properties_.m_wire_section = ui -> m_wire_section_le->text();
|
||||
|
||||
@@ -1269,8 +1269,6 @@ void DynamicElementTextModel::enableGroupRotationAndPos(
|
||||
void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi)
|
||||
{
|
||||
DynamicElementTextItem *deti = textFromItem(qsi);
|
||||
if (deti->searchedElement)
|
||||
int stop = 1;
|
||||
ElementTextItemGroup *etig = groupFromItem(qsi);
|
||||
if (!deti && !etig)
|
||||
return;
|
||||
@@ -1416,10 +1414,6 @@ void DynamicElementTextModel::setConnection(ElementTextItemGroup *group, bool se
|
||||
void DynamicElementTextModel::updateDataFromText(DynamicElementTextItem *deti,
|
||||
ValueType type)
|
||||
{
|
||||
|
||||
if (deti->searchedElement)
|
||||
int stop = 1;
|
||||
|
||||
QStandardItem *qsi = m_texts_list.value(deti);
|
||||
if (!qsi)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user