QGIS API Documentation  3.0.2-Girona (307d082)
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 
42 class CORE_EXPORT QgsContrastEnhancement
43 {
44 
45  public:
46 
49  {
50  NoEnhancement, //this should be the default color scaling algorithm
51  StretchToMinimumMaximum, //linear histogram enhanceContrast
54  UserDefinedEnhancement
55  };
56 
60 
61  const QgsContrastEnhancement &operator=( const QgsContrastEnhancement & ) = delete;
62 
63  /*
64  *
65  * Static methods
66  *
67  */
69  static double maximumValuePossible( Qgis::DataType );
70 
72  static double minimumValuePossible( Qgis::DataType );
73 
75  static QString contrastEnhancementAlgorithmString( ContrastEnhancementAlgorithm algorithm );
76 
78  static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString( const QString &contrastEnhancementString );
79 
80  /*
81  *
82  * Non-Static Inline methods
83  *
84  */
86  double maximumValue() const { return mMaximumValue; }
87 
89  double minimumValue() const { return mMinimumValue; }
90 
91  ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const { return mContrastEnhancementAlgorithm; }
92 
93  /*
94  *
95  * Non-Static methods
96  *
97  */
99  int enhanceContrast( double );
100 
102  bool isValueInDisplayableRange( double );
103 
105  void setContrastEnhancementAlgorithm( ContrastEnhancementAlgorithm, bool generateTable = true );
106 
108  void setContrastEnhancementFunction( QgsContrastEnhancementFunction * );
109 
111  void setMaximumValue( double, bool generateTable = true );
112 
114  void setMinimumValue( double, bool generateTable = true );
115 
116  void writeXml( QDomDocument &doc, QDomElement &parentElem ) const;
117 
118  void readXml( const QDomElement &elem );
119 
120  private:
121 #ifdef SIP_RUN
122  const QgsContrastEnhancement &operator=( const QgsContrastEnhancement & );
123 #endif
124 
126  ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm = NoEnhancement;
127 
129  std::unique_ptr< QgsContrastEnhancementFunction > mContrastEnhancementFunction;
130 
132  bool mEnhancementDirty = false;
133 
135  double mLookupTableOffset;
136 
138  int *mLookupTable = nullptr;
139 
141  double mMinimumValue;
142 
144  double mMaximumValue;
145 
147  Qgis::DataType mRasterDataType;
148 
150  double mRasterDataTypeRange;
151 
153  bool generateLookupTable();
154 
156  int calculateContrastEnhancementValue( double );
157 
158 };
159 
160 #endif
double maximumValue() const
Return the maximum value for the contrast enhancement range.
DataType
Raster data types.
Definition: qgis.h:91
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:94