new files from raster transparency branch

git-svn-id: http://svn.osgeo.org/qgis/trunk@7927 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
gsherman 2008-01-11 06:42:56 +00:00
parent c73ffbe699
commit 89b8386933
27 changed files with 4031 additions and 0 deletions

View File

@ -0,0 +1,243 @@
class QgsContrastEnhancement
{
%TypeHeaderCode
#include <qgscontrastenhancement.h>
%End
public:
/** \brief This enumerator describes the types of contrast enhancement algorithms that can be used. */
enum CONTRAST_ENHANCEMENT_ALGORITHM
{
NO_STRETCH, //this should be the default color scaling algorithm
STRETCH_TO_MINMAX, //linear histogram stretch
STRETCH_AND_CLIP_TO_MINMAX,
CLIP_TO_MINMAX,
USER_DEFINED
};
/*! These are exactly the same as GDAL pixel data types */
enum QgsRasterDataType {
QGS_Unknown = 0,
/*! Eight bit unsigned integer */ QGS_Byte = 1,
/*! Sixteen bit unsigned integer */ QGS_UInt16 = 2,
/*! Sixteen bit signed integer */ QGS_Int16 = 3,
/*! Thirty two bit unsigned integer */ QGS_UInt32 = 4,
/*! Thirty two bit signed integer */ QGS_Int32 = 5,
/*! Thirty two bit floating point */ QGS_Float32 = 6,
/*! Sixty four bit floating point */ QGS_Float64 = 7,
/*! Complex Int16 */ QGS_CInt16 = 8,
/*! Complex Int32 */ QGS_CInt32 = 9,
/*! Complex Float32 */ QGS_CFloat32 = 10,
/*! Complex Float64 */ QGS_CFloat64 = 11,
QGS_TypeCount = 12 /* maximum type # + 1 */
};
QgsContrastEnhancement(QgsContrastEnhancement::QgsRasterDataType theDatatype=QGS_Byte);
~QgsContrastEnhancement();
/*
*
* Static methods
*
*/
/** \brief Helper function that returns the maximum possible value for a GDAL data type */
static double getMaximumPossibleValue(QgsRasterDataType);
/** \brief Helper function that returns the minimum possible value for a GDAL data type */
static double getMinimumPossibleValue(QgsRasterDataType);
/*
*
* Non-Static Inline methods
*
*/
/** \brief Return the maximum value for the contrast enhancement range. */
double getMaximumValue();
/** \brief Return the minimum value for the contrast enhancement range. */
double getMinimumValue();
CONTRAST_ENHANCEMENT_ALGORITHM getContrastEnhancementAlgorithm();
/*
*
* Non-Static methods
*
*/
/** \brief Return true if pixel is in stretable range, false if pixel is outside of range (i.e., clipped) */
bool isValueInDisplayableRange(double);
/** \brief Set the contrast enhancement algorithm */
void setContrastEnhancementAlgorithm(CONTRAST_ENHANCEMENT_ALGORITHM, bool generateTable=true);
/** \brief A public method that allows the user to set their own custom contrast enhancment function */
void setContrastEnhancementFunction(QgsContrastEnhancementFunction*);
/** \brief Set the maximum value for the contrast enhancement range. */
void setMaximumValue(double, bool generateTable=true);
/** \brief Return the minimum value for the contrast enhancement range. */
void setMinimumValue(double, bool generateTable=true);
/** \brief Apply the contrast enhancement to a value. Return values are 0 - 254, -1 means the pixel was clipped and should not be displayed */
int stretch(double);
};
class QgsContrastEnhancement
{
%TypeHeaderCode
#include <qgscontrastenhancement.h>
%End
public:
/** \brief This enumerator describes the types of contrast enhancement algorithms that can be used. */
enum CONTRAST_ENHANCEMENT_ALGORITHM
{
NO_STRETCH, //this should be the default color scaling algorithm
STRETCH_TO_MINMAX, //linear histogram stretch
STRETCH_AND_CLIP_TO_MINMAX,
CLIP_TO_MINMAX,
USER_DEFINED
};
/*! These are exactly the same as GDAL pixel data types */
enum QgsRasterDataType {
QGS_Unknown = 0,
/*! Eight bit unsigned integer */ QGS_Byte = 1,
/*! Sixteen bit unsigned integer */ QGS_UInt16 = 2,
/*! Sixteen bit signed integer */ QGS_Int16 = 3,
/*! Thirty two bit unsigned integer */ QGS_UInt32 = 4,
/*! Thirty two bit signed integer */ QGS_Int32 = 5,
/*! Thirty two bit floating point */ QGS_Float32 = 6,
/*! Sixty four bit floating point */ QGS_Float64 = 7,
/*! Complex Int16 */ QGS_CInt16 = 8,
/*! Complex Int32 */ QGS_CInt32 = 9,
/*! Complex Float32 */ QGS_CFloat32 = 10,
/*! Complex Float64 */ QGS_CFloat64 = 11,
QGS_TypeCount = 12 /* maximum type # + 1 */
};
QgsContrastEnhancement(QgsContrastEnhancement::QgsRasterDataType theDatatype=QGS_Byte);
~QgsContrastEnhancement();
/*
*
* Static methods
*
*/
/** \brief Helper function that returns the maximum possible value for a GDAL data type */
static double getMaximumPossibleValue(QgsRasterDataType);
/** \brief Helper function that returns the minimum possible value for a GDAL data type */
static double getMinimumPossibleValue(QgsRasterDataType);
/*
*
* Non-Static Inline methods
*
*/
/** \brief Return the maximum value for the contrast enhancement range. */
double getMaximumValue();
/** \brief Return the minimum value for the contrast enhancement range. */
double getMinimumValue();
CONTRAST_ENHANCEMENT_ALGORITHM getContrastEnhancementAlgorithm();
/*
*
* Non-Static methods
*
*/
/** \brief Return true if pixel is in stretable range, false if pixel is outside of range (i.e., clipped) */
bool isValueInDisplayableRange(double);
/** \brief Set the contrast enhancement algorithm */
void setContrastEnhancementAlgorithm(CONTRAST_ENHANCEMENT_ALGORITHM, bool generateTable=true);
/** \brief A public method that allows the user to set their own custom contrast enhancment function */
void setContrastEnhancementFunction(QgsContrastEnhancementFunction*);
/** \brief Set the maximum value for the contrast enhancement range. */
void setMaximumValue(double, bool generateTable=true);
/** \brief Return the minimum value for the contrast enhancement range. */
void setMinimumValue(double, bool generateTable=true);
/** \brief Apply the contrast enhancement to a value. Return values are 0 - 254, -1 means the pixel was clipped and should not be displayed */
int stretch(double);
};
class QgsContrastEnhancement
{
%TypeHeaderCode
#include <qgscontrastenhancement.h>
%End
public:
/** \brief This enumerator describes the types of contrast enhancement algorithms that can be used. */
enum CONTRAST_ENHANCEMENT_ALGORITHM
{
NO_STRETCH, //this should be the default color scaling algorithm
STRETCH_TO_MINMAX, //linear histogram stretch
STRETCH_AND_CLIP_TO_MINMAX,
CLIP_TO_MINMAX,
USER_DEFINED
};
/*! These are exactly the same as GDAL pixel data types */
enum QgsRasterDataType {
QGS_Unknown = 0,
/*! Eight bit unsigned integer */ QGS_Byte = 1,
/*! Sixteen bit unsigned integer */ QGS_UInt16 = 2,
/*! Sixteen bit signed integer */ QGS_Int16 = 3,
/*! Thirty two bit unsigned integer */ QGS_UInt32 = 4,
/*! Thirty two bit signed integer */ QGS_Int32 = 5,
/*! Thirty two bit floating point */ QGS_Float32 = 6,
/*! Sixty four bit floating point */ QGS_Float64 = 7,
/*! Complex Int16 */ QGS_CInt16 = 8,
/*! Complex Int32 */ QGS_CInt32 = 9,
/*! Complex Float32 */ QGS_CFloat32 = 10,
/*! Complex Float64 */ QGS_CFloat64 = 11,
QGS_TypeCount = 12 /* maximum type # + 1 */
};
QgsContrastEnhancement(QgsContrastEnhancement::QgsRasterDataType theDatatype=QGS_Byte);
~QgsContrastEnhancement();
/*
*
* Static methods
*
*/
/** \brief Helper function that returns the maximum possible value for a GDAL data type */
static double getMaximumPossibleValue(QgsRasterDataType);
/** \brief Helper function that returns the minimum possible value for a GDAL data type */
static double getMinimumPossibleValue(QgsRasterDataType);
/*
*
* Non-Static Inline methods
*
*/
/** \brief Return the maximum value for the contrast enhancement range. */
double getMaximumValue();
/** \brief Return the minimum value for the contrast enhancement range. */
double getMinimumValue();
CONTRAST_ENHANCEMENT_ALGORITHM getContrastEnhancementAlgorithm();
/*
*
* Non-Static methods
*
*/
/** \brief Return true if pixel is in stretable range, false if pixel is outside of range (i.e., clipped) */
bool isValueInDisplayableRange(double);
/** \brief Set the contrast enhancement algorithm */
void setContrastEnhancementAlgorithm(CONTRAST_ENHANCEMENT_ALGORITHM, bool generateTable=true);
/** \brief A public method that allows the user to set their own custom contrast enhancment function */
void setContrastEnhancementFunction(QgsContrastEnhancementFunction*);
/** \brief Set the maximum value for the contrast enhancement range. */
void setMaximumValue(double, bool generateTable=true);
/** \brief Return the minimum value for the contrast enhancement range. */
void setMinimumValue(double, bool generateTable=true);
/** \brief Apply the contrast enhancement to a value. Return values are 0 - 254, -1 means the pixel was clipped and should not be displayed */
int stretch(double);
};

View File

@ -0,0 +1,69 @@
class QgsContrastEnhancementFunction
{
%TypeHeaderCode
#include <qgscontrastenhancement.h>
#include <qgscontrastenhancementfunction.h>
%End
public:
QgsContrastEnhancementFunction(QgsContrastEnhancement::QgsRasterDataType, double, double);
virtual ~QgsContrastEnhancementFunction();
/** \brief Mustator for the maximum value */
void setMaximumValue(double);
/** \brief Mutator for the minimum value */
void setMinimumValue(double);
/** \brief A customizable method that takes in a double and returns a int between 0 and 255 */
virtual int enhanceValue(double);
/** \brief A customicable method to indicate if the pixels is displayable */
virtual bool isValueInDisplayableRange(double);
};
class QgsContrastEnhancementFunction
{
%TypeHeaderCode
#include <qgscontrastenhancement.h>
#include <qgscontrastenhancementfunction.h>
%End
public:
QgsContrastEnhancementFunction(QgsContrastEnhancement::QgsRasterDataType, double, double);
virtual ~QgsContrastEnhancementFunction();
/** \brief Mustator for the maximum value */
void setMaximumValue(double);
/** \brief Mutator for the minimum value */
void setMinimumValue(double);
/** \brief A customizable method that takes in a double and returns a int between 0 and 255 */
virtual int enhanceValue(double);
/** \brief A customicable method to indicate if the pixels is displayable */
virtual bool isValueInDisplayableRange(double);
};
class QgsContrastEnhancementFunction
{
%TypeHeaderCode
#include <qgscontrastenhancement.h>
#include <qgscontrastenhancementfunction.h>
%End
public:
QgsContrastEnhancementFunction(QgsContrastEnhancement::QgsRasterDataType, double, double);
virtual ~QgsContrastEnhancementFunction();
/** \brief Mustator for the maximum value */
void setMaximumValue(double);
/** \brief Mutator for the minimum value */
void setMinimumValue(double);
/** \brief A customizable method that takes in a double and returns a int between 0 and 255 */
virtual int enhanceValue(double);
/** \brief A customicable method to indicate if the pixels is displayable */
virtual bool isValueInDisplayableRange(double);
};

View File

@ -0,0 +1,120 @@
class QgsRasterShader
{
%TypeHeaderCode
#include <qgsrastershader.h>
#include <qgsrastershaderfunction.h>
%End
public:
QgsRasterShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
~QgsRasterShader();
/*
*
* Non-Static Inline methods
*
*/
/** \brief Return the maximum value for the raster shader */
double getMaximumValue();
/** \brief Return the minimum value for the raster shader */
double getMinimumValue();
QgsRasterShaderFunction* getRasterShaderFunction();
/*
*
* Non-Static methods
*
*/
/** \brief generates and new RGB value based on one input value */
bool generateShadedValue(double, int*, int*, int*);
/** \brief generates and new RGB value based on original RGB value */
bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief A public method that allows the user to set their own shader function */
void setRasterShaderFunction(QgsRasterShaderFunction*);
/** \brief Set the maximum value */
void setMaximumValue(double);
/** \brief Return the minimum value */
void setMinimumValue(double);
};
class QgsRasterShader
{
%TypeHeaderCode
#include <qgsrastershader.h>
#include <qgsrastershaderfunction.h>
%End
public:
QgsRasterShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
~QgsRasterShader();
/*
*
* Non-Static Inline methods
*
*/
/** \brief Return the maximum value for the raster shader */
double getMaximumValue();
/** \brief Return the minimum value for the raster shader */
double getMinimumValue();
QgsRasterShaderFunction* getRasterShaderFunction();
/*
*
* Non-Static methods
*
*/
/** \brief generates and new RGB value based on one input value */
bool generateShadedValue(double, int*, int*, int*);
/** \brief generates and new RGB value based on original RGB value */
bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief A public method that allows the user to set their own shader function */
void setRasterShaderFunction(QgsRasterShaderFunction*);
/** \brief Set the maximum value */
void setMaximumValue(double);
/** \brief Return the minimum value */
void setMinimumValue(double);
};
class QgsRasterShader
{
%TypeHeaderCode
#include <qgsrastershader.h>
#include <qgsrastershaderfunction.h>
%End
public:
QgsRasterShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
~QgsRasterShader();
/*
*
* Non-Static Inline methods
*
*/
/** \brief Return the maximum value for the raster shader */
double getMaximumValue();
/** \brief Return the minimum value for the raster shader */
double getMinimumValue();
QgsRasterShaderFunction* getRasterShaderFunction();
/*
*
* Non-Static methods
*
*/
/** \brief generates and new RGB value based on one input value */
bool generateShadedValue(double, int*, int*, int*);
/** \brief generates and new RGB value based on original RGB value */
bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief A public method that allows the user to set their own shader function */
void setRasterShaderFunction(QgsRasterShaderFunction*);
/** \brief Set the maximum value */
void setMaximumValue(double);
/** \brief Return the minimum value */
void setMinimumValue(double);
};

View File

@ -0,0 +1,63 @@
class QgsRasterShaderFunction
{
%TypeHeaderCode
#include <qgsrastershaderfunction.h>
%End
public:
QgsRasterShaderFunction(double theMinimumValue = 0.0, double theMaximumValue = 255.0);
virtual ~QgsRasterShaderFunction();
/** \brief generates and new RGB value based on one input value */
virtual bool generateShadedValue(double, int*, int*, int*);
/** \brief generates and new RGB value based on original RGB value */
virtual bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief Set the maximum value */
virtual void setMaximumValue(double);
/** \brief Return the minimum value */
virtual void setMinimumValue(double);
};
class QgsRasterShaderFunction
{
%TypeHeaderCode
#include <qgsrastershaderfunction.h>
%End
public:
QgsRasterShaderFunction(double theMinimumValue = 0.0, double theMaximumValue = 255.0);
virtual ~QgsRasterShaderFunction();
/** \brief generates and new RGB value based on one input value */
virtual bool generateShadedValue(double, int*, int*, int*);
/** \brief generates and new RGB value based on original RGB value */
virtual bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief Set the maximum value */
virtual void setMaximumValue(double);
/** \brief Return the minimum value */
virtual void setMinimumValue(double);
};
class QgsRasterShaderFunction
{
%TypeHeaderCode
#include <qgsrastershaderfunction.h>
%End
public:
QgsRasterShaderFunction(double theMinimumValue = 0.0, double theMaximumValue = 255.0);
virtual ~QgsRasterShaderFunction();
/** \brief generates and new RGB value based on one input value */
virtual bool generateShadedValue(double, int*, int*, int*);
/** \brief generates and new RGB value based on original RGB value */
virtual bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief Set the maximum value */
virtual void setMaximumValue(double);
/** \brief Return the minimum value */
virtual void setMinimumValue(double);
};

View File

@ -0,0 +1,265 @@
class QgsRasterTransparency
{
%TypeHeaderCode
#include <qgsrastertransparency.h>
%End
public:
QgsRasterTransparency();
//
// Structs to hold transparent pixel vlaues
//
struct TransparentThreeValuePixel
{
double red;
double green;
double blue;
double percentTransparent;
};
struct TransparentSingleValuePixel
{
double pixelValue;
double percentTransparent;
};
//
// Initializer, Accessor and mutator for transparency tables.
//
/** \brief Mutator for transparentSingleValuePixelList */
QList<QgsRasterTransparency::TransparentSingleValuePixel> getTransparentSingleValuePixelList();
/** \brief Mutator for transparentThreeValuePixelList */
QList<QgsRasterTransparency::TransparentThreeValuePixel> getTransparentThreeValuePixelList();
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double);
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double, double, double);
/** \brief Accessor for transparentSingleValuePixelList */
void setTransparentSingleValuePixelList(QList<QgsRasterTransparency::TransparentSingleValuePixel>);
/** \brief Accessor for transparentThreeValuePixelList */
void setTransparentThreeValuePixelList(QList<QgsRasterTransparency::TransparentThreeValuePixel>);
/** \brief Returns the transparency value for a single value Pixel */
int getAlphaValue(double, int theGlobalTransparency=255);
/** \brief Return the transparency value for a RGB Pixel */
int getAlphaValue(double, double, double, int theGlobalTransparency=255);
};
class QgsRasterTransparency
{
%TypeHeaderCode
#include <qgsrastertransparency.h>
%End
public:
QgsRasterTransparency();
//
// Structs to hold transparent pixel vlaues
//
struct TransparentThreeValuePixel
{
double red;
double green;
double blue;
double percentTransparent;
};
struct TransparentSingleValuePixel
{
double pixelValue;
double percentTransparent;
};
//
// Initializer, Accessor and mutator for transparency tables.
//
/** \brief Mutator for transparentSingleValuePixelList */
QList<QgsRasterTransparency::TransparentSingleValuePixel> getTransparentSingleValuePixelList();
/** \brief Mutator for transparentThreeValuePixelList */
QList<QgsRasterTransparency::TransparentThreeValuePixel> getTransparentThreeValuePixelList();
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double);
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double, double, double);
/** \brief Accessor for transparentSingleValuePixelList */
void setTransparentSingleValuePixelList(QList<QgsRasterTransparency::TransparentSingleValuePixel>);
/** \brief Accessor for transparentThreeValuePixelList */
void setTransparentThreeValuePixelList(QList<QgsRasterTransparency::TransparentThreeValuePixel>);
/** \brief Returns the transparency value for a single value Pixel */
int getAlphaValue(double, int theGlobalTransparency=255);
/** \brief Return the transparency value for a RGB Pixel */
int getAlphaValue(double, double, double, int theGlobalTransparency=255);
};
class QgsRasterTransparency
{
%TypeHeaderCode
#include <qgsrastertransparency.h>
%End
public:
QgsRasterTransparency();
//
// Structs to hold transparent pixel vlaues
//
struct TransparentThreeValuePixel
{
double red;
double green;
double blue;
double percentTransparent;
};
struct TransparentSingleValuePixel
{
double pixelValue;
double percentTransparent;
};
//
// Initializer, Accessor and mutator for transparency tables.
//
/** \brief Mutator for transparentSingleValuePixelList */
QList<QgsRasterTransparency::TransparentSingleValuePixel> getTransparentSingleValuePixelList();
/** \brief Mutator for transparentThreeValuePixelList */
QList<QgsRasterTransparency::TransparentThreeValuePixel> getTransparentThreeValuePixelList();
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double);
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double, double, double);
/** \brief Accessor for transparentSingleValuePixelList */
void setTransparentSingleValuePixelList(QList<QgsRasterTransparency::TransparentSingleValuePixel>);
/** \brief Accessor for transparentThreeValuePixelList */
void setTransparentThreeValuePixelList(QList<QgsRasterTransparency::TransparentThreeValuePixel>);
/** \brief Returns the transparency value for a single value Pixel */
int getAlphaValue(double, int theGlobalTransparency=255);
/** \brief Return the transparency value for a RGB Pixel */
int getAlphaValue(double, double, double, int theGlobalTransparency=255);
};
class QgsRasterTransparency
{
%TypeHeaderCode
#include <qgsrastertransparency.h>
%End
public:
QgsRasterTransparency();
//
// Structs to hold transparent pixel vlaues
//
struct TransparentThreeValuePixel
{
double red;
double green;
double blue;
double percentTransparent;
};
struct TransparentSingleValuePixel
{
double pixelValue;
double percentTransparent;
};
//
// Initializer, Accessor and mutator for transparency tables.
//
/** \brief Mutator for transparentSingleValuePixelList */
QList<QgsRasterTransparency::TransparentSingleValuePixel> getTransparentSingleValuePixelList();
/** \brief Mutator for transparentThreeValuePixelList */
QList<QgsRasterTransparency::TransparentThreeValuePixel> getTransparentThreeValuePixelList();
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double);
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double, double, double);
/** \brief Accessor for transparentSingleValuePixelList */
void setTransparentSingleValuePixelList(QList<QgsRasterTransparency::TransparentSingleValuePixel>);
/** \brief Accessor for transparentThreeValuePixelList */
void setTransparentThreeValuePixelList(QList<QgsRasterTransparency::TransparentThreeValuePixel>);
/** \brief Returns the transparency value for a single value Pixel */
int getAlphaValue(double, int theGlobalTransparency=255);
/** \brief Return the transparency value for a RGB Pixel */
int getAlphaValue(double, double, double, int theGlobalTransparency=255);
};
class QgsRasterTransparency
{
%TypeHeaderCode
#include <qgsrastertransparency.h>
%End
public:
QgsRasterTransparency();
//
// Structs to hold transparent pixel vlaues
//
struct TransparentThreeValuePixel
{
double red;
double green;
double blue;
double percentTransparent;
};
struct TransparentSingleValuePixel
{
double pixelValue;
double percentTransparent;
};
//
// Initializer, Accessor and mutator for transparency tables.
//
/** \brief Mutator for transparentSingleValuePixelList */
QList<QgsRasterTransparency::TransparentSingleValuePixel> getTransparentSingleValuePixelList();
/** \brief Mutator for transparentThreeValuePixelList */
QList<QgsRasterTransparency::TransparentThreeValuePixel> getTransparentThreeValuePixelList();
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double);
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double, double, double);
/** \brief Accessor for transparentSingleValuePixelList */
void setTransparentSingleValuePixelList(QList<QgsRasterTransparency::TransparentSingleValuePixel>);
/** \brief Accessor for transparentThreeValuePixelList */
void setTransparentThreeValuePixelList(QList<QgsRasterTransparency::TransparentThreeValuePixel>);
/** \brief Returns the transparency value for a single value Pixel */
int getAlphaValue(double, int theGlobalTransparency=255);
/** \brief Return the transparency value for a RGB Pixel */
int getAlphaValue(double, double, double, int theGlobalTransparency=255);
};

View File

@ -0,0 +1,50 @@
/* **************************************************************************
qgscliptominmaxenhancement.cpp - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgscliptominmaxenhancement.h"
QgsClipToMinMaxEnhancement::QgsClipToMinMaxEnhancement(QgsContrastEnhancement::QgsRasterDataType theQgsRasterDataType, double theMinimumValue, double theMaximumValue) : QgsContrastEnhancementFunction(theQgsRasterDataType, theMinimumValue, theMaximumValue)
{
}
int QgsClipToMinMaxEnhancement::enhanceValue(double theValue)
{
if(theValue < mMinimumValue || theValue > mMaximumValue)
{
return -1;
}
if(mQgsRasterDataType == QgsContrastEnhancement::QGS_Byte)
{
return static_cast<int>(theValue);
}
else
{
return static_cast<int>((((theValue - QgsContrastEnhancement::getMinimumPossibleValue(mQgsRasterDataType))/(QgsContrastEnhancement::getMaximumPossibleValue(mQgsRasterDataType) - QgsContrastEnhancement::getMinimumPossibleValue(mQgsRasterDataType)))*255.0));
}
}
bool QgsClipToMinMaxEnhancement::isValueInDisplayableRange(double theValue)
{
if(theValue < mMinimumValue || theValue > mMaximumValue)
{
return false;
}
return true;
}

View File

@ -0,0 +1,99 @@
/* **************************************************************************
qgscliptominmaxenhancement.h - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSCLIPTOMINMAXENHANCEMENT_H
#define QGSCLIPTOMINMAXENHANCEMENT_H
#include "qgscontrastenhancementfunction.h"
class CORE_EXPORT QgsClipToMinMaxEnhancement : public QgsContrastEnhancementFunction
{
public:
QgsClipToMinMaxEnhancement(QgsContrastEnhancement::QgsRasterDataType, double, double);
int enhanceValue(double);
bool isValueInDisplayableRange(double);
};
#endif
/* **************************************************************************
qgscliptominmaxenhancement.h - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSCLIPTOMINMAXENHANCEMENT_H
#define QGSCLIPTOMINMAXENHANCEMENT_H
#include "qgscontrastenhancementfunction.h"
class CORE_EXPORT QgsClipToMinMaxEnhancement : public QgsContrastEnhancementFunction
{
public:
QgsClipToMinMaxEnhancement(QgsContrastEnhancement::QgsRasterDataType, double, double);
int enhanceValue(double);
bool isValueInDisplayableRange(double);
};
#endif
/* **************************************************************************
qgscliptominmaxenhancement.h - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSCLIPTOMINMAXENHANCEMENT_H
#define QGSCLIPTOMINMAXENHANCEMENT_H
#include "qgscontrastenhancementfunction.h"
class CORE_EXPORT QgsClipToMinMaxEnhancement : public QgsContrastEnhancementFunction
{
public:
QgsClipToMinMaxEnhancement(QgsContrastEnhancement::QgsRasterDataType, double, double);
int enhanceValue(double);
bool isValueInDisplayableRange(double);
};
#endif

View File

@ -0,0 +1,113 @@
/* **************************************************************************
qgscolorrampshader.cpp - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class is based off of code that was originally written by Marco Hugentobler and
originally part of the larger QgsRasterLayer class
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgslogger.h"
#include "qgscolorrampshader.h"
QgsColorRampShader::QgsColorRampShader(double theMinimumValue, double theMaximumValue) : QgsRasterShaderFunction(theMinimumValue, theMaximumValue)
{
#ifdef QGISDEBUG
QgsDebugMsg("QgsColorRampShader::QgsColorRampShader called");
#endif
}
bool QgsColorRampShader::generateShadedValue(double theValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue)
{
if(QgsColorRampShader::DISCRETE == mColorRampType)
{
return getDiscreteColor(theValue, theReturnRedValue, theReturnGreenValue, theReturnBlueValue);
}
return getInterpolatedColor(theValue, theReturnRedValue, theReturnGreenValue, theReturnBlueValue);
}
bool QgsColorRampShader::generateShadedValue(double theRedValue, double theGreenValue, double theBlueValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue)
{
*theReturnRedValue = 0;
*theReturnGreenValue = 0;
*theReturnBlueValue = 0;
return false;
}
bool QgsColorRampShader::getDiscreteColor(double theValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue)
{
if(mColorRampItemList.count() <= 0)
{
return false;
}
QList<QgsColorRampShader::ColorRampItem>::const_iterator it;
QList<QgsColorRampShader::ColorRampItem>::const_iterator last_it = mColorRampItemList.begin();
double myCurrentRampValue;
for(it = mColorRampItemList.begin(); it != mColorRampItemList.end(); ++it)
{
myCurrentRampValue = it->value;
if(theValue <= myCurrentRampValue)
{
if(last_it != mColorRampItemList.end())
{
*theReturnRedValue = last_it->color.red();
*theReturnGreenValue = last_it->color.green();
*theReturnBlueValue = last_it->color.blue();
return true;
}
}
last_it = it;
}
return false; // value not found
}
bool QgsColorRampShader::getInterpolatedColor(double theValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue)
{
if(mColorRampItemList.count() <= 0)
{
return false;
}
QList<QgsColorRampShader::ColorRampItem>::const_iterator it;
QList<QgsColorRampShader::ColorRampItem>::const_iterator last_it = mColorRampItemList.end();
double myCurrentRampValue;
double myCurrentRampRange; //difference between two consecutive entry values
double myDiffTheValueLastRampValue; //difference between value and last entry value
double myDiffCurrentRampValueTheValue; //difference between this entry value and value
for(it = mColorRampItemList.begin(); it != mColorRampItemList.end(); ++it)
{
myCurrentRampValue = it->value;
if(theValue <= myCurrentRampValue)
{
if(last_it != mColorRampItemList.end())
{
myCurrentRampRange = myCurrentRampValue - last_it->value;
myDiffTheValueLastRampValue = theValue - last_it->value;
myDiffCurrentRampValueTheValue = myCurrentRampValue - theValue;
*theReturnRedValue = (int)((it->color.red() * myDiffTheValueLastRampValue + last_it->color.red() * myDiffCurrentRampValueTheValue)/myCurrentRampRange);
*theReturnGreenValue = (int)((it->color.green() * myDiffTheValueLastRampValue + last_it->color.green() * myDiffCurrentRampValueTheValue)/myCurrentRampRange);
*theReturnBlueValue = (int)((it->color.blue() * myDiffTheValueLastRampValue + last_it->color.blue() * myDiffCurrentRampValueTheValue)/myCurrentRampRange);
return true;
}
}
last_it = it;
}
return false;
}

View File

@ -0,0 +1,234 @@
/* **************************************************************************
qgscolorrampshader.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class is based off of code that was originally written by Marco Hugentobler and
originally part of the larger QgsRasterLayer class
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSCOLORRAMPSHADER_H
#define QGSCOLORRAMPSHADER_H
#include <QColor>
#include "qgsrastershaderfunction.h"
class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction {
public:
QgsColorRampShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
//An entry for classification based upon value.
//Such a classification is typically used for
//single band layers where a pixel value represents
//not a color but a quantity, e.g. temperature or elevation
struct ColorRampItem
{
QString label;
double value;
QColor color;
};
enum COLOR_RAMP_TYPE {
INTERPOLATED,
DISCRETE
};
bool generateShadedValue(double, int*, int*, int*);
bool generateShadedValue(double, double, double, int*, int*, int*);
/** Get the custom colormap*/
QList<QgsColorRampShader::ColorRampItem> getColorRampItemList() const {return mColorRampItemList;}
/**Get the color ramp type */
QgsColorRampShader::COLOR_RAMP_TYPE getColorRampType() {return mColorRampType;}
/**Set custom colormap */
void setColorRampItemList(const QList<QgsColorRampShader::ColorRampItem>& theList) { mColorRampItemList = theList; }
/**Set discrete/interpolated colors for custom classification*/
void setColorRampType(QgsColorRampShader::COLOR_RAMP_TYPE theColorRampType) {mColorRampType = theColorRampType;}
private:
/**Gets the color for a pixel value from the classification vector mValueClassification. Assigns the color of the lower class for every pixel between two class breaks.*/
bool getDiscreteColor(double, int*, int*, int*);
/**Gets the color for a pixel value from the classification vector mValueClassification. Interpolates the color between two class breaks linearly.*/
bool getInterpolatedColor(double, int*, int*, int*);
/**This vector holds the information for classification based on values. Each item holds a value, a label and a color. The member mDiscreteClassification holds if one color is applied for all values between two class breaks (true) or if the item values are (linearly) interpolated for values between the item values (false)*/
QList<QgsColorRampShader::ColorRampItem> mColorRampItemList;
QgsColorRampShader::COLOR_RAMP_TYPE mColorRampType;
};
#endif
/* **************************************************************************
qgscolorrampshader.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class is based off of code that was originally written by Marco Hugentobler and
originally part of the larger QgsRasterLayer class
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSCOLORRAMPSHADER_H
#define QGSCOLORRAMPSHADER_H
#include <QColor>
#include "qgsrastershaderfunction.h"
class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction {
public:
QgsColorRampShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
//An entry for classification based upon value.
//Such a classification is typically used for
//single band layers where a pixel value represents
//not a color but a quantity, e.g. temperature or elevation
struct ColorRampItem
{
QString label;
double value;
QColor color;
};
enum COLOR_RAMP_TYPE {
INTERPOLATED,
DISCRETE
};
bool generateShadedValue(double, int*, int*, int*);
bool generateShadedValue(double, double, double, int*, int*, int*);
/** Get the custom colormap*/
QList<QgsColorRampShader::ColorRampItem> getColorRampItemList() const {return mColorRampItemList;}
/**Get the color ramp type */
QgsColorRampShader::COLOR_RAMP_TYPE getColorRampType() {return mColorRampType;}
/**Set custom colormap */
void setColorRampItemList(const QList<QgsColorRampShader::ColorRampItem>& theList) { mColorRampItemList = theList; }
/**Set discrete/interpolated colors for custom classification*/
void setColorRampType(QgsColorRampShader::COLOR_RAMP_TYPE theColorRampType) {mColorRampType = theColorRampType;}
private:
/**Gets the color for a pixel value from the classification vector mValueClassification. Assigns the color of the lower class for every pixel between two class breaks.*/
bool getDiscreteColor(double, int*, int*, int*);
/**Gets the color for a pixel value from the classification vector mValueClassification. Interpolates the color between two class breaks linearly.*/
bool getInterpolatedColor(double, int*, int*, int*);
/**This vector holds the information for classification based on values. Each item holds a value, a label and a color. The member mDiscreteClassification holds if one color is applied for all values between two class breaks (true) or if the item values are (linearly) interpolated for values between the item values (false)*/
QList<QgsColorRampShader::ColorRampItem> mColorRampItemList;
QgsColorRampShader::COLOR_RAMP_TYPE mColorRampType;
};
#endif
/* **************************************************************************
qgscolorrampshader.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class is based off of code that was originally written by Marco Hugentobler and
originally part of the larger QgsRasterLayer class
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSCOLORRAMPSHADER_H
#define QGSCOLORRAMPSHADER_H
#include <QColor>
#include "qgsrastershaderfunction.h"
class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction {
public:
QgsColorRampShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
//An entry for classification based upon value.
//Such a classification is typically used for
//single band layers where a pixel value represents
//not a color but a quantity, e.g. temperature or elevation
struct ColorRampItem
{
QString label;
double value;
QColor color;
};
enum COLOR_RAMP_TYPE {
INTERPOLATED,
DISCRETE
};
bool generateShadedValue(double, int*, int*, int*);
bool generateShadedValue(double, double, double, int*, int*, int*);
/** Get the custom colormap*/
QList<QgsColorRampShader::ColorRampItem> getColorRampItemList() const {return mColorRampItemList;}
/**Get the color ramp type */
QgsColorRampShader::COLOR_RAMP_TYPE getColorRampType() {return mColorRampType;}
/**Set custom colormap */
void setColorRampItemList(const QList<QgsColorRampShader::ColorRampItem>& theList) { mColorRampItemList = theList; }
/**Set discrete/interpolated colors for custom classification*/
void setColorRampType(QgsColorRampShader::COLOR_RAMP_TYPE theColorRampType) {mColorRampType = theColorRampType;}
private:
/**Gets the color for a pixel value from the classification vector mValueClassification. Assigns the color of the lower class for every pixel between two class breaks.*/
bool getDiscreteColor(double, int*, int*, int*);
/**Gets the color for a pixel value from the classification vector mValueClassification. Interpolates the color between two class breaks linearly.*/
bool getInterpolatedColor(double, int*, int*, int*);
/**This vector holds the information for classification based on values. Each item holds a value, a label and a color. The member mDiscreteClassification holds if one color is applied for all values between two class breaks (true) or if the item values are (linearly) interpolated for values between the item values (false)*/
QList<QgsColorRampShader::ColorRampItem> mColorRampItemList;
QgsColorRampShader::COLOR_RAMP_TYPE mColorRampType;
};
#endif

View File

@ -0,0 +1,330 @@
/* **************************************************************************
qgscontrastenhancement.cpp - description
-------------------
begin : Mon Oct 22 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class contains code that was originally part of the larger QgsRasterLayer
class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgscontrastenhancement.h"
#include "qgscontrastenhancementfunction.h"
#include "qgslinearminmaxenhancement.h"
#include "qgslinearminmaxenhancementwithclip.h"
#include "qgscliptominmaxenhancement.h"
QgsContrastEnhancement::QgsContrastEnhancement(QgsRasterDataType theDataType)
{
mLookupTable = 0;
mContrastEnhancementFunction = 0;
mEnhancementDirty = false;
mContrastEnhancementAlgorithm = NO_STRETCH;
mRasterDataType = theDataType;
mMinimumValue = getMinimumPossibleValue(mRasterDataType);
mMaximumValue = getMaximumPossibleValue(mRasterDataType);
mRasterDataTypeRange = mMaximumValue - mMinimumValue;
mLookupTableOffset = mMinimumValue * -1;
mContrastEnhancementFunction = new QgsContrastEnhancementFunction(mRasterDataType, mMinimumValue, mMaximumValue);
//If the data type is larger than 16-bit do not generate a lookup table
if(mRasterDataTypeRange <= 65535.0)
{
mLookupTable = new int[static_cast <int>(mRasterDataTypeRange)];
}
}
QgsContrastEnhancement::~QgsContrastEnhancement()
{
}
/*
*
* Static methods
*
*/
/**
Simple function to compute the maximum possible value for a data types.
*/
double QgsContrastEnhancement::getMaximumPossibleValue(QgsRasterDataType theDataType)
{
switch(theDataType)
{
case QGS_Byte:
return std::numeric_limits<unsigned char>::max();
break;
case QGS_UInt16:
return std::numeric_limits<unsigned short>::max();
break;
case QGS_Int16:
return std::numeric_limits<short>::max();
break;
case QGS_UInt32:
return std::numeric_limits<unsigned int>::max();
break;
case QGS_Int32:
return std::numeric_limits<int>::max();
break;
case QGS_Float32:
return std::numeric_limits<float>::max();
break;
case QGS_Float64:
return std::numeric_limits<double>::max();
break;
case QGS_CInt16:
return std::numeric_limits<short>::max();
break;
case QGS_CInt32:
return std::numeric_limits<int>::max();
break;
case QGS_CFloat32:
return std::numeric_limits<float>::max();
break;
case QGS_CFloat64:
return std::numeric_limits<double>::max();
break;
}
return std::numeric_limits<double>::max();
}
/**
Simple function to compute the minimum possible value for a data type.
*/
double QgsContrastEnhancement::getMinimumPossibleValue(QgsRasterDataType theDataType)
{
switch(theDataType)
{
case QGS_Byte:
return std::numeric_limits<unsigned char>::min();
break;
case QGS_UInt16:
return std::numeric_limits<unsigned short>::min();
break;
case QGS_Int16:
return std::numeric_limits<short>::min();
break;
case QGS_UInt32:
return std::numeric_limits<unsigned int>::min();
break;
case QGS_Int32:
return std::numeric_limits<int>::min();
break;
case QGS_Float32:
return std::numeric_limits<float>::max() * -1.0;
break;
case QGS_Float64:
return std::numeric_limits<double>::max() * -1.0;
break;
case QGS_CInt16:
return std::numeric_limits<short>::min();
break;
case QGS_CInt32:
return std::numeric_limits<int>::min();
break;
case QGS_CFloat32:
return std::numeric_limits<float>::max() * -1.0;
break;
case QGS_CFloat64:
return std::numeric_limits<double>::max() * -1.0;
break;
}
return std::numeric_limits<double>::max() * -1.0;
}
/*
*
* Non-Static methods
*
*/
/**
Generate a new lookup table
*/
bool QgsContrastEnhancement::generateLookupTable()
{
mEnhancementDirty = false;
if(0 == mContrastEnhancementFunction) { return false; }
if(NO_STRETCH == mContrastEnhancementAlgorithm) { return false; }
if(QGS_Byte != mRasterDataType && QGS_UInt16 != mRasterDataType && QGS_Int16 != mRasterDataType) { return false; }
if(!mLookupTable) { return false; }
for(int myIterator = 0; myIterator < mRasterDataTypeRange; myIterator++)
{
mLookupTable[myIterator] = mContrastEnhancementFunction->enhanceValue((double)myIterator - mLookupTableOffset);
}
return true;
}
/**
Determine if a pixel is within in the displayable range.
@param theValue The pixel value to examine
*/
bool QgsContrastEnhancement::isValueInDisplayableRange(double theValue)
{
if(0 != mContrastEnhancementFunction)
{
return mContrastEnhancementFunction->isValueInDisplayableRange(theValue);
}
return false;
}
/**
Set the contrast enhancement algorithm. The second parameter is optional and is for performace improvements. If you know you are immediately going to set the Minimum or Maximum value, you can elect to not generate the lookup tale. By default it will be generated.
@param theAlgorithm The new contrast enhancement algorithm
@param generateTable Flag to overide automatic look up table generation
*/
void QgsContrastEnhancement::setContrastEnhancementAlgorithm(CONTRAST_ENHANCEMENT_ALGORITHM theAlgorithm, bool generateTable)
{
if(theAlgorithm != mContrastEnhancementAlgorithm )
{
switch(theAlgorithm)
{
case STRETCH_TO_MINMAX :
mContrastEnhancementFunction = new QgsLinearMinMaxEnhancement(mRasterDataType, mMinimumValue, mMaximumValue);
break;
case STRETCH_AND_CLIP_TO_MINMAX :
mContrastEnhancementFunction = new QgsLinearMinMaxEnhancementWithClip(mRasterDataType, mMinimumValue, mMaximumValue);
break;
case CLIP_TO_MINMAX :
mContrastEnhancementFunction = new QgsClipToMinMaxEnhancement(mRasterDataType, mMinimumValue, mMaximumValue);
break;
case USER_DEFINED :
//Do nothing
break;
default:
mContrastEnhancementFunction = new QgsContrastEnhancementFunction(mRasterDataType, mMinimumValue, mMaximumValue);
break;
}
mEnhancementDirty = true;
mContrastEnhancementAlgorithm = theAlgorithm;
if(generateTable)
{
generateLookupTable();
}
}
}
/**
A public function that allows the user to set their own custom contrast enhancement function.
@param theFunction The new contrast enhancement function
*/
void QgsContrastEnhancement::setContrastEnhancementFunction(QgsContrastEnhancementFunction* theFunction)
{
if(0 != theFunction)
{
mContrastEnhancementFunction = theFunction;
mContrastEnhancementAlgorithm = USER_DEFINED;
generateLookupTable();
}
}
/**
Set the maximum value for the contrast enhancement. The second parameter is option an is for performace improvements. If you know you are immediately going to set the Minimum value or the contrast enhancement algorithm, you can elect to not generate the lookup tale. By default it will be generated.
@param theValue The new maximum value for the band
@param generateTable Flag to overide automatic look up table generation
*/
void QgsContrastEnhancement::setMaximumValue(double theValue, bool generateTable)
{
if(theValue > getMaximumPossibleValue(mRasterDataType))
{
mMaximumValue = getMaximumPossibleValue(mRasterDataType);
}
else
{
mMaximumValue = theValue;
}
if(0 != mContrastEnhancementFunction)
{
mContrastEnhancementFunction->setMaximumValue(theValue);
}
mEnhancementDirty = true;
if(generateTable)
{
generateLookupTable();
}
}
/**
Set the maximum value for the contrast enhancement. The second parameter is option an is for performace improvements. If you know you are immediately going to set the Maximum value or the contrast enhancement algorithm, you can elect to not generate the lookup tale. By default it will be generated.
@param theValue The new minimum value for the band
@param generateTable Flag to overide automatic look up table generation
*/
void QgsContrastEnhancement::setMinimumValue(double theValue, bool generateTable)
{
if(theValue < getMinimumPossibleValue(mRasterDataType))
{
mMinimumValue = getMinimumPossibleValue(mRasterDataType);
}
else
{
mMinimumValue = theValue;
}
if(0 != mContrastEnhancementFunction)
{
mContrastEnhancementFunction->setMinimumValue(theValue);
}
mEnhancementDirty = true;
if(generateTable)
{
generateLookupTable();
}
}
/**
Public function to generate the enhanced for stretched value for a given input.
@param theValue The pixel value to enhance
*/
int QgsContrastEnhancement::stretch(double theValue)
{
if(mEnhancementDirty)
{
generateLookupTable();
}
if(mLookupTable && NO_STRETCH != mContrastEnhancementAlgorithm)
{
return mLookupTable[static_cast <int>(theValue)];
}
else
{
// Even if the contrast enhancement algorithms is set to NO_STRETCH
// The input values will still have to be scaled for all data types
// greater than 1 byte.
return mContrastEnhancementFunction->enhanceValue(theValue);
}
}

View File

@ -0,0 +1,411 @@
/* **************************************************************************
qgscontrastenhancement.h - description
-------------------
begin : Mon Oct 22 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class contains code that was originally part of the larger QgsRasterLayer
class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSCONTRASTENHANCEMENT_H
#define QGSCONTRASTENHANCEMENT_H
#include <limits>
class QgsContrastEnhancementFunction;
class CORE_EXPORT QgsContrastEnhancement {
public:
/** \brief This enumerator describes the types of contrast enhancement algorithms that can be used. */
enum CONTRAST_ENHANCEMENT_ALGORITHM
{
NO_STRETCH, //this should be the default color scaling algorithm
STRETCH_TO_MINMAX, //linear histogram stretch
STRETCH_AND_CLIP_TO_MINMAX,
CLIP_TO_MINMAX,
USER_DEFINED
};
/** These are exactly the same as GDAL pixel data types
** This was added so that the python bindings could be built,
** which initially was a problem because GDALDataType was passed
** around as an argument to numerous method, including the constructor.
**
** It seems like there should be a better way to do this...
*/
typedef enum QgsRasterDataType {
QGS_Unknown = 0,
/*! Eight bit unsigned integer */ QGS_Byte = 1,
/*! Sixteen bit unsigned integer */ QGS_UInt16 = 2,
/*! Sixteen bit signed integer */ QGS_Int16 = 3,
/*! Thirty two bit unsigned integer */ QGS_UInt32 = 4,
/*! Thirty two bit signed integer */ QGS_Int32 = 5,
/*! Thirty two bit floating point */ QGS_Float32 = 6,
/*! Sixty four bit floating point */ QGS_Float64 = 7,
/*! Complex Int16 */ QGS_CInt16 = 8,
/*! Complex Int32 */ QGS_CInt32 = 9,
/*! Complex Float32 */ QGS_CFloat32 = 10,
/*! Complex Float64 */ QGS_CFloat64 = 11,
QGS_TypeCount = 12 /* maximum type # + 1 */
};
QgsContrastEnhancement(QgsContrastEnhancement::QgsRasterDataType theDatatype=QGS_Byte);
~QgsContrastEnhancement();
/*
*
* Static methods
*
*/
/** \brief Helper function that returns the maximum possible value for a GDAL data type */
static double getMaximumPossibleValue(QgsRasterDataType);
/** \brief Helper function that returns the minimum possible value for a GDAL data type */
static double getMinimumPossibleValue(QgsRasterDataType);
/*
*
* Non-Static Inline methods
*
*/
/** \brief Return the maximum value for the contrast enhancement range. */
double getMaximumValue() { return mMaximumValue; }
/** \brief Return the minimum value for the contrast enhancement range. */
double getMinimumValue() { return mMinimumValue; }
CONTRAST_ENHANCEMENT_ALGORITHM getContrastEnhancementAlgorithm() { return mContrastEnhancementAlgorithm; }
/*
*
* Non-Static methods
*
*/
/** \brief Return true if pixel is in stretable range, false if pixel is outside of range (i.e., clipped) */
bool isValueInDisplayableRange(double);
/** \brief Set the contrast enhancement algorithm */
void setContrastEnhancementAlgorithm(CONTRAST_ENHANCEMENT_ALGORITHM, bool generateTable=true);
/** \brief A public method that allows the user to set their own custom contrast enhancment function */
void setContrastEnhancementFunction(QgsContrastEnhancementFunction*);
/** \brief Set the maximum value for the contrast enhancement range. */
void setMaximumValue(double, bool generateTable=true);
/** \brief Return the minimum value for the contrast enhancement range. */
void setMinimumValue(double, bool generateTable=true);
/** \brief Apply the contrast enhancement to a value. Return values are 0 - 254, -1 means the pixel was clipped and should not be displayed */
int stretch(double);
private:
/** \brief Current contrast enhancement algorithm */
CONTRAST_ENHANCEMENT_ALGORITHM mContrastEnhancementAlgorithm;
/** \brief Data type of the band */
QgsRasterDataType mRasterDataType;
/** \brief Maximum range of values for a given data type */
double mRasterDataTypeRange;
/** \brief Flag indicating if the lookup table needs to be regenerated */
bool mEnhancementDirty;
QgsContrastEnhancementFunction* mContrastEnhancementFunction;
/** \brief User defineable minimum value for the band, used for stretching */
double mMinimumValue;
/** \brief user defineable maximum value for the band, used for stretching */
double mMaximumValue;
/** \brief Scalar so that values can be used as array indicies */
double mLookupTableOffset;
/** \brief Pointer to the lookup table */
int *mLookupTable;
/** \brief Method to generate a new lookup table */
bool generateLookupTable();
/** \brief Method to calculate the actual stretched value(s) */
int calculateContrastEnhancementValue(double);
};
#endif
/* **************************************************************************
qgscontrastenhancement.h - description
-------------------
begin : Mon Oct 22 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class contains code that was originally part of the larger QgsRasterLayer
class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSCONTRASTENHANCEMENT_H
#define QGSCONTRASTENHANCEMENT_H
#include <limits>
class QgsContrastEnhancementFunction;
class CORE_EXPORT QgsContrastEnhancement {
public:
/** \brief This enumerator describes the types of contrast enhancement algorithms that can be used. */
enum CONTRAST_ENHANCEMENT_ALGORITHM
{
NO_STRETCH, //this should be the default color scaling algorithm
STRETCH_TO_MINMAX, //linear histogram stretch
STRETCH_AND_CLIP_TO_MINMAX,
CLIP_TO_MINMAX,
USER_DEFINED
};
/** These are exactly the same as GDAL pixel data types
** This was added so that the python bindings could be built,
** which initially was a problem because GDALDataType was passed
** around as an argument to numerous method, including the constructor.
**
** It seems like there should be a better way to do this...
*/
typedef enum QgsRasterDataType {
QGS_Unknown = 0,
/*! Eight bit unsigned integer */ QGS_Byte = 1,
/*! Sixteen bit unsigned integer */ QGS_UInt16 = 2,
/*! Sixteen bit signed integer */ QGS_Int16 = 3,
/*! Thirty two bit unsigned integer */ QGS_UInt32 = 4,
/*! Thirty two bit signed integer */ QGS_Int32 = 5,
/*! Thirty two bit floating point */ QGS_Float32 = 6,
/*! Sixty four bit floating point */ QGS_Float64 = 7,
/*! Complex Int16 */ QGS_CInt16 = 8,
/*! Complex Int32 */ QGS_CInt32 = 9,
/*! Complex Float32 */ QGS_CFloat32 = 10,
/*! Complex Float64 */ QGS_CFloat64 = 11,
QGS_TypeCount = 12 /* maximum type # + 1 */
};
QgsContrastEnhancement(QgsContrastEnhancement::QgsRasterDataType theDatatype=QGS_Byte);
~QgsContrastEnhancement();
/*
*
* Static methods
*
*/
/** \brief Helper function that returns the maximum possible value for a GDAL data type */
static double getMaximumPossibleValue(QgsRasterDataType);
/** \brief Helper function that returns the minimum possible value for a GDAL data type */
static double getMinimumPossibleValue(QgsRasterDataType);
/*
*
* Non-Static Inline methods
*
*/
/** \brief Return the maximum value for the contrast enhancement range. */
double getMaximumValue() { return mMaximumValue; }
/** \brief Return the minimum value for the contrast enhancement range. */
double getMinimumValue() { return mMinimumValue; }
CONTRAST_ENHANCEMENT_ALGORITHM getContrastEnhancementAlgorithm() { return mContrastEnhancementAlgorithm; }
/*
*
* Non-Static methods
*
*/
/** \brief Return true if pixel is in stretable range, false if pixel is outside of range (i.e., clipped) */
bool isValueInDisplayableRange(double);
/** \brief Set the contrast enhancement algorithm */
void setContrastEnhancementAlgorithm(CONTRAST_ENHANCEMENT_ALGORITHM, bool generateTable=true);
/** \brief A public method that allows the user to set their own custom contrast enhancment function */
void setContrastEnhancementFunction(QgsContrastEnhancementFunction*);
/** \brief Set the maximum value for the contrast enhancement range. */
void setMaximumValue(double, bool generateTable=true);
/** \brief Return the minimum value for the contrast enhancement range. */
void setMinimumValue(double, bool generateTable=true);
/** \brief Apply the contrast enhancement to a value. Return values are 0 - 254, -1 means the pixel was clipped and should not be displayed */
int stretch(double);
private:
/** \brief Current contrast enhancement algorithm */
CONTRAST_ENHANCEMENT_ALGORITHM mContrastEnhancementAlgorithm;
/** \brief Data type of the band */
QgsRasterDataType mRasterDataType;
/** \brief Maximum range of values for a given data type */
double mRasterDataTypeRange;
/** \brief Flag indicating if the lookup table needs to be regenerated */
bool mEnhancementDirty;
QgsContrastEnhancementFunction* mContrastEnhancementFunction;
/** \brief User defineable minimum value for the band, used for stretching */
double mMinimumValue;
/** \brief user defineable maximum value for the band, used for stretching */
double mMaximumValue;
/** \brief Scalar so that values can be used as array indicies */
double mLookupTableOffset;
/** \brief Pointer to the lookup table */
int *mLookupTable;
/** \brief Method to generate a new lookup table */
bool generateLookupTable();
/** \brief Method to calculate the actual stretched value(s) */
int calculateContrastEnhancementValue(double);
};
#endif
/* **************************************************************************
qgscontrastenhancement.h - description
-------------------
begin : Mon Oct 22 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class contains code that was originally part of the larger QgsRasterLayer
class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSCONTRASTENHANCEMENT_H
#define QGSCONTRASTENHANCEMENT_H
#include <limits>
class QgsContrastEnhancementFunction;
class CORE_EXPORT QgsContrastEnhancement {
public:
/** \brief This enumerator describes the types of contrast enhancement algorithms that can be used. */
enum CONTRAST_ENHANCEMENT_ALGORITHM
{
NO_STRETCH, //this should be the default color scaling algorithm
STRETCH_TO_MINMAX, //linear histogram stretch
STRETCH_AND_CLIP_TO_MINMAX,
CLIP_TO_MINMAX,
USER_DEFINED
};
/** These are exactly the same as GDAL pixel data types
** This was added so that the python bindings could be built,
** which initially was a problem because GDALDataType was passed
** around as an argument to numerous method, including the constructor.
**
** It seems like there should be a better way to do this...
*/
typedef enum QgsRasterDataType {
QGS_Unknown = 0,
/*! Eight bit unsigned integer */ QGS_Byte = 1,
/*! Sixteen bit unsigned integer */ QGS_UInt16 = 2,
/*! Sixteen bit signed integer */ QGS_Int16 = 3,
/*! Thirty two bit unsigned integer */ QGS_UInt32 = 4,
/*! Thirty two bit signed integer */ QGS_Int32 = 5,
/*! Thirty two bit floating point */ QGS_Float32 = 6,
/*! Sixty four bit floating point */ QGS_Float64 = 7,
/*! Complex Int16 */ QGS_CInt16 = 8,
/*! Complex Int32 */ QGS_CInt32 = 9,
/*! Complex Float32 */ QGS_CFloat32 = 10,
/*! Complex Float64 */ QGS_CFloat64 = 11,
QGS_TypeCount = 12 /* maximum type # + 1 */
};
QgsContrastEnhancement(QgsContrastEnhancement::QgsRasterDataType theDatatype=QGS_Byte);
~QgsContrastEnhancement();
/*
*
* Static methods
*
*/
/** \brief Helper function that returns the maximum possible value for a GDAL data type */
static double getMaximumPossibleValue(QgsRasterDataType);
/** \brief Helper function that returns the minimum possible value for a GDAL data type */
static double getMinimumPossibleValue(QgsRasterDataType);
/*
*
* Non-Static Inline methods
*
*/
/** \brief Return the maximum value for the contrast enhancement range. */
double getMaximumValue() { return mMaximumValue; }
/** \brief Return the minimum value for the contrast enhancement range. */
double getMinimumValue() { return mMinimumValue; }
CONTRAST_ENHANCEMENT_ALGORITHM getContrastEnhancementAlgorithm() { return mContrastEnhancementAlgorithm; }
/*
*
* Non-Static methods
*
*/
/** \brief Return true if pixel is in stretable range, false if pixel is outside of range (i.e., clipped) */
bool isValueInDisplayableRange(double);
/** \brief Set the contrast enhancement algorithm */
void setContrastEnhancementAlgorithm(CONTRAST_ENHANCEMENT_ALGORITHM, bool generateTable=true);
/** \brief A public method that allows the user to set their own custom contrast enhancment function */
void setContrastEnhancementFunction(QgsContrastEnhancementFunction*);
/** \brief Set the maximum value for the contrast enhancement range. */
void setMaximumValue(double, bool generateTable=true);
/** \brief Return the minimum value for the contrast enhancement range. */
void setMinimumValue(double, bool generateTable=true);
/** \brief Apply the contrast enhancement to a value. Return values are 0 - 254, -1 means the pixel was clipped and should not be displayed */
int stretch(double);
private:
/** \brief Current contrast enhancement algorithm */
CONTRAST_ENHANCEMENT_ALGORITHM mContrastEnhancementAlgorithm;
/** \brief Data type of the band */
QgsRasterDataType mRasterDataType;
/** \brief Maximum range of values for a given data type */
double mRasterDataTypeRange;
/** \brief Flag indicating if the lookup table needs to be regenerated */
bool mEnhancementDirty;
QgsContrastEnhancementFunction* mContrastEnhancementFunction;
/** \brief User defineable minimum value for the band, used for stretching */
double mMinimumValue;
/** \brief user defineable maximum value for the band, used for stretching */
double mMaximumValue;
/** \brief Scalar so that values can be used as array indicies */
double mLookupTableOffset;
/** \brief Pointer to the lookup table */
int *mLookupTable;
/** \brief Method to generate a new lookup table */
bool generateLookupTable();
/** \brief Method to calculate the actual stretched value(s) */
int calculateContrastEnhancementValue(double);
};
#endif

View File

@ -0,0 +1,80 @@
/* **************************************************************************
qgscontrastenhancementfunction.cpp - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgscontrastenhancementfunction.h"
QgsContrastEnhancementFunction::QgsContrastEnhancementFunction(QgsContrastEnhancement::QgsRasterDataType theDataType, double theMinimumValue, double theMaximumValue)
{
mQgsRasterDataType = theDataType;
mMaximumValue = theMaximumValue;
mMinimumValue = theMinimumValue;
mMinimumMaximumRange = mMaximumValue - mMinimumValue;
}
void QgsContrastEnhancementFunction::setMaximumValue(double theValue)
{
if(QgsContrastEnhancement::getMaximumPossibleValue(mQgsRasterDataType) < theValue)
{
mMaximumValue = QgsContrastEnhancement::getMaximumPossibleValue(mQgsRasterDataType);
}
else
{
mMaximumValue = theValue;
}
mMinimumMaximumRange = mMaximumValue - mMinimumValue;
}
void QgsContrastEnhancementFunction::setMinimumValue(double theValue)
{
if(QgsContrastEnhancement::getMinimumPossibleValue(mQgsRasterDataType) > theValue)
{
mMinimumValue = QgsContrastEnhancement::getMinimumPossibleValue(mQgsRasterDataType);
}
else
{
mMinimumValue = theValue;
}
mMinimumMaximumRange = mMaximumValue - mMinimumValue;
}
int QgsContrastEnhancementFunction::enhanceValue(double theValue)
{
if(mQgsRasterDataType == QgsContrastEnhancement::QGS_Byte)
{
return static_cast<int>(theValue);
}
else
{
return static_cast<int>((((theValue - QgsContrastEnhancement::getMinimumPossibleValue(mQgsRasterDataType))/(QgsContrastEnhancement::getMaximumPossibleValue(mQgsRasterDataType) - QgsContrastEnhancement::getMinimumPossibleValue(mQgsRasterDataType)))*255.0));
}
return 0;
}
bool QgsContrastEnhancementFunction::isValueInDisplayableRange(double theValue) {
//A default check is to see if the provided value is with the range for the data type
if(theValue < QgsContrastEnhancement::getMinimumPossibleValue(mQgsRasterDataType) || theValue > QgsContrastEnhancement::getMaximumPossibleValue(mQgsRasterDataType))
{
return false;
}
return true;
}

View File

@ -0,0 +1,156 @@
/* **************************************************************************
qgscontrastenhancementfunction.h - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSCONTRASTENHANCEMENTFUNCTION_H
#define QGSCONTRASTENHANCEMENTFUNCTION_H
#include "qgscontrastenhancement.h"
class CORE_EXPORT QgsContrastEnhancementFunction
{
public:
QgsContrastEnhancementFunction(QgsContrastEnhancement::QgsRasterDataType, double, double);
virtual ~QgsContrastEnhancementFunction() {}
/** \brief Mustator for the maximum value */
void setMaximumValue(double);
/** \brief Mutator for the minimum value */
void setMinimumValue(double);
/** \brief A customizable method that takes in a double and returns a int between 0 and 255 */
virtual int enhanceValue(double);
/** \brief A customicable method to indicate if the pixels is displayable */
virtual bool isValueInDisplayableRange(double);
protected:
/** \brief User defineable maximum value for the band, used for stretching */
double mMaximumValue;
/** \brief User defineable minimum value for the band, used for stretching */
double mMinimumValue;
/** \brief Minimum maximum range for the band, used for stretching */
double mMinimumMaximumRange;
/** \brief Data type of the band */
QgsContrastEnhancement::QgsRasterDataType mQgsRasterDataType;
};
#endif
/* **************************************************************************
qgscontrastenhancementfunction.h - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSCONTRASTENHANCEMENTFUNCTION_H
#define QGSCONTRASTENHANCEMENTFUNCTION_H
#include "qgscontrastenhancement.h"
class CORE_EXPORT QgsContrastEnhancementFunction
{
public:
QgsContrastEnhancementFunction(QgsContrastEnhancement::QgsRasterDataType, double, double);
virtual ~QgsContrastEnhancementFunction() {}
/** \brief Mustator for the maximum value */
void setMaximumValue(double);
/** \brief Mutator for the minimum value */
void setMinimumValue(double);
/** \brief A customizable method that takes in a double and returns a int between 0 and 255 */
virtual int enhanceValue(double);
/** \brief A customicable method to indicate if the pixels is displayable */
virtual bool isValueInDisplayableRange(double);
protected:
/** \brief User defineable maximum value for the band, used for stretching */
double mMaximumValue;
/** \brief User defineable minimum value for the band, used for stretching */
double mMinimumValue;
/** \brief Minimum maximum range for the band, used for stretching */
double mMinimumMaximumRange;
/** \brief Data type of the band */
QgsContrastEnhancement::QgsRasterDataType mQgsRasterDataType;
};
#endif
/* **************************************************************************
qgscontrastenhancementfunction.h - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSCONTRASTENHANCEMENTFUNCTION_H
#define QGSCONTRASTENHANCEMENTFUNCTION_H
#include "qgscontrastenhancement.h"
class CORE_EXPORT QgsContrastEnhancementFunction
{
public:
QgsContrastEnhancementFunction(QgsContrastEnhancement::QgsRasterDataType, double, double);
virtual ~QgsContrastEnhancementFunction() {}
/** \brief Mustator for the maximum value */
void setMaximumValue(double);
/** \brief Mutator for the minimum value */
void setMinimumValue(double);
/** \brief A customizable method that takes in a double and returns a int between 0 and 255 */
virtual int enhanceValue(double);
/** \brief A customicable method to indicate if the pixels is displayable */
virtual bool isValueInDisplayableRange(double);
protected:
/** \brief User defineable maximum value for the band, used for stretching */
double mMaximumValue;
/** \brief User defineable minimum value for the band, used for stretching */
double mMinimumValue;
/** \brief Minimum maximum range for the band, used for stretching */
double mMinimumMaximumRange;
/** \brief Data type of the band */
QgsContrastEnhancement::QgsRasterDataType mQgsRasterDataType;
};
#endif

View File

@ -0,0 +1,120 @@
/* **************************************************************************
qgsfreakoutshader.cpp - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class contains code that was originally part of the larger QgsRasterLayer
class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <QDebug>
#include "qgsfreakoutshader.h"
QgsFreakOutShader::QgsFreakOutShader(double theMinimumValue, double theMaximumValue) : QgsRasterShaderFunction(theMinimumValue, theMaximumValue)
{
setClassBreaks();
}
bool QgsFreakOutShader::generateShadedValue(double theValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue)
{
double myPixelValue = theValue;
//double check that myInt >= min and <= max
//this is relevant if we are plotting within stddevs
if ( myPixelValue < mMinimumValue )
{
myPixelValue = mMinimumValue;
}
if ( myPixelValue > mMaximumValue)
{
myPixelValue = mMaximumValue;
}
//check if we are in the first class break
if ((myPixelValue >= mClassBreakMin1) && (myPixelValue < mClassBreakMax1))
{
*theReturnRedValue = 0;
*theReturnGreenValue = static_cast < int >( ( (255 / mMinimumMaximumRange) * (myPixelValue - mClassBreakMin1) ) * 3 );
*theReturnBlueValue = 255;
*theReturnRedValue = 255 - *theReturnGreenValue;
}
//check if we are in the second class break
else if ( (myPixelValue >= mClassBreakMin2) && (myPixelValue < mClassBreakMax2) )
{
*theReturnRedValue = static_cast < int >( ( (255 / mMinimumMaximumRange) * ((myPixelValue - mClassBreakMin2) / 1)) * 3);
*theReturnGreenValue = 255;
*theReturnBlueValue = static_cast < int >(255 - ( ( (255 / mMinimumMaximumRange) * ((myPixelValue - mClassBreakMin2) / 1)) * 3));
*theReturnGreenValue = *theReturnBlueValue;
}
//otherwise we must be in the third classbreak
else
{
*theReturnGreenValue = 255;
*theReturnGreenValue = static_cast < int >(255 - ( ( (255 / mMinimumMaximumRange) * ((myPixelValue - mClassBreakMin3) / 1) * 3)));
*theReturnBlueValue = 0;
*theReturnRedValue = *theReturnGreenValue;
*theReturnGreenValue = 255 - *theReturnGreenValue;
}
return true;
}
bool QgsFreakOutShader::generateShadedValue(double theRedValue, double theGreenValue, double theBlueValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue)
{
*theReturnRedValue = 0;
*theReturnGreenValue = 0;
*theReturnBlueValue = 0;
return false;
}
void QgsFreakOutShader::setClassBreaks()
{
//set up the three class breaks for pseudocolour mapping
mBreakSize = mMinimumMaximumRange / 3;
mClassBreakMin1 = mMinimumValue;
mClassBreakMax1 = mClassBreakMin1 + mBreakSize;
mClassBreakMin2 = mClassBreakMax1;
mClassBreakMax2 = mClassBreakMin2 + mBreakSize;
mClassBreakMin3 = mClassBreakMax2;
}
/**
Set the maximum value for the raster shader.
@param theValue The new maximum value
*/
void QgsFreakOutShader::setMaximumValue(double theValue)
{
mMaximumValue = theValue;
mMinimumMaximumRange = mMaximumValue - mMinimumValue;
setClassBreaks();
}
/**
Set the maximum value for the raster shader
@param theValue The new minimum value
*/
void QgsFreakOutShader::setMinimumValue(double theValue)
{
mMinimumValue = theValue;
mMinimumMaximumRange = mMaximumValue - mMinimumValue;
setClassBreaks();
}

View File

@ -0,0 +1,153 @@
/* **************************************************************************
qgsfreakoutshader.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class contains code that was originally part of the larger QgsRasterLayer
class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSFREAKOUTSHADER_H
#define QGSFREAKOUTSHADER_H
#include "qgsrastershaderfunction.h"
class CORE_EXPORT QgsFreakOutShader : public QgsRasterShaderFunction {
public:
QgsFreakOutShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
bool generateShadedValue(double, int*, int*, int*);
bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief Set the maximum value */
void setMaximumValue(double);
/** \brief Return the minimum value */
void setMinimumValue(double);
private:
void setClassBreaks();
double mBreakSize;
double mClassBreakMin1;
double mClassBreakMax1;
double mClassBreakMin2;
double mClassBreakMax2;
double mClassBreakMin3;
};
#endif
/* **************************************************************************
qgsfreakoutshader.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class contains code that was originally part of the larger QgsRasterLayer
class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSFREAKOUTSHADER_H
#define QGSFREAKOUTSHADER_H
#include "qgsrastershaderfunction.h"
class CORE_EXPORT QgsFreakOutShader : public QgsRasterShaderFunction {
public:
QgsFreakOutShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
bool generateShadedValue(double, int*, int*, int*);
bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief Set the maximum value */
void setMaximumValue(double);
/** \brief Return the minimum value */
void setMinimumValue(double);
private:
void setClassBreaks();
double mBreakSize;
double mClassBreakMin1;
double mClassBreakMax1;
double mClassBreakMin2;
double mClassBreakMax2;
double mClassBreakMin3;
};
#endif
/* **************************************************************************
qgsfreakoutshader.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class contains code that was originally part of the larger QgsRasterLayer
class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSFREAKOUTSHADER_H
#define QGSFREAKOUTSHADER_H
#include "qgsrastershaderfunction.h"
class CORE_EXPORT QgsFreakOutShader : public QgsRasterShaderFunction {
public:
QgsFreakOutShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
bool generateShadedValue(double, int*, int*, int*);
bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief Set the maximum value */
void setMaximumValue(double);
/** \brief Return the minimum value */
void setMinimumValue(double);
private:
void setClassBreaks();
double mBreakSize;
double mClassBreakMin1;
double mClassBreakMax1;
double mClassBreakMin2;
double mClassBreakMax2;
double mClassBreakMin3;
};
#endif

View File

@ -0,0 +1,38 @@
/* **************************************************************************
qgslinearminmaxenhancement.cpp - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgslinearminmaxenhancement.h"
QgsLinearMinMaxEnhancement::QgsLinearMinMaxEnhancement(QgsContrastEnhancement::QgsRasterDataType theQgsRasterDataType, double theMinimumValue, double theMaximumValue) : QgsContrastEnhancementFunction(theQgsRasterDataType, theMinimumValue, theMaximumValue)
{
}
int QgsLinearMinMaxEnhancement::enhanceValue(double theValue)
{
int myStretchedValue = static_cast<int>(((theValue - mMinimumValue)/(mMinimumMaximumRange))*255.0);
if(myStretchedValue < QgsContrastEnhancement::getMinimumPossibleValue(mQgsRasterDataType))
{
return 0;
}
else if(myStretchedValue > QgsContrastEnhancement::getMaximumPossibleValue(mQgsRasterDataType))
{
return static_cast<int>(QgsContrastEnhancement::getMaximumPossibleValue(mQgsRasterDataType));
}
return myStretchedValue;
}

View File

@ -0,0 +1,99 @@
/* **************************************************************************
qgslinearminmaxenhancement.h - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLINEARMINMAXENHANCEMENT_H
#define QGSLINEARMINMAXENHANCEMENT_H
#include "qgscontrastenhancementfunction.h"
class CORE_EXPORT QgsLinearMinMaxEnhancement : public QgsContrastEnhancementFunction
{
public:
QgsLinearMinMaxEnhancement(QgsContrastEnhancement::QgsRasterDataType, double, double);
int enhanceValue(double);
};
#endif
/* **************************************************************************
qgslinearminmaxenhancement.h - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLINEARMINMAXENHANCEMENT_H
#define QGSLINEARMINMAXENHANCEMENT_H
#include "qgscontrastenhancementfunction.h"
class CORE_EXPORT QgsLinearMinMaxEnhancement : public QgsContrastEnhancementFunction
{
public:
QgsLinearMinMaxEnhancement(QgsContrastEnhancement::QgsRasterDataType, double, double);
int enhanceValue(double);
};
#endif
/* **************************************************************************
qgslinearminmaxenhancement.h - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLINEARMINMAXENHANCEMENT_H
#define QGSLINEARMINMAXENHANCEMENT_H
#include "qgscontrastenhancementfunction.h"
class CORE_EXPORT QgsLinearMinMaxEnhancement : public QgsContrastEnhancementFunction
{
public:
QgsLinearMinMaxEnhancement(QgsContrastEnhancement::QgsRasterDataType, double, double);
int enhanceValue(double);
};
#endif

View File

@ -0,0 +1,52 @@
/* **************************************************************************
qgslinearminmaxenhancementwithclip.cpp - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgslinearminmaxenhancementwithclip.h"
QgsLinearMinMaxEnhancementWithClip::QgsLinearMinMaxEnhancementWithClip(QgsContrastEnhancement::QgsRasterDataType theQgsRasterDataType, double theMinimumValue, double theMaximumValue) : QgsContrastEnhancementFunction(theQgsRasterDataType, theMinimumValue, theMaximumValue)
{
}
int QgsLinearMinMaxEnhancementWithClip::enhanceValue(double theValue)
{
if(theValue < mMinimumValue || theValue > mMaximumValue)
{
return -1;
}
int myStretchedValue = static_cast<int>(((theValue - mMinimumValue)/(mMinimumMaximumRange))*255.0);
if(myStretchedValue < QgsContrastEnhancement::getMinimumPossibleValue(mQgsRasterDataType))
{
return 0;
}
else if(myStretchedValue > QgsContrastEnhancement::getMaximumPossibleValue(mQgsRasterDataType))
{
return static_cast<int>(QgsContrastEnhancement::getMaximumPossibleValue(mQgsRasterDataType));
}
return myStretchedValue;
}
bool QgsLinearMinMaxEnhancementWithClip::isValueInDisplayableRange(double theValue)
{
if(theValue < mMinimumValue || theValue > mMaximumValue)
{
return false;
}
return true;
}

View File

@ -0,0 +1,99 @@
/* **************************************************************************
qgslinearminmaxenhancementwithclip.h - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLINEARMINMAXENHANCEMENTWITHCLIP_H
#define QGSLINEARMINMAXENHANCEMENTWITHCLIP_H
#include "qgscontrastenhancementfunction.h"
class CORE_EXPORT QgsLinearMinMaxEnhancementWithClip : public QgsContrastEnhancementFunction
{
public:
QgsLinearMinMaxEnhancementWithClip(QgsContrastEnhancement::QgsRasterDataType, double, double);
int enhanceValue(double);
bool isValueInDisplayableRange(double);
};
#endif
/* **************************************************************************
qgslinearminmaxenhancementwithclip.h - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLINEARMINMAXENHANCEMENTWITHCLIP_H
#define QGSLINEARMINMAXENHANCEMENTWITHCLIP_H
#include "qgscontrastenhancementfunction.h"
class CORE_EXPORT QgsLinearMinMaxEnhancementWithClip : public QgsContrastEnhancementFunction
{
public:
QgsLinearMinMaxEnhancementWithClip(QgsContrastEnhancement::QgsRasterDataType, double, double);
int enhanceValue(double);
bool isValueInDisplayableRange(double);
};
#endif
/* **************************************************************************
qgslinearminmaxenhancementwithclip.h - description
-------------------
begin : Fri Nov 16 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLINEARMINMAXENHANCEMENTWITHCLIP_H
#define QGSLINEARMINMAXENHANCEMENTWITHCLIP_H
#include "qgscontrastenhancementfunction.h"
class CORE_EXPORT QgsLinearMinMaxEnhancementWithClip : public QgsContrastEnhancementFunction
{
public:
QgsLinearMinMaxEnhancementWithClip(QgsContrastEnhancement::QgsRasterDataType, double, double);
int enhanceValue(double);
bool isValueInDisplayableRange(double);
};
#endif

View File

@ -0,0 +1,113 @@
/* **************************************************************************
qgspseudocolorshader.cpp - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class contains code that was originally part of the larger QgsRasterLayer
class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <QDebug>
#include "qgspseudocolorshader.h"
QgsPseudoColorShader::QgsPseudoColorShader(double theMinimumValue, double theMaximumValue) : QgsRasterShaderFunction(theMinimumValue, theMaximumValue)
{
setClassBreaks();
}
bool QgsPseudoColorShader::generateShadedValue(double theValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue)
{
double myPixelValue = theValue;
//double check that myInt >= min and <= max
//this is relevant if we are plotting within stddevs
if ( myPixelValue < mMinimumValue )
{
myPixelValue = mMinimumValue;
}
if ( myPixelValue > mMaximumValue)
{
myPixelValue = mMaximumValue;
}
//check if we are in the first class break
if ((myPixelValue >= mClassBreakMin1) && (myPixelValue < mClassBreakMax1))
{
*theReturnRedValue = 0;
*theReturnGreenValue = static_cast < int >( ( (255 / mMinimumMaximumRange) * (myPixelValue - mClassBreakMin1) ) * 3 );
*theReturnBlueValue = 255;
}
//check if we are in the second class break
else if ( (myPixelValue >= mClassBreakMin2) && (myPixelValue < mClassBreakMax2) )
{
*theReturnRedValue = static_cast < int >( ( (255 / mMinimumMaximumRange) * ((myPixelValue - mClassBreakMin2) / 1)) * 3);
*theReturnGreenValue = 255;
*theReturnBlueValue = static_cast < int >(255 - ( ( (255 / mMinimumMaximumRange) * ((myPixelValue - mClassBreakMin2) / 1)) * 3));
}
//otherwise we must be in the third classbreak
else
{
*theReturnRedValue = 255;
*theReturnGreenValue = static_cast < int >(255 - ( ( (255 / mMinimumMaximumRange) * ((myPixelValue - mClassBreakMin3) / 1) * 3)));
*theReturnBlueValue = 0;
}
return true;
}
bool QgsPseudoColorShader::generateShadedValue(double theRedValue, double theGreenValue, double theBlueValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue)
{
*theReturnRedValue = 0;
*theReturnGreenValue = 0;
*theReturnBlueValue = 0;
return false;
}
void QgsPseudoColorShader::setClassBreaks()
{
//set up the three class breaks for pseudocolour mapping
mBreakSize = mMinimumMaximumRange / 3;
mClassBreakMin1 = mMinimumValue;
mClassBreakMax1 = mClassBreakMin1 + mBreakSize;
mClassBreakMin2 = mClassBreakMax1;
mClassBreakMax2 = mClassBreakMin2 + mBreakSize;
mClassBreakMin3 = mClassBreakMax2;
}
/**
Set the maximum value for the raster shader.
@param theValue The new maximum value
*/
void QgsPseudoColorShader::setMaximumValue(double theValue)
{
mMaximumValue = theValue;
mMinimumMaximumRange = mMaximumValue - mMinimumValue;
setClassBreaks();
}
/**
Set the maximum value for the raster shader
@param theValue The new minimum value
*/
void QgsPseudoColorShader::setMinimumValue(double theValue)
{
mMinimumValue = theValue;
mMinimumMaximumRange = mMaximumValue - mMinimumValue;
setClassBreaks();
}

View File

@ -0,0 +1,153 @@
/* **************************************************************************
qgspseudocolorshader.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class contains code that was originally part of the larger QgsRasterLayer
class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSPSEUDOCOLORSHADER_H
#define QGSPSEUDOCOLORSHADER_H
#include "qgsrastershaderfunction.h"
class CORE_EXPORT QgsPseudoColorShader : public QgsRasterShaderFunction {
public:
QgsPseudoColorShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
bool generateShadedValue(double, int*, int*, int*);
bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief Set the maximum value */
void setMaximumValue(double);
/** \brief Return the minimum value */
void setMinimumValue(double);
private:
void setClassBreaks();
double mBreakSize;
double mClassBreakMin1;
double mClassBreakMax1;
double mClassBreakMin2;
double mClassBreakMax2;
double mClassBreakMin3;
};
#endif
/* **************************************************************************
qgspseudocolorshader.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class contains code that was originally part of the larger QgsRasterLayer
class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSPSEUDOCOLORSHADER_H
#define QGSPSEUDOCOLORSHADER_H
#include "qgsrastershaderfunction.h"
class CORE_EXPORT QgsPseudoColorShader : public QgsRasterShaderFunction {
public:
QgsPseudoColorShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
bool generateShadedValue(double, int*, int*, int*);
bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief Set the maximum value */
void setMaximumValue(double);
/** \brief Return the minimum value */
void setMinimumValue(double);
private:
void setClassBreaks();
double mBreakSize;
double mClassBreakMin1;
double mClassBreakMax1;
double mClassBreakMin2;
double mClassBreakMax2;
double mClassBreakMin3;
};
#endif
/* **************************************************************************
qgspseudocolorshader.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
This class contains code that was originally part of the larger QgsRasterLayer
class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSPSEUDOCOLORSHADER_H
#define QGSPSEUDOCOLORSHADER_H
#include "qgsrastershaderfunction.h"
class CORE_EXPORT QgsPseudoColorShader : public QgsRasterShaderFunction {
public:
QgsPseudoColorShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
bool generateShadedValue(double, int*, int*, int*);
bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief Set the maximum value */
void setMaximumValue(double);
/** \brief Return the minimum value */
void setMinimumValue(double);
private:
void setClassBreaks();
double mBreakSize;
double mClassBreakMin1;
double mClassBreakMax1;
double mClassBreakMin2;
double mClassBreakMax2;
double mClassBreakMin3;
};
#endif

View File

@ -0,0 +1,125 @@
/* **************************************************************************
qgsrastershader.cpp - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgslogger.h"
#include "qgsrastershader.h"
QgsRasterShader::QgsRasterShader(double theMinimumValue, double theMaximumValue)
{
#ifdef QGISDEBUG
QgsDebugMsg("QgsRasterShader::QgsRasterShader called");
#endif
mMinimumValue = theMinimumValue;
mMaximumValue = theMaximumValue;
mRasterShaderFunction = new QgsRasterShaderFunction(mMinimumValue, mMaximumValue);
}
QgsRasterShader::~QgsRasterShader()
{
}
/**
Generates and new RGB value based on one input value
@param theValue The original value to base a new RGB value on
@param theReturnRedValue The red component of the new RGB value
@param theReturnGreenValue The green component of the new RGB value
@param theReturnBlueValue The blue component of the new RGB value
@return True if the return values are valid otherwise false
*/
bool QgsRasterShader::generateShadedValue(double theValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue)
{
if(0 != mRasterShaderFunction)
{
return mRasterShaderFunction->generateShadedValue(theValue, theReturnRedValue, theReturnGreenValue, theReturnBlueValue);
}
return false;
}
/**
Generates and new RGB value based on an original RGB value
@param theRedValue The red component of the original value to base a new RGB value on
@param theGreenValue The green component of the original value to base a new RGB value on
@param theBlueValue The blue component of the original value to base a new RGB value on
@param theReturnRedValue The red component of the new RGB value
@param theReturnGreenValue The green component of the new RGB value
@param theReturnBlueValue The blue component of the new RGB value
@return True if the return values are valid otherwise false
*/
bool QgsRasterShader::generateShadedValue(double theRedValue, double theGreenValue, double theBlueValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue)
{
if(0 != mRasterShaderFunction)
{
return mRasterShaderFunction->generateShadedValue(theRedValue, theGreenValue, theBlueValue, theReturnRedValue, theReturnGreenValue, theReturnBlueValue);
}
return false;
}
/**
A public function that allows the user to set their own custom shader function.
@param theFunction A pointer to the new raster shader function
*/
void QgsRasterShader::setRasterShaderFunction(QgsRasterShaderFunction* theFunction)
{
#ifdef QGISDEBUG
QgsDebugMsg("QgsRasterShader::setRasterShaderFunction called");
#endif
if(0 != theFunction)
{
mRasterShaderFunction = theFunction;
}
}
/**
Set the maximum value for the raster shader.
@param theValue The new maximum value
*/
void QgsRasterShader::setMaximumValue(double theValue)
{
#ifdef QGISDEBUG
QgsDebugMsg("QgsRasterShader::setMaximumValue called - Value = " + QString::number(theValue));
#endif
mMaximumValue = theValue;
if(0 != mRasterShaderFunction)
{
mRasterShaderFunction->setMaximumValue(theValue);
}
}
/**
Set the maximum value for the raster shader
@param theValue The new minimum value
*/
void QgsRasterShader::setMinimumValue(double theValue)
{
#ifdef QGISDEBUG
QgsDebugMsg("QgsRasterShader::setMinimumValue called - Value = " + QString::number(theValue));
#endif
mMinimumValue = theValue;
if(0 != mRasterShaderFunction)
{
mRasterShaderFunction->setMinimumValue(theValue);
}
}

View File

@ -0,0 +1,204 @@
/* **************************************************************************
qgsrastershader.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSRASTERSHADER_H
#define QGSRASTERSHADER_H
#include "qgsrastershaderfunction.h"
class CORE_EXPORT QgsRasterShader {
public:
QgsRasterShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
~QgsRasterShader();
/*
*
* Non-Static Inline methods
*
*/
/** \brief Return the maximum value for the raster shader */
double getMaximumValue() { return mMaximumValue; }
/** \brief Return the minimum value for the raster shader */
double getMinimumValue() { return mMinimumValue; }
QgsRasterShaderFunction* getRasterShaderFunction() { return mRasterShaderFunction; }
/*
*
* Non-Static methods
*
*/
/** \brief generates and new RGB value based on one input value */
bool generateShadedValue(double, int*, int*, int*);
/** \brief generates and new RGB value based on original RGB value */
bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief A public method that allows the user to set their own shader function */
void setRasterShaderFunction(QgsRasterShaderFunction*);
/** \brief Set the maximum value */
void setMaximumValue(double);
/** \brief Return the minimum value */
void setMinimumValue(double);
private:
/** \brief User defineable minimum value for the raster shader */
double mMinimumValue;
/** \brief user defineable maximum value for the raster shader */
double mMaximumValue;
QgsRasterShaderFunction* mRasterShaderFunction;
};
#endif
/* **************************************************************************
qgsrastershader.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSRASTERSHADER_H
#define QGSRASTERSHADER_H
#include "qgsrastershaderfunction.h"
class CORE_EXPORT QgsRasterShader {
public:
QgsRasterShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
~QgsRasterShader();
/*
*
* Non-Static Inline methods
*
*/
/** \brief Return the maximum value for the raster shader */
double getMaximumValue() { return mMaximumValue; }
/** \brief Return the minimum value for the raster shader */
double getMinimumValue() { return mMinimumValue; }
QgsRasterShaderFunction* getRasterShaderFunction() { return mRasterShaderFunction; }
/*
*
* Non-Static methods
*
*/
/** \brief generates and new RGB value based on one input value */
bool generateShadedValue(double, int*, int*, int*);
/** \brief generates and new RGB value based on original RGB value */
bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief A public method that allows the user to set their own shader function */
void setRasterShaderFunction(QgsRasterShaderFunction*);
/** \brief Set the maximum value */
void setMaximumValue(double);
/** \brief Return the minimum value */
void setMinimumValue(double);
private:
/** \brief User defineable minimum value for the raster shader */
double mMinimumValue;
/** \brief user defineable maximum value for the raster shader */
double mMaximumValue;
QgsRasterShaderFunction* mRasterShaderFunction;
};
#endif
/* **************************************************************************
qgsrastershader.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSRASTERSHADER_H
#define QGSRASTERSHADER_H
#include "qgsrastershaderfunction.h"
class CORE_EXPORT QgsRasterShader {
public:
QgsRasterShader(double theMinimumValue=0.0, double theMaximumValue=255.0);
~QgsRasterShader();
/*
*
* Non-Static Inline methods
*
*/
/** \brief Return the maximum value for the raster shader */
double getMaximumValue() { return mMaximumValue; }
/** \brief Return the minimum value for the raster shader */
double getMinimumValue() { return mMinimumValue; }
QgsRasterShaderFunction* getRasterShaderFunction() { return mRasterShaderFunction; }
/*
*
* Non-Static methods
*
*/
/** \brief generates and new RGB value based on one input value */
bool generateShadedValue(double, int*, int*, int*);
/** \brief generates and new RGB value based on original RGB value */
bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief A public method that allows the user to set their own shader function */
void setRasterShaderFunction(QgsRasterShaderFunction*);
/** \brief Set the maximum value */
void setMaximumValue(double);
/** \brief Return the minimum value */
void setMinimumValue(double);
private:
/** \brief User defineable minimum value for the raster shader */
double mMinimumValue;
/** \brief user defineable maximum value for the raster shader */
double mMaximumValue;
QgsRasterShaderFunction* mRasterShaderFunction;
};
#endif

View File

@ -0,0 +1,99 @@
/* **************************************************************************
qgsrastershaderfunction.cpp - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgslogger.h"
#include "qgsrastershaderfunction.h"
QgsRasterShaderFunction::QgsRasterShaderFunction(double theMinimumValue, double theMaximumValue)
{
#ifdef QGISDEBUG
QgsDebugMsg("QgsRasterShaderFunction::QgsRasterShaderFunction called");
#endif
mMinimumValue = theMinimumValue;
mMaximumValue = theMaximumValue;
mMinimumMaximumRange = mMaximumValue - mMinimumValue;
}
/**
Generates and new RGB value based on one input value
@param theValue The original value to base a new RGB value on
@param theReturnRedValue The red component of the new RGB value
@param theReturnGreenValue The green component of the new RGB value
@param theReturnBlueValue The blue component of the new RGB value
@return True if the return values are valid otherwise false
*/
bool QgsRasterShaderFunction::generateShadedValue(double theValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue)
{
*theReturnRedValue = 0;
*theReturnGreenValue = 0;
*theReturnBlueValue = 0;
return false;
}
/**
Generates and new RGB value based on an original RGB value
@param theRedValue The red component of the original value to base a new RGB value on
@param theGreenValue The green component of the original value to base a new RGB value on
@param theBlueValue The blue component of the original value to base a new RGB value on
@param theReturnRedValue The red component of the new RGB value
@param theReturnGreenValue The green component of the new RGB value
@param theReturnBlueValue The blue component of the new RGB value
@return True if the return values are valid otherwise false
*/
bool QgsRasterShaderFunction::generateShadedValue(double theRedValue, double theGreenValue, double theBlueValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue)
{
*theReturnRedValue = 0;
*theReturnGreenValue = 0;
*theReturnBlueValue = 0;
return false;
}
/**
Set the maximum value for the raster shader.
@param theValue The new maximum value
*/
void QgsRasterShaderFunction::setMaximumValue(double theValue)
{
#ifdef QGISDEBUG
QgsDebugMsg("QgsRasterShaderFunction::setMaximumValue called - Value = " + QString::number(theValue));
#endif
mMaximumValue = theValue;
mMinimumMaximumRange = mMaximumValue - mMinimumValue;
}
/**
Set the maximum value for the raster shader
@param theValue The new minimum value
*/
void QgsRasterShaderFunction::setMinimumValue(double theValue)
{
#ifdef QGISDEBUG
QgsDebugMsg("QgsRasterShaderFunction::setMinimumValue called - Value = " + QString::number(theValue));
#endif
mMinimumValue = theValue;
mMinimumMaximumRange = mMaximumValue - mMinimumValue;
}

View File

@ -0,0 +1,141 @@
/* **************************************************************************
qgsrastershaderfunction.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSRASTERSHADERFUNCTION_H
#define QGSRASTERSHADERFUNCTION_H
class CORE_EXPORT QgsRasterShaderFunction {
public:
QgsRasterShaderFunction(double theMinimumValue=0.0, double theMaximumValue=255.0);
virtual ~QgsRasterShaderFunction() {}
/** \brief generates and new RGB value based on one input value */
virtual bool generateShadedValue(double, int*, int*, int*);
/** \brief generates and new RGB value based on original RGB value */
virtual bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief Set the maximum value */
virtual void setMaximumValue(double);
/** \brief Return the minimum value */
virtual void setMinimumValue(double);
protected:
/** \brief User defineable maximum value for the shading function */
double mMaximumValue;
/** \brief User defineable minimum value for the shading function */
double mMinimumValue;
/** \brief Minimum maximum range for the shading function */
double mMinimumMaximumRange;
};
#endif
/* **************************************************************************
qgsrastershaderfunction.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSRASTERSHADERFUNCTION_H
#define QGSRASTERSHADERFUNCTION_H
class CORE_EXPORT QgsRasterShaderFunction {
public:
QgsRasterShaderFunction(double theMinimumValue=0.0, double theMaximumValue=255.0);
virtual ~QgsRasterShaderFunction() {}
/** \brief generates and new RGB value based on one input value */
virtual bool generateShadedValue(double, int*, int*, int*);
/** \brief generates and new RGB value based on original RGB value */
virtual bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief Set the maximum value */
virtual void setMaximumValue(double);
/** \brief Return the minimum value */
virtual void setMinimumValue(double);
protected:
/** \brief User defineable maximum value for the shading function */
double mMaximumValue;
/** \brief User defineable minimum value for the shading function */
double mMinimumValue;
/** \brief Minimum maximum range for the shading function */
double mMinimumMaximumRange;
};
#endif
/* **************************************************************************
qgsrastershaderfunction.h - description
-------------------
begin : Fri Dec 28 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSRASTERSHADERFUNCTION_H
#define QGSRASTERSHADERFUNCTION_H
class CORE_EXPORT QgsRasterShaderFunction {
public:
QgsRasterShaderFunction(double theMinimumValue=0.0, double theMaximumValue=255.0);
virtual ~QgsRasterShaderFunction() {}
/** \brief generates and new RGB value based on one input value */
virtual bool generateShadedValue(double, int*, int*, int*);
/** \brief generates and new RGB value based on original RGB value */
virtual bool generateShadedValue(double, double, double, int*, int*, int*);
/** \brief Set the maximum value */
virtual void setMaximumValue(double);
/** \brief Return the minimum value */
virtual void setMinimumValue(double);
protected:
/** \brief User defineable maximum value for the shading function */
double mMaximumValue;
/** \brief User defineable minimum value for the shading function */
double mMinimumValue;
/** \brief Minimum maximum range for the shading function */
double mMinimumMaximumRange;
};
#endif

View File

@ -0,0 +1,171 @@
/* **************************************************************************
qgsrastertransparency.cpp - description
-------------------
begin : Mon Nov 30 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <QList>
#include "qgsrastertransparency.h"
QgsRasterTransparency::QgsRasterTransparency()
{
}
/**
Accessor for transparentSingleValuePixelList
*/
QList<QgsRasterTransparency::TransparentSingleValuePixel> QgsRasterTransparency::getTransparentSingleValuePixelList()
{
return mTransparentSingleValuePixelList;
}
/**
Accessor for transparentThreeValuePixelList
*/
QList<QgsRasterTransparency::TransparentThreeValuePixel> QgsRasterTransparency::getTransparentThreeValuePixelList()
{
return mTransparentThreeValuePixelList;
}
/**
Reset to the transparency list to a single value
*/
void QgsRasterTransparency::initializeTransparentPixelList(double theValue)
{
//clear the existing list
mTransparentSingleValuePixelList.clear();
//add the initial value
TransparentSingleValuePixel myTransparentSingleValuePixel;
myTransparentSingleValuePixel.pixelValue = theValue;
myTransparentSingleValuePixel.percentTransparent = 100.0;
mTransparentSingleValuePixelList.append(myTransparentSingleValuePixel);
}
/**
Reset to the transparency list to a single value
*/
void QgsRasterTransparency::initializeTransparentPixelList(double theRedValue, double theGreenValue, double theBlueValue)
{
//clearn the existing list
mTransparentThreeValuePixelList.clear();
//add the initial values
TransparentThreeValuePixel myTransparentThreeValuePixel;
myTransparentThreeValuePixel.red = theRedValue;
myTransparentThreeValuePixel.green = theGreenValue;
myTransparentThreeValuePixel.blue = theBlueValue;
myTransparentThreeValuePixel.percentTransparent = 100.0;
mTransparentThreeValuePixelList.append(myTransparentThreeValuePixel);
}
/**
Mutator for transparentSingleValuePixelList, , replaces the whole list
*/
void QgsRasterTransparency::setTransparentSingleValuePixelList(QList<QgsRasterTransparency::TransparentSingleValuePixel> theNewList)
{
mTransparentSingleValuePixelList = theNewList;
}
/**
Mutator for transparentThreeValuePixelList, , replaces the whole list
*/
void QgsRasterTransparency::setTransparentThreeValuePixelList(QList<QgsRasterTransparency::TransparentThreeValuePixel> theNewList)
{
mTransparentThreeValuePixelList = theNewList;
}
/**
Searches throught the transparency list, if a match is found, the global transparency value is scaled
by the stored transparency value.
@param theValue the needle to search for in the transparency hay stack
@param theGlobalTransparency the overal transparency level for the layer
*/
int QgsRasterTransparency::getAlphaValue(double theValue, int theGlobalTransparency)
{
//if NaN return 0, transparent
if(theValue != theValue)
{
return 0;
}
//Search throught he transparency list looking for a match
bool myTransparentPixelFound = false;
TransparentSingleValuePixel myTransparentPixel;
for(int myListRunner = 0; myListRunner < mTransparentSingleValuePixelList.count(); myListRunner++)
{
myTransparentPixel = mTransparentSingleValuePixelList[myListRunner];
if(myTransparentPixel.pixelValue == theValue)
{
myTransparentPixelFound = true;
break;
}
}
//if a match was found use the stored transparency percentage
if(myTransparentPixelFound)
{
return (int)((float)theGlobalTransparency * (1.0 - (myTransparentPixel.percentTransparent/100.0)));
}
return theGlobalTransparency;
}
/**
Searches throught the transparency list, if a match is found, the global transparency value is scaled
by the stored transparency value.
@param theRedValue the red portion of the needle to search for in the transparency hay stack
@param theGreenValue the green portion of the needle to search for in the transparency hay stack
@param theBlueValue the green portion of the needle to search for in the transparency hay stack
@param theGlobalTransparency the overal transparency level for the layer
*/
int QgsRasterTransparency::getAlphaValue(double theRedValue, double theGreenValue, double theBlueValue, int theGlobalTransparency)
{
//if NaN return 0, transparent
if(theRedValue != theRedValue || theGreenValue != theGreenValue || theBlueValue != theBlueValue)
{
return 0;
}
//Search throught he transparency list looking for a match
bool myTransparentPixelFound = false;
TransparentThreeValuePixel myTransparentPixel;
for(int myListRunner = 0; myListRunner < mTransparentThreeValuePixelList.count(); myListRunner++)
{
myTransparentPixel = mTransparentThreeValuePixelList[myListRunner];
if(myTransparentPixel.red == theRedValue)
{
if(myTransparentPixel.green == theGreenValue)
{
if(myTransparentPixel.blue == theBlueValue)
{
myTransparentPixelFound = true;
break;
}
}
}
}
//if a match was found use the stored transparency percentage
if(myTransparentPixelFound)
{
return (int)((float)theGlobalTransparency * (1.0 - (myTransparentPixel.percentTransparent/100.0)));
}
return theGlobalTransparency;
}

View File

@ -0,0 +1,231 @@
/* **************************************************************************
qgsrastertransparency.h - description
-------------------
begin : Mon Nov 30 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSRASTERTRANSPARENCY_H
#define QGSRASTERTRANSPARENCY_H
class CORE_EXPORT QgsRasterTransparency
{
public:
QgsRasterTransparency();
//
// Structs to hold transparent pixel vlaues
//
struct TransparentThreeValuePixel
{
double red;
double green;
double blue;
double percentTransparent;
};
struct TransparentSingleValuePixel
{
double pixelValue;
double percentTransparent;
};
//
// Initializer, Accessor and mutator for transparency tables.
//
/** \brief Mutator for transparentSingleValuePixelList */
QList<QgsRasterTransparency::TransparentSingleValuePixel> getTransparentSingleValuePixelList();
/** \brief Mutator for transparentThreeValuePixelList */
QList<QgsRasterTransparency::TransparentThreeValuePixel> getTransparentThreeValuePixelList();
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double);
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double, double, double);
/** \brief Accessor for transparentSingleValuePixelList */
void setTransparentSingleValuePixelList(QList<QgsRasterTransparency::TransparentSingleValuePixel>);
/** \brief Accessor for transparentThreeValuePixelList */
void setTransparentThreeValuePixelList(QList<QgsRasterTransparency::TransparentThreeValuePixel>);
/** \brief Returns the transparency value for a single value Pixel */
int getAlphaValue(double, int theGlobalTransparency=255);
/** \brief Return the transparency value for a RGB Pixel */
int getAlphaValue(double, double, double, int theGlobalTransparency=255);
private:
/** \brief The list to hold transparency values for RGB layers */
QList<QgsRasterTransparency::TransparentThreeValuePixel> mTransparentThreeValuePixelList;
/** \brief The lsit to hold transparency values for single value pixel layers */
QList<QgsRasterTransparency::TransparentSingleValuePixel> mTransparentSingleValuePixelList;
};
#endif
/* **************************************************************************
qgsrastertransparency.h - description
-------------------
begin : Mon Nov 30 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSRASTERTRANSPARENCY_H
#define QGSRASTERTRANSPARENCY_H
class CORE_EXPORT QgsRasterTransparency
{
public:
QgsRasterTransparency();
//
// Structs to hold transparent pixel vlaues
//
struct TransparentThreeValuePixel
{
double red;
double green;
double blue;
double percentTransparent;
};
struct TransparentSingleValuePixel
{
double pixelValue;
double percentTransparent;
};
//
// Initializer, Accessor and mutator for transparency tables.
//
/** \brief Mutator for transparentSingleValuePixelList */
QList<QgsRasterTransparency::TransparentSingleValuePixel> getTransparentSingleValuePixelList();
/** \brief Mutator for transparentThreeValuePixelList */
QList<QgsRasterTransparency::TransparentThreeValuePixel> getTransparentThreeValuePixelList();
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double);
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double, double, double);
/** \brief Accessor for transparentSingleValuePixelList */
void setTransparentSingleValuePixelList(QList<QgsRasterTransparency::TransparentSingleValuePixel>);
/** \brief Accessor for transparentThreeValuePixelList */
void setTransparentThreeValuePixelList(QList<QgsRasterTransparency::TransparentThreeValuePixel>);
/** \brief Returns the transparency value for a single value Pixel */
int getAlphaValue(double, int theGlobalTransparency=255);
/** \brief Return the transparency value for a RGB Pixel */
int getAlphaValue(double, double, double, int theGlobalTransparency=255);
private:
/** \brief The list to hold transparency values for RGB layers */
QList<QgsRasterTransparency::TransparentThreeValuePixel> mTransparentThreeValuePixelList;
/** \brief The lsit to hold transparency values for single value pixel layers */
QList<QgsRasterTransparency::TransparentSingleValuePixel> mTransparentSingleValuePixelList;
};
#endif
/* **************************************************************************
qgsrastertransparency.h - description
-------------------
begin : Mon Nov 30 2007
copyright : (C) 2007 by Peter J. Ersts
email : ersts@amnh.org
****************************************************************************/
/* **************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSRASTERTRANSPARENCY_H
#define QGSRASTERTRANSPARENCY_H
class CORE_EXPORT QgsRasterTransparency
{
public:
QgsRasterTransparency();
//
// Structs to hold transparent pixel vlaues
//
struct TransparentThreeValuePixel
{
double red;
double green;
double blue;
double percentTransparent;
};
struct TransparentSingleValuePixel
{
double pixelValue;
double percentTransparent;
};
//
// Initializer, Accessor and mutator for transparency tables.
//
/** \brief Mutator for transparentSingleValuePixelList */
QList<QgsRasterTransparency::TransparentSingleValuePixel> getTransparentSingleValuePixelList();
/** \brief Mutator for transparentThreeValuePixelList */
QList<QgsRasterTransparency::TransparentThreeValuePixel> getTransparentThreeValuePixelList();
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double);
/** \brief Reset to the transparency list to a single value */
void initializeTransparentPixelList(double, double, double);
/** \brief Accessor for transparentSingleValuePixelList */
void setTransparentSingleValuePixelList(QList<QgsRasterTransparency::TransparentSingleValuePixel>);
/** \brief Accessor for transparentThreeValuePixelList */
void setTransparentThreeValuePixelList(QList<QgsRasterTransparency::TransparentThreeValuePixel>);
/** \brief Returns the transparency value for a single value Pixel */
int getAlphaValue(double, int theGlobalTransparency=255);
/** \brief Return the transparency value for a RGB Pixel */
int getAlphaValue(double, double, double, int theGlobalTransparency=255);
private:
/** \brief The list to hold transparency values for RGB layers */
QList<QgsRasterTransparency::TransparentThreeValuePixel> mTransparentThreeValuePixelList;
/** \brief The lsit to hold transparency values for single value pixel layers */
QList<QgsRasterTransparency::TransparentSingleValuePixel> mTransparentSingleValuePixelList;
};
#endif