2015-05-30 12:02:20 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vistoolpointofintersectioncircles.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 29 5, 2015
|
|
|
|
**
|
|
|
|
** @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) 2015 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 "vistoolpointofintersectioncircles.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
|
|
|
#include <QGraphicsEllipseItem>
|
|
|
|
#include <QPen>
|
|
|
|
#include <QPointF>
|
|
|
|
#include <QSharedPointer>
|
|
|
|
#include <Qt>
|
|
|
|
#include <new>
|
|
|
|
|
2016-03-24 15:49:15 +01:00
|
|
|
#include "../../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../ifc/ifcdef.h"
|
2015-06-20 08:23:04 +02:00
|
|
|
#include "../vgeometry/vpointf.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vmisc/vabstractapplication.h"
|
|
|
|
#include "../vpatterndb/vcontainer.h"
|
|
|
|
#include "../vwidgets/vmaingraphicsscene.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../visualization.h"
|
|
|
|
#include "visline.h"
|
2015-05-30 12:02:20 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VisToolPointOfIntersectionCircles::VisToolPointOfIntersectionCircles(const VContainer *data, QGraphicsItem *parent)
|
2016-01-24 17:15:08 +01:00
|
|
|
: VisLine(data, parent), object2Id(NULL_ID), c1Radius(0), c2Radius(0),
|
2015-05-30 12:02:20 +02:00
|
|
|
crossPoint(CrossCirclesPoint::FirstPoint), point(nullptr), c1Center(nullptr), c2Center(nullptr), c1Path(nullptr),
|
|
|
|
c2Path(nullptr)
|
|
|
|
{
|
2016-02-09 16:19:25 +01:00
|
|
|
this->setPen(QPen(Qt::NoPen)); // don't use parent this time
|
|
|
|
|
2015-05-30 12:02:20 +02:00
|
|
|
c1Path = InitItem<QGraphicsEllipseItem>(Qt::darkGreen, this);
|
|
|
|
c2Path = InitItem<QGraphicsEllipseItem>(Qt::darkRed, this);
|
|
|
|
point = InitPoint(mainColor, this);
|
|
|
|
c1Center = InitPoint(supportColor, this);
|
2015-10-28 15:22:36 +01:00
|
|
|
c2Center = InitPoint(supportColor, this); //-V656
|
2015-05-30 12:02:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VisToolPointOfIntersectionCircles::~VisToolPointOfIntersectionCircles()
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VisToolPointOfIntersectionCircles::RefreshGeometry()
|
|
|
|
{
|
2016-01-24 17:15:08 +01:00
|
|
|
if (object1Id > NULL_ID)
|
2015-05-30 12:02:20 +02:00
|
|
|
{
|
2016-01-24 17:15:08 +01:00
|
|
|
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(object1Id);
|
2016-05-14 21:28:09 +02:00
|
|
|
DrawPoint(c1Center, *first, supportColor);
|
2015-05-30 12:02:20 +02:00
|
|
|
|
2016-01-24 17:15:08 +01:00
|
|
|
if (object2Id > NULL_ID)
|
2015-05-30 12:02:20 +02:00
|
|
|
{
|
2016-01-24 17:15:08 +01:00
|
|
|
const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(object2Id);
|
2016-05-14 21:28:09 +02:00
|
|
|
DrawPoint(c2Center, *second, supportColor);
|
2015-05-30 12:02:20 +02:00
|
|
|
|
|
|
|
if (c1Radius > 0 && c2Radius > 0)
|
|
|
|
{
|
|
|
|
c1Path->setRect(PointRect(c1Radius));
|
2016-05-14 21:28:09 +02:00
|
|
|
DrawPoint(c1Path, *first, Qt::darkGreen, Qt::DashLine);
|
2015-05-30 12:02:20 +02:00
|
|
|
|
|
|
|
c2Path->setRect(PointRect(c2Radius));
|
2016-05-14 21:28:09 +02:00
|
|
|
DrawPoint(c2Path, *second, Qt::darkRed, Qt::DashLine);
|
2015-05-30 12:02:20 +02:00
|
|
|
|
2016-05-14 21:28:09 +02:00
|
|
|
const QPointF fPoint = VToolPointOfIntersectionCircles::FindPoint(*first, *second, c1Radius,
|
2015-05-30 12:02:20 +02:00
|
|
|
c2Radius, crossPoint);
|
|
|
|
DrawPoint(point, fPoint, mainColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VisToolPointOfIntersectionCircles::VisualMode(const quint32 &id)
|
|
|
|
{
|
|
|
|
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(scene != nullptr)
|
2015-05-30 12:02:20 +02:00
|
|
|
|
2016-01-24 17:15:08 +01:00
|
|
|
this->object1Id = id;
|
2015-05-30 12:02:20 +02:00
|
|
|
Visualization::scenePos = scene->getScenePos();
|
|
|
|
RefreshGeometry();
|
|
|
|
|
|
|
|
AddOnScene();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-01-24 17:15:08 +01:00
|
|
|
void VisToolPointOfIntersectionCircles::setObject2Id(const quint32 &value)
|
2015-05-30 12:02:20 +02:00
|
|
|
{
|
2016-01-24 17:15:08 +01:00
|
|
|
object2Id = value;
|
2015-05-30 12:02:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VisToolPointOfIntersectionCircles::setC1Radius(const QString &value)
|
|
|
|
{
|
2016-02-25 20:23:16 +01:00
|
|
|
c1Radius = FindLength(value, Visualization::data->PlainVariables());
|
2015-05-30 12:02:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VisToolPointOfIntersectionCircles::setC2Radius(const QString &value)
|
|
|
|
{
|
2016-02-25 20:23:16 +01:00
|
|
|
c2Radius = FindLength(value, Visualization::data->PlainVariables());
|
2015-05-30 12:02:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VisToolPointOfIntersectionCircles::setCrossPoint(const CrossCirclesPoint &value)
|
|
|
|
{
|
|
|
|
crossPoint = value;
|
|
|
|
}
|