2015-04-11 13:01:25 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file def.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 11 4, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2015-04-11 13:01:25 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2015-04-11 13:01:25 +02:00
|
|
|
**
|
|
|
|
** Valentina 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 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina 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 Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef DEF_H
|
|
|
|
#define DEF_H
|
|
|
|
|
2019-11-15 08:51:31 +01:00
|
|
|
#include <QtGlobal>
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
# include <qt_windows.h>
|
|
|
|
#endif /*Q_OS_WIN*/
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <qcompilerdetection.h>
|
|
|
|
#include <QPrinter>
|
|
|
|
#include <QString>
|
2015-06-12 10:55:44 +02:00
|
|
|
#include <QStringList>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <Qt>
|
|
|
|
#include <csignal>
|
2019-04-05 14:42:22 +02:00
|
|
|
#include <QMargins>
|
2019-06-08 07:40:56 +02:00
|
|
|
#include <QLineF>
|
2015-06-12 10:55:44 +02:00
|
|
|
|
2015-09-13 14:00:33 +02:00
|
|
|
#include "debugbreak.h"
|
2017-11-13 11:59:25 +01:00
|
|
|
#include "defglobal.h"
|
2015-10-22 14:16:15 +02:00
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
template <class T> class QSharedPointer;
|
|
|
|
|
2018-12-11 21:27:55 +01:00
|
|
|
#include <ciso646>
|
2015-09-13 14:00:33 +02:00
|
|
|
|
2018-12-23 19:09:57 +01:00
|
|
|
// Backport of relaxed constexpr
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
|
|
|
#if defined Q_COMPILER_CONSTEXPR
|
|
|
|
# if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304
|
|
|
|
# define Q_DECL_RELAXED_CONSTEXPR constexpr
|
|
|
|
# define Q_RELAXED_CONSTEXPR constexpr
|
|
|
|
# else
|
|
|
|
# define Q_DECL_RELAXED_CONSTEXPR
|
|
|
|
# define Q_RELAXED_CONSTEXPR const
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# define Q_DECL_RELAXED_CONSTEXPR
|
|
|
|
# define Q_RELAXED_CONSTEXPR const
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2015-10-16 19:26:05 +02:00
|
|
|
class QComboBox;
|
2016-10-06 18:13:06 +02:00
|
|
|
class QMarginsF;
|
2016-10-17 15:55:58 +02:00
|
|
|
class VTranslateMeasurements;
|
2017-08-01 13:35:48 +02:00
|
|
|
class QGraphicsItem;
|
2015-10-16 19:26:05 +02:00
|
|
|
|
2017-10-11 12:51:06 +02:00
|
|
|
#define SceneSize 50000
|
|
|
|
extern const qreal defCurveApproximationScale;
|
|
|
|
extern const qreal minCurveApproximationScale;
|
|
|
|
extern const qreal maxCurveApproximationScale;
|
2015-08-27 18:20:02 +02:00
|
|
|
|
2019-05-08 18:22:55 +02:00
|
|
|
extern const int minLabelFontSize;
|
|
|
|
extern const int maxLabelFontSize;
|
|
|
|
|
2020-01-07 11:54:01 +01:00
|
|
|
enum class NodeDetail : qint8 { Contour, Modeling };
|
|
|
|
enum class SceneObject : qint8 { Point, Line, Spline, Arc, ElArc, SplinePath, Detail, Unknown };
|
2020-10-15 17:05:21 +02:00
|
|
|
enum class MeasurementsType : qint8 { Multisize, Individual, Unknown};
|
2020-01-07 11:54:01 +01:00
|
|
|
enum class Unit : qint8 { Mm = 0, Cm, Inch, Px, LAST_UNIT_DO_NOT_USE};
|
|
|
|
enum class Source : qint8 { FromGui, FromFile, FromTool };
|
2015-12-26 14:08:41 +01:00
|
|
|
enum class NodeUsage : bool {NotInUse = false, InUse = true};
|
2016-03-31 19:10:20 +02:00
|
|
|
enum class SelectionType : bool {ByMousePress, ByMouseRelease};
|
2017-10-10 11:22:59 +02:00
|
|
|
enum class PageOrientation : bool {Portrait = true, Landscape = false};
|
2020-01-07 11:54:01 +01:00
|
|
|
enum class Draw : qint8 { Calculation, Modeling, Layout };
|
2015-06-12 10:55:44 +02:00
|
|
|
|
2020-01-07 11:54:01 +01:00
|
|
|
enum class PieceNodeAngle : quint8
|
2016-11-19 12:44:12 +01:00
|
|
|
{
|
|
|
|
ByLength = 0,
|
2018-10-17 17:12:39 +02:00
|
|
|
ByPointsIntersection = 1,
|
|
|
|
ByFirstEdgeSymmetry = 2,
|
|
|
|
BySecondEdgeSymmetry = 3,
|
|
|
|
ByFirstEdgeRightAngle = 4,
|
|
|
|
BySecondEdgeRightAngle = 5,
|
|
|
|
ByLengthCurve = 6, // used only in runtime
|
2018-09-19 14:16:29 +02:00
|
|
|
LAST_ONE_DO_NOT_USE
|
2016-11-19 12:44:12 +01:00
|
|
|
};
|
|
|
|
|
2020-01-07 11:54:01 +01:00
|
|
|
enum class PassmarkLineType : quint8
|
2017-03-24 12:08:16 +01:00
|
|
|
{
|
2017-03-24 13:48:07 +01:00
|
|
|
OneLine = 0, // Default
|
2017-03-24 12:08:16 +01:00
|
|
|
TwoLines,
|
2017-04-05 12:22:33 +02:00
|
|
|
ThreeLines,
|
|
|
|
TMark,
|
2019-01-24 08:26:57 +01:00
|
|
|
VMark,
|
2019-04-23 19:56:11 +02:00
|
|
|
VMark2,
|
|
|
|
UMark,
|
2019-07-01 11:11:18 +02:00
|
|
|
BoxMark,
|
|
|
|
LAST_ONE_DO_NOT_USE
|
2017-03-24 12:08:16 +01:00
|
|
|
};
|
|
|
|
|
2017-03-24 13:48:07 +01:00
|
|
|
QString PassmarkLineTypeToString(PassmarkLineType type);
|
|
|
|
PassmarkLineType StringToPassmarkLineType(const QString &value);
|
|
|
|
|
2020-01-07 11:54:01 +01:00
|
|
|
enum class PassmarkAngleType : quint8
|
2017-03-24 12:08:16 +01:00
|
|
|
{
|
2017-03-24 13:48:07 +01:00
|
|
|
Straightforward = 0, // Default
|
2017-04-25 10:42:08 +02:00
|
|
|
Bisector,
|
2017-09-28 20:18:13 +02:00
|
|
|
Intersection,
|
|
|
|
IntersectionOnlyLeft,
|
2018-02-04 11:35:27 +01:00
|
|
|
IntersectionOnlyRight,
|
|
|
|
Intersection2,
|
|
|
|
Intersection2OnlyLeft,
|
2019-09-05 10:29:20 +02:00
|
|
|
Intersection2OnlyRight,
|
|
|
|
LAST_ONE_DO_NOT_USE
|
2017-03-24 12:08:16 +01:00
|
|
|
};
|
|
|
|
|
2017-03-24 13:48:07 +01:00
|
|
|
QString PassmarkAngleTypeToString(PassmarkAngleType type);
|
|
|
|
PassmarkAngleType StringToPassmarkAngleType(const QString &value);
|
|
|
|
|
2017-07-02 13:34:36 +02:00
|
|
|
|
|
|
|
Unit StrToUnits(const QString &unit);
|
|
|
|
QString UnitsToStr(const Unit &unit, const bool translate = false);
|
|
|
|
|
|
|
|
|
2020-01-07 11:54:01 +01:00
|
|
|
enum class PiecePathIncludeType : quint8
|
2016-11-28 13:52:31 +01:00
|
|
|
{
|
|
|
|
AsMainPath = 0,
|
2016-11-29 14:29:29 +01:00
|
|
|
AsCustomSA = 1
|
2016-11-28 13:52:31 +01:00
|
|
|
};
|
|
|
|
|
2020-01-07 11:54:01 +01:00
|
|
|
enum class PiecePathType : quint8 {PiecePath = 0, CustomSeamAllowance = 1, InternalPath = 2, Unknown = 3};
|
2016-11-23 13:50:30 +01:00
|
|
|
|
2017-06-09 11:39:24 +02:00
|
|
|
typedef int ToolVisHolderType;
|
2015-08-28 18:38:02 +02:00
|
|
|
enum class Tool : ToolVisHolderType
|
2015-06-12 10:55:44 +02:00
|
|
|
{
|
|
|
|
Arrow,
|
2015-06-20 18:14:04 +02:00
|
|
|
SinglePoint,
|
|
|
|
DoublePoint,
|
2015-06-12 10:55:44 +02:00
|
|
|
LinePoint,
|
|
|
|
AbstractSpline,
|
|
|
|
Cut,
|
2015-06-19 14:08:27 +02:00
|
|
|
BasePoint,
|
2015-06-12 10:55:44 +02:00
|
|
|
EndLine,
|
|
|
|
Line,
|
|
|
|
AlongLine,
|
|
|
|
ShoulderPoint,
|
|
|
|
Normal,
|
|
|
|
Bisector,
|
|
|
|
LineIntersect,
|
|
|
|
Spline,
|
2016-03-10 14:55:04 +01:00
|
|
|
CubicBezier,
|
2015-06-12 10:55:44 +02:00
|
|
|
CutSpline,
|
|
|
|
CutArc,
|
|
|
|
Arc,
|
|
|
|
ArcWithLength,
|
|
|
|
SplinePath,
|
2016-03-17 19:12:48 +01:00
|
|
|
CubicBezierPath,
|
2015-06-12 10:55:44 +02:00
|
|
|
CutSplinePath,
|
|
|
|
PointOfContact,
|
2016-11-08 11:57:01 +01:00
|
|
|
Piece,
|
2016-11-22 13:33:08 +01:00
|
|
|
PiecePath,
|
2015-06-12 10:55:44 +02:00
|
|
|
NodePoint,
|
|
|
|
NodeArc,
|
2016-12-20 15:51:58 +01:00
|
|
|
NodeElArc,
|
2015-06-12 10:55:44 +02:00
|
|
|
NodeSpline,
|
|
|
|
NodeSplinePath,
|
|
|
|
Height,
|
|
|
|
Triangle,
|
|
|
|
LineIntersectAxis,
|
|
|
|
PointOfIntersectionArcs,
|
|
|
|
PointOfIntersectionCircles,
|
2016-01-24 17:15:08 +01:00
|
|
|
PointOfIntersectionCurves,
|
2015-06-12 10:55:44 +02:00
|
|
|
CurveIntersectAxis,
|
2016-06-23 19:45:45 +02:00
|
|
|
ArcIntersectAxis,
|
2015-06-12 10:55:44 +02:00
|
|
|
PointOfIntersection,
|
|
|
|
PointFromCircleAndTangent,
|
|
|
|
PointFromArcAndTangent,
|
2015-06-24 16:30:07 +02:00
|
|
|
TrueDarts,
|
2016-02-09 16:26:59 +01:00
|
|
|
UnionDetails,
|
2016-04-05 19:14:12 +02:00
|
|
|
Group,
|
2016-05-12 21:11:21 +02:00
|
|
|
Rotation,
|
2016-09-13 10:27:44 +02:00
|
|
|
FlippingByLine,
|
2016-09-17 11:10:03 +02:00
|
|
|
FlippingByAxis,
|
2016-10-04 16:34:37 +02:00
|
|
|
Move,
|
2016-06-23 19:20:21 +02:00
|
|
|
Midpoint,
|
2016-12-17 02:01:40 +01:00
|
|
|
EllipticalArc,
|
2017-01-31 13:28:48 +01:00
|
|
|
Pin,
|
2017-03-21 14:39:14 +01:00
|
|
|
InsertNode,
|
2017-10-15 11:25:20 +02:00
|
|
|
PlaceLabel,
|
2017-10-25 16:49:04 +02:00
|
|
|
DuplicateDetail,
|
2022-01-28 15:54:20 +01:00
|
|
|
BackgroundImage,
|
|
|
|
BackgroundImageControls,
|
|
|
|
BackgroundPixmapImage,
|
|
|
|
BackgroundSVGImage,
|
2015-08-25 19:53:03 +02:00
|
|
|
LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used
|
2015-06-12 10:55:44 +02:00
|
|
|
};
|
|
|
|
|
2015-08-28 18:38:02 +02:00
|
|
|
enum class Vis : ToolVisHolderType
|
2015-06-12 10:55:44 +02:00
|
|
|
{
|
2015-08-28 18:38:02 +02:00
|
|
|
ControlPointSpline = static_cast<ToolVisHolderType>(Tool::LAST_ONE_DO_NOT_USE),
|
2015-06-12 10:55:44 +02:00
|
|
|
GraphicsSimpleTextItem,
|
2015-06-20 18:14:04 +02:00
|
|
|
SimplePoint,
|
2016-05-12 21:11:21 +02:00
|
|
|
SimpleCurve,
|
2017-07-25 20:56:01 +02:00
|
|
|
ScaledLine,
|
|
|
|
ScaledEllipse,
|
2015-06-12 10:55:44 +02:00
|
|
|
Line,
|
|
|
|
Path,
|
2016-09-13 10:27:44 +02:00
|
|
|
Operation,
|
2015-06-12 10:55:44 +02:00
|
|
|
ToolAlongLine,
|
|
|
|
ToolArc,
|
|
|
|
ToolArcWithLength,
|
|
|
|
ToolBisector,
|
|
|
|
ToolCutArc,
|
|
|
|
ToolEndLine,
|
|
|
|
ToolHeight,
|
|
|
|
ToolLine,
|
|
|
|
ToolLineIntersect,
|
|
|
|
ToolNormal,
|
|
|
|
ToolPointOfContact,
|
|
|
|
ToolPointOfIntersection,
|
|
|
|
ToolPointOfIntersectionArcs,
|
|
|
|
ToolPointOfIntersectionCircles,
|
2016-01-24 17:15:08 +01:00
|
|
|
ToolPointOfIntersectionCurves,
|
2015-06-12 10:55:44 +02:00
|
|
|
ToolPointFromCircleAndTangent,
|
|
|
|
ToolPointFromArcAndTangent,
|
|
|
|
ToolShoulderPoint,
|
|
|
|
ToolSpline,
|
2016-03-10 14:55:04 +01:00
|
|
|
ToolCubicBezier,
|
2016-03-17 19:12:48 +01:00
|
|
|
ToolCubicBezierPath,
|
2015-06-12 10:55:44 +02:00
|
|
|
ToolTriangle,
|
|
|
|
ToolCutSpline,
|
|
|
|
ToolSplinePath,
|
|
|
|
ToolCutSplinePath,
|
|
|
|
ToolLineIntersectAxis,
|
2015-06-24 16:30:07 +02:00
|
|
|
ToolCurveIntersectAxis,
|
2016-05-12 21:11:21 +02:00
|
|
|
ToolTrueDarts,
|
2016-09-13 10:27:44 +02:00
|
|
|
ToolRotation,
|
2016-09-17 11:10:03 +02:00
|
|
|
ToolFlippingByLine,
|
2016-10-04 16:34:37 +02:00
|
|
|
ToolFlippingByAxis,
|
2016-11-05 09:56:44 +01:00
|
|
|
ToolMove,
|
2016-12-20 13:39:05 +01:00
|
|
|
ToolEllipticalArc,
|
2016-11-22 13:33:08 +01:00
|
|
|
ToolPiece,
|
2017-01-31 13:28:48 +01:00
|
|
|
ToolPiecePath,
|
2017-10-15 11:25:20 +02:00
|
|
|
ToolSpecialPoint,
|
|
|
|
ToolPlaceLabel,
|
2017-10-25 16:49:04 +02:00
|
|
|
ToolDuplicateDetail,
|
2017-10-15 11:25:20 +02:00
|
|
|
PieceSpecialPoints,
|
2017-06-09 11:39:24 +02:00
|
|
|
NoBrush,
|
|
|
|
CurvePathItem,
|
|
|
|
GrainlineItem,
|
|
|
|
PieceItem,
|
|
|
|
TextGraphicsItem,
|
2017-10-23 20:10:48 +02:00
|
|
|
ScenePoint,
|
2017-06-09 11:39:24 +02:00
|
|
|
LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used
|
2015-06-12 10:55:44 +02:00
|
|
|
};
|
|
|
|
|
2022-02-05 14:00:22 +01:00
|
|
|
enum class VarType : qint8 { Measurement, MeasurementSeparator, Increment, IncrementSeparator, LineLength, CurveLength,
|
|
|
|
CurveCLength, LineAngle, CurveAngle, ArcRadius, Unknown };
|
2019-01-16 15:24:41 +01:00
|
|
|
|
2020-01-07 11:54:01 +01:00
|
|
|
enum class IncrementType : qint8 { Increment, Separator };
|
2019-01-16 15:24:41 +01:00
|
|
|
|
2022-02-05 14:00:22 +01:00
|
|
|
auto IncrementTypeToString(IncrementType type) -> QString;
|
|
|
|
auto StringToIncrementType(const QString &value) -> IncrementType;
|
|
|
|
|
|
|
|
enum class MeasurementType : qint8 { Measurement, Separator };
|
|
|
|
|
|
|
|
auto MeasurementTypeToString(MeasurementType type) -> QString;
|
|
|
|
auto StringToMeasurementType(const QString &value) -> MeasurementType;
|
2015-06-12 10:55:44 +02:00
|
|
|
|
2020-10-15 08:35:08 +02:00
|
|
|
enum class IMD: qint8 // Individual measurement dimension
|
|
|
|
{
|
|
|
|
N, // None
|
|
|
|
X, // height
|
|
|
|
Y, // size (chest half circumference)
|
2020-10-31 09:14:08 +01:00
|
|
|
W, // waist half circumference
|
|
|
|
Z // hip half circumference
|
2020-10-15 08:35:08 +02:00
|
|
|
};
|
|
|
|
|
2015-05-06 14:03:45 +02:00
|
|
|
/* QImage supports a maximum of 32768x32768 px images (signed short).
|
|
|
|
* This follows from the condition: width * height * colordepth < INT_MAX (4 billion) -> 32768 * 32768 * 4 = 4 billion.
|
|
|
|
* The second condition is of course that malloc is able to allocate the requested memory.
|
|
|
|
*
|
|
|
|
* If you really need bigger images you will have to use another wrapper or split into multiple QImage's.
|
|
|
|
*/
|
|
|
|
#define QIMAGE_MAX 32768
|
|
|
|
|
2015-04-11 13:01:25 +02:00
|
|
|
/*
|
|
|
|
* This macros SCASSERT (for Stop and Continue Assert) will break into the debugger on the line of the assert and allow
|
|
|
|
* you to continue afterwards should you choose to.
|
|
|
|
* idea: Q_ASSERT no longer pauses debugger - http://qt-project.org/forums/viewthread/13148
|
|
|
|
* Usefull links:
|
|
|
|
* 1. What's the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__? -
|
|
|
|
* https://stackoverflow.com/questions/4384765/whats-the-difference-between-pretty-function-function-func
|
|
|
|
*
|
|
|
|
* 2. Windows Predefined Macros - http://msdn.microsoft.com/library/b0084kay.aspx
|
|
|
|
*
|
|
|
|
* 3. Windows DebugBreak function - http://msdn.microsoft.com/en-us/library/ms679297%28VS.85%29.aspx
|
|
|
|
*
|
|
|
|
* 4. Continue to debug after failed assertion on Linux? [C/C++] -
|
|
|
|
* https://stackoverflow.com/questions/1721543/continue-to-debug-after-failed-assertion-on-linux-c-c
|
|
|
|
*/
|
|
|
|
#ifndef V_NO_ASSERT
|
|
|
|
|
2021-09-25 10:41:26 +02:00
|
|
|
#define SCASSERT(cond) \
|
|
|
|
if (!(cond)) \
|
|
|
|
{ \
|
|
|
|
qCritical("ASSERT: %s in %s (%s:%u)", \
|
|
|
|
#cond, Q_FUNC_INFO , __FILE__, __LINE__); \
|
|
|
|
debug_break(); \
|
|
|
|
abort(); \
|
|
|
|
}
|
2015-04-11 13:01:25 +02:00
|
|
|
|
|
|
|
#else // define but disable this function if debugging is not set
|
|
|
|
#define SCASSERT(cond) qt_noop();
|
|
|
|
#endif /* V_NO_ASSERT */
|
|
|
|
|
2017-05-30 19:56:59 +02:00
|
|
|
#ifndef __has_cpp_attribute
|
|
|
|
# define __has_cpp_attribute(x) 0
|
|
|
|
#endif
|
|
|
|
|
2019-03-16 11:22:09 +01:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 8, 0)
|
2019-03-27 12:31:02 +01:00
|
|
|
|
|
|
|
#ifndef QT_HAS_CPP_ATTRIBUTE
|
|
|
|
#ifdef __has_cpp_attribute
|
|
|
|
# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
|
|
|
|
#else
|
|
|
|
# define QT_HAS_CPP_ATTRIBUTE(x) 0
|
|
|
|
#endif
|
|
|
|
#endif // QT_HAS_CPP_ATTRIBUTE
|
|
|
|
|
2019-03-16 11:22:09 +01:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
#if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
|
|
|
|
# define Q_FALLTHROUGH() [[clang::fallthrough]]
|
|
|
|
#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
|
|
|
|
# define Q_FALLTHROUGH() [[gnu::fallthrough]]
|
|
|
|
#elif QT_HAS_CPP_ATTRIBUTE(fallthrough)
|
|
|
|
# define Q_FALLTHROUGH() [[fallthrough]]
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifndef Q_FALLTHROUGH
|
|
|
|
# if (defined(Q_CC_GNU) && Q_CC_GNU >= 700) && !defined(Q_CC_INTEL)
|
|
|
|
# define Q_FALLTHROUGH() __attribute__((fallthrough))
|
|
|
|
# else
|
|
|
|
# define Q_FALLTHROUGH() (void)0
|
|
|
|
#endif
|
2019-03-27 12:31:02 +01:00
|
|
|
#endif // defined(__cplusplus)
|
|
|
|
#endif // QT_VERSION < QT_VERSION_CHECK(5, 8, 0)
|
2015-08-01 11:39:32 +02:00
|
|
|
|
2017-02-09 14:43:17 +01:00
|
|
|
bool IsOptionSet(int argc, char *argv[], const char *option);
|
|
|
|
void InitHighDpiScaling(int argc, char *argv[]);
|
|
|
|
|
2018-07-19 15:47:20 +02:00
|
|
|
// Don't forget to syncronize with XSD schema.
|
2017-09-28 16:45:57 +02:00
|
|
|
const int userMaterialPlaceholdersQuantity = 20;
|
2017-08-30 06:43:00 +02:00
|
|
|
|
2018-01-12 13:31:45 +01:00
|
|
|
QPixmap QPixmapFromCache(const QString &pixmapPath);
|
2017-08-01 13:35:48 +02:00
|
|
|
void SetItemOverrideCursor(QGraphicsItem *item, const QString & pixmapPath, int hotX = -1, int hotY = -1);
|
2016-07-10 12:39:50 +02:00
|
|
|
|
2018-12-23 19:09:57 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline double ToPixel(double val, const Unit &unit)
|
|
|
|
{
|
|
|
|
switch (unit)
|
|
|
|
{
|
|
|
|
case Unit::Mm:
|
|
|
|
return (val / 25.4) * PrintDPI;
|
|
|
|
case Unit::Cm:
|
|
|
|
return ((val * 10.0) / 25.4) * PrintDPI;
|
|
|
|
case Unit::Inch:
|
|
|
|
return val * PrintDPI;
|
|
|
|
case Unit::Px:
|
|
|
|
return val;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline double FromPixel(double pix, const Unit &unit)
|
|
|
|
{
|
|
|
|
switch (unit)
|
|
|
|
{
|
|
|
|
case Unit::Mm:
|
|
|
|
return (pix / PrintDPI) * 25.4;
|
|
|
|
case Unit::Cm:
|
|
|
|
return ((pix / PrintDPI) * 25.4) / 10.0;
|
|
|
|
case Unit::Inch:
|
|
|
|
return pix / PrintDPI;
|
|
|
|
case Unit::Px:
|
|
|
|
return pix;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline qreal UnitConvertor(qreal value, const Unit &from, const Unit &to)
|
|
|
|
{
|
|
|
|
switch (from)
|
|
|
|
{
|
|
|
|
case Unit::Mm:
|
|
|
|
switch (to)
|
|
|
|
{
|
|
|
|
case Unit::Mm:
|
|
|
|
return value;
|
|
|
|
case Unit::Cm:
|
|
|
|
return value / 10.0;
|
|
|
|
case Unit::Inch:
|
2021-08-21 15:13:56 +02:00
|
|
|
return value / 10.0 / 2.54;
|
2018-12-23 19:09:57 +01:00
|
|
|
case Unit::Px:
|
|
|
|
return (value / 25.4) * PrintDPI;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Unit::Cm:
|
|
|
|
switch (to)
|
|
|
|
{
|
|
|
|
case Unit::Mm:
|
|
|
|
return value * 10.0;
|
|
|
|
case Unit::Cm:
|
|
|
|
return value;
|
|
|
|
case Unit::Inch:
|
|
|
|
return value / 2.54;
|
|
|
|
case Unit::Px:
|
|
|
|
return ((value * 10.0) / 25.4) * PrintDPI;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Unit::Inch:
|
|
|
|
switch (to)
|
|
|
|
{
|
|
|
|
case Unit::Mm:
|
2021-08-21 15:13:56 +02:00
|
|
|
return value * 2.54 * 10.0;
|
2018-12-23 19:09:57 +01:00
|
|
|
case Unit::Cm:
|
|
|
|
return value * 2.54;
|
|
|
|
case Unit::Inch:
|
|
|
|
return value;
|
|
|
|
case Unit::Px:
|
|
|
|
return value * PrintDPI;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Unit::Px:
|
|
|
|
switch (to)
|
|
|
|
{
|
|
|
|
case Unit::Mm:
|
|
|
|
return (value / PrintDPI) * 25.4;
|
|
|
|
case Unit::Cm:
|
|
|
|
return ((value / PrintDPI) * 25.4) / 10.0;
|
|
|
|
case Unit::Inch:
|
|
|
|
return value / PrintDPI;
|
|
|
|
case Unit::Px:
|
|
|
|
return value;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2015-06-18 19:23:24 +02:00
|
|
|
|
2018-12-23 19:09:57 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief UnitConvertor Converts the values of the given margin from given unit to the new unit.
|
|
|
|
* returns a new instand of QMarginsF.
|
|
|
|
*/
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline QMarginsF UnitConvertor(const QMarginsF &margins, const Unit &from, const Unit &to)
|
|
|
|
{
|
|
|
|
const qreal left = UnitConvertor(margins.left(), from, to);
|
|
|
|
const qreal top = UnitConvertor(margins.top(), from, to);
|
|
|
|
const qreal right = UnitConvertor(margins.right(), from, to);
|
|
|
|
const qreal bottom = UnitConvertor(margins.bottom(), from, to);
|
|
|
|
|
|
|
|
return QMarginsF(left, top, right, bottom);
|
|
|
|
}
|
2015-06-18 19:23:24 +02:00
|
|
|
|
2017-04-12 14:50:48 +02:00
|
|
|
void InitLanguages(QComboBox *combobox);
|
2017-07-01 20:38:26 +02:00
|
|
|
Q_REQUIRED_RESULT QStringList SupportedLocales();
|
2015-09-19 21:58:32 +02:00
|
|
|
|
2017-07-01 20:38:26 +02:00
|
|
|
Q_REQUIRED_RESULT QString StrippedName(const QString &fullFileName);
|
|
|
|
Q_REQUIRED_RESULT QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath);
|
|
|
|
Q_REQUIRED_RESULT QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath);
|
2015-10-31 09:46:45 +01:00
|
|
|
|
2020-07-13 15:11:57 +02:00
|
|
|
QStringList SplitFilePaths(const QString &path);
|
|
|
|
|
2016-10-06 18:13:06 +02:00
|
|
|
QMarginsF GetMinPrinterFields(const QSharedPointer<QPrinter> &printer);
|
|
|
|
QMarginsF GetPrinterFields(const QSharedPointer<QPrinter> &printer);
|
|
|
|
|
2017-07-01 20:38:26 +02:00
|
|
|
Q_REQUIRED_RESULT QPixmap darkenPixmap(const QPixmap &pixmap);
|
2015-12-03 13:07:51 +01:00
|
|
|
|
2016-06-18 15:57:07 +02:00
|
|
|
void ShowInGraphicalShell(const QString &filePath);
|
|
|
|
|
2018-12-23 19:09:57 +01:00
|
|
|
Q_REQUIRED_RESULT Q_DECL_RELAXED_CONSTEXPR static inline bool VFuzzyComparePossibleNulls(double p1, double p2);
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR static inline bool VFuzzyComparePossibleNulls(double p1, double p2)
|
2016-03-23 15:09:30 +01:00
|
|
|
{
|
|
|
|
if(qFuzzyIsNull(p1))
|
|
|
|
{
|
|
|
|
return qFuzzyIsNull(p2);
|
|
|
|
}
|
|
|
|
else if(qFuzzyIsNull(p2))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return qFuzzyCompare(p1, p2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-25 13:19:44 +01:00
|
|
|
/**
|
|
|
|
* @brief The CustomSA struct contains record about custom seam allowanse (SA).
|
|
|
|
*/
|
|
|
|
struct CustomSARecord
|
|
|
|
{
|
|
|
|
CustomSARecord()
|
|
|
|
: startPoint(0),
|
|
|
|
path(0),
|
|
|
|
endPoint(0),
|
2016-11-28 13:52:31 +01:00
|
|
|
reverse(false),
|
|
|
|
includeType(PiecePathIncludeType::AsCustomSA)
|
2016-11-25 13:19:44 +01:00
|
|
|
{}
|
|
|
|
|
2018-12-21 12:01:32 +01:00
|
|
|
friend QDataStream& operator<<(QDataStream& out, const CustomSARecord& record);
|
|
|
|
friend QDataStream& operator>>(QDataStream& in, CustomSARecord& record);
|
|
|
|
|
2019-07-01 12:25:03 +02:00
|
|
|
quint32 startPoint{0};
|
|
|
|
quint32 path{0};
|
|
|
|
quint32 endPoint{0};
|
|
|
|
bool reverse{false};
|
|
|
|
PiecePathIncludeType includeType{PiecePathIncludeType::AsCustomSA};
|
|
|
|
|
|
|
|
private:
|
|
|
|
static const quint32 streamHeader;
|
|
|
|
static const quint16 classVersion;
|
2016-11-25 13:19:44 +01:00
|
|
|
};
|
|
|
|
|
2016-11-28 09:47:36 +01:00
|
|
|
Q_DECLARE_METATYPE(CustomSARecord)
|
2016-11-25 13:19:44 +01:00
|
|
|
Q_DECLARE_TYPEINFO(CustomSARecord, Q_MOVABLE_TYPE);
|
2016-06-01 15:37:42 +02:00
|
|
|
/****************************************************************************
|
|
|
|
** This file is derived from code bearing the following notice:
|
|
|
|
** The sole author of this file, Adam Higerd, has explicitly disclaimed all
|
|
|
|
** copyright interest and protection for the content within. This file has
|
|
|
|
** been placed in the public domain according to United States copyright
|
|
|
|
** statute and case law. In jurisdictions where this public domain dedication
|
|
|
|
** is not legally recognized, anyone who receives a copy of this file is
|
|
|
|
** permitted to use, modify, duplicate, and redistribute this file, in whole
|
|
|
|
** or in part, with no restrictions or conditions. In these jurisdictions,
|
|
|
|
** this file shall be copyright (C) 2006-2008 by Adam Higerd.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#define QXT_DECLARE_PRIVATE(PUB) friend class PUB##Private; QxtPrivateInterface<PUB, PUB##Private> qxt_d;
|
|
|
|
#define QXT_DECLARE_PUBLIC(PUB) friend class PUB;
|
|
|
|
#define QXT_INIT_PRIVATE(PUB) qxt_d.setPublic(this);
|
|
|
|
#define QXT_D(PUB) PUB##Private& d = qxt_d()
|
|
|
|
#define QXT_P(PUB) PUB& p = qxt_p()
|
|
|
|
|
2021-09-25 16:18:33 +02:00
|
|
|
QT_WARNING_PUSH
|
|
|
|
QT_WARNING_DISABLE_GCC("-Wsuggest-final-types")
|
|
|
|
QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods")
|
|
|
|
|
2016-06-01 15:37:42 +02:00
|
|
|
template <typename PUB>
|
|
|
|
class QxtPrivate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QxtPrivate(): qxt_p_ptr(nullptr)
|
|
|
|
{}
|
|
|
|
virtual ~QxtPrivate()
|
|
|
|
{}
|
|
|
|
inline void QXT_setPublic(PUB* pub)
|
|
|
|
{
|
|
|
|
qxt_p_ptr = pub;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
inline PUB& qxt_p()
|
|
|
|
{
|
|
|
|
return *qxt_p_ptr;
|
|
|
|
}
|
|
|
|
inline const PUB& qxt_p() const
|
|
|
|
{
|
|
|
|
return *qxt_p_ptr;
|
|
|
|
}
|
|
|
|
inline PUB* qxt_ptr()
|
|
|
|
{
|
|
|
|
return qxt_p_ptr;
|
|
|
|
}
|
|
|
|
inline const PUB* qxt_ptr() const
|
|
|
|
{
|
|
|
|
return qxt_p_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(QxtPrivate)
|
|
|
|
PUB* qxt_p_ptr;
|
|
|
|
};
|
|
|
|
|
2021-09-25 16:18:33 +02:00
|
|
|
QT_WARNING_POP
|
|
|
|
|
2016-06-01 15:37:42 +02:00
|
|
|
template <typename PUB, typename PVT>
|
|
|
|
class QxtPrivateInterface
|
|
|
|
{
|
|
|
|
friend class QxtPrivate<PUB>;
|
|
|
|
public:
|
|
|
|
QxtPrivateInterface() : pvt(new PVT)
|
|
|
|
{}
|
|
|
|
~QxtPrivateInterface()
|
|
|
|
{
|
|
|
|
delete pvt;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setPublic(PUB* pub)
|
|
|
|
{
|
|
|
|
pvt->QXT_setPublic(pub);
|
|
|
|
}
|
|
|
|
inline PVT& operator()()
|
|
|
|
{
|
|
|
|
return *static_cast<PVT*>(pvt);
|
|
|
|
}
|
|
|
|
inline const PVT& operator()() const
|
|
|
|
{
|
|
|
|
return *static_cast<PVT*>(pvt);
|
|
|
|
}
|
|
|
|
inline PVT * operator->()
|
|
|
|
{
|
|
|
|
return static_cast<PVT*>(pvt);
|
|
|
|
}
|
|
|
|
inline const PVT * operator->() const
|
|
|
|
{
|
|
|
|
return static_cast<PVT*>(pvt);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(QxtPrivateInterface)
|
|
|
|
QxtPrivate<PUB>* pvt;
|
|
|
|
};
|
|
|
|
|
2015-04-11 13:01:25 +02:00
|
|
|
#endif // DEF_H
|