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 vtoolspline.cpp
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)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-08-05 10:37:56 +02:00
|
|
|
#include "vtoolspline.h"
|
2013-11-06 18:06:00 +01:00
|
|
|
#include "../../geometry/vspline.h"
|
2014-02-21 14:04:39 +01:00
|
|
|
#include "../../dialogs/tools/dialogspline.h"
|
2014-06-09 19:39:18 +02:00
|
|
|
#include "../../undocommands/movespline.h"
|
2014-09-03 15:52:16 +02:00
|
|
|
#include "../../visualization/vistoolspline.h"
|
2013-08-20 12:26:02 +02:00
|
|
|
|
2013-10-29 14:45:07 +01:00
|
|
|
const QString VToolSpline::ToolType = QStringLiteral("simple");
|
2013-08-05 10:37:56 +02:00
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief VToolSpline constructor.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param data container with variables.
|
|
|
|
* @param id object id in container.
|
|
|
|
* @param typeCreation way we create this tool.
|
|
|
|
* @param parent parent object.
|
|
|
|
*/
|
2014-06-12 09:22:29 +02:00
|
|
|
VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
2014-07-24 12:19:41 +02:00
|
|
|
QGraphicsItem *parent)
|
|
|
|
:VAbstractSpline(doc, data, id, parent)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-08-17 17:50:33 +02:00
|
|
|
sceneType = SceneObject::Spline;
|
|
|
|
|
2014-03-26 05:39:07 +01:00
|
|
|
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor));
|
2013-08-05 10:37:56 +02:00
|
|
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
2014-01-03 16:13:43 +01:00
|
|
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
2013-08-05 10:37:56 +02:00
|
|
|
this->setAcceptHoverEvents(true);
|
2014-08-17 16:22:30 +02:00
|
|
|
this->setPath(ToolPath());
|
2013-08-05 10:37:56 +02:00
|
|
|
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
2014-06-12 09:22:29 +02:00
|
|
|
VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePointPosition::FirstPoint, spl->GetP2(),
|
2013-12-29 17:48:57 +01:00
|
|
|
spl->GetP1().toQPointF(), this);
|
2013-08-05 10:37:56 +02:00
|
|
|
connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this,
|
2013-08-09 08:49:34 +02:00
|
|
|
&VToolSpline::ControlPointChangePosition);
|
|
|
|
connect(this, &VToolSpline::RefreshLine, controlPoint1, &VControlPointSpline::RefreshLine);
|
|
|
|
connect(this, &VToolSpline::setEnabledPoint, controlPoint1, &VControlPointSpline::setEnabledPoint);
|
|
|
|
controlPoints.append(controlPoint1);
|
2013-08-05 10:37:56 +02:00
|
|
|
|
2014-06-12 09:22:29 +02:00
|
|
|
VControlPointSpline *controlPoint2 = new VControlPointSpline(1, SplinePointPosition::LastPoint, spl->GetP3(),
|
2013-12-29 17:48:57 +01:00
|
|
|
spl->GetP4().toQPointF(), this);
|
2013-08-05 10:37:56 +02:00
|
|
|
connect(controlPoint2, &VControlPointSpline::ControlPointChangePosition, this,
|
2013-08-09 08:49:34 +02:00
|
|
|
&VToolSpline::ControlPointChangePosition);
|
|
|
|
connect(this, &VToolSpline::RefreshLine, controlPoint2, &VControlPointSpline::RefreshLine);
|
|
|
|
connect(this, &VToolSpline::setEnabledPoint, controlPoint2, &VControlPointSpline::setEnabledPoint);
|
|
|
|
controlPoints.append(controlPoint2);
|
2013-08-05 10:37:56 +02:00
|
|
|
|
2014-09-06 10:51:46 +02:00
|
|
|
ShowFoot(false);
|
|
|
|
|
2014-06-12 09:22:29 +02:00
|
|
|
if (typeCreation == Source::FromGui)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
AddToFile();
|
|
|
|
}
|
2013-12-24 12:24:29 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
RefreshDataInFile();
|
|
|
|
}
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
|
|
|
|
2014-10-04 08:37:19 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VToolSpline::~VToolSpline()
|
|
|
|
{}
|
|
|
|
|
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-11-04 21:35:15 +01:00
|
|
|
void VToolSpline::setDialog()
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(dialog != nullptr);
|
2014-02-06 14:57:23 +01:00
|
|
|
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(dialogTool != nullptr);
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
2015-02-03 11:17:04 +01:00
|
|
|
dialogTool->SetP1(spl->GetP1().id());
|
|
|
|
dialogTool->SetP4(spl->GetP4().id());
|
|
|
|
dialogTool->SetAngle1(spl->GetAngle1());
|
|
|
|
dialogTool->SetAngle2(spl->GetAngle2());
|
|
|
|
dialogTool->SetKAsm1(spl->GetKasm1());
|
|
|
|
dialogTool->SetKAsm2(spl->GetKasm2());
|
|
|
|
dialogTool->SetKCurve(spl->GetKcurve());
|
2015-02-06 18:43:31 +01:00
|
|
|
dialogTool->SetColor(lineColor);
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief Create help create tool from GUI.
|
|
|
|
* @param dialog dialog.
|
|
|
|
* @param scene pointer to scene.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param data container with variables.
|
2014-08-18 16:42:53 +02:00
|
|
|
* @return the created tool
|
2014-06-13 19:02:41 +02:00
|
|
|
*/
|
2014-08-18 16:42:53 +02:00
|
|
|
VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(dialog != nullptr);
|
2014-02-06 14:57:23 +01:00
|
|
|
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(dialogTool != nullptr);
|
2015-02-03 11:17:04 +01:00
|
|
|
const quint32 p1 = dialogTool->GetP1();
|
|
|
|
const quint32 p4 = dialogTool->GetP4();
|
|
|
|
const qreal kAsm1 = dialogTool->GetKAsm1();
|
|
|
|
const qreal kAsm2 = dialogTool->GetKAsm2();
|
|
|
|
const qreal angle1 = dialogTool->GetAngle1();
|
|
|
|
const qreal angle2 = dialogTool->GetAngle2();
|
|
|
|
const qreal kCurve = dialogTool->GetKCurve();
|
2014-08-18 16:42:53 +02:00
|
|
|
VToolSpline *spl = nullptr;
|
|
|
|
spl = Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, doc, data, Document::FullParse,
|
|
|
|
Source::FromGui);
|
|
|
|
if (spl != nullptr)
|
|
|
|
{
|
|
|
|
spl->dialog=dialogTool;
|
|
|
|
}
|
|
|
|
return spl;
|
2013-08-13 18:48:36 +02: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 p1 id first spline point.
|
|
|
|
* @param p4 id last spline point.
|
|
|
|
* @param kAsm1 coefficient of length first control line.
|
|
|
|
* @param kAsm2 coefficient of length second control line.
|
|
|
|
* @param angle1 angle from first point to first control point.
|
|
|
|
* @param angle2 angle from second point to second control point.
|
|
|
|
* @param kCurve coefficient of curvature spline.
|
|
|
|
* @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-08-18 16:42:53 +02:00
|
|
|
* @return the created tool
|
2014-06-13 19:02:41 +02:00
|
|
|
*/
|
2014-08-18 16:42:53 +02:00
|
|
|
VToolSpline* VToolSpline::Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1,
|
|
|
|
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
|
|
|
|
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
|
|
|
|
const Document &parse, const Source &typeCreation)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
VPointF point1 = *data->GeometricObject<VPointF>(p1);
|
|
|
|
VPointF point4 = *data->GeometricObject<VPointF>(p4);
|
2013-12-29 17:48:57 +01:00
|
|
|
VSpline *spline = new VSpline(point1, point4, angle1, angle2, kAsm1, kAsm2, kCurve);
|
2014-02-25 15:40:24 +01:00
|
|
|
quint32 id = _id;
|
2014-06-12 09:22:29 +02:00
|
|
|
if (typeCreation == Source::FromGui)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
id = data->AddGObject(spline);
|
2014-08-15 19:27:30 +02:00
|
|
|
data->AddCurveLength<VSplineLength>(id);
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
data->UpdateGObject(id, spline);
|
2014-08-15 19:27:30 +02:00
|
|
|
data->AddCurveLength<VSplineLength>(id);
|
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-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
}
|
2014-08-26 20:31:28 +02:00
|
|
|
VDrawTool::AddRecord(id, Tool::Spline, doc);
|
2013-11-04 21:35:15 +01:00
|
|
|
if (parse == Document::FullParse)
|
|
|
|
{
|
2013-09-10 14:29:06 +02:00
|
|
|
VToolSpline *spl = new VToolSpline(doc, data, id, typeCreation);
|
2013-08-13 18:48:36 +02:00
|
|
|
scene->addItem(spl);
|
|
|
|
connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
2013-10-16 11:17:34 +02:00
|
|
|
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSpline::SetFactor);
|
2014-06-24 10:23:39 +02:00
|
|
|
connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSpline::Disable);
|
2013-09-30 18:29:03 +02:00
|
|
|
doc->AddTool(id, spl);
|
|
|
|
doc->IncrementReferens(p1);
|
|
|
|
doc->IncrementReferens(p4);
|
2014-08-18 16:42:53 +02:00
|
|
|
return spl;
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
2014-08-18 16:42:53 +02:00
|
|
|
return nullptr;
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
|
2014-09-01 18:36:15 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VSpline VToolSpline::getSpline() const
|
|
|
|
{
|
|
|
|
QSharedPointer<VSpline> spline = VAbstractTool::data.GeometricObject<VSpline>(id);
|
|
|
|
return *spline.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VToolSpline::setSpline(const VSpline &spl)
|
|
|
|
{
|
|
|
|
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
|
|
|
QSharedPointer<VSpline> spline = qSharedPointerDynamicCast<VSpline>(obj);
|
|
|
|
*spline.data() = spl;
|
|
|
|
SaveOption(obj);
|
|
|
|
}
|
|
|
|
|
2014-09-03 15:52:16 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VToolSpline::ShowVisualization(bool show)
|
|
|
|
{
|
|
|
|
if (show)
|
|
|
|
{
|
|
|
|
if (vis == nullptr)
|
|
|
|
{
|
2014-09-27 14:50:00 +02:00
|
|
|
VisToolSpline *visual = new VisToolSpline(getData(), this);
|
2014-09-03 15:52:16 +02:00
|
|
|
VMainGraphicsScene *scene = qApp->getCurrentScene();
|
|
|
|
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
|
|
|
|
|
|
|
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
|
|
|
visual->setPoint1Id(spl->GetP1().id());
|
|
|
|
visual->setPoint4Id(spl->GetP4().id());
|
2015-02-03 11:17:04 +01:00
|
|
|
visual->SetAngle1(spl->GetAngle1());
|
|
|
|
visual->SetAngle2(spl->GetAngle2());
|
|
|
|
visual->SetKAsm1(spl->GetKasm1());
|
|
|
|
visual->SetKAsm2(spl->GetKasm2());
|
|
|
|
visual->SetKCurve(spl->GetKcurve());
|
2014-09-03 15:52:16 +02:00
|
|
|
visual->RefreshGeometry();
|
|
|
|
vis = visual;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
VisToolSpline *visual = qobject_cast<VisToolSpline *>(vis);
|
|
|
|
if (visual != nullptr)
|
|
|
|
{
|
|
|
|
visual->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delete vis;
|
|
|
|
vis = nullptr;
|
|
|
|
}
|
2014-09-06 10:51:46 +02:00
|
|
|
ShowFoot(show);
|
2014-09-03 15:52:16 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief ControlPointChangePosition handle change position control point.
|
|
|
|
* @param indexSpline position spline in spline list.
|
|
|
|
* @param position position point in spline.
|
|
|
|
* @param pos new position.
|
|
|
|
*/
|
2014-06-12 09:22:29 +02:00
|
|
|
void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
|
2013-11-07 15:40:39 +01:00
|
|
|
const QPointF &pos)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-08-09 08:49:34 +02:00
|
|
|
Q_UNUSED(indexSpline);
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VSpline> spline = VAbstractTool::data.GeometricObject<VSpline>(id);
|
2013-12-29 17:48:57 +01:00
|
|
|
VSpline spl;
|
2014-06-12 09:22:29 +02:00
|
|
|
if (position == SplinePointPosition::FirstPoint)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
spl = VSpline(spline->GetP1(), pos, spline->GetP3(), spline->GetP4(), spline->GetKcurve());
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
spl = VSpline(spline->GetP1(), spline->GetP2(), pos, spline->GetP4(), spline->GetKcurve());
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
2014-06-09 19:39:18 +02:00
|
|
|
|
2014-08-21 14:44:40 +02:00
|
|
|
MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, id, this->scene());
|
2014-06-09 19:39:18 +02:00
|
|
|
connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VPattern::LiteParseTree);
|
|
|
|
qApp->getUndoStack()->push(moveSpl);
|
2013-08-05 10:37:56 +02: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-11-04 21:35:15 +01:00
|
|
|
void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|
|
|
{
|
2014-02-06 14:57:23 +01:00
|
|
|
ContextMenu<DialogSpline>(this, event);
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief RemoveReferens decrement value of reference.
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolSpline::RemoveReferens()
|
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
2013-12-29 17:48:57 +01:00
|
|
|
doc->DecrementReferens(spl->GetP1().id());
|
|
|
|
doc->DecrementReferens(spl->GetP4().id());
|
2013-09-30 18:29:03 +02: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 VToolSpline::SaveDialog(QDomElement &domElement)
|
|
|
|
{
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(dialog != nullptr);
|
2014-02-06 14:57:23 +01:00
|
|
|
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
|
2014-05-30 21:56:05 +02:00
|
|
|
SCASSERT(dialogTool != nullptr);
|
2014-02-06 14:57:23 +01:00
|
|
|
|
2015-02-03 11:17:04 +01:00
|
|
|
VPointF point1 = *VAbstractTool::data.GeometricObject<VPointF>(dialogTool->GetP1());
|
|
|
|
VPointF point4 = *VAbstractTool::data.GeometricObject<VPointF>(dialogTool->GetP4());
|
|
|
|
VSpline spl = VSpline (point1, point4, dialogTool->GetAngle1(), dialogTool->GetAngle2(),
|
|
|
|
dialogTool->GetKAsm1(), dialogTool->GetKAsm2(), dialogTool->GetKCurve());
|
2014-02-06 14:57:23 +01:00
|
|
|
|
2014-08-09 10:43:01 +02:00
|
|
|
controlPoints[0]->blockSignals(true);
|
|
|
|
controlPoints[1]->blockSignals(true);
|
|
|
|
|
2014-02-06 14:57:23 +01:00
|
|
|
controlPoints[0]->setPos(spl.GetP2());
|
|
|
|
controlPoints[1]->setPos(spl.GetP3());
|
2014-08-09 10:43:01 +02:00
|
|
|
|
|
|
|
controlPoints[0]->blockSignals(false);
|
|
|
|
controlPoints[1]->blockSignals(false);
|
2014-02-06 14:57:23 +01:00
|
|
|
|
2015-02-03 11:17:04 +01:00
|
|
|
spl = VSpline (point1, controlPoints[0]->pos(), controlPoints[1]->pos(), point4, dialogTool->GetKCurve());
|
2014-02-06 14:57:23 +01:00
|
|
|
|
2014-02-25 15:02:09 +01:00
|
|
|
doc->SetAttribute(domElement, AttrPoint1, spl.GetP1().id());
|
|
|
|
doc->SetAttribute(domElement, AttrPoint4, spl.GetP4().id());
|
|
|
|
doc->SetAttribute(domElement, AttrAngle1, spl.GetAngle1());
|
|
|
|
doc->SetAttribute(domElement, AttrAngle2, spl.GetAngle2());
|
|
|
|
doc->SetAttribute(domElement, AttrKAsm1, spl.GetKasm1());
|
|
|
|
doc->SetAttribute(domElement, AttrKAsm2, spl.GetKasm2());
|
|
|
|
doc->SetAttribute(domElement, AttrKCurve, spl.GetKcurve());
|
2015-02-06 18:50:33 +01:00
|
|
|
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
|
2014-02-06 14:57:23 +01:00
|
|
|
}
|
|
|
|
|
2014-08-30 21:58:31 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VToolSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
|
|
|
{
|
|
|
|
QSharedPointer<VSpline> spl = qSharedPointerDynamicCast<VSpline>(obj);
|
|
|
|
SCASSERT(spl.isNull() == false);
|
|
|
|
|
|
|
|
doc->SetAttribute(tag, VDomDocument::AttrId, id);
|
|
|
|
doc->SetAttribute(tag, AttrType, ToolType);
|
|
|
|
doc->SetAttribute(tag, AttrPoint1, spl->GetP1().id());
|
|
|
|
doc->SetAttribute(tag, AttrPoint4, spl->GetP4().id());
|
|
|
|
doc->SetAttribute(tag, AttrAngle1, spl->GetAngle1());
|
|
|
|
doc->SetAttribute(tag, AttrAngle2, spl->GetAngle2());
|
|
|
|
doc->SetAttribute(tag, AttrKAsm1, spl->GetKasm1());
|
|
|
|
doc->SetAttribute(tag, AttrKAsm2, spl->GetKasm2());
|
|
|
|
doc->SetAttribute(tag, AttrKCurve, spl->GetKcurve());
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief RefreshGeometry refresh item on scene.
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolSpline::RefreshGeometry()
|
|
|
|
{
|
2015-02-06 12:41:30 +01:00
|
|
|
this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
2014-09-10 19:57:08 +02:00
|
|
|
if (isHovered)
|
2014-08-19 13:16:00 +02:00
|
|
|
{
|
|
|
|
this->setPath(ToolPath(PathDirection::Show));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->setPath(ToolPath());
|
|
|
|
}
|
2014-08-17 16:22:30 +02:00
|
|
|
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
|
|
|
QPointF splinePoint = VAbstractTool::data.GeometricObject<VPointF>(spl->GetP1().id())->toQPointF();
|
2013-12-29 17:48:57 +01:00
|
|
|
QPointF controlPoint = spl->GetP2();
|
2014-06-12 09:22:29 +02:00
|
|
|
emit RefreshLine(1, SplinePointPosition::FirstPoint, controlPoint, splinePoint);
|
2014-08-21 14:44:40 +02:00
|
|
|
splinePoint = VAbstractTool::data.GeometricObject<VPointF>(spl->GetP4().id())->toQPointF();
|
2013-12-29 17:48:57 +01:00
|
|
|
controlPoint = spl->GetP3();
|
2014-06-12 09:22:29 +02:00
|
|
|
emit RefreshLine(1, SplinePointPosition::LastPoint, controlPoint, splinePoint);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
2014-08-09 10:43:01 +02:00
|
|
|
controlPoints[0]->blockSignals(true);
|
|
|
|
controlPoints[1]->blockSignals(true);
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
controlPoints[0]->setPos(spl->GetP2());
|
|
|
|
controlPoints[1]->setPos(spl->GetP3());
|
2014-08-09 10:43:01 +02:00
|
|
|
|
|
|
|
controlPoints[0]->blockSignals(false);
|
|
|
|
controlPoints[1]->blockSignals(false);
|
2014-09-03 15:52:16 +02:00
|
|
|
|
|
|
|
if (vis != nullptr)
|
|
|
|
{
|
|
|
|
VisToolSpline *visual = qobject_cast<VisToolSpline *>(vis);
|
|
|
|
visual->setPoint1Id(spl->GetP1().id());
|
|
|
|
visual->setPoint4Id(spl->GetP4().id());
|
2015-02-03 11:17:04 +01:00
|
|
|
visual->SetAngle1(spl->GetAngle1());
|
|
|
|
visual->SetAngle2(spl->GetAngle2());
|
|
|
|
visual->SetKAsm1(spl->GetKasm1());
|
|
|
|
visual->SetKAsm2(spl->GetKasm2());
|
|
|
|
visual->SetKCurve(spl->GetKcurve());
|
2014-09-03 15:52:16 +02:00
|
|
|
visual->RefreshGeometry();
|
|
|
|
}
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|