QGIS API Documentation 4.1.0-Master (376402f9aeb)
Loading...
Searching...
No Matches
qgsmodeldesignerdialog.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmodeldesignerdialog.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 QGSMODELDESIGNERDIALOG_H
17#define QGSMODELDESIGNERDIALOG_H
18
19#include "ui_qgsmodeldesignerdialogbase.h"
20
21#include "qgis.h"
22#include "qgis_gui.h"
23#include "qgsmodelundocommand.h"
26#include "qobjectuniqueptr.h"
27
28class QgsMessageBar;
29class QgsProcessingModelAlgorithm;
30class QgsModelUndoCommand;
31class QUndoView;
34class QgsScreenHelper;
35class QgsProcessingAlgorithmDialogBase;
39
41
42#ifndef SIP_RUN
43
44class GUI_EXPORT QgsModelerToolboxModel : public QgsProcessingToolboxProxyModel
45{
46 Q_OBJECT
47 public:
48 explicit QgsModelerToolboxModel( QObject *parent = nullptr );
49 Qt::ItemFlags flags( const QModelIndex &index ) const override;
50 Qt::DropActions supportedDragActions() const override;
51};
52
53#endif
54
61class GUI_EXPORT QgsModelDesignerDialog : public QMainWindow, public Ui::QgsModelDesignerDialogBase
62{
63 Q_OBJECT
64 public:
65 QgsModelDesignerDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
66 ~QgsModelDesignerDialog() override;
67
68 void closeEvent( QCloseEvent *event ) override;
69
73 void beginUndoCommand( const QString &text, const QString &id = QString(), QgsModelUndoCommand::CommandOperation operation SIP_PYARGREMOVE = QgsModelUndoCommand::CommandOperation::Unknown );
74
78 void endUndoCommand();
79
84 void abortUndoCommand();
85
89 QgsProcessingModelAlgorithm *model();
90
96 void setModel( QgsProcessingModelAlgorithm *model SIP_TRANSFER );
97
101 void loadModel( const QString &path );
102
108 void setModelScene( QgsModelGraphicsScene *scene SIP_TRANSFER );
109
116 QgsModelGraphicsScene *modelScene();
117
123 enum class SaveAction
124 {
125 SaveAsFile,
126 SaveInProject,
127 };
128
129 public slots:
130
136 void activate();
137
138 protected:
139 // cppcheck-suppress pureVirtualCall
140 virtual void repaintModel( bool showControls = true ) = 0;
141 virtual void addAlgorithm( const QString &algorithmId, const QPointF &pos ) = 0;
142 // cppcheck-suppress pureVirtualCall
143 virtual void addInput( const QString &inputId, const QPointF &pos ) = 0;
144 // cppcheck-suppress pureVirtualCall
145 virtual void exportAsScriptAlgorithm() = 0;
146 // cppcheck-suppress pureVirtualCall
147 virtual bool saveModel( bool saveAs = false ) = 0;
148 // cppcheck-suppress pureVirtualCall
149 virtual QgsProcessingAlgorithmDialogBase *createExecutionDialog() = 0 SIP_TRANSFERBACK;
150
154 virtual QgsProcessingParameterWidgetContext createWidgetContext() = 0; // cppcheck-suppress pureVirtualCall
155
160 void registerProcessingContextGenerator( QgsProcessingContextGenerator *generator );
161
162 QToolBar *toolbar() { return mToolbar; }
163 QAction *actionOpen() { return mActionOpen; }
164 QAction *actionSaveInProject() { return mActionSaveInProject; }
165 QAction *actionRun() { return mActionRun; }
166 QgsMessageBar *messageBar() { return mMessageBar; }
167 QgsModelGraphicsView *view() { return mView; }
168
169 void setDirty( bool dirty );
170
174 bool validateSave( SaveAction action );
175
181 bool checkForUnsavedChanges();
182
186 void setLastRunResult( const QgsProcessingModelResult &result );
187
195 void setModelName( const QString &name );
196
197 private slots:
198 void zoomIn();
199 void zoomOut();
200 void zoomActual();
201 void zoomFull();
202 void newModel();
203 void exportToImage();
204 void exportToPdf();
205 void exportToSvg();
206 void exportAsPython();
207 void toggleComments( bool show );
208 void toggleFeatureCount( bool show );
209 void updateWindowTitle();
210 void deleteSelected();
211 void populateZoomToMenu();
212 void validate();
213 void reorderInputs();
214 void reorderOutputs();
215 void setPanelVisibility( bool hidden );
216 void editHelp();
217 void runSelectedSteps();
218 void runFromChild( const QString &id );
219 void run( const QSet<QString> &childAlgorithmSubset = QSet<QString>() );
220 void showChildAlgorithmOutputs( const QString &childId );
221 void showChildAlgorithmLog( const QString &childId );
222 void onItemFocused( QgsModelComponentGraphicItem *item );
223
224 private:
225 std::unique_ptr<QgsProcessingModelAlgorithm> mModel;
226
227 QgsScreenHelper *mScreenHelper = nullptr;
228
229 QgsMessageBar *mMessageBar = nullptr;
230 QgsModelerToolboxModel *mAlgorithmsModel = nullptr;
231
232 QActionGroup *mToolsActionGroup = nullptr;
233
234 QgsModelViewToolPan *mPanTool = nullptr;
235 QObjectUniquePtr<QgsModelViewToolSelect> mSelectTool;
236 QgsModelGraphicsScene *mScene = nullptr;
237
238 bool mHasChanged = false;
239 QUndoStack *mUndoStack = nullptr;
240 std::unique_ptr<QgsModelUndoCommand> mActiveCommand;
241
242 QAction *mUndoAction = nullptr;
243 QAction *mRedoAction = nullptr;
244 QUndoView *mUndoView = nullptr;
245 QgsDockWidget *mUndoDock = nullptr;
246
247 QMenu *mGroupMenu = nullptr;
248
249 QAction *mActionCut = nullptr;
250 QAction *mActionCopy = nullptr;
251 QAction *mActionPaste = nullptr;
252 int mBlockUndoCommands = 0;
253 int mIgnoreUndoStackChanges = 0;
254
255 QgsDockWidget *mConfigWidgetDock = nullptr;
256 QgsModelDesignerConfigDockWidget *mConfigWidget = nullptr;
257
258 QgsProcessingContextGenerator *mProcessingContextGenerator = nullptr;
259
260 QString mTitle;
261
262 int mBlockRepaints = 0;
263
264 QgsProcessingModelResult mLastResult;
265
266 bool isDirty() const;
267
268 void fillInputsTree();
269 void updateVariablesGui();
270
271 struct PanelStatus
272 {
273 PanelStatus( bool visible = true, bool active = false )
274 : isVisible( visible )
275 , isActive( active )
276 {}
277 bool isVisible;
278 bool isActive;
279 };
280 QMap<QString, PanelStatus> mPanelStatus;
281
282 QgsProcessingContext mLayerStore;
283};
284
285
286class GUI_EXPORT QgsModelChildDependenciesWidget : public QWidget
287{
288 Q_OBJECT
289
290 public:
291 QgsModelChildDependenciesWidget( QWidget *parent, QgsProcessingModelAlgorithm *model, const QString &childId );
292 QList<QgsProcessingModelChildDependency> value() const { return mValue; }
293 void setValue( const QList<QgsProcessingModelChildDependency> &value );
294 private slots:
295
296 void showDialog();
297
298 private:
299 void updateSummaryText();
300
301 QLineEdit *mLineEdit = nullptr;
302 QToolButton *mToolButton = nullptr;
303
304 QgsProcessingModelAlgorithm *mModel = nullptr;
305 QString mChildId;
306
307 QList<QgsProcessingModelChildDependency> mValue;
308
309 friend class TestProcessingGui;
310};
312
313#endif // QGSMODELDESIGNERDIALOG_H
A bar for displaying non-blocking messages to the user.
A dockable panel widget stack which allows users to specify the properties of a Processing model comp...
Model designer view tool for panning a model.
Model designer view tool for selecting items in the model.
An interface for objects which can create Processing contexts.
Contains settings which reflect the context in which a Processing parameter widget is shown.
A proxy model for providers and algorithms shown within the Processing toolbox.
A utility class for dynamic handling of changes to screen properties.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_PYARGREMOVE
Definition qgis_sip.h:158
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_TRANSFERBACK
Definition qgis_sip.h:47