2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file vdomdocument.cpp
|
2013-11-15 13:41:26 +01:00
|
|
|
** @author Roman Telezhinsky <dismine@gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
** @date November 15, 2013
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** @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.
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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.
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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/>.
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
*************************************************************************/
|
2013-09-18 21:16:19 +02:00
|
|
|
|
2013-07-13 12:51:31 +02:00
|
|
|
#include "vdomdocument.h"
|
2013-11-06 16:49:07 +01:00
|
|
|
#include "../exception/vexceptionwrongparameterid.h"
|
|
|
|
#include "../exception/vexceptionconversionerror.h"
|
|
|
|
#include "../exception/vexceptionemptyparameter.h"
|
|
|
|
#include "../exception/vexceptionuniqueid.h"
|
|
|
|
#include "../exception/vexceptionobjecterror.h"
|
|
|
|
#include "../exception/vexceptionbadid.h"
|
2013-12-18 12:13:32 +01:00
|
|
|
#include "../tools/vtooldetail.h"
|
2013-12-29 17:48:57 +01:00
|
|
|
#include "../tools/vtooluniondetails.h"
|
2013-11-06 16:49:07 +01:00
|
|
|
#include "../tools/drawTools/drawtools.h"
|
2013-12-18 12:13:32 +01:00
|
|
|
#include "../tools/nodeDetails/nodedetails.h"
|
2013-08-13 18:48:36 +02:00
|
|
|
|
2013-11-21 13:05:26 +01:00
|
|
|
#include <QMessageBox>
|
|
|
|
|
2014-01-02 16:50:01 +01:00
|
|
|
VDomDocument::VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode, QObject *parent)
|
|
|
|
: QObject(parent), QDomDocument(), map(QHash<QString, QDomElement>()), nameActivDraw(QString()), data(data),
|
2013-10-04 13:32:42 +02:00
|
|
|
tools(QHash<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0),
|
2013-11-04 21:35:15 +01:00
|
|
|
comboBoxDraws(comboBoxDraws), mode(mode){}
|
2013-07-13 12:51:31 +02:00
|
|
|
|
2014-01-02 16:50:01 +01:00
|
|
|
VDomDocument::VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode,
|
|
|
|
QObject *parent)
|
|
|
|
:QObject(parent), QDomDocument(name), map(QHash<QString, QDomElement>()), nameActivDraw(QString()), data(data),
|
2013-10-04 13:32:42 +02:00
|
|
|
tools(QHash<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0),
|
2013-11-04 21:35:15 +01:00
|
|
|
comboBoxDraws(comboBoxDraws), mode(mode){}
|
2013-07-13 12:51:31 +02:00
|
|
|
|
2013-08-29 12:31:50 +02:00
|
|
|
VDomDocument::VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws,
|
2014-01-02 16:50:01 +01:00
|
|
|
Draw::Draws *mode, QObject *parent)
|
|
|
|
:QObject(parent), QDomDocument(doctype), map(QHash<QString, QDomElement>()), nameActivDraw(QString()), data(data),
|
2013-10-04 13:32:42 +02:00
|
|
|
tools(QHash<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0),
|
2013-11-04 21:35:15 +01:00
|
|
|
comboBoxDraws(comboBoxDraws), mode(mode){}
|
2013-07-13 12:51:31 +02:00
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
QDomElement VDomDocument::elementById(const QString& id)
|
|
|
|
{
|
|
|
|
if (map.contains(id))
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomElement e = map[id];
|
2013-11-04 21:35:15 +01:00
|
|
|
if (e.parentNode().nodeType() != QDomNode::BaseNode)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return e;
|
|
|
|
}
|
|
|
|
map.remove(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool res = this->find(this->documentElement(), id);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (res)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return map[id];
|
|
|
|
}
|
|
|
|
|
|
|
|
return QDomElement();
|
|
|
|
}
|
|
|
|
|
2014-01-02 16:50:01 +01:00
|
|
|
void VDomDocument::removeAllChilds(QDomElement &element)
|
|
|
|
{
|
|
|
|
QDomNode domNode = element.firstChild();
|
|
|
|
while (domNode.isNull() == false)
|
|
|
|
{
|
|
|
|
if (domNode.isElement())
|
|
|
|
{
|
|
|
|
QDomElement domElement = domNode.toElement();
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
{
|
|
|
|
element.removeChild(domElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
domNode = element.firstChild();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 22:11:12 +01:00
|
|
|
bool VDomDocument::find(const QDomElement &node, const QString& id)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
if (node.hasAttribute("id"))
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
QString value = node.attribute("id");
|
|
|
|
this->map[value] = node;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (value == id)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i=0; i<node.childNodes().length(); ++i)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomNode n = node.childNodes().at(i);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (n.isElement())
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
bool res = this->find(n.toElement(), id);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (res)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VDomDocument::CreateEmptyFile()
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomElement domElement = this->createElement("lekalo");
|
|
|
|
this->appendChild(domElement);
|
|
|
|
QDomNode xmlNode = this->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");
|
|
|
|
this->insertBefore(xmlNode, this->firstChild());
|
2013-07-17 13:38:11 +02:00
|
|
|
QDomElement incrElement = this->createElement("increments");
|
|
|
|
domElement.appendChild(incrElement);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
bool VDomDocument::CheckNameDraw(const QString& name) const
|
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, "CheckNameDraw", "name draw is empty");
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomNodeList elements = this->documentElement().elementsByTagName( "draw" );
|
2013-11-04 21:35:15 +01:00
|
|
|
if (elements.size() == 0)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
for ( qint32 i = 0; i < elements.count(); i++ )
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomElement elem = elements.at( i ).toElement();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (elem.isNull() == false)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
QString fieldName = elem.attribute( "name" );
|
2013-11-04 21:35:15 +01:00
|
|
|
if ( fieldName == name )
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
bool VDomDocument::appendDraw(const QString& name)
|
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, "appendDraw", "name draw is empty");
|
|
|
|
if (name.isEmpty())
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (CheckNameDraw(name)== false)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomElement rootElement = this->documentElement();
|
|
|
|
|
|
|
|
QDomElement drawElement = this->createElement("draw");
|
|
|
|
QDomAttr drawAttr = this->createAttribute("name");
|
|
|
|
drawAttr.setValue(name);
|
|
|
|
drawElement.setAttributeNode(drawAttr);
|
|
|
|
|
|
|
|
QDomElement calculationElement = this->createElement("calculation");
|
|
|
|
QDomElement modelingElement = this->createElement("modeling");
|
2013-08-28 10:55:11 +02:00
|
|
|
QDomElement pathsElement = this->createElement("details");
|
2013-07-13 12:51:31 +02:00
|
|
|
drawElement.appendChild(calculationElement);
|
|
|
|
drawElement.appendChild(modelingElement);
|
|
|
|
drawElement.appendChild(pathsElement);
|
|
|
|
|
|
|
|
rootElement.appendChild(drawElement);
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
if (nameActivDraw.isEmpty())
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
SetActivDraw(name);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
ChangeActivDraw(name);
|
|
|
|
}
|
|
|
|
return true;
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-06 22:11:12 +01:00
|
|
|
void VDomDocument::ChangeActivDraw(const QString& name, const Document::Documents &parse)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, "ChangeActivDraw", "name draw is empty");
|
|
|
|
if (CheckNameDraw(name) == true)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
this->nameActivDraw = name;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (parse == Document::FullParse)
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
emit ChangedActivDraw(name);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
bool VDomDocument::SetNameDraw(const QString& name)
|
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, "SetNameDraw", "name draw is empty");
|
2013-07-13 12:51:31 +02:00
|
|
|
QString oldName = nameActivDraw;
|
2013-10-10 12:00:04 +02:00
|
|
|
QDomElement element;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (GetActivDrawElement(element))
|
|
|
|
{
|
2013-10-10 12:00:04 +02:00
|
|
|
nameActivDraw = name;
|
|
|
|
element.setAttribute("name", nameActivDraw);
|
|
|
|
emit haveChange();
|
|
|
|
emit ChangedNameDraw(oldName, nameActivDraw);
|
|
|
|
return true;
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-10 12:00:04 +02:00
|
|
|
qWarning()<<"Can't find activ draw"<<Q_FUNC_INFO;
|
|
|
|
return false;
|
|
|
|
}
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VDomDocument::SetActivDraw(const QString& name)
|
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, "SetActivDraw", "name draw is empty");
|
2013-07-13 12:51:31 +02:00
|
|
|
this->nameActivDraw = name;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
bool VDomDocument::GetActivDrawElement(QDomElement &element)
|
|
|
|
{
|
|
|
|
if (nameActivDraw.isEmpty() == false)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomNodeList elements = this->documentElement().elementsByTagName( "draw" );
|
2013-11-04 21:35:15 +01:00
|
|
|
if (elements.size() == 0)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
for ( qint32 i = 0; i < elements.count(); i++ )
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
element = elements.at( i ).toElement();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (element.isNull() == false)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
QString fieldName = element.attribute( "name" );
|
2013-11-04 21:35:15 +01:00
|
|
|
if ( fieldName == nameActivDraw )
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
bool VDomDocument::GetActivCalculationElement(QDomElement &element)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
bool ok = GetActivNodeElement("calculation", element);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (ok)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return true;
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
bool VDomDocument::GetActivModelingElement(QDomElement &element)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
bool ok = GetActivNodeElement("modeling", element);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (ok)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return true;
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
bool VDomDocument::GetActivDetailsElement(QDomElement &element)
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
bool ok = GetActivNodeElement("details", element);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (ok)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return true;
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
bool VDomDocument::GetActivNodeElement(const QString& name, QDomElement &element)
|
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, "GetActivNodeElement", "name draw is empty");
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomElement drawElement;
|
|
|
|
bool drawOk = this->GetActivDrawElement(drawElement);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (drawOk == true)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomNodeList listElement = drawElement.elementsByTagName(name);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (listElement.size() == 0 || listElement.size() > 1)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
element = listElement.at( 0 ).toElement();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (element.isNull() == false)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return true;
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 22:11:12 +01:00
|
|
|
void VDomDocument::Parse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw,
|
|
|
|
VMainGraphicsScene *sceneDetail)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
Q_ASSERT(sceneDraw != 0);
|
|
|
|
Q_ASSERT(sceneDetail != 0);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (parse == Document::FullParse)
|
|
|
|
{
|
2013-10-07 11:13:24 +02:00
|
|
|
TestUniqueId();
|
2013-07-13 12:51:31 +02:00
|
|
|
data->Clear();
|
2013-12-30 19:59:33 +01:00
|
|
|
data->CreateManTableIGroup();
|
2013-07-13 12:51:31 +02:00
|
|
|
nameActivDraw.clear();
|
2013-08-28 10:55:11 +02:00
|
|
|
sceneDraw->clear();
|
|
|
|
sceneDetail->clear();
|
2013-07-13 12:51:31 +02:00
|
|
|
comboBoxDraws->clear();
|
2013-08-13 18:48:36 +02:00
|
|
|
tools.clear();
|
2013-08-15 22:39:00 +02:00
|
|
|
cursor = 0;
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-08-15 22:39:00 +02:00
|
|
|
data->ClearLengthLines();
|
|
|
|
data->ClearLengthArcs();
|
|
|
|
data->ClearLengthSplines();
|
2013-08-21 10:03:53 +02:00
|
|
|
data->ClearLineAngles();
|
2013-08-15 22:39:00 +02:00
|
|
|
history.clear();
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomElement rootElement = this->documentElement();
|
|
|
|
QDomNode domNode = rootElement.firstChild();
|
2013-11-04 21:35:15 +01:00
|
|
|
while (domNode.isNull() == false)
|
|
|
|
{
|
|
|
|
if (domNode.isElement())
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomElement domElement = domNode.toElement();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.isNull() == false)
|
|
|
|
{
|
|
|
|
if (domElement.tagName()=="draw")
|
|
|
|
{
|
|
|
|
if (parse == Document::FullParse)
|
|
|
|
{
|
|
|
|
if (nameActivDraw.isEmpty())
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
SetActivDraw(domElement.attribute("name"));
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
ChangeActivDraw(domElement.attribute("name"));
|
|
|
|
}
|
2013-08-15 22:39:00 +02:00
|
|
|
comboBoxDraws->addItem(domElement.attribute("name"));
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
ChangeActivDraw(domElement.attribute("name"), Document::LiteParse);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-08-28 10:55:11 +02:00
|
|
|
ParseDrawElement(sceneDraw, sceneDetail, domElement, parse);
|
2013-07-17 13:38:11 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.tagName()=="increments")
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
ParseIncrementsElement(domElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
domNode = domNode.nextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
VDataTool *VDomDocument::getTool(const qint64 &id)
|
|
|
|
{
|
|
|
|
if (tools.contains(id))
|
|
|
|
{
|
|
|
|
return tools.value(id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QString error = QString(tr("Can't find tool id = %1 in table.")).arg(id);
|
|
|
|
throw VException(error);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VDomDocument::ParseIncrementsElement(const QDomNode &node)
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
QDomNode domNode = node.firstChild();
|
2013-11-04 21:35:15 +01:00
|
|
|
while (domNode.isNull() == false)
|
|
|
|
{
|
|
|
|
if (domNode.isElement())
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
QDomElement domElement = domNode.toElement();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.isNull() == false)
|
|
|
|
{
|
|
|
|
if (domElement.tagName() == "increment")
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
QString name = GetParametrString(domElement, "name", "");
|
|
|
|
qreal base = GetParametrDouble(domElement, "base", "0");
|
|
|
|
qreal ksize = GetParametrDouble(domElement, "ksize", "0");
|
|
|
|
qreal kgrowth = GetParametrDouble(domElement, "kgrowth", "0");
|
|
|
|
QString desc = GetParametrString(domElement, "description", "Description");
|
2013-08-13 18:48:36 +02:00
|
|
|
data->UpdateId(id);
|
2013-12-30 19:59:33 +01:00
|
|
|
data->AddIncrementTableRow(name, VIncrementTableRow(id, base, ksize, kgrowth, desc));
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
domNode = domNode.nextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
qint64 VDomDocument::GetParametrId(const QDomElement &domElement) const
|
|
|
|
{
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
2013-12-23 20:50:30 +01:00
|
|
|
qint64 id = GetParametrLongLong(domElement, "id", "0");
|
2013-11-04 21:35:15 +01:00
|
|
|
if (id <= 0)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
throw VExceptionWrongParameterId(tr("Got wrong parameter id. Need only id > 0."), domElement);
|
|
|
|
}
|
2013-09-11 16:14:21 +02:00
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2013-12-23 20:50:30 +01:00
|
|
|
qint64 VDomDocument::GetParametrLongLong(const QDomElement &domElement, const QString &name,
|
|
|
|
const QString &defValue) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty");
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
2013-09-11 16:14:21 +02:00
|
|
|
bool ok = false;
|
2013-12-23 20:50:30 +01:00
|
|
|
QString parametr = GetParametrString(domElement, name, defValue);
|
2013-09-11 16:14:21 +02:00
|
|
|
qint64 id = parametr.toLongLong(&ok);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (ok == false)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
throw VExceptionConversionError(tr("Can't convert toLongLong parameter"), name);
|
|
|
|
}
|
2013-09-11 16:14:21 +02:00
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2013-12-23 20:50:30 +01:00
|
|
|
QString VDomDocument::GetParametrString(const QDomElement &domElement, const QString &name,
|
|
|
|
const QString &defValue) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty");
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
2013-12-23 20:50:30 +01:00
|
|
|
QString parameter = domElement.attribute(name, defValue);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (parameter.isEmpty())
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
throw VExceptionEmptyParameter(tr("Got empty parameter"), name, domElement);
|
|
|
|
}
|
|
|
|
return parameter;
|
2013-09-11 16:14:21 +02:00
|
|
|
}
|
|
|
|
|
2013-12-23 20:50:30 +01:00
|
|
|
qreal VDomDocument::GetParametrDouble(const QDomElement &domElement, const QString &name, const QString &defValue) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty");
|
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
2013-09-11 16:14:21 +02:00
|
|
|
bool ok = false;
|
2013-12-23 20:50:30 +01:00
|
|
|
QString parametr = GetParametrString(domElement, name, defValue);
|
2013-10-14 13:26:42 +02:00
|
|
|
qreal param = parametr.replace(",", ".").toDouble(&ok);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (ok == false)
|
|
|
|
{
|
2013-12-30 12:28:33 +01:00
|
|
|
qDebug()<<"defValue"<<defValue;
|
|
|
|
qDebug()<<"parametr"<<parametr;
|
2013-09-23 14:08:06 +02:00
|
|
|
throw VExceptionConversionError(tr("Can't convert toDouble parameter"), name);
|
|
|
|
}
|
2013-09-11 16:14:21 +02:00
|
|
|
return param;
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VDomDocument::TestUniqueId() const
|
|
|
|
{
|
2013-10-07 11:13:24 +02:00
|
|
|
QVector<qint64> vector;
|
|
|
|
CollectId(this->documentElement(), vector);
|
|
|
|
}
|
|
|
|
|
2013-11-06 22:11:12 +01:00
|
|
|
void VDomDocument::CollectId(const QDomElement &node, QVector<qint64> &vector) const
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
if (node.hasAttribute("id"))
|
|
|
|
{
|
2013-10-07 11:13:24 +02:00
|
|
|
qint64 id = GetParametrId(node);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (vector.contains(id))
|
|
|
|
{
|
2013-10-07 11:13:24 +02:00
|
|
|
throw VExceptionUniqueId(tr("This id is not unique."), node);
|
|
|
|
}
|
|
|
|
vector.append(id);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i=0; i<node.childNodes().length(); ++i)
|
|
|
|
{
|
2013-10-07 11:13:24 +02:00
|
|
|
QDomNode n = node.childNodes().at(i);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (n.isElement())
|
|
|
|
{
|
2013-10-07 11:13:24 +02:00
|
|
|
CollectId(n.toElement(), vector);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
void VDomDocument::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
2013-11-04 21:35:15 +01:00
|
|
|
const QDomNode& node, const Document::Documents &parse)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomNode domNode = node.firstChild();
|
2013-11-04 21:35:15 +01:00
|
|
|
while (domNode.isNull() == false)
|
|
|
|
{
|
|
|
|
if (domNode.isElement())
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomElement domElement = domNode.toElement();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.isNull() == false)
|
|
|
|
{
|
|
|
|
if (domElement.tagName() == "calculation")
|
|
|
|
{
|
2014-01-02 16:50:01 +01:00
|
|
|
data->ClearCalculationGObjects();
|
2013-08-28 10:55:11 +02:00
|
|
|
ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Draw::Calculation);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.tagName() == "modeling")
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Draw::Modeling);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.tagName() == "details")
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
ParseDetails(sceneDetail, domElement, parse);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
domNode = domNode.nextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
void VDomDocument::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
2013-11-06 22:11:12 +01:00
|
|
|
const QDomNode& node, const Document::Documents &parse, const Draw::Draws &mode)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
Q_ASSERT(sceneDraw != 0);
|
|
|
|
Q_ASSERT(sceneDetail != 0);
|
2013-08-28 10:55:11 +02:00
|
|
|
VMainGraphicsScene *scene = 0;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (mode == Draw::Calculation)
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
scene = sceneDraw;
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
scene = sceneDetail;
|
|
|
|
}
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomNodeList nodeList = node.childNodes();
|
|
|
|
qint32 num = nodeList.size();
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i < num; ++i)
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomElement domElement = nodeList.at(i).toElement();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.isNull() == false)
|
|
|
|
{
|
|
|
|
if (domElement.tagName() == "point")
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
ParsePointElement(scene, domElement, parse, domElement.attribute("type", ""));
|
2013-10-13 20:51:59 +02:00
|
|
|
continue;
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.tagName() == "line")
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
ParseLineElement(scene, domElement, parse);
|
2013-10-13 20:51:59 +02:00
|
|
|
continue;
|
2013-07-25 20:39:51 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.tagName() == "spline")
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
ParseSplineElement(scene, domElement, parse, domElement.attribute("type", ""));
|
2013-10-13 20:51:59 +02:00
|
|
|
continue;
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.tagName() == "arc")
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
ParseArcElement(scene, domElement, parse, domElement.attribute("type", ""));
|
2013-10-13 20:51:59 +02:00
|
|
|
continue;
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
2013-12-29 17:48:57 +01:00
|
|
|
if (domElement.tagName() == "tools")
|
|
|
|
{
|
|
|
|
ParseToolsElement(scene, domElement, parse, domElement.attribute("type", ""));
|
|
|
|
continue;
|
|
|
|
}
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
|
2013-11-04 21:35:15 +01:00
|
|
|
const Document::Documents &parse)
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
Q_ASSERT(sceneDetail != 0);
|
2013-11-04 21:35:15 +01:00
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
try
|
|
|
|
{
|
2013-12-30 19:59:33 +01:00
|
|
|
VDetail detail;
|
2013-09-23 14:08:06 +02:00
|
|
|
VDetail oldDetail;
|
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-30 19:59:33 +01:00
|
|
|
detail.setName(GetParametrString(domElement, VAbstractTool::AttrName, ""));
|
|
|
|
detail.setMx(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0")));
|
|
|
|
detail.setMy(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0")));
|
|
|
|
detail.setSupplement(GetParametrLongLong(domElement, VToolDetail::AttrSupplement, "1"));
|
|
|
|
detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0"));
|
|
|
|
detail.setClosed(GetParametrLongLong(domElement, VToolDetail::AttrClosed, "1"));
|
2013-09-23 14:08:06 +02:00
|
|
|
|
|
|
|
QDomNodeList nodeList = domElement.childNodes();
|
|
|
|
qint32 num = nodeList.size();
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i < num; ++i)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
QDomElement element = nodeList.at(i).toElement();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (element.isNull() == false)
|
|
|
|
{
|
2013-12-23 20:50:30 +01:00
|
|
|
if (element.tagName() == VToolDetail::TagNode)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-12-23 20:50:30 +01:00
|
|
|
qint64 id = GetParametrLongLong(element, VToolDetail::AttrIdObject, "0");
|
|
|
|
qreal mx = toPixel(GetParametrDouble(element, VAbstractTool::AttrMx, "0.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(element, VAbstractTool::AttrMy, "0.0"));
|
2013-09-27 11:17:00 +02:00
|
|
|
Tool::Tools tool;
|
|
|
|
NodeDetail::NodeDetails nodeType = NodeDetail::Contour;
|
2013-12-23 20:50:30 +01:00
|
|
|
QString t = GetParametrString(element, "type", "NodePoint");
|
2013-11-04 21:35:15 +01:00
|
|
|
if (t == "NodePoint")
|
|
|
|
{
|
2013-09-27 11:17:00 +02:00
|
|
|
tool = Tool::NodePoint;
|
2013-12-29 17:48:57 +01:00
|
|
|
// const VPointF *point = data->GeometricObject<const VPointF *>(id);
|
|
|
|
// oldDetail.append(VNodeDetail(point.getIdObject(), tool, NodeDetail::Contour));
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else if (t == "NodeArc")
|
|
|
|
{
|
2013-09-27 11:17:00 +02:00
|
|
|
tool = Tool::NodeArc;
|
2013-12-29 17:48:57 +01:00
|
|
|
// VArc arc = data->GetArc(id);
|
|
|
|
// oldDetail.append(VNodeDetail(arc.getIdObject(), tool, NodeDetail::Contour));
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else if (t == "NodeSpline")
|
|
|
|
{
|
2013-09-27 11:17:00 +02:00
|
|
|
tool = Tool::NodeSpline;
|
2013-12-29 17:48:57 +01:00
|
|
|
// VSpline spl = data->GetSpline(id);
|
|
|
|
// oldDetail.append(VNodeDetail(spl.getIdObject(), tool, NodeDetail::Contour));
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else if (t == "NodeSplinePath")
|
|
|
|
{
|
2013-09-27 11:17:00 +02:00
|
|
|
tool = Tool::NodeSplinePath;
|
2013-12-29 17:48:57 +01:00
|
|
|
// VSplinePath splPath = data->GetSplinePath(id);
|
|
|
|
// oldDetail.append(VNodeDetail(splPath.getIdObject(), tool, NodeDetail::Contour));
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
2013-12-30 19:59:33 +01:00
|
|
|
detail.append(VNodeDetail(id, tool, nodeType, mx, my));
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-30 18:29:03 +02:00
|
|
|
VToolDetail::Create(id, detail, sceneDetail, this, data, parse, Tool::FromFile);
|
2013-09-23 14:08:06 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating detail"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
|
2013-11-04 21:35:15 +01:00
|
|
|
const Document::Documents &parse)
|
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
Q_ASSERT(sceneDetail != 0);
|
2013-11-04 21:35:15 +01:00
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
2013-08-28 10:55:11 +02:00
|
|
|
QDomNode domNode = domElement.firstChild();
|
2013-11-04 21:35:15 +01:00
|
|
|
while (domNode.isNull() == false)
|
|
|
|
{
|
|
|
|
if (domNode.isElement())
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
QDomElement domElement = domNode.toElement();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.isNull() == false)
|
|
|
|
{
|
2013-12-23 20:50:30 +01:00
|
|
|
if (domElement.tagName() == VToolDetail::TagName)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
ParseDetailElement(sceneDetail, domElement, parse);
|
|
|
|
}
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-08-28 10:55:11 +02:00
|
|
|
domNode = domNode.nextSibling();
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
2013-12-21 12:36:51 +01:00
|
|
|
const Document::Documents &parse, const QString& type)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
Q_ASSERT(scene != 0);
|
2013-11-04 21:35:15 +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 point is empty");
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolSinglePoint::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-12-30 19:59:33 +01:00
|
|
|
VToolSinglePoint *spoint = 0;
|
2013-11-04 21:35:15 +01:00
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
QString name = GetParametrString(domElement, VAbstractTool::AttrName, "A");
|
|
|
|
qreal x = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrX, "10.0"));
|
|
|
|
qreal y = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrY, "10.0"));
|
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2013-09-23 14:08:06 +02:00
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
data->UpdateGObject(id, new VPointF(x, y, name, mx, my));
|
2013-09-27 11:17:00 +02:00
|
|
|
VDrawTool::AddRecord(id, Tool::SinglePointTool, this);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (parse != Document::FullParse)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
UpdateToolData(id, data);
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (parse == Document::FullParse)
|
|
|
|
{
|
2013-12-30 19:59:33 +01:00
|
|
|
spoint = new VToolSinglePoint(this, data, id, Tool::FromFile);
|
2013-10-14 16:44:33 +02:00
|
|
|
Q_ASSERT(spoint != 0);
|
2013-09-23 14:08:06 +02:00
|
|
|
scene->addItem(spoint);
|
|
|
|
connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
2013-10-16 11:17:34 +02:00
|
|
|
connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
|
2013-09-23 14:08:06 +02:00
|
|
|
tools[id] = spoint;
|
|
|
|
}
|
|
|
|
return;
|
2013-09-11 16:14:21 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating single point"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
2014-01-05 16:04:10 +01:00
|
|
|
scene->removeItem(spoint);
|
2013-12-30 19:59:33 +01:00
|
|
|
delete spoint;
|
2013-09-23 14:08:06 +02:00
|
|
|
throw excep;
|
2013-07-25 14:00:51 +02:00
|
|
|
}
|
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolEndLine::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
|
|
QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine);
|
|
|
|
QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
|
|
|
qint64 basePointId = GetParametrLongLong(domElement, VAbstractTool::AttrBasePoint, "0");
|
|
|
|
qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0");
|
2013-12-21 12:36:51 +01:00
|
|
|
|
|
|
|
VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, scene, this, data, parse,
|
|
|
|
Tool::FromFile);
|
2013-09-23 14:08:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolAlongLine::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
|
|
QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine);
|
|
|
|
QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
|
|
|
qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
|
2013-09-30 18:29:03 +02:00
|
|
|
|
2013-12-21 12:36:51 +01:00
|
|
|
VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my, scene, this, data,
|
|
|
|
parse, Tool::FromFile);
|
2013-09-23 14:08:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolShoulderPoint::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
|
|
QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine);
|
|
|
|
QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
|
|
|
qint64 p1Line = GetParametrLongLong(domElement, VAbstractTool::AttrP1Line, "0");
|
|
|
|
qint64 p2Line = GetParametrLongLong(domElement, VAbstractTool::AttrP2Line, "0");
|
|
|
|
qint64 pShoulder = GetParametrLongLong(domElement, VAbstractTool::AttrPShoulder, "0");
|
2013-09-30 18:29:03 +02:00
|
|
|
|
2013-12-21 12:36:51 +01:00
|
|
|
VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this,
|
|
|
|
data, parse, Tool::FromFile);
|
2013-09-23 14:08:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-07-29 14:55:40 +02:00
|
|
|
}
|
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolNormal::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
|
|
QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine);
|
|
|
|
QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
|
|
|
qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
|
|
|
|
qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0");
|
2013-09-30 18:29:03 +02:00
|
|
|
|
2013-12-21 12:36:51 +01:00
|
|
|
VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene, this,
|
|
|
|
data, parse, Tool::FromFile);
|
2013-09-23 14:08:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-07-30 15:09:34 +02:00
|
|
|
}
|
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolBisector::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
|
|
QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine);
|
|
|
|
QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
|
|
|
|
qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
|
|
|
|
qint64 thirdPointId = GetParametrLongLong(domElement, VAbstractTool::AttrThirdPoint, "0");
|
2013-09-30 18:29:03 +02:00
|
|
|
|
2013-12-21 12:36:51 +01:00
|
|
|
VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine, name, mx, my, scene,
|
|
|
|
this, data, parse, Tool::FromFile);
|
2013-09-23 14:08:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-07-30 20:46:40 +02:00
|
|
|
}
|
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolLineIntersect::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
|
|
qint64 p1Line1Id = GetParametrLongLong(domElement, VAbstractTool::AttrP1Line1, "0");
|
|
|
|
qint64 p2Line1Id = GetParametrLongLong(domElement, VAbstractTool::AttrP2Line1, "0");
|
|
|
|
qint64 p1Line2Id = GetParametrLongLong(domElement, VAbstractTool::AttrP1Line2, "0");
|
|
|
|
qint64 p2Line2Id = GetParametrLongLong(domElement, VAbstractTool::AttrP2Line2, "0");
|
2013-09-30 18:29:03 +02:00
|
|
|
|
2013-12-21 12:36:51 +01:00
|
|
|
VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my, scene, this, data,
|
|
|
|
parse, Tool::FromFile);
|
2013-09-23 14:08:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of lineintersection"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-07-31 13:34:39 +02:00
|
|
|
}
|
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolPointOfContact::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
|
|
QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "0");
|
|
|
|
qint64 center = GetParametrLongLong(domElement, VAbstractTool::AttrCenter, "0");
|
|
|
|
qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
|
2013-09-30 18:29:03 +02:00
|
|
|
|
2013-12-21 12:36:51 +01:00
|
|
|
VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my, scene, this,
|
|
|
|
data, parse, Tool::FromFile);
|
2013-09-23 14:08:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VNodePoint::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0");
|
2014-01-02 16:50:01 +01:00
|
|
|
qint64 idTool = GetParametrLongLong(domElement, VAbstractNode::AttrIdTool, "0");
|
2013-12-29 17:48:57 +01:00
|
|
|
const VPointF *point = data->GeometricObject<const VPointF *>(idObject );
|
2013-12-23 20:50:30 +01:00
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
2013-12-29 17:48:57 +01:00
|
|
|
data->UpdateGObject(id, new VPointF(point->x(), point->y(), point->name(), mx, my, idObject,
|
|
|
|
Draw::Modeling));
|
2014-01-02 16:50:01 +01:00
|
|
|
VNodePoint::Create(this, data, id, idObject, parse, Tool::FromFile, idTool);
|
2013-09-23 14:08:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating modeling point"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-09-11 16:14:21 +02:00
|
|
|
}
|
2013-08-21 10:03:53 +02:00
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolHeight::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-10-18 12:03:01 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
|
|
QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine);
|
|
|
|
qint64 basePointId = GetParametrLongLong(domElement, VAbstractTool::AttrBasePoint, "0");
|
|
|
|
qint64 p1LineId = GetParametrLongLong(domElement, VAbstractTool::AttrP1Line, "0");
|
|
|
|
qint64 p2LineId = GetParametrLongLong(domElement, VAbstractTool::AttrP2Line, "0");
|
2013-12-21 12:36:51 +01:00
|
|
|
|
|
|
|
VToolHeight::Create(id, name, typeLine, basePointId, p1LineId, p2LineId, mx, my, scene, this, data, parse,
|
|
|
|
Tool::FromFile);
|
2013-10-18 12:03:01 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-10-18 12:03:01 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating height"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolTriangle::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-10-18 20:20:54 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
|
|
qint64 axisP1Id = GetParametrLongLong(domElement, VAbstractTool::AttrAxisP1, "0");
|
|
|
|
qint64 axisP2Id = GetParametrLongLong(domElement, VAbstractTool::AttrAxisP2, "0");
|
|
|
|
qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
|
2013-10-18 20:20:54 +02:00
|
|
|
|
2013-12-21 12:36:51 +01:00
|
|
|
VToolTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my, scene, this, data,
|
|
|
|
parse, Tool::FromFile);
|
2013-10-18 20:20:54 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-10-18 20:20:54 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating triangle"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolPointOfIntersection::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-10-21 16:09:05 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
|
|
qint64 firstPointId = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
qint64 secondPointId = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
|
2013-10-21 16:09:05 +02:00
|
|
|
|
2013-12-21 12:36:51 +01:00
|
|
|
VToolPointOfIntersection::Create(id, name, firstPointId, secondPointId, mx, my, scene, this, data, parse,
|
|
|
|
Tool::FromFile);
|
2013-10-21 16:09:05 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-10-21 16:09:05 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating point of intersection"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolCutSpline::ToolType)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
|
|
QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
|
|
|
|
qint64 splineId = GetParametrLongLong(domElement, VToolCutSpline::AttrSpline, "0");
|
2013-12-21 12:36:51 +01:00
|
|
|
|
|
|
|
VToolCutSpline::Create(id, name, formula, splineId, mx, my, scene, this, data, parse, Tool::FromFile);
|
2013-12-18 12:13:32 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolCutSplinePath::ToolType)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
|
|
QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
|
|
|
|
qint64 splinePathId = GetParametrLongLong(domElement, VToolCutSplinePath::AttrSplinePath, "0");
|
2013-12-21 12:36:51 +01:00
|
|
|
|
|
|
|
VToolCutSplinePath::Create(id, name, formula, splinePathId, mx, my, scene, this, data, parse,
|
|
|
|
Tool::FromFile);
|
2013-12-18 12:13:32 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
}
|
2014-01-08 15:15:38 +01:00
|
|
|
if (type == VToolCutArc::ToolType)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
qint64 id = GetParametrId(domElement);
|
|
|
|
QString name = GetParametrString(domElement, VAbstractTool::AttrName, "");
|
|
|
|
qreal mx = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
|
|
|
|
qreal my = toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
|
|
|
|
QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
|
|
|
|
qint64 arcId = GetParametrLongLong(domElement, VToolCutArc::AttrArc, "0");
|
|
|
|
|
|
|
|
VToolCutArc::Create(id, name, formula, arcId, mx, my, scene, this, data, parse, Tool::FromFile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating cut arc point"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
}
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
2013-07-25 20:39:51 +02:00
|
|
|
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
2013-12-21 12:36:51 +01:00
|
|
|
const Document::Documents &parse)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
Q_ASSERT(scene != 0);
|
2013-11-04 21:35:15 +01:00
|
|
|
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
qint64 firstPoint = GetParametrLongLong(domElement, VAbstractTool::AttrFirstPoint, "0");
|
|
|
|
qint64 secondPoint = GetParametrLongLong(domElement, VAbstractTool::AttrSecondPoint, "0");
|
2013-09-30 18:29:03 +02:00
|
|
|
|
2013-12-21 12:36:51 +01:00
|
|
|
VToolLine::Create(id, firstPoint, secondPoint, scene, this, data, parse, Tool::FromFile);
|
2013-09-23 14:08:06 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating line"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
2013-12-21 12:36:51 +01:00
|
|
|
const Document::Documents &parse, const QString &type)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
Q_ASSERT(scene != 0);
|
2013-11-04 21:35:15 +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");
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolSpline::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
qint64 point1 = GetParametrLongLong(domElement, VAbstractTool::AttrPoint1, "0");
|
|
|
|
qint64 point4 = GetParametrLongLong(domElement, VAbstractTool::AttrPoint4, "0");
|
|
|
|
qreal angle1 = GetParametrDouble(domElement, VAbstractTool::AttrAngle1, "270.0");
|
|
|
|
qreal angle2 = GetParametrDouble(domElement, VAbstractTool::AttrAngle2, "90.0");
|
|
|
|
qreal kAsm1 = GetParametrDouble(domElement, VAbstractTool::AttrKAsm1, "1.0");
|
|
|
|
qreal kAsm2 = GetParametrDouble(domElement, VAbstractTool::AttrKAsm2, "1.0");
|
|
|
|
qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0");
|
2013-09-30 18:29:03 +02:00
|
|
|
|
2013-12-21 12:36:51 +01:00
|
|
|
VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this, data, parse,
|
|
|
|
Tool::FromFile);
|
2013-09-23 14:08:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating simple curve"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-08-09 08:49:34 +02:00
|
|
|
}
|
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolSplinePath::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0");
|
2013-12-29 17:48:57 +01:00
|
|
|
VSplinePath *path = new VSplinePath(kCurve);
|
|
|
|
Q_ASSERT(path != 0);
|
2013-09-23 14:08:06 +02:00
|
|
|
|
|
|
|
QDomNodeList nodeList = domElement.childNodes();
|
|
|
|
qint32 num = nodeList.size();
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i < num; ++i)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
QDomElement element = nodeList.at(i).toElement();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (element.isNull() == false)
|
|
|
|
{
|
2013-12-23 20:50:30 +01:00
|
|
|
if (element.tagName() == VAbstractTool::AttrPathPoint)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-12-23 20:50:30 +01:00
|
|
|
qreal kAsm1 = GetParametrDouble(element, VAbstractTool::AttrKAsm1, "1.0");
|
|
|
|
qreal angle = GetParametrDouble(element, VAbstractTool::AttrAngle, "0");
|
|
|
|
qreal kAsm2 = GetParametrDouble(element, VAbstractTool::AttrKAsm2, "1.0");
|
|
|
|
qint64 pSpline = GetParametrLongLong(element, VAbstractTool::AttrPSpline, "0");
|
2013-12-29 17:48:57 +01:00
|
|
|
VPointF p = *data->GeometricObject<const VPointF *>(pSpline);
|
|
|
|
|
|
|
|
VSplinePoint splPoint(p, kAsm1, angle, kAsm2);
|
|
|
|
path->append(splPoint);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (parse == Document::FullParse)
|
|
|
|
{
|
2013-09-30 18:29:03 +02:00
|
|
|
IncrementReferens(pSpline);
|
|
|
|
}
|
2013-09-23 14:08:06 +02:00
|
|
|
}
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
2013-07-25 20:39:51 +02:00
|
|
|
}
|
2013-12-21 12:36:51 +01:00
|
|
|
|
|
|
|
VToolSplinePath::Create(id, path, scene, this, data, parse, Tool::FromFile);
|
2013-09-23 14:08:06 +02:00
|
|
|
return;
|
2013-09-11 16:14:21 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating curve path"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VNodeSpline::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0");
|
2014-01-02 16:50:01 +01:00
|
|
|
qint64 idTool = GetParametrLongLong(domElement, VAbstractNode::AttrIdTool, "0");
|
2013-12-29 17:48:57 +01:00
|
|
|
VSpline *spl = new VSpline(*data->GeometricObject<const VSpline *>(idObject));
|
|
|
|
Q_ASSERT(spl != 0);
|
|
|
|
spl->setIdObject(idObject);
|
2014-01-05 21:19:34 +01:00
|
|
|
spl->setMode(Draw::Modeling);
|
2013-12-29 17:48:57 +01:00
|
|
|
data->UpdateGObject(id, spl);
|
2014-01-02 16:50:01 +01:00
|
|
|
VNodeSpline::Create(this, data, id, idObject, parse, Tool::FromFile, idTool);
|
2013-09-23 14:08:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating modeling simple curve"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-09-18 21:23:46 +02:00
|
|
|
}
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VNodeSplinePath::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0");
|
2014-01-02 16:50:01 +01:00
|
|
|
qint64 idTool = GetParametrLongLong(domElement, VAbstractNode::AttrIdTool, "0");
|
2013-12-29 17:48:57 +01:00
|
|
|
VSplinePath *path = new VSplinePath(*data->GeometricObject<const VSplinePath *>(idObject));
|
|
|
|
Q_ASSERT(path != 0);
|
|
|
|
path->setIdObject(idObject);
|
2014-01-05 21:19:34 +01:00
|
|
|
path->setMode(Draw::Modeling);
|
2013-12-29 17:48:57 +01:00
|
|
|
data->UpdateGObject(id, path);
|
2014-01-02 16:50:01 +01:00
|
|
|
VNodeSplinePath::Create(this, data, id, idObject, parse, Tool::FromFile, idTool);
|
2013-09-23 14:08:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating modeling curve path"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-07-25 20:39:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-06 09:56:09 +02:00
|
|
|
void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
2013-12-21 12:36:51 +01:00
|
|
|
const Document::Documents &parse, const QString &type)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-10-14 16:44:33 +02:00
|
|
|
Q_ASSERT(scene != 0);
|
2013-11-04 21:35:15 +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");
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VToolArc::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
qint64 center = GetParametrLongLong(domElement, VAbstractTool::AttrCenter, "0");
|
|
|
|
QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "10");
|
|
|
|
QString f1 = GetParametrString(domElement, VAbstractTool::AttrAngle1, "180");
|
|
|
|
QString f2 = GetParametrString(domElement, VAbstractTool::AttrAngle2, "270");
|
2013-09-30 18:29:03 +02:00
|
|
|
|
2013-12-21 12:36:51 +01:00
|
|
|
VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile);
|
2013-09-27 17:00:51 +02:00
|
|
|
|
2013-09-23 14:08:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
|
|
|
throw excep;
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
}
|
2013-12-23 20:50:30 +01:00
|
|
|
if (type == VNodeArc::ToolType)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
qint64 id = GetParametrId(domElement);
|
2013-12-23 20:50:30 +01:00
|
|
|
qint64 idObject = GetParametrLongLong(domElement, VAbstractNode::AttrIdObject, "0");
|
2014-01-02 16:50:01 +01:00
|
|
|
qint64 idTool = GetParametrLongLong(domElement, VAbstractNode::AttrIdTool, "0");
|
2013-12-29 17:48:57 +01:00
|
|
|
VArc *arc = new VArc(*data->GeometricObject<const VArc *>(idObject));
|
|
|
|
Q_ASSERT(arc != 0);
|
|
|
|
arc->setIdObject(idObject);
|
2014-01-05 21:19:34 +01:00
|
|
|
arc->setMode(Draw::Modeling);
|
2013-12-29 17:48:57 +01:00
|
|
|
data->UpdateGObject(id, arc);
|
2014-01-02 16:50:01 +01:00
|
|
|
VNodeArc::Create(this, data, id, idObject, parse, Tool::FromFile, idTool);
|
2013-09-23 14:08:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
VExceptionObjectError excep(tr("Error creating or updating modeling arc"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
2013-12-29 17:48:57 +01:00
|
|
|
throw excep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
|
|
|
const Document::Documents &parse, const QString &type)
|
|
|
|
{
|
|
|
|
Q_ASSERT(scene != 0);
|
|
|
|
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");
|
|
|
|
if (type == VToolUnionDetails::ToolType)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
qint64 id = GetParametrId(domElement);
|
2014-01-02 16:50:01 +01:00
|
|
|
qint64 indexD1 = GetParametrLongLong(domElement, VToolUnionDetails::AttrIndexD1, "-1");
|
|
|
|
qint64 indexD2 = GetParametrLongLong(domElement, VToolUnionDetails::AttrIndexD2, "-1");
|
2013-12-29 17:48:57 +01:00
|
|
|
|
|
|
|
QVector<VDetail> vector = VToolUnionDetails::GetDetailFromFile(this, domElement);
|
|
|
|
|
2014-01-02 16:50:01 +01:00
|
|
|
VToolUnionDetails::Create(id, vector[0], vector[1], 0, 0, indexD1, indexD2, scene, this, data, parse,
|
2013-12-29 17:48:57 +01:00
|
|
|
Tool::FromFile);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &e)
|
|
|
|
{
|
|
|
|
VExceptionObjectError excep(tr("Error creating or updating union details"), domElement);
|
|
|
|
excep.AddMoreInformation(e.ErrorMessage());
|
2013-09-23 14:08:06 +02:00
|
|
|
throw excep;
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VDomDocument::FullUpdateTree()
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
VMainGraphicsScene *scene = new VMainGraphicsScene();
|
2013-10-14 16:44:33 +02:00
|
|
|
Q_ASSERT(scene != 0);
|
2013-11-04 21:35:15 +01:00
|
|
|
try
|
|
|
|
{
|
2014-01-02 16:50:01 +01:00
|
|
|
data->ClearGObjects();
|
2013-09-23 14:08:06 +02:00
|
|
|
Parse(Document::LiteParse, scene, scene);
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (const std::bad_alloc &)
|
|
|
|
{
|
2013-10-09 18:24:28 +02:00
|
|
|
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;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
catch (...)
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
delete scene;
|
|
|
|
throw;
|
|
|
|
}
|
2013-10-09 18:24:28 +02:00
|
|
|
|
2013-07-13 12:51:31 +02:00
|
|
|
delete scene;
|
2013-08-15 22:39:00 +02:00
|
|
|
setCurrentData();
|
2013-07-13 12:51:31 +02:00
|
|
|
emit FullUpdateFromFile();
|
|
|
|
emit haveChange();
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VDomDocument::haveLiteChange()
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
emit haveChange();
|
|
|
|
}
|
2013-08-15 22:39:00 +02:00
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VDomDocument::ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable)
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
emit ShowTool(id, color, enable);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VDomDocument::setCursor(const qint64 &value)
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
cursor = value;
|
|
|
|
emit ChangedCursor(cursor);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VDomDocument::setCurrentData()
|
|
|
|
{
|
|
|
|
if (*mode == Draw::Calculation)
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
QString nameDraw = comboBoxDraws->itemText(comboBoxDraws->currentIndex());
|
2013-11-04 21:35:15 +01:00
|
|
|
if (nameActivDraw != nameDraw)
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
nameActivDraw = nameDraw;
|
|
|
|
qint64 id = 0;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (history.size() == 0)
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i < history.size(); ++i)
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
VToolRecord tool = history.at(i);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (tool.getNameDraw() == nameDraw)
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
id = tool.getId();
|
|
|
|
}
|
2013-08-21 10:03:53 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (id == 0)
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
VToolRecord tool = history.at(history.size()-1);
|
|
|
|
id = tool.getId();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (id == 0)
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (tools.size() > 0)
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
VDataTool *vTool = tools.value(id);
|
|
|
|
data->setData(vTool->getData());
|
2013-08-21 10:03:53 +02:00
|
|
|
}
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-08-28 10:55:11 +02:00
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VDomDocument::AddTool(const qint64 &id, VDataTool *tool)
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
2013-10-14 16:44:33 +02:00
|
|
|
Q_ASSERT(tool != 0);
|
2013-09-10 14:29:06 +02:00
|
|
|
tools.insert(id, tool);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VDomDocument::UpdateToolData(const qint64 &id, VContainer *data)
|
|
|
|
{
|
2013-09-11 16:14:21 +02:00
|
|
|
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
2013-10-14 16:44:33 +02:00
|
|
|
Q_ASSERT(data != 0);
|
2013-09-10 14:29:06 +02:00
|
|
|
VDataTool *tool = tools.value(id);
|
2013-10-14 16:44:33 +02:00
|
|
|
Q_ASSERT(tool != 0);
|
2013-09-11 16:14:21 +02:00
|
|
|
tool->VDataTool::setData(data);
|
2013-09-10 14:29:06 +02:00
|
|
|
}
|
2013-09-30 18:29:03 +02:00
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VDomDocument::IncrementReferens(qint64 id) const
|
|
|
|
{
|
2013-09-30 18:29:03 +02:00
|
|
|
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
|
|
|
VDataTool *tool = tools.value(id);
|
2013-10-14 16:44:33 +02:00
|
|
|
Q_ASSERT(tool != 0);
|
2013-09-30 18:29:03 +02:00
|
|
|
tool->incrementReferens();
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VDomDocument::DecrementReferens(qint64 id) const
|
|
|
|
{
|
2013-09-30 18:29:03 +02:00
|
|
|
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
|
|
|
VDataTool *tool = tools.value(id);
|
2014-01-02 19:21:00 +01:00
|
|
|
if(tool != 0)
|
|
|
|
{
|
|
|
|
tool->decrementReferens();
|
|
|
|
}
|
2013-09-30 18:29:03 +02:00
|
|
|
}
|