Seamly2D
Code documentation
vistoolellipticalarc.cpp
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vistoolellipticalarc.cpp
4  ** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
5  ** @date 24 10, 2016
6  **
7  ** @brief
8  ** @copyright
9  ** This source code is part of the Valentine project, a pattern making
10  ** program, whose allow create and modeling patterns of clothing.
11  ** Copyright (C) 2016 Seamly2D project
12  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
13  **
14  ** Seamly2D is free software: you can redistribute it and/or modify
15  ** it under the terms of the GNU General Public License as published by
16  ** the Free Software Foundation, either version 3 of the License, or
17  ** (at your option) any later version.
18  **
19  ** Seamly2D is distributed in the hope that it will be useful,
20  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  ** GNU General Public License for more details.
23  **
24  ** You should have received a copy of the GNU General Public License
25  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
26  **
27  *************************************************************************/
28 #include "vistoolellipticalarc.h"
29 #include <QPainterPath>
30 #include <QPointF>
31 #include <QSharedPointer>
32 #include <Qt>
33 #include <new>
34 
35 #include "../ifc/ifcdef.h"
36 #include "../vgeometry/vabstractcurve.h"
37 #include "../vgeometry/vellipticalarc.h"
38 #include "../vgeometry/vpointf.h"
39 #include "../vpatterndb/vcontainer.h"
40 #include "../visualization.h"
41 #include "vispath.h"
42 
43 VisToolEllipticalArc::VisToolEllipticalArc(const VContainer *data, QGraphicsItem *parent)
44  :VisPath(data, parent), arcCenter(nullptr), radius1(0), radius2(0), f1(0), f2(0), rotationAngle(0)
45 {
46  arcCenter = InitPoint(mainColor, this);
47 }
48 
49 //---------------------------------------------------------------------------------------------------------------------
51 {
52  if (object1Id > NULL_ID)
53  {
55  DrawPoint(arcCenter, static_cast<QPointF>(*first), supportColor);
56 
57  if (not qFuzzyIsNull(radius1) && not qFuzzyIsNull(radius2) && f1 >= 0 && f2 >= 0 && rotationAngle >= 0)
58  {
60  DrawPath(this, elArc.GetPath(), elArc.DirectionArrows(), mainColor, lineStyle, lineWeight, Qt::RoundCap);
61  }
62  }
63 }
64 
65 //---------------------------------------------------------------------------------------------------------------------
66 void VisToolEllipticalArc::setRadius1(const QString &expression)
67 {
68  radius1 = FindLength(expression, Visualization::data->DataVariables());
69 }
70 
71 //---------------------------------------------------------------------------------------------------------------------
72 void VisToolEllipticalArc::setRadius2(const QString &expression)
73 {
74  radius2 = FindLength(expression, Visualization::data->DataVariables());
75 }
76 
77 //---------------------------------------------------------------------------------------------------------------------
78 void VisToolEllipticalArc::setF1(const QString &expression)
79 {
80  f1 = FindVal(expression, Visualization::data->DataVariables());
81 }
82 
83 //---------------------------------------------------------------------------------------------------------------------
84 void VisToolEllipticalArc::setF2(const QString &expression)
85 {
86  f2 = FindVal(expression, Visualization::data->DataVariables());
87 }
88 
89 //---------------------------------------------------------------------------------------------------------------------
90 void VisToolEllipticalArc::setRotationAngle(const QString &expression)
91 {
92  rotationAngle = FindVal(expression, Visualization::data->DataVariables());
93 }
virtual QVector< DirectionArrow > DirectionArrows() const
virtual QPainterPath GetPath() const
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
void setF1(const QString &expression)
void setRadius2(const QString &expression)
VScaledEllipse * arcCenter
VisToolEllipticalArc(const VContainer *data, QGraphicsItem *parent=nullptr)
virtual void RefreshGeometry() Q_DECL_OVERRIDE
void setF2(const QString &expression)
void setRadius1(const QString &expression)
void setRotationAngle(const QString &expression)
QColor supportColor
QColor mainColor
Definition: visualization.h:99
void DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, const QColor &color, Qt::PenStyle style=Qt::SolidLine)
static qreal FindLength(const QString &expression, const QHash< QString, QSharedPointer< VInternalVariable > > *vars)
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)
VScaledEllipse * InitPoint(const QColor &color, QGraphicsItem *parent, qreal z=0) const
quint32 object1Id
static qreal FindVal(const QString &expression, const QHash< QString, QSharedPointer< VInternalVariable > > *vars)
Qt::PenStyle lineStyle
#define NULL_ID
Definition: ifcdef.h:76