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 vtoolpointofcontact.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-08-21 10:03:53 +02:00
|
|
|
#include "vtoolpointofcontact.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/dialogpointofcontact.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../../../../dialogs/tools/dialogtool.h"
|
|
|
|
#include "../../../../visualization/visualization.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../../../../visualization/line/vistoolpointofcontact.h"
|
|
|
|
#include "../ifc/exception/vexception.h"
|
|
|
|
#include "../ifc/xml/vdomdocument.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"
|
2015-06-19 16:17:31 +02:00
|
|
|
#include "../vgeometry/vpointf.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vmisc/vabstractapplication.h"
|
|
|
|
#include "../vmisc/vcommonsettings.h"
|
|
|
|
#include "../vpatterndb/vcontainer.h"
|
2015-06-19 16:17:31 +02:00
|
|
|
#include "../vpatterndb/vformula.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vpatterndb/vtranslatevars.h"
|
|
|
|
#include "../vwidgets/vmaingraphicsscene.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../../../vabstracttool.h"
|
|
|
|
#include "../../vdrawtool.h"
|
|
|
|
#include "vtoolsinglepoint.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
|
|
|
template <class T> class QSharedPointer;
|
2013-08-21 10:03:53 +02:00
|
|
|
|
2013-10-29 14:45:07 +01:00
|
|
|
const QString VToolPointOfContact::ToolType = QStringLiteral("pointOfContact");
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief VToolPointOfContact constructor.
|
|
|
|
* @param doc dom document container.
|
|
|
|
* @param data container with variables.
|
|
|
|
* @param id object id in container.
|
2014-09-11 18:52:02 +02:00
|
|
|
* @param radius string with formula radius arc.
|
2014-06-13 19:02:41 +02:00
|
|
|
* @param center id center arc point.
|
|
|
|
* @param firstPointId id first line point.
|
|
|
|
* @param secondPointId id second line point.
|
|
|
|
* @param typeCreation way we create this tool.
|
|
|
|
* @param parent parent object.
|
|
|
|
*/
|
2015-06-18 19:23:24 +02:00
|
|
|
VToolPointOfContact::VToolPointOfContact(VAbstractPattern *doc, VContainer *data, const quint32 &id,
|
2014-02-25 15:40:24 +01:00
|
|
|
const QString &radius, const quint32 ¢er,
|
|
|
|
const quint32 &firstPointId, const quint32 &secondPointId,
|
2014-06-12 09:22:29 +02:00
|
|
|
const Source &typeCreation, QGraphicsItem *parent)
|
2015-06-20 08:23:04 +02:00
|
|
|
: VToolSinglePoint(doc, data, id, parent), arcRadius(radius), center(center), firstPointId(firstPointId),
|
2014-02-06 14:57:23 +01:00
|
|
|
secondPointId(secondPointId)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2015-05-28 12:16:59 +02:00
|
|
|
ToolCreation(typeCreation);
|
2013-08-21 10:03:53 +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 VToolPointOfContact::setDialog()
|
|
|
|
{
|
2017-04-15 16:39:59 +02:00
|
|
|
SCASSERT(not m_dialog.isNull())
|
|
|
|
QSharedPointer<DialogPointOfContact> dialogTool = m_dialog.objectCast<DialogPointOfContact>();
|
|
|
|
SCASSERT(not dialogTool.isNull())
|
2014-08-21 14:44:40 +02:00
|
|
|
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
|
2014-02-06 14:57:23 +01:00
|
|
|
dialogTool->setRadius(arcRadius);
|
2014-07-29 15:08:38 +02:00
|
|
|
dialogTool->setCenter(center);
|
2015-02-03 11:17:04 +01:00
|
|
|
dialogTool->SetFirstPoint(firstPointId);
|
|
|
|
dialogTool->SetSecondPoint(secondPointId);
|
|
|
|
dialogTool->SetPointName(p->name());
|
2013-08-21 10:03:53 +02:00
|
|
|
}
|
|
|
|
|
2014-05-02 13:11:30 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-13 19:02:41 +02:00
|
|
|
/**
|
|
|
|
* @brief FindPoint return point intersection line and arc.
|
2014-09-11 18:52:02 +02:00
|
|
|
* @param radius string with formula arc radius.
|
2014-06-13 19:02:41 +02:00
|
|
|
* @param center center arc point.
|
|
|
|
* @param firstPoint first line point.
|
|
|
|
* @param secondPoint second line point.
|
|
|
|
* @return point intersection.
|
|
|
|
*/
|
2013-08-21 10:03:53 +02:00
|
|
|
QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint,
|
2013-11-04 21:35:15 +01:00
|
|
|
const QPointF &secondPoint)
|
|
|
|
{
|
2014-10-18 19:56:25 +02:00
|
|
|
QPointF p1, p2;
|
2014-10-23 10:38:57 +02:00
|
|
|
qint32 res = VGObject::LineIntersectCircle(center, radius, QLineF(firstPoint, secondPoint), p1, p2);
|
2014-10-18 19:56:25 +02:00
|
|
|
switch (res)
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2014-10-18 19:56:25 +02:00
|
|
|
case 0:
|
|
|
|
return QPointF();
|
|
|
|
case 1:
|
|
|
|
return p1;
|
|
|
|
case 2:
|
2015-03-19 15:20:25 +01:00
|
|
|
{
|
2016-01-08 16:59:51 +01:00
|
|
|
const bool flagP1 = VGObject::IsPointOnLineSegment (p1, firstPoint, secondPoint);
|
|
|
|
const bool flagP2 = VGObject::IsPointOnLineSegment (p2, firstPoint, secondPoint);
|
2015-03-19 15:20:25 +01:00
|
|
|
if ((flagP1 == true && flagP2 == true) ||
|
|
|
|
(flagP1 == false && flagP2 == false)/*In case we have something wrong*/)
|
2014-10-18 19:56:25 +02:00
|
|
|
{
|
2015-03-19 15:20:25 +01:00
|
|
|
// We don't have options for choosing correct point. Use closest to segment first point.
|
|
|
|
if (QLineF(firstPoint, p1).length() <= QLineF(firstPoint, p2).length())
|
|
|
|
{
|
|
|
|
return p1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return p2;
|
|
|
|
}
|
2014-10-18 19:56:25 +02:00
|
|
|
}
|
|
|
|
else
|
2015-03-19 15:20:25 +01:00
|
|
|
{ // In this case we have one real and one theoretical intersection.
|
|
|
|
if (flagP1)
|
|
|
|
{
|
|
|
|
return p1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return p2;
|
|
|
|
}
|
2014-10-18 19:56:25 +02:00
|
|
|
}
|
2015-03-19 15:20:25 +01:00
|
|
|
}
|
2014-10-18 19:56:25 +02:00
|
|
|
default:
|
|
|
|
qDebug() << "Unxpected value" << res;
|
2017-04-19 11:48:13 +02:00
|
|
|
break;
|
2013-08-21 10:03:53 +02:00
|
|
|
}
|
2017-02-22 18:40:50 +01:00
|
|
|
return QPointF();
|
2013-08-21 10:03:53 +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.
|
|
|
|
*/
|
2017-04-15 16:39:59 +02:00
|
|
|
VToolPointOfContact* VToolPointOfContact::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<DialogPointOfContact> dialogTool = dialog.objectCast<DialogPointOfContact>();
|
|
|
|
SCASSERT(not dialogTool.isNull())
|
2014-02-06 14:57:23 +01:00
|
|
|
QString radius = dialogTool->getRadius();
|
2014-05-30 13:50:41 +02:00
|
|
|
const quint32 center = dialogTool->getCenter();
|
2015-02-03 11:17:04 +01:00
|
|
|
const quint32 firstPointId = dialogTool->GetFirstPoint();
|
|
|
|
const quint32 secondPointId = dialogTool->GetSecondPoint();
|
2014-05-30 13:50:41 +02:00
|
|
|
const QString pointName = dialogTool->getPointName();
|
2015-11-02 17:25:29 +01:00
|
|
|
VToolPointOfContact *point = Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc,
|
|
|
|
data, Document::FullParse, Source::FromGui);
|
2014-06-09 15:00:26 +02:00
|
|
|
if (point != nullptr)
|
|
|
|
{
|
2017-04-15 16:39:59 +02:00
|
|
|
point->m_dialog = dialogTool;
|
2014-06-09 15:00:26 +02:00
|
|
|
}
|
|
|
|
return point;
|
2013-08-21 10:03:53 +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.
|
2014-09-11 18:52:02 +02:00
|
|
|
* @param radius string with formula radius arc.
|
2014-06-13 19:02:41 +02:00
|
|
|
* @param center id center arc point.
|
|
|
|
* @param firstPointId id first line point.
|
|
|
|
* @param secondPointId id second line point.
|
|
|
|
* @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.
|
|
|
|
*/
|
|
|
|
VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &radius, const quint32 ¢er,
|
|
|
|
const quint32 &firstPointId, const quint32 &secondPointId,
|
|
|
|
const QString &pointName, const qreal &mx, const qreal &my,
|
2015-06-18 19:23:24 +02:00
|
|
|
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
|
2014-06-13 19:02:41 +02:00
|
|
|
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> centerP = data->GeometricObject<VPointF>(center);
|
|
|
|
const QSharedPointer<VPointF> firstP = data->GeometricObject<VPointF>(firstPointId);
|
|
|
|
const QSharedPointer<VPointF> secondP = data->GeometricObject<VPointF>(secondPointId);
|
2013-08-21 10:03:53 +02:00
|
|
|
|
2014-07-29 14:19:11 +02:00
|
|
|
const qreal result = CheckFormula(_id, radius, data);
|
2014-05-21 10:51:16 +02:00
|
|
|
|
2017-03-31 16:04:11 +02:00
|
|
|
QPointF fPoint = VToolPointOfContact::FindPoint(qApp->toPixel(result), static_cast<QPointF>(*centerP),
|
|
|
|
static_cast<QPointF>(*firstP), static_cast<QPointF>(*secondP));
|
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(firstPointId, id);
|
|
|
|
data->AddLine(secondPointId, id);
|
|
|
|
data->AddLine(center, 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(firstPointId, id);
|
|
|
|
data->AddLine(secondPointId, id);
|
|
|
|
data->AddLine(center, 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-21 10:03:53 +02:00
|
|
|
}
|
|
|
|
}
|
2017-02-13 07:55:42 +01:00
|
|
|
|
2014-05-21 10:51:16 +02:00
|
|
|
if (parse == Document::FullParse)
|
|
|
|
{
|
2017-02-13 07:55:42 +01:00
|
|
|
VDrawTool::AddRecord(id, Tool::PointOfContact, doc);
|
2014-05-21 10:51:16 +02:00
|
|
|
VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center,
|
|
|
|
firstPointId, secondPointId, 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(centerP->getIdTool());
|
|
|
|
doc->IncrementReferens(firstP->getIdTool());
|
|
|
|
doc->IncrementReferens(secondP->getIdTool());
|
2014-06-09 15:00:26 +02:00
|
|
|
return point;
|
2014-05-21 10:51:16 +02:00
|
|
|
}
|
2014-06-09 15:00:26 +02:00
|
|
|
return nullptr;
|
2013-08-21 10:03:53 +02:00
|
|
|
}
|
|
|
|
|
2017-03-19 16:13:02 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VToolPointOfContact::ArcCenterPointName() const
|
|
|
|
{
|
|
|
|
return VAbstractTool::data.GetGObject(center)->name();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VToolPointOfContact::FirstPointName() const
|
|
|
|
{
|
|
|
|
return VAbstractTool::data.GetGObject(firstPointId)->name();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QString VToolPointOfContact::SecondPointName() const
|
|
|
|
{
|
|
|
|
return VAbstractTool::data.GetGObject(secondPointId)->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 VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|
|
|
{
|
2015-11-02 17:25:29 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
ContextMenu<DialogPointOfContact>(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-08-21 10:03:53 +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 VToolPointOfContact::RemoveReferens()
|
|
|
|
{
|
2016-02-02 14:38:30 +01:00
|
|
|
const auto c = VAbstractTool::data.GetGObject(center);
|
|
|
|
const auto firstPoint = VAbstractTool::data.GetGObject(firstPointId);
|
|
|
|
const auto secondPoint = VAbstractTool::data.GetGObject(secondPointId);
|
|
|
|
|
|
|
|
doc->DecrementReferens(c->getIdTool());
|
|
|
|
doc->DecrementReferens(firstPoint->getIdTool());
|
|
|
|
doc->DecrementReferens(secondPoint->getIdTool());
|
2013-09-30 18:29:03 +02:00
|
|
|
}
|
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 VToolPointOfContact::SaveDialog(QDomElement &domElement)
|
|
|
|
{
|
2017-04-15 16:39:59 +02:00
|
|
|
SCASSERT(not m_dialog.isNull())
|
|
|
|
QSharedPointer<DialogPointOfContact> dialogTool = m_dialog.objectCast<DialogPointOfContact>();
|
|
|
|
SCASSERT(not dialogTool.isNull())
|
2014-02-25 15:02:09 +01:00
|
|
|
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
|
|
|
|
doc->SetAttribute(domElement, AttrRadius, dialogTool->getRadius());
|
|
|
|
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->getCenter()));
|
2015-02-03 11:17:04 +01:00
|
|
|
doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPoint()));
|
|
|
|
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPoint()));
|
2014-02-06 14:57:23 +01:00
|
|
|
}
|
2014-08-30 21:58:31 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VToolPointOfContact::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
|
|
|
{
|
2015-06-20 08:23:04 +02:00
|
|
|
VToolSinglePoint::SaveOptions(tag, obj);
|
2014-08-30 21:58:31 +02:00
|
|
|
|
|
|
|
doc->SetAttribute(tag, AttrType, ToolType);
|
|
|
|
doc->SetAttribute(tag, AttrRadius, arcRadius);
|
|
|
|
doc->SetAttribute(tag, AttrCenter, center);
|
|
|
|
doc->SetAttribute(tag, AttrFirstPoint, firstPointId);
|
|
|
|
doc->SetAttribute(tag, AttrSecondPoint, secondPointId);
|
|
|
|
}
|
2014-09-01 18:19:41 +02:00
|
|
|
|
2015-02-06 18:43:31 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VToolPointOfContact::ReadToolAttributes(const QDomElement &domElement)
|
|
|
|
{
|
|
|
|
arcRadius = doc->GetParametrString(domElement, AttrRadius, "");
|
|
|
|
center = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
|
|
|
|
firstPointId = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
|
|
|
|
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:40:43 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VToolPointOfContact::SetVisualization()
|
|
|
|
{
|
2016-09-24 15:09:09 +02:00
|
|
|
if (not vis.isNull())
|
2015-05-23 13:40:43 +02:00
|
|
|
{
|
|
|
|
VisToolPointOfContact *visual = qobject_cast<VisToolPointOfContact *>(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(firstPointId);
|
2015-05-23 13:40:43 +02:00
|
|
|
visual->setLineP2Id(secondPointId);
|
|
|
|
visual->setRadiusId(center);
|
2016-05-23 17:23:39 +02:00
|
|
|
visual->setRadius(qApp->TrVars()->FormulaToUser(arcRadius, qApp->Settings()->GetOsSeparator()));
|
2015-05-23 13:40:43 +02:00
|
|
|
visual->RefreshGeometry();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-01 18:19:41 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
quint32 VToolPointOfContact::GetSecondPointId() const
|
2014-09-01 18:19:41 +02:00
|
|
|
{
|
|
|
|
return secondPointId;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
void VToolPointOfContact::SetSecondPointId(const quint32 &value)
|
2014-09-01 18:19:41 +02:00
|
|
|
{
|
|
|
|
secondPointId = value;
|
|
|
|
}
|
|
|
|
|
2014-09-03 15:52:16 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VToolPointOfContact::ShowVisualization(bool show)
|
|
|
|
{
|
2015-05-23 15:10:08 +02:00
|
|
|
ShowToolVisualization<VisToolPointOfContact>(show);
|
2014-09-03 15:52:16 +02:00
|
|
|
}
|
|
|
|
|
2014-09-01 18:19:41 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
quint32 VToolPointOfContact::GetFirstPointId() const
|
2014-09-01 18:19:41 +02:00
|
|
|
{
|
|
|
|
return firstPointId;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2015-02-03 11:17:04 +01:00
|
|
|
void VToolPointOfContact::SetFirstPointId(const quint32 &value)
|
2014-09-01 18:19:41 +02:00
|
|
|
{
|
|
|
|
firstPointId = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
quint32 VToolPointOfContact::getCenter() const
|
|
|
|
{
|
|
|
|
return center;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VToolPointOfContact::setCenter(const quint32 &value)
|
|
|
|
{
|
|
|
|
if (value != NULL_ID)
|
|
|
|
{
|
|
|
|
center = value;
|
|
|
|
|
|
|
|
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
|
|
|
SaveOption(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VFormula VToolPointOfContact::getArcRadius() const
|
|
|
|
{
|
|
|
|
VFormula radius(arcRadius, this->getData());
|
|
|
|
radius.setCheckZero(true);
|
|
|
|
radius.setToolId(id);
|
2017-07-02 13:34:36 +02:00
|
|
|
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
2014-09-01 18:19:41 +02:00
|
|
|
|
|
|
|
return radius;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VToolPointOfContact::setArcRadius(const VFormula &value)
|
|
|
|
{
|
|
|
|
if (value.error() == false)
|
|
|
|
{
|
2015-02-03 11:17:04 +01:00
|
|
|
arcRadius = value.GetFormula(FormulaType::FromUser);
|
2014-09-01 18:19:41 +02:00
|
|
|
|
|
|
|
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
|
|
|
SaveOption(obj);
|
|
|
|
}
|
|
|
|
}
|