2013-09-18 21:16:19 +02:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2013 Valentina project All Rights Reserved.
|
|
|
|
**
|
|
|
|
** This file is part of Valentina.
|
|
|
|
**
|
|
|
|
** Tox 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.
|
|
|
|
**
|
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-08-28 10:55:11 +02:00
|
|
|
#include "vtooldetail.h"
|
2013-09-10 14:29:06 +02:00
|
|
|
#include "nodeDetails/nodedetails.h"
|
|
|
|
#include "modelingTools/vmodelingtool.h"
|
|
|
|
#include "modelingTools/modelingtools.h"
|
2013-08-28 10:55:11 +02:00
|
|
|
|
2013-10-29 18:46:58 +01:00
|
|
|
const QString VToolDetail::TagName = QStringLiteral("detail");
|
|
|
|
const QString VToolDetail::TagNode = QStringLiteral("node");
|
|
|
|
const QString VToolDetail::AttrSupplement = QStringLiteral("supplement");
|
|
|
|
const QString VToolDetail::AttrClosed = QStringLiteral("closed");
|
|
|
|
const QString VToolDetail::AttrWidth = QStringLiteral("width");
|
|
|
|
const QString VToolDetail::AttrIdObject = QStringLiteral("idObject");
|
|
|
|
const QString VToolDetail::AttrNodeType = QStringLiteral("nodeType");
|
|
|
|
const QString VToolDetail::NodeTypeContour = QStringLiteral("Contour");
|
2013-10-29 14:45:07 +01:00
|
|
|
const QString VToolDetail::NodeTypeModeling = QStringLiteral("Modeling");
|
|
|
|
|
2013-09-30 18:29:03 +02:00
|
|
|
VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, Tool::Sources typeCreation,
|
2013-11-04 21:35:15 +01:00
|
|
|
VMainGraphicsScene *scene, QGraphicsItem *parent)
|
|
|
|
:VAbstractTool(doc, data, id), QGraphicsPathItem(parent), dialogDetail(QSharedPointer<DialogDetail>()),
|
|
|
|
sceneDetails(scene)
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
VDetail detail = data->GetDetail(id);
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i< detail.CountNode(); ++i)
|
|
|
|
{
|
|
|
|
switch (detail[i].getTypeTool())
|
|
|
|
{
|
|
|
|
case (Tool::NodePoint):
|
|
|
|
InitTool<VNodePoint>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::NodeArc):
|
|
|
|
InitTool<VNodeArc>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::NodeSpline):
|
|
|
|
InitTool<VNodeSpline>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::NodeSplinePath):
|
|
|
|
InitTool<VNodeSplinePath>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::AlongLineTool):
|
|
|
|
InitTool<VModelingAlongLine>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::ArcTool):
|
|
|
|
InitTool<VModelingArc>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::BisectorTool):
|
|
|
|
InitTool<VModelingBisector>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::EndLineTool):
|
|
|
|
InitTool<VModelingEndLine>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::LineIntersectTool):
|
|
|
|
InitTool<VModelingLineIntersect>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::LineTool):
|
|
|
|
InitTool<VModelingLine>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::NormalTool):
|
|
|
|
InitTool<VModelingNormal>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::PointOfContact):
|
|
|
|
InitTool<VModelingPointOfContact>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::ShoulderPointTool):
|
|
|
|
InitTool<VModelingShoulderPoint>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::SplinePathTool):
|
|
|
|
InitTool<VModelingSplinePath>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::SplineTool):
|
|
|
|
InitTool<VModelingSpline>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::Height):
|
|
|
|
InitTool<VModelingHeight>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::Triangle):
|
|
|
|
InitTool<VModelingTriangle>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
case (Tool::PointOfIntersection):
|
|
|
|
InitTool<VModelingPointOfIntersection>(scene, detail[i]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
qWarning()<<"Get wrong tool type. Ignore.";
|
|
|
|
break;
|
2013-09-10 14:29:06 +02:00
|
|
|
}
|
2013-09-30 18:29:03 +02:00
|
|
|
doc->IncrementReferens(detail[i].getId());
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
|
|
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
|
|
|
RefreshGeometry();
|
|
|
|
this->setPos(detail.getMx(), detail.getMy());
|
|
|
|
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (typeCreation == Tool::FromGui)
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
AddToFile();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolDetail::setDialog()
|
|
|
|
{
|
|
|
|
Q_ASSERT(dialogDetail.isNull() == false);
|
2013-10-25 13:10:45 +02:00
|
|
|
VDetail detail = VAbstractTool::data.GetDetail(id);
|
|
|
|
dialogDetail->setDetails(detail);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
|
|
|
VContainer *data)
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
VDetail detail = dialog->getDetails();
|
|
|
|
VDetail det;
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i< detail.CountNode(); ++i)
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
qint64 id = 0;
|
2013-11-04 21:35:15 +01:00
|
|
|
switch (detail[i].getTypeTool())
|
|
|
|
{
|
|
|
|
case (Tool::NodePoint):
|
|
|
|
{
|
|
|
|
VPointF point;
|
|
|
|
if (detail[i].getMode() == Draw::Calculation)
|
|
|
|
{
|
|
|
|
point = data->GetPoint(detail[i].getId());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
point = data->GetModelingPoint(detail[i].getId());
|
|
|
|
}
|
|
|
|
id = data->AddModelingPoint(point);
|
|
|
|
VNodePoint::Create(doc, data, id, detail[i].getId(), detail[i].getMode(),
|
|
|
|
Document::FullParse, Tool::FromGui);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
break;
|
2013-11-04 21:35:15 +01:00
|
|
|
case (Tool::NodeArc):
|
|
|
|
{
|
|
|
|
VArc arc;
|
|
|
|
if (detail[i].getMode() == Draw::Calculation)
|
|
|
|
{
|
|
|
|
arc = data->GetArc(detail[i].getId());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
arc = data->GetModelingArc(detail[i].getId());
|
|
|
|
}
|
|
|
|
id = data->AddModelingArc(arc);
|
|
|
|
VNodeArc::Create(doc, data, id, detail[i].getId(), detail[i].getMode(),
|
|
|
|
Document::FullParse, Tool::FromGui);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
break;
|
2013-11-04 21:35:15 +01:00
|
|
|
case (Tool::NodeSpline):
|
|
|
|
{
|
|
|
|
VSpline spline;
|
|
|
|
if (detail[i].getMode() == Draw::Calculation)
|
|
|
|
{
|
|
|
|
spline = data->GetSpline(detail[i].getId());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spline = data->GetModelingSpline(detail[i].getId());
|
|
|
|
}
|
|
|
|
id = data->AddModelingSpline(spline);
|
|
|
|
VNodeSpline::Create(doc, data, id, detail[i].getId(), detail[i].getMode(),
|
|
|
|
Document::FullParse, Tool::FromGui);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
break;
|
2013-11-04 21:35:15 +01:00
|
|
|
case (Tool::NodeSplinePath):
|
|
|
|
{
|
|
|
|
VSplinePath splinePath;
|
|
|
|
if (detail[i].getMode() == Draw::Calculation)
|
|
|
|
{
|
|
|
|
splinePath = data->GetSplinePath(detail[i].getId());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
splinePath = data->GetModelingSplinePath(detail[i].getId());
|
|
|
|
}
|
|
|
|
id = data->AddModelingSplinePath(splinePath);
|
|
|
|
VNodeSplinePath::Create(doc, data, id, detail[i].getId(), detail[i].getMode(),
|
|
|
|
Document::FullParse, Tool::FromGui);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
break;
|
2013-11-04 21:35:15 +01:00
|
|
|
default:
|
|
|
|
qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
|
|
|
|
break;
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
2013-10-25 13:10:45 +02:00
|
|
|
VNodeDetail node(id, detail[i].getTypeTool(), Draw::Modeling, NodeDetail::Contour);
|
2013-08-28 10:55:11 +02:00
|
|
|
det.append(node);
|
|
|
|
}
|
|
|
|
det.setName(detail.getName());
|
2013-09-30 18:29:03 +02:00
|
|
|
Create(0, det, scene, doc, data, Document::FullParse, Tool::FromGui);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
2013-09-30 18:29:03 +02:00
|
|
|
void VToolDetail::Create(const qint64 _id, VDetail &newDetail, VMainGraphicsScene *scene, VDomDocument *doc,
|
2013-11-04 21:35:15 +01:00
|
|
|
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation)
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
qint64 id = _id;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (typeCreation == Tool::FromGui)
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
id = data->AddDetail(newDetail);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
data->UpdateDetail(id, newDetail);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (parse != Document::FullParse)
|
|
|
|
{
|
2013-09-30 18:29:03 +02:00
|
|
|
doc->UpdateToolData(id, data);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (parse == Document::FullParse)
|
|
|
|
{
|
2013-09-30 18:29:03 +02:00
|
|
|
VToolDetail *detail = new VToolDetail(doc, data, id, typeCreation, scene);
|
2013-08-28 10:55:11 +02:00
|
|
|
scene->addItem(detail);
|
2013-09-10 14:29:06 +02:00
|
|
|
connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
2013-09-30 18:29:03 +02:00
|
|
|
connect(detail, &VToolDetail::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
2013-10-04 13:32:42 +02:00
|
|
|
QHash<qint64, VDataTool*>* tools = doc->getTools();
|
2013-08-28 10:55:11 +02:00
|
|
|
tools->insert(id, detail);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolDetail::FullUpdateFromFile()
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
RefreshGeometry();
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolDetail::FullUpdateFromGui(int result)
|
|
|
|
{
|
|
|
|
if (result == QDialog::Accepted)
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.isElement())
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
VDetail det = dialogDetail->getDetails();
|
2013-10-29 14:45:07 +01:00
|
|
|
domElement.setAttribute(AttrName, det.getName());
|
|
|
|
domElement.setAttribute(AttrSupplement, QString().setNum(det.getSupplement()));
|
|
|
|
domElement.setAttribute(AttrClosed, QString().setNum(det.getClosed()));
|
|
|
|
domElement.setAttribute(AttrWidth, QString().setNum(det.getWidth()));
|
2013-10-25 13:16:07 +02:00
|
|
|
RemoveAllChild(domElement);
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i < det.CountNode(); ++i)
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
AddNode(domElement, det[i]);
|
|
|
|
}
|
|
|
|
emit FullUpdateTree();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dialogDetail.clear();
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolDetail::AddToFile()
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
VDetail detail = VAbstractTool::data.GetDetail(id);
|
2013-10-29 14:45:07 +01:00
|
|
|
QDomElement domElement = doc->createElement(TagName);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
2013-10-29 14:45:07 +01:00
|
|
|
AddAttribute(domElement, AttrId, id);
|
|
|
|
AddAttribute(domElement, AttrName, detail.getName());
|
|
|
|
AddAttribute(domElement, AttrMx, toMM(detail.getMx()));
|
|
|
|
AddAttribute(domElement, AttrMy, toMM(detail.getMy()));
|
|
|
|
AddAttribute(domElement, AttrSupplement, detail.getSupplement());
|
|
|
|
AddAttribute(domElement, AttrClosed, detail.getClosed());
|
|
|
|
AddAttribute(domElement, AttrWidth, detail.getWidth());
|
2013-08-28 10:55:11 +02:00
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i < detail.CountNode(); ++i)
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
AddNode(domElement, detail[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
QDomElement element;
|
|
|
|
bool ok = doc->GetActivDetailsElement(element);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (ok)
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
element.appendChild(domElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
|
|
|
{
|
|
|
|
if (change == ItemPositionHasChanged && scene())
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
// value - это новое положение.
|
|
|
|
QPointF newPos = value.toPointF();
|
2013-09-10 14:29:06 +02:00
|
|
|
//qDebug()<<newPos;
|
2013-08-28 10:55:11 +02:00
|
|
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.isElement())
|
|
|
|
{
|
2013-10-29 14:45:07 +01:00
|
|
|
domElement.setAttribute(AttrMx, QString().setNum(toMM(newPos.x())));
|
|
|
|
domElement.setAttribute(AttrMy, QString().setNum(toMM(newPos.y())));
|
2013-08-28 10:55:11 +02:00
|
|
|
//I don't now why but signal does not work.
|
|
|
|
doc->FullUpdateTree();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QGraphicsItem::itemChange(change, value);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolDetail::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|
|
|
{
|
|
|
|
if (event->button() == Qt::LeftButton)
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
emit ChoosedTool(id, Scene::Detail);
|
|
|
|
}
|
|
|
|
QGraphicsItem::mouseReleaseEvent(event);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|
|
|
{
|
2013-09-30 18:29:03 +02:00
|
|
|
QMenu menu;
|
2013-10-25 13:10:45 +02:00
|
|
|
QAction *actionOption = menu.addAction(tr("Options"));
|
2013-09-30 18:29:03 +02:00
|
|
|
QAction *actionRemove = menu.addAction(tr("Delete"));
|
2013-11-04 21:35:15 +01:00
|
|
|
if (_referens > 1)
|
|
|
|
{
|
2013-09-30 18:29:03 +02:00
|
|
|
actionRemove->setEnabled(false);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-30 18:29:03 +02:00
|
|
|
actionRemove->setEnabled(true);
|
|
|
|
}
|
|
|
|
QAction *selectedAction = menu.exec(event->screenPos());
|
2013-11-04 21:35:15 +01:00
|
|
|
if (selectedAction == actionOption)
|
|
|
|
{
|
2013-10-25 13:10:45 +02:00
|
|
|
dialogDetail = QSharedPointer<DialogDetail>(new DialogDetail(getData(), Draw::Modeling));
|
|
|
|
connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject,
|
|
|
|
dialogDetail.data(), &DialogDetail::ChoosedObject);
|
|
|
|
connect(dialogDetail.data(), &DialogDetail::DialogClosed, this, &VToolDetail::FullUpdateFromGui);
|
|
|
|
setDialog();
|
|
|
|
dialogDetail->show();
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
if (selectedAction == actionRemove)
|
|
|
|
{
|
2013-09-30 18:29:03 +02:00
|
|
|
//remove form xml file
|
|
|
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.isElement())
|
|
|
|
{
|
2013-09-30 18:29:03 +02:00
|
|
|
QDomNode element = domElement.parentNode();
|
2013-11-04 21:35:15 +01:00
|
|
|
if (element.isNull() == false)
|
|
|
|
{
|
2013-10-09 18:24:28 +02:00
|
|
|
//deincrement referens
|
|
|
|
RemoveReferens();
|
2013-09-30 18:29:03 +02:00
|
|
|
element.removeChild(domElement);
|
|
|
|
//update xml file
|
|
|
|
emit FullUpdateTree();
|
|
|
|
//remove form scene
|
|
|
|
emit RemoveTool(this);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-09 18:24:28 +02:00
|
|
|
qWarning()<<"parentNode isNull"<<Q_FUNC_INFO;
|
2013-09-30 18:29:03 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-09 18:24:28 +02:00
|
|
|
qWarning()<<"Can't get element by id = "<<id<<Q_FUNC_INFO;
|
2013-09-30 18:29:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolDetail::RemoveReferens()
|
|
|
|
{
|
2013-09-30 18:29:03 +02:00
|
|
|
VDetail detail = VAbstractTool::data.GetDetail(id);
|
2013-11-04 21:35:15 +01:00
|
|
|
for (qint32 i = 0; i< detail.CountNode(); ++i)
|
|
|
|
{
|
2013-09-30 18:29:03 +02:00
|
|
|
doc->DecrementReferens(detail[i].getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolDetail::AddNode(QDomElement &domElement, VNodeDetail &node)
|
|
|
|
{
|
2013-10-29 14:45:07 +01:00
|
|
|
QDomElement nod = doc->createElement(TagNode);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
2013-10-29 14:45:07 +01:00
|
|
|
AddAttribute(nod, AttrIdObject, node.getId());
|
|
|
|
AddAttribute(nod, AttrMx, toMM(node.getMx()));
|
|
|
|
AddAttribute(nod, AttrMy, toMM(node.getMy()));
|
2013-11-04 21:35:15 +01:00
|
|
|
if (node.getTypeNode() == NodeDetail::Contour)
|
|
|
|
{
|
2013-10-29 14:45:07 +01:00
|
|
|
AddAttribute(nod, AttrNodeType, NodeTypeContour);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-29 14:45:07 +01:00
|
|
|
AddAttribute(nod, AttrNodeType, NodeTypeModeling);
|
2013-09-10 14:29:06 +02:00
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
switch (node.getTypeTool())
|
|
|
|
{
|
|
|
|
case (Tool::AlongLineTool):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("AlongLineTool"));
|
|
|
|
break;
|
|
|
|
case (Tool::ArcTool):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("ArcTool"));
|
|
|
|
break;
|
|
|
|
case (Tool::BisectorTool):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("BisectorTool"));
|
|
|
|
break;
|
|
|
|
case (Tool::EndLineTool):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("EndLineTool"));
|
|
|
|
break;
|
|
|
|
case (Tool::LineIntersectTool):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("LineIntersectTool"));
|
|
|
|
break;
|
|
|
|
case (Tool::LineTool):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("LineTool"));
|
|
|
|
break;
|
|
|
|
case (Tool::NodeArc):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("NodeArc"));
|
|
|
|
break;
|
|
|
|
case (Tool::NodePoint):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("NodePoint"));
|
|
|
|
break;
|
|
|
|
case (Tool::NodeSpline):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("NodeSpline"));
|
|
|
|
break;
|
|
|
|
case (Tool::NodeSplinePath):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("NodeSplinePath"));
|
|
|
|
break;
|
|
|
|
case (Tool::NormalTool):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("NormalTool"));
|
|
|
|
break;
|
|
|
|
case (Tool::PointOfContact):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("PointOfContact"));
|
|
|
|
break;
|
|
|
|
case (Tool::ShoulderPointTool):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("ShoulderPointTool"));
|
|
|
|
break;
|
|
|
|
case (Tool::SplinePathTool):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("SplinePathTool"));
|
|
|
|
break;
|
|
|
|
case (Tool::SplineTool):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("SplineTool"));
|
|
|
|
break;
|
|
|
|
case (Tool::Height):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("Height"));
|
|
|
|
break;
|
|
|
|
case (Tool::Triangle):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("Triangle"));
|
|
|
|
break;
|
|
|
|
case (Tool::PointOfIntersection):
|
|
|
|
AddAttribute(nod, AttrType, QStringLiteral("PointOfIntersection"));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
|
|
|
|
break;
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
domElement.appendChild(nod);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolDetail::RefreshGeometry()
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
QPainterPath path = VAbstractTool::data.ContourPath(id);
|
2013-08-28 10:55:11 +02:00
|
|
|
this->setPath(path);
|
|
|
|
}
|
2013-10-29 16:01:56 +01:00
|
|
|
|
|
|
|
template <typename Tool>
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
|
|
|
|
{
|
2013-10-29 16:01:56 +01:00
|
|
|
QHash<qint64, VDataTool*>* tools = doc->getTools();
|
|
|
|
Q_ASSERT(tools != 0);
|
|
|
|
Tool *tool = qobject_cast<Tool*>(tools->value(node.getId()));
|
|
|
|
Q_ASSERT(tool != 0);
|
|
|
|
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
|
|
connect(tool, &Tool::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
|
|
|
tool->setParentItem(this);
|
|
|
|
}
|