2015-06-05 15:43:41 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vistoolpointfromcircleandtangent.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 5 6, 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 "vistoolpointfromcircleandtangent.h"
|
2015-06-20 08:23:04 +02:00
|
|
|
#include "../vpatterndb/vcontainer.h"
|
|
|
|
#include "../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h"
|
|
|
|
#include "../vgeometry/vpointf.h"
|
2015-06-05 15:43:41 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VisToolPointFromCircleAndTangent::VisToolPointFromCircleAndTangent(const VContainer *data, QGraphicsItem *parent)
|
2016-01-24 17:15:08 +01:00
|
|
|
: VisLine(data, parent), object2Id(NULL_ID), cRadius(0), crossPoint(CrossCirclesPoint::FirstPoint),
|
2015-06-05 15:43:41 +02:00
|
|
|
point(nullptr), tangent(nullptr), cCenter(nullptr), cPath(nullptr), tangent2(nullptr)
|
|
|
|
{
|
|
|
|
cPath = InitItem<QGraphicsEllipseItem>(Qt::darkGreen, this);
|
|
|
|
point = InitPoint(mainColor, this);
|
|
|
|
tangent = InitPoint(supportColor, this);
|
2015-10-28 15:22:36 +01:00
|
|
|
cCenter = InitPoint(supportColor, this); //-V656
|
2015-06-05 15:43:41 +02:00
|
|
|
tangent2 = InitItem<QGraphicsLineItem>(supportColor, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VisToolPointFromCircleAndTangent::~VisToolPointFromCircleAndTangent()
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VisToolPointFromCircleAndTangent::RefreshGeometry()
|
|
|
|
{
|
2016-01-24 17:15:08 +01:00
|
|
|
if (object1Id > NULL_ID)// tangent point
|
2015-06-05 15:43:41 +02:00
|
|
|
{
|
2016-01-24 17:15:08 +01:00
|
|
|
const QSharedPointer<VPointF> tan = Visualization::data->GeometricObject<VPointF>(object1Id);
|
2015-06-05 15:43:41 +02:00
|
|
|
DrawPoint(tangent, tan->toQPointF(), supportColor);
|
|
|
|
|
2016-01-24 17:15:08 +01:00
|
|
|
if (object2Id > NULL_ID)// circle center
|
2015-06-05 15:43:41 +02:00
|
|
|
{
|
2016-01-24 17:15:08 +01:00
|
|
|
const QSharedPointer<VPointF> center = Visualization::data->GeometricObject<VPointF>(object2Id);
|
2015-06-05 15:43:41 +02:00
|
|
|
DrawPoint(cCenter, center->toQPointF(), supportColor);
|
|
|
|
|
|
|
|
if (cRadius > 0)
|
|
|
|
{
|
|
|
|
cPath->setRect(PointRect(cRadius));
|
|
|
|
DrawPoint(cPath, center->toQPointF(), Qt::darkGreen, Qt::DashLine);
|
|
|
|
|
|
|
|
FindRays(tan->toQPointF(), center->toQPointF(), cRadius);
|
|
|
|
|
|
|
|
const QPointF fPoint = VToolPointFromCircleAndTangent::FindPoint(tan->toQPointF(), center->toQPointF(),
|
|
|
|
cRadius, crossPoint);
|
|
|
|
DrawPoint(point, fPoint, mainColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-01-24 17:15:08 +01:00
|
|
|
void VisToolPointFromCircleAndTangent::setObject2Id(const quint32 &value)
|
2015-06-05 15:43:41 +02:00
|
|
|
{
|
2016-01-24 17:15:08 +01:00
|
|
|
object2Id = value;
|
2015-06-05 15:43:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VisToolPointFromCircleAndTangent::setCRadius(const QString &value)
|
|
|
|
{
|
|
|
|
cRadius = FindLength(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VisToolPointFromCircleAndTangent::setCrossPoint(const CrossCirclesPoint &value)
|
|
|
|
{
|
|
|
|
crossPoint = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VisToolPointFromCircleAndTangent::FindRays(const QPointF &p, const QPointF ¢er, qreal radius)
|
|
|
|
{
|
|
|
|
QPointF p1, p2;
|
|
|
|
const int res = VGObject::ContactPoints (p, center, radius, p1, p2);
|
|
|
|
|
|
|
|
switch(res)
|
|
|
|
{
|
|
|
|
case 2:
|
|
|
|
DrawRay(this, p, p1, supportColor, Qt::DashLine);
|
|
|
|
DrawRay(tangent2, p, p2, supportColor, Qt::DashLine);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
DrawRay(this, p, p1, supportColor, Qt::DashLine);
|
|
|
|
tangent2->setVisible(false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
this->setVisible(false);
|
|
|
|
tangent2->setVisible(false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|