QGIS API Documentation 4.3.0-Master (0ff9723465c)
Loading...
Searching...
No Matches
qgsmodelgraphicsview.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodelgraphicsview.h
3 -----------------------
4 Date : March 2020
5 Copyright : (C) 2020 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program 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 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSMODELGRAPHICVIEW_H
17#define QGSMODELGRAPHICVIEW_H
18
19#include "qgis.h"
20#include "qgis_gui.h"
21#include "qgsmodelsnapper.h"
23
24#include <QGraphicsRectItem>
25#include <QGraphicsView>
26
27#define SIP_NO_FILE
28
33class QgsModelComponentGraphicItem;
34class QgsModelGraphicsScene;
35class QgsModelViewSnapMarker;
36
38
39
46class GUI_EXPORT QgsModelGraphicsView : public QGraphicsView
47{
48 Q_OBJECT
49
50 public:
54 QgsModelGraphicsView( QWidget *parent = nullptr );
55 ~QgsModelGraphicsView() override;
56
57 void dragEnterEvent( QDragEnterEvent *event ) override;
58 void dropEvent( QDropEvent *event ) override;
59 void dragMoveEvent( QDragMoveEvent *event ) override;
60 void wheelEvent( QWheelEvent *event ) override;
61 void mousePressEvent( QMouseEvent *event ) override;
62 void mouseReleaseEvent( QMouseEvent *event ) override;
63 void mouseMoveEvent( QMouseEvent *event ) override;
64 void mouseDoubleClickEvent( QMouseEvent *event ) override;
65 void keyPressEvent( QKeyEvent *event ) override;
66 void keyReleaseEvent( QKeyEvent *event ) override;
67
71 void setModelScene( QgsModelGraphicsScene *scene );
72
77 QgsModelGraphicsScene *modelScene() const;
78
84
90 void setTool( QgsModelViewTool *tool ) SIP_SKIP;
91
99 void unsetTool( QgsModelViewTool *tool ) SIP_SKIP;
100
104 QgsModelSnapper *snapper() SIP_SKIP;
105
109 void startMacroCommand( const QString &text );
110
114 void endMacroCommand();
115
119 void beginCommand( const QString &text );
120
124 void endCommand();
125
130 void abortCommand();
131
132
134 enum ClipboardOperation
135 {
136 ClipboardCut,
137 ClipboardCopy,
138 };
139
145 void copySelectedItems( ClipboardOperation operation );
146
152 void copyItems( const QList<QgsModelComponentGraphicItem *> &items, ClipboardOperation operation );
153
155 enum PasteMode
156 {
157 PasteModeCursor,
158 PasteModeCenter,
159 PasteModeInPlace,
160 };
161
168 void pasteItems( PasteMode mode );
169
170 public slots:
171
175 void snapSelected();
176 signals:
177
181 void algorithmDropped( const QString &algorithmId, const QPointF &pos );
182
186 void inputDropped( const QString &inputId, const QPointF &pos );
187
192 void toolSet( QgsModelViewTool *tool );
193
198 void itemFocused( QgsModelComponentGraphicItem *item );
199
204 void willBeDeleted();
205
209 void macroCommandStarted( const QString &text );
210
214 void macroCommandEnded();
215
219 void commandBegun( const QString &text );
220
224 void commandEnded();
225
230 void commandAborted();
231
235 void deleteSelectedItems();
236
237 private:
239 void wheelZoom( QWheelEvent *event );
240
245 void scaleSafe( double scale );
246
251 QPointF deltaForKeyEvent( QKeyEvent *event );
252
264 void friendlySetSceneRect();
265
266 QPointer<QgsModelViewTool> mTool;
267
268 QgsModelViewToolTemporaryKeyPan *mSpacePanTool = nullptr;
269 QgsModelViewToolTemporaryMousePan *mMidMouseButtonPanTool = nullptr;
270 QgsModelViewToolTemporaryKeyZoom *mSpaceZoomTool = nullptr;
271
272 QPoint mMouseCurrentXY;
273
274 int mBlockScrollbarSignals = 0;
275
276 QgsModelSnapper mSnapper;
277 QgsModelViewSnapMarker *mSnapMarker = nullptr;
278};
279
280
285class GUI_EXPORT QgsModelViewSnapMarker : public QGraphicsRectItem
286{
287 public:
288 QgsModelViewSnapMarker();
289
290 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
291
292 private:
293 int mSize = 0;
294};
295
296
298
299#endif // QGSMODELGRAPHICVIEW_H
Manages snapping grids and preset snap lines in a layout, and handles snapping points to the nearest ...
Model designer view tool for temporarily panning a layout while a key is depressed.
Model view tool for temporarily zooming a model while a key is depressed.
Model view tool for temporarily panning a model while a mouse button is depressed.
Abstract base class for all model designer view tools.
#define SIP_SKIP
Definition qgis_sip.h:138