QGIS API Documentation  3.21.0-Master (909859188c)
qgsrasterpipe.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasterpipe.h - Internal raster processing modules interface
3  --------------------------------------
4  Date : Jun 21, 2012
5  Copyright : (C) 2012 by Radim Blazek
6  email : radim dot blazek 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 QGSRASTERPIPE_H
19 #define QGSRASTERPIPE_H
20 
21 #include "qgis_core.h"
22 #include "qgis_sip.h"
23 #include "qgis.h"
24 #include "qgspropertycollection.h"
25 
26 #include <QImage>
27 #include <QMap>
28 #include <QObject>
29 
30 class QgsRasterInterface;
31 class QgsRasterRenderer;
35 class QgsRasterProjector;
36 class QgsRasterNuller;
40 
41 #if defined(Q_OS_WIN)
42 #undef interface
43 #endif
44 
49 class CORE_EXPORT QgsRasterPipe
50 {
51  public:
52 
57  enum Property
58  {
60  };
61 
65  QgsRasterPipe() = default;
66 
70  QgsRasterPipe( const QgsRasterPipe &pipe ) SIP_SKIP;
71 
72  ~QgsRasterPipe();
73 
74  QgsRasterPipe &operator=( const QgsRasterPipe &rh ) = delete;
75 
83  bool insert( int idx, QgsRasterInterface *interface SIP_TRANSFER );
84 #ifdef SIP_RUN
85  % MethodCode
86  sipRes = sipCpp->insert( a0, a1 );
87  if ( !sipRes )
88  {
89  // if insertion failed transfer ownership back to python
90  PyObject *o = sipGetPyObject( a1, sipType_QgsRasterInterface );
91  if ( o )
92  sipTransferTo( o, NULL );
93  }
94  % End
95 #endif
96 
105  bool replace( int idx, QgsRasterInterface *interface SIP_TRANSFER );
106 
128  bool set( QgsRasterInterface *interface SIP_TRANSFER );
129 
135  bool remove( int idx );
136 
142  bool remove( QgsRasterInterface *interface );
143 
147  int size() const { return mInterfaces.size(); }
148 
152  QgsRasterInterface *at( int idx ) const { return mInterfaces.at( idx ); }
153 
157  QgsRasterInterface *last() const { return mInterfaces.last(); }
158 
164  bool setOn( int idx, bool on );
165 
169  bool canSetOn( int idx, bool on );
170 
171  // Getters for special types of interfaces
172 
176  QgsRasterDataProvider *provider() const;
177 
181  QgsRasterRenderer *renderer() const;
182 
186  QgsRasterResampleFilter *resampleFilter() const;
187 
191  QgsBrightnessContrastFilter *brightnessFilter() const;
192 
196  QgsHueSaturationFilter *hueSaturationFilter() const;
197 
201  QgsRasterProjector *projector() const;
202 
206  QgsRasterNuller *nuller() const;
207 
217  void setResamplingStage( Qgis::RasterResamplingStage stage );
218 
225  Qgis::RasterResamplingStage resamplingStage() const { return mResamplingStage; }
226 
232  QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
233 
241  const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP { return mDataDefinedProperties; }
242 
252  void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
253 
260  void evaluateDataDefinedProperties( QgsExpressionContext &context );
261 
267  static QgsPropertiesDefinition propertyDefinitions();
268 
269  private:
270 #ifdef SIP_RUN
271  QgsRasterPipe( const QgsRasterPipe &pipe );
272 #endif
273 
275  Qgis::RasterPipeInterfaceRole interfaceRole( QgsRasterInterface *iface ) const;
276 
277  // Interfaces in pipe, the first is always provider
278  QVector<QgsRasterInterface *> mInterfaces;
279 
280  QMap<Qgis::RasterPipeInterfaceRole, int> mRoleMap;
281 
282  // Set role in mRoleMap
283  void setRole( QgsRasterInterface *interface, int idx );
284 
285  // Unset role in mRoleMap
286  void unsetRole( QgsRasterInterface *interface );
287 
288  // Check if index is in bounds
289  bool checkBounds( int idx ) const;
290 
292  QgsRasterInterface *interface( Qgis::RasterPipeInterfaceRole role ) const;
293 
298  bool connect( QVector<QgsRasterInterface *> interfaces );
299 
301 
303  QgsPropertyCollection mDataDefinedProperties;
304 
306  static QgsPropertiesDefinition sPropertyDefinitions;
307 
308  static void initPropertyDefinitions();
309 };
310 
311 #endif
312 
313 
RasterResamplingStage
Stage at which raster resampling occurs.
Definition: qgis.h:467
@ ResampleFilter
Resampling occurs in ResamplingFilter.
RasterPipeInterfaceRole
Raster pipe interface roles.
Definition: qgis.h:450
Brightness/contrast and gamma correction filter pipe for rasters.
Manipulates raster or point cloud pixel values so that they enhanceContrast or clip into a specified ...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Color and saturation filter pipe for rasters.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Base class for raster data providers.
Base class for processing filters like renderers, reprojector, resampler etc.
Raster pipe that deals with null values.
Contains a pipeline of raster interfaces for sequential raster processing.
Definition: qgsrasterpipe.h:50
int size() const
Returns the size of the pipe (the number of interfaces contained in the pipe).
QgsRasterPipe & operator=(const QgsRasterPipe &rh)=delete
QgsRasterPipe()=default
Constructor for an empty QgsRasterPipe.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the pipe's property collection, used for data defined overrides.
QgsRasterInterface * last() const
Returns last interface in the pipe.
Property
Data definable properties.
Definition: qgsrasterpipe.h:58
@ RendererOpacity
Raster renderer global opacity.
Definition: qgsrasterpipe.h:59
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the pipe's property collection, used for data defined overrides.
Qgis::RasterResamplingStage resamplingStage() const
Returns which stage of the pipe should apply resampling.
QgsRasterInterface * at(int idx) const
Returns the interface at the specified index.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the pipe's property collection, used for data defined overrides.
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
Raster renderer pipe that applies colors to a raster.
Resample filter pipe for rasters.
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.