QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
qgsrasterrendererregistry.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasterrendererregistry.h
3  ---------------------------
4  begin : January 2012
5  copyright : (C) 2012 by Marco Hugentobler
6  email : marco at sourcepole dot ch
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 QGSRASTERRENDERERREGISTRY_H
19 #define QGSRASTERRENDERERREGISTRY_H
20 
21 #include "qgsrasterlayer.h" //for DrawingStyle enum
22 #include <QHash>
23 #include <QString>
24 
25 class QDomElement;
26 class QgsRasterInterface;
27 class QgsRasterLayer;
28 class QgsRasterRenderer;
30 
31 typedef QgsRasterRenderer*( *QgsRasterRendererCreateFunc )( const QDomElement&, QgsRasterInterface* input );
32 typedef QgsRasterRendererWidget*( *QgsRasterRendererWidgetCreateFunc )( QgsRasterLayer*, const QgsRectangle &extent );
33 
38 {
39  QgsRasterRendererRegistryEntry( const QString& theName, const QString& theVisibleName, QgsRasterRendererCreateFunc rendererFunction,
40  QgsRasterRendererWidgetCreateFunc widgetFunction );
41  QgsRasterRendererRegistryEntry();
42  QString name;
43  QString visibleName; //visible (and translatable) name
45  QgsRasterRendererWidgetCreateFunc widgetCreateFunction; //pointer to create function for renderer widget
46 };
47 
51 class CORE_EXPORT QgsRasterRendererRegistry
52 {
53  public:
54  static QgsRasterRendererRegistry* instance();
56 
57  void insert( QgsRasterRendererRegistryEntry entry );
58  void insertWidgetFunction( const QString& rendererName, QgsRasterRendererWidgetCreateFunc func );
59  bool rendererData( const QString& rendererName, QgsRasterRendererRegistryEntry& data ) const;
60  QStringList renderersList() const;
61  QList< QgsRasterRendererRegistryEntry > entries() const;
62 
65  QgsRasterRenderer* defaultRendererForDrawingStyle( const QgsRaster::DrawingStyle& theDrawingStyle, QgsRasterDataProvider* provider ) const;
66 
67  protected:
69 
70  private:
72  QHash< QString, QgsRasterRendererRegistryEntry > mEntries;
73  QStringList mSortedEntries;
74 
75  //read min/max values from
76  bool minMaxValuesForBand( int band, QgsRasterDataProvider* provider, double& minValue, double& maxValue ) const;
77 };
78 
79 #endif // QGSRASTERRENDERERREGISTRY_H
static QgsRasterRendererRegistry * mInstance
A rectangle specified with double values.
Definition: qgsrectangle.h:35
QgsRasterRendererWidgetCreateFunc widgetCreateFunction
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
Registry for raster renderers.
QgsRasterRendererWidget *(* QgsRasterRendererWidgetCreateFunc)(QgsRasterLayer *, const QgsRectangle &extent)
QHash< QString, QgsRasterRendererRegistryEntry > mEntries
Base class for processing filters like renderers, reprojector, resampler etc.
Registry for raster renderer entries.
QgsRasterRenderer *(* QgsRasterRendererCreateFunc)(const QDomElement &, QgsRasterInterface *input)
DrawingStyle
This enumerator describes the different kinds of drawing we can do.
Definition: qgsraster.h:95
Raster renderer pipe that applies colors to a raster.
QgsRasterRendererCreateFunc rendererCreateFunction
Base class for raster data providers.