Seamly2D
Code documentation
vtoolspline.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 vtoolspline.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 VTOOLSPLINE_H
53 #define VTOOLSPLINE_H
54 
55 #include <qcompilerdetection.h>
56 #include <QGraphicsItem>
57 #include <QMetaObject>
58 #include <QObject>
59 #include <QPointF>
60 #include <QString>
61 #include <QtGlobal>
62 
63 #include "../vgeometry/vgeometrydef.h"
64 #include "../vmisc/def.h"
65 #include "../ifc/xml/vabstractpattern.h"
66 #include "vabstractspline.h"
67 
68 template <class T> class QSharedPointer;
69 
70 /**
71  * @brief The VToolSpline class tool for creation spline. I mean bezier curve.
72  */
74 {
75  Q_OBJECT
76 public:
77  virtual ~VToolSpline() =default;
78  virtual void setDialog() Q_DECL_OVERRIDE;
80  VContainer *data);
81  static VToolSpline *Create(const quint32 _id, VSpline *spline,
83  const Document &parse, const Source &typeCreation);
84  static VToolSpline *Create(const quint32 _id, quint32 point1, quint32 point4, QString &a1, QString &a2, QString &l1,
85  QString &l2, quint32 duplicate, const QString &color, const QString &penStyle,
86  const QString &lineWeight, VMainGraphicsScene *scene, VAbstractPattern *doc,
87  VContainer *data, const Document &parse, const Source &typeCreation);
88  static const QString ToolType;
89  static const QString OldToolType;
90  virtual int type() const Q_DECL_OVERRIDE {return Type;}
91  enum { Type = UserType + static_cast<int>(Tool::Spline)};
92 
93  VSpline getSpline()const;
94  void setSpline(const VSpline &spl);
95 
96  virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
97 
98 public slots:
99  void ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
100  const QPointF &pos);
101  virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE;
102 
103 protected slots:
104  virtual void showContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
105 
106 protected:
107  virtual void RemoveReferens() Q_DECL_OVERRIDE;
108  virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
109  virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
110  virtual void mousePressEvent(QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
111  virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
112  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
113  virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
114  virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
115  virtual void SetVisualization() Q_DECL_OVERRIDE;
116  virtual void refreshCtrlPoints() Q_DECL_OVERRIDE;
117 
118 private:
119  Q_DISABLE_COPY(VToolSpline)
120  QPointF oldPosition;
121 
123  const Source &typeCreation, QGraphicsItem * parent = nullptr );
124 
125  bool IsMovable() const;
126  void SetSplineAttributes(QDomElement &domElement, const VSpline &spl);
127 };
128 
129 #endif // VTOOLSPLINE_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.
VSpline class that implements the spline.
Definition: vspline.h:75
The VToolSpline class tool for creation spline. I mean bezier curve.
Definition: vtoolspline.h:74
VSpline getSpline() const
static const QString OldToolType
Definition: vtoolspline.h:89
virtual void RemoveReferens() Q_DECL_OVERRIDE
RemoveReferens decrement value of reference.
virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE
virtual void SaveOptions(QDomElement &tag, QSharedPointer< VGObject > &obj) Q_DECL_OVERRIDE
QPointF oldPosition
Definition: vtoolspline.h:120
void setSpline(const VSpline &spl)
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
static VToolSpline * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
bool IsMovable() const
void ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position, const QPointF &pos)
ControlPointChangePosition handle change position control point.
virtual void refreshCtrlPoints() Q_DECL_OVERRIDE
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE
hoverEnterEvent handle hover enter events.
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE
hoverLeaveEvent handle hover leave events.
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
mouseReleaseEvent handle mouse release events.
void SetSplineAttributes(QDomElement &domElement, const VSpline &spl)
virtual void setDialog() Q_DECL_OVERRIDE
setDialog set dialog when user want change tool option.
virtual ~VToolSpline()=default
virtual int type() const Q_DECL_OVERRIDE
Definition: vtoolspline.h:90
virtual void showContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE
contextMenuEvent handle context menu events.
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE
SaveDialog save options into file after change in dialog.
virtual void SetVisualization() Q_DECL_OVERRIDE
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
static const QString ToolType
Definition: vtoolspline.h:88
@ Spline
Source
Definition: def.h:106
#define NULL_ID
Definition: ifcdef.h:76
Document
SplinePointPosition
Definition: vgeometrydef.h:58