QGIS API Documentation 4.1.0-Master (31622b25bb0)
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"
27#include "qobjectuniqueptr.h"
28
29class QgsMessageBar;
30class QgsProcessingModelAlgorithm;
31class QgsModelUndoCommand;
32class QUndoView;
35class QgsScreenHelper;
36class QgsProcessingAlgorithmWidgetBase;
40
42
43#ifndef SIP_RUN
44
45class GUI_EXPORT QgsModelerToolboxModel : public QgsProcessingToolboxProxyModel
46{
47 Q_OBJECT
48 public:
49 explicit QgsModelerToolboxModel( QObject *parent = nullptr );
50 Qt::ItemFlags flags( const QModelIndex &index ) const override;
51 Qt::DropActions supportedDragActions() const override;
52};
53
54#endif
55
62class GUI_EXPORT QgsModelDesignerDialog : public QMainWindow, public QgsProcessingFeedbackGenerator, public Ui::QgsModelDesignerDialogBase
63{
64 Q_OBJECT
65 public:
66 QgsModelDesignerDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
67 ~QgsModelDesignerDialog() override;
68
69 void closeEvent( QCloseEvent *event ) override;
70
74 void beginUndoCommand( const QString &text, const QString &id = QString(), QgsModelUndoCommand::CommandOperation operation SIP_PYARGREMOVE = QgsModelUndoCommand::CommandOperation::Unknown );
75
79 void endUndoCommand();
80
85 void abortUndoCommand();
86
90 QgsProcessingModelAlgorithm *model();
91
97 void setModel( QgsProcessingModelAlgorithm *model SIP_TRANSFER );
98
102 void loadModel( const QString &path );
103
109 void setModelScene( QgsModelGraphicsScene *scene SIP_TRANSFER );
110
117 QgsModelGraphicsScene *modelScene();
118
119 QgsProcessingFeedback *createFeedback() override SIP_FACTORY;
120
126 enum class SaveAction
127 {
128 SaveAsFile,
129 SaveInProject,
130 };
131
132 public slots:
133
139 void activate();
140
141 protected:
142 // cppcheck-suppress pureVirtualCall
143 virtual void repaintModel( bool showControls = true ) = 0;
144 virtual void addAlgorithm( const QString &algorithmId, const QPointF &pos ) = 0;
145 // cppcheck-suppress pureVirtualCall
146 virtual void addInput( const QString &inputId, const QPointF &pos ) = 0;
147 // cppcheck-suppress pureVirtualCall
148 virtual void exportAsScriptAlgorithm() = 0;
149 // cppcheck-suppress pureVirtualCall
150 virtual bool saveModel( bool saveAs = false ) = 0;
151 // cppcheck-suppress pureVirtualCall
152 virtual QgsProcessingAlgorithmWidgetBase *createExecutionWidget() = 0 SIP_TRANSFERBACK;
153
157 virtual QgsProcessingParameterWidgetContext createWidgetContext() = 0; // cppcheck-suppress pureVirtualCall
158
163 void registerProcessingContextGenerator( QgsProcessingContextGenerator *generator );
164
165 QToolBar *toolbar() { return mToolbar; }
166 QAction *actionOpen() { return mActionOpen; }
167 QAction *actionSaveInProject() { return mActionSaveInProject; }
168 QAction *actionRun() { return mActionRun; }
169 QgsMessageBar *messageBar() { return mMessageBar; }
170 QgsModelGraphicsView *view() { return mView; }
171
172 void setDirty( bool dirty );
173
177 bool validateSave( SaveAction action );
178
184 bool checkForUnsavedChanges();
185
189 void setLastRunResult( const QgsProcessingModelResult &result );
190
198 void setModelName( const QString &name );
199
200 private slots:
201 void zoomIn();
202 void zoomOut();
203 void zoomActual();
204 void zoomFull();
205 void newModel();
206 void exportToImage();
207 void exportToPdf();
208 void exportToSvg();
209 void exportAsPython();
210 void toggleComments( bool show );
211 void toggleFeatureCount( bool show );
212 void updateWindowTitle();
213 void deleteSelected();
214 void populateZoomToMenu();
215 void validate();
216 void reorderInputs();
217 void reorderOutputs();
218 void setPanelVisibility( bool hidden );
219 void editHelp();
220 void runSelectedSteps();
221 void runFromChild( const QString &id );
222 void run( const QSet<QString> &childAlgorithmSubset = QSet<QString>() );
223 void showChildAlgorithmOutputs( const QString &childId );
224 void showChildAlgorithmLog( const QString &childId );
225 void onItemFocused( QgsModelComponentGraphicItem *item );
226
227 void cancelRunningModel();
228
229 private:
230 std::unique_ptr<QgsProcessingModelAlgorithm> mModel;
231
232 QgsScreenHelper *mScreenHelper = nullptr;
233
234 QgsMessageBar *mMessageBar = nullptr;
235 QgsModelerToolboxModel *mAlgorithmsModel = nullptr;
236
237 QPointer<QgsProcessingAlgorithmWidgetBase> mAlgorithmWidget;
238
239 QVector<QPointer<QgsProcessingAlgorithmWidgetBase>> mAlgorithmWidgetsToCleanUp;
240
241 QActionGroup *mToolsActionGroup = nullptr;
242
243 QgsModelViewToolPan *mPanTool = nullptr;
244 QObjectUniquePtr<QgsModelViewToolSelect> mSelectTool;
245 QgsModelGraphicsScene *mScene = nullptr;
246
247 bool mHasChanged = false;
248 QUndoStack *mUndoStack = nullptr;
249 std::unique_ptr<QgsModelUndoCommand> mActiveCommand;
250
251 QAction *mUndoAction = nullptr;
252 QAction *mRedoAction = nullptr;
253 QUndoView *mUndoView = nullptr;
254 QgsDockWidget *mUndoDock = nullptr;
255
256 QMenu *mGroupMenu = nullptr;
257
258 QAction *mActionCut = nullptr;
259 QAction *mActionCopy = nullptr;
260 QAction *mActionPaste = nullptr;
261 int mBlockUndoCommands = 0;
262 int mIgnoreUndoStackChanges = 0;
263
264 QgsDockWidget *mConfigWidgetDock = nullptr;
265 QgsModelDesignerConfigDockWidget *mConfigWidget = nullptr;
266
267 QgsProcessingContextGenerator *mProcessingContextGenerator = nullptr;
268
269 QString mTitle;
270
271 int mBlockRepaints = 0;
272
273 QgsProcessingModelResult mLastResult;
274 QSet< QString > mOutdatedChildResults;
275
276 bool isDirty() const;
277
278 void fillInputsTree();
279 void updateVariablesGui();
280
281 struct PanelStatus
282 {
283 PanelStatus( bool visible = true, bool active = false )
284 : isVisible( visible )
285 , isActive( active )
286 {}
287 bool isVisible;
288 bool isActive;
289 };
290 QMap<QString, PanelStatus> mPanelStatus;
291
292 QgsProcessingContext mLayerStore;
293};
294
295
296class GUI_EXPORT QgsModelChildDependenciesWidget : public QWidget
297{
298 Q_OBJECT
299
300 public:
301 QgsModelChildDependenciesWidget( QWidget *parent, QgsProcessingModelAlgorithm *model, const QString &childId );
302 QList<QgsProcessingModelChildDependency> value() const { return mValue; }
303 void setValue( const QList<QgsProcessingModelChildDependency> &value );
304 private slots:
305
306 void showDialog();
307
308 private:
309 void updateSummaryText();
310
311 QLineEdit *mLineEdit = nullptr;
312 QToolButton *mToolButton = nullptr;
313
314 QgsProcessingModelAlgorithm *mModel = nullptr;
315 QString mChildId;
316
317 QList<QgsProcessingModelChildDependency> mValue;
318
319 friend class TestProcessingGui;
320};
322
323#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
#define SIP_FACTORY
Definition qgis_sip.h:83