QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
31class QgsModelComponentGraphicItem;
32class QgsModelGraphicsScene;
33class QgsModelViewSnapMarker;
34
36
43class GUI_EXPORT QgsModelGraphicsView : public QGraphicsView
44{
45 Q_OBJECT
46
47 public:
51 QgsModelGraphicsView( QWidget *parent = nullptr );
52 ~QgsModelGraphicsView() override;
53
54 void dragEnterEvent( QDragEnterEvent *event ) override;
55 void dropEvent( QDropEvent *event ) override;
56 void dragMoveEvent( QDragMoveEvent *event ) override;
57 void wheelEvent( QWheelEvent *event ) override;
58 void mousePressEvent( QMouseEvent *event ) override;
59 void mouseReleaseEvent( QMouseEvent *event ) override;
60 void mouseMoveEvent( QMouseEvent *event ) override;
61 void mouseDoubleClickEvent( QMouseEvent *event ) override;
62 void keyPressEvent( QKeyEvent *event ) override;
63 void keyReleaseEvent( QKeyEvent *event ) override;
64
68 void setModelScene( QgsModelGraphicsScene *scene );
69
74 QgsModelGraphicsScene *modelScene() const;
75
80 QgsModelViewTool *tool() SIP_SKIP;
81
87 void setTool( QgsModelViewTool *tool ) SIP_SKIP;
88
96 void unsetTool( QgsModelViewTool *tool ) SIP_SKIP;
97
101 QgsModelSnapper *snapper() SIP_SKIP;
102
106 void startMacroCommand( const QString &text );
107
111 void endMacroCommand();
112
116 void beginCommand( const QString &text );
117
121 void endCommand();
122
127 void abortCommand();
128
129
131 enum ClipboardOperation
132 {
133 ClipboardCut,
134 ClipboardCopy,
135 };
136
142 void copySelectedItems( ClipboardOperation operation );
143
149 void copyItems( const QList<QgsModelComponentGraphicItem *> &items, ClipboardOperation operation );
150
152 enum PasteMode
153 {
154 PasteModeCursor,
155 PasteModeCenter,
156 PasteModeInPlace,
157 };
158
165 void pasteItems( PasteMode mode );
166
167 public slots:
168
172 void snapSelected();
173 signals:
174
178 void algorithmDropped( const QString &algorithmId, const QPointF &pos );
179
183 void inputDropped( const QString &inputId, const QPointF &pos );
184
189 void toolSet( QgsModelViewTool *tool ) SIP_SKIP;
190
195 void itemFocused( QgsModelComponentGraphicItem *item );
196
201 void willBeDeleted();
202
206 void macroCommandStarted( const QString &text );
207
211 void macroCommandEnded();
212
216 void commandBegun( const QString &text );
217
221 void commandEnded();
222
227 void commandAborted();
228
232 void deleteSelectedItems();
233
234 private:
236 void wheelZoom( QWheelEvent *event );
237
242 void scaleSafe( double scale );
243
248 QPointF deltaForKeyEvent( QKeyEvent *event );
249
261 void friendlySetSceneRect();
262
263 QPointer<QgsModelViewTool> mTool;
264
265 QgsModelViewToolTemporaryKeyPan *mSpacePanTool = nullptr;
266 QgsModelViewToolTemporaryMousePan *mMidMouseButtonPanTool = nullptr;
267 QgsModelViewToolTemporaryKeyZoom *mSpaceZoomTool = nullptr;
268
269 QPoint mMouseCurrentXY;
270
271 int mBlockScrollbarSignals = 0;
272
273 QgsModelSnapper mSnapper;
274 QgsModelViewSnapMarker *mSnapMarker = nullptr;
275};
276
277
282class GUI_EXPORT QgsModelViewSnapMarker : public QGraphicsRectItem
283{
284 public:
285 QgsModelViewSnapMarker();
286
287 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
288
289 private:
290 int mSize = 0;
291};
292
293
295
296#endif // QGSMODELGRAPHICVIEW_H
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:134