Seamly2D
Code documentation
vtoolsplinepath.h
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 vtoolsplinepath.h
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date November 15, 2013
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) 2013-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 #ifndef VTOOLSPLINEPATH_H
53 #define VTOOLSPLINEPATH_H
54 
55 #include <qcompilerdetection.h>
56 #include <QGraphicsItem>
57 #include <QMetaObject>
58 #include <QObject>
59 #include <QPointF>
60 #include <QString>
61 #include <QVector>
62 #include <QtGlobal>
63 
64 #include "../vgeometry/vgeometrydef.h"
65 #include "../vmisc/def.h"
66 #include "../ifc/xml/vabstractpattern.h"
67 #include "vabstractspline.h"
68 
69 class VSplinePath;
70 template <class T> class QSharedPointer;
71 
72 /**
73  * @brief The VToolSplinePath class tool for creation spline path.
74  */
76 {
77  Q_OBJECT
78 public:
79  virtual ~VToolSplinePath() =default;
80  virtual void setDialog() Q_DECL_OVERRIDE;
83  static VToolSplinePath *Create(const quint32 _id, VSplinePath *path,
85  const Document &parse, const Source &typeCreation);
86  static VToolSplinePath *Create(const quint32 _id, const QVector<quint32> &points, QVector<QString> &a1,
87  QVector<QString> &a2, QVector<QString> &l1, QVector<QString> &l2,
88  const QString &color, const QString &penStyle, const QString &lineWeight,
89  quint32 duplicate, VMainGraphicsScene *scene, VAbstractPattern *doc,
90  VContainer *data, const Document &parse, const Source &typeCreation);
91  static const QString ToolType;
92  static const QString OldToolType;
93  static void UpdatePathPoints(VAbstractPattern *doc, QDomElement &element, const VSplinePath &path);
94  virtual int type() const Q_DECL_OVERRIDE {return Type;}
95  enum { Type = UserType + static_cast<int>(Tool::SplinePath)};
96 
98  void setSplinePath(const VSplinePath &splPath);
99 
100  virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
101 
102 signals:
103  /**
104  * @brief RefreshLine refresh control line.
105  * @param indexSpline position spline in spline list.
106  * @param pos position point in spline.
107  * @param controlPoint new position control point.
108  * @param splinePoint new position spline point.
109  */
110  void RefreshLine(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint,
111  const QPointF &splinePoint);
112 public slots:
113 
114  void ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
115  const QPointF &pos);
116  virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE;
117 
118 protected slots:
119  virtual void showContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
120 
121 protected:
122  virtual void RemoveReferens() Q_DECL_OVERRIDE;
123  virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
124  virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
125  virtual void mousePressEvent(QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
126  virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
127  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
128  virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
129  virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
130  virtual void SetVisualization() Q_DECL_OVERRIDE;
131  virtual void refreshCtrlPoints() Q_DECL_OVERRIDE;
132 
133 private:
134  Q_DISABLE_COPY(VToolSplinePath)
135  QPointF oldPosition;
136  int splIndex;
137 
139  const Source &typeCreation, QGraphicsItem *parent = nullptr);
140 
141  bool IsMovable(int index) const;
142  static void AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint);
143  void UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const;
144  void SetSplinePathAttributes(QDomElement &domElement, const VSplinePath &path);
145 };
146 
147 #endif // VTOOLSPLINEPATH_H
The DialogTool class parent for all dialog of tools.
Definition: dialogtool.h:107
VAbstractPattern * doc
doc dom document container
The VContainer class container of all variables.
Definition: vcontainer.h:141
VContainer data
data container with data
Definition: vdatatool.h:84
The VGObject class keep information graphical objects.
Definition: vgobject.h:74
The VMainGraphicsScene class main scene.
The VSplinePath class keep information about splinePath.
Definition: vsplinepath.h:72
The VSplinePoint class keep information about point in spline path. Each point have two angles and tw...
Definition: vsplinepoint.h:108
VSpline class that implements the spline.
Definition: vspline.h:75
The VToolSplinePath class tool for creation spline path.
static void AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint)
AddPathPoint write path point to pattern file.
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE
SaveDialog save options into file after change in dialog.
virtual void setDialog() Q_DECL_OVERRIDE
setDialog set dialog when user want change tool option.
static VToolSplinePath * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
virtual void SetVisualization() Q_DECL_OVERRIDE
static void UpdatePathPoints(VAbstractPattern *doc, QDomElement &element, const VSplinePath &path)
UpdatePathPoints update spline path in pattern file.
void SetSplinePathAttributes(QDomElement &domElement, const VSplinePath &path)
virtual void SaveOptions(QDomElement &tag, QSharedPointer< VGObject > &obj) Q_DECL_OVERRIDE
static const QString ToolType
virtual void showContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE
contextMenuEvent handle context menu events.
static const QString OldToolType
virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE
virtual int type() const Q_DECL_OVERRIDE
void UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const
UpdateControlPoints update position points control points in file.
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE
virtual ~VToolSplinePath()=default
virtual void refreshCtrlPoints() Q_DECL_OVERRIDE
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
mouseReleaseEvent handle mouse release events.
void RefreshLine(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint, const QPointF &splinePoint)
RefreshLine refresh control line.
void setSplinePath(const VSplinePath &splPath)
void ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position, const QPointF &pos)
ControlPointChangePosition handle change position control point.
bool IsMovable(int index) const
VSplinePath getSplinePath() const
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE
hoverLeaveEvent handle hover leave events.
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE
hoverEnterEvent handle hover enter events.
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
virtual void RemoveReferens() Q_DECL_OVERRIDE
RemoveReferens decrement value of reference.
@ SplinePath
Source
Definition: def.h:106
const QString splPath
Definition: ifcdef.cpp:419
#define NULL_ID
Definition: ifcdef.h:76
Document
SplinePointPosition
Definition: vgeometrydef.h:58