QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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  sipTransferBreak( o );
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 
134  private:
135 #ifdef SIP_RUN
136  QgsRasterPipe( const QgsRasterPipe &pipe );
137 #endif
138 
140  Role interfaceRole( QgsRasterInterface *iface ) const;
141 
142  // Interfaces in pipe, the first is always provider
143  QVector<QgsRasterInterface *> mInterfaces;
144 
145  QMap<Role, int> mRoleMap;
146 
147  // Set role in mRoleMap
148  void setRole( QgsRasterInterface *interface, int idx );
149 
150  // Unset role in mRoleMap
151  void unsetRole( QgsRasterInterface *interface );
152 
153  // Check if index is in bounds
154  bool checkBounds( int idx ) const;
155 
157  QgsRasterInterface *interface( Role role ) const;
158 
163  bool connect( QVector<QgsRasterInterface *> interfaces );
164 
165 };
166 
167 #endif
168 
169 
Base class for processing modules.
Definition: qgsrasterpipe.h:46
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.