113 lines
4.3 KiB
C++
113 lines
4.3 KiB
C++
/************************************************************************
|
|
**
|
|
** @file vistoolpointofintersectioncurves.cpp
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
** @date 24 1, 2016
|
|
**
|
|
** @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) 2016 Valentina project
|
|
** <https://gitlab.com/smart-pattern/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 "vistoolpointofintersectioncurves.h"
|
|
|
|
#include <QGraphicsPathItem>
|
|
#include <QPainterPath>
|
|
#include <QPointF>
|
|
#include <QSharedPointer>
|
|
#include <Qt>
|
|
#include <new>
|
|
|
|
#include "../../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h"
|
|
#include "../ifc/ifcdef.h"
|
|
#include "../vgeometry/vabstractcurve.h"
|
|
#include "../vmisc/vabstractapplication.h"
|
|
#include "../vpatterndb/vcontainer.h"
|
|
#include "../vwidgets/vmaingraphicsscene.h"
|
|
#include "../vwidgets/scalesceneitems.h"
|
|
#include "../visualization.h"
|
|
#include "visualization/path/vispath.h"
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
VisToolPointOfIntersectionCurves::VisToolPointOfIntersectionCurves(const VContainer *data, QGraphicsItem *parent)
|
|
:VisPath(data, parent),
|
|
object2Id(NULL_ID),
|
|
vCrossPoint(VCrossCurvesPoint::HighestPoint),
|
|
hCrossPoint(HCrossCurvesPoint::LeftmostPoint),
|
|
point(nullptr),
|
|
visCurve2(nullptr)
|
|
{
|
|
visCurve2 = InitItem<VCurvePathItem>(supportColor, this);
|
|
point = InitPoint(mainColor, this);
|
|
}
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
void VisToolPointOfIntersectionCurves::RefreshGeometry()
|
|
{
|
|
if (object1Id > NULL_ID)
|
|
{
|
|
auto curve1 = Visualization::data->GeometricObject<VAbstractCurve>(object1Id);
|
|
DrawPath(this, curve1->GetPath(), curve1->DirectionArrows(), supportColor, Qt::SolidLine, Qt::RoundCap);
|
|
|
|
if (object2Id > NULL_ID)
|
|
{
|
|
auto curve2 = Visualization::data->GeometricObject<VAbstractCurve>(object2Id);
|
|
DrawPath(visCurve2, curve2->GetPath(), curve2->DirectionArrows(), supportColor, Qt::SolidLine,
|
|
Qt::RoundCap);
|
|
|
|
QPointF p;
|
|
VToolPointOfIntersectionCurves::FindPoint(curve1->GetPoints(), curve2->GetPoints(), vCrossPoint,
|
|
hCrossPoint, &p);
|
|
DrawPoint(point, p, mainColor);
|
|
}
|
|
}
|
|
}
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
void VisToolPointOfIntersectionCurves::VisualMode(const quint32 &id)
|
|
{
|
|
auto scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
|
SCASSERT(scene != nullptr)
|
|
|
|
this->object1Id = id;
|
|
Visualization::scenePos = scene->getScenePos();
|
|
RefreshGeometry();
|
|
|
|
AddOnScene();
|
|
}
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
void VisToolPointOfIntersectionCurves::setObject2Id(const quint32 &value)
|
|
{
|
|
object2Id = value;
|
|
}
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
void VisToolPointOfIntersectionCurves::setVCrossPoint(const VCrossCurvesPoint &value)
|
|
{
|
|
vCrossPoint = value;
|
|
}
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
void VisToolPointOfIntersectionCurves::setHCrossPoint(const HCrossCurvesPoint &value)
|
|
{
|
|
hCrossPoint = value;
|
|
}
|