Seamly2D
Code documentation
vistooltruedarts.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 vistooltruedarts.cpp
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 23 6, 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 
52 #include "vistooltruedarts.h"
53 
54 #include <QGraphicsLineItem>
55 #include <QLineF>
56 #include <QPointF>
57 #include <QSharedPointer>
58 #include <Qt>
59 #include <new>
60 
61 #include "../../tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h"
62 #include "../ifc/ifcdef.h"
63 #include "../vgeometry/vpointf.h"
64 #include "../vpatterndb/vcontainer.h"
65 #include "../visualization.h"
66 #include "visline.h"
67 
68 //---------------------------------------------------------------------------------------------------------------------
69 VisToolTrueDarts::VisToolTrueDarts(const VContainer *data, QGraphicsItem *parent)
70  :VisLine(data, parent),
71  baseLineP2Id(NULL_ID),
72  dartP1Id(NULL_ID),
73  dartP2Id(NULL_ID),
74  dartP3Id(NULL_ID),
75  point1(nullptr),
76  point2(nullptr),
77  baseLineP1(nullptr),
78  baseLineP2(nullptr),
79  dartP1(nullptr),
80  dartP2(nullptr),
81  dartP3(nullptr),
82  lineblP1P1(nullptr),
83  lineblP2P2(nullptr),
84  p1d2(nullptr),
85  d2p2(nullptr)
86 {
89  dartP1 = InitPoint(supportColor, this);
90  dartP2 = InitPoint(supportColor, this);
91  dartP3 = InitPoint(supportColor, this);
92 
93  lineblP1P1 = InitItem<VScaledLine>(supportColor, this);
94  lineblP2P2 = InitItem<VScaledLine>(supportColor, this);
95  p1d2 = InitItem<VScaledLine>(supportColor, this);
96  d2p2 = InitItem<VScaledLine>(supportColor, this);
97 
98  point1 = InitPoint(mainColor, this);
99  point2 = InitPoint(mainColor, this); //-V656
100 }
101 
102 //---------------------------------------------------------------------------------------------------------------------
104 {
105  if (object1Id > NULL_ID)
106  {
108  DrawPoint(baseLineP1, static_cast<QPointF>(*blP1), supportColor);
109 
110  if (baseLineP2Id <= NULL_ID)
111  {
112  DrawLine(this, QLineF(static_cast<QPointF>(*blP1), Visualization::scenePos), supportColor,
113  lineWeight, Qt::DashLine);
114  }
115  else
116  {
118  DrawPoint(baseLineP2, static_cast<QPointF>(*blP2), supportColor);
119  DrawLine(this, QLineF(static_cast<QPointF>(*blP1), static_cast<QPointF>(*blP2)), supportColor, lineWeight,
120  Qt::DashLine);
121 
122  if (dartP1Id > NULL_ID)
123  {
125  DrawPoint(dartP1, static_cast<QPointF>(*d1), supportColor);
126 
127  if (dartP2Id <= NULL_ID)
128  {
129  DrawLine(p1d2, QLineF(static_cast<QPointF>(*d1), Visualization::scenePos),
131  }
132  else
133  {
135  DrawPoint(dartP2, static_cast<QPointF>(*d2), supportColor);
136  DrawLine(p1d2, QLineF(static_cast<QPointF>(*d1), static_cast<QPointF>(*d2)),
138 
139  if (dartP3Id <= NULL_ID)
140  {
141  DrawLine(d2p2, QLineF(static_cast<QPointF>(*d2), Visualization::scenePos),
143  }
144  else
145  {
147  DrawPoint(dartP3, static_cast<QPointF>(*d3), supportColor);
148  DrawLine(d2p2, QLineF(static_cast<QPointF>(*d2), static_cast<QPointF>(*d3)),
150 
151  QPointF p1;
152  QPointF p2;
153  VToolTrueDarts::FindPoint(static_cast<QPointF>(*blP1), static_cast<QPointF>(*blP2),
154  static_cast<QPointF>(*d1), static_cast<QPointF>(*d2),
155  static_cast<QPointF>(*d3), p1, p2);
156 
157  DrawLine(lineblP1P1, QLineF(static_cast<QPointF>(*blP1), p1), supportColor, lineWeight);
158  DrawLine(lineblP2P2, QLineF(static_cast<QPointF>(*blP2), p2), supportColor, lineWeight);
159  DrawLine(p1d2, QLineF(p1, static_cast<QPointF>(*d2)), supportColor, lineWeight);
160  DrawLine(d2p2, QLineF(static_cast<QPointF>(*d2), p2), supportColor, lineWeight);
161 
162  DrawPoint(point1, p1, mainColor);
163  DrawPoint(point2, p2, mainColor);
164  }
165  }
166  }
167  }
168  }
169 }
170 
171 //---------------------------------------------------------------------------------------------------------------------
172 void VisToolTrueDarts::setObject2Id(const quint32 &value)
173 {
174  baseLineP2Id = value;
175 }
176 
177 //---------------------------------------------------------------------------------------------------------------------
178 void VisToolTrueDarts::setD1PointId(const quint32 &value)
179 {
180  dartP1Id = value;
181 }
182 
183 //---------------------------------------------------------------------------------------------------------------------
184 void VisToolTrueDarts::setD2PointId(const quint32 &value)
185 {
186  dartP2Id = value;
187 }
188 
189 //---------------------------------------------------------------------------------------------------------------------
190 void VisToolTrueDarts::setD3PointId(const quint32 &value)
191 {
192  dartP3Id = value;
193 }
The VContainer class container of all variables.
Definition: vcontainer.h:141
const QSharedPointer< T > GeometricObject(const quint32 &id) const
Definition: vcontainer.h:266
The VPointF class keep data of point.
Definition: vpointf.h:75
static void FindPoint(const QPointF &baseLineP1, const QPointF &baseLineP2, const QPointF &dartP1, const QPointF &dartP2, const QPointF &dartP3, QPointF &p1, QPointF &p2)
void setD3PointId(const quint32 &value)
VScaledEllipse * point1
VScaledEllipse * point2
VScaledEllipse * dartP2
VScaledEllipse * dartP1
VScaledEllipse * dartP3
VScaledEllipse * baseLineP1
void setD1PointId(const quint32 &value)
VScaledLine * lineblP2P2
VisToolTrueDarts(const VContainer *data, QGraphicsItem *parent=nullptr)
virtual void RefreshGeometry() Q_DECL_OVERRIDE
VScaledLine * p1d2
void setObject2Id(const quint32 &value)
VScaledLine * lineblP1P1
void setD2PointId(const quint32 &value)
VScaledEllipse * baseLineP2
VScaledLine * d2p2
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
QPointF scenePos
Definition: visualization.h:98
virtual void DrawLine(VScaledLine *lineItem, const QLineF &line, const QColor &color, const qreal &lineWeight, Qt::PenStyle style=Qt::SolidLine)
VScaledEllipse * InitPoint(const QColor &color, QGraphicsItem *parent, qreal z=0) const
quint32 object1Id
#define NULL_ID
Definition: ifcdef.h:76