QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <QImage>
22 #include <QObject>
23 
25 #include "qgshuesaturationfilter.h"
26 #include "qgsrasterdataprovider.h"
27 #include "qgsrasterinterface.h"
28 #include "qgsrasternuller.h"
29 #include "qgsrasterprojector.h"
30 #include "qgsrasterrenderer.h"
32 #include "qgsrectangle.h"
33 
34 #if defined(Q_OS_WIN)
35 #undef interface
36 #endif
37 
41 class CORE_EXPORT QgsRasterPipe
42 {
43  public:
44  // Role of known interfaces
45  enum Role
46  {
47  UnknownRole = 0,
48  ProviderRole = 1,
49  RendererRole = 2,
50  BrightnessRole = 3,
51  ResamplerRole = 4,
52  ProjectorRole = 5,
53  NullerRole = 6,
54  HueSaturationRole = 7
55  };
56 
57  QgsRasterPipe();
58  QgsRasterPipe( const QgsRasterPipe& thePipe );
59 
60  ~QgsRasterPipe();
61 
64  bool insert( int idx, QgsRasterInterface* theInterface );
65 
68  bool replace( int idx, QgsRasterInterface* theInterface );
69 
76  bool set( QgsRasterInterface * theInterface );
77 
79  bool remove( int idx );
80 
82  bool remove( QgsRasterInterface * theInterface );
83 
84  int size() const { return mInterfaces.size(); }
85  QgsRasterInterface * at( int idx ) const { return mInterfaces.at( idx ); }
86  QgsRasterInterface * last() const { return mInterfaces.last(); }
87 
90  bool setOn( int idx, bool on );
91 
93  bool canSetOn( int idx, bool on );
94 
95  // Getters for special types of interfaces
96  QgsRasterDataProvider * provider() const;
97  QgsRasterRenderer * renderer() const;
98  QgsRasterResampleFilter * resampleFilter() const;
99  QgsBrightnessContrastFilter * brightnessFilter() const;
100  QgsHueSaturationFilter * hueSaturationFilter() const;
101  QgsRasterProjector * projector() const;
102  QgsRasterNuller * nuller() const;
103 
104  private:
106  Role interfaceRole( QgsRasterInterface * iface ) const;
107 
108  // Interfaces in pipe, the first is always provider
109  QVector<QgsRasterInterface*> mInterfaces;
110 
111  QMap<Role, int> mRoleMap;
112 
113  // Set role in mRoleMap
114  void setRole( QgsRasterInterface * theInterface, int idx );
115 
116  // Unset role in mRoleMap
117  void unsetRole( QgsRasterInterface * theInterface );
118 
119  // Check if index is in bounds
120  bool checkBounds( int idx ) const;
121 
123  QgsRasterInterface * interface( Role role ) const;
124 
127  bool connect( QVector<QgsRasterInterface*> theInterfaces );
128 };
129 
130 #endif
131 
132