QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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"
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:
47
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
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
113
115 enum ClipboardOperation
116 {
117 ClipboardCut,
118 ClipboardCopy,
119 };
120
126 void copySelectedItems( ClipboardOperation operation );
127
133 void copyItems( const QList< QgsModelComponentGraphicItem * > &items, ClipboardOperation operation );
134
136 enum PasteMode
137 {
138 PasteModeCursor,
139 PasteModeCenter,
140 PasteModeInPlace,
141 };
142
149 void pasteItems( PasteMode mode );
150
151 public slots:
152
156 void snapSelected();
157
158 signals:
159
163 void algorithmDropped( const QString &algorithmId, const QPointF &pos );
164
168 void inputDropped( const QString &inputId, const QPointF &pos );
169
174 void toolSet( QgsModelViewTool *tool ) SIP_SKIP;
175
180 void itemFocused( QgsModelComponentGraphicItem *item );
181
186 void willBeDeleted();
187
191 void macroCommandStarted( const QString &text );
192
196 void macroCommandEnded();
197
201 void beginCommand( const QString &text );
202
206 void endCommand();
207
211 void deleteSelectedItems();
212
213 private:
214
216 void wheelZoom( QWheelEvent *event );
217
222 void scaleSafe( double scale );
223
228 QPointF deltaForKeyEvent( QKeyEvent *event );
229
230 QPointer< QgsModelViewTool > mTool;
231
232 QgsModelViewToolTemporaryKeyPan *mSpacePanTool = nullptr;
233 QgsModelViewToolTemporaryMousePan *mMidMouseButtonPanTool = nullptr;
234 QgsModelViewToolTemporaryKeyZoom *mSpaceZoomTool = nullptr;
235
236 QPoint mMouseCurrentXY;
237
238 QgsModelSnapper mSnapper;
239 QgsModelViewSnapMarker *mSnapMarker = nullptr;
240};
241
242
247class GUI_EXPORT QgsModelViewSnapMarker : public QGraphicsRectItem
248{
249 public:
250
251 QgsModelViewSnapMarker();
252
253 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
254
255 private:
256
257 int mSize = 0;
258
259};
260
261
263
264#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