71 QPen pen(painter -> pen());
72 pen.setCapStyle(Qt::FlatCap);
73 pen.setJoinStyle(Qt::MiterJoin);
74 pen.setStyle(Qt::SolidLine);
76 painter -> setPen(pen);
77 painter -> setRenderHint(QPainter::Antialiasing,
true);
80 qreal interleave_base = (direction ==
QET::Horizontal ? rect.width() : rect.height());
81 qreal interleave = interleave_base / (symbols_count + 1);;
82 qreal symbol_width = interleave_base / 12;
84 for (uint i = 1 ; i <= symbols_count ; ++ i) {
86 QPointF symbol_p1, symbol_p2;
88 symbol_p1 = QPointF(rect.x() + (i * interleave) + symbol_width, rect.y() + rect.height() * 0.75);
89 symbol_p2 = QPointF(rect.x() + (i * interleave) - symbol_width, rect.y() + rect.height() * 0.25);
91 symbol_p2 = QPointF(rect.x() + rect.width() * 0.75, rect.y() + (i * interleave) - symbol_width);
92 symbol_p1 = QPointF(rect.x() + rect.width() * 0.25, rect.y() + (i * interleave) + symbol_width);
94 painter -> drawLine(QLineF(symbol_p1, symbol_p2));
99 drawPen(painter, direction, symbol_p2, symbol_width);
103 drawGround(painter, direction, symbol_p2, symbol_width * 2.0);
105 drawNeutral(painter, direction, symbol_p2, symbol_width * 1.5);
109 painter -> restore();
123 painter -> setRenderHint(QPainter::Antialiasing,
false);
124 QPen pen2(painter -> pen());
125 pen2.setCapStyle(Qt::SquareCap);
126 painter -> setPen(pen2);
129 qreal half_size = size / 2.0;
130 QPointF offset_point(
136 center + offset_point,
137 center - offset_point
141 painter -> restore();
156 if (painter -> brush() == Qt::NoBrush) painter -> setBrush(Qt::black);
157 painter -> setPen(Qt::NoPen);
160 painter -> drawEllipse(
162 center - QPointF(size / 2.0, size / 2.0),
167 painter -> restore();
186 drawNeutral(painter, direction, center, size * 1.5);
188 int offset = (size * 1.5 / 2.0);
189 QPointF pos = center + (direction ==
QET::Horizontal ? QPointF(0.0, -offset - 0.5) : QPointF(offset + 0.5, 0.0));
190 drawGround(painter, direction, pos, 2.0 * size);
191 painter -> restore();
200 e.setAttribute(
"ground",
hasGround ?
"true" :
"false");
201 e.setAttribute(
"neutral",
hasNeutral ?
"true" :
"false");
202 e.setAttribute(
"phase",
phases);
203 if (
isPen()) e.setAttribute(
"pen",
"true");
212 hasGround = e.attribute(
"ground") ==
"true";
213 hasNeutral = e.attribute(
"neutral") ==
"true";
228 verti_rotate_text(270),
229 horiz_rotate_text(0),
231 m_one_text_per_folio(false),
251 if (
color != QColor(Qt::black))
252 e.setAttribute(
"color",
color.name());
254 e.setAttribute(
"bicolor",
m_bicolor?
"true" :
"false");
255 e.setAttribute(
"color2",
m_color_2.name());
256 e.setAttribute(
"dash-size", QString::number(
m_dash_size));
261 e.setAttribute(
"num",
text);
265 e.setAttribute(
"numsize", QString::number(
text_size));
266 e.setAttribute(
"condsize", QString::number(
cond_size));
272 QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
277 if (!conductor_style.isEmpty())
278 e.setAttribute(
"style", conductor_style);
290 QColor xml_color= QColor(e.attribute(
"color"));
291 color = (xml_color.isValid()? xml_color : QColor(Qt::black));
293 QString bicolor_str = e.attribute(
"bicolor",
"false");
294 m_bicolor = bicolor_str ==
"true"? true :
false;
296 QColor xml_color_2 = QColor(e.attribute(
"color2"));
297 m_color_2 = xml_color_2.isValid()? xml_color_2 : QColor(Qt::black);
299 m_dash_size = e.attribute(
"dash-size", QString::number(1)).toInt();
313 text = e.attribute(
"num");
317 text_size = e.attribute(
"numsize", QString::number(9)).toInt();
318 cond_size = e.attribute(
"condsize", QString::number(1)).toDouble();
319 m_show_text = e.attribute(
"displaytext", QString::number(1)).toInt();
324 QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
325 m_horizontal_alignment = Qt::Alignment(me.keyToValue(e.attribute(
"horizontal-alignment",
"AlignBottom").toStdString().data()));
326 m_vertical_alignment = Qt::Alignment(me.keyToValue(e.attribute(
"vertical-alignment",
"AlignRight").toStdString().data()));
331 if (e.attribute(
"type") ==
"simple")
m_show_text =
false;
340 settings.setValue(prefix +
"color",
color.name());
341 settings.setValue(prefix +
"bicolor",
m_bicolor);
342 settings.setValue(prefix +
"color2",
m_color_2.name());
343 settings.setValue(prefix +
"dash-size",
m_dash_size);
344 settings.setValue(prefix +
"style",
writeStyle());
346 settings.setValue(prefix +
"text",
text);
347 settings.setValue(prefix +
"formula",
m_formula);
348 settings.setValue(prefix +
"function",
m_function);
350 settings.setValue(prefix +
"textsize", QString::number(
text_size));
351 settings.setValue(prefix +
"size", QString::number(
cond_size));
352 settings.setValue(prefix +
"displaytext",
m_show_text);
354 settings.setValue(prefix +
"vertirotatetext", QString::number(
verti_rotate_text));
355 settings.setValue(prefix +
"horizrotatetext", QString::number(
horiz_rotate_text));
357 QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
370 QColor settings_color = QColor(settings.value(prefix +
"color").toString());
371 color = (settings_color.isValid()? settings_color : QColor(Qt::black));
373 QColor settings_color_2 = QColor(settings.value(prefix +
"color2").toString());
374 m_color_2 = (settings_color_2.isValid()? settings_color_2 : QColor(Qt::black));
376 m_bicolor = settings.value(prefix +
"bicolor",
false).toBool();
377 m_dash_size = settings.value(prefix +
"dash-size", 1).toInt();
379 QString setting_type = settings.value(prefix +
"type",
typeToString(
Multi)).toString();
384 text = settings.value(prefix +
"text",
"_").toString();
385 m_formula = settings.value(prefix +
"formula",
"").toString();
386 m_function = settings.value(prefix +
"function",
"").toString();
388 text_size = settings.value(prefix +
"textsize",
"7").toInt();
389 cond_size = settings.value(prefix +
"size",
"1").toInt();
390 m_show_text = settings.value(prefix +
"displaytext",
true).toBool();
392 verti_rotate_text = settings.value((prefix +
"vertirotatetext"),
"270").toDouble();
393 horiz_rotate_text = settings.value((prefix +
"horizrotatetext"),
"0").toDouble();
395 QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
396 m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix +
"horizontal-alignment",
"AlignBottom").toString().toStdString().data()));
397 m_vertical_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix +
"vertical-alignment",
"AlignRight").toString().toStdString().data()));
399 readStyle(settings.value(prefix +
"style").toString());
409 case Single:
return(
"single");
410 case Multi:
return(
"multi");
423 const QList<ConductorProperties> clist = std::move(list);
428 if (clist.size() == 1)
457 Qt::Alignment align_value;
460 c_value = clist.first().color;
463 if (cp.color != c_value)
471 b_value = clist.first().m_bicolor;
474 if (cp.m_bicolor != b_value)
482 c_value = clist.first().m_color_2;
485 if (cp.m_color_2 != c_value)
493 i_value = clist.first().m_dash_size;
496 if (cp.m_dash_size != i_value)
504 s_value = clist.first().text;
507 if (cp.text != s_value)
515 s_value = clist.first().m_formula;
518 if (cp.m_formula != s_value)
526 s_value = clist.first().m_function;
529 if (cp.m_function != s_value)
537 s_value = clist.first().m_tension_protocol;
540 if (cp.m_tension_protocol != s_value)
548 i_value = clist.first().text_size;
551 if (cp.text_size != i_value)
559 d_value = clist.first().cond_size;
562 if (cp.cond_size != d_value)
570 b_value = clist.first().m_show_text;
573 if (cp.m_show_text != b_value)
581 b_value = clist.first().m_one_text_per_folio;
584 if (cp.m_one_text_per_folio != b_value)
592 d_value = clist.first().verti_rotate_text;
595 if (cp.verti_rotate_text != d_value)
603 d_value = clist.first().horiz_rotate_text;
606 if (cp.horiz_rotate_text != d_value)
614 align_value = clist.first().m_horizontal_alignment;
617 if (cp.m_horizontal_alignment != align_value)
625 align_value = clist.first().m_vertical_alignment;
628 if (cp.m_vertical_alignment != align_value)
645 def.
fromSettings(settings,
"diagrameditor/defaultconductor");
685 return(!(*
this == other));
693 style = Qt::SolidLine;
695 if (style_string.isEmpty())
return;
698 QStringList styles = style_string.split(
";", QString::SkipEmptyParts);
700 QRegExp rx(
"^\\s*([a-z-]+)\\s*:\\s*([a-z-]+)\\s*$");
701 foreach (QString style_str, styles) {
702 if (rx.exactMatch(style_str)) {
703 QString style_name = rx.cap(1);
704 QString style_value = rx.cap(2);
705 if (style_name ==
"line-style") {
706 if (style_value ==
"dashed")
style = Qt::DashLine;
707 else if (style_value ==
"dashdotted")
style = Qt::DashDotLine;
708 else if (style_value ==
"normal")
style = Qt::SolidLine;
719 if (
style == Qt::DashLine) {
720 return(
"line-style: dashed;");
721 }
else if (
style == Qt::DashDotLine) {
722 return(
"line-style: dashdotted");
746 return(!(other == (*
this)));
754 settings.setValue(prefix +
"hasGround",
hasGround);
755 settings.setValue(prefix +
"hasNeutral",
hasNeutral);
756 settings.setValue(prefix +
"phases",
phases);
757 settings.setValue(prefix +
"pen",
is_pen);
765 hasGround = settings.value(prefix +
"hasGround",
true).toBool();
766 hasNeutral = settings.value(prefix +
"hasNeutral",
true).toBool();
767 phases = settings.value(prefix +
"phases", 1).toInt();
768 is_pen = settings.value(prefix +
"pen",
false).toBool();
bool hasGround
Whether the singleline conductor should display the ground symbol.
static ConductorProperties defaultProperties()
ConductorProperties::defaultProperties.
Qt::Alignment m_vertical_alignment
unsigned short int phasesCount()
static QString typeToString(ConductorType)
int operator!=(const SingleLineProperties &) const
bool m_one_text_per_folio
void readStyle(const QString &)
SingleLineProperties singleLineProperties
void toXml(QDomElement &) const
ConductorProperties::toXml Export conductor propertie, in the XML element 'e'.
Qt::Alignment m_horizontal_alignment
void fromXml(QDomElement &)
ConductorProperties::fromXml Import conductor propertie, from the attribute of the xml element 'e'...
virtual ~SingleLineProperties()
Destructeur.
ConductorSegmentType
Known kinds of conductor segments.
bool hasNeutral
Whether the singleline conductor should display the neutral symbol.
virtual ~ConductorProperties()
void fromSettings(QSettings &, const QString &=QString())
void drawGround(QPainter *, QET::ConductorSegmentType, QPointF, qreal)
bool operator!=(const ConductorProperties &) const
void drawNeutral(QPainter *, QET::ConductorSegmentType, QPointF, qreal)
void toSettings(QSettings &, const QString &=QString()) const
ConductorType
The ConductorType enum Represents the kind of a particular conductor: Single: singleline symbols...
unsigned short int phases
QString m_tension_protocol
bool operator==(const ConductorProperties &) const
ConductorProperties::operator ==.
void fromXml(QDomElement &)
int operator==(const SingleLineProperties &) const
void drawPen(QPainter *, QET::ConductorSegmentType, QPointF, qreal)
void toSettings(QSettings &, const QString &=QString()) const
void fromSettings(QSettings &, const QString &=QString())
bool is_pen
Protective Earth Neutral: visually merge neutral and ground.
QString writeStyle() const
void applyForEqualAttributes(QList< ConductorProperties > list)
ConductorProperties::applyForEqualAttributes Test each attribute of properties in the list separatly...
void draw(QPainter *, QET::ConductorSegmentType, const QRectF &)
void toXml(QDomElement &) const