2014-08-18 16:42:53 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vistoolspline.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 18 8, 2014
|
|
|
|
**
|
|
|
|
** @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) 2014 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 "vistoolspline.h"
|
|
|
|
#include "../geometry/vpointf.h"
|
|
|
|
#include "../geometry/vspline.h"
|
|
|
|
#include "../container/vcontainer.h"
|
|
|
|
|
|
|
|
const int EMPTY_ANGLE = -1;
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VisToolSpline::VisToolSpline(const VContainer *data, QGraphicsItem *parent)
|
|
|
|
: VisPath(data, parent), point4Id(NULL_ID), lineP1(nullptr), lineP4(nullptr), line(nullptr), angle1(EMPTY_ANGLE),
|
|
|
|
angle2(EMPTY_ANGLE), kAsm1(1), kAsm2(1), kCurve(1)
|
|
|
|
{
|
|
|
|
lineP1 = InitPoint(supportColor, this);
|
|
|
|
lineP4 = InitPoint(supportColor, this);
|
|
|
|
line = InitItem<QGraphicsLineItem>(mainColor, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VisToolSpline::~VisToolSpline()
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VisToolSpline::RefreshGeometry()
|
|
|
|
{
|
2014-10-24 16:16:31 +02:00
|
|
|
if (point1Id > NULL_ID)
|
2014-08-18 16:42:53 +02:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(point1Id);
|
2014-08-18 16:42:53 +02:00
|
|
|
DrawPoint(lineP1, first->toQPointF(), supportColor);
|
|
|
|
|
2014-10-24 16:16:31 +02:00
|
|
|
if (point4Id <= NULL_ID)
|
2014-08-18 16:42:53 +02:00
|
|
|
{
|
|
|
|
DrawLine(line, QLineF(first->toQPointF(), Visualization::scenePos), mainColor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(point4Id);
|
2014-08-18 16:42:53 +02:00
|
|
|
DrawPoint(lineP4, second->toQPointF(), supportColor);
|
|
|
|
|
|
|
|
if (qFuzzyCompare(angle1, EMPTY_ANGLE) || qFuzzyCompare(angle2, EMPTY_ANGLE))
|
|
|
|
{
|
|
|
|
DrawLine(line, QLineF(first->toQPointF(), second->toQPointF()), mainColor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
VSpline spline(*first, *second, angle1, angle2, kAsm1, kAsm2, kCurve);
|
|
|
|
DrawPath(this, spline.GetPath(PathDirection::Show), mainColor, Qt::SolidLine, Qt::RoundCap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VisToolSpline::setPoint4Id(const quint32 &value)
|
|
|
|
{
|
|
|
|
point4Id = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
void VisToolSpline::SetAngle1(const qreal &value)
|
2014-08-18 16:42:53 +02:00
|
|
|
{
|
|
|
|
angle1 = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
void VisToolSpline::SetAngle2(const qreal &value)
|
2014-08-18 16:42:53 +02:00
|
|
|
{
|
|
|
|
angle2 = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
void VisToolSpline::SetKAsm1(const qreal &value)
|
2014-08-18 16:42:53 +02:00
|
|
|
{
|
|
|
|
kAsm1 = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
void VisToolSpline::SetKAsm2(const qreal &value)
|
2014-08-18 16:42:53 +02:00
|
|
|
{
|
|
|
|
kAsm2 = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
void VisToolSpline::SetKCurve(const qreal &value)
|
2014-08-18 16:42:53 +02:00
|
|
|
{
|
|
|
|
kCurve = value;
|
|
|
|
}
|