2013-12-18 12:13:32 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vtoolcutsplinepath.cpp
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2013-12-18 12:13:32 +01:00
|
|
|
** @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-21 14:04:39 +01:00
|
|
|
#include "../../dialogs/tools/dialogcutsplinepath.h"
|
2014-06-08 20:10:57 +02:00
|
|
|
#include "../../geometry/vpointf.h"
|
|
|
|
|
|
|
|
#include "../../geometry/vsplinepath.h"
|
2013-12-18 12:13:32 +01:00
|
|
|
|
2014-06-26 12:26:13 +02:00
|
|
|
const QString VToolCutSplinePath::ToolType = QStringLiteral("cutSplinePath");
|
2013-12-18 12:13:32 +01:00
|
|
|
const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath");
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief VToolCutSplinePath constructor.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param data container with variables.
|
|
|
|
* @param id object id in container.
|
|
|
|
* @param formula string with formula length first splinePath.
|
|
|
|
* @param splinePathId id splinePath (we cut this splinePath) in data container.
|
|
|
|
* @param splPath1id id first splinePath after cutting.
|
|
|
|
* @param splPath2id id second splinePath after cutting.
|
|
|
|
* @param typeCreation way we create this tool.
|
|
|
|
* @param parent parent object.
|
|
|
|
*/
|
2014-02-25 15:40:24 +01:00
|
|
|
VToolCutSplinePath::VToolCutSplinePath(VPattern *doc, VContainer *data, const quint32 &id,
|
|
|
|
const QString &formula, const quint32 &splinePathId,
|
|
|
|
const quint32 &splPath1id, const quint32 &splPath2id,
|
2014-06-12 09:22:29 +02:00
|
|
|
const Source &typeCreation, QGraphicsItem *parent)
|
2014-06-26 12:26:13 +02:00
|
|
|
:VToolCut(doc, data, id, formula, splinePathId, splPath1id, splPath2id, parent)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-06-26 12:26:13 +02:00
|
|
|
RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint);
|
|
|
|
RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint);
|
2013-12-20 14:35:14 +01:00
|
|
|
|
2014-06-12 09:22:29 +02:00
|
|
|
if (typeCreation == Source::FromGui)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
|
|
|
AddToFile();
|
|
|
|
}
|
2013-12-24 12:24:29 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
RefreshDataInFile();
|
|
|
|
}
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief setDialog set dialog when user want change tool option.
|
|
|
|
*/
|
2013-12-18 12:13:32 +01:00
|
|
|
void VToolCutSplinePath::setDialog()
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(dialog != nullptr);
|
2014-02-06 14:57:23 +01:00
|
|
|
DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog);
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(dialogTool != nullptr);
|
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);
|
2014-06-26 12:26:13 +02:00
|
|
|
dialogTool->setSplinePathId(curveCutId, id);
|
2014-02-06 14:57:23 +01:00
|
|
|
dialogTool->setPointName(point->name());
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief Create help create tool form GUI.
|
|
|
|
* @param dialog dialog.
|
|
|
|
* @param scene pointer to scene.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param data container with variables.
|
|
|
|
*/
|
2014-02-25 15:02:09 +01:00
|
|
|
void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(dialog != nullptr);
|
2014-02-06 14:57:23 +01:00
|
|
|
DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog);
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(dialogTool != nullptr);
|
2014-05-30 13:50:41 +02:00
|
|
|
const QString pointName = dialogTool->getPointName();
|
2014-02-06 14:57:23 +01:00
|
|
|
QString formula = dialogTool->getFormula();
|
2014-05-30 13:50:41 +02:00
|
|
|
const quint32 splinePathId = dialogTool->getSplinePathId();
|
2014-06-12 09:22:29 +02:00
|
|
|
Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief Create help create tool.
|
|
|
|
* @param _id tool id, 0 if tool doesn't exist yet.
|
|
|
|
* @param pointName point name.
|
|
|
|
* @param formula string with formula length first splinePath.
|
|
|
|
* @param splinePathId id of splinePath in data container.
|
|
|
|
* @param mx label bias x axis.
|
|
|
|
* @param my label bias y axis.
|
|
|
|
* @param scene pointer to scene.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param data container with variables.
|
|
|
|
* @param parse parser file mode.
|
|
|
|
* @param typeCreation way we create this tool.
|
|
|
|
*/
|
2014-05-30 13:50:41 +02:00
|
|
|
void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula,
|
2014-06-13 19:02:41 +02:00
|
|
|
const quint32 &splinePathId, const qreal &mx, const qreal &my,
|
|
|
|
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
|
|
|
|
const Document &parse, const Source &typeCreation)
|
2013-12-18 12:13:32 +01:00
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(splinePathId);
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(splPath != nullptr);
|
2014-05-21 10:51:16 +02:00
|
|
|
|
2014-05-30 13:50:41 +02:00
|
|
|
const qreal result = CheckFormula(formula, data);
|
2013-12-20 14:35:14 +01:00
|
|
|
|
2014-05-21 10:51:16 +02:00
|
|
|
quint32 id = _id;
|
|
|
|
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
|
|
|
|
qint32 p1 = 0, p2 = 0;
|
2013-12-20 14:35:14 +01:00
|
|
|
|
2014-05-21 10:51:16 +02:00
|
|
|
const QPointF point = splPath->CutSplinePath(qApp->toPixel(result), p1, p2, spl1p2, spl1p3, spl2p2, spl2p3);
|
2014-07-25 13:53:39 +02:00
|
|
|
VPointF *p = new VPointF(point, pointName, mx, my);
|
2014-06-12 09:22:29 +02:00
|
|
|
if (typeCreation == Source::FromGui)
|
2014-05-21 10:51:16 +02:00
|
|
|
{
|
|
|
|
id = data->AddGObject(p);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data->UpdateGObject(id, p);
|
|
|
|
}
|
2013-12-20 14:35:14 +01:00
|
|
|
|
2014-05-21 10:51:16 +02:00
|
|
|
quint32 splPath1id = id + 1;
|
|
|
|
quint32 splPath2id = id + 2;
|
2013-12-20 14:35:14 +01:00
|
|
|
|
2014-05-21 10:51:16 +02:00
|
|
|
VSplinePoint splP1 = splPath->at(p1);
|
|
|
|
VSplinePoint splP2 = splPath->at(p2);
|
|
|
|
const VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p, splPath->getKCurve());
|
|
|
|
const VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P(), splPath->getKCurve());
|
|
|
|
|
|
|
|
VSplinePath *splPath1 = new VSplinePath();
|
|
|
|
VSplinePath *splPath2 = new VSplinePath();
|
2014-06-19 11:29:56 +02:00
|
|
|
|
|
|
|
for (qint32 i = 0; i < splPath->CountPoint(); i++)
|
2014-05-21 10:51:16 +02:00
|
|
|
{
|
2014-06-19 11:29:56 +02:00
|
|
|
if (i <= p1 && i < p2)
|
2014-03-06 15:01:15 +01:00
|
|
|
{
|
2014-06-19 11:29:56 +02:00
|
|
|
if (i == p1)
|
2013-12-20 14:35:14 +01:00
|
|
|
{
|
2014-06-19 11:29:56 +02:00
|
|
|
splPath1->append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1()+180, spl1.GetKasm1(),
|
|
|
|
spl1.GetAngle1()));
|
|
|
|
VSplinePoint cutPoint;
|
|
|
|
if (typeCreation == Source::FromGui)
|
2013-12-31 09:44:54 +01:00
|
|
|
{
|
2014-06-19 11:29:56 +02:00
|
|
|
cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(), spl1.GetAngle2()+180,
|
|
|
|
spl1.GetAngle2());
|
2013-12-20 14:35:14 +01:00
|
|
|
}
|
2014-06-19 11:29:56 +02:00
|
|
|
else
|
2013-12-20 14:35:14 +01:00
|
|
|
{
|
2014-06-19 11:29:56 +02:00
|
|
|
cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(), spl2.GetKasm1(),
|
|
|
|
spl1.GetAngle2()+180);
|
2013-12-20 14:35:14 +01:00
|
|
|
}
|
2014-06-19 11:29:56 +02:00
|
|
|
splPath1->append(cutPoint);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
splPath1->append(splPath->at(i));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (i == p2)
|
|
|
|
{
|
|
|
|
const VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl2.GetAngle1()+180,
|
|
|
|
spl2.GetKasm1(), spl2.GetAngle1());
|
|
|
|
splPath2->append(cutPoint);
|
|
|
|
splPath2->append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2(), splP2.KAsm2(),
|
|
|
|
spl2.GetAngle2()+180));
|
|
|
|
continue;
|
2013-12-20 14:35:14 +01:00
|
|
|
}
|
2014-06-19 11:29:56 +02:00
|
|
|
splPath2->append(splPath->at(i));
|
2014-05-21 10:51:16 +02:00
|
|
|
}
|
2014-06-19 11:29:56 +02:00
|
|
|
}
|
2013-12-20 14:35:14 +01:00
|
|
|
|
2014-06-19 11:29:56 +02:00
|
|
|
splPath1->setMaxCountPoints(splPath->CountPoint());
|
|
|
|
splPath2->setMaxCountPoints(splPath->CountPoint());
|
2014-01-08 21:23:08 +01:00
|
|
|
|
2014-06-19 11:29:56 +02:00
|
|
|
if (typeCreation == Source::FromGui)
|
|
|
|
{
|
2014-05-21 10:51:16 +02:00
|
|
|
splPath1id = data->AddGObject(splPath1);
|
|
|
|
data->AddLengthSpline(splPath1->name(), qApp->fromPixel(splPath1->GetLength()));
|
2013-12-18 12:13:32 +01:00
|
|
|
|
2014-05-21 10:51:16 +02:00
|
|
|
splPath2id = data->AddGObject(splPath2);
|
|
|
|
data->AddLengthSpline(splPath2->name(), qApp->fromPixel(splPath2->GetLength()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data->UpdateGObject(splPath1id, splPath1);
|
|
|
|
data->AddLengthSpline(splPath1->name(), qApp->fromPixel(splPath1->GetLength()));
|
2013-12-20 14:35:14 +01:00
|
|
|
|
2014-05-21 10:51:16 +02:00
|
|
|
data->UpdateGObject(splPath2id, splPath2);
|
|
|
|
data->AddLengthSpline(splPath2->name(), qApp->fromPixel(splPath2->GetLength()));
|
2013-12-20 14:35:14 +01:00
|
|
|
|
2014-05-21 10:51:16 +02:00
|
|
|
if (parse != Document::FullParse)
|
2013-12-20 14:35:14 +01:00
|
|
|
{
|
2014-05-21 10:51:16 +02:00
|
|
|
doc->UpdateToolData(id, data);
|
2013-12-20 14:35:14 +01:00
|
|
|
}
|
|
|
|
}
|
2014-06-19 11:29:56 +02:00
|
|
|
|
2014-06-12 09:22:29 +02:00
|
|
|
VDrawTool::AddRecord(id, Tool::CutSplinePathTool, doc);
|
2014-05-21 10:51:16 +02: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);
|
2014-06-24 10:23:39 +02:00
|
|
|
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable);
|
2014-05-21 10:51:16 +02:00
|
|
|
doc->AddTool(id, point);
|
|
|
|
doc->AddTool(splPath1id, point);
|
|
|
|
doc->AddTool(splPath2id, point);
|
|
|
|
doc->IncrementReferens(splinePathId);
|
|
|
|
}
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief FullUpdateFromFile update tool data form file.
|
|
|
|
*/
|
2013-12-18 12:13:32 +01:00
|
|
|
void VToolCutSplinePath::FullUpdateFromFile()
|
|
|
|
{
|
2014-06-26 12:26:13 +02:00
|
|
|
FullUpdateCurveFromFile(AttrSplinePath);
|
2013-12-18 12:13:32 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
2014-06-26 12:26:13 +02:00
|
|
|
* @brief CurveChoosed send signal about selection splinePath.
|
2014-06-13 19:02:41 +02:00
|
|
|
* @param id object id in container.
|
|
|
|
*/
|
2014-06-26 12:26:13 +02:00
|
|
|
void VToolCutSplinePath::CurveChoosed(quint32 id)
|
2013-12-20 14:35:14 +01:00
|
|
|
{
|
2014-06-12 09:22:29 +02:00
|
|
|
emit ChoosedTool(id, SceneObject::SplinePath);
|
2013-12-20 14:35:14 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief ShowContextMenu show context menu.
|
|
|
|
* @param event context menu event.
|
|
|
|
*/
|
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
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief contextMenuEvent handle context menu events.
|
|
|
|
* @param event context menu event.
|
|
|
|
*/
|
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
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief AddToFile add tag with informations about tool into file.
|
|
|
|
*/
|
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-03-21 11:08:29 +01:00
|
|
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
2014-02-25 15:02:09 +01:00
|
|
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
|
|
|
doc->SetAttribute(domElement, AttrName, point->name());
|
2014-03-19 19:27:11 +01:00
|
|
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
|
|
|
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
|
2013-12-18 12:13:32 +01:00
|
|
|
|
2014-02-25 15:02:09 +01:00
|
|
|
doc->SetAttribute(domElement, AttrLength, formula);
|
2014-06-26 12:26:13 +02:00
|
|
|
doc->SetAttribute(domElement, AttrSplinePath, curveCutId);
|
2013-12-18 12:13:32 +01:00
|
|
|
|
|
|
|
AddToCalculation(domElement);
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
|
|
|
|
*/
|
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-02-25 15:02:09 +01:00
|
|
|
doc->SetAttribute(domElement, AttrName, point->name());
|
2014-03-19 19:27:11 +01:00
|
|
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
|
|
|
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
|
2014-02-25 15:02:09 +01:00
|
|
|
doc->SetAttribute(domElement, AttrLength, formula);
|
2014-06-26 12:26:13 +02:00
|
|
|
doc->SetAttribute(domElement, AttrSplinePath, curveCutId);
|
2013-12-24 12:24:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief SaveDialog save options into file after change in dialog.
|
|
|
|
*/
|
2014-02-06 14:57:23 +01:00
|
|
|
void VToolCutSplinePath::SaveDialog(QDomElement &domElement)
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(dialog != nullptr);
|
2014-02-06 14:57:23 +01:00
|
|
|
DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog);
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(dialogTool != nullptr);
|
2014-02-25 15:02:09 +01:00
|
|
|
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
|
|
|
|
doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula());
|
|
|
|
doc->SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId()));
|
2014-02-06 14:57:23 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
2014-06-26 12:26:13 +02:00
|
|
|
* @brief RefreshCurve refresh curve on scene.
|
|
|
|
* @param curve curve.
|
|
|
|
* @param curveId curve id.
|
|
|
|
* @param tr point type.
|
2014-06-13 19:02:41 +02:00
|
|
|
*/
|
2014-06-26 12:26:13 +02:00
|
|
|
void VToolCutSplinePath::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint tr)
|
2013-12-20 14:35:14 +01:00
|
|
|
{
|
2014-06-26 12:26:13 +02:00
|
|
|
const VSplinePath *splPath = VAbstractTool::data.GeometricObject<const VSplinePath *>(curveId);
|
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 );
|
2014-06-25 16:14:02 +02:00
|
|
|
if (tr == SimpleCurvePoint::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
|
|
|
}
|
2014-06-26 12:26:13 +02:00
|
|
|
curve->setPath(path);
|
2013-12-20 14:35:14 +01:00
|
|
|
}
|