QGIS API Documentation 4.3.0-Master (0de80482b60)
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,
63 public QgsProcessingFeedbackGenerator,
66 public Ui::QgsModelDesignerDialogBase
67{
68 Q_OBJECT
69 public:
70 QgsModelDesignerDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
71 ~QgsModelDesignerDialog() override;
72
73 void closeEvent( QCloseEvent *event ) override;
74
78 void beginUndoCommand( const QString &text, const QString &id = QString(), QgsModelUndoCommand::CommandOperation operation SIP_PYARGREMOVE = QgsModelUndoCommand::CommandOperation::Unknown );
79
83 void endUndoCommand();
84
89 void abortUndoCommand();
90
94 QgsProcessingModelAlgorithm *model();
95
101 void setModel( QgsProcessingModelAlgorithm *model SIP_TRANSFER );
102
106 void loadModel( const QString &path );
107
113 void setModelScene( QgsModelGraphicsScene *scene SIP_TRANSFER );
114
121 QgsModelGraphicsScene *modelScene();
122
123 QgsProcessingFeedback *createFeedback() override SIP_FACTORY;
124 QgsProcessingParameterWidgetContext createWidgetContext() override;
125
131 enum class SaveAction
132 {
133 SaveAsFile,
134 SaveInProject,
135 };
136
137 public slots:
138
144 void activate();
145
146 protected:
147 // cppcheck-suppress pureVirtualCall
148 virtual void repaintModel( bool showControls = true ) = 0;
149 virtual void addAlgorithm( const QString &algorithmId, const QPointF &pos ) = 0;
150 // cppcheck-suppress pureVirtualCall
151 virtual void addInput( const QString &inputId, const QPointF &pos ) = 0;
152 // cppcheck-suppress pureVirtualCall
153 virtual void exportAsScriptAlgorithm() = 0;
154 // cppcheck-suppress pureVirtualCall
155 virtual bool saveModel( bool saveAs = false ) = 0;
156 // cppcheck-suppress pureVirtualCall
157 virtual QgsProcessingAlgorithmWidgetBase *createExecutionWidget() = 0 SIP_TRANSFERBACK;
158
163 void registerProcessingContextGenerator( QgsProcessingContextGenerator *generator );
164 QgsProcessingContext *processingContext() const override;
165
166 QToolBar *toolbar() { return mToolbar; }
167 QAction *actionOpen() { return mActionOpen; }
168 QAction *actionSaveInProject() { return mActionSaveInProject; }
169 QAction *actionRun() { return mActionRun; }
170 QgsMessageBar *messageBar() { return mMessageBar; }
171
172#ifndef SIP_RUN
173 QgsModelGraphicsView *view() { return mView; }
174#endif
175
176 void setDirty( bool dirty );
177
181 bool validateSave( SaveAction action );
182
188 bool checkForUnsavedChanges();
189
193 void setLastRunResult( const QgsProcessingModelResult &result );
194
202 void setModelName( const QString &name );
203
204 private slots:
205 void zoomIn();
206 void zoomOut();
207 void zoomActual();
208 void zoomFull();
209 void newModel();
210 void exportToImage();
211 void exportToPdf();
212 void exportToSvg();
213 void exportAsPython();
214 void toggleComments( bool show );
215 void toggleFeatureCount( bool show );
216 void updateWindowTitle();
217 void deleteSelected();
218 void populateZoomToMenu();
219 void validate();
220 void reorderInputs();
221 void reorderOutputs();
222 void setPanelVisibility( bool hidden );
223 void editHelp();
224 void runSelectedSteps();
225 void runFromChild( const QString &id );
226 void run( const QSet<QString> &childAlgorithmSubset = QSet<QString>() );
227 void showChildAlgorithmOutputs( const QString &childId );
228 void showChildAlgorithmLog( const QString &childId );
229 void onItemFocused( QgsModelComponentGraphicItem *item );
230
231 void cancelRunningModel();
232
233 private:
234 std::unique_ptr<QgsProcessingModelAlgorithm> mModel;
235
236 QgsScreenHelper *mScreenHelper = nullptr;
237
238 QgsMessageBar *mMessageBar = nullptr;
239 QgsModelerToolboxModel *mAlgorithmsModel = nullptr;
240
241 QPointer<QgsProcessingAlgorithmWidgetBase> mAlgorithmWidget;
242
243 QVector<QPointer<QgsProcessingAlgorithmWidgetBase>> mAlgorithmWidgetsToCleanUp;
244
245 QActionGroup *mToolsActionGroup = nullptr;
246
247 QgsModelViewToolPan *mPanTool = nullptr;
248 QObjectUniquePtr<QgsModelViewToolSelect> mSelectTool;
249 QgsModelGraphicsScene *mScene = nullptr;
250
251 bool mHasChanged = false;
252 QUndoStack *mUndoStack = nullptr;
253 std::unique_ptr<QgsModelUndoCommand> mActiveCommand;
254
255 QAction *mUndoAction = nullptr;
256 QAction *mRedoAction = nullptr;
257 QUndoView *mUndoView = nullptr;
258 QgsDockWidget *mUndoDock = nullptr;
259
260 QMenu *mGroupMenu = nullptr;
261
262 QAction *mActionCut = nullptr;
263 QAction *mActionCopy = nullptr;
264 QAction *mActionPaste = nullptr;
265 int mBlockUndoCommands = 0;
266 int mIgnoreUndoStackChanges = 0;
267
268 QgsDockWidget *mConfigWidgetDock = nullptr;
269 QgsModelDesignerConfigDockWidget *mConfigWidget = nullptr;
270
271 QgsProcessingContextGenerator *mProcessingContextGenerator = nullptr;
272
273 QString mTitle;
274
275 int mBlockRepaints = 0;
276
277 QgsProcessingModelResult mLastResult;
278 QSet< QString > mOutdatedChildResults;
279
280 bool isDirty() const;
281
282 void fillInputsTree();
283 void updateVariablesGui();
284
285 struct PanelStatus
286 {
287 PanelStatus( bool visible = true, bool active = false )
288 : isVisible( visible )
289 , isActive( active )
290 {}
291 bool isVisible;
292 bool isActive;
293 };
294 QMap<QString, PanelStatus> mPanelStatus;
295
296 QgsProcessingContext mLayerStore;
297};
298
299
300class GUI_EXPORT QgsModelChildDependenciesWidget : public QWidget
301{
302 Q_OBJECT
303
304 public:
305 QgsModelChildDependenciesWidget( QWidget *parent, QgsProcessingModelAlgorithm *model, const QString &childId );
306 QList<QgsProcessingModelChildDependency> value() const { return mValue; }
307 void setValue( const QList<QgsProcessingModelChildDependency> &value );
308
309 signals:
310
316 void changed();
317
318 private slots:
319
320 void showDialog();
321
322 private:
323 void updateSummaryText();
324
325 QLineEdit *mLineEdit = nullptr;
326 QToolButton *mToolButton = nullptr;
327
328 QgsProcessingModelAlgorithm *mModel = nullptr;
329 QString mChildId;
330
331 QList<QgsProcessingModelChildDependency> mValue;
332
333 friend class TestProcessingGui;
334};
336
337#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.
An interface for objects which can create Processing widget contexts.
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:163
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_TRANSFERBACK
Definition qgis_sip.h:47
#define SIP_FACTORY
Definition qgis_sip.h:83