QGIS API Documentation 3.99.0-Master (c22de0620c0)
Loading...
Searching...
No Matches
qgsalgorithmrandomextract.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmrandomextract.h
3 ---------------------
4 begin : December 2019
5 copyright : (C) 2019 by Alexander Bruy
6 email : alexander dot bruy 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 QGSALGORITHMRANDOMEXTRACT_H
19#define QGSALGORITHMRANDOMEXTRACT_H
20
21
22#include "qgis_sip.h"
23#include "qgsapplication.h"
25
26#include <QString>
27
28#define SIP_NO_FILE
29
30using namespace Qt::StringLiterals;
31
33
37class QgsRandomExtractSelectAlgorithmBase : public QgsProcessingAlgorithm
38{
39 public:
40 QString group() const override;
41 QString groupId() const override;
42
43 protected:
47 void sampleFeatureIds( QgsFeatureSource *source, const long long count, QgsProcessingFeedback *feedback );
48
49 QgsFeatureIds mSelectedFeatureIds;
50};
51
55class QgsRandomExtractAlgorithm : public QgsRandomExtractSelectAlgorithmBase
56{
57 public:
58 QgsRandomExtractAlgorithm() = default;
59 QString name() const override;
60 QString displayName() const override;
61 QStringList tags() const override;
62 QString shortHelpString() const override;
63 QString shortDescription() const override;
64 Qgis::ProcessingAlgorithmDocumentationFlags documentationFlags() const override;
65 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
66 QgsRandomExtractAlgorithm *createInstance() const override SIP_FACTORY;
67
68 protected:
69 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
70};
71
75class QgsRandomSelectionAlgorithm : public QgsRandomExtractSelectAlgorithmBase
76{
77 public:
78 QgsRandomSelectionAlgorithm() = default;
79 QString name() const override;
80 QString displayName() const override;
81 QStringList tags() const override;
82 QString shortHelpString() const override;
83 QString shortDescription() const override;
84 QIcon icon() const override { return QgsApplication::getThemeIcon( u"/algorithms/mAlgorithmSelectRandom.svg"_s ); }
85 QString svgIconPath() const override { return QgsApplication::iconPath( u"/algorithms/mAlgorithmSelectRandom.svg"_s ); }
86 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
87 QgsRandomSelectionAlgorithm *createInstance() const override SIP_FACTORY;
88
89 protected:
90 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
91 QVariantMap postProcessAlgorithm( QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
92
93 private:
94 QVariant mInput;
95 QgsVectorLayer *mTargetLayer = nullptr;
96};
97
99
100#endif // QGSALGORITHMRANDOMEXTRACT_H
QFlags< ProcessingAlgorithmDocumentationFlag > ProcessingAlgorithmDocumentationFlags
Flags describing algorithm behavior for documentation purposes.
Definition qgis.h:3716
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
An interface for objects which provide features via a getFeatures method.
Abstract base class for processing algorithms.
virtual QString group() const
Returns the name of the group this algorithm belongs to.
virtual QString groupId() const
Returns the unique ID of the group this algorithm belongs to.
Base class for providing feedback from a processing algorithm.
#define SIP_FACTORY
Definition qgis_sip.h:83
QSet< QgsFeatureId > QgsFeatureIds