Seamly2D
Code documentation
vmaingraphicsscene.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 vmaingraphicsscene.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 VMAINGRAPHICSSCENE_H
53 #define VMAINGRAPHICSSCENE_H
54 
55 #include <qcompilerdetection.h>
56 #include <QGraphicsScene>
57 #include <QMetaObject>
58 #include <QObject>
59 #include <QPointF>
60 #include <QRectF>
61 #include <QString>
62 #include <QTransform>
63 #include <QVector>
64 #include <QtGlobal>
65 
66 #include "../vmisc/def.h"
67 
68 /**
69  * @brief The VMainGraphicsScene class main scene.
70  */
71 class VMainGraphicsScene : public QGraphicsScene
72 {
73  Q_OBJECT
74 public:
75  explicit VMainGraphicsScene(QObject *parent = nullptr);
76  explicit VMainGraphicsScene(const QRectF & sceneRect, QObject * parent = nullptr);
77  qint32 getHorScrollBar() const;
78  void setHorScrollBar(const qint32 &value);
79  qint32 getVerScrollBar() const;
80  void setVerScrollBar(const qint32 &value);
81  QTransform transform() const;
82  void setCurrentTransform(const QTransform &transform);
83  void swapTransforms();
84  void SetDisableTools(bool disable, const QString &draftBlockName);
85  QPointF getScenePos() const;
86 
87  QRectF visibleItemsBoundingRect() const;
88  void InitOrigins();
89  void setOriginsVisible(bool visible);
90 
91 public slots:
92  void chosenItem(quint32 id, const SceneObject &type);
93  void SelectedItem(bool selected, quint32 object, quint32 tool);
94  void EnableItemMove(bool move);
95  void enablePiecesMode(bool mode);
96  void ItemsSelection(const SelectionType &type);
97  void HighlightItem(quint32 id);
98 
99  void ToggleLabelSelection(bool enabled);
100  void TogglePointSelection(bool enabled);
101  void ToggleLineSelection(bool enabled);
102  void ToggleArcSelection(bool enabled);
103  void ToggleElArcSelection(bool enabled);
104  void ToggleSplineSelection(bool enabled);
105  void ToggleSplinePathSelection(bool enabled);
106  void ToggleNodeLabelSelection(bool enabled);
107  void ToggleNodePointSelection(bool enabled);
108  void togglePieceSelection(bool enabled);
109 
110  void ToggleLabelHover(bool enabled);
111  void TogglePointHover(bool enabled);
112  void ToggleLineHover(bool enabled);
113  void ToggleArcHover(bool enabled);
114  void ToggleElArcHover(bool enabled);
115  void ToggleSplineHover(bool enabled);
116  void ToggleSplinePathHover(bool enabled);
117  void ToggleNodeLabelHover(bool enabled);
118  void ToggleNodePointHover(bool enabled);
119  void togglePieceHover(bool enabled);
120 
121 protected:
122  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
123  virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
124  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
125 
126 signals:
127  /**
128  * @brief mouseMove send new mouse position.
129  * @param scenePos new mouse position.
130  */
131  void mouseMove(const QPointF &scenePos);
132 
135  void ItemClicked(QGraphicsItem* pItem);
136 
137  /**
138  * @brief ChosenObject send option choosed object.
139  * @param id object id.
140  * @param type object scene type.
141  */
142  void ChosenObject(quint32 id, SceneObject type);
143  void SelectedObject(bool selected, quint32 object, quint32 tool);
144  void DisableItem(bool disable, const QString &draftBlockName);
145  void EnableToolMove(bool move);
146  void pieceLockedChanged(quint32 id, bool lock);
147  void curvePiecesMode(bool mode);
148  void ItemSelection(const SelectionType &type);
149  void highlightPiece(quint32 id);
150 
151  void enableTextItemSelection(bool enable);
152  void EnablePointItemSelection(bool enable);
153  void EnableLineItemSelection(bool enable);
154  void EnableArcItemSelection(bool enable);
155  void EnableElArcItemSelection(bool enable);
156  void EnableSplineItemSelection(bool enable);
157  void EnableSplinePathItemSelection(bool enable);
158  void EnableNodeLabelItemSelection(bool enabled);
159  void EnableNodePointItemSelection(bool enabled);
160  void EnableDetailItemSelection(bool enabled);
161 
162  void enableTextItemHover(bool enable);
163  void EnablePointItemHover(bool enable);
164  void EnableArcItemHover(bool enable);
165  void EnableElArcItemHover(bool enable);
166  void EnableSplineItemHover(bool enable);
167  void EnableSplinePathItemHover(bool enable);
168  void EnableNodeLabelItemHover(bool enabled);
169  void EnableNodePointItemHover(bool enabled);
170  void EnableDetailItemHover(bool enabled);
171  void EnableLineItemHover(bool enabled);
174 
175 private:
176  /** @brief horScrollBar value horizontal scroll bar. */
177  qint32 horScrollBar;
178 
179  /** @brief verScrollBar value vertical scroll bar. */
180  qint32 verScrollBar;
181 
182  /** @brief _transform view transform value. */
184  QTransform m_currentTransform;
185  QPointF scenePos;
187 };
188 
189 //---------------------------------------------------------------------------------------------------------------------
190 /**
191  * @brief getHorScrollBar return scene horizontal scrollbar.
192  * @return horizontal scrollbar.
193  */
195 {
196  return horScrollBar;
197 }
198 
199 //---------------------------------------------------------------------------------------------------------------------
200 /**
201  * @brief setHorScrollBar set scene horizontal scrollbar.
202  * @param value horizontal scrollbar.
203  */
204 inline void VMainGraphicsScene::setHorScrollBar(const qint32 &value)
205 {
206  horScrollBar = value;
207 }
208 
209 //---------------------------------------------------------------------------------------------------------------------
210 /**
211  * @brief getVerScrollBar return scene vertical scrollbar.
212  * @return vertical scrollbar.
213  */
215 {
216  return verScrollBar;
217 }
218 
219 //---------------------------------------------------------------------------------------------------------------------
220 /**
221  * @brief setVerScrollBar set scene vertical scrollbar.
222  * @param value vertical scrollbar.
223  */
224 inline void VMainGraphicsScene::setVerScrollBar(const qint32 &value)
225 {
226  verScrollBar = value;
227 }
228 
229 #endif // VMAINGRAPHICSSCENE_H
The VMainGraphicsScene class main scene.
void EnableSplinePathItemHover(bool enable)
void chosenItem(quint32 id, const SceneObject &type)
chosenItem emit ChosenObject signal.
void SetDisableTools(bool disable, const QString &draftBlockName)
QTransform transform() const
transform return view transformation.
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
void EnableItemMove(bool move)
void EnableArcItemHover(bool enable)
void EnablePointItemSelection(bool enable)
void EnableElArcItemHover(bool enable)
QRectF visibleItemsBoundingRect() const
void EnableLineItemHover(bool enabled)
void setOriginsVisible(bool visible)
void ToggleArcHover(bool enabled)
void enableTextItemSelection(bool enable)
QPointF getScenePos() const
void EnableNodeLabelItemHover(bool enabled)
void curvePiecesMode(bool mode)
void ItemClicked(QGraphicsItem *pItem)
void EnableSplineItemSelection(bool enable)
void mouseMove(const QPointF &scenePos)
mouseMove send new mouse position.
void EnableDetailItemHover(bool enabled)
void ItemSelection(const SelectionType &type)
void ToggleSplinePathSelection(bool enabled)
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
mousePressEvent mouse press events.
void EnablePointItemHover(bool enable)
void TogglePointHover(bool enabled)
void EnableDetailItemSelection(bool enabled)
QVector< QGraphicsItem * > origins
void EnableArcItemSelection(bool enable)
void enableTextItemHover(bool enable)
void EnableToolMove(bool move)
void ToggleElArcHover(bool enabled)
void ToggleElArcSelection(bool enabled)
void togglePieceSelection(bool enabled)
void ToggleNodePointSelection(bool enabled)
void EnableNodeLabelItemSelection(bool enabled)
void ToggleNodeLabelHover(bool enabled)
void EnableElArcItemSelection(bool enable)
void DisableItem(bool disable, const QString &draftBlockName)
void ToggleNodePointHover(bool enabled)
void SelectedObject(bool selected, quint32 object, quint32 tool)
qint32 getHorScrollBar() const
getHorScrollBar return scene horizontal scrollbar.
void pieceLockedChanged(quint32 id, bool lock)
void ToggleSplinePathHover(bool enabled)
void ToggleNodeLabelSelection(bool enabled)
void setVerScrollBar(const qint32 &value)
setVerScrollBar set scene vertical scrollbar.
void ChosenObject(quint32 id, SceneObject type)
ChosenObject send option choosed object.
void highlightPiece(quint32 id)
void ToggleSplineHover(bool enabled)
void setHorScrollBar(const qint32 &value)
setHorScrollBar set scene horizontal scrollbar.
void ToggleLabelSelection(bool enabled)
void ToggleSplineSelection(bool enabled)
qint32 horScrollBar
horScrollBar value horizontal scroll bar.
void EnableNodePointItemSelection(bool enabled)
void SelectedItem(bool selected, quint32 object, quint32 tool)
void EnableLineItemSelection(bool enable)
void togglePieceHover(bool enabled)
void ToggleArcSelection(bool enabled)
void ToggleLabelHover(bool enabled)
void HighlightItem(quint32 id)
QTransform m_previousTransform
_transform view transform value.
void setCurrentTransform(const QTransform &transform)
setCurrentTransform set view transformation.
qint32 verScrollBar
verScrollBar value vertical scroll bar.
void swapTransforms()
swapTransforms.
void EnableSplineItemHover(bool enable)
void EnableSplinePathItemSelection(bool enable)
void enablePiecesMode(bool mode)
void ItemsSelection(const SelectionType &type)
void ToggleLineSelection(bool enabled)
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
mouseMoveEvent handle mouse move events.
VMainGraphicsScene(QObject *parent=nullptr)
VMainGraphicsScene default constructor.
void TogglePointSelection(bool enabled)
qint32 getVerScrollBar() const
getVerScrollBar return scene vertical scrollbar.
void ToggleLineHover(bool enabled)
void EnableNodePointItemHover(bool enabled)
SceneObject
Definition: def.h:103
SelectionType
Definition: def.h:108