Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #3887 from nirvn/raster_pseudocolor_move
  • Loading branch information
nirvn committed Dec 27, 2016
2 parents 9c68837 + 239b342 commit 901cd29
Show file tree
Hide file tree
Showing 15 changed files with 526 additions and 286 deletions.
2 changes: 2 additions & 0 deletions doc/api_break.dox
Expand Up @@ -475,6 +475,7 @@ QgsColorRampShader {#qgis_api_break_3_0_QgsColorRampShader}
------------------

- maximumColorCacheSize() and setMaximumColorCacheSize() were no longer used and are removed.
- ColorRamp_TYPE enum was renamed to Type, and its value names decapitalized


QgsComposerArrow {#qgis_api_break_3_0_QgsComposerArrow}
Expand Down Expand Up @@ -1465,6 +1466,7 @@ QgsSingleSymbolRendererWidget {#qgis_api_break_3_0_QgsSingleSymbolRendere
-----------------------------

- sizeScaleFieldChanged() and scaleMethodChanged() were removed. These settings are no longer exposed in the widget's GUI.
- The Mode enum was removed.


QgsSnapper {#qgis_api_break_3_0_QgsSnapper}
Expand Down
60 changes: 49 additions & 11 deletions python/core/raster/qgscolorrampshader.sip
Expand Up @@ -5,7 +5,31 @@ class QgsColorRampShader : QgsRasterShaderFunction
%End

public:
QgsColorRampShader( double theMinimumValue = 0.0, double theMaximumValue = 255.0 );
//! Supported methods for color interpolation.
enum Type
{
Interpolated, //!< Interpolates the color between two class breaks linearly.
Discrete, //!< Assigns the color of the higher class for every pixel between two class breaks.
Exact //!< Assigns the color of the exact matching value in the color ramp item list
};

//! Classification modes used to create the color ramp shader
enum ClassificationMode
{
Continuous = 1, //!< Uses breaks from color palette
EqualInterval = 2, //!< Uses equal interval
Quantile = 3 //!< Uses quantile (i.e. equal pixel) count
};

/** Creates a new color ramp shader.
* @param theMinimumValue minimum value for the raster shader
* @param theMaximumValue maximum value for the raster shader
* @param theType interpolation type used
* @param theClassificationMode method used to classify the color ramp shader
* @param theColorRamp vector color ramp used to classify the color ramp shader
* @returns new QgsColorRampShader
*/
QgsColorRampShader( double theMinimumValue = 0.0, double theMaximumValue = 255.0, QgsColorRamp* theColorRamp = nullptr, Type theType = Interpolated, ClassificationMode theClassificationMode = Continuous );

~QgsColorRampShader();

Expand All @@ -28,19 +52,11 @@ class QgsColorRampShader : QgsRasterShaderFunction
bool operator<( const QgsColorRampShader::ColorRampItem& other ) const;
};

/** Supported methods for color interpolation. */
enum ColorRamp_TYPE
{
INTERPOLATED, //!< Interpolates the color between two class breaks linearly.
DISCRETE, //!< Assigns the color of the higher class for every pixel between two class breaks.
EXACT //!< Assigns the color of the exact matching value in the color ramp item list
};

/** \brief Get the custom colormap*/
QList<QgsColorRampShader::ColorRampItem> colorRampItemList() const;

/** \brief Get the color ramp type */
QgsColorRampShader::ColorRamp_TYPE colorRampType() const;
Type colorRampType() const;

/** Get the source color ramp
* @note added in QGIS 3.0
Expand All @@ -61,11 +77,27 @@ class QgsColorRampShader : QgsRasterShaderFunction
void setColorRampItemList( const QList<QgsColorRampShader::ColorRampItem>& theList ); //TODO: sort on set

/** \brief Set the color ramp type*/
void setColorRampType( QgsColorRampShader::ColorRamp_TYPE theColorRampType );
void setColorRampType( QgsColorRampShader::Type theColorRampType );

/** \brief Set the color ramp type*/
void setColorRampType( const QString& theType );

/** Classify color ramp shader
* @param classes number of classes
* @param band raster band used in classification (only used in quantile mode)
* @param extent extent used in classification (only used in quantile mode)
* @param input raster input used in classification (only used in quantile mode)
*/
void classifyColorRamp( const int classes = 0, const int band = -1, const QgsRectangle& extent = QgsRectangle(), QgsRasterInterface* input = nullptr );

/** Classify color ramp shader
* @param band raster band used in classification (only used in quantile mode)
* @param extent extent used in classification (only used in quantile mode)
* @param input raster input used in classification (only used in quantile mode)
*/
void classifyColorRamp( const int band = -1, const QgsRectangle& extent = QgsRectangle(), QgsRasterInterface* input = nullptr ) /PyName=classifyColorRampV2/;


/** \brief Generates and new RGB value based on one input value */
bool shade( double, int* /Out/, int* /Out/, int* /Out/, int* /Out/ );

Expand All @@ -74,6 +106,12 @@ class QgsColorRampShader : QgsRasterShaderFunction

void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const;

//! Sets classification mode
void setClassificationMode( ClassificationMode classificationMode );

//! Returns the classification mode
ClassificationMode classificationMode() const;

/** Sets whether the shader should not render values out of range.
* @param clip set to true to clip values which are out of range.
* @see clip()
Expand Down
13 changes: 13 additions & 0 deletions python/core/raster/qgssinglebandpseudocolorrenderer.sip
Expand Up @@ -4,6 +4,7 @@ class QgsSingleBandPseudoColorRenderer: QgsRasterRenderer
#include "qgssinglebandpseudocolorrenderer.h"
%End
public:

/** Note: takes ownership of QgsRasterShader*/
QgsSingleBandPseudoColorRenderer( QgsRasterDataProvider* provider, int band, QgsRasterShader* shader /Transfer/ );
~QgsSingleBandPseudoColorRenderer();
Expand All @@ -15,10 +16,22 @@ class QgsSingleBandPseudoColorRenderer: QgsRasterRenderer

/** Takes ownership of the shader*/
void setShader( QgsRasterShader* shader /Transfer/ );

QgsRasterShader* shader();

//! @note available in python as constShader
const QgsRasterShader* shader() const /PyName=constShader/;

/** Creates a color ramp shader
* @param colorRamp vector color ramp
* @param colorRampType type of color ramp shader
* @param classificationMode classification mode
* @param classes number of classes
* @param clip clip out of range values
* @param extent extent used in classification (only used in quantile mode)
*/
void createShader( QgsColorRamp* colorRamp = nullptr, QgsColorRampShader::Type colorRampType = QgsColorRampShader::Interpolated, QgsColorRampShader::ClassificationMode classificationMode = QgsColorRampShader::Continuous, int classes = 0, bool clip = false, const QgsRectangle& extent = QgsRectangle() );

void writeXml( QDomDocument& doc, QDomElement& parentElem ) const;

void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const;
Expand Down
6 changes: 0 additions & 6 deletions python/gui/raster/qgssinglebandpseudocolorrendererwidget.sip
Expand Up @@ -5,12 +5,6 @@ class QgsSingleBandPseudoColorRendererWidget : QgsRasterRendererWidget
%End

public:
enum Mode
{
Continuous, // Using breaks from color palette
EqualInterval,
Quantile,
};

QgsSingleBandPseudoColorRendererWidget( QgsRasterLayer* layer, const QgsRectangle &extent = QgsRectangle() );
~QgsSingleBandPseudoColorRendererWidget();
Expand Down

0 comments on commit 901cd29

Please sign in to comment.