Seamly2D
Code documentation
vtoolline.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 vtoolline.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 VTOOLLINE_H
53 #define VTOOLLINE_H
54 
55 #include <qcompilerdetection.h>
56 #include <QDomElement>
57 #include <QGraphicsItem>
58 #include <QGraphicsLineItem>
59 #include <QMetaObject>
60 #include <QObject>
61 #include <QString>
62 #include <QVariant>
63 #include <QtGlobal>
64 
65 #include "../ifc/xml/vabstractpattern.h"
66 #include "../vmisc/def.h"
67 #include "vdrawtool.h"
68 
69 template <class T> class QSharedPointer;
70 
71 /**
72  * @brief The VToolLine class tool for creation line.
73  */
74 class VToolLine: public VDrawTool, public QGraphicsLineItem
75 {
76  Q_OBJECT
77 public:
78  virtual void setDialog() Q_DECL_OVERRIDE;
79 
81  VContainer *data);
82  static VToolLine *Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint,
83  const QString &typeLine, const QString &lineWeight,
84  const QString &lineColor, VMainGraphicsScene *scene,
85  VAbstractPattern *doc, VContainer *data, const Document &parse,
86  const Source &typeCreation);
87 
88  virtual int type() const Q_DECL_OVERRIDE {return Type;}
89  enum { Type = UserType + static_cast<int>(Tool::Line)};
90  virtual QString getTagName() const Q_DECL_OVERRIDE;
91 
92  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
93  QWidget *widget = nullptr) Q_DECL_OVERRIDE;
94 
95  QString FirstPointName() const;
96  QString SecondPointName() const;
97 
98  quint32 GetFirstPoint() const;
99  void SetFirstPoint(const quint32 &value);
100 
101  quint32 GetSecondPoint() const;
102  void SetSecondPoint(const quint32 &value);
103 
104  QString getLineColor() const;
105  void setLineColor(const QString &value);
106 
107  virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
108 
109  virtual void setLineType(const QString &value) Q_DECL_OVERRIDE;
110  void setLineWeight(const QString &value) Q_DECL_OVERRIDE;
111 
112  virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
113 
114 public slots:
115  virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
116  virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE;
117  virtual void Disable(bool disable, const QString &draftBlockName) Q_DECL_OVERRIDE;
118  virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
119  virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
120 
121 protected slots:
122  virtual void showContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
123 
124 protected:
125  virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent * event ) override;
126  virtual void AddToFile() Q_DECL_OVERRIDE;
127  virtual void hoverEnterEvent(QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
128  virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
129  virtual void RemoveReferens() Q_DECL_OVERRIDE;
130  virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
131  virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
132  virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
133  virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
134  virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
135  virtual void SetVisualization() Q_DECL_OVERRIDE;
136  virtual QString makeToolTip() const Q_DECL_OVERRIDE;
137 
138 private:
139  Q_DISABLE_COPY(VToolLine)
140 
141  /** @brief firstPoint id first line point. */
142  quint32 firstPoint;
143 
144  /** @brief secondPoint id second line point. */
145  quint32 secondPoint;
146 
147  /** @brief lineColor color of a line. */
148  QString lineColor;
149 
151 
152  VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstPoint,
153  quint32 secondPoint, const QString &typeLine, const QString &lineWeight,
154  const QString &lineColor,
155  const Source &typeCreation, QGraphicsItem * parent = nullptr);
156 
157  void RefreshGeometry();
158 };
159 
160 #endif // VTOOLLINE_H
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 VDrawTool abstract class for all draw tool.
Definition: vdrawtool.h:68
The VGObject class keep information graphical objects.
Definition: vgobject.h:74
The VMainGraphicsScene class main scene.
The VToolLine class tool for creation line.
Definition: vtoolline.h:75
bool m_isHovered
Definition: vtoolline.h:150
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE
Definition: vtoolline.cpp:275
static VToolLine * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool form GUI.
Definition: vtoolline.cpp:133
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE
Definition: vtoolline.cpp:560
quint32 GetFirstPoint() const
Definition: vtoolline.cpp:567
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE
hoverLeaveEvent handle hover leave events.
Definition: vtoolline.cpp:344
void RefreshGeometry()
RefreshGeometry refresh item on scene.
Definition: vtoolline.cpp:588
quint32 secondPoint
secondPoint id second line point.
Definition: vtoolline.h:145
void SetFirstPoint(const quint32 &value)
Definition: vtoolline.cpp:573
quint32 firstPoint
firstPoint id first line point.
Definition: vtoolline.h:142
void setLineColor(const QString &value)
Definition: vtoolline.cpp:551
virtual void Disable(bool disable, const QString &draftBlockName) Q_DECL_OVERRIDE
Definition: vtoolline.cpp:268
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE
hoverEnterEvent handle hover enter events.
Definition: vtoolline.cpp:332
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE
Definition: vtoolline.cpp:502
virtual void SaveOptions(QDomElement &tag, QSharedPointer< VGObject > &obj) Q_DECL_OVERRIDE
Definition: vtoolline.cpp:426
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE
SaveDialog save options into file after change in dialog.
Definition: vtoolline.cpp:413
virtual void RemoveReferens() Q_DECL_OVERRIDE
RemoveReferens decrement value of reference.
Definition: vtoolline.cpp:357
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE
Definition: vtoolline.cpp:438
void SetSecondPoint(const quint32 &value)
Definition: vtoolline.cpp:490
virtual void SetVisualization() Q_DECL_OVERRIDE
Definition: vtoolline.cpp:448
QString SecondPointName() const
Definition: vtoolline.cpp:240
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE
FullUpdateFromFile update tool data form file.
Definition: vtoolline.cpp:249
virtual void setDialog() Q_DECL_OVERRIDE
setDialog set dialog when user want change tool option.
Definition: vtoolline.cpp:112
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE
Definition: vtoolline.cpp:281
virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE
ShowTool highlight tool.
Definition: vtoolline.cpp:262
virtual void showContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE
contextMenuEvent handle context menu events.
Definition: vtoolline.cpp:291
virtual void AddToFile() Q_DECL_OVERRIDE
AddToFile add tag with informations about tool into file.
Definition: vtoolline.cpp:319
virtual void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE
keyReleaseEvent handle key realse events.
Definition: vtoolline.cpp:388
quint32 GetSecondPoint() const
Definition: vtoolline.cpp:484
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) Q_DECL_OVERRIDE
Definition: vtoolline.cpp:220
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override
contextMenuEvent handle context menu events.
Definition: vtoolline.cpp:310
virtual QString getTagName() const Q_DECL_OVERRIDE
Definition: vtoolline.cpp:214
void setLineWeight(const QString &value) Q_DECL_OVERRIDE
Definition: vtoolline.cpp:536
virtual int type() const Q_DECL_OVERRIDE
Definition: vtoolline.h:88
QString getLineColor() const
Definition: vtoolline.cpp:545
QString lineColor
lineColor color of a line.
Definition: vtoolline.h:148
QString FirstPointName() const
Definition: vtoolline.cpp:234
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) Q_DECL_OVERRIDE
itemChange handle item change.
Definition: vtoolline.cpp:373
virtual void setLineType(const QString &value) Q_DECL_OVERRIDE
Definition: vtoolline.cpp:527
virtual QString makeToolTip() const Q_DECL_OVERRIDE
Definition: vtoolline.cpp:464
Source
Definition: def.h:106
#define NULL_ID
Definition: ifcdef.h:76
Document