/************************************************************************ ** ** @file vistoolpointofintersectioncircles.cpp ** @author Roman Telezhynskyi ** @date 29 5, 2015 ** ** @brief ** @copyright ** This source code is part of the Valentina project, a pattern making ** program, whose allow create and modeling patterns of clothing. ** Copyright (C) 2015 Valentina project ** 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 . ** *************************************************************************/ #include "vistoolpointofintersectioncircles.h" #include #include #include #include #include #include #include "../../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h" #include "../vgeometry/vpointf.h" #include "../vpatterndb/vcontainer.h" #include "../vwidgets/global.h" #include "../visualization.h" #include "visline.h" #include "../vmisc/vmodifierkey.h" //--------------------------------------------------------------------------------------------------------------------- VisToolPointOfIntersectionCircles::VisToolPointOfIntersectionCircles(const VContainer *data, QGraphicsItem *parent) : VisLine(data, parent) { this->setPen(QPen(Qt::NoPen)); // don't use parent this time m_c1Path = InitItem(Qt::darkGreen, this); m_c1Path->SetPointMode(false); m_c2Path = InitItem(Qt::darkRed, this); m_c2Path->SetPointMode(false); m_point = InitPoint(Color(VColor::MainColor), this); m_point->setZValue(1); m_c1Center = InitPoint(Color(VColor::SupportColor), this); m_c2Center = InitPoint(Color(VColor::SupportColor), this); //-V656 } //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersectionCircles::RefreshGeometry() { if (m_circle1Id > NULL_ID) { const QSharedPointer first = GetData()->GeometricObject(m_circle1Id); DrawPoint(m_c1Center, static_cast(*first), Color(VColor::SupportColor)); if (m_c1Radius > 0) { m_c1Path->setRect(PointRect(m_c1Radius)); DrawPoint(m_c1Path, static_cast(*first), Qt::darkGreen, Qt::DashLine); if (m_circle2Id > NULL_ID) { const QSharedPointer second = GetData()->GeometricObject(m_circle2Id); DrawPoint(m_c2Center, static_cast(*second), Color(VColor::SupportColor)); if (m_c2Radius > 0) { m_c2Path->setRect(PointRect(m_c2Radius)); DrawPoint(m_c2Path, static_cast(*second), Qt::darkRed, Qt::DashLine); QPointF fPoint; VToolPointOfIntersectionCircles::FindPoint(static_cast(*first), static_cast(*second), m_c1Radius, m_c2Radius, m_crossPoint, &fPoint); DrawPoint(m_point, fPoint, Color(VColor::MainColor)); } else if (GetMode() == Mode::Creation) { QLineF radiusLine (static_cast(*second), ScenePos()); const qreal length = radiusLine.length(); m_c2Path->setRect(PointRect(length)); DrawPoint(m_c2Path, static_cast(*second), Qt::darkRed, Qt::DashLine); QPointF fPoint; VToolPointOfIntersectionCircles::FindPoint(static_cast(*first), static_cast(*second), m_c1Radius, length, m_crossPoint, &fPoint); DrawPoint(m_point, fPoint, Color(VColor::MainColor)); const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); SetToolTip(tr("Radius = %1%2; " "Mouse click - finish selecting the second radius, " "%3 - skip") .arg(LengthToUser(length), prefix, VModifierKey::EnterKey())); } } } else if (GetMode() == Mode::Creation && VAbstractValApplication::VApp()->Settings()->IsInteractiveTools()) { QLineF radiusLine (static_cast(*first), ScenePos()); const qreal length = radiusLine.length(); m_c1Path->setRect(PointRect(length)); DrawPoint(m_c1Path, static_cast(*first), Qt::darkGreen, Qt::DashLine); const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true); SetToolTip(tr("Radius = %1%2; " "Mouse click - finish selecting the first radius, " "%3 - skip") .arg(LengthToUser(length), prefix, VModifierKey::EnterKey())); } } } //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersectionCircles::VisualMode(quint32 id) { m_circle1Id = id; StartVisualMode(); } //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersectionCircles::SetC1Radius(const QString &value) { m_c1Radius = FindLengthFromUser(value, GetData()->DataVariables()); } //--------------------------------------------------------------------------------------------------------------------- void VisToolPointOfIntersectionCircles::SetC2Radius(const QString &value) { m_c2Radius = FindLengthFromUser(value, GetData()->DataVariables()); }