Seamly2D
Code documentation
vtooldoublepoint.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 vtooldoublepoint.h
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 20 6, 2015
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) 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 VTOOLDOUBLEPOINT_H
53 #define VTOOLDOUBLEPOINT_H
54 
55 #include <qcompilerdetection.h>
56 #include <QGraphicsItem>
57 #include <QGraphicsPathItem>
58 #include <QMetaObject>
59 #include <QObject>
60 #include <QPointF>
61 #include <QString>
62 #include <QVariant>
63 #include <QtGlobal>
64 
65 #include "../vabstractpoint.h"
66 #include "../vmisc/def.h"
67 
68 class VSimplePoint;
69 template <class T> class QSharedPointer;
70 
71 class VToolDoublePoint: public VAbstractPoint, public QGraphicsPathItem
72 {
73  Q_OBJECT
74 public:
76  quint32 p1id, quint32 p2id, QGraphicsItem * parent = nullptr);
77  virtual ~VToolDoublePoint() Q_DECL_EQ_DEFAULT;
78 
79  virtual int type() const Q_DECL_OVERRIDE {return Type;}
80  enum { Type = UserType + static_cast<int>(Tool::DoublePoint)};
81 
82  QString nameP1() const;
83  void setNameP1(const QString &name);
84 
85  QString nameP2() const;
86  void setNameP2(const QString &name);
87 
88  virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
89  virtual void setPointNamePosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE;
90  virtual bool isPointNameVisible(quint32 id) const Q_DECL_OVERRIDE;
91  virtual void setPointNameVisiblity(quint32 id, bool visible) Q_DECL_OVERRIDE;
92 
93 public slots:
94  void changePointName1Position(const QPointF &pos);
95  void changePointName2Position(const QPointF &pos);
96  virtual void Disable(bool disable, const QString &draftBlockName) Q_DECL_OVERRIDE;
97  virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE;
98  void point1Chosen();
99  void point2Chosen();
100  void point1Selected(bool selected);
101  void point2Selected(bool selected);
102  virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
103  virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
104  virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
105  void allowTextHover(bool enabled);
106  void allowTextSelectable(bool enabled);
107  virtual void ToolSelectionType(const SelectionType &type) Q_DECL_OVERRIDE;
108 
109 protected:
112 
113  quint32 p1id;
114  quint32 p2id;
115 
116  virtual void updatePointNamePosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE;
117  virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
118  virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
119  virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *event) Q_DECL_OVERRIDE;
120  virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
121  virtual void AddToFile() Q_DECL_OVERRIDE;
122  virtual void updatePointNameVisibility(quint32 id, bool visible) Q_DECL_OVERRIDE;
123  QString complexToolTip(quint32 itemId) const;
124 
125 private:
126  Q_DISABLE_COPY(VToolDoublePoint)
127 };
128 
129 #endif // VTOOLDOUBLEPOINT_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 VGObject class keep information graphical objects.
Definition: vgobject.h:74
virtual void updatePointNamePosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE
VSimplePoint * secondPoint
VToolDoublePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 p1id, quint32 p2id, QGraphicsItem *parent=nullptr)
QString nameP1() const
void setNameP2(const QString &name)
virtual void Disable(bool disable, const QString &draftBlockName) Q_DECL_OVERRIDE
void setNameP1(const QString &name)
virtual bool isPointNameVisible(quint32 id) const Q_DECL_OVERRIDE
virtual void SaveOptions(QDomElement &tag, QSharedPointer< VGObject > &obj) Q_DECL_OVERRIDE
virtual void ToolSelectionType(const SelectionType &type) Q_DECL_OVERRIDE
virtual void AddToFile() Q_DECL_OVERRIDE
AddToFile add tag with Information about tool into file.
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE
VSimplePoint * firstPoint
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) Q_DECL_OVERRIDE
virtual int type() const Q_DECL_OVERRIDE
QString nameP2() const
void changePointName1Position(const QPointF &pos)
void allowTextSelectable(bool enabled)
void point1Selected(bool selected)
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE
virtual void setPointNameVisiblity(quint32 id, bool visible) Q_DECL_OVERRIDE
virtual void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE
keyReleaseEvent handle key release events.
virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE
void point2Selected(bool selected)
virtual void updatePointNameVisibility(quint32 id, bool visible) Q_DECL_OVERRIDE
void changePointName2Position(const QPointF &pos)
void allowTextHover(bool enabled)
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) Q_DECL_OVERRIDE
itemChange hadle item change.
QString complexToolTip(quint32 itemId) const
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE
virtual void setPointNamePosition(quint32 id, const QPointF &pos) Q_DECL_OVERRIDE
virtual ~VToolDoublePoint() Q_DECL_EQ_DEFAULT
@ DoublePoint
SelectionType
Definition: def.h:108