QGIS API Documentation  2.99.0-Master (23ddace)
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 
61  QgsRasterPipe();
62  QgsRasterPipe( const QgsRasterPipe &pipe ) SIP_SKIP;
63 
64  ~QgsRasterPipe();
65 
66  QgsRasterPipe &operator=( const QgsRasterPipe &rh ) = delete;
67 
70  bool insert( int idx, QgsRasterInterface *interface SIP_TRANSFER );
71 #ifdef SIP_RUN
72  % MethodCode
73  sipRes = sipCpp->insert( a0, a1 );
74  if ( !sipRes )
75  {
76  // if insertion failed transfer ownership back to python
77  PyObject *o = sipGetPyObject( a1, sipType_QgsRasterInterface );
78  if ( o )
79  sipTransferBreak( o );
80  }
81  % End
82 #endif
83 
86  bool replace( int idx, QgsRasterInterface *interface SIP_TRANSFER );
87 
94  bool set( QgsRasterInterface *interface SIP_TRANSFER );
95 
97  bool remove( int idx );
98 
100  bool remove( QgsRasterInterface *interface );
101 
102  int size() const { return mInterfaces.size(); }
103  QgsRasterInterface *at( int idx ) const { return mInterfaces.at( idx ); }
104  QgsRasterInterface *last() const { return mInterfaces.last(); }
105 
108  bool setOn( int idx, bool on );
109 
111  bool canSetOn( int idx, bool on );
112 
113  // Getters for special types of interfaces
114  QgsRasterDataProvider *provider() const;
115  QgsRasterRenderer *renderer() const;
116  QgsRasterResampleFilter *resampleFilter() const;
117  QgsBrightnessContrastFilter *brightnessFilter() const;
118  QgsHueSaturationFilter *hueSaturationFilter() const;
119  QgsRasterProjector *projector() const;
120  QgsRasterNuller *nuller() const;
121 
122  private:
123 #ifdef SIP_RUN
124  QgsRasterPipe( const QgsRasterPipe &pipe );
125 #endif
126 
128  Role interfaceRole( QgsRasterInterface *iface ) const;
129 
130  // Interfaces in pipe, the first is always provider
131  QVector<QgsRasterInterface *> mInterfaces;
132 
133  QMap<Role, int> mRoleMap;
134 
135  // Set role in mRoleMap
136  void setRole( QgsRasterInterface *interface, int idx );
137 
138  // Unset role in mRoleMap
139  void unsetRole( QgsRasterInterface *interface );
140 
141  // Check if index is in bounds
142  bool checkBounds( int idx ) const;
143 
145  QgsRasterInterface *interface( Role role ) const;
146 
149  bool connect( QVector<QgsRasterInterface *> interfaces );
150 
151 };
152 
153 #endif
154 
155 
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:107
QgsRasterInterface * at(int idx) const
#define SIP_TRANSFER
Definition: qgis_sip.h:24
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.