Seamly2D
Code documentation
vtoolmove.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
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 1 10, 2016
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) 2016 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 VTOOLMOVING_H
53 #define VTOOLMOVING_H
54 
55 #include <qcompilerdetection.h>
56 #include <QMap>
57 #include <QMetaObject>
58 #include <QObject>
59 #include <QString>
60 #include <QVector>
61 #include <QtGlobal>
62 
63 #include "vabstractoperation.h"
64 #include "../vgeometry/vgeometrydef.h"
65 #include "../vmisc/def.h"
66 #include "../ifc/xml/vabstractpattern.h"
67 
68 template <class T> class QSharedPointer;
69 class VFormula;
70 
72 {
73  Q_OBJECT
74 public:
75  virtual ~VToolMove() Q_DECL_EQ_DEFAULT;
76  virtual void setDialog() Q_DECL_OVERRIDE;
79 
80  static VToolMove *Create(quint32 _id, QString &formulaAngle, QString &formulaLength, QString &formulaRotation,
81  quint32 &rotationOriginId, const QString &suffix, const QVector<SourceItem> &source,
84  const Document &parse, const Source &typeCreation);
85 
86  static const QString ToolType;
87 
88  virtual int type() const Q_DECL_OVERRIDE {return Type;}
89  enum {Type = UserType + static_cast<int>(Tool::Move)};
90 
91  VFormula GetFormulaAngle() const;
92  void SetFormulaAngle(const VFormula &value);
93 
94  VFormula GetFormulaLength() const;
95  void SetFormulaLength(const VFormula &value);
96 
98  void setFormulaRotation(const VFormula &value);
99 
100  QString getOriginPointName() const;
101  quint32 getOriginPointId() const;
102  void setOriginPointId(const quint32 &value);
103 
104  virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
105 
106 protected slots:
107  virtual void showContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
108 
109 protected:
110  virtual void SetVisualization() Q_DECL_OVERRIDE;
111  virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
112  virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
113  virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
114  virtual QString makeToolTip() const Q_DECL_OVERRIDE;
115 
116 private:
117  Q_DISABLE_COPY(VToolMove)
118  QString formulaAngle;
119  QString formulaLength;
122 
123  VToolMove(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &formulaAngle,
124  const QString &formulaLength, const QString &formulaRotation,
125  const quint32 &originPointId, const QString &suffix,
127  const Source &typeCreation, QGraphicsItem *parent = nullptr);
128 
129  static DestinationItem createPoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation,
130  const QPointF &rotationOrigin, const QString &suffix, VContainer *data);
131 
132  template <class Item>
133  static DestinationItem createItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation,
134  const QPointF &rotationOrigin, const QString &suffix, VContainer *data);
135  template <class Item>
136  static DestinationItem createArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation,
137  const QPointF &rotationOrigin, const QString &suffix, VContainer *data);
138  template <class Item>
139  static DestinationItem createCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation,
140  const QPointF &rotationOrigin, const QString &suffix, VContainer *data);
141  template <class Item>
142  static DestinationItem createCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length,
143  qreal rotation, const QPointF &rotationOrigin,
144  const QString &suffix, VContainer *data);
145 
146  static void updatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation,
147  const QPointF &rotationOrigin, const QString &suffix, VContainer *data,
148  const DestinationItem &item);
149  template <class Item>
150  static void updateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation,
151  const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id);
152  template <class Item>
153  static void updateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation,
154  const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id);
155  template <class Item>
156  static void updateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation,
157  const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id);
158  template <class Item>
159  static void updateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length,
160  qreal rotation, const QPointF &rotationOrigin,
161  const QString &suffix, VContainer *data, quint32 id);
162 };
163 
164 #endif // VTOOLMOVING_H
The DialogTool class parent for all dialog of tools.
Definition: dialogtool.h:107
QVector< SourceItem > source
QVector< DestinationItem > destination
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.
static void updateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation, const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id)
Definition: vtoolmove.cpp:689
static void updatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation, const QPointF &rotationOrigin, const QString &suffix, VContainer *data, const DestinationItem &item)
Definition: vtoolmove.cpp:664
virtual int type() const Q_DECL_OVERRIDE
Definition: vtoolmove.h:88
static void updateCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation, const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id)
Definition: vtoolmove.cpp:698
static VToolMove * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Definition: vtoolmove.cpp:178
virtual void SetVisualization() Q_DECL_OVERRIDE
Definition: vtoolmove.cpp:501
void setFormulaRotation(const VFormula &value)
Definition: vtoolmove.cpp:455
virtual void showContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE
Definition: vtoolmove.cpp:582
static DestinationItem createArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation, const QPointF &rotationOrigin, const QString &suffix, VContainer *data)
Definition: vtoolmove.cpp:630
static DestinationItem createItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation, const QPointF &rotationOrigin, const QString &suffix, VContainer *data)
Definition: vtoolmove.cpp:614
QString formulaAngle
Definition: vtoolmove.h:118
virtual void setDialog() Q_DECL_OVERRIDE
setDialog set dialog when user want change tool option.
Definition: vtoolmove.cpp:164
QString getOriginPointName() const
Definition: vtoolmove.cpp:467
quint32 getOriginPointId() const
Definition: vtoolmove.cpp:480
VFormula getFormulaRotation() const
Definition: vtoolmove.cpp:444
QString formulaLength
Definition: vtoolmove.h:119
static void updateCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation, const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id)
Definition: vtoolmove.cpp:707
QString formulaRotation
Definition: vtoolmove.h:120
static DestinationItem createPoint(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation, const QPointF &rotationOrigin, const QString &suffix, VContainer *data)
Definition: vtoolmove.cpp:596
virtual ~VToolMove() Q_DECL_EQ_DEFAULT
static DestinationItem createCurveWithSegments(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation, const QPointF &rotationOrigin, const QString &suffix, VContainer *data)
Definition: vtoolmove.cpp:653
static DestinationItem createCurve(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation, const QPointF &rotationOrigin, const QString &suffix, VContainer *data)
Definition: vtoolmove.cpp:642
void SetFormulaLength(const VFormula &value)
Definition: vtoolmove.cpp:432
VFormula GetFormulaLength() const
Definition: vtoolmove.cpp:421
static const QString ToolType
Definition: vtoolmove.h:86
void SetFormulaAngle(const VFormula &value)
Definition: vtoolmove.cpp:409
virtual QString makeToolTip() const Q_DECL_OVERRIDE
Definition: vtoolmove.cpp:562
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE
Definition: vtoolmove.cpp:495
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE
Definition: vtoolmove.cpp:536
quint32 m_originPointId
Definition: vtoolmove.h:121
void setOriginPointId(const quint32 &value)
Definition: vtoolmove.cpp:486
static void updateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, qreal rotation, const QPointF &rotationOrigin, const QString &suffix, VContainer *data, quint32 id)
Definition: vtoolmove.cpp:678
virtual void SaveOptions(QDomElement &tag, QSharedPointer< VGObject > &obj) Q_DECL_OVERRIDE
Definition: vtoolmove.cpp:549
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE
SaveDialog save options into file after change in dialog.
Definition: vtoolmove.cpp:518
VFormula GetFormulaAngle() const
Definition: vtoolmove.cpp:398
Source
Definition: def.h:106
#define NULL_ID
Definition: ifcdef.h:76
Document