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"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
|
|
|
#include <QColor>
|
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QLineF>
|
|
|
|
#include <QPointF>
|
|
|
|
#include <QSharedPointer>
|
|
|
|
#include <Qt>
|
|
|
|
#include <new>
|
|
|
|
|
|
|
|
#include "../ifc/xml/vdomdocument.h"
|
|
|
|
#include "../vgeometry/vgobject.h"
|
2016-03-24 15:49:15 +01:00
|
|
|
#include "../vgeometry/vpointf.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vmisc/vabstractapplication.h"
|
|
|
|
#include "../vmisc/vcommonsettings.h"
|
2016-03-24 15:49:15 +01:00
|
|
|
#include "../vpatterndb/vcontainer.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "visualization/line/../../tools/../visualization/visualization.h"
|
|
|
|
#include "visualization/line/visline.h"
|
|
|
|
#include "vtranslatevars.h"
|
2014-07-23 10:56:32 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
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
|
|
|
{
|
2016-03-19 16:45:57 +01:00
|
|
|
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
|
|
|
{
|
2016-05-14 21:28:09 +02:00
|
|
|
line = QLineF(*first, Visualization::scenePos);
|
2016-03-19 16:45:57 +01:00
|
|
|
line.setAngle(CorrectAngle(line.angle()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-14 21:28:09 +02:00
|
|
|
line = QLineF(*first, Visualization::scenePos);
|
2016-03-19 16:45:57 +01:00
|
|
|
}
|
2014-07-23 10:56:32 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-14 21:28:09 +02:00
|
|
|
line = VGObject::BuildLine(*first, 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);
|
2016-03-19 16:45:57 +01:00
|
|
|
static const QString prefix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
|
2016-07-18 18:29:34 +02:00
|
|
|
Visualization::toolTip = tr("<b>Point at distance and angle</b>: angle = %1°, length = %2%3; "
|
|
|
|
"<b>Shift</b> - sticking angle, <b>Enter</b> - finish creation")
|
2016-03-19 16:45:57 +01:00
|
|
|
.arg(this->line().angle())
|
2016-05-23 17:23:39 +02:00
|
|
|
.arg(qApp->TrVars()->FormulaToUser(QString::number(qApp->fromPixel(this->line().length())),
|
|
|
|
qApp->Settings()->GetOsSeparator()))
|
2016-03-19 16:45:57 +01:00
|
|
|
.arg(prefix);
|
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
|
|
|
}
|
|
|
|
|
2016-03-19 16:45:57 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VisToolEndLine::Length() const
|
|
|
|
{
|
|
|
|
return QString::number(qApp->fromPixel(this->line().length()));
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|