QGIS API Documentation 3.99.0-Master (c22de0620c0)
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
27class QgsMessageBar;
28class QgsProcessingModelAlgorithm;
29class QgsModelUndoCommand;
30class QUndoView;
33class QgsScreenHelper;
34class QgsProcessingAlgorithmDialogBase;
38
40
41#ifndef SIP_RUN
42
43class GUI_EXPORT QgsModelerToolboxModel : public QgsProcessingToolboxProxyModel
44{
45 Q_OBJECT
46 public:
47 explicit QgsModelerToolboxModel( QObject *parent = nullptr );
48 Qt::ItemFlags flags( const QModelIndex &index ) const override;
49 Qt::DropActions supportedDragActions() const override;
50};
51
52#endif
53
60class GUI_EXPORT QgsModelDesignerDialog : public QMainWindow, public Ui::QgsModelDesignerDialogBase
61{
62 Q_OBJECT
63 public:
64 QgsModelDesignerDialog( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
65 ~QgsModelDesignerDialog() override;
66
67 void closeEvent( QCloseEvent *event ) override;
68
72 void beginUndoCommand( const QString &text, const QString &id = QString(), QgsModelUndoCommand::CommandOperation operation SIP_PYARGREMOVE = QgsModelUndoCommand::CommandOperation::Unknown );
73
77 void endUndoCommand();
78
83 void abortUndoCommand();
84
88 QgsProcessingModelAlgorithm *model();
89
95 void setModel( QgsProcessingModelAlgorithm *model SIP_TRANSFER );
96
100 void loadModel( const QString &path );
101
107 void setModelScene( QgsModelGraphicsScene *scene SIP_TRANSFER );
108
115 QgsModelGraphicsScene *modelScene();
116
122 enum class SaveAction
123 {
124 SaveAsFile,
125 SaveInProject,
126 };
127
128 public slots:
129
135 void activate();
136
137 protected:
138 // cppcheck-suppress pureVirtualCall
139 virtual void repaintModel( bool showControls = true ) = 0;
140 virtual void addAlgorithm( const QString &algorithmId, const QPointF &pos ) = 0;
141 // cppcheck-suppress pureVirtualCall
142 virtual void addInput( const QString &inputId, const QPointF &pos ) = 0;
143 // cppcheck-suppress pureVirtualCall
144 virtual void exportAsScriptAlgorithm() = 0;
145 // cppcheck-suppress pureVirtualCall
146 virtual bool saveModel( bool saveAs = false ) = 0;
147 // cppcheck-suppress pureVirtualCall
148 virtual QgsProcessingAlgorithmDialogBase *createExecutionDialog() = 0 SIP_TRANSFERBACK;
149
153 virtual QgsProcessingParameterWidgetContext createWidgetContext() = 0; // cppcheck-suppress pureVirtualCall
154
159 void registerProcessingContextGenerator( QgsProcessingContextGenerator *generator );
160
161 QToolBar *toolbar() { return mToolbar; }
162 QAction *actionOpen() { return mActionOpen; }
163 QAction *actionSaveInProject() { return mActionSaveInProject; }
164 QAction *actionRun() { return mActionRun; }
165 QgsMessageBar *messageBar() { return mMessageBar; }
166 QGraphicsView *view() { return mView; }
167
168 void setDirty( bool dirty );
169
173 bool validateSave( SaveAction action );
174
180 bool checkForUnsavedChanges();
181
185 void setLastRunResult( const QgsProcessingModelResult &result );
186
194 void setModelName( const QString &name );
195
196 private slots:
197 void zoomIn();
198 void zoomOut();
199 void zoomActual();
200 void zoomFull();
201 void newModel();
202 void exportToImage();
203 void exportToPdf();
204 void exportToSvg();
205 void exportAsPython();
206 void toggleComments( bool show );
207 void toggleFeatureCount( bool show );
208 void updateWindowTitle();
209 void deleteSelected();
210 void populateZoomToMenu();
211 void validate();
212 void reorderInputs();
213 void reorderOutputs();
214 void setPanelVisibility( bool hidden );
215 void editHelp();
216 void runSelectedSteps();
217 void runFromChild( const QString &id );
218 void run( const QSet<QString> &childAlgorithmSubset = QSet<QString>() );
219 void showChildAlgorithmOutputs( const QString &childId );
220 void showChildAlgorithmLog( const QString &childId );
221 void onItemFocused( QgsModelComponentGraphicItem *item );
222
223 private:
224 std::unique_ptr<QgsProcessingModelAlgorithm> mModel;
225
226 QgsScreenHelper *mScreenHelper = nullptr;
227
228 QgsMessageBar *mMessageBar = nullptr;
229 QgsModelerToolboxModel *mAlgorithmsModel = nullptr;
230
231 QActionGroup *mToolsActionGroup = nullptr;
232
233 QgsModelViewToolPan *mPanTool = nullptr;
234 QgsModelViewToolSelect *mSelectTool = nullptr;
235 QgsModelGraphicsScene *mScene = nullptr;
236
237 bool mHasChanged = false;
238 QUndoStack *mUndoStack = nullptr;
239 std::unique_ptr<QgsModelUndoCommand> mActiveCommand;
240
241 QAction *mUndoAction = nullptr;
242 QAction *mRedoAction = nullptr;
243 QUndoView *mUndoView = nullptr;
244 QgsDockWidget *mUndoDock = nullptr;
245
246 QMenu *mGroupMenu = nullptr;
247
248 QAction *mActionCut = nullptr;
249 QAction *mActionCopy = nullptr;
250 QAction *mActionPaste = nullptr;
251 int mBlockUndoCommands = 0;
252 int mIgnoreUndoStackChanges = 0;
253
254 QgsDockWidget *mConfigWidgetDock = nullptr;
255 QgsModelDesignerConfigDockWidget *mConfigWidget = nullptr;
256
257 QgsProcessingContextGenerator *mProcessingContextGenerator = nullptr;
258
259 QString mTitle;
260
261 int mBlockRepaints = 0;
262
263 QgsProcessingModelResult mLastResult;
264
265 bool isDirty() const;
266
267 void fillInputsTree();
268 void updateVariablesGui();
269
270 struct PanelStatus
271 {
272 PanelStatus( bool visible = true, bool active = false )
273 : isVisible( visible )
274 , isActive( active )
275 {}
276 bool isVisible;
277 bool isActive;
278 };
279 QMap<QString, PanelStatus> mPanelStatus;
280
281 QgsProcessingContext mLayerStore;
282};
283
284
285class GUI_EXPORT QgsModelChildDependenciesWidget : public QWidget
286{
287 Q_OBJECT
288
289 public:
290 QgsModelChildDependenciesWidget( QWidget *parent, QgsProcessingModelAlgorithm *model, const QString &childId );
291 QList<QgsProcessingModelChildDependency> value() const { return mValue; }
292 void setValue( const QList<QgsProcessingModelChildDependency> &value );
293 private slots:
294
295 void showDialog();
296
297 private:
298 void updateSummaryText();
299
300 QLineEdit *mLineEdit = nullptr;
301 QToolButton *mToolButton = nullptr;
302
303 QgsProcessingModelAlgorithm *mModel = nullptr;
304 QString mChildId;
305
306 QList<QgsProcessingModelChildDependency> mValue;
307
308 friend class TestProcessingGui;
309};
311
312#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