QGIS API Documentation  2.99.0-Master (9caa722)
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.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 
45 class CORE_EXPORT QgsRasterPipe
46 {
47  public:
48  // Role of known interfaces
49  enum Role
50  {
51  UnknownRole = 0,
52  ProviderRole = 1,
53  RendererRole = 2,
54  BrightnessRole = 3,
55  ResamplerRole = 4,
56  ProjectorRole = 5,
57  NullerRole = 6,
58  HueSaturationRole = 7
59  };
60 
64  QgsRasterPipe() = default;
65 
66  QgsRasterPipe( const QgsRasterPipe &pipe ) SIP_SKIP;
67 
68  ~QgsRasterPipe();
69 
70  QgsRasterPipe &operator=( const QgsRasterPipe &rh ) = delete;
71 
74  bool insert( int idx, QgsRasterInterface *interface SIP_TRANSFER );
75 #ifdef SIP_RUN
76  % MethodCode
77  sipRes = sipCpp->insert( a0, a1 );
78  if ( !sipRes )
79  {
80  // if insertion failed transfer ownership back to python
81  PyObject *o = sipGetPyObject( a1, sipType_QgsRasterInterface );
82  if ( o )
83  sipTransferBreak( o );
84  }
85  % End
86 #endif
87 
90  bool replace( int idx, QgsRasterInterface *interface SIP_TRANSFER );
91 
98  bool set( QgsRasterInterface *interface SIP_TRANSFER );
99 
101  bool remove( int idx );
102 
104  bool remove( QgsRasterInterface *interface );
105 
106  int size() const { return mInterfaces.size(); }
107  QgsRasterInterface *at( int idx ) const { return mInterfaces.at( idx ); }
108  QgsRasterInterface *last() const { return mInterfaces.last(); }
109 
112  bool setOn( int idx, bool on );
113 
115  bool canSetOn( int idx, bool on );
116 
117  // Getters for special types of interfaces
118  QgsRasterDataProvider *provider() const;
119  QgsRasterRenderer *renderer() const;
120  QgsRasterResampleFilter *resampleFilter() const;
121  QgsBrightnessContrastFilter *brightnessFilter() const;
122  QgsHueSaturationFilter *hueSaturationFilter() const;
123  QgsRasterProjector *projector() const;
124  QgsRasterNuller *nuller() const;
125 
126  private:
127 #ifdef SIP_RUN
128  QgsRasterPipe( const QgsRasterPipe &pipe );
129 #endif
130 
132  Role interfaceRole( QgsRasterInterface *iface ) const;
133 
134  // Interfaces in pipe, the first is always provider
135  QVector<QgsRasterInterface *> mInterfaces;
136 
137  QMap<Role, int> mRoleMap;
138 
139  // Set role in mRoleMap
140  void setRole( QgsRasterInterface *interface, int idx );
141 
142  // Unset role in mRoleMap
143  void unsetRole( QgsRasterInterface *interface );
144 
145  // Check if index is in bounds
146  bool checkBounds( int idx ) const;
147 
149  QgsRasterInterface *interface( Role role ) const;
150 
153  bool connect( QVector<QgsRasterInterface *> interfaces );
154 
155 };
156 
157 #endif
158 
159 
Base class for processing modules.
Definition: qgsrasterpipe.h:45
Raster pipe that deals with null values.
QgsRasterInterface * last() const
Resample filter pipe for rasters.
#define SIP_SKIP
Definition: qgis_sip.h:119
QgsRasterInterface * at(int idx) const
#define SIP_TRANSFER
Definition: qgis_sip.h:36
Base class for processing filters like renderers, reprojector, resampler etc.
int size() const
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
Brightness/contrast 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.