2015-06-11 19:36:17 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file ifcdef.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 11 6, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2015-06-11 19:36:17 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2015 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** 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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "ifcdef.h"
|
|
|
|
|
2017-05-16 12:07:53 +02:00
|
|
|
#include <QBrush>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QMap>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QPen>
|
|
|
|
#include <QPixmap>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QStaticStringData>
|
|
|
|
#include <QStringData>
|
|
|
|
#include <QStringDataPtr>
|
|
|
|
|
2017-05-16 12:07:53 +02:00
|
|
|
#include "../vmisc/diagnostic.h"
|
|
|
|
|
2015-08-25 12:35:50 +02:00
|
|
|
const QString CustomMSign = QStringLiteral("@");
|
|
|
|
const QString CustomIncrSign = QStringLiteral("#");
|
2015-07-22 11:44:31 +02:00
|
|
|
|
2015-08-11 15:41:03 +02:00
|
|
|
const QString AttrType = QStringLiteral("type");
|
|
|
|
const QString AttrMx = QStringLiteral("mx");
|
|
|
|
const QString AttrMy = QStringLiteral("my");
|
|
|
|
const QString AttrName = QStringLiteral("name");
|
|
|
|
const QString AttrMx1 = QStringLiteral("mx1");
|
|
|
|
const QString AttrMy1 = QStringLiteral("my1");
|
|
|
|
const QString AttrName1 = QStringLiteral("name1");
|
|
|
|
const QString AttrMx2 = QStringLiteral("mx2");
|
|
|
|
const QString AttrMy2 = QStringLiteral("my2");
|
|
|
|
const QString AttrName2 = QStringLiteral("name2");
|
|
|
|
const QString AttrBaseLineP1 = QStringLiteral("baseLineP1");
|
|
|
|
const QString AttrBaseLineP2 = QStringLiteral("baseLineP2");
|
|
|
|
const QString AttrDartP1 = QStringLiteral("dartP1");
|
|
|
|
const QString AttrDartP2 = QStringLiteral("dartP2");
|
|
|
|
const QString AttrDartP3 = QStringLiteral("dartP3");
|
|
|
|
const QString AttrX = QStringLiteral("x");
|
|
|
|
const QString AttrY = QStringLiteral("y");
|
|
|
|
const QString AttrTypeLine = QStringLiteral("typeLine");
|
2017-07-20 16:38:56 +02:00
|
|
|
const QString AttrCut = QStringLiteral("cut");
|
2015-08-11 15:41:03 +02:00
|
|
|
const QString AttrLength = QStringLiteral("length");
|
|
|
|
const QString AttrBasePoint = QStringLiteral("basePoint");
|
|
|
|
const QString AttrFirstPoint = QStringLiteral("firstPoint");
|
|
|
|
const QString AttrSecondPoint = QStringLiteral("secondPoint");
|
|
|
|
const QString AttrThirdPoint = QStringLiteral("thirdPoint");
|
|
|
|
const QString AttrCenter = QStringLiteral("center");
|
|
|
|
const QString AttrRadius = QStringLiteral("radius");
|
2016-12-17 02:53:47 +01:00
|
|
|
const QString AttrRadius1 = QStringLiteral("radius1");
|
|
|
|
const QString AttrRadius2 = QStringLiteral("radius2");
|
2015-08-11 15:41:03 +02:00
|
|
|
const QString AttrAngle = QStringLiteral("angle");
|
|
|
|
const QString AttrAngle1 = QStringLiteral("angle1");
|
|
|
|
const QString AttrAngle2 = QStringLiteral("angle2");
|
2016-02-26 15:38:42 +01:00
|
|
|
const QString AttrLength1 = QStringLiteral("length1");
|
|
|
|
const QString AttrLength2 = QStringLiteral("length2");
|
2015-08-11 15:41:03 +02:00
|
|
|
const QString AttrP1Line = QStringLiteral("p1Line");
|
|
|
|
const QString AttrP2Line = QStringLiteral("p2Line");
|
|
|
|
const QString AttrP1Line1 = QStringLiteral("p1Line1");
|
|
|
|
const QString AttrP2Line1 = QStringLiteral("p2Line1");
|
|
|
|
const QString AttrP1Line2 = QStringLiteral("p1Line2");
|
|
|
|
const QString AttrP2Line2 = QStringLiteral("p2Line2");
|
|
|
|
const QString AttrPShoulder = QStringLiteral("pShoulder");
|
|
|
|
const QString AttrPoint1 = QStringLiteral("point1");
|
|
|
|
const QString AttrPoint2 = QStringLiteral("point2");
|
2016-03-10 14:55:04 +01:00
|
|
|
const QString AttrPoint3 = QStringLiteral("point3");
|
2015-08-11 15:41:03 +02:00
|
|
|
const QString AttrPoint4 = QStringLiteral("point4");
|
|
|
|
const QString AttrKAsm1 = QStringLiteral("kAsm1");
|
|
|
|
const QString AttrKAsm2 = QStringLiteral("kAsm2");
|
|
|
|
const QString AttrKCurve = QStringLiteral("kCurve");
|
2016-02-15 15:30:48 +01:00
|
|
|
const QString AttrDuplicate = QStringLiteral("duplicate");
|
2017-10-11 12:51:06 +02:00
|
|
|
const QString AttrAScale = QStringLiteral("aScale");
|
2015-08-11 15:41:03 +02:00
|
|
|
const QString AttrPathPoint = QStringLiteral("pathPoint");
|
|
|
|
const QString AttrPSpline = QStringLiteral("pSpline");
|
|
|
|
const QString AttrAxisP1 = QStringLiteral("axisP1");
|
|
|
|
const QString AttrAxisP2 = QStringLiteral("axisP2");
|
|
|
|
const QString AttrCurve = QStringLiteral("curve");
|
2016-01-24 17:15:08 +01:00
|
|
|
const QString AttrCurve1 = QStringLiteral("curve1");
|
|
|
|
const QString AttrCurve2 = QStringLiteral("curve2");
|
2015-08-11 15:41:03 +02:00
|
|
|
const QString AttrLineColor = QStringLiteral("lineColor");
|
|
|
|
const QString AttrColor = QStringLiteral("color");
|
2017-05-16 12:07:53 +02:00
|
|
|
const QString AttrPenStyle = QStringLiteral("penStyle");
|
2015-08-11 15:41:03 +02:00
|
|
|
const QString AttrFirstArc = QStringLiteral("firstArc");
|
|
|
|
const QString AttrSecondArc = QStringLiteral("secondArc");
|
|
|
|
const QString AttrCrossPoint = QStringLiteral("crossPoint");
|
2016-01-24 17:15:08 +01:00
|
|
|
const QString AttrVCrossPoint = QStringLiteral("vCrossPoint");
|
|
|
|
const QString AttrHCrossPoint = QStringLiteral("hCrossPoint");
|
2016-09-17 11:10:03 +02:00
|
|
|
const QString AttrAxisType = QStringLiteral("axisType");
|
2015-08-11 15:41:03 +02:00
|
|
|
const QString AttrC1Center = QStringLiteral("c1Center");
|
|
|
|
const QString AttrC2Center = QStringLiteral("c2Center");
|
|
|
|
const QString AttrC1Radius = QStringLiteral("c1Radius");
|
|
|
|
const QString AttrC2Radius = QStringLiteral("c2Radius");
|
|
|
|
const QString AttrCCenter = QStringLiteral("cCenter");
|
|
|
|
const QString AttrTangent = QStringLiteral("tangent");
|
|
|
|
const QString AttrCRadius = QStringLiteral("cRadius");
|
|
|
|
const QString AttrArc = QStringLiteral("arc");
|
2016-05-12 21:11:21 +02:00
|
|
|
const QString AttrSuffix = QStringLiteral("suffix");
|
|
|
|
const QString AttrIdObject = QStringLiteral("idObject");
|
2016-06-26 13:36:12 +02:00
|
|
|
const QString AttrInLayout = QStringLiteral("inLayout");
|
2018-02-03 13:18:32 +01:00
|
|
|
const QString AttrForbidFlipping = QStringLiteral("forbidFlipping");
|
|
|
|
const QString AttrForceFlipping = QStringLiteral("forceFlipping");
|
2016-12-20 13:39:05 +01:00
|
|
|
const QString AttrRotationAngle = QStringLiteral("rotationAngle");
|
2016-12-01 19:47:15 +01:00
|
|
|
const QString AttrClosed = QStringLiteral("closed");
|
2017-09-17 18:52:18 +02:00
|
|
|
const QString AttrShowLabel = QStringLiteral("showLabel");
|
2017-09-20 09:19:02 +02:00
|
|
|
const QString AttrShowLabel1 = QStringLiteral("showLabel1");
|
|
|
|
const QString AttrShowLabel2 = QStringLiteral("showLabel2");
|
2017-10-15 11:25:20 +02:00
|
|
|
const QString AttrWidth = QStringLiteral("width");
|
|
|
|
const QString AttrHeight = QStringLiteral("height");
|
|
|
|
const QString AttrPlaceLabelType = QStringLiteral("placeLabelType");
|
2017-10-23 09:45:58 +02:00
|
|
|
const QString AttrVersion = QStringLiteral("version");
|
2015-08-11 15:41:03 +02:00
|
|
|
|
|
|
|
const QString TypeLineNone = QStringLiteral("none");
|
|
|
|
const QString TypeLineLine = QStringLiteral("hair");
|
|
|
|
const QString TypeLineDashLine = QStringLiteral("dashLine");
|
|
|
|
const QString TypeLineDotLine = QStringLiteral("dotLine");
|
|
|
|
const QString TypeLineDashDotLine = QStringLiteral("dashDotLine");
|
|
|
|
const QString TypeLineDashDotDotLine = QStringLiteral("dashDotDotLine");
|
|
|
|
|
2017-05-16 12:07:53 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief Styles return list of all line styles.
|
|
|
|
* @return list of all line styles.
|
|
|
|
*/
|
|
|
|
QStringList StylesList()
|
|
|
|
{
|
|
|
|
const QStringList styles = QStringList() << TypeLineNone << TypeLineLine << TypeLineDashLine
|
|
|
|
<< TypeLineDotLine << TypeLineDashDotLine
|
|
|
|
<< TypeLineDashDotDotLine;
|
|
|
|
return styles;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
|
|
* @brief LineStyle return pen style for current line style.
|
|
|
|
* @return pen style.
|
|
|
|
*/
|
|
|
|
Qt::PenStyle LineStyleToPenStyle(const QString &typeLine)
|
|
|
|
{
|
|
|
|
const QStringList styles = StylesList();
|
|
|
|
switch (styles.indexOf(typeLine))
|
|
|
|
{
|
|
|
|
case 0: // TypeLineNone
|
|
|
|
return Qt::NoPen;
|
|
|
|
case 2: // TypeLineDashLine
|
|
|
|
return Qt::DashLine;
|
|
|
|
case 3: // TypeLineDotLine
|
|
|
|
return Qt::DotLine;
|
|
|
|
case 4: // TypeLineDashDotLine
|
|
|
|
return Qt::DashDotLine;
|
|
|
|
case 5: // TypeLineDashDotDotLine
|
|
|
|
return Qt::DashDotDotLine;
|
|
|
|
default:
|
|
|
|
return Qt::SolidLine;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString PenStyleToLineStyle(Qt::PenStyle penStyle)
|
|
|
|
{
|
|
|
|
QT_WARNING_PUSH
|
|
|
|
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|
|
|
|
|
|
|
switch (penStyle)
|
|
|
|
{
|
|
|
|
case Qt::NoPen:
|
|
|
|
return TypeLineNone;
|
|
|
|
case Qt::DashLine:
|
|
|
|
return TypeLineDashLine;
|
|
|
|
case Qt::DotLine:
|
|
|
|
return TypeLineDotLine;
|
|
|
|
case Qt::DashDotLine:
|
|
|
|
return TypeLineDashDotLine;
|
|
|
|
case Qt::DashDotDotLine:
|
|
|
|
return TypeLineDashDotDotLine;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
QT_WARNING_POP
|
|
|
|
|
|
|
|
return TypeLineLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QMap<QString, QIcon> LineStylesPics()
|
|
|
|
{
|
|
|
|
QMap<QString, QIcon> map;
|
|
|
|
const QStringList styles = StylesList();
|
|
|
|
|
|
|
|
for (int i=0; i < styles.size(); ++i)
|
|
|
|
{
|
|
|
|
const Qt::PenStyle style = LineStyleToPenStyle(styles.at(i));
|
|
|
|
QPixmap pix(80, 14);
|
|
|
|
pix.fill(Qt::white);
|
|
|
|
|
|
|
|
QBrush brush(Qt::black);
|
|
|
|
QPen pen(brush, 2.5, style);
|
|
|
|
|
|
|
|
QPainter painter(&pix);
|
|
|
|
painter.setPen(pen);
|
|
|
|
painter.drawLine(2, 7, 78, 7);
|
|
|
|
|
|
|
|
map.insert(styles.at(i), QIcon(pix));
|
|
|
|
}
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QMap<QString, QIcon> CurvePenStylesPics()
|
|
|
|
{
|
|
|
|
QMap<QString, QIcon> map = LineStylesPics();
|
|
|
|
map.remove(TypeLineNone);
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
2016-10-16 19:23:40 +02:00
|
|
|
const QString ColorBlack = QStringLiteral("black");
|
|
|
|
const QString ColorGreen = QStringLiteral("green");
|
|
|
|
const QString ColorBlue = QStringLiteral("blue");
|
|
|
|
const QString ColorDarkRed = QStringLiteral("darkRed");
|
|
|
|
const QString ColorDarkGreen = QStringLiteral("darkGreen");
|
|
|
|
const QString ColorDarkBlue = QStringLiteral("darkBlue");
|
|
|
|
const QString ColorYellow = QStringLiteral("yellow");
|
|
|
|
const QString ColorLightSalmon = QStringLiteral("lightsalmon");
|
|
|
|
const QString ColorGoldenRod = QStringLiteral("goldenrod");
|
|
|
|
const QString ColorOrange = QStringLiteral("orange");
|
|
|
|
const QString ColorDeepPink = QStringLiteral("deeppink");
|
|
|
|
const QString ColorViolet = QStringLiteral("violet");
|
|
|
|
const QString ColorDarkViolet = QStringLiteral("darkviolet");
|
|
|
|
const QString ColorMediumSeaGreen = QStringLiteral("mediumseagreen");
|
|
|
|
const QString ColorLime = QStringLiteral("lime");
|
|
|
|
const QString ColorDeepSkyBlue = QStringLiteral("deepskyblue");
|
|
|
|
const QString ColorCornFlowerBlue = QStringLiteral("cornflowerblue");
|
2015-08-11 15:41:03 +02:00
|
|
|
|
|
|
|
//variables
|
2017-03-28 09:18:19 +02:00
|
|
|
const QString measurement_ = QStringLiteral("M_");
|
|
|
|
const QString increment_ = QStringLiteral("Increment_");
|
2017-01-20 14:58:35 +01:00
|
|
|
const QString line_ = QStringLiteral("Line_");
|
|
|
|
const QString angleLine_ = QStringLiteral("AngleLine_");
|
|
|
|
const QString spl_ = QStringLiteral(SPL_);
|
|
|
|
const QString arc_ = QStringLiteral(ARC_);
|
2017-08-08 17:27:36 +02:00
|
|
|
const QString elarc_ = QStringLiteral(ELARC_);
|
2017-01-20 14:58:35 +01:00
|
|
|
const QString splPath = QStringLiteral("SplPath");
|
|
|
|
const QString radius_V = QStringLiteral("Radius");
|
|
|
|
const QString radiusArc_ = radius_V + arc_;
|
2017-08-08 17:27:36 +02:00
|
|
|
const QString radius1ElArc_ = radius_V + QLatin1Char('1') + elarc_;
|
|
|
|
const QString radius2ElArc_ = radius_V + QLatin1Char('2') + elarc_;
|
2017-01-20 14:58:35 +01:00
|
|
|
const QString angle1_V = QStringLiteral("Angle1");
|
|
|
|
const QString angle2_V = QStringLiteral("Angle2");
|
|
|
|
const QString c1Length_V = QStringLiteral("C1Length");
|
|
|
|
const QString c2Length_V = QStringLiteral("C2Length");
|
|
|
|
const QString c1LengthSpl_ = c1Length_V + spl_;
|
|
|
|
const QString c2LengthSpl_ = c2Length_V + spl_;
|
|
|
|
const QString c1LengthSplPath = c1Length_V + splPath;
|
|
|
|
const QString c2LengthSplPath = c2Length_V + splPath;
|
|
|
|
const QString angle1Arc_ = angle1_V + arc_;
|
|
|
|
const QString angle2Arc_ = angle2_V + arc_;
|
2017-08-08 17:27:36 +02:00
|
|
|
const QString angle1ElArc_ = angle1_V + elarc_;
|
|
|
|
const QString angle2ElArc_ = angle2_V + elarc_;
|
2017-01-20 14:58:35 +01:00
|
|
|
const QString angle1Spl_ = angle1_V + spl_;
|
|
|
|
const QString angle2Spl_ = angle2_V + spl_;
|
|
|
|
const QString angle1SplPath = angle1_V + splPath;
|
|
|
|
const QString angle2SplPath = angle2_V + splPath;
|
|
|
|
const QString seg_ = QStringLiteral("Seg_");
|
|
|
|
const QString currentLength = QStringLiteral("CurrentLength");
|
|
|
|
const QString currentSeamAllowance = QStringLiteral("CurrentSeamAllowance");
|
2018-01-05 20:07:47 +01:00
|
|
|
const QString rotation_V = QStringLiteral("Rotation");
|
|
|
|
const QString rotationElArc_ = rotation_V + elarc_;
|
2015-08-11 15:41:03 +02:00
|
|
|
|
2017-03-28 09:18:19 +02:00
|
|
|
const QStringList builInVariables = QStringList() << measurement_
|
|
|
|
<< increment_
|
|
|
|
<< line_
|
2015-08-11 15:41:03 +02:00
|
|
|
<< angleLine_
|
|
|
|
<< arc_
|
2017-08-08 17:27:36 +02:00
|
|
|
<< elarc_
|
2015-08-11 15:41:03 +02:00
|
|
|
<< spl_
|
|
|
|
<< splPath
|
|
|
|
<< radiusArc_
|
2017-08-08 17:27:36 +02:00
|
|
|
<< radius1ElArc_
|
|
|
|
<< radius2ElArc_
|
2015-08-11 15:41:03 +02:00
|
|
|
<< angle1Arc_
|
|
|
|
<< angle2Arc_
|
2017-08-08 17:27:36 +02:00
|
|
|
<< angle1ElArc_
|
|
|
|
<< angle2ElArc_
|
2015-08-11 15:41:03 +02:00
|
|
|
<< angle1Spl_
|
|
|
|
<< angle2Spl_
|
|
|
|
<< angle1SplPath
|
2016-04-01 23:15:04 +02:00
|
|
|
<< angle2SplPath
|
2016-06-23 19:20:21 +02:00
|
|
|
<< seg_
|
2016-09-26 21:33:28 +02:00
|
|
|
<< currentLength
|
2017-01-20 14:58:35 +01:00
|
|
|
<< currentSeamAllowance
|
2016-09-26 21:33:28 +02:00
|
|
|
<< c1LengthSpl_
|
|
|
|
<< c2LengthSpl_
|
|
|
|
<< c1LengthSplPath
|
2018-01-05 20:07:47 +01:00
|
|
|
<< c2LengthSplPath
|
|
|
|
<< rotationElArc_;
|