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.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2007-06-30 17:41:07 +00:00
|
|
|
#ifndef _QET_H
|
|
|
|
#define _QET_H
|
2020-05-12 11:17:25 +02:00
|
|
|
|
|
|
|
#include <QDomElement>
|
|
|
|
#include <QFile>
|
2014-05-29 13:46:04 +00:00
|
|
|
#include <QObject>
|
2018-06-20 18:35:06 +00:00
|
|
|
|
|
|
|
class QActionGroup;
|
2007-06-30 17:41:07 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This file provides useful functions and enums that may be used from
|
|
|
|
anywhere else within the QElectroTech application.
|
2007-06-30 17:41:07 +00:00
|
|
|
*/
|
|
|
|
namespace QET {
|
2012-11-09 21:09:24 +00:00
|
|
|
/// QElectroTech version (as string, used to mark projects and elements XML documents)
|
2019-07-21 15:00:07 +02:00
|
|
|
const QString version = "0.80";
|
2012-11-09 21:09:24 +00:00
|
|
|
/// QElectroTech displayed version
|
2019-07-21 15:00:07 +02:00
|
|
|
const QString displayedVersion = "0.80-DEV";
|
2007-10-28 01:32:57 +00:00
|
|
|
QString license();
|
2009-04-03 19:30:25 +00:00
|
|
|
|
2018-06-21 17:57:33 +00:00
|
|
|
//Describe the current state of a graphic item
|
|
|
|
enum GraphicsItemState {
|
|
|
|
GIOK, ///<General state
|
|
|
|
GIBuildingFromXml, ///<Item is currently building from a xml description (element)
|
|
|
|
GILoadingFromXml ///<Item is loading her properties from a xml description.
|
|
|
|
};
|
|
|
|
|
2018-06-17 18:21:56 +00:00
|
|
|
/// List the various kind of changes for the zValue
|
|
|
|
enum DepthOption {
|
|
|
|
BringForward, ///< Bring item to the foreground so they have the highest zValue
|
|
|
|
Raise, ///< Raise item one layer above their current one; zValues are incremented
|
|
|
|
Lower, ///< Send item one layer below their current one; zValues are decremented
|
|
|
|
SendBackward ///< Send item to the background so they have the lowest zValue
|
|
|
|
};
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Oriented movements
|
2009-04-03 19:30:25 +00:00
|
|
|
enum OrientedMovement {
|
|
|
|
ToNorth,
|
|
|
|
ToNorthEast,
|
|
|
|
ToEast,
|
|
|
|
ToSouthEast,
|
|
|
|
ToSouth,
|
|
|
|
ToSouthWest,
|
|
|
|
ToWest,
|
|
|
|
ToNorthWest
|
|
|
|
};
|
|
|
|
|
2013-02-08 22:05:15 +00:00
|
|
|
/// List areas related to some common operations
|
|
|
|
enum OperationAreas {
|
|
|
|
ChangeInnerPoints = -4,
|
|
|
|
RotateArea = -3,
|
|
|
|
MoveArea = -2,
|
|
|
|
NoOperation = -1,
|
|
|
|
ResizeFromTopLeftCorner = 0,
|
|
|
|
ResizeFromTopCenterCorner = 1,
|
|
|
|
ResizeFromTopRightCorner = 2,
|
|
|
|
ResizeFromMiddleLeftCorner = 3,
|
|
|
|
ResizeFromMiddleRightCorner = 4,
|
|
|
|
ResizeFromBottomLeftCorner = 5,
|
|
|
|
ResizeFromBottomCenterCorner = 6,
|
|
|
|
ResizeFromBottomRightCorner = 7
|
|
|
|
};
|
|
|
|
|
2013-03-06 18:51:29 +00:00
|
|
|
/// Supported types of interactive scaling, typically for a single element primitive
|
|
|
|
enum ScalingMethod {
|
|
|
|
FreeScaling, ///< do not interfer with the default scaling process
|
|
|
|
SnapScalingPointToGrid, ///< snap the point used to define the new bounding rectangle to the grid
|
|
|
|
RoundScaleRatios ///< adjust the scaling movement so that the induced scaling ratios are rounded
|
|
|
|
};
|
|
|
|
|
2012-11-09 21:09:24 +00:00
|
|
|
/// Known kinds of conductor segments
|
2009-04-03 19:30:25 +00:00
|
|
|
enum ConductorSegmentType {
|
2012-11-09 21:09:24 +00:00
|
|
|
Horizontal = 1, ///< Horizontal segment
|
|
|
|
Vertical = 2, ///< Vertical segment
|
|
|
|
Both = 3 ///< Invalid segment
|
2009-04-03 19:30:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This enums lists the various kind of items users can manage within the
|
|
|
|
application.
|
2009-04-03 19:30:25 +00:00
|
|
|
*/
|
|
|
|
enum ItemType {
|
2012-02-06 21:21:43 +00:00
|
|
|
Element = 1,
|
|
|
|
ElementsCategory = 2,
|
|
|
|
ElementsCollection = 4,
|
|
|
|
ElementsContainer = 6,
|
|
|
|
ElementsCollectionItem = 7,
|
|
|
|
TitleBlockTemplate = 8,
|
|
|
|
TitleBlockTemplatesCollection = 16,
|
|
|
|
TitleBlockTemplatesCollectionItem = 24,
|
|
|
|
Diagram = 32,
|
|
|
|
Project = 64,
|
|
|
|
All = 127
|
2009-04-03 19:30:25 +00:00
|
|
|
};
|
|
|
|
|
2012-02-06 21:21:43 +00:00
|
|
|
/**
|
|
|
|
This enum represents the various steps when applying a filter.
|
|
|
|
*/
|
|
|
|
enum Filtering {
|
|
|
|
BeginFilter,
|
|
|
|
RegularFilter,
|
|
|
|
EndFilter
|
|
|
|
};
|
2009-04-03 19:30:25 +00:00
|
|
|
|
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This enums lists the various ways to handle a standard problem when copying
|
|
|
|
or moving element items (collections, categories, elements).
|
2009-04-03 19:30:25 +00:00
|
|
|
@see MoveElementsHandler
|
|
|
|
*/
|
|
|
|
enum Action {
|
2012-11-09 21:09:24 +00:00
|
|
|
Retry, ///< The operation must be tried again
|
|
|
|
Ignore, ///< Skip the current item
|
|
|
|
Erase, ///< Erase the target content
|
|
|
|
Abort, ///< abort the whole operation, ignoring the curent item
|
|
|
|
Managed, ///< the current item was handled by the Strategy object: do not treat it and continue
|
|
|
|
Rename ///< the target has to be renamed
|
2009-04-03 19:30:25 +00:00
|
|
|
};
|
|
|
|
|
2009-08-09 12:51:02 +00:00
|
|
|
/**
|
2012-11-09 21:09:24 +00:00
|
|
|
This enum represents diagram areas that may be exported/printed.
|
2009-08-09 12:51:02 +00:00
|
|
|
*/
|
|
|
|
enum DiagramArea {
|
2012-11-09 21:09:24 +00:00
|
|
|
BorderArea, ///< Export the diagram along with its border and title block
|
|
|
|
ElementsArea ///< Export the content of the diagram only
|
2009-08-09 12:51:02 +00:00
|
|
|
};
|
|
|
|
|
2010-12-19 18:08:08 +00:00
|
|
|
/// enum used to specify the type of a length
|
2010-12-20 02:45:36 +00:00
|
|
|
enum TitleBlockColumnLength {
|
2010-12-19 18:08:08 +00:00
|
|
|
Absolute, ///< the length is absolute and should be applied as is
|
|
|
|
RelativeToTotalLength, ///< the length is just a fraction of the total available length
|
|
|
|
RelativeToRemainingLength ///< the length is just a fraction of the length that is still available when other types of lengths have been removed
|
|
|
|
};
|
2015-04-17 11:36:28 +00:00
|
|
|
|
|
|
|
///Enum used to specify the origin of a collection of thing (title block, element etc...)
|
|
|
|
enum QetCollection {
|
|
|
|
Common, ///< From common collection
|
|
|
|
Custom, ///< From user collection
|
2015-04-25 08:54:54 +00:00
|
|
|
Embedded ///< From an embedded collection (a project for exemple)
|
2015-04-17 11:36:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
QString qetCollectionToString (const QetCollection &c);
|
|
|
|
QetCollection qetCollectionFromString (const QString &str);
|
2010-12-19 18:08:08 +00:00
|
|
|
|
2010-05-08 21:24:43 +00:00
|
|
|
bool lineContainsPoint(const QLineF &, const QPointF &);
|
2017-08-05 02:06:59 +00:00
|
|
|
bool orthogonalProjection(const QPointF &, const QLineF &, QPointF * = nullptr);
|
2018-07-19 14:14:31 +00:00
|
|
|
bool attributeIsAnInteger(const QDomElement &, const QString& , int * = nullptr);
|
|
|
|
bool attributeIsAReal(const QDomElement &, const QString& , qreal * = nullptr);
|
2020-05-12 11:17:25 +02:00
|
|
|
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);
|
2012-07-01 21:54:05 +00:00
|
|
|
QList<QDomElement> findInDomElement(const QDomElement &, const QString &);
|
2007-10-27 13:18:17 +00:00
|
|
|
QList<QDomElement> findInDomElement(const QDomElement &, const QString &, const QString &);
|
2007-12-23 01:15:16 +00:00
|
|
|
QList<QChar> forbiddenCharacters();
|
2009-04-03 19:30:25 +00:00
|
|
|
QString stringToFileName(const QString &);
|
2008-07-26 15:26:19 +00:00
|
|
|
QString escapeSpaces(const QString &);
|
|
|
|
QString unescapeSpaces(const QString &);
|
|
|
|
QString joinWithSpaces(const QStringList &);
|
|
|
|
QStringList splitWithSpaces(const QString &);
|
2009-08-09 12:51:02 +00:00
|
|
|
QString diagramAreaToString(const QET::DiagramArea &);
|
|
|
|
QET::DiagramArea diagramAreaFromString(const QString &);
|
2013-03-06 18:50:46 +00:00
|
|
|
qreal round(qreal, qreal);
|
2009-12-13 16:43:35 +00:00
|
|
|
qreal correctAngle(const qreal &);
|
2010-03-28 16:27:48 +00:00
|
|
|
bool compareCanonicalFilePaths(const QString &, const QString &);
|
2017-12-30 14:41:25 +00:00
|
|
|
bool writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString * error_message= nullptr);
|
2019-03-16 10:50:30 +00:00
|
|
|
bool writeToFile (QDomDocument &xml_doc, QFile *file, QString *error_message = nullptr);
|
2014-12-04 10:57:21 +00:00
|
|
|
bool eachStrIsEqual (const QStringList &qsl);
|
2018-06-20 18:35:06 +00:00
|
|
|
QActionGroup *depthActionGroup(QObject *parent = nullptr);
|
2007-06-30 17:41:07 +00:00
|
|
|
}
|
2014-05-29 13:46:04 +00:00
|
|
|
|
2018-06-17 18:21:56 +00:00
|
|
|
Q_DECLARE_METATYPE(QET::DepthOption)
|
|
|
|
|
2019-03-18 19:49:12 +00:00
|
|
|
class Qet : public QObject
|
|
|
|
{
|
2014-05-29 13:46:04 +00:00
|
|
|
Q_OBJECT
|
2019-03-18 19:49:12 +00:00
|
|
|
|
2014-05-29 13:46:04 +00:00
|
|
|
public:
|
2019-03-18 19:49:12 +00:00
|
|
|
///This enum lists the various available endings for line primitives when drawing an electrical element.
|
|
|
|
enum EndType {
|
|
|
|
None, ///< Regular line
|
|
|
|
Simple, ///< Base-less triangle
|
|
|
|
Triangle, ///< Triangle
|
|
|
|
Circle, ///< Circle
|
|
|
|
Diamond ///< Diamond
|
|
|
|
};
|
|
|
|
Q_ENUM (EndType)
|
|
|
|
|
|
|
|
static QString endTypeToString(const Qet::EndType &);
|
|
|
|
static Qet::EndType endTypeFromString(const QString &);
|
|
|
|
|
|
|
|
/// Orientation (used for electrical elements and their terminals)
|
|
|
|
enum Orientation {North,
|
|
|
|
East,
|
|
|
|
South,
|
|
|
|
West};
|
|
|
|
Q_ENUM (Orientation)
|
2014-05-29 13:46:04 +00:00
|
|
|
|
2019-03-18 19:49:12 +00:00
|
|
|
static Qet::Orientation nextOrientation(Qet::Orientation);
|
|
|
|
static Qet::Orientation previousOrientation(Qet::Orientation);
|
2015-01-07 19:21:17 +00:00
|
|
|
|
2019-03-18 19:49:12 +00:00
|
|
|
static Qet::Orientation orientationFromString (const QString &);
|
|
|
|
static QString orientationToString (Qet::Orientation);
|
2015-01-07 19:21:17 +00:00
|
|
|
|
2019-03-18 19:49:12 +00:00
|
|
|
static bool surLeMemeAxe (Qet::Orientation, Qet::Orientation);
|
|
|
|
static bool isOpposed (Qet::Orientation a, Qet::Orientation b);
|
|
|
|
static bool isHorizontal (Qet::Orientation);
|
|
|
|
static bool isVertical (Qet::Orientation);
|
2014-05-29 13:46:04 +00:00
|
|
|
};
|
|
|
|
|
2007-06-30 17:41:07 +00:00
|
|
|
#endif
|