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
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2013 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "vpattern.h"
|
|
|
|
|
|
|
|
#include "../tools/vtooldetail.h"
|
|
|
|
#include "../tools/vtooluniondetails.h"
|
|
|
|
#include "../tools/drawTools/drawtools.h"
|
|
|
|
#include "../tools/nodeDetails/nodedetails.h"
|
|
|
|
#include "../exception/vexceptionobjecterror.h"
|
2014-03-03 18:32:38 +01:00
|
|
|
#include "../exception/vexceptionwrongid.h"
|
2014-03-14 16:59:28 +01:00
|
|
|
#include "../exception/vexceptionconversionerror.h"
|
2014-03-24 16:02:57 +01:00
|
|
|
#include "vstandardmeasurements.h"
|
|
|
|
#include "vindividualmeasurements.h"
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
2014-03-16 07:32:52 +01:00
|
|
|
const QString VPattern::TagPattern = QStringLiteral("pattern");
|
|
|
|
const QString VPattern::TagCalculation = QStringLiteral("calculation");
|
|
|
|
const QString VPattern::TagModeling = QStringLiteral("modeling");
|
|
|
|
const QString VPattern::TagDetails = QStringLiteral("details");
|
|
|
|
const QString VPattern::TagAuthor = QStringLiteral("author");
|
|
|
|
const QString VPattern::TagDescription = QStringLiteral("description");
|
|
|
|
const QString VPattern::TagNotes = QStringLiteral("notes");
|
|
|
|
const QString VPattern::TagMeasurements = QStringLiteral("measurements");
|
|
|
|
const QString VPattern::TagIncrements = QStringLiteral("increments");
|
|
|
|
const QString VPattern::TagIncrement = QStringLiteral("increment");
|
|
|
|
const QString VPattern::TagDraw = QStringLiteral("draw");
|
|
|
|
const QString VPattern::TagPoint = QStringLiteral("point");
|
|
|
|
const QString VPattern::TagLine = QStringLiteral("line");
|
|
|
|
const QString VPattern::TagSpline = QStringLiteral("spline");
|
|
|
|
const QString VPattern::TagArc = QStringLiteral("arc");
|
|
|
|
const QString VPattern::TagTools = QStringLiteral("tools");
|
2014-02-25 19:03:17 +01:00
|
|
|
|
2014-03-16 07:32:52 +01:00
|
|
|
const QString VPattern::AttrName = QStringLiteral("name");
|
|
|
|
const QString VPattern::AttrType = QStringLiteral("type");
|
2014-03-21 11:08:29 +01:00
|
|
|
const QString VPattern::AttrPath = QStringLiteral("path");
|
2014-02-25 19:03:17 +01:00
|
|
|
|
|
|
|
const QString VPattern::IncrementName = QStringLiteral("name");
|
|
|
|
const QString VPattern::IncrementBase = QStringLiteral("base");
|
|
|
|
const QString VPattern::IncrementKsize = QStringLiteral("ksize");
|
|
|
|
const QString VPattern::IncrementKgrowth = QStringLiteral("kgrowth");
|
|
|
|
const QString VPattern::IncrementDescription = QStringLiteral("description");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-11 12:43:24 +01:00
|
|
|
VPattern::VPattern(VContainer *data, QComboBox *comboBoxDraws, Valentina::Draws *mode, QObject *parent)
|
2014-02-25 15:40:24 +01:00
|
|
|
: QObject(parent), VDomDocument(data), nameActivDraw(QString()), tools(QHash<quint32, VDataTool*>()),
|
2014-02-25 15:02:09 +01:00
|
|
|
history(QVector<VToolRecord>()), cursor(0), comboBoxDraws(comboBoxDraws), mode(mode), patternModified(false)
|
2014-05-02 13:11:30 +02:00
|
|
|
{}
|
2014-02-25 15:02:09 +01:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-16 07:32:52 +01:00
|
|
|
void VPattern::CreateEmptyFile(const QString &tablePath)
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
2014-03-16 07:32:52 +01:00
|
|
|
if (tablePath.isEmpty())
|
|
|
|
{
|
|
|
|
throw VException("Path to measurement table empty.");
|
|
|
|
}
|
2014-02-25 19:03:17 +01:00
|
|
|
QDomElement patternElement = this->createElement(TagPattern);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
|
|
patternElement.appendChild(createComment("Valentina pattern format."));
|
|
|
|
patternElement.appendChild(createElement(TagAuthor));
|
|
|
|
patternElement.appendChild(createElement(TagDescription));
|
|
|
|
patternElement.appendChild(createElement(TagNotes));
|
2014-03-16 07:32:52 +01:00
|
|
|
|
|
|
|
QDomElement measurements = createElement(TagMeasurements);
|
2014-03-24 16:02:57 +01:00
|
|
|
SetAttribute(measurements, AttrUnit, UnitsToStr(qApp->patternUnit()));
|
2014-03-21 11:08:29 +01:00
|
|
|
SetAttribute(measurements, AttrType, qApp->patternType());
|
|
|
|
SetAttribute(measurements, AttrPath, tablePath);
|
2014-03-16 07:32:52 +01:00
|
|
|
patternElement.appendChild(measurements);
|
|
|
|
|
2014-02-25 15:02:09 +01:00
|
|
|
patternElement.appendChild(createElement(TagIncrements));
|
|
|
|
|
|
|
|
this->appendChild(patternElement);
|
|
|
|
insertBefore(createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""), this->firstChild());
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::ChangeActivDraw(const QString &name, const Document::Documents &parse)
|
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, "ChangeActivDraw", "name draw is empty");
|
|
|
|
if (CheckNameDraw(name))
|
|
|
|
{
|
|
|
|
this->nameActivDraw = name;
|
|
|
|
if (parse == Document::FullParse)
|
|
|
|
{
|
|
|
|
emit ChangedActivDraw(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
bool VPattern::GetActivDrawElement(QDomElement &element)
|
|
|
|
{
|
|
|
|
if (nameActivDraw.isEmpty() == false)
|
|
|
|
{
|
|
|
|
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw );
|
|
|
|
if (elements.size() == 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for ( qint32 i = 0; i < elements.count(); i++ )
|
|
|
|
{
|
|
|
|
element = elements.at( i ).toElement();
|
|
|
|
if (element.isNull() == false)
|
|
|
|
{
|
|
|
|
const QString fieldName = element.attribute( AttrName );
|
|
|
|
if ( fieldName == nameActivDraw )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
bool VPattern::appendDraw(const QString &name)
|
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, "appendDraw", "name draw is empty");
|
|
|
|
if (name.isEmpty())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (CheckNameDraw(name) == false)
|
|
|
|
{
|
|
|
|
QDomElement rootElement = this->documentElement();
|
|
|
|
|
|
|
|
QDomElement drawElement = this->createElement(TagDraw);
|
|
|
|
SetAttribute(drawElement, AttrName, name);
|
|
|
|
|
|
|
|
drawElement.appendChild(createElement(TagCalculation));
|
|
|
|
drawElement.appendChild(createElement(TagModeling));
|
|
|
|
drawElement.appendChild(createElement(TagDetails));
|
|
|
|
|
|
|
|
rootElement.appendChild(drawElement);
|
|
|
|
|
|
|
|
if (nameActivDraw.isEmpty())
|
|
|
|
{
|
|
|
|
SetActivDraw(name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ChangeActivDraw(name);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
bool VPattern::SetNameDraw(const QString &name)
|
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, "SetNameDraw", "name draw is empty");
|
|
|
|
const QString oldName = nameActivDraw;
|
|
|
|
QDomElement element;
|
|
|
|
if (GetActivDrawElement(element))
|
|
|
|
{
|
|
|
|
nameActivDraw = name;
|
|
|
|
element.setAttribute(AttrName, nameActivDraw);
|
|
|
|
emit patternChanged();
|
|
|
|
emit ChangedNameDraw(oldName, nameActivDraw);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-28 14:11:46 +01:00
|
|
|
qDebug()<<"Can't find activ draw"<<Q_FUNC_INFO;
|
2014-02-25 15:02:09 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::Parse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail)
|
|
|
|
{
|
|
|
|
Q_CHECK_PTR(sceneDraw);
|
|
|
|
Q_CHECK_PTR(sceneDetail);
|
|
|
|
PrepareForParse(parse, sceneDraw, sceneDetail);
|
|
|
|
QDomNode domNode = documentElement().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
|
|
|
QStringList tags;
|
2014-03-23 15:36:34 +01:00
|
|
|
tags << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes << TagMeasurements;
|
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
|
|
|
|
if (parse == Document::FullParse)
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
2014-02-25 19:03:17 +01:00
|
|
|
if (nameActivDraw.isEmpty())
|
|
|
|
{
|
|
|
|
SetActivDraw(GetParametrString(domElement, AttrName));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ChangeActivDraw(GetParametrString(domElement, AttrName));
|
|
|
|
}
|
|
|
|
comboBoxDraws->addItem(GetParametrString(domElement, AttrName));
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-02-25 19:03:17 +01:00
|
|
|
ChangeActivDraw(GetParametrString(domElement, AttrName), Document::LiteParse);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
2014-02-25 19:03:17 +01:00
|
|
|
ParseDrawElement(sceneDraw, sceneDetail, domElement, parse);
|
|
|
|
break;
|
|
|
|
case 1: // TagIncrements
|
|
|
|
ParseIncrementsElement(domElement);
|
|
|
|
break;
|
2014-03-03 16:30:04 +01:00
|
|
|
case 2: // TagAuthor
|
|
|
|
break;
|
|
|
|
case 3: // TagDescription
|
|
|
|
break;
|
|
|
|
case 4: // TagNotes
|
|
|
|
break;
|
2014-03-23 15:36:34 +01:00
|
|
|
case 5: // TagMeasurements
|
|
|
|
break;
|
2014-02-25 19:03:17 +01:00
|
|
|
default:
|
2014-03-28 14:11:46 +01:00
|
|
|
qDebug()<<"Wrong tag name"<<Q_FUNC_INFO;
|
2014-02-25 19:03:17 +01:00
|
|
|
break;
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
domNode = domNode.nextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
VDataTool *VPattern::getTool(const quint32 &id)
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
|
|
|
if (tools.contains(id))
|
|
|
|
{
|
|
|
|
return tools.value(id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const QString error = QString(tr("Can't find tool id = %1 in table.")).arg(id);
|
|
|
|
throw VException(error);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void VPattern::setCursor(const quint32 &value)
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
|
|
|
cursor = value;
|
|
|
|
emit ChangedCursor(cursor);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::setCurrentData()
|
|
|
|
{
|
2014-03-11 12:43:24 +01:00
|
|
|
if (*mode == Valentina::Calculation)
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
|
|
|
const QString nameDraw = comboBoxDraws->itemText(comboBoxDraws->currentIndex());
|
|
|
|
if (nameActivDraw != nameDraw)
|
|
|
|
{
|
|
|
|
nameActivDraw = nameDraw;
|
2014-02-25 15:40:24 +01:00
|
|
|
quint32 id = 0;
|
2014-02-25 15:02:09 +01:00
|
|
|
if (history.size() == 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (qint32 i = 0; i < history.size(); ++i)
|
|
|
|
{
|
|
|
|
const VToolRecord tool = history.at(i);
|
|
|
|
if (tool.getNameDraw() == nameDraw)
|
|
|
|
{
|
|
|
|
id = tool.getId();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (id == 0)
|
|
|
|
{
|
|
|
|
const VToolRecord tool = history.at(history.size()-1);
|
|
|
|
id = tool.getId();
|
|
|
|
if (id == 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tools.size() > 0)
|
|
|
|
{
|
|
|
|
const VDataTool *vTool = tools.value(id);
|
|
|
|
data->setData(vTool->getData());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void VPattern::AddTool(const quint32 &id, VDataTool *tool)
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
|
|
|
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
|
|
|
Q_CHECK_PTR(tool);
|
|
|
|
tools.insert(id, tool);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void VPattern::UpdateToolData(const quint32 &id, VContainer *data)
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
|
|
|
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
|
|
|
Q_CHECK_PTR(data);
|
|
|
|
VDataTool *tool = tools.value(id);
|
|
|
|
Q_CHECK_PTR(tool);
|
|
|
|
tool->VDataTool::setData(data);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void VPattern::IncrementReferens(quint32 id) const
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
|
|
|
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
|
|
|
VDataTool *tool = tools.value(id);
|
|
|
|
Q_CHECK_PTR(tool);
|
|
|
|
tool->incrementReferens();
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void VPattern::DecrementReferens(quint32 id) const
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
|
|
|
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
|
|
|
VDataTool *tool = tools.value(id);
|
|
|
|
Q_CHECK_PTR(tool);
|
|
|
|
tool->decrementReferens();
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::TestUniqueId() const
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
QVector<quint32> vector;
|
2014-02-25 15:02:09 +01:00
|
|
|
CollectId(documentElement(), vector);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
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)
|
|
|
|
{
|
|
|
|
if (domElement.tagName() == VToolPoint::TagName &&
|
2014-02-25 19:03:17 +01:00
|
|
|
domElement.attribute(AttrType, "") == VToolSinglePoint::ToolType)
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
|
|
|
return GetParametrId(domElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
bool VPattern::CheckNameDraw(const QString &name) const
|
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, "CheckNameDraw", "name draw is empty");
|
|
|
|
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw );
|
|
|
|
if (elements.size() == 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for ( qint32 i = 0; i < elements.count(); i++ )
|
|
|
|
{
|
|
|
|
const QDomElement elem = elements.at( i ).toElement();
|
|
|
|
if (elem.isNull() == false)
|
|
|
|
{
|
|
|
|
if ( GetParametrString(elem, AttrName) == name )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::SetActivDraw(const QString &name)
|
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, "SetActivDraw", "name draw is empty");
|
|
|
|
this->nameActivDraw = name;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
bool VPattern::GetActivNodeElement(const QString &name, QDomElement &element)
|
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, "GetActivNodeElement", "name draw is empty");
|
|
|
|
QDomElement drawElement;
|
|
|
|
if (GetActivDrawElement(drawElement))
|
|
|
|
{
|
|
|
|
const QDomNodeList listElement = drawElement.elementsByTagName(name);
|
|
|
|
if (listElement.size() != 1)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
element = listElement.at( 0 ).toElement();
|
|
|
|
if (element.isNull() == false)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-21 11:08:29 +01:00
|
|
|
QString VPattern::MPath() const
|
|
|
|
{
|
2014-03-24 16:02:57 +01:00
|
|
|
QDomNodeList list = elementsByTagName(TagMeasurements);
|
2014-03-21 11:08:29 +01:00
|
|
|
QDomElement element = list.at(0).toElement();
|
|
|
|
if (element.isElement())
|
|
|
|
{
|
|
|
|
return GetParametrString(element, AttrPath);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-24 16:02:57 +01:00
|
|
|
void VPattern::SetPath(const QString &path)
|
|
|
|
{
|
2014-03-26 05:39:07 +01:00
|
|
|
if (path.isEmpty())
|
|
|
|
{
|
2014-03-28 14:11:46 +01:00
|
|
|
qDebug()<<"Path to measurements is empty"<<Q_FUNC_INFO;
|
2014-03-26 05:39:07 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-03-24 16:02:57 +01:00
|
|
|
QDomNodeList list = elementsByTagName(TagMeasurements);
|
|
|
|
QDomElement element = list.at(0).toElement();
|
|
|
|
if (element.isElement())
|
|
|
|
{
|
|
|
|
SetAttribute(element, AttrPath, path);
|
2014-03-26 05:39:07 +01:00
|
|
|
emit patternChanged();
|
2014-03-24 16:02:57 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-28 14:11:46 +01:00
|
|
|
qDebug()<<"Can't save path to measurements"<<Q_FUNC_INFO;
|
2014-03-24 16:02:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-21 11:08:29 +01:00
|
|
|
Valentina::Units VPattern::MUnit() const
|
|
|
|
{
|
|
|
|
QDomNodeList list = elementsByTagName(VPattern::TagMeasurements);
|
|
|
|
QDomElement element = list.at(0).toElement();
|
|
|
|
if (element.isElement())
|
|
|
|
{
|
|
|
|
QStringList units;
|
2014-03-24 16:02:57 +01:00
|
|
|
units << "mm" << "cm" << "inch";
|
2014-03-21 11:08:29 +01:00
|
|
|
QString unit = GetParametrString(element, AttrUnit);
|
2014-05-01 13:33:40 +02:00
|
|
|
switch (units.indexOf(unit))
|
2014-03-21 11:08:29 +01:00
|
|
|
{
|
|
|
|
case 0:// mm
|
|
|
|
return Valentina::Mm;
|
|
|
|
break;
|
|
|
|
case 1:// cm
|
|
|
|
return Valentina::Cm;
|
|
|
|
break;
|
|
|
|
case 2:// in
|
2014-03-24 16:02:57 +01:00
|
|
|
return Valentina::Inch;
|
2014-03-21 11:08:29 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return Valentina::Cm;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return Valentina::Cm;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-21 11:08:29 +01:00
|
|
|
Pattern::Measurements VPattern::MType() const
|
|
|
|
{
|
|
|
|
QDomNodeList list = elementsByTagName(VPattern::TagMeasurements);
|
|
|
|
QDomElement element = list.at(0).toElement();
|
|
|
|
if (element.isElement())
|
|
|
|
{
|
|
|
|
QString type = GetParametrString(element, AttrType);
|
|
|
|
QStringList types;
|
|
|
|
types << "standard" << "individual";
|
2014-05-01 13:33:40 +02:00
|
|
|
switch (types.indexOf(type))
|
2014-03-21 11:08:29 +01:00
|
|
|
{
|
|
|
|
case 0:// standard
|
|
|
|
return Pattern::Standard;
|
|
|
|
break;
|
|
|
|
case 1:// individual
|
|
|
|
return Pattern::Individual;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return Pattern::Individual;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return Pattern::Individual;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-28 14:11:46 +01:00
|
|
|
bool VPattern::SaveDocument(const QString &fileName)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
TestUniqueId();
|
|
|
|
}
|
|
|
|
catch (const VExceptionWrongId &e)
|
|
|
|
{
|
|
|
|
e.CriticalMessageBox(tr("Error no unique id."));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return VDomDocument::SaveDocument(fileName);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::FullUpdateTree()
|
|
|
|
{
|
|
|
|
VMainGraphicsScene *scene = new VMainGraphicsScene();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Parse(Document::LiteParse, scene, scene);
|
|
|
|
}
|
|
|
|
catch (const std::bad_alloc &)
|
|
|
|
{
|
|
|
|
delete scene;
|
|
|
|
QMessageBox msgBox;
|
|
|
|
msgBox.setWindowTitle(tr("Error!"));
|
|
|
|
msgBox.setText(tr("Error parsing file."));
|
|
|
|
msgBox.setInformativeText("std::bad_alloc");
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
|
|
|
msgBox.setIcon(QMessageBox::Warning);
|
|
|
|
msgBox.exec();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
delete scene;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete scene;
|
|
|
|
setCurrentData();
|
|
|
|
emit FullUpdateFromFile();
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::haveLiteChange()
|
|
|
|
{
|
|
|
|
patternModified = true;
|
|
|
|
emit patternChanged();
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void VPattern::ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable)
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
|
|
|
emit ShowTool(id, color, enable);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, const QDomNode &node,
|
|
|
|
const Document::Documents &parse)
|
|
|
|
{
|
|
|
|
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
|
|
|
QStringList tags;
|
|
|
|
tags << TagCalculation << TagModeling << TagDetails;
|
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
|
|
|
|
data->ClearCalculationGObjects();
|
2014-03-11 12:43:24 +01:00
|
|
|
ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Valentina::Calculation);
|
2014-02-25 19:03:17 +01:00
|
|
|
break;
|
|
|
|
case 1: // TagModeling
|
2014-03-11 12:43:24 +01:00
|
|
|
ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Valentina::Modeling);
|
2014-02-25 19:03:17 +01:00
|
|
|
break;
|
|
|
|
case 2: // TagDetails
|
|
|
|
ParseDetails(sceneDetail, domElement, parse);
|
|
|
|
break;
|
|
|
|
default:
|
2014-03-28 14:11:46 +01:00
|
|
|
qDebug()<<"Wrong tag name"<<Q_FUNC_INFO;
|
2014-02-25 19:03:17 +01:00
|
|
|
break;
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
domNode = domNode.nextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, const QDomNode &node,
|
2014-03-11 12:43:24 +01:00
|
|
|
const Document::Documents &parse, const Valentina::Draws &mode)
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
|
|
|
Q_CHECK_PTR(sceneDraw);
|
|
|
|
Q_CHECK_PTR(sceneDetail);
|
2014-03-10 17:22:55 +01:00
|
|
|
VMainGraphicsScene *scene = nullptr;
|
2014-03-11 12:43:24 +01:00
|
|
|
if (mode == Valentina::Calculation)
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
|
|
|
scene = sceneDraw;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scene = sceneDetail;
|
|
|
|
}
|
|
|
|
const QDomNodeList nodeList = node.childNodes();
|
|
|
|
const qint32 num = nodeList.size();
|
|
|
|
for (qint32 i = 0; i < num; ++i)
|
|
|
|
{
|
|
|
|
const QDomElement domElement = nodeList.at(i).toElement();
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
{
|
2014-02-25 19:03:17 +01:00
|
|
|
QStringList tags;
|
|
|
|
tags << TagPoint << TagLine << TagSpline << TagArc << TagTools;
|
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
|
|
|
|
ParsePointElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
|
|
|
break;
|
|
|
|
case 1: // TagLine
|
|
|
|
ParseLineElement(scene, domElement, parse);
|
|
|
|
break;
|
|
|
|
case 2: // TagSpline
|
|
|
|
ParseSplineElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
|
|
|
break;
|
|
|
|
case 3: // TagArc
|
|
|
|
ParseArcElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
|
|
|
break;
|
|
|
|
case 4: // TagTools
|
|
|
|
ParseToolsElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
|
|
|
|
break;
|
|
|
|
default:
|
2014-03-28 14:11:46 +01:00
|
|
|
qDebug()<<"Wrong tag name"<<Q_FUNC_INFO;
|
2014-02-25 19:03:17 +01:00
|
|
|
break;
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
|
|
|
|
const Document::Documents &parse)
|
|
|
|
{
|
|
|
|
Q_CHECK_PTR(sceneDetail);
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
try
|
|
|
|
{
|
|
|
|
VDetail detail;
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
detail.setName(GetParametrString(domElement, VAbstractTool::AttrName, ""));
|
2014-03-19 19:27:11 +01:00
|
|
|
detail.setMx(qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0")));
|
|
|
|
detail.setMy(qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0")));
|
2014-02-25 15:40:24 +01:00
|
|
|
detail.setSeamAllowance(GetParametrUInt(domElement, VToolDetail::AttrSupplement, "1"));
|
2014-02-25 15:02:09 +01:00
|
|
|
detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0"));
|
2014-02-25 15:40:24 +01:00
|
|
|
detail.setClosed(GetParametrUInt(domElement, VToolDetail::AttrClosed, "1"));
|
2014-02-25 15:02:09 +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 (element.isNull() == false)
|
|
|
|
{
|
|
|
|
if (element.tagName() == VToolDetail::TagNode)
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrUInt(element, VToolDetail::AttrIdObject, "0");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(element, VAbstractTool::AttrMx, "0.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(element, VAbstractTool::AttrMy, "0.0"));
|
2014-02-25 15:02:09 +01:00
|
|
|
const NodeDetail::NodeDetails nodeType = NodeDetail::Contour;
|
2014-02-25 19:03:17 +01:00
|
|
|
|
|
|
|
const QString t = GetParametrString(element, AttrType, "NodePoint");
|
2014-03-11 12:43:24 +01:00
|
|
|
Valentina::Tools tool;
|
2014-02-25 19:03:17 +01:00
|
|
|
QStringList types;
|
|
|
|
types << VToolDetail::NodePoint << VToolDetail::NodeArc << VToolDetail::NodeSpline <<
|
|
|
|
VToolDetail::NodeSplinePath;
|
2014-02-26 10:51:37 +01:00
|
|
|
switch (types.indexOf(t))
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
2014-02-25 19:03:17 +01:00
|
|
|
case 0: // VToolDetail::NodePoint
|
2014-03-11 12:43:24 +01:00
|
|
|
tool = Valentina::NodePoint;
|
2014-02-25 19:03:17 +01:00
|
|
|
break;
|
|
|
|
case 1: // VToolDetail::NodeArc
|
2014-03-11 12:43:24 +01:00
|
|
|
tool = Valentina::NodeArc;
|
2014-02-25 19:03:17 +01:00
|
|
|
break;
|
|
|
|
case 2: // VToolDetail::NodeSpline
|
2014-03-11 12:43:24 +01:00
|
|
|
tool = Valentina::NodeSpline;
|
2014-02-25 19:03:17 +01:00
|
|
|
break;
|
|
|
|
case 3: // VToolDetail::NodeSplinePath
|
2014-03-11 12:43:24 +01:00
|
|
|
tool = Valentina::NodeSplinePath;
|
2014-02-25 19:03:17 +01:00
|
|
|
break;
|
|
|
|
default:
|
2014-03-28 14:11:46 +01:00
|
|
|
qDebug()<<"Wrong node type."<<Q_FUNC_INFO;
|
2014-02-25 19:03:17 +01:00
|
|
|
break;
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
detail.append(VNodeDetail(id, tool, nodeType, mx, my));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-11 12:43:24 +01:00
|
|
|
VToolDetail::Create(id, detail, sceneDetail, this, data, parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating detail"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
|
|
|
|
const Document::Documents &parse)
|
|
|
|
{
|
|
|
|
Q_CHECK_PTR(sceneDetail);
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
QDomNode domNode = domElement.firstChild();
|
|
|
|
while (domNode.isNull() == false)
|
|
|
|
{
|
|
|
|
if (domNode.isElement())
|
|
|
|
{
|
|
|
|
const QDomElement domElement = domNode.toElement();
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
{
|
|
|
|
if (domElement.tagName() == VToolDetail::TagName)
|
|
|
|
{
|
|
|
|
ParseDetailElement(sceneDetail, domElement, parse);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
domNode = domNode.nextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
|
|
|
const Document::Documents &parse, const QString &type)
|
|
|
|
{
|
|
|
|
Q_CHECK_PTR(scene);
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of point is empty");
|
|
|
|
|
|
|
|
|
|
|
|
QStringList points;
|
|
|
|
points << VToolSinglePoint::ToolType << VToolEndLine::ToolType << VToolAlongLine::ToolType
|
|
|
|
<< VToolShoulderPoint::ToolType << VToolNormal::ToolType << VToolBisector::ToolType
|
|
|
|
<< VToolLineIntersect::ToolType << VToolPointOfContact::ToolType << VNodePoint::ToolType
|
|
|
|
<< VToolHeight::ToolType << VToolTriangle::ToolType << VToolPointOfIntersection::ToolType
|
|
|
|
<< VToolCutSpline::ToolType << VToolCutSplinePath::ToolType << VToolCutArc::ToolType;
|
2014-02-26 10:51:37 +01:00
|
|
|
switch (points.indexOf(type))
|
|
|
|
{
|
2014-02-25 15:02:09 +01:00
|
|
|
case 0: //VToolSinglePoint::ToolType
|
|
|
|
{
|
|
|
|
VToolSinglePoint *spoint = 0;
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "A");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal x = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrX, "10.0"));
|
|
|
|
const qreal y = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrY, "10.0"));
|
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
|
|
data->UpdateGObject(id, new VPointF(x, y, name, mx, my));
|
2014-03-11 12:43:24 +01:00
|
|
|
VDrawTool::AddRecord(id, Valentina::SinglePointTool, this);
|
2014-02-25 15:02:09 +01:00
|
|
|
if (parse != Document::FullParse)
|
|
|
|
{
|
|
|
|
UpdateToolData(id, data);
|
|
|
|
}
|
|
|
|
if (parse == Document::FullParse)
|
|
|
|
{
|
2014-03-11 12:43:24 +01:00
|
|
|
spoint = new VToolSinglePoint(this, data, id, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
scene->addItem(spoint);
|
|
|
|
connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
|
|
connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
|
|
|
|
tools[id] = spoint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1: //VToolEndLine::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
|
|
|
VAbstractTool::TypeLineLine);
|
|
|
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0");
|
|
|
|
|
|
|
|
VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId,
|
2014-03-11 12:43:24 +01:00
|
|
|
mx, my, scene, this, data, parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: //VToolAlongLine::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
|
|
|
VAbstractTool::TypeLineLine);
|
|
|
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
|
|
VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my, scene, this,
|
2014-03-11 12:43:24 +01:00
|
|
|
data, parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3: //VToolShoulderPoint::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
|
|
|
VAbstractTool::TypeLineLine);
|
|
|
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 p1Line = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
|
|
|
|
const quint32 p2Line = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0");
|
|
|
|
const quint32 pShoulder = GetParametrUInt(domElement, VAbstractTool::AttrPShoulder, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
|
|
VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this,
|
2014-03-11 12:43:24 +01:00
|
|
|
data, parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4: //VToolNormal::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
|
|
|
VAbstractTool::TypeLineLine);
|
|
|
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0");
|
|
|
|
|
2014-02-26 10:51:37 +01:00
|
|
|
VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene,
|
2014-03-11 12:43:24 +01:00
|
|
|
this, data, parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5: //VToolBisector::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
|
|
|
VAbstractTool::TypeLineLine);
|
|
|
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
|
|
|
const quint32 thirdPointId = GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
|
|
VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId,
|
2014-03-11 12:43:24 +01:00
|
|
|
typeLine, name, mx, my, scene, this, data, parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 6: //VToolLineIntersect::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 p1Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, "0");
|
|
|
|
const quint32 p2Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, "0");
|
|
|
|
const quint32 p1Line2Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line2, "0");
|
|
|
|
const quint32 p2Line2Id = GetParametrUInt(domElement, VAbstractTool::AttrP2Line2, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
|
|
VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name,
|
2014-03-11 12:43:24 +01:00
|
|
|
mx, my, scene, this, data, parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of lineintersection"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 7: //VToolPointOfContact::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "0");
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
|
|
|
|
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
2014-02-26 10:51:37 +01:00
|
|
|
VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my, scene, this,
|
2014-03-11 12:43:24 +01:00
|
|
|
data, parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 8: //VNodePoint::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
|
|
|
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
|
|
|
|
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
const VPointF *point = data->GeometricObject<const VPointF *>(idObject );
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-26 10:51:37 +01:00
|
|
|
data->UpdateGObject(id, new VPointF(point->x(), point->y(), point->name(), mx, my, idObject,
|
2014-03-11 12:43:24 +01:00
|
|
|
Valentina::Modeling));
|
|
|
|
VNodePoint::Create(this, data, id, idObject, parse, Valentina::FromFile, idTool);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating modeling point"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 9: //VToolHeight::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
|
|
|
VAbstractTool::TypeLineLine);
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
|
|
|
|
const quint32 p1LineId = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
|
|
|
|
const quint32 p2LineId = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
|
|
VToolHeight::Create(id, name, typeLine, basePointId, p1LineId, p2LineId,
|
2014-03-11 12:43:24 +01:00
|
|
|
mx, my, scene, this, data, parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating height"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 10: //VToolTriangle::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 axisP1Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, "0");
|
|
|
|
const quint32 axisP2Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, "0");
|
|
|
|
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
|
|
VToolTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my, scene, this,
|
2014-03-11 12:43:24 +01:00
|
|
|
data, parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating triangle"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 11: //VToolPointOfIntersection::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
2014-02-26 10:51:37 +01:00
|
|
|
VToolPointOfIntersection::Create(id, name, firstPointId, secondPointId, mx, my, scene, this, data,
|
2014-03-11 12:43:24 +01:00
|
|
|
parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of intersection"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 12: //VToolCutSpline::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
2014-05-01 13:33:40 +02:00
|
|
|
VToolCutSpline::Create(id, name, formula, splineId, mx, my, scene, this, data, parse,
|
|
|
|
Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 13: //VToolCutSplinePath::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
|
|
VToolCutSplinePath::Create(id, name, formula, splinePathId, mx, my,
|
2014-03-11 12:43:24 +01:00
|
|
|
scene, this, data, parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 14: //VToolCutArc::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
2014-03-19 19:27:11 +01:00
|
|
|
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 arcId = GetParametrUInt(domElement, VToolCutArc::AttrArc, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
2014-03-11 12:43:24 +01:00
|
|
|
VToolCutArc::Create(id, name, formula, arcId, mx, my, scene, this, data, parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating cut arc point"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2014-03-28 14:11:46 +01:00
|
|
|
qDebug() << "Illegal point type in VDomDocument::ParsePointElement().";
|
2014-02-25 15:02:09 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 19:03:17 +01:00
|
|
|
void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
|
|
|
const Document::Documents &parse)
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
|
|
|
Q_CHECK_PTR(scene);
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
|
|
|
const quint32 firstPoint = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
const quint32 secondPoint = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
|
2014-02-25 19:03:17 +01:00
|
|
|
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
|
|
|
|
VAbstractTool::TypeLineLine);
|
2014-02-25 15:02:09 +01:00
|
|
|
|
2014-03-11 12:43:24 +01:00
|
|
|
VToolLine::Create(id, firstPoint, secondPoint, typeLine, scene, this, data, parse, Valentina::FromFile);
|
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-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
|
|
|
const Document::Documents &parse, const QString &type)
|
|
|
|
{
|
|
|
|
Q_CHECK_PTR(scene);
|
|
|
|
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");
|
|
|
|
|
|
|
|
QStringList splines;
|
|
|
|
splines << VToolSpline::ToolType << VToolSplinePath::ToolType << VNodeSpline::ToolType << VNodeSplinePath::ToolType;
|
2014-02-26 10:51:37 +01:00
|
|
|
switch (splines.indexOf(type))
|
|
|
|
{
|
2014-02-25 15:02:09 +01:00
|
|
|
case 0: //VToolSpline::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
|
|
|
const quint32 point1 = GetParametrUInt(domElement, VAbstractTool::AttrPoint1, "0");
|
|
|
|
const quint32 point4 = GetParametrUInt(domElement, VAbstractTool::AttrPoint4, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
const qreal angle1 = GetParametrDouble(domElement, VAbstractTool::AttrAngle1, "270.0");
|
|
|
|
const qreal angle2 = GetParametrDouble(domElement, VAbstractTool::AttrAngle2, "90.0");
|
|
|
|
const qreal kAsm1 = GetParametrDouble(domElement, VAbstractTool::AttrKAsm1, "1.0");
|
|
|
|
const qreal kAsm2 = GetParametrDouble(domElement, VAbstractTool::AttrKAsm2, "1.0");
|
|
|
|
const qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0");
|
|
|
|
|
|
|
|
VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this, data, parse,
|
2014-03-11 12:43:24 +01:00
|
|
|
Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating simple curve"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1: //VToolSplinePath::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
2014-02-25 15:02:09 +01:00
|
|
|
const qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0");
|
|
|
|
VSplinePath *path = new VSplinePath(kCurve);
|
|
|
|
|
|
|
|
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() == VAbstractTool::AttrPathPoint)
|
|
|
|
{
|
|
|
|
const qreal kAsm1 = GetParametrDouble(element, VAbstractTool::AttrKAsm1, "1.0");
|
|
|
|
const qreal angle = GetParametrDouble(element, VAbstractTool::AttrAngle, "0");
|
|
|
|
const qreal kAsm2 = GetParametrDouble(element, VAbstractTool::AttrKAsm2, "1.0");
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 pSpline = GetParametrUInt(element, VAbstractTool::AttrPSpline, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
const VPointF p = *data->GeometricObject<const VPointF *>(pSpline);
|
|
|
|
|
|
|
|
QLineF line(0, 0, 100, 0);
|
|
|
|
line.setAngle(angle+180);
|
|
|
|
|
|
|
|
VSplinePoint splPoint(p, kAsm1, line.angle(), kAsm2, angle);
|
|
|
|
path->append(splPoint);
|
|
|
|
if (parse == Document::FullParse)
|
|
|
|
{
|
|
|
|
IncrementReferens(pSpline);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-11 12:43:24 +01:00
|
|
|
VToolSplinePath::Create(id, path, scene, this, data, parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating curve path"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: //VNodeSpline::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
|
|
|
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
|
|
|
|
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
VSpline *spl = new VSpline(*data->GeometricObject<const VSpline *>(idObject));
|
|
|
|
spl->setIdObject(idObject);
|
2014-03-11 12:43:24 +01:00
|
|
|
spl->setMode(Valentina::Modeling);
|
2014-02-25 15:02:09 +01:00
|
|
|
data->UpdateGObject(id, spl);
|
2014-03-11 12:43:24 +01:00
|
|
|
VNodeSpline::Create(this, data, id, idObject, parse, Valentina::FromFile, idTool);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating modeling simple curve"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3: //VNodeSplinePath::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
|
|
|
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
|
|
|
|
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
VSplinePath *path = new VSplinePath(*data->GeometricObject<const VSplinePath *>(idObject));
|
|
|
|
path->setIdObject(idObject);
|
2014-03-11 12:43:24 +01:00
|
|
|
path->setMode(Valentina::Modeling);
|
2014-02-25 15:02:09 +01:00
|
|
|
data->UpdateGObject(id, path);
|
2014-03-11 12:43:24 +01:00
|
|
|
VNodeSplinePath::Create(this, data, id, idObject, parse, Valentina::FromFile, idTool);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating modeling curve path"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2014-03-28 14:11:46 +01:00
|
|
|
qDebug() << "Illegal spline type in VDomDocument::ParseSplineElement().";
|
2014-02-25 15:02:09 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
|
|
|
const Document::Documents &parse, const QString &type)
|
|
|
|
{
|
|
|
|
Q_CHECK_PTR(scene);
|
|
|
|
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");
|
|
|
|
|
|
|
|
QStringList arcs;
|
|
|
|
arcs << VToolArc::ToolType << VNodeArc::ToolType;
|
|
|
|
|
2014-02-26 10:51:37 +01:00
|
|
|
switch (arcs.indexOf(type))
|
|
|
|
{
|
2014-02-25 15:02:09 +01:00
|
|
|
case 0: //VToolArc::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
|
|
|
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "10");
|
|
|
|
const QString f1 = GetParametrString(domElement, VAbstractTool::AttrAngle1, "180");
|
|
|
|
const QString f2 = GetParametrString(domElement, VAbstractTool::AttrAngle2, "270");
|
|
|
|
|
2014-03-11 12:43:24 +01:00
|
|
|
VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Valentina::FromFile);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1: //VNodeArc::ToolType
|
|
|
|
try
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
|
|
|
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
|
|
|
|
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
|
2014-02-25 15:02:09 +01:00
|
|
|
VArc *arc = new VArc(*data->GeometricObject<const VArc *>(idObject));
|
|
|
|
arc->setIdObject(idObject);
|
2014-03-11 12:43:24 +01:00
|
|
|
arc->setMode(Valentina::Modeling);
|
2014-02-25 15:02:09 +01:00
|
|
|
data->UpdateGObject(id, arc);
|
2014-03-11 12:43:24 +01:00
|
|
|
VNodeArc::Create(this, data, id, idObject, parse, Valentina::FromFile, idTool);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating modeling arc"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2014-03-28 14:11:46 +01:00
|
|
|
qDebug() << "Illegal arc type in VDomDocument::ParseArcElement().";
|
2014-02-25 15:02:09 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
|
|
|
const Document::Documents &parse, const QString &type)
|
|
|
|
{
|
|
|
|
Q_CHECK_PTR(scene);
|
|
|
|
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");
|
|
|
|
|
|
|
|
QStringList tools;
|
|
|
|
tools << 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
|
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
|
|
|
const quint32 indexD1 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD1, "-1");
|
|
|
|
const quint32 indexD2 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD2, "-1");
|
2014-02-25 15:02:09 +01:00
|
|
|
|
|
|
|
const QVector<VDetail> vector = VToolUnionDetails::GetDetailFromFile(this, domElement);
|
|
|
|
|
|
|
|
VToolUnionDetails::Create(id, vector[0], vector[1], 0, 0, indexD1, indexD2, scene, this, data, parse,
|
2014-03-11 12:43:24 +01:00
|
|
|
Valentina::FromFile);
|
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:
|
2014-03-28 14:11:46 +01:00
|
|
|
qDebug() << "Illegal tools type in VDomDocument::ParseToolsElement().";
|
2014-02-25 15:02:09 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::ParseIncrementsElement(const QDomNode &node)
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2014-02-25 19:03:17 +01:00
|
|
|
const quint32 id = GetParametrId(domElement);
|
|
|
|
const QString name = GetParametrString(domElement, IncrementName, "");
|
|
|
|
const qreal base = GetParametrDouble(domElement, IncrementBase, "0");
|
|
|
|
const qreal ksize = GetParametrDouble(domElement, IncrementKsize, "0");
|
|
|
|
const qreal kgrowth = GetParametrDouble(domElement, IncrementKgrowth, "0");
|
|
|
|
const QString desc = GetParametrString(domElement, IncrementDescription, "Description");
|
2014-02-25 15:02:09 +01:00
|
|
|
data->UpdateId(id);
|
2014-03-19 19:27:11 +01:00
|
|
|
data->AddIncrement(name, VIncrement(id, base, ksize, kgrowth, desc));
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
domNode = domNode.nextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
quint32 VPattern::GetParametrId(const QDomElement &domElement) const
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
2014-03-14 16:59:28 +01:00
|
|
|
|
|
|
|
quint32 id = 0;
|
|
|
|
|
|
|
|
QString message = tr("Got wrong parameter id. Need only id > 0.");
|
|
|
|
try
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
id = GetParametrUInt(domElement, VDomDocument::AttrId, "0");
|
2014-03-14 16:59:28 +01:00
|
|
|
if (id <= 0)
|
|
|
|
{
|
|
|
|
throw VExceptionWrongId(message, domElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const VExceptionConversionError &e)
|
|
|
|
{
|
|
|
|
VExceptionWrongId excep(message, domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:40:24 +01:00
|
|
|
void VPattern::CollectId(const QDomElement &node, QVector<quint32> &vector) const
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
if (node.hasAttribute(VDomDocument::AttrId))
|
2014-02-25 15:02:09 +01:00
|
|
|
{
|
2014-02-25 15:40:24 +01:00
|
|
|
const quint32 id = GetParametrId(node);
|
2014-02-25 15:02:09 +01:00
|
|
|
if (vector.contains(id))
|
|
|
|
{
|
2014-03-03 18:32:38 +01:00
|
|
|
throw VExceptionWrongId(tr("This id is not unique."), node);
|
2014-02-25 15:02:09 +01:00
|
|
|
}
|
|
|
|
vector.append(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (qint32 i=0; i<node.childNodes().length(); ++i)
|
|
|
|
{
|
|
|
|
const QDomNode n = node.childNodes().at(i);
|
|
|
|
if (n.isElement())
|
|
|
|
{
|
|
|
|
CollectId(n.toElement(), vector);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-02-25 15:02:09 +01:00
|
|
|
void VPattern::PrepareForParse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw,
|
|
|
|
VMainGraphicsScene *sceneDetail)
|
|
|
|
{
|
|
|
|
Q_CHECK_PTR(sceneDraw);
|
|
|
|
Q_CHECK_PTR(sceneDetail);
|
|
|
|
if (parse == Document::FullParse)
|
|
|
|
{
|
|
|
|
TestUniqueId();
|
|
|
|
data->Clear();
|
2014-03-24 16:02:57 +01:00
|
|
|
UpdateMeasurements();
|
2014-02-25 15:02:09 +01:00
|
|
|
nameActivDraw.clear();
|
|
|
|
sceneDraw->clear();
|
|
|
|
sceneDetail->clear();
|
|
|
|
comboBoxDraws->clear();
|
|
|
|
tools.clear();
|
|
|
|
cursor = 0;
|
|
|
|
}
|
|
|
|
data->ClearLengthLines();
|
|
|
|
data->ClearLengthArcs();
|
|
|
|
data->ClearLengthSplines();
|
|
|
|
data->ClearLineAngles();
|
|
|
|
data->ClearDetails();
|
|
|
|
history.clear();
|
|
|
|
}
|
2014-03-24 16:02:57 +01:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-24 16:02:57 +01:00
|
|
|
void VPattern::UpdateMeasurements()
|
|
|
|
{
|
|
|
|
const QString path = MPath();
|
|
|
|
if (MType() == Pattern::Standard)
|
|
|
|
{
|
|
|
|
VStandardMeasurements m(data);
|
|
|
|
m.setContent(path);
|
|
|
|
m.Measurements();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
VIndividualMeasurements m(data);
|
|
|
|
m.setContent(path);
|
|
|
|
m.Measurements();
|
|
|
|
}
|
|
|
|
}
|