2014-02-25 15:02:09 +01:00
|
|
|
|
/************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** @file vpattern.cpp
|
2014-04-30 07:38:52 +02:00
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2014-02-25 15:02:09 +01:00
|
|
|
|
** @date 24 2, 2014
|
|
|
|
|
**
|
|
|
|
|
** @brief
|
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2014-02-25 15:02:09 +01:00
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2014-02-25 15:02:09 +01:00
|
|
|
|
** <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 "vpattern.h"
|
2016-07-26 15:16:09 +02:00
|
|
|
|
#include "../vwidgets/vabstractmainwindow.h"
|
2015-08-09 18:38:12 +02:00
|
|
|
|
#include "../vtools/tools/vdatatool.h"
|
2016-11-08 16:54:26 +01:00
|
|
|
|
#include "../vtools/tools/vtoolseamallowance.h"
|
2015-08-09 18:38:12 +02:00
|
|
|
|
#include "../vtools/tools/vtooluniondetails.h"
|
|
|
|
|
#include "../vtools/tools/drawTools/drawtools.h"
|
|
|
|
|
#include "../vtools/tools/nodeDetails/nodedetails.h"
|
|
|
|
|
#include "../ifc/exception/vexceptionobjecterror.h"
|
|
|
|
|
#include "../ifc/exception/vexceptionwrongid.h"
|
|
|
|
|
#include "../ifc/exception/vexceptionconversionerror.h"
|
|
|
|
|
#include "../ifc/exception/vexceptionemptyparameter.h"
|
|
|
|
|
#include "../ifc/exception/vexceptionundo.h"
|
|
|
|
|
#include "../ifc/xml/vpatternconverter.h"
|
2017-08-03 14:25:14 +02:00
|
|
|
|
#include "../vmisc/customevents.h"
|
2015-08-09 18:38:12 +02:00
|
|
|
|
#include "../vmisc/vsettings.h"
|
2016-08-16 18:57:32 +02:00
|
|
|
|
#include "../vmisc/vmath.h"
|
2017-05-29 15:33:36 +02:00
|
|
|
|
#include "../vmisc/projectversion.h"
|
2015-08-09 18:38:12 +02:00
|
|
|
|
#include "../qmuparser/qmuparsererror.h"
|
2017-08-08 16:43:41 +02:00
|
|
|
|
#include "../qmuparser/qmutokenparser.h"
|
2015-08-09 18:38:12 +02:00
|
|
|
|
#include "../vgeometry/varc.h"
|
2016-12-20 15:51:58 +01:00
|
|
|
|
#include "../vgeometry/vellipticalarc.h"
|
2016-02-12 19:10:01 +01:00
|
|
|
|
#include "../vgeometry/vsplinepath.h"
|
2016-03-10 14:55:04 +01:00
|
|
|
|
#include "../vgeometry/vcubicbezier.h"
|
2016-03-18 22:11:14 +01:00
|
|
|
|
#include "../vgeometry/vcubicbezierpath.h"
|
2015-06-18 19:23:24 +02:00
|
|
|
|
#include "../core/vapplication.h"
|
2016-11-08 16:54:26 +01:00
|
|
|
|
#include "../vpatterndb/vpiecenode.h"
|
2015-08-25 12:35:50 +02:00
|
|
|
|
#include "../vpatterndb/calculator.h"
|
2017-02-23 10:37:19 +01:00
|
|
|
|
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
|
|
|
|
|
#include "../vpatterndb/floatItemData/vpatternlabeldata.h"
|
|
|
|
|
#include "../vpatterndb/floatItemData/vgrainlinedata.h"
|
2016-11-23 11:54:46 +01:00
|
|
|
|
#include "../vpatterndb/vpiecepath.h"
|
2017-01-21 18:12:57 +01:00
|
|
|
|
#include "../vpatterndb/vnodedetail.h"
|
2014-08-07 14:03:24 +02:00
|
|
|
|
|
2014-06-08 20:10:57 +02:00
|
|
|
|
#include <QMessageBox>
|
2014-07-13 14:49:00 +02:00
|
|
|
|
#include <QUndoStack>
|
2016-05-24 14:06:35 +02:00
|
|
|
|
#include <QtNumeric>
|
2016-10-23 11:11:00 +02:00
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QFileInfo>
|
2018-01-24 13:06:21 +01:00
|
|
|
|
#include <QtConcurrentMap>
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
2016-01-22 11:45:18 +01:00
|
|
|
|
const QString VPattern::AttrReadOnly = QStringLiteral("readOnly");
|
|
|
|
|
|
2017-05-29 15:33:36 +02:00
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
QString FileComment()
|
|
|
|
|
{
|
2017-09-01 16:04:19 +02:00
|
|
|
|
return QString("Pattern created with Valentina v%1 (https://valentinaproject.bitbucket.io/).").arg(APP_VERSION_STR);
|
2017-05-29 15:33:36 +02:00
|
|
|
|
}
|
2018-01-24 13:06:21 +01:00
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void GatherCount(int &count, const int nodes)
|
|
|
|
|
{
|
|
|
|
|
count += nodes;
|
|
|
|
|
}
|
2017-05-29 15:33:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-12 09:22:29 +02:00
|
|
|
|
VPattern::VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw,
|
2014-06-05 13:35:38 +02:00
|
|
|
|
VMainGraphicsScene *sceneDetail, QObject *parent)
|
2015-06-16 11:04:48 +02:00
|
|
|
|
: VAbstractPattern(parent), data(data), mode(mode), sceneDraw(sceneDraw), sceneDetail(sceneDetail)
|
2014-06-05 13:35:38 +02:00
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(sceneDraw != nullptr)
|
|
|
|
|
SCASSERT(sceneDetail != nullptr)
|
2014-06-05 13:35:38 +02:00
|
|
|
|
}
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-05 12:02:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief CreateEmptyFile create minimal empty file.
|
|
|
|
|
*/
|
2015-08-16 17:56:06 +02:00
|
|
|
|
void VPattern::CreateEmptyFile()
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2014-06-06 17:06:41 +02:00
|
|
|
|
this->clear();
|
2014-02-25 19:03:17 +01:00
|
|
|
|
QDomElement patternElement = this->createElement(TagPattern);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
2017-05-29 15:33:36 +02:00
|
|
|
|
patternElement.appendChild(createComment(FileComment()));
|
2014-05-21 16:40:21 +02:00
|
|
|
|
|
|
|
|
|
QDomElement version = createElement(TagVersion);
|
2014-12-11 20:44:48 +01:00
|
|
|
|
QDomText newNodeText = createTextNode(VPatternConverter::PatternMaxVerStr);
|
2014-05-21 16:40:21 +02:00
|
|
|
|
version.appendChild(newNodeText);
|
2014-06-09 19:47:25 +02:00
|
|
|
|
patternElement.appendChild(version);
|
2014-05-21 16:40:21 +02:00
|
|
|
|
|
2015-08-16 17:56:06 +02:00
|
|
|
|
QDomElement unit = createElement(TagUnit);
|
|
|
|
|
newNodeText = createTextNode(UnitsToStr(qApp->patternUnit()));
|
|
|
|
|
unit.appendChild(newNodeText);
|
|
|
|
|
patternElement.appendChild(unit);
|
2014-03-16 07:32:52 +01:00
|
|
|
|
|
2015-08-27 10:25:11 +02:00
|
|
|
|
patternElement.appendChild(createElement(TagDescription));
|
|
|
|
|
patternElement.appendChild(createElement(TagNotes));
|
|
|
|
|
|
2015-08-16 17:56:06 +02:00
|
|
|
|
patternElement.appendChild(createElement(TagMeasurements));
|
2014-02-25 15:02:09 +01:00
|
|
|
|
patternElement.appendChild(createElement(TagIncrements));
|
2017-09-02 13:47:44 +02:00
|
|
|
|
patternElement.appendChild(createElement(TagPreviewCalculations));
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
|
|
|
|
this->appendChild(patternElement);
|
|
|
|
|
insertBefore(createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""), this->firstChild());
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-26 14:08:41 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::setXMLContent(const QString &fileName)
|
|
|
|
|
{
|
|
|
|
|
VDomDocument::setXMLContent(fileName);
|
|
|
|
|
GarbageCollector();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-05 12:02:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief Parse parse file.
|
|
|
|
|
* @param parse parser file mode.
|
|
|
|
|
*/
|
2014-06-12 09:22:29 +02:00
|
|
|
|
void VPattern::Parse(const Document &parse)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Parsing pattern.");
|
2015-01-27 14:56:44 +01:00
|
|
|
|
switch (parse)
|
|
|
|
|
{
|
|
|
|
|
case Document::FullParse:
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Full parse.");
|
2015-01-27 14:56:44 +01:00
|
|
|
|
break;
|
|
|
|
|
case Document::LiteParse:
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Lite parse.");
|
2015-01-27 14:56:44 +01:00
|
|
|
|
break;
|
|
|
|
|
case Document::LitePPParse:
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Lite pattern piece parse.");
|
2015-01-27 14:56:44 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(sceneDraw != nullptr)
|
|
|
|
|
SCASSERT(sceneDetail != nullptr)
|
2017-08-16 15:56:07 +02:00
|
|
|
|
QStringList tags = QStringList() << TagDraw << TagIncrements << TagDescription << TagNotes
|
2016-06-27 01:17:27 +02:00
|
|
|
|
<< TagMeasurements << TagVersion << TagGradation << TagImage << TagUnit
|
|
|
|
|
<< TagPatternName << TagPatternNum << TagCompanyName << TagCustomerName
|
2017-09-26 11:54:52 +02:00
|
|
|
|
<< TagPatternLabel << TagPatternMaterials << TagPreviewCalculations
|
|
|
|
|
<< TagFinalMeasurements;
|
2014-06-05 13:46:12 +02:00
|
|
|
|
PrepareForParse(parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
QDomNode domNode = documentElement().firstChild();
|
|
|
|
|
while (domNode.isNull() == false)
|
|
|
|
|
{
|
|
|
|
|
if (domNode.isElement())
|
|
|
|
|
{
|
|
|
|
|
const QDomElement domElement = domNode.toElement();
|
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
|
{
|
2014-02-26 10:51:37 +01:00
|
|
|
|
switch (tags.indexOf(domElement.tagName()))
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2014-02-25 19:03:17 +01:00
|
|
|
|
case 0: // TagDraw
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag draw.");
|
2014-02-25 19:03:17 +01:00
|
|
|
|
if (parse == Document::FullParse)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2014-07-17 14:41:48 +02:00
|
|
|
|
if (nameActivPP.isEmpty())
|
2014-02-25 19:03:17 +01:00
|
|
|
|
{
|
2014-06-06 17:06:41 +02:00
|
|
|
|
SetActivPP(GetParametrString(domElement, AttrName));
|
2014-02-25 19:03:17 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-06 17:06:41 +02:00
|
|
|
|
ChangeActivPP(GetParametrString(domElement, AttrName));
|
2014-02-25 19:03:17 +01:00
|
|
|
|
}
|
2014-06-05 13:35:38 +02:00
|
|
|
|
patternPieces << GetParametrString(domElement, AttrName);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-06-06 17:06:41 +02:00
|
|
|
|
ChangeActivPP(GetParametrString(domElement, AttrName), Document::LiteParse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
2014-07-16 14:47:31 +02:00
|
|
|
|
ParseDrawElement(domElement, parse);
|
2014-02-25 19:03:17 +01:00
|
|
|
|
break;
|
|
|
|
|
case 1: // TagIncrements
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag increments.");
|
2018-01-22 13:26:53 +01:00
|
|
|
|
ParseIncrementsElement(domElement, parse);
|
2014-02-25 19:03:17 +01:00
|
|
|
|
break;
|
2017-08-16 15:56:07 +02:00
|
|
|
|
case 2: // TagDescription
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag description.");
|
2014-03-03 16:30:04 +01:00
|
|
|
|
break;
|
2017-08-16 15:56:07 +02:00
|
|
|
|
case 3: // TagNotes
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag notes.");
|
2014-03-03 16:30:04 +01:00
|
|
|
|
break;
|
2017-08-16 15:56:07 +02:00
|
|
|
|
case 4: // TagMeasurements
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag measurements.");
|
2014-03-23 15:36:34 +01:00
|
|
|
|
break;
|
2017-08-16 15:56:07 +02:00
|
|
|
|
case 5: // TagVersion
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag version.");
|
2014-05-21 19:33:40 +02:00
|
|
|
|
break;
|
2017-08-16 15:56:07 +02:00
|
|
|
|
case 6: // TagGradation
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag gradation.");
|
2014-08-08 18:24:36 +02:00
|
|
|
|
break;
|
2017-08-16 15:56:07 +02:00
|
|
|
|
case 7: // TagImage
|
2016-04-02 02:00:00 +02:00
|
|
|
|
qCDebug(vXML, "Tag image.");
|
2014-08-08 18:24:36 +02:00
|
|
|
|
break;
|
2017-08-16 15:56:07 +02:00
|
|
|
|
case 8: // TagUnit
|
2015-10-08 08:43:29 +02:00
|
|
|
|
qCDebug(vXML, "Tag unit.");
|
|
|
|
|
break;
|
2017-08-16 15:56:07 +02:00
|
|
|
|
case 9: // TagPatternName
|
2016-06-27 01:17:27 +02:00
|
|
|
|
qCDebug(vXML, "Pattern name.");
|
|
|
|
|
break;
|
2017-08-16 15:56:07 +02:00
|
|
|
|
case 10: // TagPatternNumber
|
2016-06-27 01:17:27 +02:00
|
|
|
|
qCDebug(vXML, "Pattern number.");
|
|
|
|
|
break;
|
2017-08-16 15:56:07 +02:00
|
|
|
|
case 11: // TagCompanyName
|
2016-06-27 01:17:27 +02:00
|
|
|
|
qCDebug(vXML, "Company name.");
|
|
|
|
|
break;
|
2017-08-16 15:56:07 +02:00
|
|
|
|
case 12: // TagCustomerName
|
2016-06-27 01:17:27 +02:00
|
|
|
|
qCDebug(vXML, "Customer name.");
|
|
|
|
|
break;
|
2017-08-16 15:56:07 +02:00
|
|
|
|
case 13: // TagPatternLabel
|
|
|
|
|
qCDebug(vXML, "Pattern label.");
|
2016-07-24 12:30:10 +02:00
|
|
|
|
break;
|
2017-08-30 07:55:07 +02:00
|
|
|
|
case 14: // TagPatternMaterials
|
|
|
|
|
qCDebug(vXML, "Pattern materials.");
|
|
|
|
|
break;
|
2017-09-02 13:47:44 +02:00
|
|
|
|
case 15: // TagPreviewCalculations
|
|
|
|
|
qCDebug(vXML, "Tag prewiew calculations.");
|
2018-01-22 13:26:53 +01:00
|
|
|
|
ParseIncrementsElement(domElement, parse);
|
2017-09-02 13:47:44 +02:00
|
|
|
|
break;
|
2017-09-26 11:54:52 +02:00
|
|
|
|
case 16: // TagFinalMeasurements
|
|
|
|
|
qCDebug(vXML, "Tag final measurements.");
|
|
|
|
|
break;
|
2014-02-25 19:03:17 +01:00
|
|
|
|
default:
|
2015-10-01 17:34:03 +02:00
|
|
|
|
qCDebug(vXML, "Wrong tag name %s", qUtf8Printable(domElement.tagName()));
|
2014-02-25 19:03:17 +01:00
|
|
|
|
break;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
domNode = domNode.nextSibling();
|
|
|
|
|
}
|
2014-07-23 15:13:08 +02:00
|
|
|
|
emit CheckLayout();
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-05 12:02:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief setCurrentData set current data set.
|
2014-06-05 13:35:38 +02:00
|
|
|
|
*
|
|
|
|
|
* Each time after parsing need set correct data set for current pattern piece. After parsing it is always last.
|
|
|
|
|
* Current data set for pattern pice it is data set for last object in pattern pice (point, arc, spline, spline path so
|
|
|
|
|
* on).
|
2014-06-05 12:02:35 +02:00
|
|
|
|
*/
|
2014-02-25 15:02:09 +01:00
|
|
|
|
void VPattern::setCurrentData()
|
|
|
|
|
{
|
2014-06-12 09:22:29 +02:00
|
|
|
|
if (*mode == Draw::Calculation)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2017-09-25 17:15:28 +02:00
|
|
|
|
const int countPP = CountPP();
|
|
|
|
|
if (countPP > 1)//don't need upadate data if we have only one pattern piece
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Setting current data");
|
2015-10-01 17:34:03 +02:00
|
|
|
|
qCDebug(vXML, "Current PP name %s", qUtf8Printable(nameActivPP));
|
2017-09-25 17:15:28 +02:00
|
|
|
|
qCDebug(vXML, "PP count %d", countPP);
|
2014-11-24 14:03:34 +01:00
|
|
|
|
|
2017-09-25 17:15:28 +02:00
|
|
|
|
const QVector<VToolRecord> localHistory = getLocalHistory();
|
|
|
|
|
if (localHistory.size() == 0)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "History is empty!");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2017-09-25 17:15:28 +02:00
|
|
|
|
|
|
|
|
|
const quint32 id = localHistory.last().getId();
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Resoring data from tool with id %u", id);
|
2014-11-24 14:03:34 +01:00
|
|
|
|
|
2014-02-25 15:02:09 +01:00
|
|
|
|
if (tools.size() > 0)
|
|
|
|
|
{
|
2014-12-21 21:33:31 +01:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ToolExists(id);
|
|
|
|
|
}
|
|
|
|
|
catch (VExceptionBadId &e)
|
|
|
|
|
{
|
2015-03-16 13:23:02 +01:00
|
|
|
|
Q_UNUSED(e)
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "List of tools doesn't containe id= %u", id);
|
2014-12-21 21:33:31 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-25 15:02:09 +01:00
|
|
|
|
const VDataTool *vTool = tools.value(id);
|
2014-08-21 14:44:40 +02:00
|
|
|
|
*data = vTool->getData();
|
2017-01-21 14:24:40 +01:00
|
|
|
|
//Delete special variables if exist
|
2016-06-23 19:20:21 +02:00
|
|
|
|
data->RemoveVariable(currentLength);
|
2017-01-21 14:24:40 +01:00
|
|
|
|
data->RemoveVariable(currentSeamAllowance);
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Data successfully updated.");
|
2014-11-24 14:03:34 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "List of tools is empty!");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-05 12:02:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief UpdateToolData update tool in list tools.
|
|
|
|
|
* @param id tool id.
|
|
|
|
|
* @param data container with variables.
|
|
|
|
|
*/
|
2014-02-25 15:40:24 +01:00
|
|
|
|
void VPattern::UpdateToolData(const quint32 &id, VContainer *data)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(id != 0, Q_FUNC_INFO, "id == 0"); //-V712 //-V654
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(data != nullptr)
|
2014-10-30 13:52:49 +01:00
|
|
|
|
ToolExists(id);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
VDataTool *tool = tools.value(id);
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(tool != nullptr)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
tool->VDataTool::setData(data);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-25 15:36:04 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
VContainer VPattern::GetCompleteData() const
|
|
|
|
|
{
|
|
|
|
|
const int countPP = CountPP();
|
|
|
|
|
if (countPP <= 0 || history.isEmpty() || tools.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
return (data != nullptr ? *data : VContainer(nullptr, nullptr));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const quint32 id = (countPP == 1 ? history.last().getId() : LastToolId());
|
|
|
|
|
|
|
|
|
|
if (id == NULL_ID)
|
|
|
|
|
{
|
|
|
|
|
return (data != nullptr ? *data : VContainer(nullptr, nullptr));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ToolExists(id);
|
|
|
|
|
}
|
|
|
|
|
catch (VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(e)
|
|
|
|
|
return (data != nullptr ? *data : VContainer(nullptr, nullptr));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const VDataTool *vTool = tools.value(id);
|
|
|
|
|
VContainer lastData = vTool->getData();
|
|
|
|
|
//Delete special variables if exist
|
|
|
|
|
lastData.RemoveVariable(currentLength);
|
|
|
|
|
lastData.RemoveVariable(currentSeamAllowance);
|
|
|
|
|
return lastData;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-05 12:02:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief SPointActiveDraw return id base point current pattern peace.
|
|
|
|
|
* @return id base point.
|
|
|
|
|
*/
|
2015-04-15 14:44:57 +02:00
|
|
|
|
// cppcheck-suppress unusedFunction
|
2014-02-25 15:40:24 +01:00
|
|
|
|
quint32 VPattern::SPointActiveDraw()
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
|
|
|
|
QDomElement calcElement;
|
|
|
|
|
if (GetActivNodeElement(TagCalculation, calcElement))
|
|
|
|
|
{
|
|
|
|
|
const QDomNode domNode = calcElement.firstChild();
|
|
|
|
|
if (domNode.isNull() == false && domNode.isElement())
|
|
|
|
|
{
|
|
|
|
|
const QDomElement domElement = domNode.toElement();
|
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
|
{
|
2016-05-16 19:59:04 +02:00
|
|
|
|
if (domElement.tagName() == TagPoint && domElement.attribute(AttrType, "") == VToolBasePoint::ToolType)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
|
|
|
|
return GetParametrId(domElement);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-23 17:41:01 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
QVector<quint32> VPattern::GetActivePPPieces() const
|
|
|
|
|
{
|
|
|
|
|
QVector<quint32> pieces;
|
|
|
|
|
QDomElement drawElement;
|
|
|
|
|
if (GetActivDrawElement(drawElement))
|
|
|
|
|
{
|
|
|
|
|
const QDomElement details = drawElement.firstChildElement(TagDetails);
|
|
|
|
|
if (not details.isNull())
|
|
|
|
|
{
|
|
|
|
|
QDomElement detail = details.firstChildElement(TagDetail);
|
|
|
|
|
while(not detail.isNull())
|
|
|
|
|
{
|
|
|
|
|
bool united = GetParametrBool(detail, VToolSeamAllowance::AttrUnited, falseStr);
|
|
|
|
|
if (not united)
|
|
|
|
|
{
|
|
|
|
|
pieces.append(GetParametrId(detail));
|
|
|
|
|
}
|
|
|
|
|
detail = detail.nextSiblingElement(TagDetail);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return pieces;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-05-29 15:33:36 +02:00
|
|
|
|
bool VPattern::SaveDocument(const QString &fileName, QString &error)
|
2014-03-28 14:11:46 +01:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
TestUniqueId();
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionWrongId &e)
|
|
|
|
|
{
|
2015-12-18 12:57:03 +01:00
|
|
|
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error not unique id.")),
|
2015-10-01 16:59:01 +02:00
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
2014-03-28 14:11:46 +01:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-06-12 11:51:40 +02:00
|
|
|
|
|
2017-05-29 15:33:36 +02:00
|
|
|
|
// Update comment with Valentina version
|
|
|
|
|
QDomNode commentNode = documentElement().firstChild();
|
|
|
|
|
if (commentNode.isComment())
|
|
|
|
|
{
|
|
|
|
|
QDomComment comment = commentNode.toComment();
|
|
|
|
|
comment.setData(FileComment());
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-18 12:57:03 +01:00
|
|
|
|
const bool saved = VAbstractPattern::SaveDocument(fileName, error);
|
2016-07-20 10:39:15 +02:00
|
|
|
|
if (saved && QFileInfo(fileName).suffix() != QLatin1String("autosave"))
|
2015-12-18 12:57:03 +01:00
|
|
|
|
{
|
|
|
|
|
modified = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return saved;
|
2014-03-28 14:11:46 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-23 15:52:57 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::LiteParseIncrements()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
emit SetEnabledGUI(true);
|
|
|
|
|
|
|
|
|
|
VContainer::ClearUniqueIncrementNames();
|
|
|
|
|
data->ClearVariables(VarType::Increment);
|
|
|
|
|
|
2017-09-02 13:47:44 +02:00
|
|
|
|
QDomNodeList tags = elementsByTagName(TagIncrements);
|
|
|
|
|
if (not tags.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
const QDomNode domElement = tags.at(0);
|
|
|
|
|
if (not domElement.isNull())
|
|
|
|
|
{
|
2018-01-22 13:26:53 +01:00
|
|
|
|
ParseIncrementsElement(domElement, Document::LiteParse);
|
2017-09-02 13:47:44 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tags = elementsByTagName(TagPreviewCalculations);
|
2017-07-23 15:52:57 +02:00
|
|
|
|
if (not tags.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
const QDomNode domElement = tags.at(0);
|
|
|
|
|
if (not domElement.isNull())
|
|
|
|
|
{
|
2018-01-22 13:26:53 +01:00
|
|
|
|
ParseIncrementsElement(domElement, Document::LiteParse);
|
2017-07-23 15:52:57 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionUndo &e)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(e)
|
|
|
|
|
/* If user want undo last operation before undo we need finish broken redo operation. For those we post event
|
|
|
|
|
* myself. Later in method customEvent call undo.*/
|
|
|
|
|
QApplication::postEvent(this, new UndoEvent());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionObjectError &e)
|
|
|
|
|
{
|
|
|
|
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), //-V807
|
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
|
|
|
|
emit SetEnabledGUI(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionConversionError &e)
|
|
|
|
|
{
|
|
|
|
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value.")),
|
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
|
|
|
|
emit SetEnabledGUI(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionEmptyParameter &e)
|
|
|
|
|
{
|
|
|
|
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter.")),
|
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
|
|
|
|
emit SetEnabledGUI(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionWrongId &e)
|
|
|
|
|
{
|
|
|
|
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")),
|
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
|
|
|
|
emit SetEnabledGUI(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
catch (VException &e)
|
|
|
|
|
{
|
|
|
|
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")),
|
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
|
|
|
|
emit SetEnabledGUI(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
catch (const std::bad_alloc &)
|
|
|
|
|
{
|
|
|
|
|
qCCritical(vXML, "%s", qUtf8Printable(tr("Error parsing file (std::bad_alloc).")));
|
|
|
|
|
emit SetEnabledGUI(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-11 12:51:06 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::RefreshCurves()
|
|
|
|
|
{
|
|
|
|
|
QHash<quint32, VDataTool*>::const_iterator i = tools.constBegin();
|
|
|
|
|
while (i != tools.constEnd())
|
|
|
|
|
{
|
|
|
|
|
if (VAbstractSpline *vTool = qobject_cast<VAbstractSpline *>(i.value()))
|
|
|
|
|
{
|
|
|
|
|
vTool->FullUpdateFromFile();
|
|
|
|
|
}
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-22 13:26:53 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
int VPattern::ElementsToParse() const
|
|
|
|
|
{
|
2018-01-24 13:06:21 +01:00
|
|
|
|
QVector<QString> tags({TagArc, TagDetail, TagElArc, TagLine, TagSpline, TagOperation, TagPath, TagPoint,
|
|
|
|
|
TagTools, TagIncrement
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
std::function<int (const QString &tagName)> TagsCount = [this](const QString &tagName)
|
|
|
|
|
{
|
|
|
|
|
return elementsByTagName(tagName).length();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return QtConcurrent::blockingMappedReduced(tags, TagsCount, GatherCount);
|
2018-01-22 13:26:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-05 12:02:35 +02:00
|
|
|
|
/**
|
2014-06-10 13:53:40 +02:00
|
|
|
|
* @brief LiteParseTree lite parse file.
|
2014-06-05 12:02:35 +02:00
|
|
|
|
*/
|
2014-08-04 15:37:36 +02:00
|
|
|
|
void VPattern::LiteParseTree(const Document &parse)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2014-07-23 10:56:32 +02:00
|
|
|
|
// Save name current pattern piece
|
|
|
|
|
QString namePP = nameActivPP;
|
|
|
|
|
|
2014-02-25 15:02:09 +01:00
|
|
|
|
try
|
|
|
|
|
{
|
2014-06-24 10:23:39 +02:00
|
|
|
|
emit SetEnabledGUI(true);
|
2014-09-10 19:57:08 +02:00
|
|
|
|
switch (parse)
|
2014-08-04 15:37:36 +02:00
|
|
|
|
{
|
|
|
|
|
case Document::LitePPParse:
|
|
|
|
|
ParseCurrentPP();
|
|
|
|
|
break;
|
|
|
|
|
case Document::LiteParse:
|
|
|
|
|
Parse(parse);
|
|
|
|
|
break;
|
|
|
|
|
case Document::FullParse:
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCWarning(vXML, "Lite parsing doesn't support full parsing");
|
2014-08-04 15:37:36 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
2014-06-24 10:23:39 +02:00
|
|
|
|
catch (const VExceptionUndo &e)
|
|
|
|
|
{
|
2016-12-20 20:19:21 +01:00
|
|
|
|
Q_UNUSED(e)
|
2014-06-24 10:23:39 +02:00
|
|
|
|
/* If user want undo last operation before undo we need finish broken redo operation. For those we post event
|
|
|
|
|
* myself. Later in method customEvent call undo.*/
|
|
|
|
|
QApplication::postEvent(this, new UndoEvent());
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-05-30 15:22:03 +02:00
|
|
|
|
catch (const VExceptionObjectError &e)
|
|
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")), //-V807
|
2015-10-01 16:59:01 +02:00
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
2014-06-24 10:23:39 +02:00
|
|
|
|
emit SetEnabledGUI(false);
|
2015-12-09 12:31:33 +01:00
|
|
|
|
if (not VApplication::IsGUIMode())
|
2015-10-08 08:30:26 +02:00
|
|
|
|
{
|
2015-10-11 11:06:14 +02:00
|
|
|
|
qApp->exit(V_EX_NOINPUT);
|
2015-10-08 08:30:26 +02:00
|
|
|
|
}
|
2015-10-11 11:06:14 +02:00
|
|
|
|
return;
|
2014-05-30 15:22:03 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionConversionError &e)
|
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error can't convert value.")),
|
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
2014-06-24 10:23:39 +02:00
|
|
|
|
emit SetEnabledGUI(false);
|
2015-12-09 12:31:33 +01:00
|
|
|
|
if (not VApplication::IsGUIMode())
|
2015-10-08 08:30:26 +02:00
|
|
|
|
{
|
2015-10-11 11:06:14 +02:00
|
|
|
|
qApp->exit(V_EX_NOINPUT);
|
2015-10-08 08:30:26 +02:00
|
|
|
|
}
|
2015-10-11 11:06:14 +02:00
|
|
|
|
return;
|
2014-05-30 15:22:03 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionEmptyParameter &e)
|
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error empty parameter.")),
|
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
2014-06-24 10:23:39 +02:00
|
|
|
|
emit SetEnabledGUI(false);
|
2015-12-09 12:31:33 +01:00
|
|
|
|
if (not VApplication::IsGUIMode())
|
2015-10-08 08:30:26 +02:00
|
|
|
|
{
|
2015-10-11 11:06:14 +02:00
|
|
|
|
qApp->exit(V_EX_NOINPUT);
|
2015-10-08 08:30:26 +02:00
|
|
|
|
}
|
2015-10-11 11:06:14 +02:00
|
|
|
|
return;
|
2014-05-30 15:22:03 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionWrongId &e)
|
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error wrong id.")),
|
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
2014-06-24 10:23:39 +02:00
|
|
|
|
emit SetEnabledGUI(false);
|
2015-12-09 12:31:33 +01:00
|
|
|
|
if (not VApplication::IsGUIMode())
|
2015-10-08 08:30:26 +02:00
|
|
|
|
{
|
2015-10-11 11:06:14 +02:00
|
|
|
|
qApp->exit(V_EX_NOINPUT);
|
2015-10-08 08:30:26 +02:00
|
|
|
|
}
|
2015-10-11 11:06:14 +02:00
|
|
|
|
return;
|
2014-05-30 15:22:03 +02:00
|
|
|
|
}
|
|
|
|
|
catch (VException &e)
|
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
|
qCCritical(vXML, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Error parsing file.")),
|
|
|
|
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
2014-06-24 10:23:39 +02:00
|
|
|
|
emit SetEnabledGUI(false);
|
2015-12-09 12:31:33 +01:00
|
|
|
|
if (not VApplication::IsGUIMode())
|
2015-10-08 08:30:26 +02:00
|
|
|
|
{
|
2015-10-11 11:06:14 +02:00
|
|
|
|
qApp->exit(V_EX_NOINPUT);
|
2015-10-08 08:30:26 +02:00
|
|
|
|
}
|
2015-10-11 11:06:14 +02:00
|
|
|
|
return;
|
2014-05-30 15:22:03 +02:00
|
|
|
|
}
|
2014-02-25 15:02:09 +01:00
|
|
|
|
catch (const std::bad_alloc &)
|
|
|
|
|
{
|
2015-10-01 16:59:01 +02:00
|
|
|
|
qCCritical(vXML, "%s", qUtf8Printable(tr("Error parsing file (std::bad_alloc).")));
|
2014-06-24 10:23:39 +02:00
|
|
|
|
emit SetEnabledGUI(false);
|
2015-12-09 12:31:33 +01:00
|
|
|
|
if (not VApplication::IsGUIMode())
|
2015-10-08 08:30:26 +02:00
|
|
|
|
{
|
2015-10-11 11:06:14 +02:00
|
|
|
|
qApp->exit(V_EX_NOINPUT);
|
2015-10-08 08:30:26 +02:00
|
|
|
|
}
|
2015-10-11 11:06:14 +02:00
|
|
|
|
return;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-23 10:56:32 +02:00
|
|
|
|
// Restore name current pattern piece
|
|
|
|
|
nameActivPP = namePP;
|
2015-10-01 17:34:03 +02:00
|
|
|
|
qCDebug(vXML, "Current pattern piece %s", qUtf8Printable(nameActivPP));
|
2014-02-25 15:02:09 +01:00
|
|
|
|
setCurrentData();
|
|
|
|
|
emit FullUpdateFromFile();
|
2014-10-28 14:17:43 +01:00
|
|
|
|
// Recalculate scene rect
|
2015-06-15 09:40:23 +02:00
|
|
|
|
VMainGraphicsView::NewSceneRect(sceneDraw, qApp->getSceneView());
|
|
|
|
|
VMainGraphicsView::NewSceneRect(sceneDetail, qApp->getSceneView());
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Scene size updated.");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-24 10:23:39 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-04-15 14:44:57 +02:00
|
|
|
|
// cppcheck-suppress unusedFunction
|
2014-06-24 10:23:39 +02:00
|
|
|
|
void VPattern::customEvent(QEvent *event)
|
|
|
|
|
{
|
2014-09-10 19:57:08 +02:00
|
|
|
|
if (event->type() == UNDO_EVENT)
|
2014-06-24 10:23:39 +02:00
|
|
|
|
{
|
|
|
|
|
qApp->getUndoStack()->undo();
|
|
|
|
|
}
|
2017-08-03 14:25:14 +02:00
|
|
|
|
else if (event->type() == LITE_PARSE_EVENT)
|
|
|
|
|
{
|
|
|
|
|
LiteParseTree(Document::LiteParse);
|
|
|
|
|
}
|
2014-06-24 10:23:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-01 19:47:15 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
VNodeDetail VPattern::ParseDetailNode(const QDomElement &domElement) const
|
|
|
|
|
{
|
|
|
|
|
const quint32 id = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
|
|
|
|
|
const qreal mx = GetParametrDouble(domElement, AttrMx, "0.0");
|
|
|
|
|
const qreal my = GetParametrDouble(domElement, AttrMy, "0.0");
|
|
|
|
|
const bool reverse = GetParametrUInt(domElement, VAbstractPattern::AttrNodeReverse, "0");
|
|
|
|
|
const NodeDetail nodeType = NodeDetail::Contour;
|
|
|
|
|
|
|
|
|
|
const QString t = GetParametrString(domElement, AttrType, "NodePoint");
|
|
|
|
|
Tool tool;
|
|
|
|
|
|
|
|
|
|
QStringList types = QStringList() << VAbstractPattern::NodePoint
|
|
|
|
|
<< VAbstractPattern::NodeArc
|
|
|
|
|
<< VAbstractPattern::NodeSpline
|
2016-12-20 16:42:51 +01:00
|
|
|
|
<< VAbstractPattern::NodeSplinePath
|
|
|
|
|
<< VAbstractPattern::NodeElArc;
|
2016-12-01 19:47:15 +01:00
|
|
|
|
switch (types.indexOf(t))
|
|
|
|
|
{
|
|
|
|
|
case 0: // NodePoint
|
|
|
|
|
tool = Tool::NodePoint;
|
|
|
|
|
break;
|
|
|
|
|
case 1: // NodeArc
|
|
|
|
|
tool = Tool::NodeArc;
|
|
|
|
|
break;
|
|
|
|
|
case 2: // NodeSpline
|
|
|
|
|
tool = Tool::NodeSpline;
|
|
|
|
|
break;
|
|
|
|
|
case 3: // NodeSplinePath
|
|
|
|
|
tool = Tool::NodeSplinePath;
|
|
|
|
|
break;
|
2016-12-20 16:42:51 +01:00
|
|
|
|
case 4: // NodeElArc
|
|
|
|
|
tool = Tool::NodeElArc;
|
|
|
|
|
break;
|
2016-12-01 19:47:15 +01:00
|
|
|
|
default:
|
|
|
|
|
VException e(tr("Wrong tag name '%1'.").arg(t));
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
return VNodeDetail(id, tool, nodeType, mx, my, reverse);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-05 12:02:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief ParseDrawElement parse draw tag.
|
|
|
|
|
* @param node node.
|
|
|
|
|
* @param parse parser file mode.
|
|
|
|
|
*/
|
2014-07-16 14:47:31 +02:00
|
|
|
|
void VPattern::ParseDrawElement(const QDomNode &node, const Document &parse)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2016-04-06 11:03:34 +02:00
|
|
|
|
QStringList tags = QStringList() << TagCalculation << TagModeling << TagDetails << TagGroups;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
QDomNode domNode = node.firstChild();
|
|
|
|
|
while (domNode.isNull() == false)
|
|
|
|
|
{
|
|
|
|
|
if (domNode.isElement())
|
|
|
|
|
{
|
|
|
|
|
const QDomElement domElement = domNode.toElement();
|
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
|
{
|
2014-02-26 10:51:37 +01:00
|
|
|
|
switch (tags.indexOf(domElement.tagName()))
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2014-02-25 19:03:17 +01:00
|
|
|
|
case 0: // TagCalculation
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag calculation.");
|
2014-02-25 19:03:17 +01:00
|
|
|
|
data->ClearCalculationGObjects();
|
2014-07-16 14:47:31 +02:00
|
|
|
|
ParseDrawMode(domElement, parse, Draw::Calculation);
|
2014-02-25 19:03:17 +01:00
|
|
|
|
break;
|
|
|
|
|
case 1: // TagModeling
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag modeling.");
|
2014-07-16 14:47:31 +02:00
|
|
|
|
ParseDrawMode(domElement, parse, Draw::Modeling);
|
2014-02-25 19:03:17 +01:00
|
|
|
|
break;
|
|
|
|
|
case 2: // TagDetails
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag details.");
|
2014-07-16 14:47:31 +02:00
|
|
|
|
ParseDetails(domElement, parse);
|
2014-02-25 19:03:17 +01:00
|
|
|
|
break;
|
2016-04-06 11:03:34 +02:00
|
|
|
|
case 3: // TagGroups
|
|
|
|
|
qCDebug(vXML, "Tag groups.");
|
|
|
|
|
ParseGroups(domElement);
|
|
|
|
|
break;
|
2014-02-25 19:03:17 +01:00
|
|
|
|
default:
|
2015-10-08 08:43:29 +02:00
|
|
|
|
VException e(tr("Wrong tag name '%1'.").arg(domElement.tagName()));
|
|
|
|
|
throw e;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
domNode = domNode.nextSibling();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-05 12:02:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief ParseDrawMode parse draw tag with draw mode.
|
|
|
|
|
* @param node node.
|
|
|
|
|
* @param parse parser file mode.
|
|
|
|
|
* @param mode draw mode.
|
|
|
|
|
*/
|
2014-07-16 14:47:31 +02:00
|
|
|
|
void VPattern::ParseDrawMode(const QDomNode &node, const Document &parse, const Draw &mode)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(sceneDraw != nullptr)
|
|
|
|
|
SCASSERT(sceneDetail != nullptr)
|
2014-03-10 17:22:55 +01:00
|
|
|
|
VMainGraphicsScene *scene = nullptr;
|
2014-06-12 09:22:29 +02:00
|
|
|
|
if (mode == Draw::Calculation)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
|
|
|
|
scene = sceneDraw;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
scene = sceneDetail;
|
|
|
|
|
}
|
2016-11-24 20:35:54 +01:00
|
|
|
|
const QStringList tags = QStringList() << TagPoint
|
|
|
|
|
<< TagLine
|
|
|
|
|
<< TagSpline
|
|
|
|
|
<< TagArc
|
|
|
|
|
<< TagTools
|
|
|
|
|
<< TagOperation
|
2016-12-20 13:39:05 +01:00
|
|
|
|
<< TagElArc
|
2016-11-24 20:35:54 +01:00
|
|
|
|
<< TagPath;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
const QDomNodeList nodeList = node.childNodes();
|
|
|
|
|
const qint32 num = nodeList.size();
|
|
|
|
|
for (qint32 i = 0; i < num; ++i)
|
|
|
|
|
{
|
2014-05-30 10:32:40 +02:00
|
|
|
|
QDomElement domElement = nodeList.at(i).toElement();
|
2014-02-25 15:02:09 +01:00
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
|
{
|
2014-02-26 10:51:37 +01:00
|
|
|
|
switch (tags.indexOf(domElement.tagName()))
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2014-02-25 19:03:17 +01:00
|
|
|
|
case 0: // TagPoint
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag point.");
|
2014-02-25 19:03:17 +01:00
|
|
|
|
ParsePointElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
|
|
|
|
break;
|
|
|
|
|
case 1: // TagLine
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag line.");
|
2014-02-25 19:03:17 +01:00
|
|
|
|
ParseLineElement(scene, domElement, parse);
|
|
|
|
|
break;
|
|
|
|
|
case 2: // TagSpline
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag spline.");
|
2014-02-25 19:03:17 +01:00
|
|
|
|
ParseSplineElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
|
|
|
|
break;
|
|
|
|
|
case 3: // TagArc
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag arc.");
|
2014-02-25 19:03:17 +01:00
|
|
|
|
ParseArcElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
|
|
|
|
break;
|
|
|
|
|
case 4: // TagTools
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Tag tools.");
|
2014-02-25 19:03:17 +01:00
|
|
|
|
ParseToolsElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
|
|
|
|
break;
|
2016-05-16 19:27:51 +02:00
|
|
|
|
case 5: // TagOperation
|
|
|
|
|
qCDebug(vXML, "Tag operation.");
|
|
|
|
|
ParseOperationElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
|
|
|
|
break;
|
2016-12-17 02:53:47 +01:00
|
|
|
|
case 6: // TagElArc
|
|
|
|
|
qCDebug(vXML, "Tag elliptical arc.");
|
|
|
|
|
ParseEllipticalArcElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
2017-01-27 13:07:12 +01:00
|
|
|
|
break;
|
2016-12-20 13:39:05 +01:00
|
|
|
|
case 7: // TagPath
|
2016-11-24 20:35:54 +01:00
|
|
|
|
qCDebug(vXML, "Tag path.");
|
|
|
|
|
ParsePathElement(scene, domElement, parse);
|
|
|
|
|
break;
|
2014-02-25 19:03:17 +01:00
|
|
|
|
default:
|
2015-10-08 08:43:29 +02:00
|
|
|
|
VException e(tr("Wrong tag name '%1'.").arg(domElement.tagName()));
|
|
|
|
|
throw e;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
2018-01-22 13:26:53 +01:00
|
|
|
|
|
|
|
|
|
if (parse == Document::FullParse)
|
|
|
|
|
{
|
|
|
|
|
emit MadeProgress();
|
|
|
|
|
}
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-05 12:02:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief ParseDetailElement parse detail tag.
|
|
|
|
|
* @param domElement tag in xml tree.
|
|
|
|
|
* @param parse parser file mode.
|
|
|
|
|
*/
|
2017-01-21 14:24:40 +01:00
|
|
|
|
void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2016-11-08 16:54:26 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolSeamAllowanceInitData initData;
|
|
|
|
|
initData.id = GetParametrId(domElement);
|
|
|
|
|
initData.detail.SetName(GetParametrString(domElement, AttrName, tr("Detail")));
|
|
|
|
|
initData.detail.SetMx(qApp->toPixel(GetParametrDouble(domElement, AttrMx, "0.0")));
|
|
|
|
|
initData.detail.SetMy(qApp->toPixel(GetParametrDouble(domElement, AttrMy, "0.0")));
|
|
|
|
|
initData.detail.SetSeamAllowance(GetParametrBool(domElement, VToolSeamAllowance::AttrSeamAllowance, falseStr));
|
|
|
|
|
initData.detail.SetHideMainPath(GetParametrBool(domElement, VToolSeamAllowance::AttrHideMainPath,
|
2017-05-16 14:16:50 +02:00
|
|
|
|
QString().setNum(qApp->ValentinaSettings()->IsHideMainPath())));
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.detail.SetSeamAllowanceBuiltIn(GetParametrBool(domElement,
|
|
|
|
|
VToolSeamAllowance::AttrSeamAllowanceBuiltIn,
|
|
|
|
|
falseStr));
|
|
|
|
|
initData.detail.SetForbidFlipping(GetParametrBool(domElement, VToolSeamAllowance::AttrForbidFlipping,
|
2017-12-17 14:06:46 +01:00
|
|
|
|
QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping())));
|
|
|
|
|
initData.detail.SetForceFlipping(GetParametrBool(domElement, VToolSeamAllowance::AttrForceFlipping,
|
|
|
|
|
QString().setNum(qApp->ValentinaSettings()->GetForceWorkpieceFlipping())));
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr));
|
|
|
|
|
initData.detail.SetUnited(GetParametrBool(domElement, VToolSeamAllowance::AttrUnited, falseStr));
|
2016-11-08 11:57:01 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.width = GetParametrString(domElement, AttrWidth, "0.0");
|
|
|
|
|
const QString w = initData.width;//need for saving fixed formula;
|
2017-10-23 09:45:58 +02:00
|
|
|
|
const uint version = GetParametrUInt(domElement, AttrVersion, "1");
|
2016-12-01 19:47:15 +01:00
|
|
|
|
|
2016-11-25 13:19:44 +01:00
|
|
|
|
const QStringList tags = QStringList() << TagNodes
|
2016-11-08 16:54:26 +01:00
|
|
|
|
<< TagData
|
|
|
|
|
<< TagPatternInfo
|
2016-11-25 13:19:44 +01:00
|
|
|
|
<< TagGrainline
|
2016-12-03 17:01:39 +01:00
|
|
|
|
<< VToolSeamAllowance::TagCSA
|
2017-01-31 17:09:18 +01:00
|
|
|
|
<< VToolSeamAllowance::TagIPaths
|
2017-10-15 11:25:20 +02:00
|
|
|
|
<< VToolSeamAllowance::TagPins
|
|
|
|
|
<< VToolSeamAllowance::TagPlaceLabels;
|
2016-11-08 11:57:01 +01:00
|
|
|
|
|
2016-11-08 16:54:26 +01:00
|
|
|
|
const QDomNodeList nodeList = domElement.childNodes();
|
|
|
|
|
for (qint32 i = 0; i < nodeList.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
const QDomElement element = nodeList.at(i).toElement();
|
|
|
|
|
if (not element.isNull())
|
|
|
|
|
{
|
|
|
|
|
switch (tags.indexOf(element.tagName()))
|
|
|
|
|
{
|
2016-11-25 13:19:44 +01:00
|
|
|
|
case 0:// TagNodes
|
2016-12-01 19:47:15 +01:00
|
|
|
|
if (version == 1)
|
|
|
|
|
{
|
|
|
|
|
// TODO. Delete if minimal supported version is 0.4.0
|
|
|
|
|
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 4, 0),
|
|
|
|
|
"Time to refactor the code.");
|
|
|
|
|
const bool closed = GetParametrUInt(domElement, AttrClosed, "1");
|
2017-01-25 10:32:52 +01:00
|
|
|
|
const qreal width = GetParametrDouble(domElement, AttrWidth, "0.0");
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ParseDetailNodes(element, initData.detail, width, closed);
|
2016-12-01 19:47:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.detail.SetPath(ParsePieceNodes(element));
|
2016-12-01 19:47:15 +01:00
|
|
|
|
}
|
2016-11-08 16:54:26 +01:00
|
|
|
|
break;
|
|
|
|
|
case 1:// TagData
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ParsePieceDataTag(element, initData.detail);
|
2016-11-08 16:54:26 +01:00
|
|
|
|
break;
|
|
|
|
|
case 2:// TagPatternInfo
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ParsePiecePatternInfo(element, initData.detail);
|
2016-11-08 16:54:26 +01:00
|
|
|
|
break;
|
|
|
|
|
case 3:// TagGrainline
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ParsePieceGrainline(element, initData.detail);
|
2016-11-08 16:54:26 +01:00
|
|
|
|
break;
|
2016-11-25 13:19:44 +01:00
|
|
|
|
case 4:// VToolSeamAllowance::TagCSA
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.detail.SetCustomSARecords(ParsePieceCSARecords(element));
|
2016-11-25 13:19:44 +01:00
|
|
|
|
break;
|
2016-12-03 17:01:39 +01:00
|
|
|
|
case 5:// VToolSeamAllowance::TagIPaths
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.detail.SetInternalPaths(ParsePieceInternalPaths(element));
|
2017-01-27 13:07:12 +01:00
|
|
|
|
break;
|
2017-01-31 17:09:18 +01:00
|
|
|
|
case 6:// VToolSeamAllowance::TagPins
|
2017-10-15 11:25:20 +02:00
|
|
|
|
initData.detail.SetPins(ParsePiecePointRecords(element));
|
|
|
|
|
break;
|
|
|
|
|
case 7:// VToolSeamAllowance::TagPlaceLabels
|
|
|
|
|
initData.detail.SetPlaceLabels(ParsePiecePointRecords(element));
|
2017-01-31 17:09:18 +01:00
|
|
|
|
break;
|
2016-11-08 16:54:26 +01:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-18 10:37:23 +02:00
|
|
|
|
|
|
|
|
|
initData.scene = sceneDetail;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
|
|
|
|
|
VToolSeamAllowance::Create(initData);
|
2017-01-21 14:24:40 +01:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (w != initData.width)
|
2017-01-21 14:24:40 +01:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrWidth, initData.width);
|
2017-01-21 14:24:40 +01:00
|
|
|
|
modified = true;
|
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
2016-11-08 16:54:26 +01:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating detail"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-08 16:54:26 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-01-25 10:32:52 +01:00
|
|
|
|
void VPattern::ParseDetailNodes(const QDomElement &domElement, VPiece &detail, qreal width, bool closed) const
|
2016-12-01 19:47:15 +01:00
|
|
|
|
{
|
|
|
|
|
QVector<VNodeDetail> oldNodes;
|
|
|
|
|
const QDomNodeList nodeList = domElement.childNodes();
|
|
|
|
|
for (qint32 i = 0; i < nodeList.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
const QDomElement element = nodeList.at(i).toElement();
|
2016-12-03 17:01:39 +01:00
|
|
|
|
if (not element.isNull()
|
|
|
|
|
&& element.tagName() == VAbstractPattern::TagNode) // Old detail version need this check!
|
2016-12-01 19:47:15 +01:00
|
|
|
|
{
|
|
|
|
|
oldNodes.append(ParseDetailNode(element));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-25 10:32:52 +01:00
|
|
|
|
detail.GetPath().SetNodes(VNodeDetail::Convert(data, oldNodes, width, closed));
|
2016-12-01 19:47:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-25 13:19:44 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-01-12 15:08:27 +01:00
|
|
|
|
void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail) const
|
|
|
|
|
{
|
2017-03-13 13:27:29 +01:00
|
|
|
|
VPieceLabelData &ppData = detail.GetPatternPieceData();
|
|
|
|
|
ppData.SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
|
2017-08-21 12:16:43 +02:00
|
|
|
|
ppData.SetLetter(GetParametrEmptyString(domElement, AttrLetter));
|
|
|
|
|
ppData.SetAnnotation(GetParametrEmptyString(domElement, AttrAnnotation));
|
|
|
|
|
ppData.SetOrientation(GetParametrEmptyString(domElement, AttrOrientation));
|
2017-08-21 16:10:55 +02:00
|
|
|
|
ppData.SetRotationWay(GetParametrEmptyString(domElement, AttrRotationWay));
|
2017-08-21 12:16:43 +02:00
|
|
|
|
ppData.SetTilt(GetParametrEmptyString(domElement, AttrTilt));
|
|
|
|
|
ppData.SetFoldPosition(GetParametrEmptyString(domElement, AttrFoldPosition));
|
2017-08-18 06:59:47 +02:00
|
|
|
|
ppData.SetQuantity(static_cast<int>(GetParametrUInt(domElement, AttrQuantity, "1")));
|
|
|
|
|
ppData.SetOnFold(GetParametrBool(domElement, AttrOnFold, falseStr));
|
2017-03-13 13:27:29 +01:00
|
|
|
|
ppData.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0")));
|
|
|
|
|
ppData.SetLabelWidth(GetParametrString(domElement, AttrWidth, "1"));
|
2017-10-15 11:25:20 +02:00
|
|
|
|
ppData.SetLabelHeight(GetParametrString(domElement, AttrHeight, "1"));
|
2017-03-13 13:27:29 +01:00
|
|
|
|
ppData.SetFontSize(static_cast<int>(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, "0")));
|
|
|
|
|
ppData.SetRotation(GetParametrString(domElement, AttrRotation, "0"));
|
2017-03-13 15:10:25 +01:00
|
|
|
|
ppData.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
|
2017-03-13 13:27:29 +01:00
|
|
|
|
ppData.SetTopLeftPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR));
|
|
|
|
|
ppData.SetBottomRightPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR));
|
2017-08-18 06:59:47 +02:00
|
|
|
|
ppData.SetLabelTemplate(GetLabelTemplate(domElement));
|
2017-01-12 15:08:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParsePiecePatternInfo(const QDomElement &domElement, VPiece &detail) const
|
|
|
|
|
{
|
2017-03-13 13:27:29 +01:00
|
|
|
|
VPatternLabelData &patternInfo = detail.GetPatternInfo();
|
|
|
|
|
patternInfo.SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
|
|
|
|
|
patternInfo.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0")));
|
|
|
|
|
patternInfo.SetLabelWidth(GetParametrString(domElement, AttrWidth, "1"));
|
2017-10-15 11:25:20 +02:00
|
|
|
|
patternInfo.SetLabelHeight(GetParametrString(domElement, AttrHeight, "1"));
|
2017-03-13 13:27:29 +01:00
|
|
|
|
patternInfo.SetFontSize(static_cast<int>(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, "0")));
|
|
|
|
|
patternInfo.SetRotation(GetParametrString(domElement, AttrRotation, "0"));
|
2017-03-13 15:10:25 +01:00
|
|
|
|
patternInfo.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
|
2017-03-13 13:27:29 +01:00
|
|
|
|
patternInfo.SetTopLeftPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR));
|
|
|
|
|
patternInfo.SetBottomRightPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR));
|
2017-01-12 15:08:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParsePieceGrainline(const QDomElement &domElement, VPiece &detail) const
|
|
|
|
|
{
|
2017-03-13 13:27:29 +01:00
|
|
|
|
VGrainlineData &gGeometry = detail.GetGrainlineGeometry();
|
|
|
|
|
gGeometry.SetVisible(GetParametrBool(domElement, AttrVisible, falseStr));
|
|
|
|
|
gGeometry.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0")));
|
|
|
|
|
gGeometry.SetLength(GetParametrString(domElement, AttrLength, "1"));
|
|
|
|
|
gGeometry.SetRotation(GetParametrString(domElement, AttrRotation, "90"));
|
|
|
|
|
gGeometry.SetArrowType(static_cast<ArrowType>(GetParametrUInt(domElement, AttrArrows, "0")));
|
|
|
|
|
gGeometry.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
|
|
|
|
|
gGeometry.SetTopPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopPin, NULL_ID_STR));
|
|
|
|
|
gGeometry.SetBottomPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomPin, NULL_ID_STR));
|
2017-01-12 15:08:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-05 12:02:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief ParseDetails parse details tag.
|
|
|
|
|
* @param domElement tag in xml tree.
|
|
|
|
|
* @param parse parser file mode.
|
|
|
|
|
*/
|
2014-07-16 14:47:31 +02:00
|
|
|
|
void VPattern::ParseDetails(const QDomElement &domElement, const Document &parse)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
QDomNode domNode = domElement.firstChild();
|
|
|
|
|
while (domNode.isNull() == false)
|
|
|
|
|
{
|
|
|
|
|
if (domNode.isElement())
|
|
|
|
|
{
|
2017-01-21 14:24:40 +01:00
|
|
|
|
QDomElement domElement = domNode.toElement();
|
2014-02-25 15:02:09 +01:00
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
|
{
|
2016-05-16 19:59:04 +02:00
|
|
|
|
if (domElement.tagName() == TagDetail)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2014-07-16 14:47:31 +02:00
|
|
|
|
ParseDetailElement(domElement, parse);
|
2018-01-22 13:26:53 +01:00
|
|
|
|
|
|
|
|
|
if (parse == Document::FullParse)
|
|
|
|
|
{
|
|
|
|
|
emit MadeProgress();
|
|
|
|
|
}
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
domNode = domNode.nextSibling();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-18 18:11:14 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-09-18 10:37:23 +02:00
|
|
|
|
void VPattern::PointsWithLineCommonAttributes(const QDomElement &domElement, VToolLinePointInitData &initData)
|
2014-06-18 18:11:14 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsCommonAttributes(domElement, initData);
|
|
|
|
|
initData.typeLine = GetParametrString(domElement, AttrTypeLine, TypeLineLine);
|
|
|
|
|
initData.lineColor = GetParametrString(domElement, AttrLineColor, ColorBlack);
|
2014-06-18 18:11:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-09-18 10:37:23 +02:00
|
|
|
|
void VPattern::PointsCommonAttributes(const QDomElement &domElement, VToolSinglePointInitData &initData)
|
2014-06-18 18:11:14 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsCommonAttributes(domElement, initData.id, initData.mx, initData.my);
|
|
|
|
|
initData.name = GetParametrString(domElement, AttrName, "A");
|
|
|
|
|
initData.showLabel = GetParametrBool(domElement, AttrShowLabel, trueStr);
|
2014-06-18 18:11:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my)
|
|
|
|
|
{
|
|
|
|
|
ToolsCommonAttributes(domElement, id);
|
2015-08-11 15:41:03 +02:00
|
|
|
|
mx = qApp->toPixel(GetParametrDouble(domElement, AttrMx, "10.0"));
|
|
|
|
|
my = qApp->toPixel(GetParametrDouble(domElement, AttrMy, "15.0"));
|
2014-06-18 18:11:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-05 12:02:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief ParsePointElement parse point tag.
|
|
|
|
|
* @param scene scene.
|
|
|
|
|
* @param domElement tag in xml tree.
|
|
|
|
|
* @param parse parser file mode.
|
|
|
|
|
* @param type type of point.
|
|
|
|
|
*/
|
2014-05-30 10:32:40 +02:00
|
|
|
|
void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement,
|
2014-06-12 09:22:29 +02:00
|
|
|
|
const Document &parse, const QString &type)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of point is empty");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
2015-06-24 18:14:26 +02:00
|
|
|
|
QStringList points = QStringList() << VToolBasePoint::ToolType /*0*/
|
|
|
|
|
<< VToolEndLine::ToolType /*1*/
|
|
|
|
|
<< VToolAlongLine::ToolType /*2*/
|
|
|
|
|
<< VToolShoulderPoint::ToolType /*3*/
|
|
|
|
|
<< VToolNormal::ToolType /*4*/
|
|
|
|
|
<< VToolBisector::ToolType /*5*/
|
|
|
|
|
<< VToolLineIntersect::ToolType /*6*/
|
|
|
|
|
<< VToolPointOfContact::ToolType /*7*/
|
|
|
|
|
<< VNodePoint::ToolType /*8*/
|
|
|
|
|
<< VToolHeight::ToolType /*9*/
|
|
|
|
|
<< VToolTriangle::ToolType /*10*/
|
|
|
|
|
<< VToolPointOfIntersection::ToolType /*11*/
|
|
|
|
|
<< VToolCutSpline::ToolType /*12*/
|
|
|
|
|
<< VToolCutSplinePath::ToolType /*13*/
|
|
|
|
|
<< VToolCutArc::ToolType /*14*/
|
|
|
|
|
<< VToolLineIntersectAxis::ToolType /*15*/
|
|
|
|
|
<< VToolCurveIntersectAxis::ToolType /*16*/
|
|
|
|
|
<< VToolPointOfIntersectionArcs::ToolType /*17*/
|
|
|
|
|
<< VToolPointOfIntersectionCircles::ToolType /*18*/
|
|
|
|
|
<< VToolPointFromCircleAndTangent::ToolType /*19*/
|
|
|
|
|
<< VToolPointFromArcAndTangent::ToolType /*20*/
|
2016-01-24 17:15:08 +01:00
|
|
|
|
<< VToolTrueDarts::ToolType /*21*/
|
2017-01-31 15:04:51 +01:00
|
|
|
|
<< VToolPointOfIntersectionCurves::ToolType /*22*/
|
2017-10-15 11:25:20 +02:00
|
|
|
|
<< VToolPin::ToolType /*23*/
|
|
|
|
|
<< VToolPlaceLabel::ToolType; /*24*/
|
2014-02-26 10:51:37 +01:00
|
|
|
|
switch (points.indexOf(type))
|
|
|
|
|
{
|
2015-06-19 14:08:27 +02:00
|
|
|
|
case 0: //VToolBasePoint::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolBasePoint(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 1: //VToolEndLine::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolEndLine(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 2: //VToolAlongLine::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolAlongLine(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 3: //VToolShoulderPoint::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolShoulderPoint(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 4: //VToolNormal::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolNormal(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 5: //VToolBisector::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolBisector(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 6: //VToolLineIntersect::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolLineIntersect(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 7: //VToolPointOfContact::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolPointOfContact(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 8: //VNodePoint::ToolType
|
2015-06-25 12:52:09 +02:00
|
|
|
|
ParseNodePoint(domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 9: //VToolHeight::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolHeight(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 10: //VToolTriangle::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolTriangle(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 11: //VToolPointOfIntersection::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolPointOfIntersection(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 12: //VToolCutSpline::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolCutSpline(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 13: //VToolCutSplinePath::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolCutSplinePath(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 14: //VToolCutArc::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolCutArc(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
2014-10-20 19:41:02 +02:00
|
|
|
|
case 15: //VToolLineIntersectAxis::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolLineIntersectAxis(scene, domElement, parse);
|
2014-10-20 19:41:02 +02:00
|
|
|
|
break;
|
2014-10-23 10:38:57 +02:00
|
|
|
|
case 16: //VToolCurveIntersectAxis::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolCurveIntersectAxis(scene, domElement, parse);
|
2014-10-23 10:38:57 +02:00
|
|
|
|
break;
|
2015-05-27 20:23:50 +02:00
|
|
|
|
case 17: //VToolPointOfIntersectionArcs::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolPointOfIntersectionArcs(scene, domElement, parse);
|
2015-05-27 20:23:50 +02:00
|
|
|
|
break;
|
2015-05-30 12:02:20 +02:00
|
|
|
|
case 18: //VToolPointOfIntersectionCircles::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolPointOfIntersectionCircles(scene, domElement, parse);
|
2015-05-30 12:02:20 +02:00
|
|
|
|
break;
|
2015-06-05 15:43:41 +02:00
|
|
|
|
case 19: //VToolPointFromCircleAndTangent::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolPointFromCircleAndTangent(scene, domElement, parse);
|
2015-06-05 15:43:41 +02:00
|
|
|
|
break;
|
2015-06-06 08:33:19 +02:00
|
|
|
|
case 20: //VToolPointFromArcAndTangent::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolPointFromArcAndTangent(scene, domElement, parse);
|
2015-06-06 08:33:19 +02:00
|
|
|
|
break;
|
2015-06-24 16:30:07 +02:00
|
|
|
|
case 21: //VToolTrueDarts::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolTrueDarts(scene, domElement, parse);
|
2015-06-24 16:30:07 +02:00
|
|
|
|
break;
|
2016-01-24 17:15:08 +01:00
|
|
|
|
case 22: //VToolPointOfIntersectionCurves::ToolType
|
|
|
|
|
ParseToolPointOfIntersectionCurves(scene, domElement, parse);
|
|
|
|
|
break;
|
2017-01-31 15:04:51 +01:00
|
|
|
|
case 23: //VToolPin::ToolType
|
|
|
|
|
ParsePinPoint(domElement, parse);
|
|
|
|
|
break;
|
2017-10-15 11:25:20 +02:00
|
|
|
|
case 24: //VToolPlaceLabel::ToolType
|
|
|
|
|
ParsePlaceLabel(domElement, parse);
|
|
|
|
|
break;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
default:
|
2015-10-08 08:30:26 +02:00
|
|
|
|
VException e(tr("Unknown point type '%1'.").arg(type));
|
|
|
|
|
throw e;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-05 12:02:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief ParseLineElement parse line tag.
|
|
|
|
|
* @param scene scene.
|
|
|
|
|
* @param domElement tag in xml tree.
|
|
|
|
|
* @param parse parser file mode.
|
|
|
|
|
*/
|
2014-02-25 19:03:17 +01:00
|
|
|
|
void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
2014-06-12 09:22:29 +02:00
|
|
|
|
const Document &parse)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolLineInitData initData;
|
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.firstPoint = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
|
|
|
|
|
initData.secondPoint = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
|
|
|
|
|
initData.typeLine = GetParametrString(domElement, AttrTypeLine, TypeLineLine);
|
|
|
|
|
initData.lineColor = GetParametrString(domElement, AttrLineColor, ColorBlack);
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolLine::Create(initData);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating line"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-18 18:11:14 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject, quint32 &idTool)
|
|
|
|
|
{
|
|
|
|
|
ToolsCommonAttributes(domElement, id);
|
2016-05-12 21:11:21 +02:00
|
|
|
|
idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
|
2014-10-29 12:06:50 +01:00
|
|
|
|
idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
|
2014-06-18 18:11:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:23:18 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-07-30 11:03:50 +02:00
|
|
|
|
void VPattern::ParseCurrentPP()
|
2014-07-29 17:23:18 +02:00
|
|
|
|
{
|
|
|
|
|
QDomElement domElement;
|
|
|
|
|
if (GetActivDrawElement(domElement))
|
|
|
|
|
{
|
|
|
|
|
ParseDrawElement(domElement, Document::LiteParse);
|
|
|
|
|
}
|
|
|
|
|
emit CheckLayout();
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-05 10:01:46 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-10-26 09:36:07 +01:00
|
|
|
|
QString VPattern::GetLabelBase(quint32 index) const
|
2014-09-05 10:01:46 +02:00
|
|
|
|
{
|
2015-10-08 08:49:20 +02:00
|
|
|
|
const QStringList list = VApplication::LabelLanguages();
|
|
|
|
|
const QString def = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z");
|
2014-09-05 10:01:46 +02:00
|
|
|
|
QStringList alphabet;
|
2015-07-24 14:06:53 +02:00
|
|
|
|
switch (list.indexOf(qApp->ValentinaSettings()->GetLabelLanguage()))
|
2014-09-05 10:01:46 +02:00
|
|
|
|
{
|
|
|
|
|
case 0: // de
|
|
|
|
|
{
|
2015-10-08 08:49:20 +02:00
|
|
|
|
const QString al = QStringLiteral("A,Ä,B,C,D,E,F,G,H,I,J,K,L,M,N,O,Ö,P,Q,R,S,ß,T,U,Ü,V,W,X,Y,Z");
|
2014-09-05 10:01:46 +02:00
|
|
|
|
alphabet = al.split(",");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2: // fr
|
|
|
|
|
{
|
2015-10-08 08:49:20 +02:00
|
|
|
|
const QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z");
|
2014-09-05 10:01:46 +02:00
|
|
|
|
alphabet = al.split(",");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 3: // ru
|
|
|
|
|
{
|
2015-10-08 08:49:20 +02:00
|
|
|
|
const QString al = QStringLiteral("А,Б,В,Г,Д,Е,Ж,З,И,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Э,Ю,Я");
|
2014-09-05 10:01:46 +02:00
|
|
|
|
alphabet = al.split(",");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 4: // uk
|
|
|
|
|
{
|
2015-10-08 08:49:20 +02:00
|
|
|
|
const QString al = QStringLiteral("А,Б,В,Г,Д,Е,Ж,З,І,Ї,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Є,Ю,Я");
|
2014-09-05 10:01:46 +02:00
|
|
|
|
alphabet = al.split(",");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-09-09 15:11:50 +02:00
|
|
|
|
case 5: // hr
|
2017-05-12 09:15:44 +02:00
|
|
|
|
case 7: // bs
|
2014-09-09 15:11:50 +02:00
|
|
|
|
{
|
2015-10-08 08:49:20 +02:00
|
|
|
|
const QString al = QStringLiteral("A,B,C,Č,Ć,D,Dž,Ð,E,F,G,H,I,J,K,L,Lj,M,N,Nj,O,P,R,S,Š,T,U,V,Z,Ž");
|
2014-09-09 15:11:50 +02:00
|
|
|
|
alphabet = al.split(",");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 6: // sr
|
|
|
|
|
{
|
2015-10-08 08:49:20 +02:00
|
|
|
|
const QString al = QStringLiteral("А,Б,В,Г,Д,Ђ,Е,Ж,З,И,Ј,К,Л,Љ,М,Н,Њ,О,П,Р,С,Т,Ћ,У,Ф,Х,Ц,Ч,Џ,Ш");
|
2014-09-09 15:11:50 +02:00
|
|
|
|
alphabet = al.split(",");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-12-21 20:35:07 +01:00
|
|
|
|
case 1: // en
|
2014-09-05 10:01:46 +02:00
|
|
|
|
default: // en
|
|
|
|
|
{
|
2015-10-08 08:49:20 +02:00
|
|
|
|
alphabet = def.split(",");
|
2014-09-05 10:01:46 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString base;
|
2015-10-26 09:36:07 +01:00
|
|
|
|
const int count = qFloor(index/static_cast<quint32>(alphabet.size()));
|
2015-10-08 08:49:20 +02:00
|
|
|
|
const int number = static_cast<int>(index) - alphabet.size() * count;
|
2014-09-05 10:01:46 +02:00
|
|
|
|
int i = 0;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
base.append(alphabet.at(number));
|
|
|
|
|
++i;
|
|
|
|
|
} while (i < count);
|
|
|
|
|
return base;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-06-24 18:14:26 +02:00
|
|
|
|
void VPattern::ParseToolBasePoint(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
2016-08-02 14:12:13 +02:00
|
|
|
|
VToolBasePoint *spoint = nullptr;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
try
|
2014-02-26 10:51:37 +01:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolBasePointInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsCommonAttributes(domElement, initData);
|
|
|
|
|
initData.x = qApp->toPixel(GetParametrDouble(domElement, AttrX, "10.0"));
|
|
|
|
|
initData.y = qApp->toPixel(GetParametrDouble(domElement, AttrY, "10.0"));
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
spoint = VToolBasePoint::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating single point"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
scene->removeItem(spoint);
|
|
|
|
|
delete spoint;
|
|
|
|
|
throw excep;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-06-24 18:14:26 +02:00
|
|
|
|
void VPattern::ParseToolEndLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
2015-06-24 18:14:26 +02:00
|
|
|
|
try
|
2014-02-26 10:51:37 +01:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolEndLineInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsWithLineCommonAttributes(domElement, initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.formulaLength = GetParametrString(domElement, AttrLength, "100.0");
|
|
|
|
|
const QString f = initData.formulaLength;//need for saving fixed formula;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.basePointId = GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.formulaAngle = GetParametrString(domElement, AttrAngle, "0.0");
|
|
|
|
|
const QString angleFix = initData.formulaAngle;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolEndLine::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (f != initData.formulaLength || angleFix != initData.formulaAngle)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrLength, initData.formulaLength);
|
|
|
|
|
SetAttribute(domElement, AttrAngle, initData.formulaAngle);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolAlongLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolAlongLineInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
|
|
|
|
|
PointsWithLineCommonAttributes(domElement, initData);
|
|
|
|
|
initData.formula = GetParametrString(domElement, AttrLength, "100.0");
|
|
|
|
|
const QString f = initData.formula;//need for saving fixed formula;
|
|
|
|
|
initData.firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
|
|
|
|
|
initData.secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
|
|
|
|
|
|
|
|
|
|
VToolAlongLine::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (f != initData.formula)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrLength, initData.formula);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolShoulderPoint(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolShoulderPointInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
|
|
|
|
|
PointsWithLineCommonAttributes(domElement, initData);
|
|
|
|
|
initData.formula = GetParametrString(domElement, AttrLength, "100.0");
|
|
|
|
|
const QString f = initData.formula;//need for saving fixed formula;
|
|
|
|
|
initData.p1Line = GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
|
|
|
|
|
initData.p2Line = GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
|
|
|
|
|
initData.pShoulder = GetParametrUInt(domElement, AttrPShoulder, NULL_ID_STR);
|
|
|
|
|
|
|
|
|
|
VToolShoulderPoint::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (f != initData.formula)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrLength, initData.formula);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolNormal(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolNormalInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
|
|
|
|
|
PointsWithLineCommonAttributes(domElement, initData);
|
|
|
|
|
initData.formula = GetParametrString(domElement, AttrLength, "100.0");
|
|
|
|
|
const QString f = initData.formula;//need for saving fixed formula;
|
|
|
|
|
initData.firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
|
|
|
|
|
initData.secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
|
|
|
|
|
initData.angle = GetParametrDouble(domElement, AttrAngle, "0.0");
|
|
|
|
|
|
|
|
|
|
VToolNormal::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (f != initData.formula)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrLength, initData.formula);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolBisector(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolBisectorInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
|
|
|
|
|
PointsWithLineCommonAttributes(domElement, initData);
|
|
|
|
|
initData.formula = GetParametrString(domElement, AttrLength, "100.0");
|
|
|
|
|
const QString f = initData.formula;//need for saving fixed formula;
|
|
|
|
|
initData.firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
|
|
|
|
|
initData.secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
|
|
|
|
|
initData.thirdPointId = GetParametrUInt(domElement, AttrThirdPoint, NULL_ID_STR);
|
|
|
|
|
|
|
|
|
|
VToolBisector::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (f != initData.formula)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrLength, initData.formula);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolLineIntersect(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolLineIntersectInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsCommonAttributes(domElement, initData);
|
|
|
|
|
initData.p1Line1Id = GetParametrUInt(domElement, AttrP1Line1, NULL_ID_STR);
|
|
|
|
|
initData.p2Line1Id = GetParametrUInt(domElement, AttrP2Line1, NULL_ID_STR);
|
|
|
|
|
initData.p1Line2Id = GetParametrUInt(domElement, AttrP1Line2, NULL_ID_STR);
|
|
|
|
|
initData.p2Line2Id = GetParametrUInt(domElement, AttrP2Line2, NULL_ID_STR);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolLineIntersect::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
2016-10-25 18:12:06 +02:00
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of line intersection"), domElement);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolPointOfContact(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolPointOfContactInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
|
|
|
|
|
PointsCommonAttributes(domElement, initData);
|
|
|
|
|
initData.radius = GetParametrString(domElement, AttrRadius, "0");
|
|
|
|
|
const QString f = initData.radius;//need for saving fixed formula;
|
|
|
|
|
initData.center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
|
|
|
|
|
initData.firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
|
|
|
|
|
initData.secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
|
|
|
|
|
|
|
|
|
|
VToolPointOfContact::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (f != initData.radius)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrRadius, initData.radius);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-06-25 12:52:09 +02:00
|
|
|
|
void VPattern::ParseNodePoint(const QDomElement &domElement, const Document &parse)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VAbstractNodeInitData initData;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
initData.scene = sceneDetail;
|
|
|
|
|
|
2015-10-12 13:52:48 +02:00
|
|
|
|
qreal mx = 0;
|
|
|
|
|
qreal my = 0;
|
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsCommonAttributes(domElement, initData.id, mx, my);
|
|
|
|
|
initData.idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
|
|
|
|
|
initData.idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
QSharedPointer<VPointF> point;
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
point = initData.data->GeometricObject<VPointF>(initData.idObject);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{ // Possible case. Parent was deleted, but the node object is still here.
|
2016-12-20 20:19:21 +01:00
|
|
|
|
Q_UNUSED(e)
|
2016-04-03 18:52:53 +02:00
|
|
|
|
return;// Just ignore
|
|
|
|
|
}
|
2017-10-27 10:53:35 +02:00
|
|
|
|
|
2018-01-16 18:32:38 +01:00
|
|
|
|
QSharedPointer<VPointF> p(new VPointF(*point));
|
|
|
|
|
p->setIdObject(initData.idObject);
|
|
|
|
|
p->setMode(Draw::Modeling);
|
2017-10-27 10:53:35 +02:00
|
|
|
|
p->SetShowLabel(GetParametrBool(domElement, AttrShowLabel, trueStr));
|
|
|
|
|
|
|
|
|
|
initData.data->UpdateGObject(initData.id, p);
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VNodePoint::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating modeling point"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-31 15:04:51 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParsePinPoint(const QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolPinInitData initData;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2017-01-31 15:04:51 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.pointId = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
|
|
|
|
|
initData.idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
|
|
|
|
|
VToolPin::Create(initData);
|
2017-01-31 15:04:51 +01:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating pin point"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-15 11:25:20 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParsePlaceLabel(QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
VToolPlaceLabelInitData initData;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
|
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.centerPoint = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
|
|
|
|
|
initData.idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
|
|
|
|
|
|
2017-10-23 09:45:58 +02:00
|
|
|
|
initData.width = GetParametrString(domElement, AttrWidth, "1.0");
|
2017-10-15 11:25:20 +02:00
|
|
|
|
const QString w = initData.width;//need for saving fixed formula;
|
|
|
|
|
|
|
|
|
|
initData.height = GetParametrString(domElement, AttrHeight, "1.0");
|
|
|
|
|
const QString h = initData.height;//need for saving fixed formula;
|
|
|
|
|
|
|
|
|
|
initData.angle = GetParametrString(domElement, AttrAngle, "0.0");
|
|
|
|
|
const QString angle = initData.angle;//need for saving fixed formula;
|
|
|
|
|
|
|
|
|
|
initData.type = static_cast<PlaceLabelType>(GetParametrUInt(domElement, AttrPlaceLabelType, "0"));
|
|
|
|
|
|
|
|
|
|
VToolPlaceLabel::Create(initData);
|
|
|
|
|
|
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
|
|
|
|
if (w != initData.width || h != initData.height || angle != initData.angle)
|
|
|
|
|
{
|
|
|
|
|
SetAttribute(domElement, AttrWidth, initData.width);
|
|
|
|
|
SetAttribute(domElement, AttrHeight, initData.height);
|
|
|
|
|
SetAttribute(domElement, AttrAngle, initData.angle);
|
|
|
|
|
modified = true;
|
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating place lavel"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating place lavel"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolHeight(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolHeightInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsWithLineCommonAttributes(domElement, initData);
|
|
|
|
|
initData.basePointId = GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR);
|
|
|
|
|
initData.p1LineId = GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
|
|
|
|
|
initData.p2LineId = GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolHeight::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating height"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolTriangle(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolTriangleInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsCommonAttributes(domElement, initData);
|
|
|
|
|
initData.axisP1Id = GetParametrUInt(domElement, AttrAxisP1, NULL_ID_STR);
|
|
|
|
|
initData.axisP2Id = GetParametrUInt(domElement, AttrAxisP2, NULL_ID_STR);
|
|
|
|
|
initData.firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
|
|
|
|
|
initData.secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolTriangle::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating triangle"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolPointOfIntersection(VMainGraphicsScene *scene, const QDomElement &domElement,
|
|
|
|
|
const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolPointOfIntersectionInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsCommonAttributes(domElement, initData);
|
|
|
|
|
initData.firstPointId = GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
|
|
|
|
|
initData.secondPointId = GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolPointOfIntersection::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of intersection"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolCutSplineInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsCommonAttributes(domElement, initData);
|
|
|
|
|
initData.formula = GetParametrString(domElement, AttrLength, "0");
|
|
|
|
|
const QString f = initData.formula;//need for saving fixed formula;
|
|
|
|
|
initData.splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolCutSpline::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (f != initData.formula)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrLength, initData.formula);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolCutSplinePathInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsCommonAttributes(domElement, initData);
|
|
|
|
|
initData.formula = GetParametrString(domElement, AttrLength, "0");
|
|
|
|
|
const QString f = initData.formula;//need for saving fixed formula;
|
|
|
|
|
initData.splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, NULL_ID_STR);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolCutSplinePath::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (f != initData.formula)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrLength, initData.formula);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolCutArcInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsCommonAttributes(domElement, initData);
|
|
|
|
|
initData.formula = GetParametrString(domElement, AttrLength, "0");
|
|
|
|
|
const QString f = initData.formula;//need for saving fixed formula;
|
|
|
|
|
initData.arcId = GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolCutArc::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (f != initData.formula)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrLength, initData.formula);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating cut arc point"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating cut arc point"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolLineIntersectAxis(VMainGraphicsScene *scene, QDomElement &domElement,
|
|
|
|
|
const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolLineIntersectAxisInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsWithLineCommonAttributes(domElement, initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.basePointId = GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR);
|
|
|
|
|
initData.firstPointId = GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
|
|
|
|
|
initData.secondPointId = GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.formulaAngle = GetParametrString(domElement, AttrAngle, "0.0");
|
|
|
|
|
const QString angleFix = initData.formulaAngle;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolLineIntersectAxis::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (angleFix != initData.formulaAngle)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrAngle, initData.formulaAngle);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of intersection line and axis"),
|
|
|
|
|
domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of intersection line and axis"),
|
|
|
|
|
domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolCurveIntersectAxis(VMainGraphicsScene *scene, QDomElement &domElement,
|
|
|
|
|
const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolCurveIntersectAxisInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsWithLineCommonAttributes(domElement, initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.basePointId = GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR);
|
|
|
|
|
initData.curveId = GetParametrUInt(domElement, AttrCurve, NULL_ID_STR);
|
|
|
|
|
initData.formulaAngle = GetParametrString(domElement, AttrAngle, "0.0");
|
|
|
|
|
const QString angleFix = initData.formulaAngle;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolCurveIntersectAxis::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (angleFix != initData.formulaAngle)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrAngle, initData.formulaAngle);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of intersection curve and axis"),
|
|
|
|
|
domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of intersection curve and axis"),
|
|
|
|
|
domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolPointOfIntersectionArcs(VMainGraphicsScene *scene, const QDomElement &domElement,
|
|
|
|
|
const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolPointOfIntersectionArcsInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsCommonAttributes(domElement, initData);
|
|
|
|
|
initData.firstArcId = GetParametrUInt(domElement, AttrFirstArc, NULL_ID_STR);
|
|
|
|
|
initData.secondArcId = GetParametrUInt(domElement, AttrSecondArc, NULL_ID_STR);
|
|
|
|
|
initData.pType = static_cast<CrossCirclesPoint>(GetParametrUInt(domElement, AttrCrossPoint, "1"));
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolPointOfIntersectionArcs::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of intersection arcs"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolPointOfIntersectionCircles(VMainGraphicsScene *scene, QDomElement &domElement,
|
|
|
|
|
const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolPointOfIntersectionCirclesInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
|
|
|
|
|
PointsCommonAttributes(domElement, initData);
|
|
|
|
|
initData.firstCircleCenterId = GetParametrUInt(domElement, AttrC1Center, NULL_ID_STR);
|
|
|
|
|
initData.secondCircleCenterId = GetParametrUInt(domElement, AttrC2Center, NULL_ID_STR);
|
|
|
|
|
initData.firstCircleRadius = GetParametrString(domElement, AttrC1Radius);
|
|
|
|
|
const QString c1R = initData.firstCircleRadius;
|
|
|
|
|
initData.secondCircleRadius = GetParametrString(domElement, AttrC2Radius);
|
|
|
|
|
const QString c2R = initData.secondCircleRadius;
|
|
|
|
|
initData.crossPoint = static_cast<CrossCirclesPoint>(GetParametrUInt(domElement, AttrCrossPoint, "1"));
|
|
|
|
|
|
|
|
|
|
VToolPointOfIntersectionCircles::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (c1R != initData.firstCircleRadius || c2R != initData.secondCircleRadius)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrC1Center, initData.firstCircleRadius);
|
|
|
|
|
SetAttribute(domElement, AttrC2Center, initData.secondCircleRadius);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of intersection circles"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-24 17:15:08 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolPointOfIntersectionCurves(VMainGraphicsScene *scene, QDomElement &domElement,
|
|
|
|
|
const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2016-01-24 17:15:08 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolPointOfIntersectionCurvesInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2016-01-24 17:15:08 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsCommonAttributes(domElement, initData);
|
|
|
|
|
initData.firstCurveId = GetParametrUInt(domElement, AttrCurve1, NULL_ID_STR);
|
|
|
|
|
initData.secondCurveId = GetParametrUInt(domElement, AttrCurve2, NULL_ID_STR);
|
|
|
|
|
initData.vCrossPoint = static_cast<VCrossCurvesPoint>(GetParametrUInt(domElement, AttrVCrossPoint, "1"));
|
|
|
|
|
initData.hCrossPoint = static_cast<HCrossCurvesPoint>(GetParametrUInt(domElement, AttrHCrossPoint, "1"));
|
2016-01-24 17:15:08 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolPointOfIntersectionCurves::Create(initData);
|
2016-01-24 17:15:08 +01:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of intersection curves"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolPointFromCircleAndTangent(VMainGraphicsScene *scene, QDomElement &domElement,
|
|
|
|
|
const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolPointFromCircleAndTangentInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
|
|
|
|
|
PointsCommonAttributes(domElement, initData);
|
|
|
|
|
initData.circleCenterId = GetParametrUInt(domElement, AttrCCenter, NULL_ID_STR);
|
|
|
|
|
initData.tangentPointId = GetParametrUInt(domElement, AttrTangent, NULL_ID_STR);
|
|
|
|
|
initData.circleRadius = GetParametrString(domElement, AttrCRadius);
|
|
|
|
|
const QString cR = initData.circleRadius;
|
|
|
|
|
initData.crossPoint = static_cast<CrossCirclesPoint>(GetParametrUInt(domElement, AttrCrossPoint, "1"));
|
|
|
|
|
|
|
|
|
|
VToolPointFromCircleAndTangent::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (cR != initData.circleRadius)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrCCenter, initData.circleRadius);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point from circle and tangent"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolPointFromArcAndTangent(VMainGraphicsScene *scene, const QDomElement &domElement,
|
|
|
|
|
const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolPointFromArcAndTangentInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
PointsCommonAttributes(domElement, initData);
|
|
|
|
|
initData.arcId = GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
|
|
|
|
|
initData.tangentPointId = GetParametrUInt(domElement, AttrTangent, NULL_ID_STR);
|
|
|
|
|
initData.crossPoint = static_cast<CrossCirclesPoint>(GetParametrUInt(domElement, AttrCrossPoint, "1"));
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolPointFromArcAndTangent::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point from arc and tangent"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolTrueDarts(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolTrueDartsInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.p1id = GetParametrUInt(domElement, AttrPoint1, NULL_ID_STR);
|
|
|
|
|
initData.p2id = GetParametrUInt(domElement, AttrPoint2, NULL_ID_STR);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.baseLineP1Id = GetParametrUInt(domElement, AttrBaseLineP1, NULL_ID_STR);
|
|
|
|
|
initData.baseLineP2Id = GetParametrUInt(domElement, AttrBaseLineP2, NULL_ID_STR);
|
|
|
|
|
initData.dartP1Id = GetParametrUInt(domElement, AttrDartP1, NULL_ID_STR);
|
|
|
|
|
initData.dartP2Id = GetParametrUInt(domElement, AttrDartP2, NULL_ID_STR);
|
|
|
|
|
initData.dartP3Id = GetParametrUInt(domElement, AttrDartP3, NULL_ID_STR);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.name1 = GetParametrString(domElement, AttrName1, "A");
|
|
|
|
|
initData.mx1 = qApp->toPixel(GetParametrDouble(domElement, AttrMx1, "10.0"));
|
|
|
|
|
initData.my1 = qApp->toPixel(GetParametrDouble(domElement, AttrMy1, "15.0"));
|
2017-09-20 09:19:02 +02:00
|
|
|
|
initData.showLabel1 = GetParametrBool(domElement, AttrShowLabel1, trueStr);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.name2 = GetParametrString(domElement, AttrName2, "A");
|
|
|
|
|
initData.mx2 = qApp->toPixel(GetParametrDouble(domElement, AttrMx2, "10.0"));
|
|
|
|
|
initData.my2 = qApp->toPixel(GetParametrDouble(domElement, AttrMy2, "15.0"));
|
2017-09-20 09:19:02 +02:00
|
|
|
|
initData.showLabel2 = GetParametrBool(domElement, AttrShowLabel2, trueStr);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolTrueDarts::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating true darts"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-02-26 15:38:42 +01:00
|
|
|
|
// TODO. Delete if minimal supported version is 0.2.7
|
|
|
|
|
void VPattern::ParseOldToolSpline(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolSplineInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
2015-08-11 15:41:03 +02:00
|
|
|
|
const quint32 point1 = GetParametrUInt(domElement, AttrPoint1, NULL_ID_STR);
|
|
|
|
|
const quint32 point4 = GetParametrUInt(domElement, AttrPoint4, NULL_ID_STR);
|
|
|
|
|
const qreal angle1 = GetParametrDouble(domElement, AttrAngle1, "270.0");
|
|
|
|
|
const qreal angle2 = GetParametrDouble(domElement, AttrAngle2, "90.0");
|
|
|
|
|
const qreal kAsm1 = GetParametrDouble(domElement, AttrKAsm1, "1.0");
|
|
|
|
|
const qreal kAsm2 = GetParametrDouble(domElement, AttrKAsm2, "1.0");
|
|
|
|
|
const qreal kCurve = GetParametrDouble(domElement, AttrKCurve, "1.0");
|
|
|
|
|
const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
|
2016-02-15 15:30:48 +01:00
|
|
|
|
const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
2016-02-15 10:02:55 +01:00
|
|
|
|
const auto p1 = data->GeometricObject<VPointF>(point1);
|
|
|
|
|
const auto p4 = data->GeometricObject<VPointF>(point4);
|
|
|
|
|
|
2016-02-26 15:38:42 +01:00
|
|
|
|
auto spline = new VSpline(*p1, *p4, angle1, angle2, kAsm1, kAsm2, kCurve);
|
2016-02-15 15:30:48 +01:00
|
|
|
|
if (duplicate > 0)
|
|
|
|
|
{
|
2016-02-26 15:38:42 +01:00
|
|
|
|
spline->SetDuplicate(duplicate);
|
2016-02-15 15:30:48 +01:00
|
|
|
|
}
|
2017-05-16 12:07:53 +02:00
|
|
|
|
spline->SetColor(color);
|
2016-02-15 10:02:55 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolSpline::Create(initData, spline);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating simple curve"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-26 15:38:42 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2016-02-26 15:38:42 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolSplineInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2016-02-26 15:38:42 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.point1 = GetParametrUInt(domElement, AttrPoint1, NULL_ID_STR);
|
|
|
|
|
initData.point4 = GetParametrUInt(domElement, AttrPoint4, NULL_ID_STR);
|
2016-02-26 15:38:42 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.a1 = GetParametrString(domElement, AttrAngle1, "0");
|
|
|
|
|
const QString angle1 = initData.a1;//need for saving fixed formula;
|
2016-02-26 15:38:42 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.a2 = GetParametrString(domElement, AttrAngle2, "0");
|
|
|
|
|
const QString angle2 = initData.a2;//need for saving fixed formula;
|
2016-02-26 15:38:42 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.l1 = GetParametrString(domElement, AttrLength1, "0");
|
|
|
|
|
const QString length1 = initData.l1;//need for saving fixed formula;
|
2016-02-26 15:38:42 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.l2 = GetParametrString(domElement, AttrLength2, "0");
|
|
|
|
|
const QString length2 = initData.l2;//need for saving fixed formula;
|
2016-02-26 15:38:42 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.color = GetParametrString(domElement, AttrColor, ColorBlack);
|
|
|
|
|
initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
|
|
|
|
|
initData.duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
|
2017-10-11 12:51:06 +02:00
|
|
|
|
initData.approximationScale = GetParametrDouble(domElement, AttrAScale, "0");
|
2016-02-26 15:38:42 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolSpline *spl = VToolSpline::Create(initData);
|
2016-07-13 21:50:55 +02:00
|
|
|
|
|
|
|
|
|
if (spl != nullptr)
|
|
|
|
|
{
|
2016-07-26 12:45:17 +02:00
|
|
|
|
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(window != nullptr)
|
2016-07-26 12:45:17 +02:00
|
|
|
|
connect(spl, &VToolSpline::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
|
2016-07-13 21:50:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-26 15:38:42 +01:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (angle1 != initData.a1 || angle2 != initData.a2 || length1 != initData.l1 || length2 != initData.l2)
|
2016-02-26 15:38:42 +01:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrAngle1, initData.a1);
|
|
|
|
|
SetAttribute(domElement, AttrAngle2, initData.a2);
|
|
|
|
|
SetAttribute(domElement, AttrLength1, initData.l1);
|
|
|
|
|
SetAttribute(domElement, AttrLength2, initData.l2);
|
2016-02-26 15:38:42 +01:00
|
|
|
|
modified = true;
|
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating simple curve"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating simple interactive spline"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-10 14:55:04 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolCubicBezier(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2016-03-10 14:55:04 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolCubicBezierInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
|
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
2016-03-10 14:55:04 +01:00
|
|
|
|
|
|
|
|
|
const quint32 point1 = GetParametrUInt(domElement, AttrPoint1, NULL_ID_STR);
|
|
|
|
|
const quint32 point2 = GetParametrUInt(domElement, AttrPoint2, NULL_ID_STR);
|
|
|
|
|
const quint32 point3 = GetParametrUInt(domElement, AttrPoint3, NULL_ID_STR);
|
|
|
|
|
const quint32 point4 = GetParametrUInt(domElement, AttrPoint4, NULL_ID_STR);
|
|
|
|
|
|
|
|
|
|
const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
|
2017-05-16 12:07:53 +02:00
|
|
|
|
const QString penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
|
2016-03-10 14:55:04 +01:00
|
|
|
|
const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
|
2017-10-11 12:51:06 +02:00
|
|
|
|
const qreal approximationScale = GetParametrDouble(domElement, AttrAScale, "0");
|
2016-03-10 14:55:04 +01:00
|
|
|
|
|
|
|
|
|
auto p1 = data->GeometricObject<VPointF>(point1);
|
|
|
|
|
auto p2 = data->GeometricObject<VPointF>(point2);
|
|
|
|
|
auto p3 = data->GeometricObject<VPointF>(point3);
|
|
|
|
|
auto p4 = data->GeometricObject<VPointF>(point4);
|
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.spline = new VCubicBezier(*p1, *p2, *p3, *p4);
|
2016-03-10 14:55:04 +01:00
|
|
|
|
if (duplicate > 0)
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.spline->SetDuplicate(duplicate);
|
2016-03-10 14:55:04 +01:00
|
|
|
|
}
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.spline->SetColor(color);
|
|
|
|
|
initData.spline->SetPenStyle(penStyle);
|
2017-10-11 12:51:06 +02:00
|
|
|
|
initData.spline->SetPenStyle(penStyle);
|
|
|
|
|
initData.spline->SetApproximationScale(approximationScale);
|
2016-03-10 14:55:04 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolCubicBezier::Create(initData);
|
2016-03-10 14:55:04 +01:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating cubic bezier curve"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-03-04 17:08:29 +01:00
|
|
|
|
void VPattern::ParseOldToolSplinePath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolSplinePathInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
2015-08-11 15:41:03 +02:00
|
|
|
|
const qreal kCurve = GetParametrDouble(domElement, AttrKCurve, "1.0");
|
|
|
|
|
const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
|
2016-02-16 14:37:01 +01:00
|
|
|
|
const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
|
2017-10-11 12:51:06 +02:00
|
|
|
|
const qreal approximationScale = GetParametrDouble(domElement, AttrAScale, "0");
|
2016-02-16 14:37:01 +01:00
|
|
|
|
|
2016-03-04 17:08:29 +01:00
|
|
|
|
QVector<VFSplinePoint> points;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
const QDomNodeList nodeList = domElement.childNodes();
|
|
|
|
|
const qint32 num = nodeList.size();
|
|
|
|
|
for (qint32 i = 0; i < num; ++i)
|
|
|
|
|
{
|
|
|
|
|
const QDomElement element = nodeList.at(i).toElement();
|
|
|
|
|
if (element.isNull() == false)
|
2014-05-21 12:12:52 +02:00
|
|
|
|
{
|
2015-08-11 15:41:03 +02:00
|
|
|
|
if (element.tagName() == AttrPathPoint)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2015-08-11 15:41:03 +02:00
|
|
|
|
const qreal kAsm1 = GetParametrDouble(element, AttrKAsm1, "1.0");
|
|
|
|
|
const qreal angle = GetParametrDouble(element, AttrAngle, "0");
|
|
|
|
|
const qreal kAsm2 = GetParametrDouble(element, AttrKAsm2, "1.0");
|
|
|
|
|
const quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
const VPointF p = *data->GeometricObject<VPointF>(pSpline);
|
|
|
|
|
|
|
|
|
|
QLineF line(0, 0, 100, 0);
|
|
|
|
|
line.setAngle(angle+180);
|
|
|
|
|
|
2016-03-04 17:08:29 +01:00
|
|
|
|
VFSplinePoint splPoint(p, kAsm1, line.angle(), kAsm2, angle);
|
|
|
|
|
points.append(splPoint);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
if (parse == Document::FullParse)
|
|
|
|
|
{
|
2016-02-02 14:38:30 +01:00
|
|
|
|
IncrementReferens(p.getIdTool());
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-21 12:12:52 +02:00
|
|
|
|
}
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-04 17:08:29 +01:00
|
|
|
|
auto path = new VSplinePath(points, kCurve);
|
|
|
|
|
if (duplicate > 0)
|
|
|
|
|
{
|
|
|
|
|
path->SetDuplicate(duplicate);
|
|
|
|
|
}
|
2017-05-16 12:07:53 +02:00
|
|
|
|
path->SetColor(color);
|
2017-10-11 12:51:06 +02:00
|
|
|
|
path->SetApproximationScale(approximationScale);
|
2016-03-04 17:08:29 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolSplinePath::Create(initData, path);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating curve path"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-04 17:08:29 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2016-03-04 17:08:29 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolSplinePathInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2016-03-04 17:08:29 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.color = GetParametrString(domElement, AttrColor, ColorBlack);
|
|
|
|
|
initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
|
|
|
|
|
initData.duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
|
2017-10-11 12:51:06 +02:00
|
|
|
|
initData.approximationScale = GetParametrDouble(domElement, AttrAScale, "0");
|
2016-03-04 17:08:29 +01:00
|
|
|
|
|
|
|
|
|
const QDomNodeList nodeList = domElement.childNodes();
|
|
|
|
|
const qint32 num = nodeList.size();
|
|
|
|
|
for (qint32 i = 0; i < num; ++i)
|
|
|
|
|
{
|
|
|
|
|
const QDomElement element = nodeList.at(i).toElement();
|
|
|
|
|
if (not element.isNull() && element.tagName() == AttrPathPoint)
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.a1.append(GetParametrString(element, AttrAngle1, "0"));
|
|
|
|
|
initData.a2.append(GetParametrString(element, AttrAngle2, "0"));
|
|
|
|
|
initData.l1.append(GetParametrString(element, AttrLength1, "0"));
|
|
|
|
|
initData.l2.append(GetParametrString(element, AttrLength2, "0"));
|
2016-03-04 17:08:29 +01:00
|
|
|
|
const quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR);
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.points.append(pSpline);
|
2016-03-04 17:08:29 +01:00
|
|
|
|
|
|
|
|
|
if (parse == Document::FullParse)
|
|
|
|
|
{
|
|
|
|
|
IncrementReferens(data->GeometricObject<VPointF>(pSpline)->getIdTool());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//need for saving fixed formula;
|
2017-09-18 10:37:23 +02:00
|
|
|
|
const QVector<QString> angle1 = initData.a1;
|
|
|
|
|
const QVector<QString> angle2 = initData.a2;
|
|
|
|
|
const QVector<QString> length1 = initData.l1;
|
|
|
|
|
const QVector<QString> length2 = initData.l2;
|
2016-03-04 17:08:29 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolSplinePath *spl = VToolSplinePath::Create(initData);
|
2016-07-13 21:50:55 +02:00
|
|
|
|
|
|
|
|
|
if (spl != nullptr)
|
|
|
|
|
{
|
2016-07-26 12:45:17 +02:00
|
|
|
|
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(window != nullptr)
|
2016-07-26 12:45:17 +02:00
|
|
|
|
connect(spl, &VToolSplinePath::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
|
2016-07-13 21:50:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-04 17:08:29 +01:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
|
|
|
|
int count = 0;
|
|
|
|
|
for (qint32 i = 0; i < num; ++i)
|
|
|
|
|
{
|
|
|
|
|
QDomElement element = nodeList.at(i).toElement();
|
|
|
|
|
if (not element.isNull() && element.tagName() == AttrPathPoint)
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (angle1.at(count) != initData.a1.at(count) || angle2.at(count) != initData.a2.at(count) ||
|
|
|
|
|
length1.at(count) != initData.l1.at(count) || length2.at(count) != initData.l2.at(count))
|
2016-03-04 17:08:29 +01:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(element, AttrAngle1, initData.a1.at(count));
|
|
|
|
|
SetAttribute(element, AttrAngle2, initData.a2.at(count));
|
|
|
|
|
SetAttribute(element, AttrLength1, initData.l1.at(count));
|
|
|
|
|
SetAttribute(element, AttrLength2, initData.l2.at(count));
|
2016-03-04 17:08:29 +01:00
|
|
|
|
modified = true;
|
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
++count;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating curve path"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating interactive spline path"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 22:11:14 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolCubicBezierPath(VMainGraphicsScene *scene, const QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2016-03-18 22:11:14 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolCubicBezierPathInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2016-03-18 22:11:14 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
2016-03-18 22:11:14 +01:00
|
|
|
|
const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
|
2017-05-16 12:07:53 +02:00
|
|
|
|
const QString penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
|
2016-03-18 22:11:14 +01:00
|
|
|
|
const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
|
2017-10-11 12:51:06 +02:00
|
|
|
|
const qreal approximationScale = GetParametrDouble(domElement, AttrAScale, "0");
|
2016-03-18 22:11:14 +01:00
|
|
|
|
|
|
|
|
|
QVector<VPointF> points;
|
|
|
|
|
|
|
|
|
|
const QDomNodeList nodeList = domElement.childNodes();
|
|
|
|
|
const qint32 num = nodeList.size();
|
|
|
|
|
for (qint32 i = 0; i < num; ++i)
|
|
|
|
|
{
|
|
|
|
|
const QDomElement element = nodeList.at(i).toElement();
|
|
|
|
|
if (element.isNull() == false)
|
|
|
|
|
{
|
|
|
|
|
if (element.tagName() == AttrPathPoint)
|
|
|
|
|
{
|
|
|
|
|
const quint32 pSpline = GetParametrUInt(element, AttrPSpline, NULL_ID_STR);
|
|
|
|
|
const VPointF p = *data->GeometricObject<VPointF>(pSpline);
|
|
|
|
|
points.append(p);
|
|
|
|
|
if (parse == Document::FullParse)
|
|
|
|
|
{
|
|
|
|
|
IncrementReferens(p.getIdTool());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.path = new VCubicBezierPath(points);
|
2016-03-18 22:11:14 +01:00
|
|
|
|
if (duplicate > 0)
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.path->SetDuplicate(duplicate);
|
2016-03-18 22:11:14 +01:00
|
|
|
|
}
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.path->SetColor(color);
|
|
|
|
|
initData.path->SetPenStyle(penStyle);
|
2017-10-11 12:51:06 +02:00
|
|
|
|
initData.path->SetApproximationScale(approximationScale);
|
2016-03-18 22:11:14 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolCubicBezierPath::Create(initData);
|
2016-03-18 22:11:14 +01:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating cubic bezier path curve"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-06-25 12:52:09 +02:00
|
|
|
|
void VPattern::ParseNodeSpline(const QDomElement &domElement, const Document &parse)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VAbstractNodeInitData initData;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SplinesCommonAttributes(domElement, initData.id, initData.idObject, initData.idTool);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
try
|
2016-03-10 18:08:37 +01:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
const auto obj = initData.data->GetGObject(initData.idObject);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
if (obj->getType() == GOType::Spline)
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VSpline *spl = new VSpline(*data->GeometricObject<VSpline>(initData.idObject));
|
|
|
|
|
spl->setIdObject(initData.idObject);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
spl->setMode(Draw::Modeling);
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.data->UpdateGObject(initData.id, spl);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VCubicBezier *spl = new VCubicBezier(*initData.data->GeometricObject<VCubicBezier>(initData.idObject));
|
|
|
|
|
spl->setIdObject(initData.idObject);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
spl->setMode(Draw::Modeling);
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.data->UpdateGObject(initData.id, spl);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
}
|
2016-03-10 18:08:37 +01:00
|
|
|
|
}
|
2016-04-03 18:52:53 +02:00
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{ // Possible case. Parent was deleted, but the node object is still here.
|
2016-12-20 20:19:21 +01:00
|
|
|
|
Q_UNUSED(e)
|
2016-04-03 18:52:53 +02:00
|
|
|
|
return;// Just ignore
|
2016-03-10 18:08:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VNodeSpline::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating modeling simple curve"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-06-25 12:52:09 +02:00
|
|
|
|
void VPattern::ParseNodeSplinePath(const QDomElement &domElement, const Document &parse)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VAbstractNodeInitData initData;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SplinesCommonAttributes(domElement, initData.id, initData.idObject, initData.idTool);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
try
|
2016-03-22 16:33:05 +01:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
const auto obj = initData.data->GetGObject(initData.idObject);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
if (obj->getType() == GOType::SplinePath)
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VSplinePath *path = new VSplinePath(*initData.data->GeometricObject<VSplinePath>(initData.idObject));
|
|
|
|
|
path->setIdObject(initData.idObject);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
path->setMode(Draw::Modeling);
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.data->UpdateGObject(initData.id, path);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VCubicBezierPath *spl =
|
|
|
|
|
new VCubicBezierPath(*initData.data->GeometricObject<VCubicBezierPath>(initData.idObject));
|
|
|
|
|
spl->setIdObject(initData.idObject);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
spl->setMode(Draw::Modeling);
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.data->UpdateGObject(initData.id, spl);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
}
|
2016-03-22 16:33:05 +01:00
|
|
|
|
}
|
2016-04-03 18:52:53 +02:00
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{ // Possible case. Parent was deleted, but the node object is still here.
|
2016-12-20 20:19:21 +01:00
|
|
|
|
Q_UNUSED(e)
|
2016-04-03 18:52:53 +02:00
|
|
|
|
return;// Just ignore
|
2016-03-22 16:33:05 +01:00
|
|
|
|
}
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VNodeSplinePath::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating modeling curve path"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolArcInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
|
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
|
|
|
|
|
initData.radius = GetParametrString(domElement, AttrRadius, "10");
|
|
|
|
|
const QString r = initData.radius;//need for saving fixed formula;
|
|
|
|
|
initData.f1 = GetParametrString(domElement, AttrAngle1, "180");
|
|
|
|
|
const QString f1Fix = initData.f1;//need for saving fixed formula;
|
|
|
|
|
initData.f2 = GetParametrString(domElement, AttrAngle2, "270");
|
|
|
|
|
const QString f2Fix = initData.f2;//need for saving fixed formula;
|
|
|
|
|
initData.color = GetParametrString(domElement, AttrColor, ColorBlack);
|
|
|
|
|
initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
|
2017-10-11 12:51:06 +02:00
|
|
|
|
initData.approximationScale = GetParametrDouble(domElement, AttrAScale, "0");
|
2017-09-18 10:37:23 +02:00
|
|
|
|
|
|
|
|
|
VToolArc::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (r != initData.radius || f1Fix != initData.f1 || f2Fix != initData.f2)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrRadius, initData.radius);
|
|
|
|
|
SetAttribute(domElement, AttrAngle1, initData.f1);
|
|
|
|
|
SetAttribute(domElement, AttrAngle2, initData.f2);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-17 02:53:47 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolEllipticalArc(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2016-12-17 02:53:47 +01:00
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolEllipticalArcInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
|
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
|
|
|
|
|
initData.radius1 = GetParametrString(domElement, AttrRadius1, "10");
|
|
|
|
|
initData.radius2 = GetParametrString(domElement, AttrRadius2, "10");
|
|
|
|
|
const QString r1 = initData.radius1;//need for saving fixed formula;
|
|
|
|
|
const QString r2 = initData.radius2;//need for saving fixed formula;
|
|
|
|
|
initData.f1 = GetParametrString(domElement, AttrAngle1, "180");
|
|
|
|
|
const QString f1Fix = initData.f1;//need for saving fixed formula;
|
|
|
|
|
initData.f2 = GetParametrString(domElement, AttrAngle2, "270");
|
|
|
|
|
const QString f2Fix = initData.f2;//need for saving fixed formula;
|
|
|
|
|
initData.rotationAngle = GetParametrString(domElement, AttrRotationAngle, "0");
|
|
|
|
|
const QString frotationFix = initData.rotationAngle;//need for saving fixed formula;
|
|
|
|
|
initData.color = GetParametrString(domElement, AttrColor, ColorBlack);
|
|
|
|
|
initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
|
2017-11-18 12:48:03 +01:00
|
|
|
|
initData.approximationScale = GetParametrDouble(domElement, AttrAScale, "0");
|
2017-09-18 10:37:23 +02:00
|
|
|
|
|
|
|
|
|
VToolEllipticalArc::Create(initData);
|
2016-12-17 02:53:47 +01:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (r1 != initData.radius1 || r2 != initData.radius2 || f1Fix != initData.f1 || f2Fix != initData.f2
|
|
|
|
|
|| frotationFix != initData.rotationAngle)
|
|
|
|
|
{
|
|
|
|
|
SetAttribute(domElement, AttrRadius1, initData.radius1);
|
|
|
|
|
SetAttribute(domElement, AttrRadius2, initData.radius2);
|
|
|
|
|
SetAttribute(domElement, AttrAngle1, initData.f1);
|
|
|
|
|
SetAttribute(domElement, AttrAngle2, initData.f2);
|
|
|
|
|
SetAttribute(domElement, AttrRotationAngle, initData.rotationAngle);
|
2016-12-17 02:53:47 +01:00
|
|
|
|
modified = true;
|
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating simple elliptical arc"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating simple elliptical arc"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-20 15:51:58 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseNodeEllipticalArc(const QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VAbstractNodeInitData initData;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2016-12-20 15:51:58 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
|
|
|
|
|
initData.idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
|
2016-12-20 15:51:58 +01:00
|
|
|
|
VEllipticalArc *arc = nullptr;
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
arc = new VEllipticalArc(*initData.data->GeometricObject<VEllipticalArc>(initData.idObject));
|
2016-12-20 15:51:58 +01:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{ // Possible case. Parent was deleted, but the node object is still here.
|
2016-12-20 20:19:21 +01:00
|
|
|
|
Q_UNUSED(e)
|
2016-12-20 15:51:58 +01:00
|
|
|
|
return;// Just ignore
|
|
|
|
|
}
|
2017-09-18 10:37:23 +02:00
|
|
|
|
arc->setIdObject(initData.idObject);
|
2016-12-20 15:51:58 +01:00
|
|
|
|
arc->setMode(Draw::Modeling);
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.data->UpdateGObject(initData.id, arc);
|
|
|
|
|
VNodeEllipticalArc::Create(initData);
|
2016-12-20 15:51:58 +01:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating modeling elliptical arc"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-06-25 12:52:09 +02:00
|
|
|
|
void VPattern::ParseNodeArc(const QDomElement &domElement, const Document &parse)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VAbstractNodeInitData initData;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2015-10-12 13:52:48 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.idObject = GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
|
|
|
|
|
initData.idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
|
2016-04-03 18:52:53 +02:00
|
|
|
|
VArc *arc = nullptr;
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
arc = new VArc(*data->GeometricObject<VArc>(initData.idObject));
|
2016-04-03 18:52:53 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{ // Possible case. Parent was deleted, but the node object is still here.
|
2016-12-20 20:19:21 +01:00
|
|
|
|
Q_UNUSED(e)
|
2016-04-03 18:52:53 +02:00
|
|
|
|
return;// Just ignore
|
|
|
|
|
}
|
2017-09-18 10:37:23 +02:00
|
|
|
|
arc->setIdObject(initData.idObject);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
arc->setMode(Draw::Modeling);
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.data->UpdateGObject(initData.id, arc);
|
|
|
|
|
VNodeArc::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating modeling arc"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolArcWithLengthInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
|
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.center = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
|
|
|
|
|
initData.radius = GetParametrString(domElement, AttrRadius, "10");
|
|
|
|
|
const QString r = initData.radius;//need for saving fixed formula;
|
|
|
|
|
initData.f1 = GetParametrString(domElement, AttrAngle1, "180");
|
|
|
|
|
const QString f1Fix = initData.f1;//need for saving fixed formula;
|
|
|
|
|
initData.length = GetParametrString(domElement, AttrLength, "10");
|
|
|
|
|
const QString lengthFix = initData.length;//need for saving fixed length;
|
|
|
|
|
initData.color = GetParametrString(domElement, AttrColor, ColorBlack);
|
|
|
|
|
initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
|
|
|
|
|
|
|
|
|
|
VToolArcWithLength::Create(initData);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (r != initData.radius || f1Fix != initData.f1 || lengthFix != initData.length)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrRadius, initData.radius);
|
|
|
|
|
SetAttribute(domElement, AttrAngle1, initData.f1);
|
|
|
|
|
SetAttribute(domElement, AttrLength, initData.length);
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-16 19:27:51 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolRotation(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2016-05-16 19:27:51 +02:00
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolRotationInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2016-05-16 19:27:51 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.origin = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
|
|
|
|
|
initData.angle = GetParametrString(domElement, AttrAngle, "10");
|
|
|
|
|
const QString a = initData.angle;//need for saving fixed formula;
|
|
|
|
|
initData.suffix = GetParametrString(domElement, AttrSuffix, "");
|
2016-05-16 19:27:51 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VAbstractOperation::ExtractData(domElement, initData);
|
2016-05-16 19:27:51 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolRotation::Create(initData);
|
2016-05-16 19:27:51 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-09-18 10:37:23 +02:00
|
|
|
|
if (a != initData.angle)
|
2016-05-16 19:27:51 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrAngle, initData.angle);
|
2016-05-16 19:27:51 +02:00
|
|
|
|
modified = true;
|
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating operation of rotation"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating operation of rotation"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-13 10:27:44 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolFlippingByLine(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2016-09-13 10:27:44 +02:00
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolFlippingByLineInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2016-09-13 10:27:44 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.firstLinePointId = GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
|
|
|
|
|
initData.secondLinePointId = GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
|
|
|
|
|
initData.suffix = GetParametrString(domElement, AttrSuffix, "");
|
2016-09-13 10:27:44 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VAbstractOperation::ExtractData(domElement, initData);
|
2016-09-13 10:27:44 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolFlippingByLine::Create(initData);
|
2016-09-13 10:27:44 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating operation of flipping by line"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-17 11:10:03 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolFlippingByAxis(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2016-09-17 11:10:03 +02:00
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolFlippingByAxisInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2016-09-17 11:10:03 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.originPointId = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
|
|
|
|
|
initData.axisType = static_cast<AxisType>(GetParametrUInt(domElement, AttrAxisType, "1"));
|
|
|
|
|
initData.suffix = GetParametrString(domElement, AttrSuffix, "");
|
2016-09-17 11:10:03 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VAbstractOperation::ExtractData(domElement, initData);
|
2016-09-17 11:10:03 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolFlippingByAxis::Create(initData);
|
2016-09-17 11:10:03 +02:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating operation of flipping by axis"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-04 16:34:37 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseToolMove(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2016-10-04 16:34:37 +02:00
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolMoveInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2016-10-04 16:34:37 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.formulaAngle = GetParametrString(domElement, AttrAngle, "0");
|
|
|
|
|
const QString a = initData.formulaAngle;//need for saving fixed formula;
|
2017-11-13 18:39:11 +01:00
|
|
|
|
initData.formulaRotationAngle = GetParametrString(domElement, AttrRotationAngle, "0");
|
|
|
|
|
const QString r = initData.formulaRotationAngle;//need for saving fixed formula;
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.formulaLength = GetParametrString(domElement, AttrLength, "0");
|
|
|
|
|
const QString len = initData.formulaLength;//need for saving fixed formula;
|
|
|
|
|
initData.suffix = GetParametrString(domElement, AttrSuffix, "");
|
2017-11-17 11:28:57 +01:00
|
|
|
|
initData.rotationOrigin = GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
|
2016-10-04 16:34:37 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VAbstractOperation::ExtractData(domElement, initData);
|
2016-10-04 16:34:37 +02:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolMove::Create(initData);
|
2016-10-04 16:34:37 +02:00
|
|
|
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
2017-11-13 18:39:11 +01:00
|
|
|
|
if (a != initData.formulaAngle || r != initData.formulaRotationAngle || len != initData.formulaLength)
|
2016-10-04 16:34:37 +02:00
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrAngle, initData.formulaAngle);
|
2017-11-13 18:39:11 +01:00
|
|
|
|
SetAttribute(domElement, AttrRotationAngle, initData.formulaRotationAngle);
|
2017-09-18 10:37:23 +02:00
|
|
|
|
SetAttribute(domElement, AttrLength, initData.formulaLength);
|
2016-10-04 16:34:37 +02:00
|
|
|
|
modified = true;
|
|
|
|
|
haveLiteChange();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating operation of moving"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating operation of moving"), domElement);
|
|
|
|
|
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-25 12:35:50 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
qreal VPattern::EvalFormula(VContainer *data, const QString &formula, bool *ok) const
|
|
|
|
|
{
|
|
|
|
|
if (formula.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
*ok = true;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2016-05-24 14:25:58 +02:00
|
|
|
|
QScopedPointer<Calculator> cal(new Calculator());
|
2018-01-24 21:08:53 +01:00
|
|
|
|
const qreal result = cal->EvalFormula(data->DataVariables(), formula);
|
2015-08-25 12:35:50 +02:00
|
|
|
|
|
2016-05-24 14:06:35 +02:00
|
|
|
|
(qIsInf(result) || qIsNaN(result)) ? *ok = false : *ok = true;
|
2015-08-25 12:35:50 +02:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (qmu::QmuParserError &e)
|
|
|
|
|
{
|
2015-10-19 15:21:06 +02:00
|
|
|
|
Q_UNUSED(e)
|
2015-08-25 12:35:50 +02:00
|
|
|
|
*ok = false;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
QDomElement VPattern::MakeEmptyIncrement(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
QDomElement element = createElement(TagIncrement);
|
2017-09-26 11:54:52 +02:00
|
|
|
|
SetAttribute(element, AttrName, name);
|
|
|
|
|
SetAttribute(element, AttrFormula, QString("0"));
|
|
|
|
|
SetAttribute(element, AttrDescription, QString(""));
|
2015-08-25 12:35:50 +02:00
|
|
|
|
return element;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
QDomElement VPattern::FindIncrement(const QString &name) const
|
|
|
|
|
{
|
|
|
|
|
QDomNodeList list = elementsByTagName(TagIncrement);
|
|
|
|
|
|
|
|
|
|
for (int i=0; i < list.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
const QDomElement domElement = list.at(i).toElement();
|
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
|
{
|
2017-09-26 11:54:52 +02:00
|
|
|
|
const QString parameter = domElement.attribute(AttrName);
|
2015-08-25 12:35:50 +02:00
|
|
|
|
if (parameter == name)
|
|
|
|
|
{
|
|
|
|
|
return domElement;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QDomElement();
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-26 14:08:41 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::GarbageCollector()
|
|
|
|
|
{
|
|
|
|
|
QDomNodeList modelingList = elementsByTagName(TagModeling);
|
|
|
|
|
for (int i=0; i < modelingList.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
QDomElement modElement = modelingList.at(i).toElement();
|
|
|
|
|
if (not modElement.isNull())
|
|
|
|
|
{
|
|
|
|
|
QDomElement modNode = modElement.firstChild().toElement();
|
|
|
|
|
while (not modNode.isNull())
|
|
|
|
|
{
|
|
|
|
|
// First get next sibling because later will not have chance to get it
|
|
|
|
|
QDomElement nextSibling = modNode.nextSibling().toElement();
|
2017-09-13 10:52:41 +02:00
|
|
|
|
if (modNode.hasAttribute(VAbstractTool::AttrInUse))
|
2015-12-26 14:08:41 +01:00
|
|
|
|
{
|
2017-09-13 10:52:41 +02:00
|
|
|
|
const NodeUsage inUse = GetParametrUsage(modNode, VAbstractTool::AttrInUse);
|
2015-12-26 14:08:41 +01:00
|
|
|
|
if (inUse == NodeUsage::InUse)
|
|
|
|
|
{ // It is dangerous to leave object with attribute 'inUse'
|
|
|
|
|
// Each parse should confirm this status.
|
2017-09-13 10:52:41 +02:00
|
|
|
|
SetParametrUsage(modNode, VAbstractTool::AttrInUse, NodeUsage::NotInUse);
|
2015-12-26 14:08:41 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{ // Parent was deleted. We do not need this object anymore
|
|
|
|
|
modElement.removeChild(modNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2015-12-26 19:04:26 +01:00
|
|
|
|
{ // Each parse should confirm his status.
|
2017-09-13 10:52:41 +02:00
|
|
|
|
SetParametrUsage(modNode, VAbstractTool::AttrInUse, NodeUsage::NotInUse);
|
2015-12-26 14:08:41 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
modNode = nextSibling;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-02 13:47:44 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::NewEmptyIncrement(const QString &type, const QString &name)
|
|
|
|
|
{
|
|
|
|
|
const QDomElement element = MakeEmptyIncrement(name);
|
|
|
|
|
|
|
|
|
|
const QDomNodeList list = elementsByTagName(type);
|
|
|
|
|
list.at(0).appendChild(element);
|
|
|
|
|
emit patternChanged(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::NewEmptyIncrementAfter(const QString &type, const QString &after, const QString &name)
|
|
|
|
|
{
|
|
|
|
|
const QDomElement element = MakeEmptyIncrement(name);
|
|
|
|
|
const QDomElement sibling = FindIncrement(after);
|
|
|
|
|
|
|
|
|
|
const QDomNodeList list = elementsByTagName(type);
|
|
|
|
|
|
|
|
|
|
if (sibling.isNull())
|
|
|
|
|
{
|
|
|
|
|
list.at(0).appendChild(element);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
list.at(0).insertAfter(element, sibling);
|
|
|
|
|
}
|
|
|
|
|
emit patternChanged(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::RemoveIncrement(const QString &type, const QString &name)
|
|
|
|
|
{
|
|
|
|
|
const QDomNodeList list = elementsByTagName(type);
|
|
|
|
|
list.at(0).removeChild(FindIncrement(name));
|
|
|
|
|
emit patternChanged(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::MoveUpIncrement(const QString &type, const QString &name)
|
|
|
|
|
{
|
|
|
|
|
const QDomElement node = FindIncrement(name);
|
|
|
|
|
if (not node.isNull())
|
|
|
|
|
{
|
|
|
|
|
const QDomElement prSibling = node.previousSiblingElement(TagIncrement);
|
|
|
|
|
if (not prSibling.isNull())
|
|
|
|
|
{
|
2017-11-27 22:37:36 +01:00
|
|
|
|
elementsByTagName(type).at(0).insertBefore(node, prSibling);
|
2017-09-02 13:47:44 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
emit patternChanged(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::MoveDownIncrement(const QString &type, const QString &name)
|
|
|
|
|
{
|
|
|
|
|
const QDomElement node = FindIncrement(name);
|
|
|
|
|
if (not node.isNull())
|
|
|
|
|
{
|
|
|
|
|
const QDomElement nextSibling = node.nextSiblingElement(TagIncrement);
|
|
|
|
|
if (not nextSibling.isNull())
|
|
|
|
|
{
|
2017-11-27 22:37:36 +01:00
|
|
|
|
elementsByTagName(type).at(0).insertAfter(node, nextSibling);
|
2017-09-02 13:47:44 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
emit patternChanged(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-09-02 14:37:52 +02:00
|
|
|
|
void VPattern::SetIncrementAttribute(const QString &name, const QString &attr, const QString &text)
|
2017-09-02 13:47:44 +02:00
|
|
|
|
{
|
|
|
|
|
QDomElement node = FindIncrement(name);
|
|
|
|
|
if (not node.isNull())
|
|
|
|
|
{
|
2017-09-02 14:37:52 +02:00
|
|
|
|
SetAttribute(node, attr, text);
|
2017-09-02 13:47:44 +02:00
|
|
|
|
emit patternChanged(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-25 15:36:04 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
QString VPattern::LastDrawName() const
|
|
|
|
|
{
|
|
|
|
|
const QDomNodeList elements = this->documentElement().elementsByTagName(TagDraw);
|
|
|
|
|
if (elements.size() == 0)
|
|
|
|
|
{
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QDomElement &elem = elements.at(elements.size()-1).toElement();
|
|
|
|
|
if (not elem.isNull())
|
|
|
|
|
{
|
|
|
|
|
return GetParametrString(elem, AttrName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
quint32 VPattern::LastToolId() const
|
|
|
|
|
{
|
|
|
|
|
const QString name = LastDrawName();
|
|
|
|
|
if (name.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
return NULL_ID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QVector<VToolRecord> localHistory = getLocalHistory(name);
|
|
|
|
|
|
|
|
|
|
return (not localHistory.isEmpty() ? localHistory.last().getId() : NULL_ID);
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-24 18:14:26 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
* @brief ParseSplineElement parse spline tag.
|
|
|
|
|
* @param scene scene.
|
|
|
|
|
* @param domElement tag in xml tree.
|
|
|
|
|
* @param parse parser file mode.
|
|
|
|
|
* @param type type of spline.
|
|
|
|
|
*/
|
2016-02-26 15:38:42 +01:00
|
|
|
|
void VPattern::ParseSplineElement(VMainGraphicsScene *scene, QDomElement &domElement,
|
2015-06-24 18:14:26 +02:00
|
|
|
|
const Document &parse, const QString &type)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-06-24 18:14:26 +02:00
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
|
|
|
|
|
|
2016-03-18 22:11:14 +01:00
|
|
|
|
QStringList splines = QStringList() << VToolSpline::OldToolType /*0*/
|
|
|
|
|
<< VToolSpline::ToolType /*1*/
|
|
|
|
|
<< VToolSplinePath::OldToolType /*2*/
|
|
|
|
|
<< VToolSplinePath::ToolType /*3*/
|
|
|
|
|
<< VNodeSpline::ToolType /*4*/
|
|
|
|
|
<< VNodeSplinePath::ToolType /*5*/
|
|
|
|
|
<< VToolCubicBezier::ToolType /*6*/
|
|
|
|
|
<< VToolCubicBezierPath::ToolType; /*7*/
|
2015-06-24 18:14:26 +02:00
|
|
|
|
switch (splines.indexOf(type))
|
|
|
|
|
{
|
2016-02-26 15:38:42 +01:00
|
|
|
|
case 0: //VToolSpline::OldToolType
|
2016-03-04 17:08:29 +01:00
|
|
|
|
qCDebug(vXML, "VOldToolSpline.");
|
2016-02-26 15:38:42 +01:00
|
|
|
|
ParseOldToolSpline(scene, domElement, parse);// TODO. Delete if minimal supported version is 0.2.7
|
|
|
|
|
break;
|
|
|
|
|
case 1: //VToolSpline::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
qCDebug(vXML, "VToolSpline.");
|
|
|
|
|
ParseToolSpline(scene, domElement, parse);
|
|
|
|
|
break;
|
2016-03-04 17:08:29 +01:00
|
|
|
|
case 2: //VToolSplinePath::OldToolType
|
|
|
|
|
qCDebug(vXML, "VOldToolSplinePath.");
|
|
|
|
|
ParseOldToolSplinePath(scene, domElement, parse);// TODO. Delete if minimal supported version is 0.2.7
|
|
|
|
|
break;
|
|
|
|
|
case 3: //VToolSplinePath::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
qCDebug(vXML, "VToolSplinePath.");
|
|
|
|
|
ParseToolSplinePath(scene, domElement, parse);
|
|
|
|
|
break;
|
2016-03-04 17:08:29 +01:00
|
|
|
|
case 4: //VNodeSpline::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
qCDebug(vXML, "VNodeSpline.");
|
2015-06-25 12:52:09 +02:00
|
|
|
|
ParseNodeSpline(domElement, parse);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
break;
|
2016-03-04 17:08:29 +01:00
|
|
|
|
case 5: //VNodeSplinePath::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
qCDebug(vXML, "VNodeSplinePath.");
|
2015-06-25 12:52:09 +02:00
|
|
|
|
ParseNodeSplinePath(domElement, parse);
|
2015-06-24 18:14:26 +02:00
|
|
|
|
break;
|
2016-03-10 14:55:04 +01:00
|
|
|
|
case 6: //VToolCubicBezier::ToolType
|
|
|
|
|
qCDebug(vXML, "VToolCubicBezier.");
|
|
|
|
|
ParseToolCubicBezier(scene, domElement, parse);
|
|
|
|
|
break;
|
2016-03-18 22:11:14 +01:00
|
|
|
|
case 7: //VToolCubicBezierPath::ToolType
|
|
|
|
|
qCDebug(vXML, "VToolCubicBezierPath.");
|
|
|
|
|
ParseToolCubicBezierPath(scene, domElement, parse);
|
|
|
|
|
break;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
default:
|
2015-10-08 08:30:26 +02:00
|
|
|
|
VException e(tr("Unknown spline type '%1'.").arg(type));
|
|
|
|
|
throw e;
|
2015-06-24 18:14:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
* @brief ParseArcElement parse arc tag.
|
|
|
|
|
* @param scene scene.
|
|
|
|
|
* @param domElement tag in xml tree.
|
|
|
|
|
* @param parse parser file mode.
|
|
|
|
|
* @param type type of spline.
|
|
|
|
|
*/
|
|
|
|
|
void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse,
|
|
|
|
|
const QString &type)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of arc is empty");
|
2015-06-24 18:14:26 +02:00
|
|
|
|
|
|
|
|
|
QStringList arcs = QStringList() << VToolArc::ToolType /*0*/
|
|
|
|
|
<< VNodeArc::ToolType /*1*/
|
|
|
|
|
<< VToolArcWithLength::ToolType; /*2*/
|
|
|
|
|
|
|
|
|
|
switch (arcs.indexOf(type))
|
|
|
|
|
{
|
|
|
|
|
case 0: //VToolArc::ToolType
|
|
|
|
|
ParseToolArc(scene, domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
|
|
|
|
case 1: //VNodeArc::ToolType
|
2015-06-25 12:52:09 +02:00
|
|
|
|
ParseNodeArc(domElement, parse);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
break;
|
2015-06-09 20:23:37 +02:00
|
|
|
|
case 2: //VToolArcWithLength::ToolType
|
2015-06-24 18:14:26 +02:00
|
|
|
|
ParseToolArcWithLength(scene, domElement, parse);
|
2015-06-09 20:23:37 +02:00
|
|
|
|
break;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
default:
|
2015-10-08 08:30:26 +02:00
|
|
|
|
VException e(tr("Unknown arc type '%1'.").arg(type));
|
|
|
|
|
throw e;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-17 02:53:47 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
/**
|
|
|
|
|
* @brief ParseEllipticalArcElement parse elliptical arc tag.
|
|
|
|
|
* @param scene scene.
|
|
|
|
|
* @param domElement tag in xml tree.
|
|
|
|
|
* @param parse parser file mode.
|
|
|
|
|
* @param type type of spline.
|
|
|
|
|
*/
|
|
|
|
|
void VPattern::ParseEllipticalArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse,
|
|
|
|
|
const QString &type)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2016-12-17 02:53:47 +01:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of elliptical arc is empty");
|
|
|
|
|
|
2016-12-20 15:51:58 +01:00
|
|
|
|
const QStringList arcs = QStringList() << VToolEllipticalArc::ToolType /*0*/
|
|
|
|
|
<< VNodeEllipticalArc::ToolType; /*1*/
|
2016-12-17 02:53:47 +01:00
|
|
|
|
|
|
|
|
|
switch (arcs.indexOf(type))
|
|
|
|
|
{
|
|
|
|
|
case 0: //VToolArc::ToolType
|
|
|
|
|
ParseToolEllipticalArc(scene, domElement, parse);
|
|
|
|
|
break;
|
2016-12-20 15:51:58 +01:00
|
|
|
|
case 1: //VNodeEllipticalArc::ToolType
|
|
|
|
|
ParseNodeEllipticalArc(domElement, parse);
|
|
|
|
|
break;
|
2016-12-17 02:53:47 +01:00
|
|
|
|
default:
|
|
|
|
|
VException e(tr("Unknown elliptical arc type '%1'.").arg(type));
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-05 12:02:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief ParseToolsElement parse tools tag.
|
|
|
|
|
* @param scene scene.
|
|
|
|
|
* @param domElement tag in xml tree.
|
|
|
|
|
* @param parse parser file mode.
|
|
|
|
|
* @param type type of spline.
|
|
|
|
|
*/
|
2014-02-25 15:02:09 +01:00
|
|
|
|
void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
2014-06-12 09:22:29 +02:00
|
|
|
|
const Document &parse, const QString &type)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
|
|
|
|
|
|
2015-10-23 19:47:33 +02:00
|
|
|
|
const QStringList tools = QStringList() << VToolUnionDetails::ToolType;
|
2014-02-26 10:51:37 +01:00
|
|
|
|
switch (tools.indexOf(type))
|
|
|
|
|
{
|
2014-02-25 15:02:09 +01:00
|
|
|
|
case 0: //VToolUnionDetails::ToolType
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-01-16 11:08:13 +01:00
|
|
|
|
VToolUnionDetailsInitData initData;
|
|
|
|
|
initData.indexD1 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD1, "-1");
|
|
|
|
|
initData.indexD2 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD2, "-1");
|
2017-10-23 09:45:58 +02:00
|
|
|
|
initData.version = GetParametrUInt(domElement, AttrVersion, "1");
|
2017-01-16 11:08:13 +01:00
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
|
|
|
|
|
VToolUnionDetails::Create(initData);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating union details"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2015-10-08 08:30:26 +02:00
|
|
|
|
VException e(tr("Unknown tools type '%1'.").arg(type));
|
|
|
|
|
throw e;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-16 19:27:51 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParseOperationElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse,
|
|
|
|
|
const QString &type)
|
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(scene != nullptr)
|
2016-05-16 19:27:51 +02:00
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
Q_ASSERT_X(not type.isEmpty(), Q_FUNC_INFO, "type of operation is empty");
|
|
|
|
|
|
2016-09-13 10:27:44 +02:00
|
|
|
|
const QStringList opers = QStringList() << VToolRotation::ToolType /*0*/
|
2016-09-17 11:10:03 +02:00
|
|
|
|
<< VToolFlippingByLine::ToolType /*1*/
|
2016-10-04 16:34:37 +02:00
|
|
|
|
<< VToolFlippingByAxis::ToolType /*2*/
|
|
|
|
|
<< VToolMove::ToolType; /*3*/
|
2016-05-16 19:27:51 +02:00
|
|
|
|
|
|
|
|
|
switch (opers.indexOf(type))
|
|
|
|
|
{
|
|
|
|
|
case 0: //VToolRotation::ToolType
|
|
|
|
|
ParseToolRotation(scene, domElement, parse);
|
|
|
|
|
break;
|
2016-09-13 10:27:44 +02:00
|
|
|
|
case 1: //VToolFlippingByLine::ToolType
|
|
|
|
|
ParseToolFlippingByLine(scene, domElement, parse);
|
|
|
|
|
break;
|
2016-09-17 11:10:03 +02:00
|
|
|
|
case 2: //VToolFlippingByAxis::ToolType
|
|
|
|
|
ParseToolFlippingByAxis(scene, domElement, parse);
|
|
|
|
|
break;
|
2016-10-04 16:34:37 +02:00
|
|
|
|
case 3: //VToolMove::ToolType
|
|
|
|
|
ParseToolMove(scene, domElement, parse);
|
|
|
|
|
break;
|
2016-05-16 19:27:51 +02:00
|
|
|
|
default:
|
|
|
|
|
VException e(tr("Unknown operation type '%1'.").arg(type));
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-24 20:35:54 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ParsePathElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse)
|
|
|
|
|
{
|
|
|
|
|
SCASSERT(scene != nullptr);
|
|
|
|
|
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolPiecePathInitData initData;
|
|
|
|
|
initData.scene = scene;
|
|
|
|
|
initData.doc = this;
|
|
|
|
|
initData.data = data;
|
|
|
|
|
initData.parse = parse;
|
|
|
|
|
initData.typeCreation = Source::FromFile;
|
|
|
|
|
|
|
|
|
|
ToolsCommonAttributes(domElement, initData.id);
|
|
|
|
|
initData.idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
|
2016-11-24 20:35:54 +01:00
|
|
|
|
|
|
|
|
|
const QDomElement element = domElement.firstChildElement(VAbstractPattern::TagNodes);
|
|
|
|
|
if (not element.isNull())
|
|
|
|
|
{
|
2017-09-18 10:37:23 +02:00
|
|
|
|
initData.path = ParsePathNodes(element);
|
2016-11-24 20:35:54 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
const QString defType = QString().setNum(static_cast<int>(PiecePathType::CustomSeamAllowance));
|
|
|
|
|
initData.path.SetType(static_cast<PiecePathType>(GetParametrUInt(domElement, AttrType, defType)));
|
|
|
|
|
initData.path.SetName(GetParametrString(domElement, AttrName, tr("Unnamed path")));
|
|
|
|
|
initData.path.SetPenType(LineStyleToPenStyle(GetParametrString(domElement, AttrTypeLine, TypeLineLine)));
|
|
|
|
|
initData.path.SetCutPath(GetParametrBool(domElement, AttrCut, falseStr));
|
2016-11-24 20:35:54 +01:00
|
|
|
|
|
2018-01-03 18:31:50 +01:00
|
|
|
|
if (initData.path.GetType() == PiecePathType::InternalPath)
|
|
|
|
|
{
|
|
|
|
|
initData.path.SetVisibilityTrigger(GetParametrString(domElement, AttrVisible, "1"));
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-18 10:37:23 +02:00
|
|
|
|
VToolPiecePath::Create(initData);
|
2016-11-24 20:35:54 +01:00
|
|
|
|
}
|
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
|
{
|
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating a piece path"), domElement);
|
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
|
throw excep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-05 12:02:35 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief ParseIncrementsElement parse increments tag.
|
|
|
|
|
* @param node tag in xml tree.
|
2018-01-22 13:26:53 +01:00
|
|
|
|
* @param parse parser file mode.
|
2014-06-05 12:02:35 +02:00
|
|
|
|
*/
|
2018-01-22 13:26:53 +01:00
|
|
|
|
void VPattern::ParseIncrementsElement(const QDomNode &node, const Document &parse)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2015-08-25 12:35:50 +02:00
|
|
|
|
int index = 0;
|
2014-02-25 15:02:09 +01:00
|
|
|
|
QDomNode domNode = node.firstChild();
|
|
|
|
|
while (domNode.isNull() == false)
|
|
|
|
|
{
|
|
|
|
|
if (domNode.isElement())
|
|
|
|
|
{
|
|
|
|
|
const QDomElement domElement = domNode.toElement();
|
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
|
{
|
2014-02-25 19:03:17 +01:00
|
|
|
|
if (domElement.tagName() == TagIncrement)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2017-09-26 11:54:52 +02:00
|
|
|
|
const QString name = GetParametrString(domElement, AttrName, "");
|
2018-01-20 11:31:12 +01:00
|
|
|
|
const QString desc = GetParametrEmptyString(domElement, AttrDescription);
|
2017-09-26 11:54:52 +02:00
|
|
|
|
const QString formula = GetParametrString(domElement, AttrFormula, "0");
|
2015-08-25 12:35:50 +02:00
|
|
|
|
bool ok = false;
|
|
|
|
|
const qreal value = EvalFormula(data, formula, &ok);
|
|
|
|
|
|
2017-09-02 13:47:44 +02:00
|
|
|
|
VIncrement *increment = new VIncrement(data, name, static_cast<quint32>(index), value, formula, ok,
|
|
|
|
|
desc);
|
|
|
|
|
increment->SetPreviewCalculation(node.toElement().tagName() == TagPreviewCalculations);
|
|
|
|
|
data->AddVariable(name, increment);
|
2015-08-25 12:35:50 +02:00
|
|
|
|
++index;
|
2018-01-22 13:26:53 +01:00
|
|
|
|
|
|
|
|
|
if (parse == Document::FullParse)
|
|
|
|
|
{
|
|
|
|
|
emit MadeProgress();
|
|
|
|
|
}
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
domNode = domNode.nextSibling();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-25 12:35:50 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::AddEmptyIncrement(const QString &name)
|
|
|
|
|
{
|
2017-09-02 13:47:44 +02:00
|
|
|
|
NewEmptyIncrement(TagIncrements, name);
|
|
|
|
|
}
|
2015-08-25 12:35:50 +02:00
|
|
|
|
|
2017-09-02 13:47:44 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::AddEmptyPreviewCalculation(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
NewEmptyIncrement(TagPreviewCalculations, name);
|
2015-08-25 12:35:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::AddEmptyIncrementAfter(const QString &after, const QString &name)
|
|
|
|
|
{
|
2017-09-02 13:47:44 +02:00
|
|
|
|
NewEmptyIncrementAfter(TagIncrements, after, name);
|
|
|
|
|
}
|
2015-08-25 12:35:50 +02:00
|
|
|
|
|
2017-09-02 13:47:44 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::AddEmptyPreviewCalculationAfter(const QString &after, const QString &name)
|
|
|
|
|
{
|
|
|
|
|
NewEmptyIncrementAfter(TagPreviewCalculations, after, name);
|
2015-08-25 12:35:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::RemoveIncrement(const QString &name)
|
|
|
|
|
{
|
2017-09-02 13:47:44 +02:00
|
|
|
|
RemoveIncrement(TagIncrements, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::RemovePreviewCalculation(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
RemoveIncrement(TagPreviewCalculations, name);
|
2015-08-25 12:35:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::MoveUpIncrement(const QString &name)
|
|
|
|
|
{
|
2017-09-02 13:47:44 +02:00
|
|
|
|
MoveUpIncrement(TagIncrements, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::MoveUpPreviewCalculation(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
MoveUpIncrement(TagPreviewCalculations, name);
|
2015-08-25 12:35:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::MoveDownIncrement(const QString &name)
|
|
|
|
|
{
|
2017-11-27 22:37:36 +01:00
|
|
|
|
MoveDownIncrement(TagIncrements, name);
|
2017-09-02 13:47:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::MoveDownPreviewCalculation(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
MoveDownIncrement(TagPreviewCalculations, name);
|
2015-08-25 12:35:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::SetIncrementName(const QString &name, const QString &text)
|
|
|
|
|
{
|
2017-09-26 11:54:52 +02:00
|
|
|
|
SetIncrementAttribute(name, AttrName, text);
|
2015-08-25 12:35:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::SetIncrementFormula(const QString &name, const QString &text)
|
|
|
|
|
{
|
2017-09-26 11:54:52 +02:00
|
|
|
|
SetIncrementAttribute(name, AttrFormula, text);
|
2015-08-25 12:35:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::SetIncrementDescription(const QString &name, const QString &text)
|
|
|
|
|
{
|
2017-09-26 11:54:52 +02:00
|
|
|
|
SetIncrementAttribute(name, AttrDescription, text);
|
2015-08-25 12:35:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-08 16:43:41 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::ReplaceNameInFormula(QVector<VFormulaField> &expressions, const QString &name, const QString &newName)
|
|
|
|
|
{
|
|
|
|
|
const int bias = name.length() - newName.length();
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < expressions.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (expressions.at(i).expression.indexOf(name) != -1)
|
|
|
|
|
{
|
|
|
|
|
QMap<int, QString> tokens;
|
|
|
|
|
|
|
|
|
|
// Eval formula
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(expressions.at(i).expression, false,
|
|
|
|
|
false));
|
|
|
|
|
tokens = cal->GetTokens();// Tokens (variables, measurements)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (const qmu::QmuParserError &)
|
|
|
|
|
{
|
|
|
|
|
continue;// Because we not sure if used. A formula is broken.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<QString> tValues = tokens.values();
|
|
|
|
|
if (not tValues.contains(name))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<int> tKeys = tokens.keys();// Take all tokens positions
|
|
|
|
|
QString newFormula = expressions.at(i).expression;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < tKeys.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (tValues.at(i) != name)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newFormula.replace(tKeys.at(i), name.length(), newName);
|
|
|
|
|
|
|
|
|
|
if (bias != 0)
|
|
|
|
|
{// Translated token has different length than original. Position next tokens need to be corrected.
|
|
|
|
|
VTranslateVars::BiasTokens(tKeys.at(i), bias, tokens);
|
|
|
|
|
tKeys = tokens.keys();
|
|
|
|
|
tValues = tokens.values();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expressions[i].expression = newFormula;
|
|
|
|
|
expressions[i].element.setAttribute(expressions.at(i).attribute, newFormula);
|
|
|
|
|
emit patternChanged(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-05 10:01:46 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-06-19 13:58:13 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief GenerateLabel create label for pattern piece of point.
|
|
|
|
|
* @param type type of the label.
|
|
|
|
|
* @param reservedName reversed point name. Use when need reserve name, but point is not in data base yet.
|
|
|
|
|
* @return unique name for current pattern piece.
|
|
|
|
|
*/
|
|
|
|
|
QString VPattern::GenerateLabel(const LabelType &type, const QString &reservedName) const
|
2014-09-05 10:01:46 +02:00
|
|
|
|
{
|
|
|
|
|
if (type == LabelType::NewPatternPiece)
|
|
|
|
|
{
|
2016-05-18 14:35:07 +02:00
|
|
|
|
const QDomNodeList drawList = elementsByTagName(TagDraw);
|
2014-09-05 10:01:46 +02:00
|
|
|
|
QString name;
|
|
|
|
|
int i = 0;
|
2014-09-10 19:57:08 +02:00
|
|
|
|
for (;;)
|
2014-09-05 10:01:46 +02:00
|
|
|
|
{
|
2015-10-26 09:36:07 +01:00
|
|
|
|
name = GetLabelBase(static_cast<quint32>(drawList.size() + i));
|
2014-09-05 10:01:46 +02:00
|
|
|
|
if (data->IsUnique(name))
|
|
|
|
|
{
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
if (i == INT_MAX)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++i;
|
|
|
|
|
}
|
2015-10-01 17:34:03 +02:00
|
|
|
|
qCDebug(vXML, "Point label: %s", qUtf8Printable(name));
|
2014-09-05 10:01:46 +02:00
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
else if (type == LabelType::NewLabel)
|
|
|
|
|
{
|
2016-05-18 14:35:07 +02:00
|
|
|
|
const QString labelBase = GetLabelBase(static_cast<quint32>(GetIndexActivPP()));
|
2014-09-05 10:01:46 +02:00
|
|
|
|
|
|
|
|
|
qint32 num = 1;
|
|
|
|
|
QString name;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
name = QString("%1%2").arg(labelBase).arg(num);
|
|
|
|
|
num++;
|
|
|
|
|
if (num == INT_MAX)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
2015-06-19 13:58:13 +02:00
|
|
|
|
} while (data->IsUnique(name) == false || name == reservedName);
|
2015-10-01 17:34:03 +02:00
|
|
|
|
qCDebug(vXML, "Point label: %s", qUtf8Printable(name));
|
2014-09-05 10:01:46 +02:00
|
|
|
|
return name;
|
|
|
|
|
}
|
2015-04-01 19:08:35 +02:00
|
|
|
|
qCDebug(vXML, "Got unknow type %d", static_cast<int>(type));
|
2014-09-05 10:01:46 +02:00
|
|
|
|
return QString();
|
2016-05-18 14:35:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
QString VPattern::GenerateSuffix() const
|
|
|
|
|
{
|
|
|
|
|
const QString suffixBase = GetLabelBase(static_cast<quint32>(GetIndexActivPP())).toLower();
|
2017-03-23 09:25:46 +01:00
|
|
|
|
const QStringList uniqueNames = VContainer::AllUniqueNames();
|
2016-05-18 14:35:07 +02:00
|
|
|
|
qint32 num = 1;
|
|
|
|
|
QString suffix;
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
suffix = QString("%1%2").arg(suffixBase).arg(num);
|
|
|
|
|
|
|
|
|
|
for (int i=0; i < uniqueNames.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (not data->IsUnique(uniqueNames.at(i) + suffix))
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i == uniqueNames.size()-1)
|
|
|
|
|
{
|
|
|
|
|
qCDebug(vXML, "Suffix is: %s", qUtf8Printable(suffix));
|
|
|
|
|
return suffix;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (num == INT_MAX)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++num;
|
|
|
|
|
}
|
|
|
|
|
return QString();
|
2014-09-05 10:01:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-11 15:19:11 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
bool VPattern::IsDefCustom() const
|
|
|
|
|
{
|
|
|
|
|
QDomNodeList tags = elementsByTagName(TagGradation);
|
|
|
|
|
if (tags.size() == 0)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QDomNode domNode = tags.at(0);
|
|
|
|
|
const QDomElement domElement = domNode.toElement();
|
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
|
{
|
2016-04-05 19:53:49 +02:00
|
|
|
|
return GetParametrBool(domElement, AttrCustom, falseStr);
|
2015-12-11 15:19:11 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::SetDefCustom(bool value)
|
|
|
|
|
{
|
|
|
|
|
CheckTagExists(TagGradation);
|
|
|
|
|
QDomNodeList tags = elementsByTagName(TagGradation);
|
2016-04-06 03:11:14 +02:00
|
|
|
|
if (tags.isEmpty())
|
2015-12-11 15:19:11 +01:00
|
|
|
|
{
|
|
|
|
|
qDebug()<<"Can't save attribute "<<AttrCustom<<Q_FUNC_INFO;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode domNode = tags.at(0);
|
|
|
|
|
QDomElement domElement = domNode.toElement();
|
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
|
{
|
2016-01-03 14:21:30 +01:00
|
|
|
|
if (value == false)
|
|
|
|
|
{
|
|
|
|
|
domElement.removeAttribute(AttrDefHeight);
|
|
|
|
|
SetDefCustomHeight(0);
|
|
|
|
|
SetDefCustomSize(0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SetAttribute(domElement, AttrCustom, value);
|
|
|
|
|
}
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-12-11 15:19:11 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
qDebug()<<"Can't save attribute "<<AttrCustom<<Q_FUNC_INFO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
int VPattern::GetDefCustomHeight() const
|
|
|
|
|
{
|
2015-12-12 12:15:29 +01:00
|
|
|
|
if (IsDefCustom())
|
2015-12-11 15:19:11 +01:00
|
|
|
|
{
|
2015-12-12 12:15:29 +01:00
|
|
|
|
QDomNodeList tags = elementsByTagName(TagGradation);
|
|
|
|
|
if (tags.size() == 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2015-12-11 15:19:11 +01:00
|
|
|
|
|
2015-12-12 12:15:29 +01:00
|
|
|
|
const QDomNode domNode = tags.at(0);
|
|
|
|
|
const QDomElement domElement = domNode.toElement();
|
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
|
{
|
|
|
|
|
return static_cast<int>(GetParametrUInt(domElement, AttrDefHeight, QStringLiteral("0")));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2015-12-11 15:19:11 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::SetDefCustomHeight(int value)
|
|
|
|
|
{
|
|
|
|
|
CheckTagExists(TagGradation);
|
|
|
|
|
QDomNodeList tags = elementsByTagName(TagGradation);
|
2016-04-06 03:11:14 +02:00
|
|
|
|
if (tags.isEmpty())
|
2015-12-11 15:19:11 +01:00
|
|
|
|
{
|
|
|
|
|
qDebug()<<"Can't save attribute "<<AttrDefHeight<<Q_FUNC_INFO;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode domNode = tags.at(0);
|
|
|
|
|
QDomElement domElement = domNode.toElement();
|
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
|
{
|
|
|
|
|
if (value == 0)
|
|
|
|
|
{
|
|
|
|
|
domElement.removeAttribute(AttrDefHeight);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SetAttribute(domElement, AttrDefHeight, value);
|
|
|
|
|
}
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-12-11 15:19:11 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
qDebug()<<"Can't save attribute "<<AttrDefHeight<<Q_FUNC_INFO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
int VPattern::GetDefCustomSize() const
|
|
|
|
|
{
|
2015-12-12 12:15:29 +01:00
|
|
|
|
if (IsDefCustom())
|
2015-12-11 15:19:11 +01:00
|
|
|
|
{
|
2015-12-12 12:15:29 +01:00
|
|
|
|
QDomNodeList tags = elementsByTagName(TagGradation);
|
|
|
|
|
if (tags.size() == 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2015-12-11 15:19:11 +01:00
|
|
|
|
|
2015-12-12 12:15:29 +01:00
|
|
|
|
const QDomNode domNode = tags.at(0);
|
|
|
|
|
const QDomElement domElement = domNode.toElement();
|
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
|
{
|
|
|
|
|
return static_cast<int>(GetParametrUInt(domElement, AttrDefSize, QStringLiteral("0")));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2015-12-11 15:19:11 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::SetDefCustomSize(int value)
|
|
|
|
|
{
|
|
|
|
|
CheckTagExists(TagGradation);
|
|
|
|
|
QDomNodeList tags = elementsByTagName(TagGradation);
|
2016-04-06 03:11:14 +02:00
|
|
|
|
if (tags.isEmpty())
|
2015-12-11 15:19:11 +01:00
|
|
|
|
{
|
|
|
|
|
qDebug()<<"Can't save attribute "<<AttrDefSize<<Q_FUNC_INFO;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode domNode = tags.at(0);
|
|
|
|
|
QDomElement domElement = domNode.toElement();
|
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
|
{
|
|
|
|
|
if (value == 0)
|
|
|
|
|
{
|
|
|
|
|
domElement.removeAttribute(AttrDefSize);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SetAttribute(domElement, AttrDefSize, value);
|
|
|
|
|
}
|
2015-12-18 12:57:03 +01:00
|
|
|
|
modified = true;
|
2015-12-11 15:19:11 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
qDebug()<<"Can't save attribute "<<AttrDefSize<<Q_FUNC_INFO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-22 11:45:18 +01:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
bool VPattern::IsReadOnly() const
|
|
|
|
|
{
|
|
|
|
|
const QDomElement pattern = documentElement();
|
|
|
|
|
|
|
|
|
|
if (pattern.isNull())
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-05 19:53:49 +02:00
|
|
|
|
return GetParametrBool(pattern, AttrReadOnly, falseStr);
|
2016-01-22 11:45:18 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
void VPattern::SetReadOnly(bool rOnly)
|
|
|
|
|
{
|
|
|
|
|
QDomElement pattern = documentElement();
|
|
|
|
|
|
|
|
|
|
if (not pattern.isNull())
|
|
|
|
|
{
|
|
|
|
|
if (rOnly)
|
|
|
|
|
{
|
|
|
|
|
SetAttribute(pattern, AttrReadOnly, rOnly);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{// For better backward compatibility
|
|
|
|
|
pattern.removeAttribute(AttrReadOnly);
|
|
|
|
|
}
|
|
|
|
|
modified = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-12 09:22:29 +02:00
|
|
|
|
void VPattern::PrepareForParse(const Document &parse)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(sceneDraw != nullptr)
|
|
|
|
|
SCASSERT(sceneDetail != nullptr)
|
2014-02-25 15:02:09 +01:00
|
|
|
|
if (parse == Document::FullParse)
|
|
|
|
|
{
|
|
|
|
|
TestUniqueId();
|
2014-10-04 21:12:46 +02:00
|
|
|
|
sceneDraw->clear();
|
2016-01-15 13:55:56 +01:00
|
|
|
|
sceneDraw->InitOrigins();
|
2014-10-04 21:12:46 +02:00
|
|
|
|
sceneDetail->clear();
|
2016-01-15 13:55:56 +01:00
|
|
|
|
sceneDetail->InitOrigins();
|
2015-08-26 20:14:47 +02:00
|
|
|
|
data->ClearForFullParse();
|
2014-07-17 14:41:48 +02:00
|
|
|
|
nameActivPP.clear();
|
2014-06-05 13:35:38 +02:00
|
|
|
|
patternPieces.clear();
|
2016-02-19 15:34:32 +01:00
|
|
|
|
|
2016-02-10 17:45:49 +01:00
|
|
|
|
qDeleteAll(toolsOnRemove);//Remove all invisible on a scene objects.
|
2016-02-19 15:34:32 +01:00
|
|
|
|
toolsOnRemove.clear();
|
|
|
|
|
|
2014-02-25 15:02:09 +01:00
|
|
|
|
tools.clear();
|
|
|
|
|
cursor = 0;
|
2014-07-29 13:28:18 +02:00
|
|
|
|
history.clear();
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
2014-09-04 07:20:41 +02:00
|
|
|
|
else if (parse == Document::LiteParse)
|
|
|
|
|
{
|
2017-03-23 09:25:46 +01:00
|
|
|
|
VContainer::ClearUniqueNames();
|
2017-11-19 16:08:50 +01:00
|
|
|
|
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 8, "Check that you used all types");
|
2018-01-20 13:01:35 +01:00
|
|
|
|
data->ClearVariables(QVector<VarType>({VarType::Increment,
|
|
|
|
|
VarType::LineAngle,
|
|
|
|
|
VarType::LineLength,
|
|
|
|
|
VarType::CurveLength,
|
|
|
|
|
VarType::CurveCLength,
|
|
|
|
|
VarType::ArcRadius,
|
|
|
|
|
VarType::CurveAngle}));
|
2014-09-04 07:20:41 +02:00
|
|
|
|
}
|
2014-02-25 15:02:09 +01:00
|
|
|
|
}
|
2014-03-24 16:02:57 +01:00
|
|
|
|
|
2014-06-12 11:51:40 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-18 18:11:14 +02:00
|
|
|
|
void VPattern::ToolsCommonAttributes(const QDomElement &domElement, quint32 &id)
|
|
|
|
|
{
|
|
|
|
|
id = GetParametrId(domElement);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-12 18:25:25 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-08-06 20:42:40 +02:00
|
|
|
|
QT_WARNING_PUSH
|
|
|
|
|
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
2016-03-13 15:22:15 +01:00
|
|
|
|
|
2014-07-12 18:25:25 +02:00
|
|
|
|
QRectF VPattern::ActiveDrawBoundingRect() const
|
|
|
|
|
{
|
2016-03-13 15:16:49 +01:00
|
|
|
|
// This check helps to find missed tools in the switch
|
2017-10-25 16:49:04 +02:00
|
|
|
|
Q_STATIC_ASSERT_X(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 55, "Not all tools were used.");
|
2016-03-13 15:16:49 +01:00
|
|
|
|
|
2014-07-12 18:25:25 +02:00
|
|
|
|
QRectF rec;
|
|
|
|
|
|
|
|
|
|
for (qint32 i = 0; i< history.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
const VToolRecord tool = history.at(i);
|
2014-07-17 14:41:48 +02:00
|
|
|
|
if (tool.getNameDraw() == nameActivPP)
|
2014-07-12 18:25:25 +02:00
|
|
|
|
{
|
|
|
|
|
switch ( tool.getTypeTool() )
|
|
|
|
|
{
|
2014-08-26 20:31:28 +02:00
|
|
|
|
case Tool::Arrow:
|
2016-03-13 15:16:49 +01:00
|
|
|
|
case Tool::SinglePoint:
|
|
|
|
|
case Tool::DoublePoint:
|
|
|
|
|
case Tool::LinePoint:
|
|
|
|
|
case Tool::AbstractSpline:
|
|
|
|
|
case Tool::Cut:
|
2016-06-23 19:20:21 +02:00
|
|
|
|
case Tool::Midpoint:// Same as Tool::AlongLine, but tool will never has such type
|
2016-06-23 19:45:45 +02:00
|
|
|
|
case Tool::ArcIntersectAxis:// Same as Tool::CurveIntersectAxis, but tool will never has such type
|
2016-03-13 15:16:49 +01:00
|
|
|
|
case Tool::LAST_ONE_DO_NOT_USE:
|
2014-07-12 18:25:25 +02:00
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
|
break;
|
2015-06-19 14:08:27 +02:00
|
|
|
|
case Tool::BasePoint:
|
2014-08-26 20:31:28 +02:00
|
|
|
|
case Tool::LineIntersect:
|
2014-07-12 18:25:25 +02:00
|
|
|
|
case Tool::PointOfContact:
|
|
|
|
|
case Tool::Triangle:
|
|
|
|
|
case Tool::PointOfIntersection:
|
2014-08-26 20:31:28 +02:00
|
|
|
|
case Tool::CutArc:
|
|
|
|
|
case Tool::CutSpline:
|
|
|
|
|
case Tool::CutSplinePath:
|
2016-03-13 15:16:49 +01:00
|
|
|
|
case Tool::PointOfIntersectionArcs:
|
|
|
|
|
case Tool::PointOfIntersectionCircles:
|
|
|
|
|
case Tool::PointOfIntersectionCurves:
|
2017-06-16 20:14:33 +02:00
|
|
|
|
case Tool::PointFromCircleAndTangent:
|
|
|
|
|
case Tool::PointFromArcAndTangent:
|
|
|
|
|
rec = ToolBoundingRect<VToolSinglePoint>(rec, tool.getId());
|
2016-03-19 09:38:29 +01:00
|
|
|
|
break;
|
2017-06-16 20:14:33 +02:00
|
|
|
|
case Tool::EndLine:
|
|
|
|
|
case Tool::AlongLine:
|
|
|
|
|
case Tool::ShoulderPoint:
|
|
|
|
|
case Tool::Normal:
|
|
|
|
|
case Tool::Bisector:
|
|
|
|
|
case Tool::Height:
|
|
|
|
|
case Tool::LineIntersectAxis:
|
2016-03-13 15:16:49 +01:00
|
|
|
|
case Tool::CurveIntersectAxis:
|
2017-06-16 20:14:33 +02:00
|
|
|
|
rec = ToolBoundingRect<VToolLinePoint>(rec, tool.getId());
|
2016-03-19 09:38:29 +01:00
|
|
|
|
break;
|
2017-06-16 20:14:33 +02:00
|
|
|
|
case Tool::Line:
|
|
|
|
|
rec = ToolBoundingRect<VToolLine>(rec, tool.getId());
|
2016-03-19 09:38:29 +01:00
|
|
|
|
break;
|
2017-06-16 20:14:33 +02:00
|
|
|
|
case Tool::Spline:
|
|
|
|
|
case Tool::CubicBezier:
|
|
|
|
|
case Tool::Arc:
|
|
|
|
|
case Tool::SplinePath:
|
|
|
|
|
case Tool::CubicBezierPath:
|
|
|
|
|
case Tool::ArcWithLength:
|
|
|
|
|
case Tool::EllipticalArc:
|
|
|
|
|
rec = ToolBoundingRect<VAbstractSpline>(rec, tool.getId());
|
2016-03-19 09:38:29 +01:00
|
|
|
|
break;
|
2016-03-13 15:16:49 +01:00
|
|
|
|
case Tool::TrueDarts:
|
2017-06-16 20:14:33 +02:00
|
|
|
|
rec = ToolBoundingRect<VToolDoublePoint>(rec, tool.getId());
|
2016-03-13 15:16:49 +01:00
|
|
|
|
break;
|
2016-05-12 21:11:21 +02:00
|
|
|
|
case Tool::Rotation:
|
2016-09-13 10:27:44 +02:00
|
|
|
|
case Tool::FlippingByLine:
|
2016-09-17 11:10:03 +02:00
|
|
|
|
case Tool::FlippingByAxis:
|
2016-10-04 16:34:37 +02:00
|
|
|
|
case Tool::Move:
|
2017-06-16 20:14:33 +02:00
|
|
|
|
rec = ToolBoundingRect<VAbstractOperation>(rec, tool.getId());
|
2016-12-19 15:47:43 +01:00
|
|
|
|
break;
|
2016-03-17 19:12:48 +01:00
|
|
|
|
//These tools are not accesseble in Draw mode, but still 'history' contains them.
|
2016-11-08 11:57:01 +01:00
|
|
|
|
case Tool::Piece:
|
2014-07-12 18:25:25 +02:00
|
|
|
|
case Tool::UnionDetails:
|
|
|
|
|
case Tool::NodeArc:
|
2016-12-20 15:51:58 +01:00
|
|
|
|
case Tool::NodeElArc:
|
2014-07-12 18:25:25 +02:00
|
|
|
|
case Tool::NodePoint:
|
|
|
|
|
case Tool::NodeSpline:
|
|
|
|
|
case Tool::NodeSplinePath:
|
2016-04-05 19:14:12 +02:00
|
|
|
|
case Tool::Group:
|
2016-11-22 13:33:08 +01:00
|
|
|
|
case Tool::PiecePath:
|
2017-01-31 13:28:48 +01:00
|
|
|
|
case Tool::Pin:
|
2017-03-21 14:39:14 +01:00
|
|
|
|
case Tool::InsertNode:
|
2017-10-15 11:25:20 +02:00
|
|
|
|
case Tool::PlaceLabel:
|
2017-10-25 16:49:04 +02:00
|
|
|
|
case Tool::DuplicateDetail:
|
2014-07-12 18:25:25 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return rec;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-06 20:42:40 +02:00
|
|
|
|
QT_WARNING_POP
|
2016-03-13 15:22:15 +01:00
|
|
|
|
|
2014-07-29 17:23:18 +02:00
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-03-19 09:38:29 +01:00
|
|
|
|
template <typename T>
|
2014-07-12 18:25:25 +02:00
|
|
|
|
QRectF VPattern::ToolBoundingRect(const QRectF &rec, const quint32 &id) const
|
|
|
|
|
{
|
2014-07-13 14:49:00 +02:00
|
|
|
|
QRectF recTool = rec;
|
2014-07-12 18:25:25 +02:00
|
|
|
|
if (tools.contains(id))
|
|
|
|
|
{
|
2016-03-19 09:38:29 +01:00
|
|
|
|
const T *vTool = qobject_cast<T *>(tools.value(id));
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(vTool != nullptr)
|
2014-07-12 18:25:25 +02:00
|
|
|
|
|
|
|
|
|
QRectF childrenRect = vTool->childrenBoundingRect();
|
|
|
|
|
//map to scene coordinate.
|
|
|
|
|
childrenRect.translate(vTool->scenePos());
|
|
|
|
|
|
2017-06-16 20:14:33 +02:00
|
|
|
|
recTool = recTool.united(vTool->sceneBoundingRect());
|
2014-07-13 14:49:00 +02:00
|
|
|
|
recTool = recTool.united(childrenRect);
|
2014-07-12 18:25:25 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
qDebug()<<"Can't find tool with id="<<id;
|
|
|
|
|
}
|
|
|
|
|
return recTool;
|
|
|
|
|
}
|
2014-10-29 10:14:36 +01:00
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-06-16 10:30:25 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief IncrementReferens increment reference parent objects.
|
|
|
|
|
* @param id parent object id.
|
|
|
|
|
*/
|
|
|
|
|
void VPattern::IncrementReferens(quint32 id) const
|
2014-10-29 10:14:36 +01:00
|
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(id != 0, Q_FUNC_INFO, "id == 0");
|
2015-06-16 10:30:25 +02:00
|
|
|
|
ToolExists(id);
|
|
|
|
|
VDataTool *tool = tools.value(id);
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(tool != nullptr)
|
2015-06-16 10:30:25 +02:00
|
|
|
|
tool->incrementReferens();
|
2014-10-29 10:14:36 +01:00
|
|
|
|
}
|
2014-11-10 15:49:39 +01:00
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-06-16 10:30:25 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief DecrementReferens decrement reference parent objects.
|
|
|
|
|
* @param id parent object id.
|
|
|
|
|
*/
|
|
|
|
|
void VPattern::DecrementReferens(quint32 id) const
|
2014-11-10 15:49:39 +01:00
|
|
|
|
{
|
2015-10-28 15:22:36 +01:00
|
|
|
|
Q_ASSERT_X(id != 0, Q_FUNC_INFO, "id == 0");
|
2015-06-16 10:30:25 +02:00
|
|
|
|
ToolExists(id);
|
|
|
|
|
VDataTool *tool = tools.value(id);
|
2016-12-20 19:57:20 +01:00
|
|
|
|
SCASSERT(tool != nullptr)
|
2015-06-16 10:30:25 +02:00
|
|
|
|
tool->decrementReferens();
|
2014-11-10 15:49:39 +01:00
|
|
|
|
}
|