QGIS API Documentation 3.43.0-Master (0cdc48caa8d)
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"
22#include "qgsmodelsnapper.h"
23#include <QGraphicsView>
24#include <QGraphicsRectItem>
25
30class QgsModelComponentGraphicItem;
31class QgsModelGraphicsScene;
32class QgsModelViewSnapMarker;
33
35
42class GUI_EXPORT QgsModelGraphicsView : public QGraphicsView
43{
44 Q_OBJECT
45
46 public:
50 QgsModelGraphicsView( QWidget *parent = nullptr );
51 ~QgsModelGraphicsView() override;
52
53 void dragEnterEvent( QDragEnterEvent *event ) override;
54 void dropEvent( QDropEvent *event ) override;
55 void dragMoveEvent( QDragMoveEvent *event ) override;
56 void wheelEvent( QWheelEvent *event ) override;
57 void mousePressEvent( QMouseEvent *event ) override;
58 void mouseReleaseEvent( QMouseEvent *event ) override;
59 void mouseMoveEvent( QMouseEvent *event ) override;
60 void mouseDoubleClickEvent( QMouseEvent *event ) override;
61 void keyPressEvent( QKeyEvent *event ) override;
62 void keyReleaseEvent( QKeyEvent *event ) override;
63
67 void setModelScene( QgsModelGraphicsScene *scene );
68
73 QgsModelGraphicsScene *modelScene() const;
74
80
86 void setTool( QgsModelViewTool *tool ) SIP_SKIP;
87
95 void unsetTool( QgsModelViewTool *tool ) SIP_SKIP;
96
100 QgsModelSnapper *snapper() SIP_SKIP;
101
105 void startMacroCommand( const QString &text );
106
110 void endMacroCommand();
111
115 void beginCommand( const QString &text );
116
120 void endCommand();
121
122
124 enum ClipboardOperation
125 {
126 ClipboardCut,
127 ClipboardCopy,
128 };
129
135 void copySelectedItems( ClipboardOperation operation );
136
142 void copyItems( const QList<QgsModelComponentGraphicItem *> &items, ClipboardOperation operation );
143
145 enum PasteMode
146 {
147 PasteModeCursor,
148 PasteModeCenter,
149 PasteModeInPlace,
150 };
151
158 void pasteItems( PasteMode mode );
159
160 public slots:
161
165 void snapSelected();
166
167 signals:
168
172 void algorithmDropped( const QString &algorithmId, const QPointF &pos );
173
177 void inputDropped( const QString &inputId, const QPointF &pos );
178
183 void toolSet( QgsModelViewTool *tool ) SIP_SKIP;
184
189 void itemFocused( QgsModelComponentGraphicItem *item );
190
195 void willBeDeleted();
196
200 void macroCommandStarted( const QString &text );
201
205 void macroCommandEnded();
206
210 void commandBegun( const QString &text );
211
215 void commandEnded();
216
220 void deleteSelectedItems();
221
222 private:
224 void wheelZoom( QWheelEvent *event );
225
230 void scaleSafe( double scale );
231
236 QPointF deltaForKeyEvent( QKeyEvent *event );
237
238 QPointer<QgsModelViewTool> mTool;
239
240 QgsModelViewToolTemporaryKeyPan *mSpacePanTool = nullptr;
241 QgsModelViewToolTemporaryMousePan *mMidMouseButtonPanTool = nullptr;
242 QgsModelViewToolTemporaryKeyZoom *mSpaceZoomTool = nullptr;
243
244 QPoint mMouseCurrentXY;
245
246 QgsModelSnapper mSnapper;
247 QgsModelViewSnapMarker *mSnapMarker = nullptr;
248};
249
250
255class GUI_EXPORT QgsModelViewSnapMarker : public QGraphicsRectItem
256{
257 public:
258 QgsModelViewSnapMarker();
259
260 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
261
262 private:
263 int mSize = 0;
264};
265
266
268
269#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:126