Seamly2D
Code documentation
vistoolpointofintersectioncurves.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2017 Seamly, LLC *
4  * *
5  * https://github.com/fashionfreedom/seamly2d *
6  * *
7  ***************************************************************************
8  **
9  ** Seamly2D is free software: you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation, either version 3 of the License, or
12  ** (at your option) any later version.
13  **
14  ** Seamly2D is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** You should have received a copy of the GNU General Public License
20  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
21  **
22  **************************************************************************
23 
24  ************************************************************************
25  **
26  ** @file vistoolpointofintersectioncurves.cpp
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 24 1, 2016
29  **
30  ** @brief
31  ** @copyright
32  ** This source code is part of the Valentine project, a pattern making
33  ** program, whose allow create and modeling patterns of clothing.
34  ** Copyright (C) 2016 Seamly2D project
35  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
36  **
37  ** Seamly2D is free software: you can redistribute it and/or modify
38  ** it under the terms of the GNU General Public License as published by
39  ** the Free Software Foundation, either version 3 of the License, or
40  ** (at your option) any later version.
41  **
42  ** Seamly2D is distributed in the hope that it will be useful,
43  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
44  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  ** GNU General Public License for more details.
46  **
47  ** You should have received a copy of the GNU General Public License
48  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
49  **
50  *************************************************************************/
51 
53 
54 #include <QGraphicsPathItem>
55 #include <QPainterPath>
56 #include <QPointF>
57 #include <QSharedPointer>
58 #include <Qt>
59 #include <new>
60 
61 #include "../../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h"
62 #include "../ifc/ifcdef.h"
63 #include "../vgeometry/vabstractcurve.h"
64 #include "../vmisc/vabstractapplication.h"
65 #include "../vpatterndb/vcontainer.h"
66 #include "../vwidgets/vmaingraphicsscene.h"
67 #include "../visualization.h"
69 
70 //---------------------------------------------------------------------------------------------------------------------
72  :VisPath(data, parent),
73  object2Id(NULL_ID),
74  vCrossPoint(VCrossCurvesPoint::HighestPoint),
75  hCrossPoint(HCrossCurvesPoint::LeftmostPoint),
76  point(nullptr),
77  visCurve2(nullptr)
78 {
79  visCurve2 = InitItem<VCurvePathItem>(supportColor, this);
80  point = InitPoint(mainColor, this);
81 }
82 
83 //---------------------------------------------------------------------------------------------------------------------
85 {
86  if (object1Id > NULL_ID)
87  {
89  DrawPath(this, curve1->GetPath(), curve1->DirectionArrows(), supportColor, Qt::SolidLine,
90  lineWeight, Qt::RoundCap);
91 
92  if (object2Id > NULL_ID)
93  {
95  DrawPath(visCurve2, curve2->GetPath(), curve2->DirectionArrows(), supportColor, Qt::SolidLine,
96  lineWeight, Qt::RoundCap);
97 
98  auto p = VToolPointOfIntersectionCurves::FindPoint(curve1->getPoints(), curve2->getPoints(), vCrossPoint,
99  hCrossPoint);
101  }
102  }
103 }
104 
105 //---------------------------------------------------------------------------------------------------------------------
107 {
108  auto scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
109  SCASSERT(scene != nullptr)
110 
111  this->object1Id = id;
112  Visualization::scenePos = scene->getScenePos();
113  RefreshGeometry();
114 
115  AddOnScene();
116 }
117 
118 //---------------------------------------------------------------------------------------------------------------------
120 {
121  object2Id = value;
122 }
123 
124 //---------------------------------------------------------------------------------------------------------------------
126 {
127  vCrossPoint = value;
128 }
129 
130 //---------------------------------------------------------------------------------------------------------------------
132 {
133  hCrossPoint = value;
134 }
The VContainer class container of all variables.
Definition: vcontainer.h:141
const QSharedPointer< T > GeometricObject(const quint32 &id) const
Definition: vcontainer.h:266
static QPointF FindPoint(const QVector< QPointF > &curve1Points, const QVector< QPointF > &curve2Points, VCrossCurvesPoint vCrossPoint, HCrossCurvesPoint hCrossPoint)
virtual void AddOnScene() Q_DECL_OVERRIDE
Definition: vispath.cpp:63
void setHCrossPoint(const HCrossCurvesPoint &value)
void setVCrossPoint(const VCrossCurvesPoint &value)
VisToolPointOfIntersectionCurves(const VContainer *data, QGraphicsItem *parent=nullptr)
virtual void VisualMode(const quint32 &id) Q_DECL_OVERRIDE
QColor supportColor
QColor mainColor
Definition: visualization.h:99
void DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color, Qt::PenStyle style=Qt::SolidLine)
const VContainer * data
Definition: visualization.h:97
void DrawPath(VCurvePathItem *pathItem, const QPainterPath &path, const QColor &color, Qt::PenStyle style=Qt::SolidLine, const qreal &weight=0.35, Qt::PenCapStyle cap=Qt::SquareCap)
QPointF scenePos
Definition: visualization.h:98
VScaledEllipse * InitPoint(const QColor &color, QGraphicsItem *parent, qreal z=0) const
quint32 object1Id
#define SCASSERT(cond)
Definition: def.h:317
#define NULL_ID
Definition: ifcdef.h:76
HCrossCurvesPoint
VCrossCurvesPoint
#define qApp
Definition: vapplication.h:67