WIP: Add Kabel to qet

This commit is contained in:
Simon De Backer
2020-09-24 22:39:48 +02:00
parent 30b8205f82
commit 546433cac2
4 changed files with 205 additions and 133 deletions

View File

@@ -283,6 +283,8 @@ void ConductorProperties::toXml(QDomElement &e) const
e.setAttribute("num", text); e.setAttribute("num", text);
e.setAttribute("text_color", text_color.name()); e.setAttribute("text_color", text_color.name());
e.setAttribute("formula", m_formula); e.setAttribute("formula", m_formula);
e.setAttribute("cable", m_cable);
e.setAttribute("bus", m_bus);
e.setAttribute("function", m_function); e.setAttribute("function", m_function);
e.setAttribute("tension_protocol", m_tension_protocol); e.setAttribute("tension_protocol", m_tension_protocol);
e.setAttribute("conductor_color", m_wire_color); e.setAttribute("conductor_color", m_wire_color);
@@ -340,6 +342,8 @@ void ConductorProperties::fromXml(QDomElement &e)
QColor xml_text_color= QColor(e.attribute("text_color")); QColor xml_text_color= QColor(e.attribute("text_color"));
text_color = (xml_text_color.isValid()? xml_text_color : QColor(Qt::black)); text_color = (xml_text_color.isValid()? xml_text_color : QColor(Qt::black));
m_formula = e.attribute("formula"); m_formula = e.attribute("formula");
m_cable = e.attribute("cable");
m_bus = e.attribute("bus");
m_function = e.attribute("function"); m_function = e.attribute("function");
m_tension_protocol = e.attribute("tension_protocol"); m_tension_protocol = e.attribute("tension_protocol");
m_wire_color = e.attribute("conductor_color"); m_wire_color = e.attribute("conductor_color");
@@ -389,6 +393,8 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix)
settings.setValue(prefix + "text", text); settings.setValue(prefix + "text", text);
settings.setValue(prefix + "text_color", text_color.name()); settings.setValue(prefix + "text_color", text_color.name());
settings.setValue(prefix + "formula", m_formula); settings.setValue(prefix + "formula", m_formula);
settings.setValue(prefix + "cable", m_cable);
settings.setValue(prefix + "bus", m_bus);
settings.setValue(prefix + "function", m_function); settings.setValue(prefix + "function", m_function);
settings.setValue(prefix + "tension_protocol", m_tension_protocol); settings.setValue(prefix + "tension_protocol", m_tension_protocol);
settings.setValue(prefix + "conductor_color", m_wire_color); settings.setValue(prefix + "conductor_color", m_wire_color);
@@ -431,6 +437,8 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString()); QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString());
text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black)); text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black));
m_formula = settings.value(prefix + "formula", "").toString(); m_formula = settings.value(prefix + "formula", "").toString();
m_cable = settings.value(prefix + "cable", "").toString();
m_bus = settings.value(prefix + "bus", "").toString();
m_function = settings.value(prefix + "function", "").toString(); m_function = settings.value(prefix + "function", "").toString();
m_tension_protocol = settings.value(prefix + "tension_protocol", "").toString(); m_tension_protocol = settings.value(prefix + "tension_protocol", "").toString();
m_wire_color = settings.value(prefix + "conductor_color", "").toString(); m_wire_color = settings.value(prefix + "conductor_color", "").toString();
@@ -485,6 +493,8 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
text = cp.text; text = cp.text;
text_color = cp.text_color; text_color = cp.text_color;
m_formula = cp.m_formula; m_formula = cp.m_formula;
m_cable = cp.m_cable;
m_bus = cp.m_bus;
m_function = cp.m_function; m_function = cp.m_function;
m_tension_protocol = cp.m_tension_protocol; m_tension_protocol = cp.m_tension_protocol;
m_wire_color = cp.m_wire_color; m_wire_color = cp.m_wire_color;
@@ -586,7 +596,29 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
m_formula = s_value; m_formula = s_value;
equal = true; equal = true;
//function //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;
//function
s_value = clist.first().m_function; s_value = clist.first().m_function;
for(ConductorProperties cp : clist) for(ConductorProperties cp : clist)
{ {
@@ -751,6 +783,8 @@ bool ConductorProperties::operator==(const ConductorProperties &other) const
other.text == text &&\ other.text == text &&\
other.text_color == text_color &&\ other.text_color == text_color &&\
other.m_formula == m_formula &&\ other.m_formula == m_formula &&\
other.m_cable == m_cable &&\
other.m_bus == m_bus &&\
other.m_function == m_function &&\ other.m_function == m_function &&\
other.m_tension_protocol == m_tension_protocol &&\ other.m_tension_protocol == m_tension_protocol &&\
other.m_wire_color == m_wire_color && \ other.m_wire_color == m_wire_color && \
@@ -797,7 +831,7 @@ void ConductorProperties::readStyle(const QString &style_string) {
QRegularExpression Rx("^(?<name>[a-z-]+): (?<value>[a-z-]+)$"); QRegularExpression Rx("^(?<name>[a-z-]+): (?<value>[a-z-]+)$");
if (!Rx.isValid()) if (!Rx.isValid())
{ {
qWarning() <<"this is an error in the code" qWarning() <<QObject::tr("this is an error in the code")
<< Rx.errorString() << Rx.errorString()
<< Rx.patternErrorOffset(); << Rx.patternErrorOffset();
return; return;

View File

@@ -1,17 +1,17 @@
/* /*
Copyright 2006-2020 The QElectroTech Team Copyright 2006-2020 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
@@ -41,17 +41,17 @@ class SingleLineProperties {
void fromXml(QDomElement &); void fromXml(QDomElement &);
void toSettings(QSettings &, const QString & = QString()) const; void toSettings(QSettings &, const QString & = QString()) const;
void fromSettings(QSettings &, const QString & = QString()); void fromSettings(QSettings &, const QString & = QString());
/// Whether the singleline conductor should display the ground symbol /// Whether the singleline conductor should display the ground symbol
bool hasGround; bool hasGround;
/// Whether the singleline conductor should display the neutral symbol /// Whether the singleline conductor should display the neutral symbol
bool hasNeutral; bool hasNeutral;
/// Protective Earth Neutral: visually merge neutral and ground /// Protective Earth Neutral: visually merge neutral and ground
bool is_pen; bool is_pen;
int operator==(const SingleLineProperties &) const; int operator==(const SingleLineProperties &) const;
int operator!=(const SingleLineProperties &) const; int operator!=(const SingleLineProperties &) const;
private: private:
unsigned short int phases; unsigned short int phases;
void drawGround (QPainter *, QET::ConductorSegmentType, QPointF, qreal); void drawGround (QPainter *, QET::ConductorSegmentType, QPointF, qreal);
@@ -69,7 +69,7 @@ class ConductorProperties
public: public:
ConductorProperties(); ConductorProperties();
virtual ~ConductorProperties(); virtual ~ConductorProperties();
/** /**
@brief The ConductorType enum Represents @brief The ConductorType enum Represents
the kind of a particular conductor: the kind of a particular conductor:
@@ -81,36 +81,44 @@ class ConductorProperties
//Attributes //Attributes
ConductorType type; ConductorType type;
QColor color, QColor
m_color_2, color,
text_color; m_color_2,
text_color;
QString text,
m_function, QString
m_tension_protocol, text,
m_wire_color, m_function,
m_wire_section, m_tension_protocol,
m_formula; m_wire_color,
m_wire_section,
int text_size, m_formula,
m_dash_size = 1; m_bus,
m_cable;
double cond_size,
verti_rotate_text, int
horiz_rotate_text; text_size,
m_dash_size = 1;
bool m_show_text,
m_one_text_per_folio, double
m_bicolor = false; cond_size,
verti_rotate_text,
Qt::Alignment m_horizontal_alignment = Qt::AlignBottom, horiz_rotate_text;
m_vertical_alignment = Qt::AlignRight;
bool
m_show_text,
m_one_text_per_folio,
m_bicolor = false;
Qt::Alignment
m_horizontal_alignment = Qt::AlignBottom,
m_vertical_alignment = Qt::AlignRight;
Qt::PenStyle style; Qt::PenStyle style;
SingleLineProperties singleLineProperties; SingleLineProperties singleLineProperties;
// methods // methods
void toXml(QDomElement &) const; void toXml(QDomElement &) const;
void fromXml(QDomElement &); void fromXml(QDomElement &);
@@ -120,11 +128,11 @@ class ConductorProperties
void applyForEqualAttributes(QList<ConductorProperties> list); void applyForEqualAttributes(QList<ConductorProperties> list);
static ConductorProperties defaultProperties(); static ConductorProperties defaultProperties();
// operators // operators
bool operator==(const ConductorProperties &) const; bool operator==(const ConductorProperties &) const;
bool operator!=(const ConductorProperties &) const; bool operator!=(const ConductorProperties &) const;
private: private:
void readStyle(const QString &); void readStyle(const QString &);
QString writeStyle() const; QString writeStyle() const;

View File

@@ -73,7 +73,7 @@ void ConductorPropertiesWidget::setProperties(
{ {
if (m_properties == properties) if (m_properties == properties)
return; return;
m_properties = properties; m_properties = properties;
int index = ui -> m_line_style_cb -> findData(QPen(m_properties.style)); int index = ui -> m_line_style_cb -> findData(QPen(m_properties.style));
@@ -84,6 +84,8 @@ void ConductorPropertiesWidget::setProperties(
ui->m_formula_le -> setText (m_properties.m_formula); ui->m_formula_le -> setText (m_properties.m_formula);
ui->m_text_le -> setText (m_properties.text); ui->m_text_le -> setText (m_properties.text);
ui->m_function_le -> setText (m_properties.m_function); 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_tension_protocol_le -> setText (m_properties.m_tension_protocol); 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_color_le -> setText (m_properties.m_wire_color);
ui->m_wire_section_le -> setText (m_properties.m_wire_section); ui->m_wire_section_le -> setText (m_properties.m_wire_section);
@@ -128,6 +130,8 @@ ConductorProperties ConductorPropertiesWidget::properties() const
properties_.text = ui -> m_text_le -> text(); properties_.text = ui -> m_text_le -> text();
properties_.text_color = ui -> m_text_color_kpb->color(); properties_.text_color = ui -> m_text_color_kpb->color();
properties_.m_function = ui -> m_function_le->text(); 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_tension_protocol = ui -> m_tension_protocol_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_color = ui -> m_wire_color_le->text();
properties_.m_wire_section = ui -> m_wire_section_le->text(); properties_.m_wire_section = ui -> m_wire_section_le->text();
@@ -237,6 +241,12 @@ void ConductorPropertiesWidget::initWidget()
connect(ui->m_formula_le, &QLineEdit::textChanged, [this](QString text) {this->ui->m_text_le->setEnabled(text.isEmpty());}); connect(ui->m_formula_le, &QLineEdit::textChanged, [this](QString text) {this->ui->m_text_le->setEnabled(text.isEmpty());});
ui->m_multiwires_gb->setChecked(true); ui->m_multiwires_gb->setChecked(true);
ui->m_singlewire_gb->setChecked(true); ui->m_singlewire_gb->setChecked(true);
#if TODO_LIST
#pragma message("@TODO Add Kabel and Bus to qet")
#else
ui->m_cable_le->setDisabled(true);
ui->m_bus_le->setDisabled(true);
#endif
} }
/** /**
@@ -262,7 +272,7 @@ void ConductorPropertiesWidget::setConductorType(ConductorProperties::ConductorT
@brief ConductorPropertiesWidget::updatePreview @brief ConductorPropertiesWidget::updatePreview
Update the preview for single lien Update the preview for single lien
@param b true: update from the value displayed by this widget @param b true: update from the value displayed by this widget
false: update from the properties given at the constructor of this widget false: update from the properties given at the constructor of this widget
*/ */
void ConductorPropertiesWidget::updatePreview(bool b) { void ConductorPropertiesWidget::updatePreview(bool b) {
const QRect pixmap_rect(0, 0, 96, 96); const QRect pixmap_rect(0, 0, 96, 96);

View File

@@ -52,16 +52,50 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="1"> <item row="4" column="0">
<widget class="QLineEdit" name="m_formula_le"/> <widget class="QLabel" name="label_14">
<property name="text">
<string>Couleur du texte:</string>
</property>
</widget>
</item> </item>
<item row="1" column="4"> <item row="3" column="3">
<widget class="QLineEdit" name="m_function_le"> <widget class="QLabel" name="label_4">
<property name="text">
<string>Couleur du conducteur</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="m_available_autonum_cb"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="m_text_le">
<property name="toolTip">
<string>Texte</string>
</property>
<property name="clearButtonEnabled"> <property name="clearButtonEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="3">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Tension / Protocole :</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="m_autonum_label">
<property name="text">
<string>Autonumérotation</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="KColorButton" name="m_text_color_kpb"/>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QSpinBox" name="m_text_size_sb"> <widget class="QSpinBox" name="m_text_size_sb">
<property name="toolTip"> <property name="toolTip">
@@ -84,45 +118,17 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="2" column="4">
<widget class="QLabel" name="label"> <widget class="QLineEdit" name="m_tension_protocol_le">
<property name="text"> <property name="clearButtonEnabled">
<string>Texte :</string> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="4" column="3">
<widget class="QLabel" name="label_11"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
<string>Formule du texte :</string> <string>Section du conducteur</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QPushButton" name="m_edit_autonum_pb">
<property name="toolTip">
<string>éditer les numérotations</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/16x16/configure.png</normaloff>:/ico/16x16/configure.png</iconset>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Tension / Protocole :</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Couleur du conducteur</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -139,32 +145,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="2">
<layout class="QVBoxLayout" name="m_autonum_layout"/>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="m_available_autonum_cb"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="m_autonum_label">
<property name="text">
<string>Autonumérotation</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="KColorButton" name="m_text_color_kpb"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Couleur du texte:</string>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QLineEdit" name="m_wire_section_le"/>
</item>
<item row="0" column="0" colspan="3"> <item row="0" column="0" colspan="3">
<widget class="QCheckBox" name="m_one_text_per_folio_cb"> <widget class="QCheckBox" name="m_one_text_per_folio_cb">
<property name="toolTip"> <property name="toolTip">
@@ -175,10 +155,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="4"> <item row="1" column="3">
<widget class="QLineEdit" name="m_wire_color_le"/> <widget class="QLabel" name="label_8">
<property name="text">
<string>Fonction :</string>
</property>
</widget>
</item> </item>
<item row="7" column="0" colspan="5"> <item row="8" column="0" colspan="5">
<layout class="QGridLayout" name="m_text_angle_gl"> <layout class="QGridLayout" name="m_text_angle_gl">
<item row="1" column="0"> <item row="1" column="0">
<widget class="QComboBox" name="m_verti_cb"> <widget class="QComboBox" name="m_verti_cb">
@@ -220,6 +204,19 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="7" column="0" colspan="2">
<layout class="QVBoxLayout" name="m_autonum_layout"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Texte :</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QLineEdit" name="m_wire_color_le"/>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
@@ -227,37 +224,60 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="3"> <item row="6" column="2">
<widget class="QLabel" name="label_5"> <widget class="QPushButton" name="m_edit_autonum_pb">
<property name="text">
<string>Section du conducteur</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Fonction :</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QLineEdit" name="m_tension_protocol_le">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="m_text_le">
<property name="toolTip"> <property name="toolTip">
<string>Texte</string> <string>éditer les numérotations</string>
</property> </property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../qelectrotech.qrc">
<normaloff>:/ico/16x16/configure.png</normaloff>:/ico/16x16/configure.png</iconset>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLineEdit" name="m_function_le">
<property name="clearButtonEnabled"> <property name="clearButtonEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="4">
<widget class="QLineEdit" name="m_wire_section_le"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Formule du texte :</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="m_formula_le"/>
</item>
<item row="6" column="3">
<widget class="QLabel" name="label_15">
<property name="text">
<string>cable</string>
</property>
</widget>
</item>
<item row="6" column="4">
<widget class="QLineEdit" name="m_cable_le"/>
</item>
<item row="7" column="3">
<widget class="QLabel" name="label_16">
<property name="text">
<string>bus</string>
</property>
</widget>
</item>
<item row="7" column="4">
<widget class="QLineEdit" name="m_bus_le"/>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>