Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make shade() const
  • Loading branch information
wonder-sk committed Jul 12, 2018
1 parent 39ac58b commit 48195e0
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions python/core/auto_generated/raster/qgscolorrampshader.sip.in
Expand Up @@ -143,7 +143,7 @@ Classify color ramp shader
:param input: raster input used in classification (quantile mode only)
%End

virtual bool shade( double value, int *returnRedValue /Out/, int *returnGreenValue /Out/, int *returnBlueValue /Out/, int *returnAlphaValue /Out/ );
virtual bool shade( double value, int *returnRedValue /Out/, int *returnGreenValue /Out/, int *returnBlueValue /Out/, int *returnAlphaValue /Out/ ) const;

%Docstring
Generates and new RGB value based on one input value
Expand All @@ -152,7 +152,7 @@ Generates and new RGB value based on one input value
virtual bool shade( double redValue, double greenValue,
double blueValue, double alphaValue,
int *returnRedValue /Out/, int *returnGreenValue /Out/,
int *returnBlueValue /Out/, int *returnAlphaValue /Out/ );
int *returnBlueValue /Out/, int *returnAlphaValue /Out/ ) const;
%Docstring
Generates and new RGB value based on original RGB value
%End
Expand Down
Expand Up @@ -54,7 +54,7 @@ Sets the minimum ``value`` for the raster shader.
int *returnRedValue /Out/,
int *returnGreenValue /Out/,
int *returnBlueValue /Out/,
int *returnAlpha /Out/ );
int *returnAlpha /Out/ ) const;
%Docstring
Generates an new RGBA value based on one input ``value``.

Expand All @@ -74,7 +74,7 @@ Generates an new RGBA value based on one input ``value``.
int *returnRedValue /Out/,
int *returnGreenValue /Out/,
int *returnBlueValue /Out/,
int *returnAlpha /Out/ );
int *returnAlpha /Out/ ) const;
%Docstring
Generates an new RGBA value based on an original RGBA value.

Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgscolorrampshader.cpp
Expand Up @@ -315,7 +315,7 @@ void QgsColorRampShader::classifyColorRamp( const int band, const QgsRectangle &
classifyColorRamp( colorRampItemList().count(), band, extent, input );
}

bool QgsColorRampShader::shade( double value, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue )
bool QgsColorRampShader::shade( double value, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue ) const
{
if ( mColorRampItemList.isEmpty() )
{
Expand Down Expand Up @@ -464,7 +464,7 @@ bool QgsColorRampShader::shade( double value, int *returnRedValue, int *returnGr
bool QgsColorRampShader::shade( double redValue, double greenValue,
double blueValue, double alphaValue,
int *returnRedValue, int *returnGreenValue,
int *returnBlueValue, int *returnAlphaValue )
int *returnBlueValue, int *returnAlphaValue ) const
{
Q_UNUSED( redValue );
Q_UNUSED( greenValue );
Expand Down
12 changes: 6 additions & 6 deletions src/core/raster/qgscolorrampshader.h
Expand Up @@ -157,13 +157,13 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction
void classifyColorRamp( int band = -1, const QgsRectangle &extent = QgsRectangle(), QgsRasterInterface *input = nullptr ) SIP_PYNAME( classifyColorRampV2 );

//! \brief Generates and new RGB value based on one input value
bool shade( double value, int *returnRedValue SIP_OUT, int *returnGreenValue SIP_OUT, int *returnBlueValue SIP_OUT, int *returnAlphaValue SIP_OUT ) override;
bool shade( double value, int *returnRedValue SIP_OUT, int *returnGreenValue SIP_OUT, int *returnBlueValue SIP_OUT, int *returnAlphaValue SIP_OUT ) const override;

//! \brief Generates and new RGB value based on original RGB value
bool shade( double redValue, double greenValue,
double blueValue, double alphaValue,
int *returnRedValue SIP_OUT, int *returnGreenValue SIP_OUT,
int *returnBlueValue SIP_OUT, int *returnAlphaValue SIP_OUT ) override;
int *returnBlueValue SIP_OUT, int *returnAlphaValue SIP_OUT ) const override;

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

Expand Down Expand Up @@ -207,10 +207,10 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction
/**
* Look up table to speed up finding the right color.
* It is initialized on the first call to shade(). */
QVector<int> mLUT;
double mLUTOffset = 0.0;
double mLUTFactor = 1.0;
bool mLUTInitialized = false;
mutable QVector<int> mLUT;
mutable double mLUTOffset = 0.0;
mutable double mLUTFactor = 1.0;
mutable bool mLUTInitialized = false;

//! Do not render values out of range
bool mClip = false;
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrastershaderfunction.cpp
Expand Up @@ -43,7 +43,7 @@ void QgsRasterShaderFunction::setMinimumValue( double value )
mMinimumMaximumRange = mMaximumValue - mMinimumValue;
}

bool QgsRasterShaderFunction::shade( double value, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue )
bool QgsRasterShaderFunction::shade( double value, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue ) const
{
Q_UNUSED( value );

Expand All @@ -55,7 +55,7 @@ bool QgsRasterShaderFunction::shade( double value, int *returnRedValue, int *ret
return false;
}

bool QgsRasterShaderFunction::shade( double redValue, double greenValue, double blueValue, double alphaValue, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue )
bool QgsRasterShaderFunction::shade( double redValue, double greenValue, double blueValue, double alphaValue, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue ) const
{
Q_UNUSED( redValue );
Q_UNUSED( greenValue );
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrastershaderfunction.h
Expand Up @@ -78,7 +78,7 @@ class CORE_EXPORT QgsRasterShaderFunction
int *returnRedValue SIP_OUT,
int *returnGreenValue SIP_OUT,
int *returnBlueValue SIP_OUT,
int *returnAlpha SIP_OUT );
int *returnAlpha SIP_OUT ) const;

/**
* Generates an new RGBA value based on an original RGBA value.
Expand All @@ -100,7 +100,7 @@ class CORE_EXPORT QgsRasterShaderFunction
int *returnRedValue SIP_OUT,
int *returnGreenValue SIP_OUT,
int *returnBlueValue SIP_OUT,
int *returnAlpha SIP_OUT );
int *returnAlpha SIP_OUT ) const;

double minimumMaximumRange() const { return mMinimumMaximumRange; }

Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgssinglebandpseudocolorrenderer.cpp
Expand Up @@ -235,7 +235,7 @@ QgsRasterBlock *QgsSingleBandPseudoColorRenderer::block( int bandNo, QgsRectangl

QRgb myDefaultColor = NODATA_COLOR;
QRgb *outputBlockData = outputBlock->colorData();
QgsRasterShaderFunction *fcn = const_cast<QgsRasterShaderFunction *>( mShader->rasterShaderFunction() );
const QgsRasterShaderFunction *fcn = mShader->rasterShaderFunction();

qgssize count = ( qgssize )width * height;
for ( qgssize i = 0; i < count; i++ )
Expand Down

0 comments on commit 48195e0

Please sign in to comment.