QGIS API Documentation 3.41.0-Master (cea29feecf2)
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:
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
112
114 enum ClipboardOperation
115 {
116 ClipboardCut,
117 ClipboardCopy,
118 };
119
125 void copySelectedItems( ClipboardOperation operation );
126
132 void copyItems( const QList<QgsModelComponentGraphicItem *> &items, ClipboardOperation operation );
133
135 enum PasteMode
136 {
137 PasteModeCursor,
138 PasteModeCenter,
139 PasteModeInPlace,
140 };
141
148 void pasteItems( PasteMode mode );
149
150 public slots:
151
155 void snapSelected();
156
157 signals:
158
162 void algorithmDropped( const QString &algorithmId, const QPointF &pos );
163
167 void inputDropped( const QString &inputId, const QPointF &pos );
168
173 void toolSet( QgsModelViewTool *tool ) SIP_SKIP;
174
179 void itemFocused( QgsModelComponentGraphicItem *item );
180
185 void willBeDeleted();
186
190 void macroCommandStarted( const QString &text );
191
195 void macroCommandEnded();
196
200 void beginCommand( const QString &text );
201
205 void endCommand();
206
210 void deleteSelectedItems();
211
212 private:
214 void wheelZoom( QWheelEvent *event );
215
220 void scaleSafe( double scale );
221
226 QPointF deltaForKeyEvent( QKeyEvent *event );
227
228 QPointer<QgsModelViewTool> mTool;
229
230 QgsModelViewToolTemporaryKeyPan *mSpacePanTool = nullptr;
231 QgsModelViewToolTemporaryMousePan *mMidMouseButtonPanTool = nullptr;
232 QgsModelViewToolTemporaryKeyZoom *mSpaceZoomTool = nullptr;
233
234 QPoint mMouseCurrentXY;
235
236 QgsModelSnapper mSnapper;
237 QgsModelViewSnapMarker *mSnapMarker = nullptr;
238};
239
240
245class GUI_EXPORT QgsModelViewSnapMarker : public QGraphicsRectItem
246{
247 public:
248 QgsModelViewSnapMarker();
249
250 void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr ) override;
251
252 private:
253 int mSize = 0;
254};
255
256
258
259#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