2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2020-06-15 17:42:37 +02:00
|
|
|
Copyright 2006-2020 The QElectroTech Team
|
2007-12-01 10:47:15 +00:00
|
|
|
This file is part of QElectroTech.
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2007-12-01 10:47:15 +00:00
|
|
|
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.
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2007-12-01 10:47:15 +00:00
|
|
|
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.
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2007-12-01 10:47:15 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2007-10-14 15:16:37 +00:00
|
|
|
#include "conductorproperties.h"
|
2015-09-16 15:11:13 +00:00
|
|
|
#include <QPainter>
|
2020-05-12 11:17:25 +02:00
|
|
|
#include <QMetaEnum>
|
2020-09-18 23:04:34 +02:00
|
|
|
#include <QRegularExpression>
|
2020-09-23 22:19:13 +02:00
|
|
|
#include <QtDebug>
|
2007-10-14 15:16:37 +00:00
|
|
|
/**
|
|
|
|
Constructeur par defaut
|
|
|
|
*/
|
|
|
|
SingleLineProperties::SingleLineProperties() :
|
|
|
|
hasGround(true),
|
|
|
|
hasNeutral(true),
|
2012-08-12 20:32:53 +00:00
|
|
|
is_pen(false),
|
2007-10-14 15:16:37 +00:00
|
|
|
phases(1)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Destructeur
|
2020-09-07 22:03:40 +02:00
|
|
|
SingleLineProperties::~SingleLineProperties()
|
|
|
|
{
|
2007-10-14 15:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Definit le nombre de phases (0, 1, 2, ou 3)
|
|
|
|
@param n Nombre de phases
|
|
|
|
*/
|
|
|
|
void SingleLineProperties::setPhasesCount(int n) {
|
|
|
|
phases = qBound(0, n, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @return le nombre de phases (0, 1, 2, ou 3)
|
2020-09-07 22:03:40 +02:00
|
|
|
unsigned short int SingleLineProperties::phasesCount()
|
|
|
|
{
|
2007-10-14 15:16:37 +00:00
|
|
|
return(phases);
|
|
|
|
}
|
|
|
|
|
2012-08-12 20:32:53 +00:00
|
|
|
/**
|
|
|
|
@return true if the singleline conductor should be drawn using the PEN
|
|
|
|
(Protective Earth Neutral) representation and if it features the ground and
|
|
|
|
the neutral.
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
bool SingleLineProperties::isPen() const
|
|
|
|
{
|
2012-08-12 20:32:53 +00:00
|
|
|
return(hasNeutral && hasGround && is_pen);
|
|
|
|
}
|
|
|
|
|
2007-10-14 15:16:37 +00:00
|
|
|
/**
|
|
|
|
Dessine les symboles propres a un conducteur unifilaire
|
|
|
|
@param painter QPainter a utiliser pour dessiner les symboles
|
|
|
|
@param direction direction du segment sur lequel les symboles apparaitront
|
|
|
|
@param rect rectangle englobant le dessin ; utilise pour specifier a la fois la position et la taille du dessin
|
|
|
|
*/
|
2020-08-18 21:46:39 +02:00
|
|
|
void SingleLineProperties::draw(QPainter *painter,
|
|
|
|
QET::ConductorSegmentType direction,
|
|
|
|
const QRectF &rect) {
|
2007-10-14 15:16:37 +00:00
|
|
|
// s'il n'y a rien a dessiner, on retourne immediatement
|
|
|
|
if (!hasNeutral && !hasGround && !phases) return;
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2007-10-14 15:16:37 +00:00
|
|
|
// prepare le QPainter
|
|
|
|
painter -> save();
|
|
|
|
QPen pen(painter -> pen());
|
|
|
|
pen.setCapStyle(Qt::FlatCap);
|
|
|
|
pen.setJoinStyle(Qt::MiterJoin);
|
2012-08-12 20:32:53 +00:00
|
|
|
pen.setStyle(Qt::SolidLine);
|
2015-12-28 15:19:55 +00:00
|
|
|
pen.setWidthF(1);
|
2007-10-14 15:16:37 +00:00
|
|
|
painter -> setPen(pen);
|
|
|
|
painter -> setRenderHint(QPainter::Antialiasing, true);
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2012-08-12 20:32:53 +00:00
|
|
|
uint symbols_count = (hasNeutral ? 1 : 0) + (hasGround ? 1 : 0) - (isPen() ? 1 : 0) + phases;
|
|
|
|
qreal interleave_base = (direction == QET::Horizontal ? rect.width() : rect.height());
|
|
|
|
qreal interleave = interleave_base / (symbols_count + 1);;
|
|
|
|
qreal symbol_width = interleave_base / 12;
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2012-08-12 20:32:53 +00:00
|
|
|
for (uint i = 1 ; i <= symbols_count ; ++ i) {
|
|
|
|
// dessine le tronc du symbole
|
|
|
|
QPointF symbol_p1, symbol_p2;
|
|
|
|
if (direction == QET::Horizontal) {
|
|
|
|
symbol_p1 = QPointF(rect.x() + (i * interleave) + symbol_width, rect.y() + rect.height() * 0.75);
|
|
|
|
symbol_p2 = QPointF(rect.x() + (i * interleave) - symbol_width, rect.y() + rect.height() * 0.25);
|
|
|
|
} else {
|
|
|
|
symbol_p2 = QPointF(rect.x() + rect.width() * 0.75, rect.y() + (i * interleave) - symbol_width);
|
|
|
|
symbol_p1 = QPointF(rect.x() + rect.width() * 0.25, rect.y() + (i * interleave) + symbol_width);
|
2007-10-14 15:16:37 +00:00
|
|
|
}
|
2012-08-12 20:32:53 +00:00
|
|
|
painter -> drawLine(QLineF(symbol_p1, symbol_p2));
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2012-08-12 20:32:53 +00:00
|
|
|
// dessine le reste des symboles terre et neutre
|
|
|
|
if (isPen()) {
|
|
|
|
if (i == 1) {
|
|
|
|
drawPen(painter, direction, symbol_p2, symbol_width);
|
|
|
|
}
|
|
|
|
} else {
|
2007-10-14 15:16:37 +00:00
|
|
|
if (hasGround && i == 1) {
|
|
|
|
drawGround(painter, direction, symbol_p2, symbol_width * 2.0);
|
|
|
|
} else if (hasNeutral && ((i == 1 && !hasGround) || (i == 2 && hasGround))) {
|
2020-09-04 23:00:32 +02:00
|
|
|
drawNeutral(painter, symbol_p2, symbol_width * 1.5);
|
2007-10-14 15:16:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
painter -> restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Dessine le segment correspondant au symbole de la terre sur un conducteur unifilaire
|
|
|
|
@param painter QPainter a utiliser pour dessiner le segment
|
|
|
|
@param direction direction du segment sur lequel le symbole apparaitra
|
|
|
|
@param center centre du segment
|
|
|
|
@param size taille du segment
|
|
|
|
*/
|
2020-08-18 21:46:39 +02:00
|
|
|
void SingleLineProperties::drawGround(QPainter *painter,
|
|
|
|
QET::ConductorSegmentType direction,
|
|
|
|
QPointF center,
|
|
|
|
qreal size) {
|
2007-10-14 15:16:37 +00:00
|
|
|
painter -> save();
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2007-10-14 15:16:37 +00:00
|
|
|
// prepare le QPainter
|
|
|
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
|
|
|
QPen pen2(painter -> pen());
|
|
|
|
pen2.setCapStyle(Qt::SquareCap);
|
|
|
|
painter -> setPen(pen2);
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2007-10-14 15:16:37 +00:00
|
|
|
// dessine le segment representant la terre
|
|
|
|
qreal half_size = size / 2.0;
|
|
|
|
QPointF offset_point(
|
|
|
|
(direction == QET::Horizontal) ? half_size : 0.0,
|
|
|
|
(direction == QET::Horizontal) ? 0.0 : half_size
|
|
|
|
);
|
|
|
|
painter -> drawLine(
|
|
|
|
QLineF(
|
|
|
|
center + offset_point,
|
|
|
|
center - offset_point
|
|
|
|
)
|
|
|
|
);
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2007-10-14 15:16:37 +00:00
|
|
|
painter -> restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Dessine le cercle correspondant au symbole du neutre sur un conducteur unifilaire
|
|
|
|
@param painter QPainter a utiliser pour dessiner le segment
|
|
|
|
@param center centre du cercle
|
|
|
|
@param size diametre du cercle
|
|
|
|
*/
|
2020-09-04 23:00:32 +02:00
|
|
|
void SingleLineProperties::drawNeutral(
|
|
|
|
QPainter *painter,
|
|
|
|
QPointF center,
|
|
|
|
qreal size)
|
|
|
|
{
|
2007-10-14 15:16:37 +00:00
|
|
|
painter -> save();
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2007-10-14 15:16:37 +00:00
|
|
|
// prepare le QPainter
|
|
|
|
if (painter -> brush() == Qt::NoBrush) painter -> setBrush(Qt::black);
|
|
|
|
painter -> setPen(Qt::NoPen);
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2007-10-14 15:16:37 +00:00
|
|
|
// desine le cercle representant le neutre
|
|
|
|
painter -> drawEllipse(
|
|
|
|
QRectF(
|
|
|
|
center - QPointF(size / 2.0, size / 2.0),
|
|
|
|
QSizeF(size, size)
|
|
|
|
)
|
|
|
|
);
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2007-10-14 15:16:37 +00:00
|
|
|
painter -> restore();
|
|
|
|
}
|
|
|
|
|
2012-08-12 20:32:53 +00:00
|
|
|
/**
|
2020-08-19 17:31:02 +02:00
|
|
|
@brief SingleLineProperties::drawPen
|
|
|
|
Draw the PEN (Protective Earth Neutral) symbol using
|
|
|
|
\a painter at position \a center, using a size hint of \a size.
|
|
|
|
@param painter
|
|
|
|
@param direction :
|
|
|
|
Indicate the direction of the underlying conductor segment
|
|
|
|
@param center
|
|
|
|
@param size
|
2012-08-12 20:32:53 +00:00
|
|
|
*/
|
2020-08-18 21:46:39 +02:00
|
|
|
void SingleLineProperties::drawPen(QPainter *painter,
|
|
|
|
QET::ConductorSegmentType direction,
|
|
|
|
QPointF center,
|
|
|
|
qreal size) {
|
2012-08-12 20:32:53 +00:00
|
|
|
painter -> save();
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2012-08-12 20:32:53 +00:00
|
|
|
//painter -> setBrush(Qt::white);
|
|
|
|
// desine le cercle representant le neutre
|
|
|
|
//painter -> drawEllipse(
|
|
|
|
// QRectF(
|
|
|
|
// center - QPointF(size * 1.5 / 2.0, size * 1.5 / 2.0),
|
|
|
|
// QSizeF(size * 1.5, size * 1.5)
|
|
|
|
// )
|
|
|
|
//);
|
2020-09-04 23:00:32 +02:00
|
|
|
drawNeutral(painter, center, size * 1.5);
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2012-08-12 20:32:53 +00:00
|
|
|
int offset = (size * 1.5 / 2.0);
|
|
|
|
QPointF pos = center + (direction == QET::Horizontal ? QPointF(0.0, -offset - 0.5) : QPointF(offset + 0.5, 0.0));
|
|
|
|
drawGround(painter, direction, pos, 2.0 * size);
|
|
|
|
painter -> restore();
|
|
|
|
}
|
|
|
|
|
2007-10-14 15:16:37 +00:00
|
|
|
/**
|
2009-04-03 19:30:25 +00:00
|
|
|
Exporte les parametres du conducteur unifilaire sous formes d'attributs XML
|
2007-10-14 15:16:37 +00:00
|
|
|
ajoutes a l'element e.
|
|
|
|
@param e Element XML auquel seront ajoutes des attributs
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
void SingleLineProperties::toXml(QDomElement &e) const
|
|
|
|
{
|
2007-10-14 15:16:37 +00:00
|
|
|
e.setAttribute("ground", hasGround ? "true" : "false");
|
|
|
|
e.setAttribute("neutral", hasNeutral ? "true" : "false");
|
|
|
|
e.setAttribute("phase", phases);
|
2012-08-12 20:32:53 +00:00
|
|
|
if (isPen()) e.setAttribute("pen", "true");
|
2007-10-14 15:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-04-03 19:30:25 +00:00
|
|
|
Importe les parametres du conducteur unifilaire a partir des attributs XML
|
2007-10-14 15:16:37 +00:00
|
|
|
de l'element e
|
|
|
|
@param e Element XML dont les attributs seront lus
|
|
|
|
*/
|
|
|
|
void SingleLineProperties::fromXml(QDomElement &e) {
|
|
|
|
hasGround = e.attribute("ground") == "true";
|
|
|
|
hasNeutral = e.attribute("neutral") == "true";
|
|
|
|
setPhasesCount(e.attribute("phase").toInt());
|
2012-08-12 20:32:53 +00:00
|
|
|
is_pen = (hasGround && hasNeutral && e.attribute("pen", "false") == "true");
|
2007-10-14 15:16:37 +00:00
|
|
|
}
|
|
|
|
|
2009-11-22 16:12:22 +00:00
|
|
|
/**
|
|
|
|
Constructeur : par defaut, les proprietes font un conducteur
|
|
|
|
multifilaire noir dont le texte est "_"
|
|
|
|
*/
|
|
|
|
ConductorProperties::ConductorProperties() :
|
|
|
|
type(Multi),
|
|
|
|
color(Qt::black),
|
2020-06-20 16:27:25 +02:00
|
|
|
text_color(Qt::black),
|
2009-11-22 16:12:22 +00:00
|
|
|
text("_"),
|
2013-12-03 10:17:49 +00:00
|
|
|
text_size(9),
|
2015-12-23 18:41:13 +00:00
|
|
|
cond_size(1),
|
2013-06-05 23:25:00 +00:00
|
|
|
verti_rotate_text(270),
|
|
|
|
horiz_rotate_text(0),
|
2014-10-03 17:02:01 +00:00
|
|
|
m_show_text(true),
|
2014-10-19 11:25:03 +00:00
|
|
|
m_one_text_per_folio(false),
|
|
|
|
style(Qt::SolidLine)
|
|
|
|
{}
|
2009-11-22 16:12:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructeur
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
ConductorProperties::~ConductorProperties()
|
|
|
|
{
|
2009-11-22 16:12:22 +00:00
|
|
|
}
|
|
|
|
|
2014-02-07 14:45:43 +00:00
|
|
|
|
2007-10-14 15:16:37 +00:00
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief ConductorProperties::toXml
|
|
|
|
Export conductor propertie, in the XML element 'e'
|
|
|
|
@param e the xml element
|
|
|
|
*/
|
2015-08-29 14:18:30 +00:00
|
|
|
void ConductorProperties::toXml(QDomElement &e) const
|
|
|
|
{
|
2007-10-14 15:16:37 +00:00
|
|
|
e.setAttribute("type", typeToString(type));
|
2014-02-07 19:04:57 +00:00
|
|
|
|
2015-08-29 14:18:30 +00:00
|
|
|
if (color != QColor(Qt::black))
|
2009-11-22 16:12:22 +00:00
|
|
|
e.setAttribute("color", color.name());
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2017-08-01 19:09:31 +00:00
|
|
|
e.setAttribute("bicolor", m_bicolor? "true" : "false");
|
|
|
|
e.setAttribute("color2", m_color_2.name());
|
|
|
|
e.setAttribute("dash-size", QString::number(m_dash_size));
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2015-08-29 14:18:30 +00:00
|
|
|
if (type == Single)
|
2009-04-03 19:30:25 +00:00
|
|
|
singleLineProperties.toXml(e);
|
2015-08-29 14:18:30 +00:00
|
|
|
|
2014-02-07 19:04:57 +00:00
|
|
|
e.setAttribute("num", text);
|
2020-06-20 16:27:25 +02:00
|
|
|
e.setAttribute("text_color", text_color.name());
|
2016-12-06 19:49:18 +00:00
|
|
|
e.setAttribute("formula", m_formula);
|
2015-08-29 14:18:30 +00:00
|
|
|
e.setAttribute("function", m_function);
|
2020-07-04 20:43:40 +02:00
|
|
|
e.setAttribute("tension_protocol", m_tension_protocol);
|
|
|
|
e.setAttribute("conductor_color", m_wire_color);
|
|
|
|
e.setAttribute("conductor_section", m_wire_section);
|
2016-10-17 19:08:52 +00:00
|
|
|
e.setAttribute("numsize", QString::number(text_size));
|
|
|
|
e.setAttribute("condsize", QString::number(cond_size));
|
2014-09-28 09:47:06 +00:00
|
|
|
e.setAttribute("displaytext", m_show_text);
|
2014-10-03 17:02:01 +00:00
|
|
|
e.setAttribute("onetextperfolio", m_one_text_per_folio);
|
2016-10-17 19:08:52 +00:00
|
|
|
e.setAttribute("vertirotatetext", QString::number(verti_rotate_text));
|
|
|
|
e.setAttribute("horizrotatetext", QString::number(horiz_rotate_text));
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2018-04-28 13:35:23 +00:00
|
|
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
|
|
|
e.setAttribute("horizontal-alignment", me.valueToKey(m_horizontal_alignment));
|
|
|
|
e.setAttribute("vertical-alignment", me.valueToKey(m_vertical_alignment));
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2009-11-22 16:12:22 +00:00
|
|
|
QString conductor_style = writeStyle();
|
2015-08-29 14:18:30 +00:00
|
|
|
if (!conductor_style.isEmpty())
|
2009-11-22 16:12:22 +00:00
|
|
|
e.setAttribute("style", conductor_style);
|
2007-10-14 15:16:37 +00:00
|
|
|
}
|
|
|
|
|
2014-02-07 14:45:43 +00:00
|
|
|
|
2007-10-14 15:16:37 +00:00
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief ConductorProperties::fromXml
|
|
|
|
Import conductor propertie, from the attribute of the xml element 'e'
|
|
|
|
@param e the xml document
|
|
|
|
*/
|
2015-08-29 14:18:30 +00:00
|
|
|
void ConductorProperties::fromXml(QDomElement &e)
|
|
|
|
{
|
|
|
|
// get conductor color
|
2009-11-22 16:12:22 +00:00
|
|
|
QColor xml_color= QColor(e.attribute("color"));
|
2015-08-29 14:18:30 +00:00
|
|
|
color = (xml_color.isValid()? xml_color : QColor(Qt::black));
|
2020-06-20 16:27:25 +02:00
|
|
|
|
2017-08-01 19:09:31 +00:00
|
|
|
QString bicolor_str = e.attribute("bicolor", "false");
|
|
|
|
m_bicolor = bicolor_str == "true"? true : false;
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2020-06-20 16:27:25 +02:00
|
|
|
QColor xml_color_2 = QColor(e.attribute("color2"));
|
2017-08-01 19:09:31 +00:00
|
|
|
m_color_2 = xml_color_2.isValid()? xml_color_2 : QColor(Qt::black);
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2017-08-01 19:09:31 +00:00
|
|
|
m_dash_size = e.attribute("dash-size", QString::number(1)).toInt();
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2015-08-29 14:18:30 +00:00
|
|
|
// read style of conductor
|
2009-11-22 16:12:22 +00:00
|
|
|
readStyle(e.attribute("style"));
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2015-08-29 14:18:30 +00:00
|
|
|
if (e.attribute("type") == typeToString(Single))
|
|
|
|
{
|
|
|
|
// get specific properties for single conductor
|
2007-10-14 15:16:37 +00:00
|
|
|
singleLineProperties.fromXml(e);
|
|
|
|
type = Single;
|
|
|
|
}
|
2015-08-29 14:18:30 +00:00
|
|
|
else
|
|
|
|
type = Multi;
|
|
|
|
|
|
|
|
text = e.attribute("num");
|
2020-06-20 16:27:25 +02:00
|
|
|
// get text color
|
|
|
|
QColor xml_text_color= QColor(e.attribute("text_color"));
|
|
|
|
text_color = (xml_text_color.isValid()? xml_text_color : QColor(Qt::black));
|
2016-12-06 19:49:18 +00:00
|
|
|
m_formula = e.attribute("formula");
|
2015-08-29 14:18:30 +00:00
|
|
|
m_function = e.attribute("function");
|
2020-07-04 20:43:40 +02:00
|
|
|
m_tension_protocol = e.attribute("tension_protocol");
|
|
|
|
m_wire_color = e.attribute("conductor_color");
|
|
|
|
m_wire_section = e.attribute("conductor_section");
|
2015-08-29 14:18:30 +00:00
|
|
|
text_size = e.attribute("numsize", QString::number(9)).toInt();
|
2016-08-05 12:15:59 +00:00
|
|
|
cond_size = e.attribute("condsize", QString::number(1)).toDouble();
|
2015-08-29 14:18:30 +00:00
|
|
|
m_show_text = e.attribute("displaytext", QString::number(1)).toInt();
|
2014-10-03 17:02:01 +00:00
|
|
|
m_one_text_per_folio = e.attribute("onetextperfolio", QString::number(0)).toInt();
|
2015-08-29 14:18:30 +00:00
|
|
|
verti_rotate_text = e.attribute("vertirotatetext").toDouble();
|
|
|
|
horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2018-04-28 13:35:23 +00:00
|
|
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
2020-07-19 22:06:42 +02:00
|
|
|
m_horizontal_alignment = Qt::Alignment(
|
|
|
|
me.keyToValue(
|
|
|
|
e.attribute(
|
|
|
|
"horizontal-alignment",
|
|
|
|
"AlignBottom"
|
|
|
|
).toStdString().data()));
|
|
|
|
m_vertical_alignment = Qt::Alignment(
|
|
|
|
me.keyToValue(
|
|
|
|
e.attribute(
|
|
|
|
"vertical-alignment",
|
|
|
|
"AlignRight"
|
|
|
|
).toStdString().data()));
|
|
|
|
|
|
|
|
//Keep retrocompatible with version older than 0,4
|
|
|
|
//If the propertie @type is simple (removed since QET 0,4), we set text no visible.
|
|
|
|
//@TODO remove this code for qet 0.6 or later
|
|
|
|
#pragma message("@TODO remove this code for qet 0.6 or later")
|
2014-09-28 09:47:06 +00:00
|
|
|
if (e.attribute("type") == "simple") m_show_text = false;
|
2007-10-14 15:16:37 +00:00
|
|
|
}
|
|
|
|
|
2007-11-14 20:27:45 +00:00
|
|
|
/**
|
|
|
|
@param settings Parametres a ecrire
|
2009-04-03 19:30:25 +00:00
|
|
|
@param prefix prefixe a ajouter devant les noms des parametres
|
2007-11-14 20:27:45 +00:00
|
|
|
*/
|
2015-08-29 14:18:30 +00:00
|
|
|
void ConductorProperties::toSettings(QSettings &settings, const QString &prefix) const
|
|
|
|
{
|
2009-11-22 16:12:22 +00:00
|
|
|
settings.setValue(prefix + "color", color.name());
|
2017-08-01 19:09:31 +00:00
|
|
|
settings.setValue(prefix + "bicolor", m_bicolor);
|
|
|
|
settings.setValue(prefix + "color2", m_color_2.name());
|
|
|
|
settings.setValue(prefix + "dash-size", m_dash_size);
|
2009-11-22 16:12:22 +00:00
|
|
|
settings.setValue(prefix + "style", writeStyle());
|
2007-11-14 20:27:45 +00:00
|
|
|
settings.setValue(prefix + "type", typeToString(type));
|
|
|
|
settings.setValue(prefix + "text", text);
|
2020-06-20 16:27:25 +02:00
|
|
|
settings.setValue(prefix + "text_color", text_color.name());
|
2016-12-06 19:49:18 +00:00
|
|
|
settings.setValue(prefix + "formula", m_formula);
|
2015-08-29 14:18:30 +00:00
|
|
|
settings.setValue(prefix + "function", m_function);
|
2020-07-04 20:43:40 +02:00
|
|
|
settings.setValue(prefix + "tension_protocol", m_tension_protocol);
|
|
|
|
settings.setValue(prefix + "conductor_color", m_wire_color);
|
|
|
|
settings.setValue(prefix + "conductor_section", m_wire_section);
|
2013-12-03 10:17:49 +00:00
|
|
|
settings.setValue(prefix + "textsize", QString::number(text_size));
|
2015-12-23 18:41:13 +00:00
|
|
|
settings.setValue(prefix + "size", QString::number(cond_size));
|
2014-09-28 09:47:06 +00:00
|
|
|
settings.setValue(prefix + "displaytext", m_show_text);
|
2014-10-03 17:02:01 +00:00
|
|
|
settings.setValue(prefix + "onetextperfolio", m_one_text_per_folio);
|
2013-06-05 21:42:45 +00:00
|
|
|
settings.setValue(prefix + "vertirotatetext", QString::number(verti_rotate_text));
|
|
|
|
settings.setValue(prefix + "horizrotatetext", QString::number(horiz_rotate_text));
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2018-04-28 13:35:23 +00:00
|
|
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
|
|
|
settings.setValue(prefix + "horizontal-alignment", me.valueToKey(m_horizontal_alignment));
|
|
|
|
settings.setValue(prefix + "vertical-alignment", me.valueToKey(m_vertical_alignment));
|
|
|
|
|
2007-11-14 20:27:45 +00:00
|
|
|
singleLineProperties.toSettings(settings, prefix);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@param settings Parametres a lire
|
2009-04-03 19:30:25 +00:00
|
|
|
@param prefix prefixe a ajouter devant les noms des parametres
|
2007-11-14 20:27:45 +00:00
|
|
|
*/
|
2015-08-29 14:18:30 +00:00
|
|
|
void ConductorProperties::fromSettings(QSettings &settings, const QString &prefix)
|
|
|
|
{
|
2009-11-22 16:12:22 +00:00
|
|
|
QColor settings_color = QColor(settings.value(prefix + "color").toString());
|
2015-08-29 14:18:30 +00:00
|
|
|
color = (settings_color.isValid()? settings_color : QColor(Qt::black));
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2017-08-01 19:09:31 +00:00
|
|
|
QColor settings_color_2 = QColor(settings.value(prefix + "color2").toString());
|
|
|
|
m_color_2 = (settings_color_2.isValid()? settings_color_2 : QColor(Qt::black));
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2017-08-01 19:09:31 +00:00
|
|
|
m_bicolor = settings.value(prefix + "bicolor", false).toBool();
|
|
|
|
m_dash_size = settings.value(prefix + "dash-size", 1).toInt();
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2007-11-14 20:27:45 +00:00
|
|
|
QString setting_type = settings.value(prefix + "type", typeToString(Multi)).toString();
|
2015-08-29 14:18:30 +00:00
|
|
|
type = (setting_type == typeToString(Single)? Single : Multi);
|
|
|
|
|
2007-11-14 20:27:45 +00:00
|
|
|
singleLineProperties.fromSettings(settings, prefix);
|
2015-08-29 14:18:30 +00:00
|
|
|
|
|
|
|
text = settings.value(prefix + "text", "_").toString();
|
2020-06-20 16:27:25 +02:00
|
|
|
QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString());
|
|
|
|
text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black));
|
2016-12-06 19:49:18 +00:00
|
|
|
m_formula = settings.value(prefix + "formula", "").toString();
|
2015-08-29 14:18:30 +00:00
|
|
|
m_function = settings.value(prefix + "function", "").toString();
|
2020-07-04 20:43:40 +02:00
|
|
|
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();
|
2015-08-29 14:18:30 +00:00
|
|
|
text_size = settings.value(prefix + "textsize", "7").toInt();
|
2015-12-23 18:41:13 +00:00
|
|
|
cond_size = settings.value(prefix + "size", "1").toInt();
|
2015-08-29 14:18:30 +00:00
|
|
|
m_show_text = settings.value(prefix + "displaytext", true).toBool();
|
2014-10-03 17:02:01 +00:00
|
|
|
m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
|
2015-08-29 14:18:30 +00:00
|
|
|
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
|
|
|
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2018-04-28 13:35:23 +00:00
|
|
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
2018-04-28 13:56:04 +00:00
|
|
|
m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "horizontal-alignment", "AlignBottom").toString().toStdString().data()));
|
|
|
|
m_vertical_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "vertical-alignment", "AlignRight").toString().toStdString().data()));
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2009-11-22 16:12:22 +00:00
|
|
|
readStyle(settings.value(prefix + "style").toString());
|
2007-11-14 20:27:45 +00:00
|
|
|
}
|
|
|
|
|
2007-10-14 15:16:37 +00:00
|
|
|
/**
|
|
|
|
@param t type du conducteur
|
|
|
|
*/
|
2019-03-15 16:53:13 +00:00
|
|
|
QString ConductorProperties::typeToString(ConductorType t)
|
|
|
|
{
|
|
|
|
switch(t)
|
|
|
|
{
|
2007-10-14 15:16:37 +00:00
|
|
|
case Single: return("single");
|
2007-10-17 13:40:53 +00:00
|
|
|
case Multi: return("multi");
|
2007-10-14 15:16:37 +00:00
|
|
|
}
|
2019-03-15 16:53:13 +00:00
|
|
|
return QString();
|
2016-08-29 15:37:42 +00:00
|
|
|
}
|
|
|
|
|
2017-01-05 15:25:07 +00:00
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief ConductorProperties::applyForEqualAttributes
|
|
|
|
Test each attribute of properties in the list separatly.
|
|
|
|
For each attributes, if is equal, the attribute is apply to this.
|
|
|
|
@param list
|
|
|
|
*/
|
2017-01-05 15:25:07 +00:00
|
|
|
void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> list)
|
|
|
|
{
|
2018-07-19 14:14:31 +00:00
|
|
|
const QList<ConductorProperties> clist = std::move(list);
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2017-08-01 19:09:31 +00:00
|
|
|
if (clist.isEmpty())
|
2017-01-05 15:25:07 +00:00
|
|
|
return;
|
|
|
|
|
2017-08-01 19:09:31 +00:00
|
|
|
if (clist.size() == 1)
|
2017-01-05 15:25:07 +00:00
|
|
|
{
|
2017-08-01 19:09:31 +00:00
|
|
|
ConductorProperties cp = clist.first();
|
2017-01-05 15:25:07 +00:00
|
|
|
color = cp.color;
|
2017-08-01 19:09:31 +00:00
|
|
|
m_bicolor = cp.m_bicolor;
|
|
|
|
m_color_2 = cp.m_color_2;
|
|
|
|
m_dash_size = cp.m_dash_size;
|
2017-01-05 15:25:07 +00:00
|
|
|
text = cp.text;
|
2020-06-20 16:27:25 +02:00
|
|
|
text_color = cp.text_color;
|
2017-01-05 15:25:07 +00:00
|
|
|
m_formula = cp.m_formula;
|
|
|
|
m_function = cp.m_function;
|
|
|
|
m_tension_protocol = cp.m_tension_protocol;
|
2020-05-25 12:06:27 +02:00
|
|
|
m_wire_color = cp.m_wire_color;
|
|
|
|
m_wire_section = cp.m_wire_section;
|
2017-01-05 15:25:07 +00:00
|
|
|
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;
|
2018-04-28 13:35:23 +00:00
|
|
|
m_vertical_alignment = cp.m_vertical_alignment;
|
|
|
|
m_horizontal_alignment = cp.m_horizontal_alignment;
|
2017-01-05 15:25:07 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool equal = true;
|
2017-08-01 19:09:31 +00:00
|
|
|
QColor c_value;
|
|
|
|
bool b_value;
|
|
|
|
QString s_value;
|
|
|
|
int i_value;
|
|
|
|
double d_value;
|
2018-04-28 13:35:23 +00:00
|
|
|
Qt::Alignment align_value;
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2017-01-05 15:25:07 +00:00
|
|
|
//Color
|
2017-08-01 19:09:31 +00:00
|
|
|
c_value = clist.first().color;
|
|
|
|
for(ConductorProperties cp : clist)
|
2017-01-05 15:25:07 +00:00
|
|
|
{
|
|
|
|
if (cp.color != c_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
color = c_value;
|
|
|
|
equal = true;
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2017-08-01 19:09:31 +00:00
|
|
|
//bicolor
|
|
|
|
b_value = clist.first().m_bicolor;
|
|
|
|
for(ConductorProperties cp : clist)
|
|
|
|
{
|
|
|
|
if (cp.m_bicolor != b_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
m_bicolor = b_value;
|
|
|
|
equal = true;
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2017-08-01 19:09:31 +00:00
|
|
|
//second color
|
|
|
|
c_value = clist.first().m_color_2;
|
|
|
|
for(ConductorProperties cp : clist)
|
|
|
|
{
|
|
|
|
if (cp.m_color_2 != c_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
m_color_2 = c_value;
|
|
|
|
equal = true;
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2017-08-01 19:09:31 +00:00
|
|
|
//Dash size
|
|
|
|
i_value = clist.first().m_dash_size;
|
|
|
|
for(ConductorProperties cp : clist)
|
|
|
|
{
|
|
|
|
if (cp.m_dash_size != i_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
m_dash_size = i_value;
|
|
|
|
equal = true;
|
2017-01-05 15:25:07 +00:00
|
|
|
|
|
|
|
//text
|
2017-08-01 19:09:31 +00:00
|
|
|
s_value = clist.first().text;
|
|
|
|
for(ConductorProperties cp : clist)
|
2017-01-05 15:25:07 +00:00
|
|
|
{
|
|
|
|
if (cp.text != s_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
text = s_value;
|
|
|
|
equal = true;
|
|
|
|
|
2020-06-20 16:27:25 +02:00
|
|
|
//text color
|
|
|
|
c_value = clist.first().text_color;
|
|
|
|
for(ConductorProperties cp : clist)
|
|
|
|
{
|
|
|
|
if (cp.text_color != c_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
text_color = c_value;
|
|
|
|
equal = true;
|
|
|
|
|
2017-01-05 15:25:07 +00:00
|
|
|
//formula
|
2017-08-01 19:09:31 +00:00
|
|
|
s_value = clist.first().m_formula;
|
|
|
|
for(ConductorProperties cp : clist)
|
2017-01-05 15:25:07 +00:00
|
|
|
{
|
|
|
|
if (cp.m_formula != s_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
m_formula = s_value;
|
|
|
|
equal = true;
|
|
|
|
|
|
|
|
//function
|
2017-08-01 19:09:31 +00:00
|
|
|
s_value = clist.first().m_function;
|
|
|
|
for(ConductorProperties cp : clist)
|
2017-01-05 15:25:07 +00:00
|
|
|
{
|
|
|
|
if (cp.m_function != s_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
m_function = s_value;
|
|
|
|
equal = true;
|
|
|
|
|
|
|
|
//Tension protocol
|
2017-08-01 19:09:31 +00:00
|
|
|
s_value = clist.first().m_tension_protocol;
|
|
|
|
for(ConductorProperties cp : clist)
|
2017-01-05 15:25:07 +00:00
|
|
|
{
|
|
|
|
if (cp.m_tension_protocol != s_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
m_tension_protocol = s_value;
|
|
|
|
equal = true;
|
|
|
|
|
2020-07-04 20:43:40 +02:00
|
|
|
//conductor_color
|
2020-05-25 12:06:27 +02:00
|
|
|
s_value = clist.first().m_wire_color;
|
|
|
|
for(ConductorProperties cp : clist)
|
|
|
|
{
|
|
|
|
if (cp.m_wire_color != s_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
m_wire_color = s_value;
|
|
|
|
equal = true;
|
|
|
|
|
2020-07-04 20:43:40 +02:00
|
|
|
//conductor_section
|
2020-05-25 12:06:27 +02:00
|
|
|
s_value = clist.first().m_wire_section;
|
|
|
|
for(ConductorProperties cp : clist)
|
|
|
|
{
|
|
|
|
if (cp.m_wire_section != s_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
m_wire_section = s_value;
|
|
|
|
equal = true;
|
|
|
|
|
|
|
|
|
2017-01-05 15:25:07 +00:00
|
|
|
//text size
|
2017-08-01 19:09:31 +00:00
|
|
|
i_value = clist.first().text_size;
|
|
|
|
for(ConductorProperties cp : clist)
|
2017-01-05 15:25:07 +00:00
|
|
|
{
|
|
|
|
if (cp.text_size != i_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
text_size = i_value;
|
|
|
|
equal = true;
|
|
|
|
|
|
|
|
//conductor size
|
2017-08-01 19:09:31 +00:00
|
|
|
d_value = clist.first().cond_size;
|
|
|
|
for(ConductorProperties cp : clist)
|
2017-01-05 15:25:07 +00:00
|
|
|
{
|
|
|
|
if (cp.cond_size != d_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
cond_size = d_value;
|
|
|
|
equal = true;
|
|
|
|
|
|
|
|
//show text
|
2017-08-01 19:09:31 +00:00
|
|
|
b_value = clist.first().m_show_text;
|
|
|
|
for(ConductorProperties cp : clist)
|
2017-01-05 15:25:07 +00:00
|
|
|
{
|
|
|
|
if (cp.m_show_text != b_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
m_show_text = b_value;
|
|
|
|
equal = true;
|
|
|
|
|
|
|
|
//One text per folio
|
2017-08-01 19:09:31 +00:00
|
|
|
b_value = clist.first().m_one_text_per_folio;
|
|
|
|
for(ConductorProperties cp : clist)
|
2017-01-05 15:25:07 +00:00
|
|
|
{
|
|
|
|
if (cp.m_one_text_per_folio != b_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
m_one_text_per_folio = b_value;
|
|
|
|
equal = true;
|
|
|
|
|
|
|
|
//Text rotation for vertical conducor
|
2017-08-01 19:09:31 +00:00
|
|
|
d_value = clist.first().verti_rotate_text;
|
|
|
|
for(ConductorProperties cp : clist)
|
2017-01-05 15:25:07 +00:00
|
|
|
{
|
|
|
|
if (cp.verti_rotate_text != d_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
verti_rotate_text = d_value;
|
|
|
|
equal = true;
|
|
|
|
|
|
|
|
//Text rotation for horizontal conducor
|
2017-08-01 19:09:31 +00:00
|
|
|
d_value = clist.first().horiz_rotate_text;
|
|
|
|
for(ConductorProperties cp : clist)
|
2017-01-05 15:25:07 +00:00
|
|
|
{
|
|
|
|
if (cp.horiz_rotate_text != d_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
horiz_rotate_text = d_value;
|
|
|
|
equal = true;
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2018-04-28 13:35:23 +00:00
|
|
|
//Text alignment for horizontal conducor
|
|
|
|
align_value = clist.first().m_horizontal_alignment;
|
|
|
|
for(ConductorProperties cp : clist)
|
|
|
|
{
|
|
|
|
if (cp.m_horizontal_alignment != align_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
m_horizontal_alignment = align_value;
|
|
|
|
equal = true;
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2018-04-28 13:35:23 +00:00
|
|
|
//Text alignment for vertical conducor
|
|
|
|
align_value = clist.first().m_vertical_alignment;
|
|
|
|
for(ConductorProperties cp : clist)
|
|
|
|
{
|
|
|
|
if (cp.m_vertical_alignment != align_value)
|
|
|
|
equal = false;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
m_vertical_alignment = align_value;
|
|
|
|
equal = true;
|
2017-01-05 15:25:07 +00:00
|
|
|
}
|
|
|
|
|
2014-10-26 11:57:38 +00:00
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief ConductorProperties::defaultProperties
|
|
|
|
@return the default properties stored in the setting file
|
|
|
|
*/
|
2015-09-16 15:11:13 +00:00
|
|
|
ConductorProperties ConductorProperties::defaultProperties()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
2014-10-26 11:57:38 +00:00
|
|
|
|
|
|
|
ConductorProperties def;
|
|
|
|
def.fromSettings(settings, "diagrameditor/defaultconductor");
|
|
|
|
|
|
|
|
return(def);
|
|
|
|
}
|
|
|
|
|
2007-10-21 16:10:21 +00:00
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief ConductorProperties::operator ==
|
|
|
|
@param other
|
|
|
|
@return true if other == this
|
|
|
|
*/
|
2016-12-06 19:49:18 +00:00
|
|
|
bool ConductorProperties::operator==(const ConductorProperties &other) const
|
|
|
|
{
|
2007-10-14 15:16:37 +00:00
|
|
|
return(
|
|
|
|
other.type == type &&\
|
2009-11-22 16:12:22 +00:00
|
|
|
other.color == color &&\
|
2017-08-01 19:09:31 +00:00
|
|
|
other.m_bicolor == m_bicolor &&\
|
|
|
|
other.m_color_2 == m_color_2 &&\
|
|
|
|
other.m_dash_size == m_dash_size &&\
|
2012-07-07 19:45:29 +00:00
|
|
|
other.style == style &&\
|
2007-10-14 15:16:37 +00:00
|
|
|
other.text == text &&\
|
2020-06-20 16:27:25 +02:00
|
|
|
other.text_color == text_color &&\
|
2016-12-06 19:49:18 +00:00
|
|
|
other.m_formula == m_formula &&\
|
2015-08-29 14:18:30 +00:00
|
|
|
other.m_function == m_function &&\
|
|
|
|
other.m_tension_protocol == m_tension_protocol &&\
|
2020-05-25 12:06:27 +02:00
|
|
|
other.m_wire_color == m_wire_color && \
|
|
|
|
other.m_wire_section == m_wire_section && \
|
2014-09-28 09:47:06 +00:00
|
|
|
other.m_show_text == m_show_text &&\
|
2013-12-03 10:17:49 +00:00
|
|
|
other.text_size == text_size &&\
|
2015-12-23 18:41:13 +00:00
|
|
|
other.cond_size == cond_size &&\
|
2013-06-02 21:37:04 +00:00
|
|
|
other.verti_rotate_text == verti_rotate_text &&\
|
|
|
|
other.horiz_rotate_text == horiz_rotate_text &&\
|
2014-10-03 17:02:01 +00:00
|
|
|
other.singleLineProperties == singleLineProperties &&\
|
2018-04-28 13:35:23 +00:00
|
|
|
other.m_one_text_per_folio == m_one_text_per_folio &&\
|
|
|
|
other.m_horizontal_alignment == m_horizontal_alignment &&\
|
|
|
|
other.m_vertical_alignment == m_vertical_alignment
|
2007-10-14 15:16:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2007-10-21 16:10:21 +00:00
|
|
|
/**
|
|
|
|
@param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
|
|
|
|
@return true si les deux ensembles de proprietes sont differents, false sinon
|
|
|
|
*/
|
2013-12-03 10:17:49 +00:00
|
|
|
bool ConductorProperties::operator!=(const ConductorProperties &other) const{
|
2014-09-28 09:47:06 +00:00
|
|
|
return(!(*this == other));
|
2007-10-14 15:16:37 +00:00
|
|
|
}
|
|
|
|
|
2009-11-22 16:12:22 +00:00
|
|
|
/**
|
|
|
|
Applique les styles passes en parametre dans cet objet
|
|
|
|
@param style_string Chaine decrivant le style du conducteur
|
|
|
|
*/
|
|
|
|
void ConductorProperties::readStyle(const QString &style_string) {
|
|
|
|
style = Qt::SolidLine; // style par defaut
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2009-11-22 16:12:22 +00:00
|
|
|
if (style_string.isEmpty()) return;
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2009-11-22 16:12:22 +00:00
|
|
|
// recupere la liste des couples style / valeur
|
2020-06-09 22:41:01 +02:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
|
2009-11-22 16:12:22 +00:00
|
|
|
QStringList styles = style_string.split(";", QString::SkipEmptyParts);
|
2020-06-09 22:41:01 +02:00
|
|
|
#else
|
2020-07-19 22:06:42 +02:00
|
|
|
#pragma message("@TODO remove code QString::SkipEmptyParts for QT 5.14 or later")
|
2020-06-09 22:41:01 +02:00
|
|
|
QStringList styles = style_string.split(";", Qt::SkipEmptyParts);
|
|
|
|
#endif
|
2020-09-18 23:04:34 +02:00
|
|
|
|
2020-09-23 22:19:13 +02:00
|
|
|
QRegularExpression Rx("^(?<name>[a-z-]+): (?<value>[a-z-]+)$");
|
|
|
|
if (!Rx.isValid())
|
|
|
|
{
|
|
|
|
qWarning() <<"this is an error in the code"
|
|
|
|
<< Rx.errorString()
|
|
|
|
<< Rx.patternErrorOffset();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
foreach (QString style_str, styles)
|
|
|
|
{
|
|
|
|
QRegularExpressionMatch match = Rx.match(style_str);
|
|
|
|
if (!match.hasMatch())
|
|
|
|
{
|
|
|
|
qDebug()<<"no Match"
|
|
|
|
<<style_str;
|
|
|
|
} else {
|
|
|
|
QString style_name = match.captured("name");
|
|
|
|
QString style_value = match.captured("value");
|
2009-11-22 16:12:22 +00:00
|
|
|
if (style_name == "line-style") {
|
|
|
|
if (style_value == "dashed") style = Qt::DashLine;
|
2013-02-11 18:35:18 +00:00
|
|
|
else if (style_value == "dashdotted") style = Qt::DashDotLine;
|
2009-11-22 16:12:22 +00:00
|
|
|
else if (style_value == "normal") style = Qt::SolidLine;
|
2020-09-23 22:19:13 +02:00
|
|
|
else {
|
|
|
|
qWarning()<<"style_value not known"
|
|
|
|
<<style_value;
|
|
|
|
}
|
2009-11-22 16:12:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Exporte le style du conducteur sous forme d'une chaine de caracteres
|
|
|
|
@return une chaine de caracteres decrivant le style du conducteur
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
QString ConductorProperties::writeStyle() const
|
|
|
|
{
|
2009-11-22 16:12:22 +00:00
|
|
|
if (style == Qt::DashLine) {
|
|
|
|
return("line-style: dashed;");
|
2013-02-11 18:35:18 +00:00
|
|
|
} else if (style == Qt::DashDotLine) {
|
|
|
|
return("line-style: dashdotted");
|
2009-11-22 16:12:22 +00:00
|
|
|
} else {
|
|
|
|
return(QString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-21 16:10:21 +00:00
|
|
|
/**
|
|
|
|
@param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
|
|
|
|
@return true si les deux ensembles de proprietes sont identiques, false sinon
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
int SingleLineProperties::operator==(const SingleLineProperties &other) const
|
|
|
|
{
|
2007-10-14 15:16:37 +00:00
|
|
|
return(
|
|
|
|
other.hasGround == hasGround &&\
|
|
|
|
other.hasNeutral == hasNeutral &&\
|
2012-08-12 20:32:53 +00:00
|
|
|
other.is_pen == is_pen &&\
|
2007-10-14 15:16:37 +00:00
|
|
|
other.phases == phases
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2007-10-21 16:10:21 +00:00
|
|
|
/**
|
|
|
|
@param other l'autre ensemble de proprietes avec lequel il faut effectuer la comparaison
|
|
|
|
@return true si les deux ensembles de proprietes sont differents, false sinon
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
int SingleLineProperties::operator!=(const SingleLineProperties &other) const
|
|
|
|
{
|
2007-10-14 15:16:37 +00:00
|
|
|
return(!(other == (*this)));
|
|
|
|
}
|
2007-11-14 20:27:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
@param settings Parametres a ecrire
|
|
|
|
@param prefix prefix a ajouter devant les noms des parametres
|
|
|
|
*/
|
2020-08-18 21:46:39 +02:00
|
|
|
void SingleLineProperties::toSettings(QSettings &settings,
|
2020-09-07 22:03:40 +02:00
|
|
|
const QString &prefix) const
|
|
|
|
{
|
2007-11-14 20:27:45 +00:00
|
|
|
settings.setValue(prefix + "hasGround", hasGround);
|
|
|
|
settings.setValue(prefix + "hasNeutral", hasNeutral);
|
|
|
|
settings.setValue(prefix + "phases", phases);
|
2012-08-12 20:32:53 +00:00
|
|
|
settings.setValue(prefix + "pen", is_pen);
|
2007-11-14 20:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@param settings Parametres a lire
|
|
|
|
@param prefix prefix a ajouter devant les noms des parametres
|
|
|
|
*/
|
2020-08-18 21:46:39 +02:00
|
|
|
void SingleLineProperties::fromSettings(QSettings &settings,
|
|
|
|
const QString &prefix) {
|
2007-11-14 20:27:45 +00:00
|
|
|
hasGround = settings.value(prefix + "hasGround", true).toBool();
|
|
|
|
hasNeutral = settings.value(prefix + "hasNeutral", true).toBool();
|
|
|
|
phases = settings.value(prefix + "phases", 1).toInt();
|
2012-08-12 20:32:53 +00:00
|
|
|
is_pen = settings.value(prefix + "pen", false).toBool();
|
2007-11-14 20:27:45 +00:00
|
|
|
}
|