QGIS API Documentation  3.6.0-Noosa (5873452)
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 
76  bool insert( int idx, QgsRasterInterface *interface SIP_TRANSFER );
77 #ifdef SIP_RUN
78  % MethodCode
79  sipRes = sipCpp->insert( a0, a1 );
80  if ( !sipRes )
81  {
82  // if insertion failed transfer ownership back to python
83  PyObject *o = sipGetPyObject( a1, sipType_QgsRasterInterface );
84  if ( o )
85  sipTransferBreak( o );
86  }
87  % End
88 #endif
89 
93  bool replace( int idx, QgsRasterInterface *interface SIP_TRANSFER );
94 
102  bool set( QgsRasterInterface *interface SIP_TRANSFER );
103 
105  bool remove( int idx );
106 
108  bool remove( QgsRasterInterface *interface );
109 
110  int size() const { return mInterfaces.size(); }
111  QgsRasterInterface *at( int idx ) const { return mInterfaces.at( idx ); }
112  QgsRasterInterface *last() const { return mInterfaces.last(); }
113 
117  bool setOn( int idx, bool on );
118 
120  bool canSetOn( int idx, bool on );
121 
122  // Getters for special types of interfaces
123  QgsRasterDataProvider *provider() const;
124  QgsRasterRenderer *renderer() const;
125  QgsRasterResampleFilter *resampleFilter() const;
126  QgsBrightnessContrastFilter *brightnessFilter() const;
127  QgsHueSaturationFilter *hueSaturationFilter() const;
128  QgsRasterProjector *projector() const;
129  QgsRasterNuller *nuller() const;
130 
131  private:
132 #ifdef SIP_RUN
133  QgsRasterPipe( const QgsRasterPipe &pipe );
134 #endif
135 
137  Role interfaceRole( QgsRasterInterface *iface ) const;
138 
139  // Interfaces in pipe, the first is always provider
140  QVector<QgsRasterInterface *> mInterfaces;
141 
142  QMap<Role, int> mRoleMap;
143 
144  // Set role in mRoleMap
145  void setRole( QgsRasterInterface *interface, int idx );
146 
147  // Unset role in mRoleMap
148  void unsetRole( QgsRasterInterface *interface );
149 
150  // Check if index is in bounds
151  bool checkBounds( int idx ) const;
152 
154  QgsRasterInterface *interface( Role role ) const;
155 
159  bool connect( QVector<QgsRasterInterface *> interfaces );
160 
161 };
162 
163 #endif
164 
165 
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.