QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:406
QgsRasterPipe
Contains a pipeline of raster interfaces for sequential raster processing.
Definition: qgsrasterpipe.h:49
Qgis::RasterResamplingStage
RasterResamplingStage
Stage at which raster resampling occurs.
Definition: qgis.h:720
qgis.h
QgsRasterPipe::setDataDefinedProperties
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the pipe's property collection, used for data defined overrides.
Definition: qgsrasterpipe.h:252
QgsRasterNuller
Raster pipe that deals with null values.
Definition: qgsrasternuller.h:32
QgsRasterPipe::dataDefinedProperties
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the pipe's property collection, used for data defined overrides.
Definition: qgsrasterpipe.h:241
QgsRasterPipe::at
QgsRasterInterface * at(int idx) const
Returns the interface at the specified index.
Definition: qgsrasterpipe.h:152
QgsRasterProjector
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
Definition: qgsrasterprojector.h:47
QgsPropertiesDefinition
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
Definition: qgspropertycollection.h:29
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsRasterPipe::resamplingStage
Qgis::RasterResamplingStage resamplingStage() const
Returns which stage of the pipe should apply resampling.
Definition: qgsrasterpipe.h:225
QgsRasterPipe::dataDefinedProperties
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the pipe's property collection, used for data defined overrides.
Definition: qgsrasterpipe.h:232
QgsRasterRenderer
Raster renderer pipe that applies colors to a raster.
Definition: qgsrasterrenderer.h:40
QgsRasterPipe::RendererOpacity
@ RendererOpacity
Raster renderer global opacity.
Definition: qgsrasterpipe.h:59
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsHueSaturationFilter
Color and saturation filter pipe for rasters.
Definition: qgshuesaturationfilter.h:31
Qgis::RasterPipeInterfaceRole
RasterPipeInterfaceRole
Sublayer flags.
Definition: qgis.h:703
QgsContrastEnhancement
Manipulates raster or point cloud pixel values so that they enhanceContrast or clip into a specified ...
Definition: qgscontrastenhancement.h:42
QgsPropertyCollection
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Definition: qgspropertycollection.h:318
QgsRasterInterface
Base class for processing filters like renderers, reprojector, resampler etc.
Definition: qgsrasterinterface.h:135
QgsRasterPipe::last
QgsRasterInterface * last() const
Returns last interface in the pipe.
Definition: qgsrasterpipe.h:157
QgsBrightnessContrastFilter
Brightness/contrast and gamma correction filter pipe for rasters.
Definition: qgsbrightnesscontrastfilter.h:31
QgsRasterResampleFilter
Resample filter pipe for rasters.
Definition: qgsrasterresamplefilter.h:32
qgspropertycollection.h
QgsRasterPipe::Property
Property
Data definable properties.
Definition: qgsrasterpipe.h:57
Qgis::RasterResamplingStage::ResampleFilter
@ ResampleFilter
Resampling occurs in ResamplingFilter.
QgsRasterDataProvider
Base class for raster data providers.
Definition: qgsrasterdataprovider.h:88
QgsRasterPipe::size
int size() const
Returns the size of the pipe (the number of interfaces contained in the pipe).
Definition: qgsrasterpipe.h:147