QGIS API Documentation 4.1.0-Master (31622b25bb0)
Loading...
Searching...
No Matches
qgsprocessingfeedback.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingfeedback.h
3 -----------------------
4 begin : December 2016
5 copyright : (C) 2016 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSPROCESSINGFEEDBACK_H
19#define QGSPROCESSINGFEEDBACK_H
20
21#include "qgis_core.h"
22#include "qgsfeedback.h"
23
24#include <QMap>
25
29
39class CORE_EXPORT QgsProcessingFeedback : public QgsFeedback
40{
41 Q_OBJECT
42
43 public:
50 QgsProcessingFeedback( bool logFeedback = true );
51
59 virtual void setProgressText( const QString &text );
60
68 virtual void reportError( const QString &error, bool fatalError = false );
69
82 virtual void pushWarning( const QString &warning );
83
96 virtual void pushInfo( const QString &info );
97
113 virtual void pushFormattedMessage( const QString &html, const QString &text );
114
126 virtual void pushCommandInfo( const QString &info );
127
138 virtual void pushDebugInfo( const QString &info );
139
150 virtual void pushConsoleInfo( const QString &info );
151
156 void pushVersionInfo( const QgsProcessingProvider *provider = nullptr );
157
163 void pushFormattedResults( const QgsProcessingAlgorithm *algorithm, QgsProcessingContext &context, const QVariantMap &results );
164
171 virtual QString htmlLog() const;
172
179 virtual QString textLog() const;
180
187 void reportSourceLoaded( const QString &parameterName, long long featureCount );
188
196 void featureAddedToSink( const QString &output );
197
210 void featureSinkFinalized( const QString &output );
211
218
219 signals:
220
227 void progressTextChanged( const QString &text );
228
235 void errorReported( const QString &text, bool fatalError );
236
243 void warningPushed( const QString &text );
244
251 void infoPushed( const QString &text );
252
259 void commandInfoPushed( const QString &text );
260
267 void debugInfoPushed( const QString &text );
268
275 void consoleInfoPushed( const QString &text );
276
283 void formattedMessagePushed( const QString &html );
284
297 void sinkFeatureCountChanged( const QString &output, long long featureCount );
298
305 void sourceLoaded( const QString &parameterName, long long featureCount );
306
307 private:
308 void log( const QString &htmlMessage, const QString &textMessage );
309
310 bool mLogFeedback = true;
311 QString mHtmlLog;
312 QString mTextLog;
313 int mMessageLoggedCount = 0;
314
315 struct SinkStats
316 {
317 long long featureCount = 0;
318 long long countAtLastSignal = 0;
319 };
320
321 QMap< QString, SinkStats > mSinkFeatureCounts;
322};
323
324
337{
338 Q_OBJECT
339
340 public:
347
352 void setCurrentStep( int step );
353
367 void setStepWeights( const QList<double> &weights );
368
369 void setProgressText( const QString &text ) override;
370 void reportError( const QString &error, bool fatalError = false ) override;
371 void pushWarning( const QString &warning ) override;
372 void pushInfo( const QString &info ) override;
373 void pushCommandInfo( const QString &info ) override;
374 void pushDebugInfo( const QString &info ) override;
375 void pushConsoleInfo( const QString &info ) override;
376 void pushFormattedMessage( const QString &html, const QString &text ) override;
377
378 QString htmlLog() const override;
379 QString textLog() const override;
380
381 private slots:
382
383 void updateOverallProgress( double progress );
384
385 private:
386 int mChildSteps = 0;
387 int mCurrentStep = 0;
388 QList< double > mStepWeights;
389 double mCurrentStepBaseProgress = 0.0;
390 QgsProcessingFeedback *mFeedback = nullptr;
391};
392
393#endif // QGSPROCESSINGFEEDBACK_H
QgsFeedback(QObject *parent=nullptr)
Construct a feedback object.
Definition qgsfeedback.h:48
double progress() const
Returns the current progress reported by the feedback object.
Definition qgsfeedback.h:81
Abstract base class for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
void featureAddedToSink(const QString &output)
Reports that a feature was added to the the sink associated with the specified algorithm output.
virtual void pushCommandInfo(const QString &info)
Pushes an informational message containing a command from the algorithm.
void warningPushed(const QString &text)
Emitted when an warning is pushed.
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.
void infoPushed(const QString &text)
Emitted when information text is pushed.
void errorReported(const QString &text, bool fatalError)
Emitted when an error is reported.
void progressTextChanged(const QString &text)
Emitted when the progress text is changed.
void debugInfoPushed(const QString &text)
Emitted when debug information text is pushed.
void sinkFeatureCountChanged(const QString &output, long long featureCount)
Emitted when the count of features pushed to a sink has changed.
void featureSinkFinalized(const QString &output)
Reports that a feature sink has been finalized.
void pushVersionInfo(const QgsProcessingProvider *provider=nullptr)
Pushes a summary of the QGIS (and underlying library) version information to the log.
virtual QString textLog() const
Returns the plain text contents of the log, which contains all messages pushed to the feedback object...
QgsProcessingFeedback(bool logFeedback=true)
Constructor for QgsProcessingFeedback.
void pushFormattedResults(const QgsProcessingAlgorithm *algorithm, QgsProcessingContext &context, const QVariantMap &results)
Pushes a summary of the execution results to the log.
virtual QString htmlLog() const
Returns the HTML formatted contents of the log, which contains all messages pushed to the feedback ob...
void sourceLoaded(const QString &parameterName, long long featureCount)
Emitted when a feature source was retrieved for the specified algorithm input parameter.
virtual void pushDebugInfo(const QString &info)
Pushes an informational message containing debugging helpers from the algorithm.
void reportSourceLoaded(const QString &parameterName, long long featureCount)
Reports that a feature source was retrieved for the specified algorithm input parameter.
void formattedMessagePushed(const QString &html)
Emitted when a formatted html message is pushed.
virtual void pushFormattedMessage(const QString &html, const QString &text)
Pushes a pre-formatted message from the algorithm.
void resetFeatureSinkCounts()
Resets all stored feature sink counts.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
void commandInfoPushed(const QString &text)
Emitted when command information text is pushed.
void consoleInfoPushed(const QString &text)
Emitted when console information text is pushed.
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.
QgsProcessingMultiStepFeedback(int steps, QgsProcessingFeedback *feedback)
Constructor for QgsProcessingMultiStepFeedback, for a process with the specified number of steps.
void pushDebugInfo(const QString &info) override
Pushes an informational message containing debugging helpers from the algorithm.
void pushFormattedMessage(const QString &html, const QString &text) override
Pushes a pre-formatted message from the algorithm.
void pushConsoleInfo(const QString &info) override
Pushes a console feedback message from the algorithm.
void pushInfo(const QString &info) override
Pushes a general informational message from the algorithm.
void pushWarning(const QString &warning) override
Pushes a warning informational message from the algorithm.
void setProgressText(const QString &text) override
Sets a progress report text string.
void setCurrentStep(int step)
Sets the step which is being executed.
void setStepWeights(const QList< double > &weights)
Sets the relative weights for each step.
void reportError(const QString &error, bool fatalError=false) override
Reports that the algorithm encountered an error while executing.
QString textLog() const override
Returns the plain text contents of the log, which contains all messages pushed to the feedback object...
void pushCommandInfo(const QString &info) override
Pushes an informational message containing a command from the algorithm.
QString htmlLog() const override
Returns the HTML formatted contents of the log, which contains all messages pushed to the feedback ob...
Abstract base class for processing providers.
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