Seamly2D
Code documentation
vistoolpointofintersectionarcs.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 vistoolpointofintersectionarcs.cpp
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 27 5, 2015
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) 2015 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 <QGraphicsEllipseItem>
55 #include <QGraphicsPathItem>
56 #include <QPainterPath>
57 #include <QPen>
58 #include <QPointF>
59 #include <QSharedPointer>
60 #include <Qt>
61 #include <new>
62 
63 #include "../../tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h"
64 #include "../ifc/ifcdef.h"
65 #include "../vgeometry/vabstractcurve.h"
66 #include "../vgeometry/varc.h"
67 #include "../vmisc/vabstractapplication.h"
68 #include "../vpatterndb/vcontainer.h"
69 #include "../vwidgets/vmaingraphicsscene.h"
70 #include "../visualization.h"
72 
73 //---------------------------------------------------------------------------------------------------------------------
75  : VisLine(data, parent), arc1Id(NULL_ID), arc2Id(NULL_ID), crossPoint(CrossCirclesPoint::FirstPoint),
76  point(nullptr),
77  arc1Path(nullptr), arc2Path(nullptr)
78 {
79  this->setPen(QPen(Qt::NoPen)); // don't use parent this time
80 
81  arc1Path = InitItem<VCurvePathItem>(Qt::darkGreen, this);
82  arc1Path->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
83  arc2Path = InitItem<VCurvePathItem>(Qt::darkRed, this);
84  arc2Path->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
85 
86  point = InitPoint(mainColor, this);
87  point->setZValue(2);
88  point->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
89 }
90 
91 //---------------------------------------------------------------------------------------------------------------------
93 {
94  if (arc1Id > NULL_ID)
95  {
97  DrawPath(arc1Path, arc1->GetPath(), arc1->DirectionArrows(), Qt::darkGreen, Qt::SolidLine,
98  lineWeight, Qt::RoundCap);
99 
100  if (arc2Id > NULL_ID)
101  {
103  DrawPath(arc2Path, arc2->GetPath(), arc2->DirectionArrows(), Qt::darkRed, Qt::SolidLine,
104  lineWeight, Qt::RoundCap);
105 
106  const QPointF fPoint = VToolPointOfIntersectionArcs::FindPoint(arc1.data(), arc2.data(), crossPoint);
107  DrawPoint(point, fPoint, mainColor);
108  }
109  }
110 }
111 
112 //---------------------------------------------------------------------------------------------------------------------
114 {
115  VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
116  SCASSERT(scene != nullptr)
117 
118  this->arc1Id = id;
120  RefreshGeometry();
121 
122  AddOnScene();
123 }
124 
125 //---------------------------------------------------------------------------------------------------------------------
127 {
128  arc1Id = value;
129 }
130 
131 //---------------------------------------------------------------------------------------------------------------------
133 {
134  arc2Id = value;
135 }
136 
137 //---------------------------------------------------------------------------------------------------------------------
139 {
140  crossPoint = value;
141 }
VArc class for anticlockwise arc.
Definition: varc.h:74
The VContainer class container of all variables.
Definition: vcontainer.h:141
const QSharedPointer< T > GeometricObject(const quint32 &id) const
Definition: vcontainer.h:266
The VMainGraphicsScene class main scene.
QPointF getScenePos() const
static QPointF FindPoint(const VArc *arc1, const VArc *arc2, const CrossCirclesPoint pType)
virtual void AddOnScene() Q_DECL_OVERRIDE
Definition: visline.cpp:149
VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent=nullptr)
virtual void VisualMode(const quint32 &id) Q_DECL_OVERRIDE
void setCrossPoint(const CrossCirclesPoint &value)
virtual void RefreshGeometry() Q_DECL_OVERRIDE
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
#define SCASSERT(cond)
Definition: def.h:317
#define NULL_ID
Definition: ifcdef.h:76
CrossCirclesPoint
#define qApp
Definition: vapplication.h:67