QGIS API Documentation  2.99.0-Master (7d4f81d)
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 #include <memory>
30 
32 class QDomDocument;
33 class QDomElement;
34 class QString;
35 
41 class CORE_EXPORT QgsContrastEnhancement
42 {
43 
44  public:
45 
48  {
49  NoEnhancement, //this should be the default color scaling algorithm
50  StretchToMinimumMaximum, //linear histogram enhanceContrast
53  UserDefinedEnhancement
54  };
55 
59 
60  const QgsContrastEnhancement &operator=( const QgsContrastEnhancement & ) = delete;
61 
62  /*
63  *
64  * Static methods
65  *
66  */
68  static double maximumValuePossible( Qgis::DataType );
69 
71  static double minimumValuePossible( Qgis::DataType );
72 
74  static QString contrastEnhancementAlgorithmString( ContrastEnhancementAlgorithm algorithm );
75 
77  static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString( const QString &contrastEnhancementString );
78 
79  /*
80  *
81  * Non-Static Inline methods
82  *
83  */
85  double maximumValue() const { return mMaximumValue; }
86 
88  double minimumValue() const { return mMinimumValue; }
89 
90  ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const { return mContrastEnhancementAlgorithm; }
91 
92  /*
93  *
94  * Non-Static methods
95  *
96  */
98  int enhanceContrast( double );
99 
101  bool isValueInDisplayableRange( double );
102 
104  void setContrastEnhancementAlgorithm( ContrastEnhancementAlgorithm, bool generateTable = true );
105 
107  void setContrastEnhancementFunction( QgsContrastEnhancementFunction * );
108 
110  void setMaximumValue( double, bool generateTable = true );
111 
113  void setMinimumValue( double, bool generateTable = true );
114 
115  void writeXml( QDomDocument &doc, QDomElement &parentElem ) const;
116 
117  void readXml( const QDomElement &elem );
118 
119  private:
120 #ifdef SIP_RUN
121  const QgsContrastEnhancement &operator=( const QgsContrastEnhancement & );
122 #endif
123 
125  ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm;
126 
128  std::unique_ptr< QgsContrastEnhancementFunction > mContrastEnhancementFunction;
129 
131  bool mEnhancementDirty;
132 
134  double mLookupTableOffset;
135 
137  int *mLookupTable = nullptr;
138 
140  double mMinimumValue;
141 
143  double mMaximumValue;
144 
146  Qgis::DataType mRasterDataType;
147 
149  double mRasterDataTypeRange;
150 
152  bool generateLookupTable();
153 
155  int calculateContrastEnhancementValue( double );
156 
157 };
158 
159 #endif
double maximumValue() const
Return the maximum value for the contrast enhancement range.
DataType
Raster data types.
Definition: qgis.h:74
double minimumValue() const
Return the minimum value for the contrast enhancement range.
A contrast enhancement function is the base class for all raster contrast enhancements.
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used...
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range...
Eight bit unsigned integer (quint8)
Definition: qgis.h:77