Skip to content

Commit

Permalink
[BACKPORT] Formatting changes only for raster color ramp shader class
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Mar 12, 2012
1 parent 213138e commit 8acbea9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
14 changes: 10 additions & 4 deletions src/core/raster/qgscolorrampshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ bool QgsColorRampShader::discreteColor( double theValue, int* theReturnRedValue,
myColorRampItem = mColorRampItemList.value( mCurrentColorRampItemIndex );
myTinyDiff = qAbs( theValue - myColorRampItem.value );
//If the previous entry is less, then search closer to the top of the list (assumes mColorRampItemList is sorted)
if ( mCurrentColorRampItemIndex != 0 && theValue <= mColorRampItemList.at( mCurrentColorRampItemIndex - 1 ).value )
if ( mCurrentColorRampItemIndex != 0 &&
theValue <= mColorRampItemList.at( mCurrentColorRampItemIndex - 1 ).value )
{
mCurrentColorRampItemIndex--;
}
Expand Down Expand Up @@ -119,7 +120,9 @@ bool QgsColorRampShader::exactColor( double theValue, int* theReturnRedValue, in
return true;
}
//pixel value sits between ramp entries so bail
else if ( mCurrentColorRampItemIndex != myColorRampItemCount - 1 && theValue > myColorRampItem.value && theValue < mColorRampItemList.at( mCurrentColorRampItemIndex + 1 ).value )
else if ( mCurrentColorRampItemIndex != myColorRampItemCount - 1 &&
theValue > myColorRampItem.value && theValue < mColorRampItemList.at(
mCurrentColorRampItemIndex + 1 ).value )
{
return false;
}
Expand All @@ -138,7 +141,8 @@ bool QgsColorRampShader::exactColor( double theValue, int* theReturnRedValue, in
return false; // value not found
}

bool QgsColorRampShader::interpolatedColor( double theValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue )
bool QgsColorRampShader::interpolatedColor( double theValue, int*
theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue )
{
int myColorRampItemCount = mColorRampItemList.count();
if ( myColorRampItemCount <= 0 )
Expand Down Expand Up @@ -275,7 +279,9 @@ bool QgsColorRampShader::shade( double theValue, int* theReturnRedValue, int* th
return discreteColor( theValue, theReturnRedValue, theReturnGreenValue, theReturnBlueValue );
}

bool QgsColorRampShader::shade( double theRedValue, double theGreenValue, double theBlueValue, int* theReturnRedValue, int* theReturnGreenValue, int* theReturnBlueValue )
bool QgsColorRampShader::shade( double theRedValue, double theGreenValue,
double theBlueValue, int* theReturnRedValue, int* theReturnGreenValue, int*
theReturnBlueValue )
{
Q_UNUSED( theRedValue );
Q_UNUSED( theGreenValue );
Expand Down
23 changes: 16 additions & 7 deletions src/core/raster/qgscolorrampshader.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction
int mCurrentColorRampItemIndex;

//TODO: Consider pulling this out as a separate class and internally storing as a QMap rather than a QList
/** 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)*/
/** 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;

/** \brief The color ramp type */
Expand All @@ -105,18 +109,23 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction
/** \brief Cache of values that have already been looked up */
QMap<double, QColor> mColorCache;

/** Maximum size of the color cache. The color cache could eat a ton of memory if you have 32-bit data */
/** Maximum size of the color cache. The color cache could eat a ton of
* memory if you have 32-bit data */
int mMaximumColorCacheSize;



/** 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.*/
/** 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 discreteColor( double, int*, int*, int* );

/** Gets the color for a pixel value from the classification vector mValueClassification. Assigns the color of the exact matching value in the color ramp item list */
/** Gets the color for a pixel value from the classification vector
* mValueClassification. Assigns the color of the exact matching value in
* the color ramp item list */
bool exactColor( double, int*, int*, int* );

/** Gets the color for a pixel value from the classification vector mValueClassification. Interpolates the color between two class breaks linearly.*/
/** Gets the color for a pixel value from the classification vector
* mValueClassification. Interpolates the color between two class breaks
* linearly.*/
bool interpolatedColor( double, int*, int*, int* );
};

Expand Down

0 comments on commit 8acbea9

Please sign in to comment.