QGIS API Documentation  2.99.0-Master (08c2e66)
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 "qgis_core.h"
25 #include <limits>
26 
27 #include "qgis.h"
28 #include "qgsraster.h"
29 
31 class QDomDocument;
32 class QDomElement;
33 class QString;
34 
40 class CORE_EXPORT QgsContrastEnhancement
41 {
42 
43  public:
44 
47  {
48  NoEnhancement, //this should be the default color scaling algorithm
49  StretchToMinimumMaximum, //linear histogram enhanceContrast
52  UserDefinedEnhancement
53  };
54 
58 
59  const QgsContrastEnhancement& operator=( const QgsContrastEnhancement& ) = delete;
60 
61  /*
62  *
63  * Static methods
64  *
65  */
67  static double maximumValuePossible( Qgis::DataType );
68 
70  static double minimumValuePossible( Qgis::DataType );
71 
73  static QString contrastEnhancementAlgorithmString( ContrastEnhancementAlgorithm algorithm );
74 
76  static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString( const QString& contrastEnhancementString );
77 
78  /*
79  *
80  * Non-Static Inline methods
81  *
82  */
84  double maximumValue() const { return mMaximumValue; }
85 
87  double minimumValue() const { return mMinimumValue; }
88 
89  ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const { return mContrastEnhancementAlgorithm; }
90 
91  /*
92  *
93  * Non-Static methods
94  *
95  */
97  int enhanceContrast( double );
98 
100  bool isValueInDisplayableRange( double );
101 
103  void setContrastEnhancementAlgorithm( ContrastEnhancementAlgorithm, bool generateTable = true );
104 
106  void setContrastEnhancementFunction( QgsContrastEnhancementFunction* );
107 
109  void setMaximumValue( double, bool generateTable = true );
110 
112  void setMinimumValue( double, bool generateTable = true );
113 
114  void writeXml( QDomDocument& doc, QDomElement& parentElem ) const;
115 
116  void readXml( const QDomElement& elem );
117 
118  private:
120  ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm;
121 
123  QgsContrastEnhancementFunction* mContrastEnhancementFunction = nullptr;
124 
126  bool mEnhancementDirty;
127 
129  double mLookupTableOffset;
130 
132  int *mLookupTable = nullptr;
133 
135  double mMinimumValue;
136 
138  double mMaximumValue;
139 
141  Qgis::DataType mRasterDataType;
142 
144  double mRasterDataTypeRange;
145 
147  bool generateLookupTable();
148 
150  int calculateContrastEnhancementValue( double );
151 
152 };
153 
154 #endif
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const
DataType
Raster data types.
Definition: qgis.h:61
A contrast enhancement function is the base class for all raster contrast enhancements.
double minimumValue() const
Return the minimum value for the contrast enhancement range.
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used...
double maximumValue() const
Return the maximum value for the contrast enhancement range.
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range...
Eight bit unsigned integer (quint8)
Definition: qgis.h:64