QElectroTech  0.8-dev
qet.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 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 _QET_H
19 #define _QET_H
20 
21 #include <QDomElement>
22 #include <QFile>
23 #include <QObject>
24 
25 class QActionGroup;
30 namespace QET {
32  const QString version = "0.80";
34  const QString displayedVersion = "0.80-DEV";
35  QString license();
36 
37  //Describe the current state of a graphic item
39  GIOK,
42  };
43 
45  enum DepthOption {
50  };
51 
62  };
63 
67  RotateArea = -3,
68  MoveArea = -2,
78  };
79 
85  };
86 
89  Horizontal = 1,
90  Vertical = 2,
91  Both = 3
92  };
93 
94 
99  enum ItemType {
100  Element = 1,
108  Diagram = 32,
109  Project = 64,
110  All = 127
111  };
112 
116  enum Filtering {
119  EndFilter
120  };
121 
127  enum Action {
133  Rename
134  };
135 
139  enum DiagramArea {
141  ElementsArea
142  };
143 
149  };
150 
155  Embedded
156  };
157 
158  QString qetCollectionToString (const QetCollection &c);
159  QetCollection qetCollectionFromString (const QString &str);
160 
161  bool lineContainsPoint(const QLineF &, const QPointF &);
162  bool orthogonalProjection(const QPointF &, const QLineF &, QPointF * = nullptr);
163  bool attributeIsAnInteger(const QDomElement &, const QString& , int * = nullptr);
164  bool attributeIsAReal(const QDomElement &, const QString& , qreal * = nullptr);
165  QString ElementsAndConductorsSentence(int elements=0, int conductors=0, int indi_texts=0, int images=0, int shapes=0, int element_text=0, int tables_count=0);
166  QList<QDomElement> findInDomElement(const QDomElement &, const QString &);
167  QList<QDomElement> findInDomElement(const QDomElement &, const QString &, const QString &);
168  QList<QChar> forbiddenCharacters();
169  QString stringToFileName(const QString &);
170  QString escapeSpaces(const QString &);
171  QString unescapeSpaces(const QString &);
172  QString joinWithSpaces(const QStringList &);
173  QStringList splitWithSpaces(const QString &);
174  QString diagramAreaToString(const QET::DiagramArea &);
175  QET::DiagramArea diagramAreaFromString(const QString &);
176  qreal round(qreal, qreal);
177  qreal correctAngle(const qreal &);
178  bool compareCanonicalFilePaths(const QString &, const QString &);
179  bool writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString * error_message= nullptr);
180  bool writeToFile (QDomDocument &xml_doc, QFile *file, QString *error_message = nullptr);
181  bool eachStrIsEqual (const QStringList &qsl);
182  QActionGroup *depthActionGroup(QObject *parent = nullptr);
183 }
184 
186 
187 class Qet : public QObject
188 {
189  Q_OBJECT
190 
191  public:
193  enum EndType {
198  Diamond
199  };
200  Q_ENUM (EndType)
201 
202  static QString endTypeToString(const Qet::EndType &);
203  static Qet::EndType endTypeFromString(const QString &);
204 
210  Q_ENUM (Orientation)
211 
212  static Qet::Orientation nextOrientation(Qet::Orientation);
213  static Qet::Orientation previousOrientation(Qet::Orientation);
214 
215  static Qet::Orientation orientationFromString (const QString &);
216  static QString orientationToString (Qet::Orientation);
217 
218  static bool surLeMemeAxe (Qet::Orientation, Qet::Orientation);
219  static bool isOpposed (Qet::Orientation a, Qet::Orientation b);
220  static bool isHorizontal (Qet::Orientation);
221  static bool isVertical (Qet::Orientation);
222 };
223 
224 #endif
QET::Project
@ Project
Definition: qet.h:109
QET::NoOperation
@ NoOperation
Definition: qet.h:69
QET::Icons::Lower
QIcon Lower
Definition: qeticons.cpp:117
Qet::isOpposed
static bool isOpposed(Qet::Orientation a, Qet::Orientation b)
Qet::isOpposed.
Definition: qet.cpp:77
Qet::West
@ West
Definition: qet.h:209
QET::RelativeToTotalLength
@ RelativeToTotalLength
the length is just a fraction of the total available length
Definition: qet.h:147
QET::Ignore
@ Ignore
Skip the current item.
Definition: qet.h:129
QET::All
@ All
Definition: qet.h:110
QET::Icons::West
QIcon West
Definition: qeticons.cpp:174
QET::ElementsArea
@ ElementsArea
Export the content of the diagram only.
Definition: qet.h:141
QET::ToEast
@ ToEast
Definition: qet.h:56
QET::round
qreal round(qreal, qreal)
Definition: qet.cpp:537
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(NamesList)
Qet::None
@ None
Regular line.
Definition: qet.h:194
QET::depthActionGroup
QActionGroup * depthActionGroup(QObject *parent=nullptr)
QET::depthActionGroup.
Definition: qet.cpp:676
QET::Custom
@ Custom
From user collection.
Definition: qet.h:154
QET::OrientedMovement
OrientedMovement
Oriented movements.
Definition: qet.h:53
QET::ResizeFromBottomRightCorner
@ ResizeFromBottomRightCorner
Definition: qet.h:77
QET::RegularFilter
@ RegularFilter
Definition: qet.h:118
QET::ElementsContainer
@ ElementsContainer
Definition: qet.h:103
QET::OperationAreas
OperationAreas
List areas related to some common operations.
Definition: qet.h:65
QET::version
const QString version
QElectroTech version (as string, used to mark projects and elements XML documents)
Definition: qet.h:32
QET::SnapScalingPointToGrid
@ SnapScalingPointToGrid
snap the point used to define the new bounding rectangle to the grid
Definition: qet.h:83
QET::QetCollection
QetCollection
Enum used to specify the origin of a collection of thing (title block, element etc....
Definition: qet.h:152
QET::lineContainsPoint
bool lineContainsPoint(const QLineF &, const QPointF &)
Definition: qet.cpp:150
QET::ItemType
ItemType
Definition: qet.h:99
Qet::Simple
@ Simple
Base-less triangle.
Definition: qet.h:195
QET::Raise
@ Raise
Raise item one layer above their current one; zValues are incremented.
Definition: qet.h:47
QET::FreeScaling
@ FreeScaling
do not interfer with the default scaling process
Definition: qet.h:82
QET::GraphicsItemState
GraphicsItemState
Definition: qet.h:38
QET::splitWithSpaces
QStringList splitWithSpaces(const QString &)
Definition: qet.cpp:469
QET::diagramAreaFromString
QET::DiagramArea diagramAreaFromString(const QString &)
Definition: qet.cpp:528
QET::ToSouthEast
@ ToSouthEast
Definition: qet.h:57
Qet::Diamond
@ Diamond
Diamond.
Definition: qet.h:198
QET::TitleBlockColumnLength
TitleBlockColumnLength
enum used to specify the type of a length
Definition: qet.h:145
Qet::nextOrientation
static Qet::Orientation nextOrientation(Qet::Orientation)
Definition: qet.cpp:127
QET::ElementsAndConductorsSentence
QString ElementsAndConductorsSentence(int elements=0, int conductors=0, int indi_texts=0, int images=0, int shapes=0, int element_text=0, int tables_count=0)
QET::ElementsAndConductorsSentence Permet de composer rapidement la proposition "x elements et y cond...
Definition: qet.cpp:258
QET::findInDomElement
QList< QDomElement > findInDomElement(const QDomElement &, const QString &)
Definition: qet.cpp:333
QET::Managed
@ Managed
the current item was handled by the Strategy object: do not treat it and continue
Definition: qet.h:132
QET::Icons::SendBackward
QIcon SendBackward
Definition: qeticons.cpp:158
QET::unescapeSpaces
QString unescapeSpaces(const QString &)
Definition: qet.cpp:442
QET::escapeSpaces
QString escapeSpaces(const QString &)
Definition: qet.cpp:433
QET::forbiddenCharacters
QList< QChar > forbiddenCharacters()
Definition: qet.cpp:401
QET::ElementsCollection
@ ElementsCollection
Definition: qet.h:102
QET::eachStrIsEqual
bool eachStrIsEqual(const QStringList &qsl)
QET::eachStrIsEqual.
Definition: qet.cpp:624
QET::SendBackward
@ SendBackward
Send item to the background so they have the lowest zValue.
Definition: qet.h:49
TitleBlockTemplate
The TitleBlockTemplate class This class represents an title block template for an electric diagram....
Definition: titleblocktemplate.h:36
Diagram
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition: diagram.h:56
QET::BringForward
@ BringForward
Bring item to the foreground so they have the highest zValue.
Definition: qet.h:46
QET::orthogonalProjection
bool orthogonalProjection(const QPointF &, const QLineF &, QPointF *=nullptr)
Definition: qet.cpp:166
qeticons.h
QET::ChangeInnerPoints
@ ChangeInnerPoints
Definition: qet.h:66
qet.h
Qet::surLeMemeAxe
static bool surLeMemeAxe(Qet::Orientation, Qet::Orientation)
Definition: qet.cpp:65
QET::stringToFileName
QString stringToFileName(const QString &)
Definition: qet.cpp:414
QET::ResizeFromTopLeftCorner
@ ResizeFromTopLeftCorner
Definition: qet.h:70
QET::displayedVersion
const QString displayedVersion
QElectroTech displayed version.
Definition: qet.h:34
QET::ResizeFromTopCenterCorner
@ ResizeFromTopCenterCorner
Definition: qet.h:71
QET::GIOK
@ GIOK
General state.
Definition: qet.h:39
QET::Rename
@ Rename
the target has to be renamed
Definition: qet.h:133
QET::diagramAreaToString
QString diagramAreaToString(const QET::DiagramArea &)
Definition: qet.cpp:518
QET::correctAngle
qreal correctAngle(const qreal &)
Definition: qet.cpp:545
QET::qetCollectionToString
QString qetCollectionToString(const QetCollection &c)
QET::qetCollectionToString.
Definition: qet.cpp:637
QET::Absolute
@ Absolute
the length is absolute and should be applied as is
Definition: qet.h:146
QET::license
QString license()
Definition: qet.cpp:373
Qet::Orientation
Orientation
Orientation (used for electrical elements and their terminals)
Definition: qet.h:206
QET::BorderArea
@ BorderArea
Export the diagram along with its border and title block.
Definition: qet.h:140
Qet::EndType
EndType
This enum lists the various available endings for line primitives when drawing an electrical element.
Definition: qet.h:193
QET::Icons::North
QIcon North
Definition: qeticons.cpp:122
QET::ToSouthWest
@ ToSouthWest
Definition: qet.h:59
QET::DepthOption
DepthOption
List the various kind of changes for the zValue.
Definition: qet.h:45
QET::writeXmlFile
bool writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString *error_message=nullptr)
Definition: qet.cpp:584
Qet::orientationToString
static QString orientationToString(Qet::Orientation)
Definition: qet.cpp:48
QET::ResizeFromBottomCenterCorner
@ ResizeFromBottomCenterCorner
Definition: qet.h:76
QET::ResizeFromTopRightCorner
@ ResizeFromTopRightCorner
Definition: qet.h:72
QET::Abort
@ Abort
abort the whole operation, ignoring the curent item
Definition: qet.h:131
QET::ToNorthWest
@ ToNorthWest
Definition: qet.h:61
Element
Definition: element.h:41
QET::ElementsCategory
@ ElementsCategory
Definition: qet.h:101
QET::Lower
@ Lower
Send item one layer below their current one; zValues are decremented.
Definition: qet.h:48
QET::compareCanonicalFilePaths
bool compareCanonicalFilePaths(const QString &, const QString &)
Definition: qet.cpp:559
QET::MoveArea
@ MoveArea
Definition: qet.h:68
QET::qetCollectionFromString
QetCollection qetCollectionFromString(const QString &str)
QET::qetCollectionFromString.
Definition: qet.cpp:658
QET::ToNorth
@ ToNorth
Definition: qet.h:54
Qet::previousOrientation
static Qet::Orientation previousOrientation(Qet::Orientation)
Definition: qet.cpp:139
QET::Icons::it
QIcon it
Definition: qeticons.cpp:196
Qet::isHorizontal
static bool isHorizontal(Qet::Orientation)
Qet::isHorizontal.
Definition: qet.cpp:107
Qet::North
@ North
Definition: qet.h:206
QET::ResizeFromMiddleLeftCorner
@ ResizeFromMiddleLeftCorner
Definition: qet.h:73
Qet::endTypeFromString
static Qet::EndType endTypeFromString(const QString &)
Definition: qet.cpp:506
Qet::Circle
@ Circle
Circle.
Definition: qet.h:197
QET::Action
Action
Definition: qet.h:127
QET::EndFilter
@ EndFilter
Definition: qet.h:119
QET::Embedded
@ Embedded
From an embedded collection (a project for exemple)
Definition: qet.h:155
QET::Filtering
Filtering
Definition: qet.h:116
QET::Vertical
@ Vertical
Vertical segment.
Definition: qet.h:90
QET::Icons::Raise
QIcon Raise
Definition: qeticons.cpp:154
Qet::endTypeToString
static QString endTypeToString(const Qet::EndType &)
Definition: qet.cpp:489
QET::Erase
@ Erase
Erase the target content.
Definition: qet.h:130
Qet::South
@ South
Definition: qet.h:208
Qet
Definition: qet.h:188
Qet::orientationFromString
static Qet::Orientation orientationFromString(const QString &)
Definition: qet.cpp:36
QET::attributeIsAnInteger
bool attributeIsAnInteger(const QDomElement &, const QString &, int *=nullptr)
Definition: qet.cpp:210
Qet::isVertical
static bool isVertical(Qet::Orientation)
Qet::isVertical.
Definition: qet.cpp:116
TitleBlockTemplatesCollection
Definition: templatescollection.h:34
QET::writeToFile
bool writeToFile(QDomDocument &xml_doc, QFile *file, QString *error_message=nullptr)
Definition: qet.cpp:703
QET::Both
@ Both
Invalid segment.
Definition: qet.h:91
QET::ConductorSegmentType
ConductorSegmentType
Known kinds of conductor segments.
Definition: qet.h:88
QET::GIBuildingFromXml
@ GIBuildingFromXml
Item is currently building from a xml description (element)
Definition: qet.h:40
QET::ResizeFromBottomLeftCorner
@ ResizeFromBottomLeftCorner
Definition: qet.h:75
Qet::Triangle
@ Triangle
Triangle.
Definition: qet.h:196
QET::ScalingMethod
ScalingMethod
Supported types of interactive scaling, typically for a single element primitive.
Definition: qet.h:81
QET::GILoadingFromXml
@ GILoadingFromXml
Item is loading her properties from a xml description.
Definition: qet.h:41
QET::Horizontal
@ Horizontal
Horizontal segment.
Definition: qet.h:89
QET::TitleBlockTemplatesCollectionItem
@ TitleBlockTemplatesCollectionItem
Definition: qet.h:107
QET::ElementsCollectionItem
@ ElementsCollectionItem
Definition: qet.h:104
QET::RoundScaleRatios
@ RoundScaleRatios
adjust the scaling movement so that the induced scaling ratios are rounded
Definition: qet.h:84
QET::ResizeFromMiddleRightCorner
@ ResizeFromMiddleRightCorner
Definition: qet.h:74
Qet::East
@ East
Definition: qet.h:207
QET::Common
@ Common
From common collection.
Definition: qet.h:153
QET::ToSouth
@ ToSouth
Definition: qet.h:58
QET
Definition: qet.h:30
QET::BeginFilter
@ BeginFilter
Definition: qet.h:117
QET::Icons::tr
QIcon tr
Definition: qeticons.cpp:206
QET::DiagramArea
DiagramArea
Definition: qet.h:139
QET::attributeIsAReal
bool attributeIsAReal(const QDomElement &, const QString &, qreal *=nullptr)
Definition: qet.cpp:231
QET::Retry
@ Retry
The operation must be tried again.
Definition: qet.h:128
QET::ToWest
@ ToWest
Definition: qet.h:60
QET::RotateArea
@ RotateArea
Definition: qet.h:67
QET::RelativeToRemainingLength
@ RelativeToRemainingLength
the length is just a fraction of the length that is still available when other types of lengths have ...
Definition: qet.h:148
QET::Icons::BringForward
QIcon BringForward
Definition: qeticons.cpp:33
QET::joinWithSpaces
QString joinWithSpaces(const QStringList &)
Definition: qet.cpp:452
QET::ToNorthEast
@ ToNorthEast
Definition: qet.h:55