-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Implement raster auto-stretching when updating canvas
This commit implements the improvements described at: https://lists.osgeo.org/pipermail/qgis-developer/2016-September/044393.html The QgsRasterMinMaxWidget now offers a seetting to specify that the statistics should be computed each time the canvas extent changes. Other changes: - the content of the QgsRasterMinMaxWidget is now persistant. - there is no longer any Load button. The global Apply / OK button of the raster properties dialog has this effect. - the default "limits" for single band raster is now MinMax and not CumulativeCut - the default "limits" can be configured for single band, multi band single byte and multi band multi byte - "Strech using current extent" honours the "limits" instead of forcing min/max.
- Loading branch information
Showing
48 changed files
with
1,917 additions
and
889 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/** \class QgsRasterMinMaxOrigin | ||
* This class describes the origin of min/max values. It does not store by | ||
* itself the min/max values. | ||
*/ | ||
|
||
class QgsRasterMinMaxOrigin | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsrasterminmaxorigin.h> | ||
%End | ||
public: | ||
//! \brief Default cumulative cut lower limit | ||
static const double CUMULATIVE_CUT_LOWER; | ||
|
||
//! \brief Default cumulative cut upper limit | ||
static const double CUMULATIVE_CUT_UPPER; | ||
|
||
//! \brief Default standard deviation factor | ||
static const double DEFAULT_STDDEV_FACTOR; | ||
|
||
//! \brief This enumerator describes the limits used to compute min/max values | ||
enum Limits | ||
{ | ||
//! User defined. | ||
None /PyName=None_/, | ||
//! Real min-max values | ||
MinMax, | ||
//! Range is [ mean - stdDevFactor() * stddev, mean + stdDevFactor() * stddev ] | ||
StdDev, | ||
//! Range is [ min + cumulativeCutLower() * (max - min), min + cumulativeCutUpper() * (max - min) ] | ||
CumulativeCut | ||
}; | ||
|
||
//! \brief This enumerator describes the extent used to compute min/max values | ||
enum Extent | ||
{ | ||
//! Whole raster is used to compute statistics. | ||
WholeRaster, | ||
//! Current extent of the canvas (at the time of computation) is used to compute statistics. | ||
CurrentCanvas, | ||
//! Constantly updated extent of the canvas is used to compute statistics. | ||
UpdatedCanvas | ||
}; | ||
|
||
//! \brief This enumerator describes the accuracy used to compute statistics. | ||
enum StatAccuracy | ||
{ | ||
//! Exact statistics. | ||
Exact, | ||
//! Approximated statistics. | ||
Estimated | ||
}; | ||
|
||
//! \brief Default constructor. | ||
QgsRasterMinMaxOrigin(); | ||
|
||
//! \brief Equality operator. | ||
bool operator ==( const QgsRasterMinMaxOrigin& other ) const; | ||
|
||
//////// Getter methods ///////////////////// | ||
|
||
//! \brief Return limits. | ||
QgsRasterMinMaxOrigin::Limits limits() const; | ||
|
||
//! \brief Return extent. | ||
QgsRasterMinMaxOrigin::Extent extent() const; | ||
|
||
//! \brief Return statistic accuracy. | ||
QgsRasterMinMaxOrigin::StatAccuracy statAccuracy() const; | ||
|
||
//! \brief Return lower bound of cumulative cut method (between 0 and 1). | ||
double cumulativeCutLower() const; | ||
|
||
//! \brief Return upper bound of cumulative cut method (between 0 and 1). | ||
double cumulativeCutUpper() const; | ||
|
||
//! \brief Return factor f so that the min/max range is [ mean - f * stddev , mean + f * stddev ] | ||
double stdDevFactor() const; | ||
|
||
//////// Setter methods ///////////////////// | ||
|
||
//! \brief Set limits. | ||
void setLimits(QgsRasterMinMaxOrigin::Limits theLimits); | ||
|
||
//! \brief Set extent. | ||
void setExtent(QgsRasterMinMaxOrigin::Extent theExtent); | ||
|
||
//! \brief Set statistics accuracy. | ||
void setStatAccuracy(QgsRasterMinMaxOrigin::StatAccuracy theAccuracy); | ||
|
||
//! \brief Set lower bound of cumulative cut method (between 0 and 1). | ||
void setCumulativeCutLower(double val); | ||
|
||
//! \brief Set upper bound of cumulative cut method (between 0 and 1). | ||
void setCumulativeCutUpper(double val); | ||
|
||
//! \brief Set factor f so that the min/max range is [ mean - f * stddev , mean + f * stddev ] | ||
void setStdDevFactor(double val); | ||
|
||
//////// XML serialization ///////////////////// | ||
|
||
//! \brief Serialize object. | ||
void writeXml( QDomDocument& doc, QDomElement& parentElem ) const; | ||
|
||
//! \brief Deserialize object. | ||
void readXml( const QDomElement& elem ); | ||
|
||
//////// Static methods ///////////////////// | ||
|
||
//! \brief Return a string to serialize Limits | ||
static QString limitsString( QgsRasterMinMaxOrigin::Limits theLimits ); | ||
|
||
//! \brief Deserialize Limits | ||
static QgsRasterMinMaxOrigin::Limits limitsFromString( const QString& theLimits ); | ||
|
||
//! \brief Return a string to serialize Extent | ||
static QString extentString( QgsRasterMinMaxOrigin::Extent theExtent ); | ||
|
||
//! \brief Deserialize Extent | ||
static QgsRasterMinMaxOrigin::Extent extentFromString( const QString& theExtent ); | ||
|
||
//! \brief Return a string to serialize StatAccuracy | ||
static QString statAccuracyString( QgsRasterMinMaxOrigin::StatAccuracy theAccuracy ); | ||
|
||
//! \brief Deserialize StatAccuracy | ||
static QgsRasterMinMaxOrigin::StatAccuracy statAccuracyFromString( const QString& theAccuracy ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
532eb58
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rouault following this set of commits, QGIS fails to renderer a multi band raster using single band gray renderer.
Steps to reproduce: