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 vtoolshoulderpoint.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.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2013-11-15 13:41:26 +01:00
|
|
|
** <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-07-29 14:55:40 +02:00
|
|
|
#include "vtoolshoulderpoint.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
|
|
|
#include <QLineF>
|
|
|
|
#include <QMessageLogger>
|
|
|
|
#include <QSharedPointer>
|
|
|
|
#include <QStaticStringData>
|
|
|
|
#include <QStringData>
|
|
|
|
#include <QStringDataPtr>
|
|
|
|
#include <QtDebug>
|
|
|
|
#include <new>
|
|
|
|
|
2015-06-19 16:17:31 +02:00
|
|
|
#include "../../../../../dialogs/tools/dialogshoulderpoint.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../../../../../dialogs/tools/dialogtool.h"
|
|
|
|
#include "../../../../../visualization/visualization.h"
|
2016-03-24 15:49:15 +01:00
|
|
|
#include "../../../../../visualization/line/vistoolshoulderpoint.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../ifc/exception/vexception.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../ifc/ifcdef.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vgeometry/vgobject.h"
|
|
|
|
#include "../vgeometry/vpointf.h"
|
|
|
|
#include "../vmisc/vabstractapplication.h"
|
|
|
|
#include "../vmisc/vcommonsettings.h"
|
|
|
|
#include "../vpatterndb/vcontainer.h"
|
|
|
|
#include "../vpatterndb/vtranslatevars.h"
|
|
|
|
#include "../vwidgets/vmaingraphicsscene.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../../../../vabstracttool.h"
|
|
|
|
#include "../../../vdrawtool.h"
|
|
|
|
#include "vtoollinepoint.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
|
|
|
template <class T> class QSharedPointer;
|
2013-07-29 14:55:40 +02:00
|
|
|
|
2013-10-29 14:45:07 +01:00
|
|
|
const QString VToolShoulderPoint::ToolType = QStringLiteral("shoulder");
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief VToolShoulderPoint constructor.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param data container with variables.
|
|
|
|
* @param id object id in container.
|
|
|
|
* @param typeLine line type.
|
|
|
|
* @param formula string with formula length.
|
|
|
|
* @param p1Line id first line point.
|
|
|
|
* @param p2Line id second line point.
|
|
|
|
* @param pShoulder id shoulder point.
|
|
|
|
* @param typeCreation way we create this tool.
|
|
|
|
* @param parent parent object.
|
|
|
|
*/
|
2015-06-18 19:23:24 +02:00
|
|
|
VToolShoulderPoint::VToolShoulderPoint(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
|
|
|
const QString &typeLine,
|
2015-02-07 12:17:31 +01:00
|
|
|
const QString &lineColor, const QString &formula, const quint32 &p1Line,
|
|
|
|
const quint32 &p2Line, const quint32 &pShoulder, const Source &typeCreation,
|
2013-11-04 21:35:15 +01:00
|
|
|
QGraphicsItem * parent)
|
2015-02-07 12:17:31 +01:00
|
|
|
:VToolLinePoint(doc, data, id, typeLine, lineColor, formula, p1Line, 0, parent), p2Line(p2Line),
|
|
|
|
pShoulder(pShoulder)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-05-28 12:16:59 +02:00
|
|
|
ToolCreation(typeCreation);
|
2013-07-29 14:55:40 +02:00
|
|
|
}
|
|
|
|
|
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 VToolShoulderPoint::setDialog()
|
|
|
|
{
|
2017-04-15 16:39:59 +02:00
|
|
|
SCASSERT(not m_dialog.isNull())
|
|
|
|
QSharedPointer<DialogShoulderPoint> dialogTool = m_dialog.objectCast<DialogShoulderPoint>();
|
|
|
|
SCASSERT(not dialogTool.isNull())
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
2017-05-16 12:07:53 +02:00
|
|
|
dialogTool->SetTypeLine(m_lineType);
|
2015-02-06 18:43:31 +01:00
|
|
|
dialogTool->SetLineColor(lineColor);
|
2015-02-03 11:17:04 +01:00
|
|
|
dialogTool->SetFormula(formulaLength);
|
|
|
|
dialogTool->SetP1Line(basePointId);
|
|
|
|
dialogTool->SetP2Line(p2Line);
|
|
|
|
dialogTool->SetP3(pShoulder);
|
|
|
|
dialogTool->SetPointName(p->name());
|
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 FindPoint find point.
|
|
|
|
* @param p1Line first line point.
|
|
|
|
* @param p2Line second line point.
|
|
|
|
* @param pShoulder shoulder point.
|
|
|
|
* @param length length form shoulder point to our.
|
|
|
|
* @return point.
|
|
|
|
*/
|
2013-07-29 14:55:40 +02:00
|
|
|
QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
|
2013-11-04 21:35:15 +01:00
|
|
|
const qreal &length)
|
|
|
|
{
|
2017-03-27 09:30:31 +02:00
|
|
|
QPointF shoulderPoint = p2Line; // Position if result was not found
|
|
|
|
if (length <= 0)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2017-03-27 09:30:31 +02:00
|
|
|
return shoulderPoint;
|
2013-10-18 20:20:54 +02:00
|
|
|
}
|
2017-03-27 09:30:31 +02:00
|
|
|
|
|
|
|
QLineF line = QLineF(p1Line, p2Line);
|
|
|
|
const qreal baseLength = line.length();
|
|
|
|
const int baseAngle = qRound(line.angle());
|
|
|
|
line.setLength(length*2);
|
|
|
|
|
|
|
|
QPointF p1;
|
|
|
|
QPointF p2;
|
|
|
|
|
|
|
|
const qint32 res = VGObject::LineIntersectCircle(pShoulder, length, line, p1, p2);
|
|
|
|
|
2017-04-03 12:50:05 +02:00
|
|
|
if (res == 1 || res == 2)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2017-04-03 12:50:05 +02:00
|
|
|
const QLineF line1 = QLineF(p1Line, p1);
|
|
|
|
const QLineF line2 = QLineF(p1Line, p2);
|
|
|
|
if (line1.length() > baseLength && baseAngle == qRound(line1.angle()))
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2017-03-27 09:30:31 +02:00
|
|
|
shoulderPoint = p1;
|
2013-07-29 14:55:40 +02:00
|
|
|
}
|
2017-04-03 12:50:05 +02:00
|
|
|
else if (res == 2 && line2.length() > baseLength && baseAngle == qRound(line2.angle()))
|
|
|
|
{
|
|
|
|
shoulderPoint = p2;
|
|
|
|
}
|
2013-10-18 20:20:54 +02:00
|
|
|
}
|
2017-03-27 09:30:31 +02:00
|
|
|
|
|
|
|
return shoulderPoint;
|
2013-07-29 14:55:40 +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-13 13:31:01 +02:00
|
|
|
* @return the created tool
|
2014-06-13 19:02:41 +02:00
|
|
|
*/
|
2017-04-15 16:39:59 +02:00
|
|
|
VToolShoulderPoint* VToolShoulderPoint::Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
|
|
|
VAbstractPattern *doc, VContainer *data)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2017-04-15 16:39:59 +02:00
|
|
|
SCASSERT(not dialog.isNull())
|
|
|
|
QSharedPointer<DialogShoulderPoint> dialogTool = dialog.objectCast<DialogShoulderPoint>();
|
|
|
|
SCASSERT(not dialogTool.isNull())
|
2015-02-03 11:17:04 +01:00
|
|
|
QString formula = dialogTool->GetFormula();
|
|
|
|
const quint32 p1Line = dialogTool->GetP1Line();
|
|
|
|
const quint32 p2Line = dialogTool->GetP2Line();
|
|
|
|
const quint32 pShoulder = dialogTool->GetP3();
|
|
|
|
const QString typeLine = dialogTool->GetTypeLine();
|
2015-02-07 12:17:31 +01:00
|
|
|
const QString lineColor = dialogTool->GetLineColor();
|
2014-05-30 13:50:41 +02:00
|
|
|
const QString pointName = dialogTool->getPointName();
|
2015-11-02 17:25:29 +01:00
|
|
|
VToolShoulderPoint * point = Create(0, formula, p1Line, p2Line, pShoulder, typeLine, lineColor, pointName, 5,
|
|
|
|
10, scene, doc, data, Document::FullParse, Source::FromGui);
|
2014-06-09 12:56:07 +02:00
|
|
|
if (point != nullptr)
|
|
|
|
{
|
2017-04-15 16:39:59 +02:00
|
|
|
point->m_dialog = dialogTool;
|
2014-06-09 12:56:07 +02:00
|
|
|
}
|
|
|
|
return point;
|
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 formula string with formula length.
|
|
|
|
* @param p1Line id first line point.
|
|
|
|
* @param p2Line id second line point.
|
|
|
|
* @param pShoulder id shoulder point.
|
|
|
|
* @param typeLine line type.
|
|
|
|
* @param pointName point name.
|
|
|
|
* @param mx label bias x axis.
|
|
|
|
* @param my label bias y axis.
|
|
|
|
* @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-13 13:31:01 +02:00
|
|
|
* @return the created tool
|
2014-06-13 19:02:41 +02:00
|
|
|
*/
|
2014-06-09 12:56:07 +02:00
|
|
|
VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formula, const quint32 &p1Line,
|
2015-03-02 18:11:43 +01:00
|
|
|
const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine,
|
|
|
|
const QString &lineColor, const QString &pointName, const qreal &mx,
|
2015-06-18 19:23:24 +02:00
|
|
|
const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
2015-03-02 18:11:43 +01:00
|
|
|
VContainer *data, const Document &parse, const Source &typeCreation)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(p1Line);
|
|
|
|
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(p2Line);
|
|
|
|
const QSharedPointer<VPointF> shoulderPoint = data->GeometricObject<VPointF>(pShoulder);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
2014-07-29 14:19:11 +02:00
|
|
|
const qreal result = CheckFormula(_id, formula, data);
|
2014-05-21 10:51:16 +02:00
|
|
|
|
2017-03-31 16:04:11 +02:00
|
|
|
QPointF fPoint = VToolShoulderPoint::FindPoint(static_cast<QPointF>(*firstPoint),
|
|
|
|
static_cast<QPointF>(*secondPoint),
|
|
|
|
static_cast<QPointF>(*shoulderPoint), qApp->toPixel(result));
|
2014-05-21 10:51:16 +02:00
|
|
|
quint32 id = _id;
|
2014-06-12 09:22:29 +02:00
|
|
|
if (typeCreation == Source::FromGui)
|
2014-05-21 10:51:16 +02:00
|
|
|
{
|
2014-07-25 13:53:39 +02:00
|
|
|
id = data->AddGObject(new VPointF(fPoint, pointName, mx, my));
|
2014-05-21 10:51:16 +02:00
|
|
|
data->AddLine(p1Line, id);
|
|
|
|
data->AddLine(p2Line, id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-07-25 13:53:39 +02:00
|
|
|
data->UpdateGObject(id, new VPointF(fPoint, pointName, mx, my));
|
2014-05-21 10:51:16 +02:00
|
|
|
data->AddLine(p1Line, id);
|
|
|
|
data->AddLine(p2Line, id);
|
|
|
|
if (parse != Document::FullParse)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-05-21 10:51:16 +02:00
|
|
|
doc->UpdateToolData(id, data);
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
}
|
2017-02-13 07:55:42 +01:00
|
|
|
|
2014-05-21 10:51:16 +02:00
|
|
|
if (parse == Document::FullParse)
|
|
|
|
{
|
2017-09-13 10:52:41 +02:00
|
|
|
VAbstractTool::AddRecord(id, Tool::ShoulderPoint, doc);
|
2015-02-07 12:17:31 +01:00
|
|
|
VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, lineColor, formula,
|
2014-05-21 10:51:16 +02:00
|
|
|
p1Line, p2Line, pShoulder,
|
|
|
|
typeCreation);
|
|
|
|
scene->addItem(point);
|
2016-03-31 16:01:41 +02:00
|
|
|
InitToolConnections(scene, point);
|
2017-03-23 09:25:46 +01:00
|
|
|
VAbstractPattern::AddTool(id, point);
|
2016-02-02 14:38:30 +01:00
|
|
|
doc->IncrementReferens(firstPoint->getIdTool());
|
|
|
|
doc->IncrementReferens(secondPoint->getIdTool());
|
|
|
|
doc->IncrementReferens(shoulderPoint->getIdTool());
|
2014-06-09 12:56:07 +02:00
|
|
|
return point;
|
2014-05-21 10:51:16 +02:00
|
|
|
}
|
2014-06-09 12:56:07 +02:00
|
|
|
return nullptr;
|
2013-08-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
|
2017-03-19 16:13:02 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VToolShoulderPoint::SecondPointName() const
|
|
|
|
{
|
|
|
|
return VAbstractTool::data.GetGObject(p2Line)->name();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VToolShoulderPoint::ShoulderPointName() const
|
|
|
|
{
|
|
|
|
return VAbstractTool::data.GetGObject(pShoulder)->name();
|
|
|
|
}
|
|
|
|
|
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 VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|
|
|
{
|
2015-11-02 17:25:29 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
ContextMenu<DialogShoulderPoint>(this, event);
|
|
|
|
}
|
|
|
|
catch(const VExceptionToolWasDeleted &e)
|
|
|
|
{
|
2016-12-20 20:19:21 +01:00
|
|
|
Q_UNUSED(e)
|
2015-11-02 17:25:29 +01:00
|
|
|
return;//Leave this method immediately!!!
|
|
|
|
}
|
2013-07-29 14:55:40 +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 VToolShoulderPoint::RemoveReferens()
|
|
|
|
{
|
2016-02-02 14:38:30 +01:00
|
|
|
const auto p2 = VAbstractTool::data.GetGObject(p2Line);
|
|
|
|
const auto pS = VAbstractTool::data.GetGObject(pShoulder);
|
|
|
|
|
|
|
|
doc->DecrementReferens(p2->getIdTool());
|
|
|
|
doc->DecrementReferens(pS->getIdTool());
|
2013-09-30 18:29:03 +02:00
|
|
|
VToolLinePoint::RemoveReferens();
|
|
|
|
}
|
2014-02-06 14:57:23 +01: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 VToolShoulderPoint::SaveDialog(QDomElement &domElement)
|
|
|
|
{
|
2017-04-15 16:39:59 +02:00
|
|
|
SCASSERT(not m_dialog.isNull())
|
|
|
|
QSharedPointer<DialogShoulderPoint> dialogTool = m_dialog.objectCast<DialogShoulderPoint>();
|
|
|
|
SCASSERT(not dialogTool.isNull())
|
2014-02-25 15:02:09 +01:00
|
|
|
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
|
2015-02-03 11:17:04 +01:00
|
|
|
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
|
2015-02-06 18:50:33 +01:00
|
|
|
doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
|
2015-02-03 11:17:04 +01:00
|
|
|
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
|
|
|
|
doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetP1Line()));
|
|
|
|
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetP2Line()));
|
|
|
|
doc->SetAttribute(domElement, AttrPShoulder, QString().setNum(dialogTool->GetP3()));
|
2014-02-06 14:57:23 +01:00
|
|
|
}
|
2014-08-30 21:58:31 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VToolShoulderPoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
|
|
|
{
|
2015-05-28 14:13:37 +02:00
|
|
|
VToolLinePoint::SaveOptions(tag, obj);
|
2014-08-30 21:58:31 +02:00
|
|
|
|
|
|
|
doc->SetAttribute(tag, AttrType, ToolType);
|
|
|
|
doc->SetAttribute(tag, AttrLength, formulaLength);
|
|
|
|
doc->SetAttribute(tag, AttrP1Line, basePointId);
|
|
|
|
doc->SetAttribute(tag, AttrP2Line, p2Line);
|
|
|
|
doc->SetAttribute(tag, AttrPShoulder, pShoulder);
|
|
|
|
}
|
2014-09-01 18:25:04 +02:00
|
|
|
|
2015-02-06 18:43:31 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VToolShoulderPoint::ReadToolAttributes(const QDomElement &domElement)
|
|
|
|
{
|
2017-05-16 12:07:53 +02:00
|
|
|
m_lineType = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine);
|
2015-02-06 18:43:31 +01:00
|
|
|
lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack);
|
|
|
|
formulaLength = doc->GetParametrString(domElement, AttrLength, "");
|
|
|
|
basePointId = doc->GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
|
|
|
|
p2Line = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
|
|
|
|
pShoulder = doc->GetParametrUInt(domElement, AttrPShoulder, NULL_ID_STR);
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:40:43 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VToolShoulderPoint::SetVisualization()
|
|
|
|
{
|
2016-09-24 15:09:09 +02:00
|
|
|
if (not vis.isNull())
|
2015-05-23 13:40:43 +02:00
|
|
|
{
|
|
|
|
VisToolShoulderPoint *visual = qobject_cast<VisToolShoulderPoint *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(visual != nullptr)
|
2015-05-23 13:40:43 +02:00
|
|
|
|
2016-01-24 17:15:08 +01:00
|
|
|
visual->setObject1Id(pShoulder);
|
2015-05-23 13:40:43 +02:00
|
|
|
visual->setLineP1Id(basePointId);
|
|
|
|
visual->setLineP2Id(p2Line);
|
2016-05-23 17:23:39 +02:00
|
|
|
visual->setLength(qApp->TrVars()->FormulaToUser(formulaLength, qApp->Settings()->GetOsSeparator()));
|
2017-05-16 12:07:53 +02:00
|
|
|
visual->setLineStyle(LineStyleToPenStyle(m_lineType));
|
2015-05-23 13:40:43 +02:00
|
|
|
visual->RefreshGeometry();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-23 13:50:48 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VToolShoulderPoint::MakeToolTip() const
|
|
|
|
{
|
|
|
|
const QSharedPointer<VPointF> first = VAbstractTool::data.GeometricObject<VPointF>(basePointId);
|
|
|
|
const QSharedPointer<VPointF> second = VAbstractTool::data.GeometricObject<VPointF>(p2Line);
|
|
|
|
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(id);
|
|
|
|
|
|
|
|
const QLineF firstToCur(static_cast<QPointF>(*first), static_cast<QPointF>(*current));
|
|
|
|
const QLineF secondToCur(static_cast<QPointF>(*second), static_cast<QPointF>(*current));
|
|
|
|
|
|
|
|
const QString toolTip = QString("<table>"
|
|
|
|
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
|
|
|
|
"<tr> <td><b>%4:</b> %5°</td> </tr>"
|
|
|
|
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
|
|
|
|
"</table>")
|
|
|
|
.arg(tr("Length"))
|
|
|
|
.arg(qApp->fromPixel(firstToCur.length()))
|
|
|
|
.arg(UnitsToStr(qApp->patternUnit(), true))
|
|
|
|
.arg(tr("Angle"))
|
|
|
|
.arg(firstToCur.angle())
|
|
|
|
.arg(QString("%1->%2").arg(second->name(), current->name()))
|
|
|
|
.arg(qApp->fromPixel(secondToCur.length()));
|
|
|
|
return toolTip;
|
|
|
|
}
|
|
|
|
|
2014-09-01 18:25:04 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-04-15 14:44:57 +02:00
|
|
|
// cppcheck-suppress unusedFunction
|
2014-09-01 18:25:04 +02:00
|
|
|
quint32 VToolShoulderPoint::getPShoulder() const
|
|
|
|
{
|
|
|
|
return pShoulder;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-04-15 14:44:57 +02:00
|
|
|
// cppcheck-suppress unusedFunction
|
2014-09-01 18:25:04 +02:00
|
|
|
void VToolShoulderPoint::setPShoulder(const quint32 &value)
|
|
|
|
{
|
|
|
|
if (value != NULL_ID)
|
|
|
|
{
|
|
|
|
pShoulder = value;
|
|
|
|
|
|
|
|
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
|
|
|
SaveOption(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-03 15:52:16 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VToolShoulderPoint::ShowVisualization(bool show)
|
|
|
|
{
|
2015-05-23 15:10:08 +02:00
|
|
|
ShowToolVisualization<VisToolShoulderPoint>(show);
|
2014-09-03 15:52:16 +02:00
|
|
|
}
|
|
|
|
|
2014-09-01 18:25:04 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
quint32 VToolShoulderPoint::GetP2Line() const
|
2014-09-01 18:25:04 +02:00
|
|
|
{
|
|
|
|
return p2Line;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
void VToolShoulderPoint::SetP2Line(const quint32 &value)
|
2014-09-01 18:25:04 +02:00
|
|
|
{
|
|
|
|
if (value != NULL_ID)
|
|
|
|
{
|
|
|
|
p2Line = value;
|
|
|
|
|
|
|
|
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
|
|
|
SaveOption(obj);
|
|
|
|
}
|
|
|
|
}
|