QGIS API Documentation  3.15.0-Master (dbe1ef8aa2)
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 <QImage>
24 #include <QMap>
25 #include <QObject>
26 
27 class QgsRasterInterface;
28 class QgsRasterRenderer;
32 class QgsRasterProjector;
33 class QgsRasterNuller;
37 
38 #if defined(Q_OS_WIN)
39 #undef interface
40 #endif
41 
46 class CORE_EXPORT QgsRasterPipe
47 {
48  public:
49  // Role of known interfaces
50  enum Role
51  {
52  UnknownRole = 0,
53  ProviderRole = 1,
54  RendererRole = 2,
55  BrightnessRole = 3,
56  ResamplerRole = 4,
57  ProjectorRole = 5,
58  NullerRole = 6,
59  HueSaturationRole = 7,
60  };
61 
65  QgsRasterPipe() = default;
66 
67  QgsRasterPipe( const QgsRasterPipe &pipe ) SIP_SKIP;
68 
69  ~QgsRasterPipe();
70 
71  QgsRasterPipe &operator=( const QgsRasterPipe &rh ) = delete;
72 
77  bool insert( int idx, QgsRasterInterface *interface SIP_TRANSFER );
78 #ifdef SIP_RUN
79  % MethodCode
80  sipRes = sipCpp->insert( a0, a1 );
81  if ( !sipRes )
82  {
83  // if insertion failed transfer ownership back to python
84  PyObject *o = sipGetPyObject( a1, sipType_QgsRasterInterface );
85  if ( o )
86  sipTransferTo( o, NULL );
87  }
88  % End
89 #endif
90 
95  bool replace( int idx, QgsRasterInterface *interface SIP_TRANSFER );
96 
104  bool set( QgsRasterInterface *interface SIP_TRANSFER );
105 
107  bool remove( int idx );
108 
110  bool remove( QgsRasterInterface *interface );
111 
112  int size() const { return mInterfaces.size(); }
113  QgsRasterInterface *at( int idx ) const { return mInterfaces.at( idx ); }
114  QgsRasterInterface *last() const { return mInterfaces.last(); }
115 
120  bool setOn( int idx, bool on );
121 
123  bool canSetOn( int idx, bool on );
124 
125  // Getters for special types of interfaces
126  QgsRasterDataProvider *provider() const;
127  QgsRasterRenderer *renderer() const;
128  QgsRasterResampleFilter *resampleFilter() const;
129  QgsBrightnessContrastFilter *brightnessFilter() const;
130  QgsHueSaturationFilter *hueSaturationFilter() const;
131  QgsRasterProjector *projector() const;
132  QgsRasterNuller *nuller() const;
133 
138  enum class ResamplingStage
139  {
141  ResampleFilter,
143  Provider
144  };
145 
154  void setResamplingStage( ResamplingStage stage );
155 
160  ResamplingStage resamplingStage() const { return mResamplingStage; }
161 
162  private:
163 #ifdef SIP_RUN
164  QgsRasterPipe( const QgsRasterPipe &pipe );
165 #endif
166 
168  Role interfaceRole( QgsRasterInterface *iface ) const;
169 
170  // Interfaces in pipe, the first is always provider
171  QVector<QgsRasterInterface *> mInterfaces;
172 
173  QMap<Role, int> mRoleMap;
174 
175  // Set role in mRoleMap
176  void setRole( QgsRasterInterface *interface, int idx );
177 
178  // Unset role in mRoleMap
179  void unsetRole( QgsRasterInterface *interface );
180 
181  // Check if index is in bounds
182  bool checkBounds( int idx ) const;
183 
185  QgsRasterInterface *interface( Role role ) const;
186 
191  bool connect( QVector<QgsRasterInterface *> interfaces );
192 
193  ResamplingStage mResamplingStage = ResamplingStage::ResampleFilter;
194 };
195 
196 #endif
197 
198 
Base class for processing modules.
Definition: qgsrasterpipe.h:46
Raster pipe that deals with null values.
QgsRasterInterface * last() const
ResamplingStage resamplingStage() const
Returns which stage of the pipe should apply resampling.
Resample filter pipe for rasters.
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsRasterInterface * at(int idx) const
#define SIP_TRANSFER
Definition: qgis_sip.h:36
Base class for processing filters like renderers, reprojector, resampler etc.
ResamplingStage
Stage at which resampling occurs.
int size() const
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
Brightness/contrast and gamma correction filter pipe for rasters.
Color and saturation filter pipe for rasters.
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range...
Raster renderer pipe that applies colors to a raster.
Base class for raster data providers.