QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscontrastenhancement.h
Go to the documentation of this file.
1 /* **************************************************************************
2  qgscontrastenhancement.h - description
3  -------------------
4 begin : Mon Oct 22 2007
5 copyright : (C) 2007 by Peter J. Ersts
6 email : [email protected]
7 
8 This class contains code that was originally part of the larger QgsRasterLayer
9 class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
10 ****************************************************************************/
11 
12 /* **************************************************************************
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  ***************************************************************************/
20 
21 #ifndef QGSCONTRASTENHANCEMENT_H
22 #define QGSCONTRASTENHANCEMENT_H
23 
24 #include <limits>
25 
26 #include "qgis.h"
27 
29 class QDomDocument;
30 class QDomElement;
31 class QString;
32 
38 class CORE_EXPORT QgsContrastEnhancement
39 {
40 
41  public:
42 
45  {
46  NoEnhancement, //this should be the default color scaling algorithm
47  StretchToMinimumMaximum, //linear histogram enhanceContrast
50  UserDefinedEnhancement
51  };
52 
56 
57  /*
58  *
59  * Static methods
60  *
61  */
63  static double maximumValuePossible( QGis::DataType );
64 
66  static double minimumValuePossible( QGis::DataType );
67 
68  /*
69  *
70  * Non-Static Inline methods
71  *
72  */
74  double maximumValue() const { return mMaximumValue; }
75 
77  double minimumValue() const { return mMinimumValue; }
78 
79  ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const { return mContrastEnhancementAlgorithm; }
80 
81  static QString contrastEnhancementAlgorithmString( ContrastEnhancementAlgorithm algorithm );
82 
83  static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString( const QString& contrastEnhancementString );
84 
85  /*
86  *
87  * Non-Static methods
88  *
89  */
91  int enhanceContrast( double );
92 
94  bool isValueInDisplayableRange( double );
95 
97  void setContrastEnhancementAlgorithm( ContrastEnhancementAlgorithm, bool generateTable = true );
98 
100  void setContrastEnhancementFunction( QgsContrastEnhancementFunction* );
101 
103  void setMaximumValue( double, bool generateTable = true );
104 
106  void setMinimumValue( double, bool generateTable = true );
107 
108  void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;
109 
110  void readXML( const QDomElement& elem );
111 
112  private:
114  ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm;
115 
117  QgsContrastEnhancementFunction* mContrastEnhancementFunction;
118 
120  bool mEnhancementDirty;
121 
123  double mLookupTableOffset;
124 
126  int *mLookupTable;
127 
129  double mMinimumValue;
130 
132  double mMaximumValue;
133 
135  QGis::DataType mRasterDataType;
136 
138  double mRasterDataTypeRange;
139 
140 
141 
143  bool generateLookupTable();
144 
146  int calculateContrastEnhancementValue( double );
147 };
148 
149 #endif