16#ifndef QGSPROCESSINGALGORITHMDIALOGBASE_H
17#define QGSPROCESSINGALGORITHMDIALOGBASE_H
19#include "ui_qgsprocessingalgorithmdialogbase.h"
20#include "ui_qgsprocessingalgorithmprogressdialogbase.h"
21#include "ui_qgsprocessingcontextoptionsbase.h"
35class QgsProcessingAlgorithmDialogBase;
36class QgsProcessingContextOptionsWidget;
56 QgsProcessingAlgorithmDialogFeedback();
60 void progressTextChanged(
const QString &text );
61 void errorReported(
const QString &text,
bool fatalError );
62 void warningPushed(
const QString &text );
63 void infoPushed(
const QString &text );
64 void commandInfoPushed(
const QString &text );
65 void debugInfoPushed(
const QString &text );
66 void consoleInfoPushed(
const QString &text );
67 void formattedMessagePushed(
const QString &html );
72 void reportError(
const QString &error,
bool fatalError )
override;
74 void pushInfo(
const QString &info )
override;
107 enum class DialogMode :
int
112 Q_ENUM( QgsProcessingAlgorithmDialogBase::DialogMode )
117 QgsProcessingAlgorithmDialogBase( QWidget *parent
SIP_TRANSFERTHIS =
nullptr, Qt::WindowFlags flags = Qt::WindowFlags(), QgsProcessingAlgorithmDialogBase::DialogMode mode = QgsProcessingAlgorithmDialogBase::DialogMode::Single );
118 ~QgsProcessingAlgorithmDialogBase()
override;
139 void setMainWidget( QgsPanelWidget *widget
SIP_TRANSFER );
145 QgsPanelWidget *mainWidget();
157 bool wasExecuted()
const {
return mExecuted; }
164 QVariantMap results()
const {
return mResults; }
170 QgsProcessingFeedback *createFeedback()
SIP_FACTORY;
178 void saveLogToFile( const QString &path, LogFormat format = FormatPlainText );
186 Qgis::ProcessingLogLevel logLevel() const;
194 void setLogLevel( Qgis::ProcessingLogLevel level );
201 virtual
void setParameters( const QVariantMap &values );
210 void reportError( const QString &error,
bool fatalError );
215 void pushWarning( const QString &warning );
220 void pushInfo( const QString &info );
229 void pushFormattedMessage( const QString &html );
234 void pushDebugInfo( const QString &message );
239 void pushCommandInfo( const QString &info );
244 void setPercentage(
double percent );
249 void setProgressText( const QString &text );
254 void pushConsoleInfo( const QString &info );
260 QDialog *createProgressDialog();
279 void copyLogToClipboard();
284 void showParameters();
286 void reject() override;
289 void closeEvent( QCloseEvent *e ) override;
294 QPushButton *runButton();
299 QPushButton *cancelButton();
304 QPushButton *changeParametersButton();
309 QDialogButtonBox *buttonBox();
314 QTabWidget *tabWidget();
319 void clearProgress();
326 void setExecuted(
bool executed );
331 void setExecutedAnyResult(
bool executedAnyResult );
338 void setResults( const QVariantMap &results );
343 void setInfo( const QString &message,
bool isError = false,
bool escapeHtml = true,
bool isWarning = false );
354 virtual
void resetAdditionalGui();
359 void updateRunButtonVisibility();
365 void blockControlsWhileRunning();
371 virtual
void blockAdditionalControlsWhileRunning();
376 QgsMessageBar *messageBar();
381 void hideShortHelp();
387 void setCurrentTask( QgsProcessingAlgRunnerTask *task
SIP_TRANSFER );
393 static QString formatStringForLog( const QString &
string );
400 virtual
bool isFinalized();
409 void applyContextOverrides( QgsProcessingContext *context );
420 void algorithmAboutToRun( QgsProcessingContext *context );
427 void algorithmFinished(
bool successful, const QVariantMap &result );
434 virtual
void finished(
bool successful, const QVariantMap &result, QgsProcessingContext &context, QgsProcessingFeedback *feedback );
439 virtual
void runAlgorithm();
446 virtual
void algExecuted(
bool successful, const QVariantMap &results );
451 void toggleCollapsed();
453 void splitterChanged(
int pos,
int index );
454 void mTabWidget_currentChanged(
int index );
455 void linkClicked( const QUrl &url );
456 void taskTriggered( QgsTask *task );
458 void urlClicked( const QUrl &url );
461 DialogMode mMode = DialogMode::Single;
463 QPushButton *mButtonRun =
nullptr;
464 QPushButton *mButtonClose =
nullptr;
465 QPushButton *mButtonChangeParameters =
nullptr;
466 QByteArray mSplitterState;
467 QToolButton *mButtonCollapse =
nullptr;
468 QgsMessageBar *mMessageBar =
nullptr;
469 QPushButton *mAdvancedButton =
nullptr;
470 QMenu *mAdvancedMenu =
nullptr;
471 QAction *mCopyAsQgisProcessCommand =
nullptr;
472 QAction *mPasteJsonAction =
nullptr;
473 QAction *mContextSettingsAction =
nullptr;
475 bool mExecuted = false;
476 bool mExecutedAnyResult = false;
477 QVariantMap mResults;
478 QgsPanelWidget *mMainWidget =
nullptr;
479 std::unique_ptr<QgsProcessingAlgorithm> mAlgorithm;
480 QgsProcessingAlgRunnerTask *mAlgorithmTask =
nullptr;
482 bool mHelpCollapsed = false;
484 int mMessageLoggedCount = 0;
486 Qgis::ProcessingLogLevel mLogLevel = Qgis::ProcessingLogLevel::DefaultLevel;
488 QPointer<QgsProcessingContextOptionsWidget> mContextOptionsWidget;
489 bool mOverrideDefaultContextSettings = false;
490 Qgis::InvalidGeometryCheck mGeometryCheck = Qgis::InvalidGeometryCheck::AbortOnInvalid;
491 Qgis::DistanceUnit mDistanceUnits = Qgis::DistanceUnit::Unknown;
492 Qgis::AreaUnit mAreaUnits = Qgis::AreaUnit::Unknown;
493 QString mTemporaryFolderOverride;
494 int mMaximumThreads = QThread::idealThreadCount();
496 QString formatHelp( QgsProcessingAlgorithm *
algorithm );
497 void scrollToBottomOfLog();
498 void processEvents();
508class QgsProcessingAlgorithmProgressDialog :
public QDialog,
private Ui::QgsProcessingProgressDialogBase
516 QgsProcessingAlgorithmProgressDialog( QWidget *parent =
nullptr );
521 QProgressBar *progressBar();
526 QPushButton *cancelButton();
531 QTextEdit *logTextEdit();
535 void reject()
override;
544class GUI_EXPORT QgsProcessingContextOptionsWidget :
public QgsPanelWidget,
private Ui::QgsProcessingContextOptionsBase
552 QgsProcessingContextOptionsWidget( QWidget *parent
SIP_TRANSFERTHIS =
nullptr );
557 void setFromContext(
const QgsProcessingContext *context );
577 QString temporaryFolder();
582 int maximumThreads()
const;
DistanceUnit
Units of distance.
InvalidGeometryCheck
Methods for handling of features with invalid geometries.
ProcessingLogLevel
Logging level for algorithms to use when pushing feedback messages.
A bar for displaying non-blocking messages to the user.
QgsTask task which runs a QgsProcessingAlgorithm in a background task.
Abstract base class for processing algorithms.
An interface for objects which can create Processing contexts.
Base class for providing feedback from a processing algorithm.
virtual void pushCommandInfo(const QString &info)
Pushes an informational message containing a command from the algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
virtual void pushWarning(const QString &warning)
Pushes a warning informational message from the algorithm.
virtual void pushDebugInfo(const QString &info)
Pushes an informational message containing debugging helpers from the algorithm.
virtual void pushFormattedMessage(const QString &html, const QString &text)
Pushes a pre-formatted message from the algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
virtual void pushConsoleInfo(const QString &info)
Pushes a console feedback message from the algorithm.
virtual void setProgressText(const QString &text)
Sets a progress report text string.
An interface for objects which can create sets of parameter values for processing algorithms.
Abstract base class for long running background tasks.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call