1 /* 2 Copyright 2006-2019 The QElectroTech Team 3 This file is part of QElectroTech. 4 5 QElectroTech is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 2 of the License, or 8 (at your option) any later version. 9 10 QElectroTech is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 #ifndef CONDUCTOR_PROPERTIES_H 19 #define CONDUCTOR_PROPERTIES_H 20 21 #include "qet.h" 22 #include <QColor> 23 24 class QPainter; 25 26 /** 27 This class represents the properties of a singleline conductor. 28 */ 29 class SingleLineProperties { 30 public: 31 SingleLineProperties(); 32 virtual ~SingleLineProperties(); 33 34 void setPhasesCount(int); 35 unsigned short int phasesCount(); 36 bool isPen() const; 37 void draw(QPainter *, QET::ConductorSegmentType, const QRectF &); 38 void toXml(QDomElement &) const; 39 void fromXml(QDomElement &); 40 void toSettings(QSettings &, const QString & = QString()) const; 41 void fromSettings(QSettings &, const QString & = QString()); 42 43 /// Whether the singleline conductor should display the ground symbol 44 bool hasGround; 45 /// Whether the singleline conductor should display the neutral symbol 46 bool hasNeutral; 47 /// Protective Earth Neutral: visually merge neutral and ground 48 bool is_pen; 49 50 int operator==(const SingleLineProperties &) const; 51 int operator!=(const SingleLineProperties &) const; 52 53 private: 54 unsigned short int phases; 55 void drawGround (QPainter *, QET::ConductorSegmentType, QPointF, qreal); 56 void drawNeutral(QPainter *, QET::ConductorSegmentType, QPointF, qreal); 57 void drawPen(QPainter *, QET::ConductorSegmentType, QPointF, qreal); 58 }; 59 60 /** 61 This class represents the functional properties of a particular conductor, 62 i.e. properties other than path and terminals. 63 */ 64 class ConductorProperties 65 { 66 public: 67 ConductorProperties(); 68 virtual ~ConductorProperties(); 69 70 /** 71 * @brief The ConductorType enum Represents the kind of a particular conductor: 72 * Single: singleline symbols, no text input 73 * Multi: text input, no symbol 74 */ 75 enum ConductorType { Single, Multi }; 76 77 78 //Attributes 79 ConductorType type; 80 81 QColor color, 82 m_color_2; 83 84 QString text, 85 m_function, 86 m_tension_protocol, 87 m_formula; 88 89 int text_size, 90 m_dash_size = 1; 91 92 double cond_size, 93 verti_rotate_text, 94 horiz_rotate_text; 95 96 bool m_show_text, 97 m_one_text_per_folio, 98 m_bicolor = false; 99 100 Qt::Alignment m_horizontal_alignment = Qt::AlignBottom, 101 m_vertical_alignment = Qt::AlignRight; 102 103 Qt::PenStyle style; 104 105 SingleLineProperties singleLineProperties; 106 107 // methods 108 void toXml(QDomElement &) const; 109 void fromXml(QDomElement &); 110 void toSettings(QSettings &, const QString & = QString()) const; 111 void fromSettings(QSettings &, const QString & = QString()); 112 static QString typeToString(ConductorType); 113 void applyForEqualAttributes(QList<ConductorProperties> list); 114 115 static ConductorProperties defaultProperties(); 116 117 // operators 118 bool operator==(const ConductorProperties &) const; 119 bool operator!=(const ConductorProperties &) const; 120 121 private: 122 void readStyle(const QString &); 123 QString writeStyle() const; 124 }; 125 126 Q_DECLARE_METATYPE(ConductorProperties) 127 128 #endif 129