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
|
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-08-05 10:37:56 +02:00
|
|
|
#include "vtoolspline.h"
|
2013-11-06 18:06:00 +01:00
|
|
|
#include "../../geometry/vspline.h"
|
2014-02-06 14:57:23 +01:00
|
|
|
#include "../../dialogs/dialogspline.h"
|
2013-08-20 12:26:02 +02:00
|
|
|
|
2013-10-29 14:45:07 +01:00
|
|
|
const QString VToolSpline::TagName = QStringLiteral("spline");
|
|
|
|
const QString VToolSpline::ToolType = QStringLiteral("simple");
|
2013-08-05 10:37:56 +02:00
|
|
|
|
2013-11-06 22:11:12 +01:00
|
|
|
VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id, const Tool::Sources &typeCreation,
|
2013-11-04 21:35:15 +01:00
|
|
|
QGraphicsItem *parent)
|
2014-02-06 14:57:23 +01:00
|
|
|
:VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector<VControlPointSpline *>())
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-10-21 16:09:05 +02:00
|
|
|
ignoreFullUpdate = true;
|
2013-08-05 10:37:56 +02:00
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
const VSpline *spl = data->GeometricObject<const VSpline *>(id);
|
2013-08-05 10:37:56 +02:00
|
|
|
QPainterPath path;
|
2013-12-29 17:48:57 +01:00
|
|
|
path.addPath(spl->GetPath());
|
2013-08-05 10:37:56 +02:00
|
|
|
path.setFillRule( Qt::WindingFill );
|
|
|
|
this->setPath(path);
|
2014-02-28 13:58:37 +01:00
|
|
|
this->setPen(QPen(Qt::black, toPixel(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);
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePoint::FirstPoint, spl->GetP2(),
|
|
|
|
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
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
VControlPointSpline *controlPoint2 = new VControlPointSpline(1, SplinePoint::LastPoint, spl->GetP3(),
|
|
|
|
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
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
if (typeCreation == Tool::FromGui)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolSpline::setDialog()
|
|
|
|
{
|
2014-02-06 14:57:23 +01:00
|
|
|
Q_CHECK_PTR(dialog);
|
|
|
|
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
|
|
|
|
Q_CHECK_PTR(dialogTool);
|
2013-12-29 17:48:57 +01:00
|
|
|
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
|
2014-02-06 14:57:23 +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());
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
|
2014-02-06 14:57:23 +01:00
|
|
|
void VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
2013-11-04 21:35:15 +01:00
|
|
|
VContainer *data)
|
|
|
|
{
|
2014-02-06 14:57:23 +01:00
|
|
|
Q_CHECK_PTR(dialog);
|
|
|
|
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
|
|
|
|
Q_CHECK_PTR(dialogTool);
|
|
|
|
qint64 p1 = dialogTool->getP1();
|
|
|
|
qint64 p4 = dialogTool->getP4();
|
|
|
|
qreal kAsm1 = dialogTool->getKAsm1();
|
|
|
|
qreal kAsm2 = dialogTool->getKAsm2();
|
|
|
|
qreal angle1 = dialogTool->getAngle1();
|
|
|
|
qreal angle2 = dialogTool->getAngle2();
|
|
|
|
qreal kCurve = dialogTool->getKCurve();
|
2013-08-13 18:48:36 +02:00
|
|
|
Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, doc, data, Document::FullParse,
|
2013-09-10 14:29:06 +02:00
|
|
|
Tool::FromGui);
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1,
|
|
|
|
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
|
2013-11-04 21:35:15 +01:00
|
|
|
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
2013-11-06 22:11:12 +01:00
|
|
|
const Document::Documents &parse, const Tool::Sources &typeCreation)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
VPointF point1 = *data->GeometricObject<const VPointF *>(p1);
|
|
|
|
VPointF point4 = *data->GeometricObject<const VPointF *>(p4);
|
|
|
|
VSpline *spline = new VSpline(point1, point4, angle1, angle2, kAsm1, kAsm2, kCurve);
|
2014-01-30 14:47:41 +01:00
|
|
|
Q_CHECK_PTR(spline);
|
2013-08-13 18:48:36 +02:00
|
|
|
qint64 id = _id;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (typeCreation == Tool::FromGui)
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
id = data->AddGObject(spline);
|
|
|
|
data->AddLengthSpline(spline->name(), toMM(spline->GetLength()));
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
data->UpdateGObject(id, spline);
|
|
|
|
data->AddLengthSpline(spline->name(), toMM(spline->GetLength()));
|
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
|
|
|
}
|
|
|
|
}
|
2013-09-27 11:17:00 +02:00
|
|
|
VDrawTool::AddRecord(id, Tool::SplineTool, 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);
|
2013-09-30 18:29:03 +02:00
|
|
|
doc->AddTool(id, spl);
|
|
|
|
doc->IncrementReferens(p1);
|
|
|
|
doc->IncrementReferens(p4);
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolSpline::FullUpdateFromFile()
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
RefreshGeometry();
|
|
|
|
}
|
|
|
|
|
2013-11-07 15:40:39 +01:00
|
|
|
void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const SplinePoint::Position &position,
|
|
|
|
const QPointF &pos)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-08-09 08:49:34 +02:00
|
|
|
Q_UNUSED(indexSpline);
|
2013-12-29 17:48:57 +01:00
|
|
|
const VSpline *spline = VAbstractTool::data.GeometricObject<const VSpline *>(id);
|
|
|
|
VSpline spl;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (position == SplinePoint::FirstPoint)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
2013-11-04 21:35:15 +01:00
|
|
|
if (domElement.isElement())
|
|
|
|
{
|
2014-01-20 15:00:38 +01:00
|
|
|
SetAttribute(domElement, AttrAngle1, QString().setNum(spl.GetAngle1()));
|
|
|
|
SetAttribute(domElement, AttrAngle2, QString().setNum(spl.GetAngle2()));
|
|
|
|
SetAttribute(domElement, AttrKAsm1, QString().setNum(spl.GetKasm1()));
|
|
|
|
SetAttribute(domElement, AttrKAsm2, QString().setNum(spl.GetKasm2()));
|
|
|
|
SetAttribute(domElement, AttrKCurve, QString().setNum(spl.GetKcurve()));
|
2013-08-05 10:37:56 +02:00
|
|
|
emit FullUpdateTree();
|
2014-02-06 14:57:23 +01:00
|
|
|
emit toolhaveChange();
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolSpline::AddToFile()
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
|
2013-10-29 14:45:07 +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, AttrPoint1, spl->GetP1().id());
|
|
|
|
SetAttribute(domElement, AttrPoint4, spl->GetP4().id());
|
|
|
|
SetAttribute(domElement, AttrAngle1, spl->GetAngle1());
|
|
|
|
SetAttribute(domElement, AttrAngle2, spl->GetAngle2());
|
|
|
|
SetAttribute(domElement, AttrKAsm1, spl->GetKasm1());
|
|
|
|
SetAttribute(domElement, AttrKAsm2, spl->GetKasm2());
|
|
|
|
SetAttribute(domElement, AttrKCurve, spl->GetKcurve());
|
2013-08-05 10:37:56 +02:00
|
|
|
|
2013-09-10 14:29:06 +02:00
|
|
|
AddToCalculation(domElement);
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
|
|
|
|
2013-12-24 12:24:29 +01:00
|
|
|
void VToolSpline::RefreshDataInFile()
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(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, AttrPoint1, spl->GetP1().id());
|
|
|
|
SetAttribute(domElement, AttrPoint4, spl->GetP4().id());
|
|
|
|
SetAttribute(domElement, AttrAngle1, spl->GetAngle1());
|
|
|
|
SetAttribute(domElement, AttrAngle2, spl->GetAngle2());
|
|
|
|
SetAttribute(domElement, AttrKAsm1, spl->GetKasm1());
|
|
|
|
SetAttribute(domElement, AttrKAsm2, spl->GetKasm2());
|
|
|
|
SetAttribute(domElement, AttrKCurve, spl->GetKcurve());
|
2013-12-24 12:24:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|
|
|
{
|
|
|
|
if (event->button() == Qt::LeftButton)
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
emit ChoosedTool(id, Scene::Spline);
|
|
|
|
}
|
|
|
|
QGraphicsItem::mouseReleaseEvent(event);
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
Q_UNUSED(event);
|
2014-02-28 13:58:37 +01:00
|
|
|
this->setPen(QPen(currentColor, toPixel(widthMainLine)/factor));
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
Q_UNUSED(event);
|
2014-02-28 13:58:37 +01:00
|
|
|
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolSpline::RemoveReferens()
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
|
|
|
|
doc->DecrementReferens(spl->GetP1().id());
|
|
|
|
doc->DecrementReferens(spl->GetP4().id());
|
2013-09-30 18:29:03 +02:00
|
|
|
}
|
|
|
|
|
2014-01-03 16:13:43 +01:00
|
|
|
QVariant VToolSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
|
|
|
{
|
|
|
|
if (change == QGraphicsItem::ItemSelectedChange)
|
|
|
|
{
|
|
|
|
if (value == true)
|
|
|
|
{
|
|
|
|
// do stuff if selected
|
|
|
|
this->setFocus();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// do stuff if not selected
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return QGraphicsItem::itemChange(change, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VToolSpline::keyReleaseEvent(QKeyEvent *event)
|
|
|
|
{
|
|
|
|
switch (event->key())
|
|
|
|
{
|
|
|
|
case Qt::Key_Delete:
|
|
|
|
DeleteTool(this);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
QGraphicsItem::keyReleaseEvent ( event );
|
|
|
|
}
|
|
|
|
|
2014-02-06 14:57:23 +01:00
|
|
|
void VToolSpline::SaveDialog(QDomElement &domElement)
|
|
|
|
{
|
|
|
|
Q_CHECK_PTR(dialog);
|
|
|
|
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
|
|
|
|
Q_CHECK_PTR(dialogTool);
|
|
|
|
|
|
|
|
VPointF point1 = *VAbstractTool::data.GeometricObject<const VPointF *>(dialogTool->getP1());
|
|
|
|
VPointF point4 = *VAbstractTool::data.GeometricObject<const VPointF *>(dialogTool->getP4());
|
|
|
|
VSpline spl = VSpline (point1, point4, dialogTool->getAngle1(), dialogTool->getAngle2(),
|
|
|
|
dialogTool->getKAsm1(), dialogTool->getKAsm2(), dialogTool->getKCurve());
|
|
|
|
|
|
|
|
disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
|
|
|
|
&VToolSpline::ControlPointChangePosition);
|
|
|
|
disconnect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
|
|
|
|
&VToolSpline::ControlPointChangePosition);
|
|
|
|
controlPoints[0]->setPos(spl.GetP2());
|
|
|
|
controlPoints[1]->setPos(spl.GetP3());
|
|
|
|
connect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
|
|
|
|
&VToolSpline::ControlPointChangePosition);
|
|
|
|
connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
|
|
|
|
&VToolSpline::ControlPointChangePosition);
|
|
|
|
|
|
|
|
spl = VSpline (point1, controlPoints[0]->pos(), controlPoints[1]->pos(), point4, dialogTool->getKCurve());
|
|
|
|
|
|
|
|
SetAttribute(domElement, AttrPoint1, spl.GetP1().id());
|
|
|
|
SetAttribute(domElement, AttrPoint4, spl.GetP4().id());
|
|
|
|
SetAttribute(domElement, AttrAngle1, spl.GetAngle1());
|
|
|
|
SetAttribute(domElement, AttrAngle2, spl.GetAngle2());
|
|
|
|
SetAttribute(domElement, AttrKAsm1, spl.GetKasm1());
|
|
|
|
SetAttribute(domElement, AttrKAsm2, spl.GetKasm2());
|
|
|
|
SetAttribute(domElement, AttrKCurve, spl.GetKcurve());
|
|
|
|
}
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolSpline::RefreshGeometry()
|
|
|
|
{
|
2014-02-28 13:58:37 +01:00
|
|
|
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
|
2013-12-29 17:48:57 +01:00
|
|
|
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
|
2013-08-05 10:37:56 +02:00
|
|
|
QPainterPath path;
|
2013-12-29 17:48:57 +01:00
|
|
|
path.addPath(spl->GetPath());
|
2013-08-05 10:37:56 +02:00
|
|
|
path.setFillRule( Qt::WindingFill );
|
|
|
|
this->setPath(path);
|
2013-12-29 17:48:57 +01:00
|
|
|
QPointF splinePoint = VAbstractTool::data.GeometricObject<const VPointF *>(spl->GetP1().id())->toQPointF();
|
|
|
|
QPointF controlPoint = spl->GetP2();
|
2013-08-09 08:49:34 +02:00
|
|
|
emit RefreshLine(1, SplinePoint::FirstPoint, controlPoint, splinePoint);
|
2013-12-29 17:48:57 +01:00
|
|
|
splinePoint = VAbstractTool::data.GeometricObject<const VPointF *>(spl->GetP4().id())->toQPointF();
|
|
|
|
controlPoint = spl->GetP3();
|
2013-08-09 08:49:34 +02:00
|
|
|
emit RefreshLine(1, SplinePoint::LastPoint, controlPoint, splinePoint);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
|
|
|
disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
|
|
|
|
&VToolSpline::ControlPointChangePosition);
|
|
|
|
disconnect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
|
|
|
|
&VToolSpline::ControlPointChangePosition);
|
2013-12-29 17:48:57 +01:00
|
|
|
controlPoints[0]->setPos(spl->GetP2());
|
|
|
|
controlPoints[1]->setPos(spl->GetP3());
|
2013-08-13 18:48:36 +02:00
|
|
|
connect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this,
|
|
|
|
&VToolSpline::ControlPointChangePosition);
|
|
|
|
connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this,
|
|
|
|
&VToolSpline::ControlPointChangePosition);
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-06 22:11:12 +01:00
|
|
|
void VToolSpline::ChangedActivDraw(const QString &newName)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-10-28 16:45:27 +01:00
|
|
|
bool selectable = false;
|
2013-11-04 21:35:15 +01:00
|
|
|
if (nameActivDraw == newName)
|
|
|
|
{
|
2013-10-28 16:45:27 +01:00
|
|
|
selectable = true;
|
2013-10-16 11:17:34 +02:00
|
|
|
currentColor = Qt::black;
|
2013-11-04 21:35:15 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-28 16:45:27 +01:00
|
|
|
selectable = false;
|
2013-10-16 11:17:34 +02:00
|
|
|
currentColor = Qt::gray;
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
2014-02-28 13:58:37 +01:00
|
|
|
this->setPen(QPen(currentColor, toPixel(widthHairLine)/factor));
|
2013-10-28 16:45:27 +01:00
|
|
|
this->setFlag(QGraphicsItem::ItemIsSelectable, selectable);
|
|
|
|
this->setAcceptHoverEvents (selectable);
|
|
|
|
emit setEnabledPoint(selectable);
|
|
|
|
VDrawTool::ChangedActivDraw(newName);
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
2013-08-15 22:39:00 +02:00
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolSpline::ShowTool(qint64 id, Qt::GlobalColor color, bool enable)
|
|
|
|
{
|
2013-10-28 16:45:27 +01:00
|
|
|
ShowItem(this, id, color, enable);
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
2013-10-16 11:17:34 +02:00
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
void VToolSpline::SetFactor(qreal factor)
|
|
|
|
{
|
2013-10-16 11:17:34 +02:00
|
|
|
VDrawTool::SetFactor(factor);
|
|
|
|
RefreshGeometry();
|
|
|
|
}
|