2014-07-23 10:56:32 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vistoolendline.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 21 7, 2014
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2014-07-23 10:56:32 +02:00
|
|
|
** <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 "vistoolendline.h"
|
2015-06-18 19:23:24 +02:00
|
|
|
#include "../../vgeometry/vpointf.h"
|
|
|
|
#include "../../vpatterndb/vcontainer.h"
|
2014-07-23 10:56:32 +02:00
|
|
|
#include "../tools/vabstracttool.h"
|
|
|
|
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VisToolEndLine::VisToolEndLine(const VContainer *data, QGraphicsItem *parent)
|
|
|
|
: VisLine(data, parent), length(0), angle(0), point(nullptr)
|
|
|
|
{
|
2014-07-24 12:19:41 +02:00
|
|
|
this->mainColor = Qt::red;
|
2014-07-23 10:56:32 +02:00
|
|
|
|
2014-08-15 15:54:24 +02:00
|
|
|
point = InitPoint(mainColor, this);
|
2014-07-23 10:56:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VisToolEndLine::~VisToolEndLine()
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VisToolEndLine::RefreshGeometry()
|
|
|
|
{
|
2016-01-24 17:15:08 +01:00
|
|
|
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(object1Id);
|
2014-07-23 10:56:32 +02:00
|
|
|
QLineF line;
|
2016-02-12 19:31:08 +01:00
|
|
|
if (qFuzzyIsNull(length))
|
2014-07-23 10:56:32 +02:00
|
|
|
{
|
2014-08-12 19:02:14 +02:00
|
|
|
line = QLineF(first->toQPointF(), Ray(first->toQPointF()));
|
2014-07-23 10:56:32 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-23 10:38:57 +02:00
|
|
|
line = VGObject::BuildLine(first->toQPointF(), length, angle);
|
2014-07-24 13:31:02 +02:00
|
|
|
DrawPoint(point, line.p2(), mainColor);
|
2014-07-23 10:56:32 +02:00
|
|
|
}
|
2014-07-24 13:31:02 +02:00
|
|
|
DrawLine(this, line, mainColor, lineStyle);
|
2014-08-15 12:48:11 +02:00
|
|
|
Visualization::toolTip = QString(tr("<b>Point at distance and angle</b>: angle = %1°; <b>Shift</b> - "
|
|
|
|
"sticking angle, <b>Enter</b> - finish creation")).arg(this->line().angle());
|
2014-07-23 10:56:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-08-11 16:41:17 +02:00
|
|
|
QString VisToolEndLine::Angle() const
|
2014-07-23 10:56:32 +02:00
|
|
|
{
|
2014-08-11 16:41:17 +02:00
|
|
|
return QString("%1").arg(this->line().angle());
|
2014-07-23 10:56:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
void VisToolEndLine::SetAngle(const QString &expression)
|
2014-07-23 10:56:32 +02:00
|
|
|
{
|
2016-02-25 20:23:16 +01:00
|
|
|
angle = FindVal(expression, Visualization::data->PlainVariables());
|
2014-07-23 10:56:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-07-24 12:19:41 +02:00
|
|
|
void VisToolEndLine::setLength(const QString &expression)
|
2014-07-23 10:56:32 +02:00
|
|
|
{
|
2016-02-25 20:23:16 +01:00
|
|
|
length = FindLength(expression, Visualization::data->PlainVariables());
|
2014-07-23 10:56:32 +02:00
|
|
|
}
|