2013-12-18 12:13:32 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vtoolcutsplinepath.cpp
|
|
|
|
** @author Roman Telezhinsky <dismine@gmail.com>
|
|
|
|
** @date 15 12, 2013
|
|
|
|
**
|
|
|
|
** @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 "vtoolcutsplinepath.h"
|
2013-12-20 14:35:14 +01:00
|
|
|
#include "../../container/calculator.h"
|
2014-02-06 14:57:23 +01:00
|
|
|
#include "../../dialogs/dialogcutsplinepath.h"
|
2013-12-18 12:13:32 +01:00
|
|
|
|
|
|
|
const QString VToolCutSplinePath::ToolType = QStringLiteral("cutSplinePath");
|
|
|
|
const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath");
|
|
|
|
|
|
|
|
VToolCutSplinePath::VToolCutSplinePath(VDomDocument *doc, VContainer *data, const qint64 &id,
|
|
|
|
const QString &formula, const qint64 &splinePathId,
|
2013-12-20 14:35:14 +01:00
|
|
|
const qint64 &splPath1id, const qint64 &splPath2id,
|
2013-12-18 12:13:32 +01:00
|
|
|
const Tool::Sources &typeCreation, QGraphicsItem *parent)
|
2014-02-06 14:57:23 +01:00
|
|
|
:VToolPoint(doc, data, id, parent), formula(formula), splinePathId(splinePathId), firstSpline(), secondSpline(),
|
2013-12-20 14:35:14 +01:00
|
|
|
splPath1id (splPath1id), splPath2id(splPath2id)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
|
|
|
Q_ASSERT_X(splinePathId > 0, Q_FUNC_INFO, "splinePathId <= 0");
|
2013-12-20 14:35:14 +01:00
|
|
|
Q_ASSERT_X(splPath1id > 0, Q_FUNC_INFO, "spl1id <= 0");
|
|
|
|
Q_ASSERT_X(splPath2id > 0, Q_FUNC_INFO, "spl2id <= 0");
|
|
|
|
|
|
|
|
firstSpline = new VSimpleSpline(splPath1id, ¤tColor, &factor);
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(firstSpline);
|
2013-12-20 14:35:14 +01:00
|
|
|
RefreshSpline(firstSpline, splPath1id, SimpleSpline::ForthPoint);
|
|
|
|
firstSpline->setParentItem(this);
|
|
|
|
connect(firstSpline, &VSimpleSpline::Choosed, this, &VToolCutSplinePath::SplineChoosed);
|
|
|
|
|
|
|
|
secondSpline = new VSimpleSpline(splPath2id, ¤tColor, &factor);
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(secondSpline);
|
2013-12-20 14:35:14 +01:00
|
|
|
RefreshSpline(secondSpline, splPath2id, SimpleSpline::FirstPoint);
|
|
|
|
secondSpline->setParentItem(this);
|
|
|
|
connect(secondSpline, &VSimpleSpline::Choosed, this, &VToolCutSplinePath::SplineChoosed);
|
|
|
|
|
2013-12-18 12:13:32 +01:00
|
|
|
if (typeCreation == Tool::FromGui)
|
|
|
|
{
|
|
|
|
AddToFile();
|
|
|
|
}
|
2013-12-24 12:24:29 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
RefreshDataInFile();
|
|
|
|
}
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void VToolCutSplinePath::setDialog()
|
|
|
|
{
|
2014-02-06 14:57:23 +01:00
|
|
|
Q_CHECK_PTR(dialog);
|
|
|
|
DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog);
|
|
|
|
Q_CHECK_PTR(dialogTool);
|
2013-12-29 17:48:57 +01:00
|
|
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
2014-02-06 14:57:23 +01:00
|
|
|
dialogTool->setFormula(formula);
|
|
|
|
dialogTool->setSplinePathId(splinePathId, id);
|
|
|
|
dialogTool->setPointName(point->name());
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
|
2014-02-06 14:57:23 +01:00
|
|
|
void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-02-06 14:57:23 +01:00
|
|
|
Q_CHECK_PTR(dialog);
|
|
|
|
DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog);
|
|
|
|
Q_CHECK_PTR(dialogTool);
|
|
|
|
QString pointName = dialogTool->getPointName();
|
|
|
|
QString formula = dialogTool->getFormula();
|
|
|
|
qint64 splinePathId = dialogTool->getSplinePathId();
|
2013-12-18 12:13:32 +01:00
|
|
|
Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Tool::FromGui);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VToolCutSplinePath::Create(const qint64 _id, const QString &pointName, const QString &formula,
|
|
|
|
const qint64 &splinePathId, const qreal &mx, const qreal &my,
|
|
|
|
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
|
|
|
const Document::Documents &parse, const Tool::Sources &typeCreation)
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(splinePathId);
|
2013-12-20 14:35:14 +01:00
|
|
|
Calculator cal(data);
|
|
|
|
QString errorMsg;
|
|
|
|
qreal result = cal.eval(formula, &errorMsg);
|
|
|
|
if (errorMsg.isEmpty())
|
|
|
|
{
|
|
|
|
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
|
|
|
|
qint32 p1 = 0, p2 = 0;
|
2013-12-29 17:48:57 +01:00
|
|
|
QPointF point = splPath->CutSplinePath(toPixel(result), p1, p2, spl1p2, spl1p3, spl2p2, spl2p3);
|
2013-12-20 14:35:14 +01:00
|
|
|
|
|
|
|
qint64 id = _id;
|
|
|
|
qint64 splPath1id = 0;
|
|
|
|
qint64 splPath2id = 0;
|
|
|
|
if (typeCreation == Tool::FromGui)
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my);
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(p);
|
2013-12-29 17:48:57 +01:00
|
|
|
id = data->AddGObject(p);
|
2013-12-20 14:35:14 +01:00
|
|
|
splPath1id = id + 1;
|
|
|
|
splPath2id = id + 2;
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
VSplinePoint splP1 = splPath->at(p1);
|
|
|
|
VSplinePoint splP2 = splPath->at(p2);
|
|
|
|
VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p, splPath->getKCurve());
|
|
|
|
VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P(), splPath->getKCurve());
|
2013-12-20 14:35:14 +01:00
|
|
|
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
VSplinePath *splPath1 = new VSplinePath();
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(splPath1);
|
2013-12-29 17:48:57 +01:00
|
|
|
VSplinePath *splPath2 = new VSplinePath();
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(splPath2);
|
2013-12-31 09:44:54 +01:00
|
|
|
for (qint32 i = 0; i < splPath->CountPoint(); i++)
|
2013-12-20 14:35:14 +01:00
|
|
|
{
|
2013-12-31 09:44:54 +01:00
|
|
|
if (i <= p1 && i < p2)
|
|
|
|
{
|
|
|
|
if (i == p1)
|
2013-12-20 14:35:14 +01:00
|
|
|
{
|
2014-02-14 16:16:43 +01:00
|
|
|
splPath1->append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1()+180, spl1.GetKasm1(),
|
|
|
|
spl1.GetAngle1()));
|
|
|
|
VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(),
|
|
|
|
spl1.GetAngle2()+180, spl1.GetAngle2());
|
2013-12-29 17:48:57 +01:00
|
|
|
splPath1->append(cutPoint);
|
2013-12-20 14:35:14 +01:00
|
|
|
continue;
|
|
|
|
}
|
2013-12-29 17:48:57 +01:00
|
|
|
splPath1->append(splPath->at(i));
|
2013-12-20 14:35:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-31 09:44:54 +01:00
|
|
|
if (i == p2)
|
2013-12-20 14:35:14 +01:00
|
|
|
{
|
2014-02-14 16:16:43 +01:00
|
|
|
VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl2.GetAngle1()+180, spl2.GetKasm1(),
|
|
|
|
spl2.GetAngle1());
|
2013-12-29 17:48:57 +01:00
|
|
|
splPath2->append(cutPoint);
|
2014-02-14 16:16:43 +01:00
|
|
|
splPath2->append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2(), splP2.KAsm2(),
|
|
|
|
spl2.GetAngle2()+180));
|
2013-12-20 14:35:14 +01:00
|
|
|
continue;
|
|
|
|
}
|
2013-12-29 17:48:57 +01:00
|
|
|
splPath2->append(splPath->at(i));
|
2013-12-20 14:35:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-08 21:23:08 +01:00
|
|
|
splPath1->setMaxCountPoints(splPath->CountPoint());
|
|
|
|
splPath2->setMaxCountPoints(splPath->CountPoint());
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
splPath1id = data->AddGObject(splPath1);
|
|
|
|
data->AddLengthSpline(splPath1->name(), toMM(splPath1->GetLength()));
|
2013-12-18 12:13:32 +01:00
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
splPath2id = data->AddGObject(splPath2);
|
|
|
|
data->AddLengthSpline(splPath2->name(), toMM(splPath2->GetLength()));
|
2013-12-20 14:35:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my);
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(p);
|
2013-12-29 17:48:57 +01:00
|
|
|
data->UpdateGObject(id, p);
|
2013-12-20 14:35:14 +01:00
|
|
|
|
|
|
|
splPath1id = id + 1;
|
|
|
|
splPath2id = id + 2;
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
VSplinePoint splP1 = splPath->at(p1);
|
|
|
|
VSplinePoint splP2 = splPath->at(p2);
|
|
|
|
VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p, splPath->getKCurve());
|
|
|
|
VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P(), splPath->getKCurve());
|
2013-12-20 14:35:14 +01:00
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
VSplinePath *splPath1 = new VSplinePath();
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(splPath1);
|
2013-12-29 17:48:57 +01:00
|
|
|
VSplinePath *splPath2 = new VSplinePath();
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(splPath2);
|
2013-12-31 09:44:54 +01:00
|
|
|
for (qint32 i = 0; i < splPath->CountPoint(); i++)
|
2013-12-20 14:35:14 +01:00
|
|
|
{
|
2013-12-31 09:44:54 +01:00
|
|
|
if (i <= p1 && i < p2)
|
|
|
|
{
|
|
|
|
if (i == p1)
|
2013-12-20 14:35:14 +01:00
|
|
|
{
|
2014-02-14 16:16:43 +01:00
|
|
|
splPath1->append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1()+180, spl1.GetKasm1(),
|
|
|
|
spl1.GetAngle1()));
|
|
|
|
VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(),
|
|
|
|
spl2.GetKasm1(), spl1.GetAngle2()+180);
|
2013-12-29 17:48:57 +01:00
|
|
|
splPath1->append(cutPoint);
|
2013-12-20 14:35:14 +01:00
|
|
|
continue;
|
|
|
|
}
|
2013-12-29 17:48:57 +01:00
|
|
|
splPath1->append(splPath->at(i));
|
2013-12-20 14:35:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-31 09:44:54 +01:00
|
|
|
if (i == p2)
|
2013-12-20 14:35:14 +01:00
|
|
|
{
|
2014-02-14 16:16:43 +01:00
|
|
|
VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl2.GetAngle1()+180, spl2.GetKasm1(),
|
|
|
|
spl2.GetAngle1());
|
2013-12-29 17:48:57 +01:00
|
|
|
splPath2->append(cutPoint);
|
2014-02-14 16:16:43 +01:00
|
|
|
splPath2->append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2(), splP2.KAsm2(),
|
|
|
|
spl2.GetAngle2()+180));
|
2013-12-20 14:35:14 +01:00
|
|
|
continue;
|
|
|
|
}
|
2013-12-29 17:48:57 +01:00
|
|
|
splPath2->append(splPath->at(i));
|
2013-12-20 14:35:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-08 21:23:08 +01:00
|
|
|
splPath1->setMaxCountPoints(splPath->CountPoint());
|
|
|
|
splPath2->setMaxCountPoints(splPath->CountPoint());
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
data->UpdateGObject(splPath1id, splPath1);
|
|
|
|
data->AddLengthSpline(splPath1->name(), toMM(splPath1->GetLength()));
|
2013-12-20 14:35:14 +01:00
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
data->UpdateGObject(splPath2id, splPath2);
|
|
|
|
data->AddLengthSpline(splPath2->name(), toMM(splPath2->GetLength()));
|
2013-12-20 14:35:14 +01:00
|
|
|
|
|
|
|
if (parse != Document::FullParse)
|
|
|
|
{
|
|
|
|
doc->UpdateToolData(id, data);
|
|
|
|
}
|
|
|
|
}
|
2013-12-29 17:48:57 +01:00
|
|
|
VDrawTool::AddRecord(id, Tool::CutSplinePathTool, doc);
|
2013-12-20 14:35:14 +01:00
|
|
|
if (parse == Document::FullParse)
|
|
|
|
{
|
|
|
|
VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, splPath1id,
|
|
|
|
splPath2id, typeCreation);
|
|
|
|
scene->addItem(point);
|
|
|
|
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
|
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
|
|
|
|
doc->AddTool(id, point);
|
|
|
|
doc->AddTool(splPath1id, point);
|
|
|
|
doc->AddTool(splPath2id, point);
|
|
|
|
doc->IncrementReferens(splinePathId);
|
|
|
|
}
|
|
|
|
}
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void VToolCutSplinePath::FullUpdateFromFile()
|
|
|
|
{
|
|
|
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
|
|
|
if (domElement.isElement())
|
|
|
|
{
|
|
|
|
formula = domElement.attribute(AttrLength, "");
|
|
|
|
splinePathId = domElement.attribute(AttrSplinePath, "").toLongLong();
|
|
|
|
}
|
|
|
|
RefreshGeometry();
|
|
|
|
}
|
|
|
|
|
2013-12-20 14:35:14 +01:00
|
|
|
void VToolCutSplinePath::SplineChoosed(qint64 id)
|
|
|
|
{
|
|
|
|
emit ChoosedTool(id, Scene::SplinePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VToolCutSplinePath::ChangedActivDraw(const QString &newName)
|
|
|
|
{
|
|
|
|
if (nameActivDraw == newName)
|
|
|
|
{
|
|
|
|
currentColor = Qt::black;
|
|
|
|
firstSpline->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
|
|
|
firstSpline->setAcceptHoverEvents(true);
|
|
|
|
secondSpline->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
|
|
|
secondSpline->setAcceptHoverEvents(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
currentColor = Qt::gray;
|
|
|
|
firstSpline->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
|
|
|
firstSpline->setAcceptHoverEvents(false);
|
|
|
|
secondSpline->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
|
|
|
secondSpline->setAcceptHoverEvents(false);
|
|
|
|
}
|
|
|
|
firstSpline->setPen(QPen(currentColor, widthHairLine/factor));
|
|
|
|
secondSpline->setPen(QPen(currentColor, widthHairLine/factor));
|
|
|
|
VToolPoint::ChangedActivDraw(newName);
|
|
|
|
}
|
|
|
|
|
2014-01-10 10:16:55 +01:00
|
|
|
void VToolCutSplinePath::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
|
|
|
|
{
|
2014-02-06 14:57:23 +01:00
|
|
|
ContextMenu<DialogCutSplinePath>(this, event);
|
2014-01-10 10:16:55 +01:00
|
|
|
}
|
|
|
|
|
2013-12-18 12:13:32 +01:00
|
|
|
void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|
|
|
{
|
2014-02-06 14:57:23 +01:00
|
|
|
ContextMenu<DialogCutSplinePath>(this, event);
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void VToolCutSplinePath::AddToFile()
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
2013-12-18 12:13:32 +01:00
|
|
|
QDomElement domElement = doc->createElement(TagName);
|
|
|
|
|
2014-01-20 15:00:38 +01:00
|
|
|
SetAttribute(domElement, AttrId, id);
|
|
|
|
SetAttribute(domElement, AttrType, ToolType);
|
|
|
|
SetAttribute(domElement, AttrName, point->name());
|
|
|
|
SetAttribute(domElement, AttrMx, toMM(point->mx()));
|
|
|
|
SetAttribute(domElement, AttrMy, toMM(point->my()));
|
2013-12-18 12:13:32 +01:00
|
|
|
|
2014-01-20 15:00:38 +01:00
|
|
|
SetAttribute(domElement, AttrLength, formula);
|
|
|
|
SetAttribute(domElement, AttrSplinePath, splinePathId);
|
2013-12-18 12:13:32 +01:00
|
|
|
|
|
|
|
AddToCalculation(domElement);
|
|
|
|
}
|
|
|
|
|
2013-12-24 12:24:29 +01:00
|
|
|
void VToolCutSplinePath::RefreshDataInFile()
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
2013-12-24 12:24:29 +01:00
|
|
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
|
|
|
if (domElement.isElement())
|
|
|
|
{
|
2014-01-20 15:00:38 +01:00
|
|
|
SetAttribute(domElement, AttrName, point->name());
|
|
|
|
SetAttribute(domElement, AttrMx, toMM(point->mx()));
|
|
|
|
SetAttribute(domElement, AttrMy, toMM(point->my()));
|
|
|
|
SetAttribute(domElement, AttrLength, formula);
|
|
|
|
SetAttribute(domElement, AttrSplinePath, splinePathId);
|
2013-12-24 12:24:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-18 12:13:32 +01:00
|
|
|
void VToolCutSplinePath::RefreshGeometry()
|
|
|
|
{
|
2013-12-20 14:35:14 +01:00
|
|
|
RefreshSpline(firstSpline, splPath1id, SimpleSpline::ForthPoint);
|
|
|
|
RefreshSpline(secondSpline, splPath2id, SimpleSpline::FirstPoint);
|
2013-12-29 17:48:57 +01:00
|
|
|
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
2013-12-20 14:35:14 +01:00
|
|
|
|
2014-01-08 21:23:08 +01:00
|
|
|
void VToolCutSplinePath::RemoveReferens()
|
|
|
|
{
|
|
|
|
doc->DecrementReferens(splinePathId);
|
|
|
|
}
|
|
|
|
|
2014-02-06 14:57:23 +01:00
|
|
|
void VToolCutSplinePath::SaveDialog(QDomElement &domElement)
|
|
|
|
{
|
|
|
|
Q_CHECK_PTR(dialog);
|
|
|
|
DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog);
|
|
|
|
Q_CHECK_PTR(dialogTool);
|
|
|
|
SetAttribute(domElement, AttrName, dialogTool->getPointName());
|
|
|
|
SetAttribute(domElement, AttrLength, dialogTool->getFormula());
|
|
|
|
SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId()));
|
|
|
|
}
|
|
|
|
|
2013-12-20 14:35:14 +01:00
|
|
|
void VToolCutSplinePath::RefreshSpline(VSimpleSpline *spline, qint64 splPathid, SimpleSpline::Translation tr)
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
const VSplinePath *splPath = VAbstractTool::data.GeometricObject<const VSplinePath *>(splPathid);
|
2013-12-20 14:35:14 +01:00
|
|
|
QPainterPath path;
|
2013-12-29 17:48:57 +01:00
|
|
|
path.addPath(splPath->GetPath());
|
2013-12-20 14:35:14 +01:00
|
|
|
path.setFillRule( Qt::WindingFill );
|
2013-12-31 09:44:54 +01:00
|
|
|
if (tr == SimpleSpline::FirstPoint)
|
2013-12-20 14:35:14 +01:00
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
VSpline spl = splPath->GetSpline(1);
|
|
|
|
path.translate(-spl.GetP1().toQPointF().x(), -spl.GetP1().toQPointF().y());
|
2013-12-20 14:35:14 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
VSpline spl = splPath->GetSpline(splPath->Count());
|
|
|
|
path.translate(-spl.GetP4().toQPointF().x(), -spl.GetP4().toQPointF().y());
|
2013-12-20 14:35:14 +01:00
|
|
|
}
|
|
|
|
spline->setPath(path);
|
|
|
|
}
|