Rename color ramp classes to more sensible names

QgsVectorColorRamp -> QgsColorRamp
QgsVectorGradientColorRamp -> QgsGradientColorRamp
QgsRandomColors -> QgsRandomColorRamp
QgsRandomColorRamp -> QgsLimitedRandomColorRamp
QgsVectorColorBrewerColorRamp -> QgsColorBrewerColorRamp

These color ramps are used throughout all of QGIS (not
just in vector symbology) and the current names are
misleading.
This commit is contained in:
Nyall Dawson 2016-08-24 10:56:29 +10:00
parent 014409d025
commit 932e469e5f
70 changed files with 428 additions and 421 deletions

View File

@ -72,7 +72,7 @@ This page tries to maintain a list with incompatible changes that happened in pr
<tr><td>QgsMultiLineStringV2<td>QgsMultiLineString <tr><td>QgsMultiLineStringV2<td>QgsMultiLineString
<tr><td>QgsMultiSurfaceV2<td>QgsMultiSurface <tr><td>QgsMultiSurfaceV2<td>QgsMultiSurface
<tr><td>QgsPointSequenceV2<td>QgsPointSequence <tr><td>QgsPointSequenceV2<td>QgsPointSequence
<tr><td>QgsRandomColorsV2<td>QgsRandomColors <tr><td>QgsRandomColorsV2<td>QgsRandomColorRamp
<tr><td>QgsRendererCategoryV2<td>QgsRendererCategory <tr><td>QgsRendererCategoryV2<td>QgsRendererCategory
<tr><td>QgsRendererRangeV2<td>QgsRendererRange <tr><td>QgsRendererRangeV2<td>QgsRendererRange
<tr><td>QgsRendererRangeV2LabelFomat<td>QgsRendererRangeLabelFomat <tr><td>QgsRendererRangeV2LabelFomat<td>QgsRendererRangeLabelFomat
@ -125,17 +125,17 @@ This page tries to maintain a list with incompatible changes that happened in pr
<tr><td>QgsSymbolV2SelectorDialog<td>QgsSymbolSelectorDialog <tr><td>QgsSymbolV2SelectorDialog<td>QgsSymbolSelectorDialog
<tr><td>QgsSymbolV2SelectorWidget<td>QgsSymbolSelectorWidget <tr><td>QgsSymbolV2SelectorWidget<td>QgsSymbolSelectorWidget
<tr><td>QgsSymbologyV2Conversion<td>QgsSymbologyConversion <tr><td>QgsSymbologyV2Conversion<td>QgsSymbologyConversion
<tr><td>QgsVectorColorBrewerColorRampV2<td>QgsVectorColorBrewerColorRamp <tr><td>QgsVectorColorBrewerColorRampV2<td>QgsColorBrewerColorRamp
<tr><td>QgsVectorColorBrewerColorRampV2Dialog<td>QgsVectorColorBrewerColorRampDialog <tr><td>QgsVectorColorBrewerColorRampV2Dialog<td>QgsVectorColorBrewerColorRampDialog
<tr><td>QgsVectorColorBrewerColorRampV2DialogBase<td>QgsVectorColorBrewerColorRampDialogBase <tr><td>QgsVectorColorBrewerColorRampV2DialogBase<td>QgsVectorColorBrewerColorRampDialogBase
<tr><td>QgsVectorColorRampV2<td>QgsVectorColorRamp <tr><td>QgsVectorColorRampV2<td>QgsColorRamp
<tr><td>QgsVectorColorRampV2Map<td>QgsVectorColorRampMap <tr><td>QgsVectorColorRampV2Map<td>QgsVectorColorRampMap
<tr><td>QgsVectorGradientColorRampV2<td>QgsVectorGradientColorRamp <tr><td>QgsVectorGradientColorRampV2<td>QgsGradientColorRamp
<tr><td>QgsVectorGradientColorRampV2Dialog<td>QgsVectorGradientColorRampDialog <tr><td>QgsVectorGradientColorRampV2Dialog<td>QgsVectorGradientColorRampDialog
<tr><td>QgsVectorGradientColorRampV2DialogBase<td>QgsVectorGradientColorRampDialogBase <tr><td>QgsVectorGradientColorRampV2DialogBase<td>QgsVectorGradientColorRampDialogBase
<tr><td>QgsVectorGradientRampV2<td>QgsVectorGradientRamp <tr><td>QgsVectorGradientRampV2<td>QgsVectorGradientRamp
<tr><td>QgsVectorLayersetRendererV2<td>QgsVectorLayersetRenderer <tr><td>QgsVectorLayersetRendererV2<td>QgsVectorLayersetRenderer
<tr><td>QgsVectorRandomColorRampV2<td>QgsVectorRandomColorRamp <tr><td>QgsVectorRandomColorRampV2<td>QgsLimitedRandomColorRamp
<tr><td>QgsVectorRandomColorRampV2Dialog<td>QgsVectorRandomColorRampDialog <tr><td>QgsVectorRandomColorRampV2Dialog<td>QgsVectorRandomColorRampDialog
<tr><td>QgsVectorRandomColorRampV2DialogBase<td>QgsVectorRandomColorRampDialogBase <tr><td>QgsVectorRandomColorRampV2DialogBase<td>QgsVectorRandomColorRampDialogBase
<tr><th>QgsSymbolV2<th>QgsSymbol <tr><th>QgsSymbolV2<th>QgsSymbol

View File

@ -27,6 +27,7 @@
%Include qgsattributeeditorelement.sip %Include qgsattributeeditorelement.sip
%Include qgsbrowsermodel.sip %Include qgsbrowsermodel.sip
%Include qgsclipper.sip %Include qgsclipper.sip
%Include qgscolorramp.sip
%Include qgscolorscheme.sip %Include qgscolorscheme.sip
%Include qgscolorschemeregistry.sip %Include qgscolorschemeregistry.sip
%Include qgsconditionalstyle.sip %Include qgsconditionalstyle.sip
@ -290,7 +291,6 @@
%Include symbology-ng/qgsstyle.sip %Include symbology-ng/qgsstyle.sip
%Include symbology-ng/qgssvgcache.sip %Include symbology-ng/qgssvgcache.sip
%Include symbology-ng/qgssymbol.sip %Include symbology-ng/qgssymbol.sip
%Include symbology-ng/qgsvectorcolorramp.sip
%Include symbology-ng/qgs25drenderer.sip %Include symbology-ng/qgs25drenderer.sip
%Include symbology-ng/qgscategorizedsymbolrenderer.sip %Include symbology-ng/qgscategorizedsymbolrenderer.sip

View File

@ -129,7 +129,7 @@ class QgsGlowEffect : QgsPaintEffect
* @see ramp * @see ramp
* @see setColorType * @see setColorType
*/ */
void setRamp( QgsVectorColorRamp* ramp /Transfer/ ); void setRamp( QgsColorRamp* ramp /Transfer/ );
/** Returns the color ramp used for the glow. This only applies if the @link colorType @endlink /** Returns the color ramp used for the glow. This only applies if the @link colorType @endlink
* is set to ColorRamp. The glow will utilise colors from the ramp. * is set to ColorRamp. The glow will utilise colors from the ramp.
@ -137,7 +137,7 @@ class QgsGlowEffect : QgsPaintEffect
* @see setRamp * @see setRamp
* @see colorType * @see colorType
*/ */
QgsVectorColorRamp* ramp() const; QgsColorRamp* ramp() const;
/** Sets the blend mode for the effect /** Sets the blend mode for the effect
* @param mode blend mode used for drawing the effect on to a destination * @param mode blend mode used for drawing the effect on to a destination
@ -153,7 +153,7 @@ class QgsGlowEffect : QgsPaintEffect
*/ */
QPainter::CompositionMode blendMode() const; QPainter::CompositionMode blendMode() const;
/** Sets the color mode to use for the glow. The glow can either be drawn using a QgsVectorColorRamp /** Sets the color mode to use for the glow. The glow can either be drawn using a QgsColorRamp
* color ramp or by simply specificing a single color. setColorType is used to specify which mode to use * color ramp or by simply specificing a single color. setColorType is used to specify which mode to use
* for the glow. * for the glow.
* @param colorType color type to use for glow * @param colorType color type to use for glow
@ -163,7 +163,7 @@ class QgsGlowEffect : QgsPaintEffect
*/ */
void setColorType( GlowColorType colorType ); void setColorType( GlowColorType colorType );
/** Returns the color mode used for the glow. The glow can either be drawn using a QgsVectorColorRamp /** Returns the color mode used for the glow. The glow can either be drawn using a QgsColorRamp
* color ramp or by specificing a single color. * color ramp or by specificing a single color.
* @returns current color mode used for the glow * @returns current color mode used for the glow
* @see setColorType * @see setColorType

View File

@ -96,7 +96,7 @@ class QgsImageOperation
double spread; double spread;
/** Color ramp to use for shading the distance transform /** Color ramp to use for shading the distance transform
*/ */
QgsVectorColorRamp* ramp; QgsColorRamp* ramp;
}; };
/** Performs a distance transform on the source image and shades the result /** Performs a distance transform on the source image and shades the result

View File

@ -1,23 +1,23 @@
/** \ingroup core /** \ingroup core
* \class QgsVectorColorRamp * \class QgsColorRamp
* \brief Abstract base class for color ramps * \brief Abstract base class for color ramps
*/ */
//TODO QGIS 3.0 - rename to QgsColorRamp, since this is used by much more than just vectors class QgsColorRamp
class QgsVectorColorRamp
{ {
%TypeHeaderCode %TypeHeaderCode
#include <qgsvectorcolorramp.h> #include <qgscolorramp.h>
%End %End
%ConvertToSubClassCode %ConvertToSubClassCode
if (sipCpp->type() == "gradient") if (sipCpp->type() == "gradient")
sipType = sipType_QgsVectorGradientColorRamp; sipType = sipType_QgsGradientColorRamp;
else if (sipCpp->type() == "random") else if (sipCpp->type() == "random")
sipType = sipType_QgsVectorRandomColorRamp; sipType = sipType_QgsLimitedRandomColorRamp;
else if (sipCpp->type() == "randomcolors") else if (sipCpp->type() == "randomcolors")
sipType = sipType_QgsRandomColors; sipType = sipType_QgsRandomColorRamp;
else if (sipCpp->type() == "colorbrewer") else if (sipCpp->type() == "colorbrewer")
sipType = sipType_QgsVectorColorBrewerColorRamp; sipType = sipType_QgsColorBrewerColorRamp;
else if (sipCpp->type() == "cpt-city") else if (sipCpp->type() == "cpt-city")
sipType = sipType_QgsCptCityColorRamp; sipType = sipType_QgsCptCityColorRamp;
else else
@ -26,7 +26,7 @@ class QgsVectorColorRamp
public: public:
virtual ~QgsVectorColorRamp(); virtual ~QgsColorRamp();
/** Returns number of defined colors, or -1 if undefined /** Returns number of defined colors, or -1 if undefined
*/ */
@ -48,7 +48,7 @@ class QgsVectorColorRamp
/** Creates a clone of the color ramp. /** Creates a clone of the color ramp.
*/ */
virtual QgsVectorColorRamp* clone() const = 0 /Factory/; virtual QgsColorRamp* clone() const = 0 /Factory/;
/** Returns a string map containing all the color ramp's properties. /** Returns a string map containing all the color ramp's properties.
*/ */
@ -58,20 +58,20 @@ class QgsVectorColorRamp
/** \ingroup core /** \ingroup core
* \class QgsGradientStop * \class QgsGradientStop
* \brief Represents a color stop within a gradient color ramp. * \brief Represents a color stop within a QgsGradientColorRamp color ramp.
*/ */
class QgsGradientStop class QgsGradientStop
{ {
%TypeHeaderCode %TypeHeaderCode
#include <qgsvectorcolorramp.h> #include <qgscolorramp.h>
%End %End
public: public:
/** Constructor for QgsGradientStop /** Constructor for QgsGradientStop
* @param o positional offset for stop, between 0 and 1.0 * @param offset positional offset for stop, between 0 and 1.0
* @param c color for stop * @param color color for stop
*/ */
QgsGradientStop( double o, const QColor& c ); QgsGradientStop( double offset, const QColor& color );
//! Relative positional offset, between 0 and 1 //! Relative positional offset, between 0 and 1
double offset; double offset;
@ -86,38 +86,37 @@ class QgsGradientStop
typedef QList<QgsGradientStop> QgsGradientStopsList; typedef QList<QgsGradientStop> QgsGradientStopsList;
/** \ingroup core /** \ingroup core
* \class QgsVectorGradientColorRamp * \class QgsGradientColorRamp
* \brief Gradient color ramp, which smoothly interpolates between two colors and also * \brief Gradient color ramp, which smoothly interpolates between two colors and also
* supports optional extra color stops. * supports optional extra color stops.
*/ */
//TODO QGIS 3.0 - rename to QgsGradientColorRamp, since this is used by much more than just vectors class QgsGradientColorRamp : QgsColorRamp
class QgsVectorGradientColorRamp : QgsVectorColorRamp
{ {
%TypeHeaderCode %TypeHeaderCode
#include <qgsvectorcolorramp.h> #include <qgscolorramp.h>
%End %End
public: public:
/** Constructor for QgsVectorGradientColorRamp /** Constructor for QgsGradientColorRamp
* @param color1 start color, corresponding to a position of 0.0 * @param color1 start color, corresponding to a position of 0.0
* @param color2 end color, corresponding to a position of 1.0 * @param color2 end color, corresponding to a position of 1.0
* @param discrete set to true for discrete interpolation instead of smoothly * @param discrete set to true for discrete interpolation instead of smoothly
* interpolating between colors * interpolating between colors
* @param stops optional list of additional color stops * @param stops optional list of additional color stops
*/ */
QgsVectorGradientColorRamp( const QColor& color1 = DEFAULT_GRADIENT_COLOR1, QgsGradientColorRamp( const QColor& color1 = DEFAULT_GRADIENT_COLOR1,
const QColor& color2 = QColor(0,255,0), const QColor& color2 = QColor(0,255,0),
bool discrete = false, bool discrete = false,
const QgsGradientStopsList& stops = QgsGradientStopsList() ); const QgsGradientStopsList& stops = QgsGradientStopsList() );
//! Creates a new QgsVectorColorRamp from a map of properties //! Creates a new QgsVectorColorRamp from a map of properties
static QgsVectorColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/; static QgsColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;
virtual int count() const; virtual int count() const;
virtual double value( int index ) const; virtual double value( int index ) const;
virtual QColor color( double value ) const; virtual QColor color( double value ) const;
virtual QString type() const; virtual QString type() const;
virtual QgsVectorGradientColorRamp* clone() const /Factory/; virtual QgsGradientColorRamp* clone() const /Factory/;
virtual QgsStringMap properties() const; virtual QgsStringMap properties() const;
/** Returns the gradient start color. /** Returns the gradient start color.
@ -200,22 +199,21 @@ class QgsVectorGradientColorRamp : QgsVectorColorRamp
}; };
/** \ingroup core /** \ingroup core
* \class QgsVectorRandomColorRamp * \class QgsLimitedRandomColorRamp
* \brief Random color ramp, which returns random colors based on preset parameters. * \brief Constrained random color ramp, which returns random colors based on preset parameters.
*/ */
//TODO QGIS 3.0 - rename to QgsRandomColorRamp, since this is used by much more than just vectors class QgsLimitedRandomColorRamp : QgsColorRamp
class QgsVectorRandomColorRamp : QgsVectorColorRamp
{ {
%TypeHeaderCode %TypeHeaderCode
#include <qgsvectorcolorramp.h> #include <qgscolorramp.h>
%End %End
public: public:
QgsVectorRandomColorRamp( int count = DEFAULT_RANDOM_COUNT, QgsLimitedRandomColorRamp( int count = DEFAULT_RANDOM_COUNT,
int hueMin = DEFAULT_RANDOM_HUE_MIN, int hueMax = DEFAULT_RANDOM_HUE_MAX, int hueMin = DEFAULT_RANDOM_HUE_MIN, int hueMax = DEFAULT_RANDOM_HUE_MAX,
int satMin = DEFAULT_RANDOM_SAT_MIN, int satMax = DEFAULT_RANDOM_SAT_MAX, int satMin = DEFAULT_RANDOM_SAT_MIN, int satMax = DEFAULT_RANDOM_SAT_MAX,
int valMin = DEFAULT_RANDOM_VAL_MIN, int valMax = DEFAULT_RANDOM_VAL_MAX ); int valMin = DEFAULT_RANDOM_VAL_MIN, int valMax = DEFAULT_RANDOM_VAL_MAX );
static QgsVectorColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/; static QgsColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;
virtual double value( int index ) const; virtual double value( int index ) const;
@ -223,7 +221,7 @@ class QgsVectorRandomColorRamp : QgsVectorColorRamp
virtual QString type() const; virtual QString type() const;
virtual QgsVectorRandomColorRamp* clone() const /Factory/; virtual QgsLimitedRandomColorRamp* clone() const /Factory/;
virtual QgsStringMap properties() const; virtual QgsStringMap properties() const;
@ -254,11 +252,17 @@ class QgsVectorRandomColorRamp : QgsVectorColorRamp
void setValMax( int val ); void setValMax( int val );
}; };
class QgsRandomColors : QgsVectorColorRamp /** \ingroup core
* \class QgsRandomColorRamp
*/
class QgsRandomColorRamp : QgsColorRamp
{ {
%TypeHeaderCode
#include <qgscolorramp.h>
%End
public: public:
QgsRandomColors(); QgsRandomColorRamp();
~QgsRandomColors(); ~QgsRandomColorRamp();
int count() const; int count() const;
@ -276,21 +280,24 @@ class QgsRandomColors : QgsVectorColorRamp
QString type() const; QString type() const;
virtual QgsRandomColors* clone() const /Factory/; virtual QgsRandomColorRamp* clone() const /Factory/;
QgsStringMap properties() const; QgsStringMap properties() const;
}; };
class QgsVectorColorBrewerColorRamp : QgsVectorColorRamp /** \ingroup core
* \class QgsColorBrewerColorRamp
*/
class QgsColorBrewerColorRamp : QgsColorRamp
{ {
%TypeHeaderCode %TypeHeaderCode
#include <qgsvectorcolorramp.h> #include <qgscolorramp.h>
%End %End
public: public:
QgsVectorColorBrewerColorRamp( const QString& schemeName = DEFAULT_COLORBREWER_SCHEMENAME, QgsColorBrewerColorRamp( const QString& schemeName = DEFAULT_COLORBREWER_SCHEMENAME,
int colors = DEFAULT_COLORBREWER_COLORS ); int colors = DEFAULT_COLORBREWER_COLORS );
static QgsVectorColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/; static QgsColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;
virtual double value( int index ) const; virtual double value( int index ) const;
@ -298,7 +305,7 @@ class QgsVectorColorBrewerColorRamp : QgsVectorColorRamp
virtual QString type() const; virtual QString type() const;
virtual QgsVectorColorBrewerColorRamp* clone() const /Factory/; virtual QgsColorBrewerColorRamp* clone() const /Factory/;
virtual QgsStringMap properties() const; virtual QgsStringMap properties() const;
@ -318,10 +325,13 @@ class QgsVectorColorBrewerColorRamp : QgsVectorColorRamp
}; };
class QgsCptCityColorRamp : QgsVectorGradientColorRamp /** \ingroup core
* \class QgsCptCityColorRamp
*/
class QgsCptCityColorRamp : QgsGradientColorRamp
{ {
%TypeHeaderCode %TypeHeaderCode
#include <qgsvectorcolorramp.h> #include <qgscolorramp.h>
%End %End
public: public:
QgsCptCityColorRamp( const QString& schemeName = DEFAULT_CPTCITY_SCHEMENAME, QgsCptCityColorRamp( const QString& schemeName = DEFAULT_CPTCITY_SCHEMENAME,
@ -330,13 +340,13 @@ class QgsCptCityColorRamp : QgsVectorGradientColorRamp
QgsCptCityColorRamp( const QString& schemeName, const QStringList& variantList, QgsCptCityColorRamp( const QString& schemeName, const QStringList& variantList,
const QString& variantName = QString(), bool doLoadFile = true ); const QString& variantName = QString(), bool doLoadFile = true );
static QgsVectorColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/; static QgsColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;
virtual QString type() const; virtual QString type() const;
virtual QgsCptCityColorRamp* clone() const /Factory/; virtual QgsCptCityColorRamp* clone() const /Factory/;
void copy( const QgsCptCityColorRamp* other ); void copy( const QgsCptCityColorRamp* other );
QgsVectorGradientColorRamp* cloneGradientRamp() const /Factory/; QgsGradientColorRamp* cloneGradientRamp() const /Factory/;
virtual QgsStringMap properties() const; virtual QgsStringMap properties() const;

View File

@ -148,14 +148,14 @@ class QgsCategorizedSymbolRenderer : QgsFeatureRenderer
* @see setSourceColorRamp() * @see setSourceColorRamp()
* @see sourceSymbol() * @see sourceSymbol()
*/ */
QgsVectorColorRamp* sourceColorRamp(); QgsColorRamp* sourceColorRamp();
/** Sets the source color ramp. /** Sets the source color ramp.
* @param ramp color ramp. Ownership is transferred to the renderer * @param ramp color ramp. Ownership is transferred to the renderer
* @see sourceColorRamp() * @see sourceColorRamp()
* @see setSourceSymbol() * @see setSourceSymbol()
*/ */
void setSourceColorRamp( QgsVectorColorRamp* ramp /Transfer/ ); void setSourceColorRamp( QgsColorRamp* ramp /Transfer/ );
//! @note added in 2.1 //! @note added in 2.1
bool invertedColorRamp(); bool invertedColorRamp();
@ -166,7 +166,7 @@ class QgsCategorizedSymbolRenderer : QgsFeatureRenderer
* @param inverted set to true to invert ramp colors * @param inverted set to true to invert ramp colors
* @note added in 2.5 * @note added in 2.5
*/ */
void updateColorRamp( QgsVectorColorRamp* ramp /Transfer/, bool inverted = false ); void updateColorRamp( QgsColorRamp* ramp /Transfer/, bool inverted = false );
void setRotationField( const QString& fieldOrExpression ) /Deprecated/; void setRotationField( const QString& fieldOrExpression ) /Deprecated/;
QString rotationField() const /Deprecated/; QString rotationField() const /Deprecated/;

View File

@ -183,8 +183,8 @@ class QgsGradientFillSymbolLayer : QgsFillSymbolLayer
void setGradientColorType( GradientColorType gradientColorType ); void setGradientColorType( GradientColorType gradientColorType );
/** Color ramp used for the gradient fill, only used if the gradient color type is set to ColorRamp*/ /** Color ramp used for the gradient fill, only used if the gradient color type is set to ColorRamp*/
QgsVectorColorRamp* colorRamp(); QgsColorRamp* colorRamp();
void setColorRamp( QgsVectorColorRamp* ramp ); void setColorRamp( QgsColorRamp* ramp );
/** Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor*/ /** Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor*/
QColor color2() const; QColor color2() const;
@ -336,7 +336,7 @@ class QgsShapeburstFillSymbolLayer : QgsFillSymbolLayer
void setDistanceMapUnitScale( const QgsMapUnitScale& scale ); void setDistanceMapUnitScale( const QgsMapUnitScale& scale );
const QgsMapUnitScale& distanceMapUnitScale() const; const QgsMapUnitScale& distanceMapUnitScale() const;
/** Sets the color mode to use for the shapeburst fill. Shapeburst can either be drawn using a QgsVectorColorRamp color ramp /** Sets the color mode to use for the shapeburst fill. Shapeburst can either be drawn using a QgsColorRamp color ramp
* or by simply specificing a start and end color. setColorType is used to specify which mode to use for the fill. * or by simply specificing a start and end color. setColorType is used to specify which mode to use for the fill.
* @param colorType color type to use for shapeburst fill * @param colorType color type to use for shapeburst fill
* @note added in 2.3 * @note added in 2.3
@ -346,7 +346,7 @@ class QgsShapeburstFillSymbolLayer : QgsFillSymbolLayer
* @see setColorRamp * @see setColorRamp
*/ */
void setColorType( ShapeburstColorType colorType ); void setColorType( ShapeburstColorType colorType );
/** Returns the color mode used for the shapeburst fill. Shapeburst can either be drawn using a QgsVectorColorRamp color ramp /** Returns the color mode used for the shapeburst fill. Shapeburst can either be drawn using a QgsColorRamp color ramp
* or by simply specificing a start and end color. * or by simply specificing a start and end color.
* @returns current color mode used for the shapeburst fill * @returns current color mode used for the shapeburst fill
* @note added in 2.3 * @note added in 2.3
@ -363,14 +363,14 @@ class QgsShapeburstFillSymbolLayer : QgsFillSymbolLayer
* @see setColorType * @see setColorType
* @see colorRamp * @see colorRamp
*/ */
void setColorRamp( QgsVectorColorRamp* ramp ); void setColorRamp( QgsColorRamp* ramp );
/** Returns the color ramp used for the shapeburst fill. The color ramp is only used if the colorType is set to ShapeburstColorType::ColorRamp /** Returns the color ramp used for the shapeburst fill. The color ramp is only used if the colorType is set to ShapeburstColorType::ColorRamp
* @returns a QgsVectorColorRamp color ramp * @returns a QgsColorRamp color ramp
* @note added in 2.3 * @note added in 2.3
* @see setColorRamp * @see setColorRamp
* @see colorType * @see colorType
*/ */
QgsVectorColorRamp* colorRamp(); QgsColorRamp* colorRamp();
/** Sets the color for the endpoint of the shapeburst fill. This color is only used if setColorType is set ShapeburstColorType::SimpleTwoColor. /** Sets the color for the endpoint of the shapeburst fill. This color is only used if setColorType is set ShapeburstColorType::SimpleTwoColor.
* @param color2 QColor to use for endpoint of gradient * @param color2 QColor to use for endpoint of gradient

View File

@ -209,7 +209,7 @@ class QgsGraduatedSymbolRenderer : QgsFeatureRenderer
int classes, int classes,
Mode mode, Mode mode,
QgsSymbol* symbol /Transfer/, QgsSymbol* symbol /Transfer/,
QgsVectorColorRamp* ramp /Transfer/, QgsColorRamp* ramp /Transfer/,
bool inverted = false, bool inverted = false,
const QgsRendererRangeLabelFormat& legendFormat = QgsRendererRangeLabelFormat() const QgsRendererRangeLabelFormat& legendFormat = QgsRendererRangeLabelFormat()
); );
@ -251,12 +251,12 @@ class QgsGraduatedSymbolRenderer : QgsFeatureRenderer
* @see setSourceColorRamp() * @see setSourceColorRamp()
* @see sourceSymbol() * @see sourceSymbol()
*/ */
QgsVectorColorRamp* sourceColorRamp(); QgsColorRamp* sourceColorRamp();
/** Sets the source color ramp. /** Sets the source color ramp.
* @param ramp color ramp. Ownership is transferred to the renderer * @param ramp color ramp. Ownership is transferred to the renderer
*/ */
void setSourceColorRamp( QgsVectorColorRamp* ramp /Transfer/ ); void setSourceColorRamp( QgsColorRamp* ramp /Transfer/ );
//! @note added in 2.1 //! @note added in 2.1
bool invertedColorRamp(); bool invertedColorRamp();
@ -267,7 +267,7 @@ class QgsGraduatedSymbolRenderer : QgsFeatureRenderer
* @param ramp color ramp. Ownership is transferred to the renderer * @param ramp color ramp. Ownership is transferred to the renderer
* @param inverted set to true to invert ramp colors * @param inverted set to true to invert ramp colors
*/ */
void updateColorRamp( QgsVectorColorRamp* ramp /Transfer/ = 0, bool inverted = false ); void updateColorRamp( QgsColorRamp* ramp /Transfer/ = 0, bool inverted = false );
/** Update all the symbols but leave breaks and colors. This method also sets the source /** Update all the symbols but leave breaks and colors. This method also sets the source
* symbol for the renderer. * symbol for the renderer.

View File

@ -33,12 +33,12 @@ class QgsHeatmapRenderer : QgsFeatureRenderer
* @returns color ramp for heatmap * @returns color ramp for heatmap
* @see setColorRamp * @see setColorRamp
*/ */
QgsVectorColorRamp* colorRamp() const; QgsColorRamp* colorRamp() const;
/** Sets the color ramp to use for shading the heatmap. /** Sets the color ramp to use for shading the heatmap.
* @param ramp color ramp for heatmap. Ownership of ramp is transferred to the renderer. * @param ramp color ramp for heatmap. Ownership of ramp is transferred to the renderer.
* @see colorRamp * @see colorRamp
*/ */
void setColorRamp( QgsVectorColorRamp* ramp /Transfer/ ); void setColorRamp( QgsColorRamp* ramp /Transfer/ );
/** Returns whether the ramp is inverted /** Returns whether the ramp is inverted
* @returns true if color ramp is inverted * @returns true if color ramp is inverted

View File

@ -20,11 +20,11 @@ class QgsStyle : QObject
/*! /*!
* \note Adding a color ramp with the name of existing one replaces it. * \note Adding a color ramp with the name of existing one replaces it.
* \param name is the name of the color ramp being added or updated * \param name is the name of the color ramp being added or updated
* \param colorRamp is the Vector color ramp * \param colorRamp is the color ramp
* \param update set to true when the style DB has to be updated, by default it is false * \param update set to true when the style DB has to be updated, by default it is false
* \return success status of the operation * \return success status of the operation
*/ */
bool addColorRamp( const QString& name, QgsVectorColorRamp* colorRamp /Transfer/, bool update = false ); bool addColorRamp( const QString& name, QgsColorRamp* colorRamp /Transfer/, bool update = false );
//! adds a new group and returns the group's id //! adds a new group and returns the group's id
/*! /*!
@ -72,7 +72,7 @@ class QgsStyle : QObject
void clear(); void clear();
//! return a NEW copy of color ramp //! return a NEW copy of color ramp
QgsVectorColorRamp* colorRamp( const QString& name ) /Factory/; QgsColorRamp* colorRamp( const QString& name ) /Factory/;
//! return count of color ramps //! return count of color ramps
int colorRampCount(); int colorRampCount();
@ -81,7 +81,7 @@ class QgsStyle : QObject
QStringList colorRampNames(); QStringList colorRampNames();
//! return a const pointer to a symbol (doesn't create new instance) //! return a const pointer to a symbol (doesn't create new instance)
const QgsVectorColorRamp* colorRampRef( const QString& name ) const; const QgsColorRamp* colorRampRef( const QString& name ) const;
//! return the id in the style database for the given colorramp name //! return the id in the style database for the given colorramp name
//! returns 0 if not found //! returns 0 if not found
@ -199,12 +199,12 @@ class QgsStyle : QObject
//! add the colorramp to the DB //! add the colorramp to the DB
/*! /*!
* \param name is the name of the colorramp as QString * \param name is the name of the colorramp as QString
* \param ramp is the pointer to the new QgsVectorColorRamp being saved * \param ramp is the pointer to the new QgsColorRamp being saved
* \param groupid is the id of the group to which the Color Ramp belongs. Pass 0 if it doesn't belong to any group or not known. * \param groupid is the id of the group to which the Color Ramp belongs. Pass 0 if it doesn't belong to any group or not known.
* \param tags is a list of tags that are associated with the color ramp as a QStringList. * \param tags is a list of tags that are associated with the color ramp as a QStringList.
* \return returns the success state of the save operation * \return returns the success state of the save operation
*/ */
bool saveColorRamp( const QString& name, QgsVectorColorRamp* ramp, int groupid, const QStringList& tags ); bool saveColorRamp( const QString& name, QgsColorRamp* ramp, int groupid, const QStringList& tags );
//! remove color ramp from style (and delete it) //! remove color ramp from style (and delete it)
bool removeColorRamp( const QString& name ); bool removeColorRamp( const QString& name );

View File

@ -95,13 +95,13 @@ class QgsSymbolLayerUtils
*/ */
static QIcon symbolLayerPreviewIcon( QgsSymbolLayer* layer, QgsUnitTypes::RenderUnit u, QSize size, const QgsMapUnitScale& scale = QgsMapUnitScale() ); static QIcon symbolLayerPreviewIcon( QgsSymbolLayer* layer, QgsUnitTypes::RenderUnit u, QSize size, const QgsMapUnitScale& scale = QgsMapUnitScale() );
static QIcon colorRampPreviewIcon( QgsVectorColorRamp* ramp, QSize size ); static QIcon colorRampPreviewIcon( QgsColorRamp* ramp, QSize size );
static void drawStippledBackground( QPainter* painter, QRect rect ); static void drawStippledBackground( QPainter* painter, QRect rect );
//! @note customContext parameter added in 2.6 //! @note customContext parameter added in 2.6
static QPixmap symbolPreviewPixmap( QgsSymbol* symbol, QSize size, QgsRenderContext* customContext = 0 ); static QPixmap symbolPreviewPixmap( QgsSymbol* symbol, QSize size, QgsRenderContext* customContext = 0 );
static QPixmap colorRampPreviewPixmap( QgsVectorColorRamp* ramp, QSize size ); static QPixmap colorRampPreviewPixmap( QgsColorRamp* ramp, QSize size );
/** Returns the maximum estimated bleed for the symbol */ /** Returns the maximum estimated bleed for the symbol */
static double estimateMaxSymbolBleed( QgsSymbol* symbol ); static double estimateMaxSymbolBleed( QgsSymbol* symbol );
@ -241,8 +241,8 @@ class QgsSymbolLayerUtils
static void clearSymbolMap( QgsSymbolMap& symbols ); static void clearSymbolMap( QgsSymbolMap& symbols );
static QgsVectorColorRamp* loadColorRamp( QDomElement& element ) /Factory/; static QgsColorRamp* loadColorRamp( QDomElement& element ) /Factory/;
static QDomElement saveColorRamp( const QString& name, QgsVectorColorRamp* ramp, QDomDocument& doc ); static QDomElement saveColorRamp( const QString& name, QgsColorRamp* ramp, QDomDocument& doc );
/** /**
* Returns a friendly display name for a color * Returns a friendly display name for a color

View File

@ -17,18 +17,18 @@ class QgsGradientStopEditor : QWidget
* @param parent parent widget * @param parent parent widget
* @param ramp optional initial gradient ramp * @param ramp optional initial gradient ramp
*/ */
QgsGradientStopEditor( QWidget* parent /TransferThis/ = nullptr, QgsVectorGradientColorRamp* ramp = nullptr ); QgsGradientStopEditor( QWidget* parent /TransferThis/ = nullptr, QgsGradientColorRamp* ramp = nullptr );
/** Sets the current ramp shown in the editor. /** Sets the current ramp shown in the editor.
* @param ramp color ramp * @param ramp color ramp
* @see gradientRamp() * @see gradientRamp()
*/ */
void setGradientRamp( const QgsVectorGradientColorRamp& ramp ); void setGradientRamp( const QgsGradientColorRamp& ramp );
/** Returns the current ramp created by the editor. /** Returns the current ramp created by the editor.
* @see setGradientRamp() * @see setGradientRamp()
*/ */
QgsVectorGradientColorRamp gradientRamp() const; QgsGradientColorRamp gradientRamp() const;
/** Sets the currently selected stop. /** Sets the currently selected stop.
* @param index index of stop, where 0 corresponds to the first stop * @param index index of stop, where 0 corresponds to the first stop

View File

@ -75,7 +75,7 @@ class QgsCategorizedSymbolRendererWidget : QgsRendererWidget
void changeCategorySymbol(); void changeCategorySymbol();
QgsVectorColorRamp* getColorRamp(); QgsColorRamp* getColorRamp();
QList<QgsSymbol*> selectedSymbols(); QList<QgsSymbol*> selectedSymbols();
QgsCategoryList selectedCategoryList(); QgsCategoryList selectedCategoryList();

View File

@ -12,10 +12,10 @@ class QgsColorRampComboBox : QComboBox
void populate( QgsStyle* style ); void populate( QgsStyle* style );
//! add/select color ramp which was used previously by the renderer //! add/select color ramp which was used previously by the renderer
void setSourceColorRamp( QgsVectorColorRamp* sourceRamp ); void setSourceColorRamp( QgsColorRamp* sourceRamp );
//! return new instance of the current color ramp or NULL if there is no active color ramp //! return new instance of the current color ramp or NULL if there is no active color ramp
QgsVectorColorRamp* currentColorRamp(); QgsColorRamp* currentColorRamp();
/** Returns true if the current selection in the combo box is the option for creating /** Returns true if the current selection in the combo box is the option for creating
* a new color ramp * a new color ramp

View File

@ -5,7 +5,7 @@ class QgsVectorColorBrewerColorRampDialog : QDialog
%End %End
public: public:
QgsVectorColorBrewerColorRampDialog( QgsVectorColorBrewerColorRamp* ramp, QWidget* parent /TransferThis/ = NULL ); QgsVectorColorBrewerColorRampDialog( QgsColorBrewerColorRamp* ramp, QWidget* parent /TransferThis/ = NULL );
public slots: public slots:
void setSchemeName(); void setSchemeName();

View File

@ -5,7 +5,7 @@ class QgsVectorGradientColorRampDialog : QDialog
%End %End
public: public:
QgsVectorGradientColorRampDialog( QgsVectorGradientColorRamp* ramp, QWidget* parent /TransferThis/ = NULL ); QgsVectorGradientColorRampDialog( QgsGradientColorRamp* ramp, QWidget* parent /TransferThis/ = NULL );
public slots: public slots:
void setColor1( const QColor& color ); void setColor1( const QColor& color );

View File

@ -5,7 +5,7 @@ class QgsVectorRandomColorRampDialog : QDialog
%End %End
public: public:
QgsVectorRandomColorRampDialog( QgsVectorRandomColorRamp* ramp, QWidget* parent /TransferThis/ = NULL ); QgsVectorRandomColorRampDialog( QgsLimitedRandomColorRamp* ramp, QWidget* parent /TransferThis/ = NULL );
public slots: public slots:
void setCount( int val ); void setCount( int val );

View File

@ -65,7 +65,7 @@
#include <qwt_plot_curve.h> #include <qwt_plot_curve.h>
#include <qwt_symbol.h> #include <qwt_symbol.h>
#include <qwt_legend.h> #include <qwt_legend.h>
#include "qgsvectorcolorramp.h" // for random colors #include "qgscolorramp.h" // for random colors
QgsIdentifyResultsWebView::QgsIdentifyResultsWebView( QWidget *parent ) : QgsWebView( parent ) QgsIdentifyResultsWebView::QgsIdentifyResultsWebView( QWidget *parent ) : QgsWebView( parent )
{ {
@ -609,7 +609,7 @@ QgsIdentifyPlotCurve::QgsIdentifyPlotCurve( const QMap<QString, QString> &attrib
if ( color == QColor() ) if ( color == QColor() )
{ {
color = QgsVectorRandomColorRamp::randomColors( 1 ).at( 0 ); color = QgsLimitedRandomColorRamp::randomColors( 1 ).at( 0 );
} }
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000 #if defined(QWT_VERSION) && QWT_VERSION>=0x060000
mPlotCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::white ), mPlotCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::white ),

View File

@ -40,7 +40,7 @@
#include "qgsstyle.h" #include "qgsstyle.h"
#include "qgssymbol.h" #include "qgssymbol.h"
#include "qgsstylemanagerdialog.h" #include "qgsstylemanagerdialog.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgssymbolselectordialog.h" #include "qgssymbolselectordialog.h"
#include "qgsrelationmanagerdialog.h" #include "qgsrelationmanagerdialog.h"
#include "qgsrelationmanager.h" #include "qgsrelationmanager.h"
@ -1713,7 +1713,7 @@ void QgsProjectProperties::populateStyles()
for ( int i = 0; i < colorRamps.count(); ++i ) for ( int i = 0; i < colorRamps.count(); ++i )
{ {
QString name = colorRamps[i]; QString name = colorRamps[i];
QgsVectorColorRamp* ramp = mStyle->colorRamp( name ); QgsColorRamp* ramp = mStyle->colorRamp( name );
QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp, cboStyleColorRamp->iconSize() ); QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp, cboStyleColorRamp->iconSize() );
cboStyleColorRamp->addItem( icon, name ); cboStyleColorRamp->addItem( icon, name );
delete ramp; delete ramp;

View File

@ -42,7 +42,6 @@ SET(QGIS_CORE_SRCS
symbology-ng/qgssymbollayerutils.cpp symbology-ng/qgssymbollayerutils.cpp
symbology-ng/qgssymbologyconversion.cpp symbology-ng/qgssymbologyconversion.cpp
symbology-ng/qgssymbol.cpp symbology-ng/qgssymbol.cpp
symbology-ng/qgsvectorcolorramp.cpp
symbology-ng/qgsvectorfieldsymbollayer.cpp symbology-ng/qgsvectorfieldsymbollayer.cpp
diagram/qgsdiagram.cpp diagram/qgsdiagram.cpp
@ -87,6 +86,7 @@ SET(QGIS_CORE_SRCS
qgscacheindex.cpp qgscacheindex.cpp
qgscacheindexfeatureid.cpp qgscacheindexfeatureid.cpp
qgsclipper.cpp qgsclipper.cpp
qgscolorramp.cpp
qgscolorscheme.cpp qgscolorscheme.cpp
qgscolorschemeregistry.cpp qgscolorschemeregistry.cpp
qgsconditionalstyle.cpp qgsconditionalstyle.cpp
@ -607,6 +607,7 @@ SET(QGIS_CORE_HDRS
qgscacheindex.h qgscacheindex.h
qgscacheindexfeatureid.h qgscacheindexfeatureid.h
qgsclipper.h qgsclipper.h
qgscolorramp.h
qgscolorscheme.h qgscolorscheme.h
qgscolorschemeregistry.h qgscolorschemeregistry.h
qgsconnectionpool.h qgsconnectionpool.h
@ -818,7 +819,6 @@ SET(QGIS_CORE_HDRS
symbology-ng/qgssymbollayerutils.h symbology-ng/qgssymbollayerutils.h
symbology-ng/qgssymbologyconversion.h symbology-ng/qgssymbologyconversion.h
symbology-ng/qgssymbol.h symbology-ng/qgssymbol.h
symbology-ng/qgsvectorcolorramp.h
symbology-ng/qgsvectorfieldsymbollayer.h symbology-ng/qgsvectorfieldsymbollayer.h
symbology-ng/qgsgeometrygeneratorsymbollayer.h symbology-ng/qgsgeometrygeneratorsymbollayer.h

View File

@ -18,7 +18,7 @@
#include "qgsgloweffect.h" #include "qgsgloweffect.h"
#include "qgssymbollayerutils.h" #include "qgssymbollayerutils.h"
#include "qgsimageoperation.h" #include "qgsimageoperation.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgsunittypes.h" #include "qgsunittypes.h"
QgsGlowEffect::QgsGlowEffect() QgsGlowEffect::QgsGlowEffect()
@ -65,7 +65,7 @@ void QgsGlowEffect::draw( QgsRenderContext &context )
QImage im = sourceAsImage( context )->copy(); QImage im = sourceAsImage( context )->copy();
QgsVectorColorRamp* ramp = nullptr; QgsColorRamp* ramp = nullptr;
if ( mColorType == ColorRamp && mRamp ) if ( mColorType == ColorRamp && mRamp )
{ {
ramp = mRamp; ramp = mRamp;
@ -75,7 +75,7 @@ void QgsGlowEffect::draw( QgsRenderContext &context )
//create a temporary ramp //create a temporary ramp
QColor transparentColor = mColor; QColor transparentColor = mColor;
transparentColor.setAlpha( 0 ); transparentColor.setAlpha( 0 );
ramp = new QgsVectorGradientColorRamp( mColor, transparentColor ); ramp = new QgsGradientColorRamp( mColor, transparentColor );
} }
QgsImageOperation::DistanceTransformProperties dtProps; QgsImageOperation::DistanceTransformProperties dtProps;
@ -176,10 +176,10 @@ void QgsGlowEffect::readProperties( const QgsStringMap &props )
//attempt to create color ramp from props //attempt to create color ramp from props
delete mRamp; delete mRamp;
mRamp = QgsVectorGradientColorRamp::create( props ); mRamp = QgsGradientColorRamp::create( props );
} }
void QgsGlowEffect::setRamp( QgsVectorColorRamp *ramp ) void QgsGlowEffect::setRamp( QgsColorRamp *ramp )
{ {
delete mRamp; delete mRamp;
mRamp = ramp; mRamp = ramp;

View File

@ -21,7 +21,7 @@
#include "qgssymbol.h" #include "qgssymbol.h"
#include <QPainter> #include <QPainter>
class QgsVectorColorRamp; class QgsColorRamp;
/** \ingroup core /** \ingroup core
* \class QgsGlowEffect * \class QgsGlowEffect
@ -151,7 +151,7 @@ class CORE_EXPORT QgsGlowEffect : public QgsPaintEffect
* @see ramp * @see ramp
* @see setColorType * @see setColorType
*/ */
void setRamp( QgsVectorColorRamp* ramp ); void setRamp( QgsColorRamp* ramp );
/** Returns the color ramp used for the glow. This only applies if the @link colorType @endlink /** Returns the color ramp used for the glow. This only applies if the @link colorType @endlink
* is set to ColorRamp. The glow will utilise colors from the ramp. * is set to ColorRamp. The glow will utilise colors from the ramp.
@ -159,7 +159,7 @@ class CORE_EXPORT QgsGlowEffect : public QgsPaintEffect
* @see setRamp * @see setRamp
* @see colorType * @see colorType
*/ */
QgsVectorColorRamp* ramp() const { return mRamp; } QgsColorRamp* ramp() const { return mRamp; }
/** Sets the blend mode for the effect /** Sets the blend mode for the effect
* @param mode blend mode used for drawing the effect on to a destination * @param mode blend mode used for drawing the effect on to a destination
@ -175,7 +175,7 @@ class CORE_EXPORT QgsGlowEffect : public QgsPaintEffect
*/ */
QPainter::CompositionMode blendMode() const { return mBlendMode; } QPainter::CompositionMode blendMode() const { return mBlendMode; }
/** Sets the color mode to use for the glow. The glow can either be drawn using a QgsVectorColorRamp /** Sets the color mode to use for the glow. The glow can either be drawn using a QgsColorRamp
* color ramp or by simply specificing a single color. setColorType is used to specify which mode to use * color ramp or by simply specificing a single color. setColorType is used to specify which mode to use
* for the glow. * for the glow.
* @param colorType color type to use for glow * @param colorType color type to use for glow
@ -185,7 +185,7 @@ class CORE_EXPORT QgsGlowEffect : public QgsPaintEffect
*/ */
void setColorType( GlowColorType colorType ) { mColorType = colorType; } void setColorType( GlowColorType colorType ) { mColorType = colorType; }
/** Returns the color mode used for the glow. The glow can either be drawn using a QgsVectorColorRamp /** Returns the color mode used for the glow. The glow can either be drawn using a QgsColorRamp
* color ramp or by specificing a single color. * color ramp or by specificing a single color.
* @returns current color mode used for the glow * @returns current color mode used for the glow
* @see setColorType * @see setColorType
@ -211,7 +211,7 @@ class CORE_EXPORT QgsGlowEffect : public QgsPaintEffect
double mSpread; double mSpread;
QgsUnitTypes::RenderUnit mSpreadUnit; QgsUnitTypes::RenderUnit mSpreadUnit;
QgsMapUnitScale mSpreadMapUnitScale; QgsMapUnitScale mSpreadMapUnitScale;
QgsVectorColorRamp* mRamp; QgsColorRamp* mRamp;
int mBlurLevel; int mBlurLevel;
double mTransparency; double mTransparency;
QColor mColor; QColor mColor;

View File

@ -17,7 +17,7 @@
#include "qgsimageoperation.h" #include "qgsimageoperation.h"
#include "qgis.h" #include "qgis.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgslogger.h" #include "qgslogger.h"
#include <QtConcurrentMap> #include <QtConcurrentMap>
#include <QColor> #include <QColor>

View File

@ -22,7 +22,7 @@
#include <QColor> #include <QColor>
#include <QtCore/qmath.h> #include <QtCore/qmath.h>
class QgsVectorColorRamp; class QgsColorRamp;
/** \ingroup core /** \ingroup core
* \class QgsImageOperation * \class QgsImageOperation
@ -126,7 +126,7 @@ class CORE_EXPORT QgsImageOperation
double spread; double spread;
/** Color ramp to use for shading the distance transform /** Color ramp to use for shading the distance transform
*/ */
QgsVectorColorRamp* ramp; QgsColorRamp* ramp;
}; };
/** Performs a distance transform on the source image and shades the result /** Performs a distance transform on the source image and shades the result

View File

@ -1,5 +1,5 @@
/*************************************************************************** /***************************************************************************
qgsvectorcolorramp.cpp qgscolorramp.cpp
--------------------- ---------------------
begin : November 2009 begin : November 2009
copyright : (C) 2009 by Martin Dobias copyright : (C) 2009 by Martin Dobias
@ -13,7 +13,7 @@
* * * *
***************************************************************************/ ***************************************************************************/
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgscolorbrewerpalette.h" #include "qgscolorbrewerpalette.h"
#include "qgscptcityarchive.h" #include "qgscptcityarchive.h"
@ -42,7 +42,7 @@ static QColor _interpolate( const QColor& c1, const QColor& c2, const double val
////////////// //////////////
QgsVectorGradientColorRamp::QgsVectorGradientColorRamp( const QColor& color1, const QColor& color2, QgsGradientColorRamp::QgsGradientColorRamp( const QColor& color1, const QColor& color2,
bool discrete, const QgsGradientStopsList& stops ) bool discrete, const QgsGradientStopsList& stops )
: mColor1( color1 ) : mColor1( color1 )
, mColor2( color2 ) , mColor2( color2 )
@ -51,7 +51,7 @@ QgsVectorGradientColorRamp::QgsVectorGradientColorRamp( const QColor& color1, co
{ {
} }
QgsVectorColorRamp* QgsVectorGradientColorRamp::create( const QgsStringMap& props ) QgsColorRamp* QgsGradientColorRamp::create( const QgsStringMap& props )
{ {
// color1 and color2 // color1 and color2
QColor color1 = DEFAULT_GRADIENT_COLOR1; QColor color1 = DEFAULT_GRADIENT_COLOR1;
@ -93,12 +93,12 @@ QgsVectorColorRamp* QgsVectorGradientColorRamp::create( const QgsStringMap& prop
info[ it.key().mid( 5 )] = it.value(); info[ it.key().mid( 5 )] = it.value();
} }
QgsVectorGradientColorRamp* r = new QgsVectorGradientColorRamp( color1, color2, discrete, stops ); QgsGradientColorRamp* r = new QgsGradientColorRamp( color1, color2, discrete, stops );
r->setInfo( info ); r->setInfo( info );
return r; return r;
} }
double QgsVectorGradientColorRamp::value( int index ) const double QgsGradientColorRamp::value( int index ) const
{ {
if ( index <= 0 ) if ( index <= 0 )
{ {
@ -114,7 +114,7 @@ double QgsVectorGradientColorRamp::value( int index ) const
} }
} }
QColor QgsVectorGradientColorRamp::color( double value ) const QColor QgsGradientColorRamp::color( double value ) const
{ {
if ( qgsDoubleNear( value, 0.0 ) || value < 0.0 ) if ( qgsDoubleNear( value, 0.0 ) || value < 0.0 )
{ {
@ -160,15 +160,15 @@ QColor QgsVectorGradientColorRamp::color( double value ) const
} }
} }
QgsVectorGradientColorRamp* QgsVectorGradientColorRamp::clone() const QgsGradientColorRamp* QgsGradientColorRamp::clone() const
{ {
QgsVectorGradientColorRamp* r = new QgsVectorGradientColorRamp( mColor1, mColor2, QgsGradientColorRamp* r = new QgsGradientColorRamp( mColor1, mColor2,
mDiscrete, mStops ); mDiscrete, mStops );
r->setInfo( mInfo ); r->setInfo( mInfo );
return r; return r;
} }
QgsStringMap QgsVectorGradientColorRamp::properties() const QgsStringMap QgsGradientColorRamp::properties() const
{ {
QgsStringMap map; QgsStringMap map;
map["color1"] = QgsSymbolLayerUtils::encodeColor( mColor1 ); map["color1"] = QgsSymbolLayerUtils::encodeColor( mColor1 );
@ -193,7 +193,7 @@ QgsStringMap QgsVectorGradientColorRamp::properties() const
return map; return map;
} }
void QgsVectorGradientColorRamp::convertToDiscrete( bool discrete ) void QgsGradientColorRamp::convertToDiscrete( bool discrete )
{ {
if ( discrete == mDiscrete ) if ( discrete == mDiscrete )
return; return;
@ -240,7 +240,7 @@ bool stopLessThan( const QgsGradientStop &s1, const QgsGradientStop &s2 )
return s1.offset < s2.offset; return s1.offset < s2.offset;
} }
void QgsVectorGradientColorRamp::setStops( const QgsGradientStopsList &stops ) void QgsGradientColorRamp::setStops( const QgsGradientStopsList &stops )
{ {
mStops = stops; mStops = stops;
@ -248,7 +248,7 @@ void QgsVectorGradientColorRamp::setStops( const QgsGradientStopsList &stops )
qSort( mStops.begin(), mStops.end(), stopLessThan ); qSort( mStops.begin(), mStops.end(), stopLessThan );
} }
void QgsVectorGradientColorRamp::addStopsToGradient( QGradient* gradient, double alpha ) void QgsGradientColorRamp::addStopsToGradient( QGradient* gradient, double alpha )
{ {
//copy color ramp stops to a QGradient //copy color ramp stops to a QGradient
QColor color1 = mColor1; QColor color1 = mColor1;
@ -277,7 +277,7 @@ void QgsVectorGradientColorRamp::addStopsToGradient( QGradient* gradient, double
////////////// //////////////
QgsVectorRandomColorRamp::QgsVectorRandomColorRamp( int count, int hueMin, int hueMax, QgsLimitedRandomColorRamp::QgsLimitedRandomColorRamp( int count, int hueMin, int hueMax,
int satMin, int satMax, int valMin, int valMax ) int satMin, int satMax, int valMin, int valMax )
: mCount( count ) : mCount( count )
, mHueMin( hueMin ), mHueMax( hueMax ) , mHueMin( hueMin ), mHueMax( hueMax )
@ -287,7 +287,7 @@ QgsVectorRandomColorRamp::QgsVectorRandomColorRamp( int count, int hueMin, int h
updateColors(); updateColors();
} }
QgsVectorColorRamp* QgsVectorRandomColorRamp::create( const QgsStringMap& props ) QgsColorRamp* QgsLimitedRandomColorRamp::create( const QgsStringMap& props )
{ {
int count = DEFAULT_RANDOM_COUNT; int count = DEFAULT_RANDOM_COUNT;
int hueMin = DEFAULT_RANDOM_HUE_MIN, hueMax = DEFAULT_RANDOM_HUE_MAX; int hueMin = DEFAULT_RANDOM_HUE_MIN, hueMax = DEFAULT_RANDOM_HUE_MAX;
@ -302,16 +302,16 @@ QgsVectorColorRamp* QgsVectorRandomColorRamp::create( const QgsStringMap& props
if ( props.contains( "valMin" ) ) valMin = props["valMin"].toInt(); if ( props.contains( "valMin" ) ) valMin = props["valMin"].toInt();
if ( props.contains( "valMax" ) ) valMax = props["valMax"].toInt(); if ( props.contains( "valMax" ) ) valMax = props["valMax"].toInt();
return new QgsVectorRandomColorRamp( count, hueMin, hueMax, satMin, satMax, valMin, valMax ); return new QgsLimitedRandomColorRamp( count, hueMin, hueMax, satMin, satMax, valMin, valMax );
} }
double QgsVectorRandomColorRamp::value( int index ) const double QgsLimitedRandomColorRamp::value( int index ) const
{ {
if ( mColors.size() < 1 ) return 0; if ( mColors.size() < 1 ) return 0;
return static_cast< double >( index ) / ( mColors.size() - 1 ); return static_cast< double >( index ) / ( mColors.size() - 1 );
} }
QColor QgsVectorRandomColorRamp::color( double value ) const QColor QgsLimitedRandomColorRamp::color( double value ) const
{ {
int colorCnt = mColors.count(); int colorCnt = mColors.count();
int colorIdx = static_cast< int >( value * ( colorCnt - 1 ) ); int colorIdx = static_cast< int >( value * ( colorCnt - 1 ) );
@ -322,12 +322,12 @@ QColor QgsVectorRandomColorRamp::color( double value ) const
return QColor(); return QColor();
} }
QgsVectorRandomColorRamp* QgsVectorRandomColorRamp::clone() const QgsLimitedRandomColorRamp* QgsLimitedRandomColorRamp::clone() const
{ {
return new QgsVectorRandomColorRamp( mCount, mHueMin, mHueMax, mSatMin, mSatMax, mValMin, mValMax ); return new QgsLimitedRandomColorRamp( mCount, mHueMin, mHueMax, mSatMin, mSatMax, mValMin, mValMax );
} }
QgsStringMap QgsVectorRandomColorRamp::properties() const QgsStringMap QgsLimitedRandomColorRamp::properties() const
{ {
QgsStringMap map; QgsStringMap map;
map["count"] = QString::number( mCount ); map["count"] = QString::number( mCount );
@ -340,7 +340,7 @@ QgsStringMap QgsVectorRandomColorRamp::properties() const
return map; return map;
} }
QList<QColor> QgsVectorRandomColorRamp::randomColors( int count, QList<QColor> QgsLimitedRandomColorRamp::randomColors( int count,
int hueMax, int hueMin, int satMax, int satMin, int valMax, int valMin ) int hueMax, int hueMin, int satMax, int satMin, int valMax, int valMin )
{ {
int h, s, v; int h, s, v;
@ -373,35 +373,35 @@ QList<QColor> QgsVectorRandomColorRamp::randomColors( int count,
return colors; return colors;
} }
void QgsVectorRandomColorRamp::updateColors() void QgsLimitedRandomColorRamp::updateColors()
{ {
mColors = QgsVectorRandomColorRamp::randomColors( mCount, mHueMax, mHueMin, mSatMax, mSatMin, mValMax, mValMin ); mColors = QgsLimitedRandomColorRamp::randomColors( mCount, mHueMax, mHueMin, mSatMax, mSatMin, mValMax, mValMin );
} }
///////////// /////////////
QgsRandomColors::QgsRandomColors() QgsRandomColorRamp::QgsRandomColorRamp()
: mTotalColorCount( 0 ) : mTotalColorCount( 0 )
{ {
} }
QgsRandomColors::~QgsRandomColors() QgsRandomColorRamp::~QgsRandomColorRamp()
{ {
} }
int QgsRandomColors::count() const int QgsRandomColorRamp::count() const
{ {
return -1; return -1;
} }
double QgsRandomColors::value( int index ) const double QgsRandomColorRamp::value( int index ) const
{ {
Q_UNUSED( index ); Q_UNUSED( index );
return 0.0; return 0.0;
} }
QColor QgsRandomColors::color( double value ) const QColor QgsRandomColorRamp::color( double value ) const
{ {
int minVal = 130; int minVal = 130;
int maxVal = 255; int maxVal = 255;
@ -421,7 +421,7 @@ QColor QgsRandomColors::color( double value ) const
return QColor::fromHsv( h, s, v ); return QColor::fromHsv( h, s, v );
} }
void QgsRandomColors::setTotalColorCount( const int colorCount ) void QgsRandomColorRamp::setTotalColorCount( const int colorCount )
{ {
//calculate colors in advance, so that we can ensure they are more visually distinct than pure random colors //calculate colors in advance, so that we can ensure they are more visually distinct than pure random colors
mPrecalculatedColors.clear(); mPrecalculatedColors.clear();
@ -453,31 +453,31 @@ void QgsRandomColors::setTotalColorCount( const int colorCount )
std::random_shuffle( mPrecalculatedColors.begin(), mPrecalculatedColors.end() ); std::random_shuffle( mPrecalculatedColors.begin(), mPrecalculatedColors.end() );
} }
QString QgsRandomColors::type() const QString QgsRandomColorRamp::type() const
{ {
return "randomcolors"; return "randomcolors";
} }
QgsRandomColors* QgsRandomColors::clone() const QgsRandomColorRamp* QgsRandomColorRamp::clone() const
{ {
return new QgsRandomColors(); return new QgsRandomColorRamp();
} }
QgsStringMap QgsRandomColors::properties() const QgsStringMap QgsRandomColorRamp::properties() const
{ {
return QgsStringMap(); return QgsStringMap();
} }
//////////// ////////////
QgsVectorColorBrewerColorRamp::QgsVectorColorBrewerColorRamp( const QString& schemeName, int colors ) QgsColorBrewerColorRamp::QgsColorBrewerColorRamp( const QString& schemeName, int colors )
: mSchemeName( schemeName ) : mSchemeName( schemeName )
, mColors( colors ) , mColors( colors )
{ {
loadPalette(); loadPalette();
} }
QgsVectorColorRamp* QgsVectorColorBrewerColorRamp::create( const QgsStringMap& props ) QgsColorRamp* QgsColorBrewerColorRamp::create( const QgsStringMap& props )
{ {
QString schemeName = DEFAULT_COLORBREWER_SCHEMENAME; QString schemeName = DEFAULT_COLORBREWER_SCHEMENAME;
int colors = DEFAULT_COLORBREWER_COLORS; int colors = DEFAULT_COLORBREWER_COLORS;
@ -487,31 +487,31 @@ QgsVectorColorRamp* QgsVectorColorBrewerColorRamp::create( const QgsStringMap& p
if ( props.contains( "colors" ) ) if ( props.contains( "colors" ) )
colors = props["colors"].toInt(); colors = props["colors"].toInt();
return new QgsVectorColorBrewerColorRamp( schemeName, colors ); return new QgsColorBrewerColorRamp( schemeName, colors );
} }
void QgsVectorColorBrewerColorRamp::loadPalette() void QgsColorBrewerColorRamp::loadPalette()
{ {
mPalette = QgsColorBrewerPalette::listSchemeColors( mSchemeName, mColors ); mPalette = QgsColorBrewerPalette::listSchemeColors( mSchemeName, mColors );
} }
QStringList QgsVectorColorBrewerColorRamp::listSchemeNames() QStringList QgsColorBrewerColorRamp::listSchemeNames()
{ {
return QgsColorBrewerPalette::listSchemes(); return QgsColorBrewerPalette::listSchemes();
} }
QList<int> QgsVectorColorBrewerColorRamp::listSchemeVariants( const QString& schemeName ) QList<int> QgsColorBrewerColorRamp::listSchemeVariants( const QString& schemeName )
{ {
return QgsColorBrewerPalette::listSchemeVariants( schemeName ); return QgsColorBrewerPalette::listSchemeVariants( schemeName );
} }
double QgsVectorColorBrewerColorRamp::value( int index ) const double QgsColorBrewerColorRamp::value( int index ) const
{ {
if ( mPalette.size() < 1 ) return 0; if ( mPalette.size() < 1 ) return 0;
return static_cast< double >( index ) / ( mPalette.size() - 1 ); return static_cast< double >( index ) / ( mPalette.size() - 1 );
} }
QColor QgsVectorColorBrewerColorRamp::color( double value ) const QColor QgsColorBrewerColorRamp::color( double value ) const
{ {
if ( mPalette.isEmpty() || value < 0 || value > 1 ) if ( mPalette.isEmpty() || value < 0 || value > 1 )
return QColor(); return QColor();
@ -522,12 +522,12 @@ QColor QgsVectorColorBrewerColorRamp::color( double value ) const
return mPalette.at( paletteEntry ); return mPalette.at( paletteEntry );
} }
QgsVectorColorBrewerColorRamp* QgsVectorColorBrewerColorRamp::clone() const QgsColorBrewerColorRamp* QgsColorBrewerColorRamp::clone() const
{ {
return new QgsVectorColorBrewerColorRamp( mSchemeName, mColors ); return new QgsColorBrewerColorRamp( mSchemeName, mColors );
} }
QgsStringMap QgsVectorColorBrewerColorRamp::properties() const QgsStringMap QgsColorBrewerColorRamp::properties() const
{ {
QgsStringMap map; QgsStringMap map;
map["schemeName"] = mSchemeName; map["schemeName"] = mSchemeName;
@ -541,7 +541,7 @@ QgsStringMap QgsVectorColorBrewerColorRamp::properties() const
QgsCptCityColorRamp::QgsCptCityColorRamp( const QString& schemeName, const QString& variantName, QgsCptCityColorRamp::QgsCptCityColorRamp( const QString& schemeName, const QString& variantName,
bool doLoadFile ) bool doLoadFile )
: QgsVectorGradientColorRamp() : QgsGradientColorRamp()
, mSchemeName( schemeName ), mVariantName( variantName ) , mSchemeName( schemeName ), mVariantName( variantName )
, mVariantList( QStringList() ), mFileLoaded( false ), mMultiStops( false ) , mVariantList( QStringList() ), mFileLoaded( false ), mMultiStops( false )
{ {
@ -553,7 +553,7 @@ QgsCptCityColorRamp::QgsCptCityColorRamp( const QString& schemeName, const QStri
QgsCptCityColorRamp::QgsCptCityColorRamp( const QString& schemeName, const QStringList& variantList, QgsCptCityColorRamp::QgsCptCityColorRamp( const QString& schemeName, const QStringList& variantList,
const QString& variantName, bool doLoadFile ) const QString& variantName, bool doLoadFile )
: QgsVectorGradientColorRamp() : QgsGradientColorRamp()
, mSchemeName( schemeName ), mVariantName( variantName ) , mSchemeName( schemeName ), mVariantName( variantName )
, mVariantList( variantList ), mFileLoaded( false ), mMultiStops( false ) , mVariantList( variantList ), mFileLoaded( false ), mMultiStops( false )
{ {
@ -565,7 +565,7 @@ QgsCptCityColorRamp::QgsCptCityColorRamp( const QString& schemeName, const QStri
loadFile(); loadFile();
} }
QgsVectorColorRamp* QgsCptCityColorRamp::create( const QgsStringMap& props ) QgsColorRamp* QgsCptCityColorRamp::create( const QgsStringMap& props )
{ {
QString schemeName = DEFAULT_CPTCITY_SCHEMENAME; QString schemeName = DEFAULT_CPTCITY_SCHEMENAME;
QString variantName = DEFAULT_CPTCITY_VARIANTNAME; QString variantName = DEFAULT_CPTCITY_VARIANTNAME;
@ -599,10 +599,10 @@ void QgsCptCityColorRamp::copy( const QgsCptCityColorRamp* other )
mFileLoaded = other->mFileLoaded; mFileLoaded = other->mFileLoaded;
} }
QgsVectorGradientColorRamp* QgsCptCityColorRamp::cloneGradientRamp() const QgsGradientColorRamp* QgsCptCityColorRamp::cloneGradientRamp() const
{ {
QgsVectorGradientColorRamp* ramp = QgsGradientColorRamp* ramp =
new QgsVectorGradientColorRamp( mColor1, mColor2, mDiscrete, mStops ); new QgsGradientColorRamp( mColor1, mColor2, mDiscrete, mStops );
// add author and copyright information // add author and copyright information
// TODO also add COPYING.xml file/link? // TODO also add COPYING.xml file/link?
QgsStringMap info = copyingInfo(); QgsStringMap info = copyingInfo();

View File

@ -1,5 +1,5 @@
/*************************************************************************** /***************************************************************************
qgsvectorcolorramp.h qgscolorramp.h
--------------------- ---------------------
begin : November 2009 begin : November 2009
copyright : (C) 2009 by Martin Dobias copyright : (C) 2009 by Martin Dobias
@ -13,23 +13,22 @@
* * * *
***************************************************************************/ ***************************************************************************/
#ifndef QGSVECTORCOLORRAMPV2_H #ifndef QGSCOLORRAMP_H
#define QGSVECTORCOLORRAMPV2_H #define QGSCOLORRAMP_H
#include <QColor> #include <QColor>
#include <QGradient> #include <QGradient>
#include "qgis.h" #include "qgis.h"
/** \ingroup core /** \ingroup core
* \class QgsVectorColorRamp * \class QgsColorRamp
* \brief Abstract base class for color ramps * \brief Abstract base class for color ramps
*/ */
//TODO QGIS 3.0 - rename to QgsColorRamp, since this is used by much more than just vectors class CORE_EXPORT QgsColorRamp
class CORE_EXPORT QgsVectorColorRamp
{ {
public: public:
virtual ~QgsVectorColorRamp() {} virtual ~QgsColorRamp() {}
/** Returns number of defined colors, or -1 if undefined /** Returns number of defined colors, or -1 if undefined
*/ */
@ -51,7 +50,7 @@ class CORE_EXPORT QgsVectorColorRamp
/** Creates a clone of the color ramp. /** Creates a clone of the color ramp.
*/ */
virtual QgsVectorColorRamp* clone() const = 0; virtual QgsColorRamp* clone() const = 0;
/** Returns a string map containing all the color ramp's properties. /** Returns a string map containing all the color ramp's properties.
*/ */
@ -60,19 +59,19 @@ class CORE_EXPORT QgsVectorColorRamp
/** \ingroup core /** \ingroup core
* \class QgsGradientStop * \class QgsGradientStop
* \brief Represents a color stop within a gradient color ramp. * \brief Represents a color stop within a QgsGradientColorRamp color ramp.
*/ */
class CORE_EXPORT QgsGradientStop class CORE_EXPORT QgsGradientStop
{ {
public: public:
/** Constructor for QgsGradientStop /** Constructor for QgsGradientStop
* @param o positional offset for stop, between 0 and 1.0 * @param offset positional offset for stop, between 0 and 1.0
* @param c color for stop * @param color color for stop
*/ */
QgsGradientStop( double o, const QColor& c ) QgsGradientStop( double offset, const QColor& color )
: offset( o ) : offset( offset )
, color( c ) , color( color )
{ } { }
//! Relative positional offset, between 0 and 1 //! Relative positional offset, between 0 and 1
@ -93,35 +92,34 @@ typedef QList<QgsGradientStop> QgsGradientStopsList;
#define DEFAULT_GRADIENT_COLOR2 QColor(0,255,0) #define DEFAULT_GRADIENT_COLOR2 QColor(0,255,0)
/** \ingroup core /** \ingroup core
* \class QgsVectorGradientColorRamp * \class QgsGradientColorRamp
* \brief Gradient color ramp, which smoothly interpolates between two colors and also * \brief Gradient color ramp, which smoothly interpolates between two colors and also
* supports optional extra color stops. * supports optional extra color stops.
*/ */
//TODO QGIS 3.0 - rename to QgsGradientColorRamp, since this is used by much more than just vectors class CORE_EXPORT QgsGradientColorRamp : public QgsColorRamp
class CORE_EXPORT QgsVectorGradientColorRamp : public QgsVectorColorRamp
{ {
public: public:
/** Constructor for QgsVectorGradientColorRamp /** Constructor for QgsGradientColorRamp
* @param color1 start color, corresponding to a position of 0.0 * @param color1 start color, corresponding to a position of 0.0
* @param color2 end color, corresponding to a position of 1.0 * @param color2 end color, corresponding to a position of 1.0
* @param discrete set to true for discrete interpolation instead of smoothly * @param discrete set to true for discrete interpolation instead of smoothly
* interpolating between colors * interpolating between colors
* @param stops optional list of additional color stops * @param stops optional list of additional color stops
*/ */
QgsVectorGradientColorRamp( const QColor& color1 = DEFAULT_GRADIENT_COLOR1, QgsGradientColorRamp( const QColor& color1 = DEFAULT_GRADIENT_COLOR1,
const QColor& color2 = DEFAULT_GRADIENT_COLOR2, const QColor& color2 = DEFAULT_GRADIENT_COLOR2,
bool discrete = false, bool discrete = false,
const QgsGradientStopsList& stops = QgsGradientStopsList() ); const QgsGradientStopsList& stops = QgsGradientStopsList() );
//! Creates a new QgsVectorColorRamp from a map of properties //! Creates a new QgsColorRamp from a map of properties
static QgsVectorColorRamp* create( const QgsStringMap& properties = QgsStringMap() ); static QgsColorRamp* create( const QgsStringMap& properties = QgsStringMap() );
virtual int count() const override { return mStops.count() + 2; } virtual int count() const override { return mStops.count() + 2; }
virtual double value( int index ) const override; virtual double value( int index ) const override;
virtual QColor color( double value ) const override; virtual QColor color( double value ) const override;
virtual QString type() const override { return "gradient"; } virtual QString type() const override { return "gradient"; }
virtual QgsVectorGradientColorRamp* clone() const override; virtual QgsGradientColorRamp* clone() const override;
virtual QgsStringMap properties() const override; virtual QgsStringMap properties() const override;
/** Returns the gradient start color. /** Returns the gradient start color.
@ -221,19 +219,18 @@ class CORE_EXPORT QgsVectorGradientColorRamp : public QgsVectorColorRamp
#define DEFAULT_RANDOM_SAT_MAX 240 #define DEFAULT_RANDOM_SAT_MAX 240
/** \ingroup core /** \ingroup core
* \class QgsVectorRandomColorRamp * \class QgsLimitedRandomColorRamp
* \brief Random color ramp, which returns random colors based on preset parameters. * \brief Constrained random color ramp, which returns random colors based on preset parameters.
*/ */
//TODO QGIS 3.0 - rename to QgsRandomColorRamp, since this is used by much more than just vectors class CORE_EXPORT QgsLimitedRandomColorRamp : public QgsColorRamp
class CORE_EXPORT QgsVectorRandomColorRamp : public QgsVectorColorRamp
{ {
public: public:
QgsVectorRandomColorRamp( int count = DEFAULT_RANDOM_COUNT, QgsLimitedRandomColorRamp( int count = DEFAULT_RANDOM_COUNT,
int hueMin = DEFAULT_RANDOM_HUE_MIN, int hueMax = DEFAULT_RANDOM_HUE_MAX, int hueMin = DEFAULT_RANDOM_HUE_MIN, int hueMax = DEFAULT_RANDOM_HUE_MAX,
int satMin = DEFAULT_RANDOM_SAT_MIN, int satMax = DEFAULT_RANDOM_SAT_MAX, int satMin = DEFAULT_RANDOM_SAT_MIN, int satMax = DEFAULT_RANDOM_SAT_MAX,
int valMin = DEFAULT_RANDOM_VAL_MIN, int valMax = DEFAULT_RANDOM_VAL_MAX ); int valMin = DEFAULT_RANDOM_VAL_MIN, int valMax = DEFAULT_RANDOM_VAL_MAX );
static QgsVectorColorRamp* create( const QgsStringMap& properties = QgsStringMap() ); static QgsColorRamp* create( const QgsStringMap& properties = QgsStringMap() );
virtual double value( int index ) const override; virtual double value( int index ) const override;
@ -241,7 +238,7 @@ class CORE_EXPORT QgsVectorRandomColorRamp : public QgsVectorColorRamp
virtual QString type() const override { return "random"; } virtual QString type() const override { return "random"; }
virtual QgsVectorRandomColorRamp* clone() const override; virtual QgsLimitedRandomColorRamp* clone() const override;
virtual QgsStringMap properties() const override; virtual QgsStringMap properties() const override;
@ -278,13 +275,13 @@ class CORE_EXPORT QgsVectorRandomColorRamp : public QgsVectorColorRamp
}; };
/** \ingroup core /** \ingroup core
* \class QgsRandomColors * \class QgsRandomColorRamp
*/ */
class CORE_EXPORT QgsRandomColors: public QgsVectorColorRamp class CORE_EXPORT QgsRandomColorRamp: public QgsColorRamp
{ {
public: public:
QgsRandomColors(); QgsRandomColorRamp();
~QgsRandomColors(); ~QgsRandomColorRamp();
int count() const override; int count() const override;
@ -302,7 +299,7 @@ class CORE_EXPORT QgsRandomColors: public QgsVectorColorRamp
QString type() const override; QString type() const override;
QgsRandomColors* clone() const override; QgsRandomColorRamp* clone() const override;
QgsStringMap properties() const override; QgsStringMap properties() const override;
@ -318,15 +315,15 @@ class CORE_EXPORT QgsRandomColors: public QgsVectorColorRamp
#define DEFAULT_COLORBREWER_COLORS 5 #define DEFAULT_COLORBREWER_COLORS 5
/** \ingroup core /** \ingroup core
* \class QgsVectorColorBrewerColorRamp * \class QgsColorBrewerColorRamp
*/ */
class CORE_EXPORT QgsVectorColorBrewerColorRamp : public QgsVectorColorRamp class CORE_EXPORT QgsColorBrewerColorRamp : public QgsColorRamp
{ {
public: public:
QgsVectorColorBrewerColorRamp( const QString& schemeName = DEFAULT_COLORBREWER_SCHEMENAME, QgsColorBrewerColorRamp( const QString& schemeName = DEFAULT_COLORBREWER_SCHEMENAME,
int colors = DEFAULT_COLORBREWER_COLORS ); int colors = DEFAULT_COLORBREWER_COLORS );
static QgsVectorColorRamp* create( const QgsStringMap& properties = QgsStringMap() ); static QgsColorRamp* create( const QgsStringMap& properties = QgsStringMap() );
virtual double value( int index ) const override; virtual double value( int index ) const override;
@ -334,7 +331,7 @@ class CORE_EXPORT QgsVectorColorBrewerColorRamp : public QgsVectorColorRamp
virtual QString type() const override { return "colorbrewer"; } virtual QString type() const override { return "colorbrewer"; }
virtual QgsVectorColorBrewerColorRamp* clone() const override; virtual QgsColorBrewerColorRamp* clone() const override;
virtual QgsStringMap properties() const override; virtual QgsStringMap properties() const override;
@ -364,7 +361,7 @@ class CORE_EXPORT QgsVectorColorBrewerColorRamp : public QgsVectorColorRamp
/** \ingroup core /** \ingroup core
* \class QgsCptCityColorRamp * \class QgsCptCityColorRamp
*/ */
class CORE_EXPORT QgsCptCityColorRamp : public QgsVectorGradientColorRamp class CORE_EXPORT QgsCptCityColorRamp : public QgsGradientColorRamp
{ {
public: public:
QgsCptCityColorRamp( const QString& schemeName = DEFAULT_CPTCITY_SCHEMENAME, QgsCptCityColorRamp( const QString& schemeName = DEFAULT_CPTCITY_SCHEMENAME,
@ -373,13 +370,13 @@ class CORE_EXPORT QgsCptCityColorRamp : public QgsVectorGradientColorRamp
QgsCptCityColorRamp( const QString& schemeName, const QStringList& variantList, QgsCptCityColorRamp( const QString& schemeName, const QStringList& variantList,
const QString& variantName = QString(), bool doLoadFile = true ); const QString& variantName = QString(), bool doLoadFile = true );
static QgsVectorColorRamp* create( const QgsStringMap& properties = QgsStringMap() ); static QgsColorRamp* create( const QgsStringMap& properties = QgsStringMap() );
virtual QString type() const override { return "cpt-city"; } virtual QString type() const override { return "cpt-city"; }
virtual QgsCptCityColorRamp* clone() const override; virtual QgsCptCityColorRamp* clone() const override;
void copy( const QgsCptCityColorRamp* other ); void copy( const QgsCptCityColorRamp* other );
QgsVectorGradientColorRamp* cloneGradientRamp() const; QgsGradientColorRamp* cloneGradientRamp() const;
virtual QgsStringMap properties() const override; virtual QgsStringMap properties() const override;

View File

@ -38,7 +38,7 @@
#include "qgsogcutils.h" #include "qgsogcutils.h"
#include "qgsvectorlayer.h" #include "qgsvectorlayer.h"
#include "qgssymbollayerutils.h" #include "qgssymbollayerutils.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgsstyle.h" #include "qgsstyle.h"
#include "qgsexpressioncontext.h" #include "qgsexpressioncontext.h"
#include "qgsproject.h" #include "qgsproject.h"
@ -2669,7 +2669,7 @@ static QVariant fncColorRgba( const QVariantList &values, const QgsExpressionCon
QVariant fcnRampColor( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent ) QVariant fcnRampColor( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent )
{ {
QString rampName = getStringValue( values.at( 0 ), parent ); QString rampName = getStringValue( values.at( 0 ), parent );
const QgsVectorColorRamp *mRamp = QgsStyle::defaultStyle()->colorRampRef( rampName ); const QgsColorRamp *mRamp = QgsStyle::defaultStyle()->colorRampRef( rampName );
if ( ! mRamp ) if ( ! mRamp )
{ {
parent->setEvalErrorString( QObject::tr( "\"%1\" is not a valid color ramp" ).arg( rampName ) ); parent->setEvalErrorString( QObject::tr( "\"%1\" is not a valid color ramp" ).arg( rampName ) );

View File

@ -18,7 +18,7 @@
#include "qgssymbol.h" #include "qgssymbol.h"
#include "qgssymbollayerutils.h" #include "qgssymbollayerutils.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgspointdisplacementrenderer.h" #include "qgspointdisplacementrenderer.h"
#include "qgsinvertedpolygonrenderer.h" #include "qgsinvertedpolygonrenderer.h"
#include "qgspainteffect.h" #include "qgspainteffect.h"
@ -900,24 +900,24 @@ void QgsCategorizedSymbolRenderer::setSourceSymbol( QgsSymbol* sym )
mSourceSymbol.reset( sym ); mSourceSymbol.reset( sym );
} }
QgsVectorColorRamp* QgsCategorizedSymbolRenderer::sourceColorRamp() QgsColorRamp* QgsCategorizedSymbolRenderer::sourceColorRamp()
{ {
return mSourceColorRamp.data(); return mSourceColorRamp.data();
} }
void QgsCategorizedSymbolRenderer::setSourceColorRamp( QgsVectorColorRamp* ramp ) void QgsCategorizedSymbolRenderer::setSourceColorRamp( QgsColorRamp* ramp )
{ {
mSourceColorRamp.reset( ramp ); mSourceColorRamp.reset( ramp );
} }
void QgsCategorizedSymbolRenderer::updateColorRamp( QgsVectorColorRamp* ramp, bool inverted ) void QgsCategorizedSymbolRenderer::updateColorRamp( QgsColorRamp* ramp, bool inverted )
{ {
setSourceColorRamp( ramp ); setSourceColorRamp( ramp );
setInvertedColorRamp( inverted ); setInvertedColorRamp( inverted );
double num = mCategories.count() - 1; double num = mCategories.count() - 1;
double count = 0; double count = 0;
QgsRandomColors* randomRamp = dynamic_cast<QgsRandomColors*>( ramp ); QgsRandomColorRamp* randomRamp = dynamic_cast<QgsRandomColorRamp*>( ramp );
if ( randomRamp ) if ( randomRamp )
{ {
//ramp is a random colors ramp, so inform it of the total number of required colors //ramp is a random colors ramp, so inform it of the total number of required colors

View File

@ -22,7 +22,7 @@
#include <QHash> #include <QHash>
#include <QScopedPointer> #include <QScopedPointer>
class QgsVectorColorRamp; class QgsColorRamp;
class QgsVectorLayer; class QgsVectorLayer;
/** \ingroup core /** \ingroup core
@ -182,14 +182,14 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
* @see setSourceColorRamp() * @see setSourceColorRamp()
* @see sourceSymbol() * @see sourceSymbol()
*/ */
QgsVectorColorRamp* sourceColorRamp(); QgsColorRamp* sourceColorRamp();
/** Sets the source color ramp. /** Sets the source color ramp.
* @param ramp color ramp. Ownership is transferred to the renderer * @param ramp color ramp. Ownership is transferred to the renderer
* @see sourceColorRamp() * @see sourceColorRamp()
* @see setSourceSymbol() * @see setSourceSymbol()
*/ */
void setSourceColorRamp( QgsVectorColorRamp* ramp ); void setSourceColorRamp( QgsColorRamp* ramp );
//! @note added in 2.1 //! @note added in 2.1
bool invertedColorRamp() { return mInvertedColorRamp; } bool invertedColorRamp() { return mInvertedColorRamp; }
@ -200,7 +200,7 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
* @param inverted set to true to invert ramp colors * @param inverted set to true to invert ramp colors
* @note added in 2.5 * @note added in 2.5
*/ */
void updateColorRamp( QgsVectorColorRamp* ramp, bool inverted = false ); void updateColorRamp( QgsColorRamp* ramp, bool inverted = false );
Q_DECL_DEPRECATED void setRotationField( const QString& fieldOrExpression ) override; Q_DECL_DEPRECATED void setRotationField( const QString& fieldOrExpression ) override;
Q_DECL_DEPRECATED QString rotationField() const override; Q_DECL_DEPRECATED QString rotationField() const override;
@ -238,7 +238,7 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
QString mAttrName; QString mAttrName;
QgsCategoryList mCategories; QgsCategoryList mCategories;
QScopedPointer<QgsSymbol> mSourceSymbol; QScopedPointer<QgsSymbol> mSourceSymbol;
QScopedPointer<QgsVectorColorRamp> mSourceColorRamp; QScopedPointer<QgsColorRamp> mSourceColorRamp;
bool mInvertedColorRamp; bool mInvertedColorRamp;
QScopedPointer<QgsExpression> mRotation; QScopedPointer<QgsExpression> mRotation;
QScopedPointer<QgsExpression> mSizeScale; QScopedPointer<QgsExpression> mSizeScale;

View File

@ -17,7 +17,7 @@
#ifndef QGSCPTCITYARCHIVE_H #ifndef QGSCPTCITYARCHIVE_H
#define QGSCPTCITYARCHIVE_H #define QGSCPTCITYARCHIVE_H
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QIcon> #include <QIcon>

View File

@ -25,7 +25,7 @@
#include "qgsproject.h" #include "qgsproject.h"
#include "qgssvgcache.h" #include "qgssvgcache.h"
#include "qgslogger.h" #include "qgslogger.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgsunittypes.h" #include "qgsunittypes.h"
#include <QPainter> #include <QPainter>
@ -539,7 +539,7 @@ QgsSymbolLayer* QgsGradientFillSymbolLayer::create( const QgsStringMap& props )
offset = QgsSymbolLayerUtils::decodePoint( props["offset"] ); offset = QgsSymbolLayerUtils::decodePoint( props["offset"] );
//attempt to create color ramp from props //attempt to create color ramp from props
QgsVectorColorRamp* gradientRamp = QgsVectorGradientColorRamp::create( props ); QgsColorRamp* gradientRamp = QgsGradientColorRamp::create( props );
//create a new gradient fill layer with desired properties //create a new gradient fill layer with desired properties
QgsGradientFillSymbolLayer* sl = new QgsGradientFillSymbolLayer( color, color2, colorType, type, coordinateMode, gradientSpread ); QgsGradientFillSymbolLayer* sl = new QgsGradientFillSymbolLayer( color, color2, colorType, type, coordinateMode, gradientSpread );
@ -561,7 +561,7 @@ QgsSymbolLayer* QgsGradientFillSymbolLayer::create( const QgsStringMap& props )
return sl; return sl;
} }
void QgsGradientFillSymbolLayer::setColorRamp( QgsVectorColorRamp* ramp ) void QgsGradientFillSymbolLayer::setColorRamp( QgsColorRamp* ramp )
{ {
delete mGradientRamp; delete mGradientRamp;
mGradientRamp = ramp; mGradientRamp = ramp;
@ -765,7 +765,7 @@ QPointF QgsGradientFillSymbolLayer::rotateReferencePoint( QPointF refPoint, doub
void QgsGradientFillSymbolLayer::applyGradient( const QgsSymbolRenderContext &context, QBrush &brush, void QgsGradientFillSymbolLayer::applyGradient( const QgsSymbolRenderContext &context, QBrush &brush,
const QColor &color, const QColor &color2, GradientColorType gradientColorType, const QColor &color, const QColor &color2, GradientColorType gradientColorType,
QgsVectorColorRamp *gradientRamp, GradientType gradientType, QgsColorRamp *gradientRamp, GradientType gradientType,
GradientCoordinateMode coordinateMode, GradientSpread gradientSpread, GradientCoordinateMode coordinateMode, GradientSpread gradientSpread,
QPointF referencePoint1, QPointF referencePoint2, const double angle ) QPointF referencePoint1, QPointF referencePoint2, const double angle )
{ {
@ -819,7 +819,7 @@ void QgsGradientFillSymbolLayer::applyGradient( const QgsSymbolRenderContext &co
if ( gradientColorType == QgsGradientFillSymbolLayer::ColorRamp && gradientRamp && gradientRamp->type() == "gradient" ) if ( gradientColorType == QgsGradientFillSymbolLayer::ColorRamp && gradientRamp && gradientRamp->type() == "gradient" )
{ {
//color ramp gradient //color ramp gradient
QgsVectorGradientColorRamp* gradRamp = static_cast<QgsVectorGradientColorRamp*>( gradientRamp ); QgsGradientColorRamp* gradRamp = static_cast<QgsGradientColorRamp*>( gradientRamp );
gradRamp->addStopsToGradient( &gradient, context.alpha() ); gradRamp->addStopsToGradient( &gradient, context.alpha() );
} }
else else
@ -1021,7 +1021,7 @@ QgsSymbolLayer* QgsShapeburstFillSymbolLayer::create( const QgsStringMap& props
} }
//attempt to create color ramp from props //attempt to create color ramp from props
QgsVectorColorRamp* gradientRamp = QgsVectorGradientColorRamp::create( props ); QgsColorRamp* gradientRamp = QgsGradientColorRamp::create( props );
//create a new shapeburst fill layer with desired properties //create a new shapeburst fill layer with desired properties
QgsShapeburstFillSymbolLayer* sl = new QgsShapeburstFillSymbolLayer( color, color2, colorType, blurRadius, useWholeShape, maxDistance ); QgsShapeburstFillSymbolLayer* sl = new QgsShapeburstFillSymbolLayer( color, color2, colorType, blurRadius, useWholeShape, maxDistance );
@ -1061,7 +1061,7 @@ QString QgsShapeburstFillSymbolLayer::layerType() const
return "ShapeburstFill"; return "ShapeburstFill";
} }
void QgsShapeburstFillSymbolLayer::setColorRamp( QgsVectorColorRamp* ramp ) void QgsShapeburstFillSymbolLayer::setColorRamp( QgsColorRamp* ramp )
{ {
delete mGradientRamp; delete mGradientRamp;
mGradientRamp = ramp; mGradientRamp = ramp;
@ -1188,7 +1188,7 @@ void QgsShapeburstFillSymbolLayer::renderPolygon( const QPolygonF& points, QList
//if we are using the two color mode, create a gradient ramp //if we are using the two color mode, create a gradient ramp
if ( mColorType == QgsShapeburstFillSymbolLayer::SimpleTwoColor ) if ( mColorType == QgsShapeburstFillSymbolLayer::SimpleTwoColor )
{ {
mTwoColorGradientRamp = new QgsVectorGradientColorRamp( color1, color2 ); mTwoColorGradientRamp = new QgsGradientColorRamp( color1, color2 );
} }
//no border for shapeburst fills //no border for shapeburst fills
@ -1406,7 +1406,7 @@ double * QgsShapeburstFillSymbolLayer::distanceTransform( QImage *im )
return dtArray; return dtArray;
} }
void QgsShapeburstFillSymbolLayer::dtArrayToQImage( double * array, QImage *im, QgsVectorColorRamp* ramp, double layerAlpha, bool useWholeShape, int maxPixelDistance ) void QgsShapeburstFillSymbolLayer::dtArrayToQImage( double * array, QImage *im, QgsColorRamp* ramp, double layerAlpha, bool useWholeShape, int maxPixelDistance )
{ {
int width = im->width(); int width = im->width();
int height = im->height(); int height = im->height();

View File

@ -165,7 +165,7 @@ class CORE_EXPORT QgsSimpleFillSymbolLayer : public QgsFillSymbolLayer
void applyDataDefinedSymbology( QgsSymbolRenderContext& context, QBrush& brush, QPen& pen, QPen& selPen ); void applyDataDefinedSymbology( QgsSymbolRenderContext& context, QBrush& brush, QPen& pen, QPen& selPen );
}; };
class QgsVectorColorRamp; class QgsColorRamp;
/** \ingroup core /** \ingroup core
* \class QgsGradientFillSymbolLayer * \class QgsGradientFillSymbolLayer
@ -239,8 +239,8 @@ class CORE_EXPORT QgsGradientFillSymbolLayer : public QgsFillSymbolLayer
void setGradientColorType( GradientColorType gradientColorType ) { mGradientColorType = gradientColorType; } void setGradientColorType( GradientColorType gradientColorType ) { mGradientColorType = gradientColorType; }
/** Color ramp used for the gradient fill, only used if the gradient color type is set to ColorRamp*/ /** Color ramp used for the gradient fill, only used if the gradient color type is set to ColorRamp*/
QgsVectorColorRamp* colorRamp() { return mGradientRamp; } QgsColorRamp* colorRamp() { return mGradientRamp; }
void setColorRamp( QgsVectorColorRamp* ramp ); void setColorRamp( QgsColorRamp* ramp );
/** Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor*/ /** Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor*/
QColor color2() const { return mColor2; } QColor color2() const { return mColor2; }
@ -293,7 +293,7 @@ class CORE_EXPORT QgsGradientFillSymbolLayer : public QgsFillSymbolLayer
GradientColorType mGradientColorType; GradientColorType mGradientColorType;
QColor mColor2; QColor mColor2;
QgsVectorColorRamp* mGradientRamp; QgsColorRamp* mGradientRamp;
GradientType mGradientType; GradientType mGradientType;
GradientCoordinateMode mCoordinateMode; GradientCoordinateMode mCoordinateMode;
GradientSpread mGradientSpread; GradientSpread mGradientSpread;
@ -314,7 +314,7 @@ class CORE_EXPORT QgsGradientFillSymbolLayer : public QgsFillSymbolLayer
/** Applies the gradient to a brush*/ /** Applies the gradient to a brush*/
void applyGradient( const QgsSymbolRenderContext& context, QBrush& brush, const QColor& color, const QColor& color2, void applyGradient( const QgsSymbolRenderContext& context, QBrush& brush, const QColor& color, const QColor& color2,
GradientColorType gradientColorType, QgsVectorColorRamp *gradientRamp, GradientType gradientType, GradientColorType gradientColorType, QgsColorRamp *gradientRamp, GradientType gradientType,
GradientCoordinateMode coordinateMode, GradientSpread gradientSpread, GradientCoordinateMode coordinateMode, GradientSpread gradientSpread,
QPointF referencePoint1, QPointF referencePoint2, const double angle ); QPointF referencePoint1, QPointF referencePoint2, const double angle );
@ -425,7 +425,7 @@ class CORE_EXPORT QgsShapeburstFillSymbolLayer : public QgsFillSymbolLayer
void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; } void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; } const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
/** Sets the color mode to use for the shapeburst fill. Shapeburst can either be drawn using a QgsVectorColorRamp color ramp /** Sets the color mode to use for the shapeburst fill. Shapeburst can either be drawn using a QgsColorRamp color ramp
* or by simply specificing a start and end color. setColorType is used to specify which mode to use for the fill. * or by simply specificing a start and end color. setColorType is used to specify which mode to use for the fill.
* @param colorType color type to use for shapeburst fill * @param colorType color type to use for shapeburst fill
* @note added in 2.3 * @note added in 2.3
@ -435,7 +435,7 @@ class CORE_EXPORT QgsShapeburstFillSymbolLayer : public QgsFillSymbolLayer
* @see setColorRamp * @see setColorRamp
*/ */
void setColorType( ShapeburstColorType colorType ) { mColorType = colorType; } void setColorType( ShapeburstColorType colorType ) { mColorType = colorType; }
/** Returns the color mode used for the shapeburst fill. Shapeburst can either be drawn using a QgsVectorColorRamp color ramp /** Returns the color mode used for the shapeburst fill. Shapeburst can either be drawn using a QgsColorRamp color ramp
* or by simply specificing a start and end color. * or by simply specificing a start and end color.
* @returns current color mode used for the shapeburst fill * @returns current color mode used for the shapeburst fill
* @note added in 2.3 * @note added in 2.3
@ -452,14 +452,14 @@ class CORE_EXPORT QgsShapeburstFillSymbolLayer : public QgsFillSymbolLayer
* @see setColorType * @see setColorType
* @see colorRamp * @see colorRamp
*/ */
void setColorRamp( QgsVectorColorRamp* ramp ); void setColorRamp( QgsColorRamp* ramp );
/** Returns the color ramp used for the shapeburst fill. The color ramp is only used if the colorType is set to ShapeburstColorType::ColorRamp /** Returns the color ramp used for the shapeburst fill. The color ramp is only used if the colorType is set to ShapeburstColorType::ColorRamp
* @returns a QgsVectorColorRamp color ramp * @returns a QgsColorRamp color ramp
* @note added in 2.3 * @note added in 2.3
* @see setColorRamp * @see setColorRamp
* @see colorType * @see colorType
*/ */
QgsVectorColorRamp* colorRamp() { return mGradientRamp; } QgsColorRamp* colorRamp() { return mGradientRamp; }
/** Sets the color for the endpoint of the shapeburst fill. This color is only used if setColorType is set ShapeburstColorType::SimpleTwoColor. /** Sets the color for the endpoint of the shapeburst fill. This color is only used if setColorType is set ShapeburstColorType::SimpleTwoColor.
* @param color2 QColor to use for endpoint of gradient * @param color2 QColor to use for endpoint of gradient
@ -542,8 +542,8 @@ class CORE_EXPORT QgsShapeburstFillSymbolLayer : public QgsFillSymbolLayer
ShapeburstColorType mColorType; ShapeburstColorType mColorType;
QColor mColor2; QColor mColor2;
QgsVectorColorRamp* mGradientRamp; QgsColorRamp* mGradientRamp;
QgsVectorColorRamp* mTwoColorGradientRamp; QgsColorRamp* mTwoColorGradientRamp;
bool mIgnoreRings; bool mIgnoreRings;
@ -565,7 +565,7 @@ class CORE_EXPORT QgsShapeburstFillSymbolLayer : public QgsFillSymbolLayer
double * distanceTransform( QImage * im ); double * distanceTransform( QImage * im );
/* fills a QImage with values from an array of doubles containing squared distance transform values */ /* fills a QImage with values from an array of doubles containing squared distance transform values */
void dtArrayToQImage( double * array, QImage *im, QgsVectorColorRamp* ramp, double layerAlpha = 1, bool useWholeShape = true, int maxPixelDistance = 0 ); void dtArrayToQImage( double * array, QImage *im, QgsColorRamp* ramp, double layerAlpha = 1, bool useWholeShape = true, int maxPixelDistance = 0 );
}; };
/** \ingroup core /** \ingroup core

View File

@ -17,7 +17,7 @@
#include "qgssymbol.h" #include "qgssymbol.h"
#include "qgssymbollayerutils.h" #include "qgssymbollayerutils.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgspointdisplacementrenderer.h" #include "qgspointdisplacementrenderer.h"
#include "qgsinvertedpolygonrenderer.h" #include "qgsinvertedpolygonrenderer.h"
#include "qgspainteffect.h" #include "qgspainteffect.h"
@ -843,7 +843,7 @@ QgsGraduatedSymbolRenderer* QgsGraduatedSymbolRenderer::createRenderer(
int classes, int classes,
Mode mode, Mode mode,
QgsSymbol* symbol, QgsSymbol* symbol,
QgsVectorColorRamp* ramp, QgsColorRamp* ramp,
bool inverted, bool inverted,
const QgsRendererRangeLabelFormat& labelFormat const QgsRendererRangeLabelFormat& labelFormat
) )
@ -1315,12 +1315,12 @@ void QgsGraduatedSymbolRenderer::setSourceSymbol( QgsSymbol* sym )
mSourceSymbol.reset( sym ); mSourceSymbol.reset( sym );
} }
QgsVectorColorRamp* QgsGraduatedSymbolRenderer::sourceColorRamp() QgsColorRamp* QgsGraduatedSymbolRenderer::sourceColorRamp()
{ {
return mSourceColorRamp.data(); return mSourceColorRamp.data();
} }
void QgsGraduatedSymbolRenderer::setSourceColorRamp( QgsVectorColorRamp* ramp ) void QgsGraduatedSymbolRenderer::setSourceColorRamp( QgsColorRamp* ramp )
{ {
mSourceColorRamp.reset( ramp ); mSourceColorRamp.reset( ramp );
} }
@ -1371,7 +1371,7 @@ void QgsGraduatedSymbolRenderer::setSymbolSizes( double minSize, double maxSize
} }
} }
void QgsGraduatedSymbolRenderer::updateColorRamp( QgsVectorColorRamp *ramp, bool inverted ) void QgsGraduatedSymbolRenderer::updateColorRamp( QgsColorRamp *ramp, bool inverted )
{ {
int i = 0; int i = 0;
if ( ramp ) if ( ramp )

View File

@ -123,7 +123,7 @@ class CORE_EXPORT QgsRendererRangeLabelFormat
}; };
class QgsVectorLayer; class QgsVectorLayer;
class QgsVectorColorRamp; class QgsColorRamp;
Q_NOWARN_DEPRECATED_PUSH Q_NOWARN_DEPRECATED_PUSH
/** \ingroup core /** \ingroup core
@ -253,7 +253,7 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
int classes, int classes,
Mode mode, Mode mode,
QgsSymbol* symbol, QgsSymbol* symbol,
QgsVectorColorRamp* ramp, QgsColorRamp* ramp,
bool inverted = false, bool inverted = false,
const QgsRendererRangeLabelFormat& legendFormat = QgsRendererRangeLabelFormat() const QgsRendererRangeLabelFormat& legendFormat = QgsRendererRangeLabelFormat()
); );
@ -295,12 +295,12 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
* @see setSourceColorRamp() * @see setSourceColorRamp()
* @see sourceSymbol() * @see sourceSymbol()
*/ */
QgsVectorColorRamp* sourceColorRamp(); QgsColorRamp* sourceColorRamp();
/** Sets the source color ramp. /** Sets the source color ramp.
* @param ramp color ramp. Ownership is transferred to the renderer * @param ramp color ramp. Ownership is transferred to the renderer
*/ */
void setSourceColorRamp( QgsVectorColorRamp* ramp ); void setSourceColorRamp( QgsColorRamp* ramp );
//! @note added in 2.1 //! @note added in 2.1
bool invertedColorRamp() { return mInvertedColorRamp; } bool invertedColorRamp() { return mInvertedColorRamp; }
@ -311,7 +311,7 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
* @param ramp color ramp. Ownership is transferred to the renderer * @param ramp color ramp. Ownership is transferred to the renderer
* @param inverted set to true to invert ramp colors * @param inverted set to true to invert ramp colors
*/ */
void updateColorRamp( QgsVectorColorRamp* ramp = nullptr, bool inverted = false ); void updateColorRamp( QgsColorRamp* ramp = nullptr, bool inverted = false );
/** Update all the symbols but leave breaks and colors. This method also sets the source /** Update all the symbols but leave breaks and colors. This method also sets the source
* symbol for the renderer. * symbol for the renderer.
@ -380,7 +380,7 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
QgsRangeList mRanges; QgsRangeList mRanges;
Mode mMode; Mode mMode;
QScopedPointer<QgsSymbol> mSourceSymbol; QScopedPointer<QgsSymbol> mSourceSymbol;
QScopedPointer<QgsVectorColorRamp> mSourceColorRamp; QScopedPointer<QgsColorRamp> mSourceColorRamp;
bool mInvertedColorRamp; bool mInvertedColorRamp;
QgsRendererRangeLabelFormat mLabelFormat; QgsRendererRangeLabelFormat mLabelFormat;

View File

@ -23,7 +23,7 @@
#include "qgsvectorlayer.h" #include "qgsvectorlayer.h"
#include "qgssymbollayer.h" #include "qgssymbollayer.h"
#include "qgsogcutils.h" #include "qgsogcutils.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgsrendercontext.h" #include "qgsrendercontext.h"
#include "qgspainteffect.h" #include "qgspainteffect.h"
#include "qgspainteffectregistry.h" #include "qgspainteffectregistry.h"
@ -45,7 +45,7 @@ QgsHeatmapRenderer::QgsHeatmapRenderer()
, mRenderQuality( 3 ) , mRenderQuality( 3 )
, mFeaturesRendered( 0 ) , mFeaturesRendered( 0 )
{ {
mGradientRamp = new QgsVectorGradientColorRamp( QColor( 255, 255, 255 ), QColor( 0, 0, 0 ) ); mGradientRamp = new QgsGradientColorRamp( QColor( 255, 255, 255 ), QColor( 0, 0, 0 ) );
} }
@ -413,7 +413,7 @@ QgsHeatmapRenderer* QgsHeatmapRenderer::convertFromRenderer( const QgsFeatureRen
} }
} }
void QgsHeatmapRenderer::setColorRamp( QgsVectorColorRamp *ramp ) void QgsHeatmapRenderer::setColorRamp( QgsColorRamp *ramp )
{ {
delete mGradientRamp; delete mGradientRamp;
mGradientRamp = ramp; mGradientRamp = ramp;

View File

@ -22,7 +22,7 @@
#include "qgsgeometry.h" #include "qgsgeometry.h"
#include <QScopedPointer> #include <QScopedPointer>
class QgsVectorColorRamp; class QgsColorRamp;
/** \ingroup core /** \ingroup core
* \class QgsHeatmapRenderer * \class QgsHeatmapRenderer
@ -61,12 +61,12 @@ class CORE_EXPORT QgsHeatmapRenderer : public QgsFeatureRenderer
* @returns color ramp for heatmap * @returns color ramp for heatmap
* @see setColorRamp * @see setColorRamp
*/ */
QgsVectorColorRamp* colorRamp() const { return mGradientRamp; } QgsColorRamp* colorRamp() const { return mGradientRamp; }
/** Sets the color ramp to use for shading the heatmap. /** Sets the color ramp to use for shading the heatmap.
* @param ramp color ramp for heatmap. Ownership of ramp is transferred to the renderer. * @param ramp color ramp for heatmap. Ownership of ramp is transferred to the renderer.
* @see colorRamp * @see colorRamp
*/ */
void setColorRamp( QgsVectorColorRamp* ramp ); void setColorRamp( QgsColorRamp* ramp );
/** Returns whether the ramp is inverted /** Returns whether the ramp is inverted
* @returns true if color ramp is inverted * @returns true if color ramp is inverted
@ -185,7 +185,7 @@ class CORE_EXPORT QgsHeatmapRenderer : public QgsFeatureRenderer
int mWeightAttrNum; int mWeightAttrNum;
QScopedPointer<QgsExpression> mWeightExpression; QScopedPointer<QgsExpression> mWeightExpression;
QgsVectorColorRamp* mGradientRamp; QgsColorRamp* mGradientRamp;
bool mInvertRamp; bool mInvertRamp;
double mExplicitMax; double mExplicitMax;

View File

@ -16,7 +16,7 @@
#include "qgsstyle.h" #include "qgsstyle.h"
#include "qgssymbol.h" #include "qgssymbol.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgssymbollayerregistry.h" #include "qgssymbollayerregistry.h"
@ -183,7 +183,7 @@ QStringList QgsStyle::symbolNames()
} }
bool QgsStyle::addColorRamp( const QString& name, QgsVectorColorRamp* colorRamp, bool update ) bool QgsStyle::addColorRamp( const QString& name, QgsColorRamp* colorRamp, bool update )
{ {
if ( !colorRamp || name.isEmpty() ) if ( !colorRamp || name.isEmpty() )
return false; return false;
@ -207,7 +207,7 @@ bool QgsStyle::addColorRamp( const QString& name, QgsVectorColorRamp* colorRamp,
return true; return true;
} }
bool QgsStyle::saveColorRamp( const QString& name, QgsVectorColorRamp* ramp, int groupid, const QStringList& tags ) bool QgsStyle::saveColorRamp( const QString& name, QgsColorRamp* ramp, int groupid, const QStringList& tags )
{ {
// insert it into the database // insert it into the database
QDomDocument doc( "dummy" ); QDomDocument doc( "dummy" );
@ -238,7 +238,7 @@ bool QgsStyle::saveColorRamp( const QString& name, QgsVectorColorRamp* ramp, int
bool QgsStyle::removeColorRamp( const QString& name ) bool QgsStyle::removeColorRamp( const QString& name )
{ {
QgsVectorColorRamp *ramp = mColorRamps.take( name ); QgsColorRamp *ramp = mColorRamps.take( name );
if ( !ramp ) if ( !ramp )
return false; return false;
@ -254,13 +254,13 @@ bool QgsStyle::removeColorRamp( const QString& name )
return true; return true;
} }
QgsVectorColorRamp* QgsStyle::colorRamp( const QString& name ) QgsColorRamp* QgsStyle::colorRamp( const QString& name )
{ {
const QgsVectorColorRamp *ramp = colorRampRef( name ); const QgsColorRamp *ramp = colorRampRef( name );
return ramp ? ramp->clone() : nullptr; return ramp ? ramp->clone() : nullptr;
} }
const QgsVectorColorRamp* QgsStyle::colorRampRef( const QString& name ) const const QgsColorRamp* QgsStyle::colorRampRef( const QString& name ) const
{ {
return mColorRamps.value( name ); return mColorRamps.value( name );
} }
@ -343,7 +343,7 @@ bool QgsStyle::load( const QString& filename )
continue; continue;
} }
QDomElement rampElement = doc.documentElement(); QDomElement rampElement = doc.documentElement();
QgsVectorColorRamp *ramp = QgsSymbolLayerUtils::loadColorRamp( rampElement ); QgsColorRamp *ramp = QgsSymbolLayerUtils::loadColorRamp( rampElement );
if ( ramp ) if ( ramp )
mColorRamps.insert( ramp_name, ramp ); mColorRamps.insert( ramp_name, ramp );
} }
@ -374,7 +374,7 @@ bool QgsStyle::save( QString filename )
QDomElement rampsElem = doc.createElement( "colorramps" ); QDomElement rampsElem = doc.createElement( "colorramps" );
// save color ramps // save color ramps
for ( QMap<QString, QgsVectorColorRamp*>::iterator itr = mColorRamps.begin(); itr != mColorRamps.end(); ++itr ) for ( QMap<QString, QgsColorRamp*>::iterator itr = mColorRamps.begin(); itr != mColorRamps.end(); ++itr )
{ {
QDomElement rampEl = QgsSymbolLayerUtils::saveColorRamp( itr.key(), itr.value(), doc ); QDomElement rampEl = QgsSymbolLayerUtils::saveColorRamp( itr.key(), itr.value(), doc );
rampsElem.appendChild( rampEl ); rampsElem.appendChild( rampEl );
@ -440,7 +440,7 @@ bool QgsStyle::renameColorRamp( const QString& oldName, const QString& newName )
return false; return false;
} }
QgsVectorColorRamp *ramp = mColorRamps.take( oldName ); QgsColorRamp *ramp = mColorRamps.take( oldName );
if ( !ramp ) if ( !ramp )
return false; return false;
@ -1377,7 +1377,7 @@ bool QgsStyle::exportXml( const QString& filename )
QDomElement rampsElem = doc.createElement( "colorramps" ); QDomElement rampsElem = doc.createElement( "colorramps" );
// save color ramps // save color ramps
for ( QMap<QString, QgsVectorColorRamp*>::const_iterator itr = mColorRamps.constBegin(); itr != mColorRamps.constEnd(); ++itr ) for ( QMap<QString, QgsColorRamp*>::const_iterator itr = mColorRamps.constBegin(); itr != mColorRamps.constEnd(); ++itr )
{ {
QDomElement rampEl = QgsSymbolLayerUtils::saveColorRamp( itr.key(), itr.value(), doc ); QDomElement rampEl = QgsSymbolLayerUtils::saveColorRamp( itr.key(), itr.value(), doc );
rampsElem.appendChild( rampEl ); rampsElem.appendChild( rampEl );
@ -1482,7 +1482,7 @@ bool QgsStyle::importXml( const QString& filename )
{ {
if ( e.tagName() == "colorramp" ) if ( e.tagName() == "colorramp" )
{ {
QgsVectorColorRamp* ramp = QgsSymbolLayerUtils::loadColorRamp( e ); QgsColorRamp* ramp = QgsSymbolLayerUtils::loadColorRamp( e );
if ( ramp ) if ( ramp )
{ {
addColorRamp( e.attribute( "name" ), ramp ); addColorRamp( e.attribute( "name" ), ramp );

View File

@ -26,12 +26,12 @@
class QgsSymbol; class QgsSymbol;
class QgsSymbolLayer; class QgsSymbolLayer;
class QgsVectorColorRamp; class QgsColorRamp;
class QDomDocument; class QDomDocument;
class QDomElement; class QDomElement;
typedef QMap<QString, QgsVectorColorRamp* > QgsVectorColorRampMap; typedef QMap<QString, QgsColorRamp* > QgsVectorColorRampMap;
typedef QMap<int, QString> QgsSymbolGroupMap; typedef QMap<int, QString> QgsSymbolGroupMap;
/** \ingroup core /** \ingroup core
@ -90,7 +90,7 @@ class CORE_EXPORT QgsStyle : public QObject
* \param update set to true when the style DB has to be updated, by default it is false * \param update set to true when the style DB has to be updated, by default it is false
* \return success status of the operation * \return success status of the operation
*/ */
bool addColorRamp( const QString& name, QgsVectorColorRamp* colorRamp, bool update = false ); bool addColorRamp( const QString& name, QgsColorRamp* colorRamp, bool update = false );
//! adds a new group and returns the group's id //! adds a new group and returns the group's id
/*! /*!
@ -138,7 +138,7 @@ class CORE_EXPORT QgsStyle : public QObject
void clear(); void clear();
//! return a NEW copy of color ramp //! return a NEW copy of color ramp
QgsVectorColorRamp* colorRamp( const QString& name ); QgsColorRamp* colorRamp( const QString& name );
//! return count of color ramps //! return count of color ramps
int colorRampCount(); int colorRampCount();
@ -147,7 +147,7 @@ class CORE_EXPORT QgsStyle : public QObject
QStringList colorRampNames(); QStringList colorRampNames();
//! return a const pointer to a symbol (doesn't create new instance) //! return a const pointer to a symbol (doesn't create new instance)
const QgsVectorColorRamp* colorRampRef( const QString& name ) const; const QgsColorRamp* colorRampRef( const QString& name ) const;
//! return the id in the style database for the given colorramp name //! return the id in the style database for the given colorramp name
//! returns 0 if not found //! returns 0 if not found
@ -265,12 +265,12 @@ class CORE_EXPORT QgsStyle : public QObject
//! add the colorramp to the DB //! add the colorramp to the DB
/*! /*!
* \param name is the name of the colorramp as QString * \param name is the name of the colorramp as QString
* \param ramp is the pointer to the new QgsVectorColorRamp being saved * \param ramp is the pointer to the new QgsColorRamp being saved
* \param groupid is the id of the group to which the Color Ramp belongs. Pass 0 if it doesn't belong to any group or not known. * \param groupid is the id of the group to which the Color Ramp belongs. Pass 0 if it doesn't belong to any group or not known.
* \param tags is a list of tags that are associated with the color ramp as a QStringList. * \param tags is a list of tags that are associated with the color ramp as a QStringList.
* \return returns the success state of the save operation * \return returns the success state of the save operation
*/ */
bool saveColorRamp( const QString& name, QgsVectorColorRamp* ramp, int groupid, const QStringList& tags ); bool saveColorRamp( const QString& name, QgsColorRamp* ramp, int groupid, const QStringList& tags );
//! remove color ramp from style (and delete it) //! remove color ramp from style (and delete it)
bool removeColorRamp( const QString& name ); bool removeColorRamp( const QString& name );

View File

@ -18,7 +18,7 @@
#include "qgssymbollayer.h" #include "qgssymbollayer.h"
#include "qgssymbollayerregistry.h" #include "qgssymbollayerregistry.h"
#include "qgssymbol.h" #include "qgssymbol.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgsexpression.h" #include "qgsexpression.h"
#include "qgspainteffect.h" #include "qgspainteffect.h"
#include "qgspainteffectregistry.h" #include "qgspainteffectregistry.h"
@ -619,12 +619,12 @@ QIcon QgsSymbolLayerUtils::symbolLayerPreviewIcon( QgsSymbolLayer* layer, QgsUni
return QIcon( pixmap ); return QIcon( pixmap );
} }
QIcon QgsSymbolLayerUtils::colorRampPreviewIcon( QgsVectorColorRamp* ramp, QSize size ) QIcon QgsSymbolLayerUtils::colorRampPreviewIcon( QgsColorRamp* ramp, QSize size )
{ {
return QIcon( colorRampPreviewPixmap( ramp, size ) ); return QIcon( colorRampPreviewPixmap( ramp, size ) );
} }
QPixmap QgsSymbolLayerUtils::colorRampPreviewPixmap( QgsVectorColorRamp* ramp, QSize size ) QPixmap QgsSymbolLayerUtils::colorRampPreviewPixmap( QgsColorRamp* ramp, QSize size )
{ {
QPixmap pixmap( size ); QPixmap pixmap( size );
pixmap.fill( Qt::transparent ); pixmap.fill( Qt::transparent );
@ -2665,7 +2665,7 @@ void QgsSymbolLayerUtils::clearSymbolMap( QgsSymbolMap& symbols )
} }
QgsVectorColorRamp* QgsSymbolLayerUtils::loadColorRamp( QDomElement& element ) QgsColorRamp* QgsSymbolLayerUtils::loadColorRamp( QDomElement& element )
{ {
QString rampType = element.attribute( "type" ); QString rampType = element.attribute( "type" );
@ -2673,11 +2673,11 @@ QgsVectorColorRamp* QgsSymbolLayerUtils::loadColorRamp( QDomElement& element )
QgsStringMap props = QgsSymbolLayerUtils::parseProperties( element ); QgsStringMap props = QgsSymbolLayerUtils::parseProperties( element );
if ( rampType == "gradient" ) if ( rampType == "gradient" )
return QgsVectorGradientColorRamp::create( props ); return QgsGradientColorRamp::create( props );
else if ( rampType == "random" ) else if ( rampType == "random" )
return QgsVectorRandomColorRamp::create( props ); return QgsLimitedRandomColorRamp::create( props );
else if ( rampType == "colorbrewer" ) else if ( rampType == "colorbrewer" )
return QgsVectorColorBrewerColorRamp::create( props ); return QgsColorBrewerColorRamp::create( props );
else if ( rampType == "cpt-city" ) else if ( rampType == "cpt-city" )
return QgsCptCityColorRamp::create( props ); return QgsCptCityColorRamp::create( props );
else else
@ -2688,7 +2688,7 @@ QgsVectorColorRamp* QgsSymbolLayerUtils::loadColorRamp( QDomElement& element )
} }
QDomElement QgsSymbolLayerUtils::saveColorRamp( const QString& name, QgsVectorColorRamp* ramp, QDomDocument& doc ) QDomElement QgsSymbolLayerUtils::saveColorRamp( const QString& name, QgsColorRamp* ramp, QDomDocument& doc )
{ {
QDomElement rampEl = doc.createElement( "colorramp" ); QDomElement rampEl = doc.createElement( "colorramp" );
rampEl.setAttribute( "type", ramp->type() ); rampEl.setAttribute( "type", ramp->type() );

View File

@ -29,7 +29,7 @@
class QgsExpression; class QgsExpression;
class QgsSymbolLayer; class QgsSymbolLayer;
class QgsVectorColorRamp; class QgsColorRamp;
typedef QMap<QString, QString> QgsStringMap; typedef QMap<QString, QString> QgsStringMap;
typedef QMap<QString, QgsSymbol* > QgsSymbolMap; typedef QMap<QString, QgsSymbol* > QgsSymbolMap;
@ -138,13 +138,13 @@ class CORE_EXPORT QgsSymbolLayerUtils
*/ */
static QIcon symbolLayerPreviewIcon( QgsSymbolLayer* layer, QgsUnitTypes::RenderUnit u, QSize size, const QgsMapUnitScale& scale = QgsMapUnitScale() ); static QIcon symbolLayerPreviewIcon( QgsSymbolLayer* layer, QgsUnitTypes::RenderUnit u, QSize size, const QgsMapUnitScale& scale = QgsMapUnitScale() );
static QIcon colorRampPreviewIcon( QgsVectorColorRamp* ramp, QSize size ); static QIcon colorRampPreviewIcon( QgsColorRamp* ramp, QSize size );
static void drawStippledBackground( QPainter* painter, QRect rect ); static void drawStippledBackground( QPainter* painter, QRect rect );
//! @note customContext parameter added in 2.6 //! @note customContext parameter added in 2.6
static QPixmap symbolPreviewPixmap( QgsSymbol* symbol, QSize size, QgsRenderContext* customContext = nullptr ); static QPixmap symbolPreviewPixmap( QgsSymbol* symbol, QSize size, QgsRenderContext* customContext = nullptr );
static QPixmap colorRampPreviewPixmap( QgsVectorColorRamp* ramp, QSize size ); static QPixmap colorRampPreviewPixmap( QgsColorRamp* ramp, QSize size );
/** Returns the maximum estimated bleed for the symbol */ /** Returns the maximum estimated bleed for the symbol */
static double estimateMaxSymbolBleed( QgsSymbol* symbol ); static double estimateMaxSymbolBleed( QgsSymbol* symbol );
@ -297,8 +297,8 @@ class CORE_EXPORT QgsSymbolLayerUtils
static void clearSymbolMap( QgsSymbolMap& symbols ); static void clearSymbolMap( QgsSymbolMap& symbols );
static QgsVectorColorRamp* loadColorRamp( QDomElement& element ); static QgsColorRamp* loadColorRamp( QDomElement& element );
static QDomElement saveColorRamp( const QString& name, QgsVectorColorRamp* ramp, QDomDocument& doc ); static QDomElement saveColorRamp( const QString& name, QgsColorRamp* ramp, QDomDocument& doc );
/** /**
* Returns a friendly display name for a color * Returns a friendly display name for a color

View File

@ -23,7 +23,7 @@
#include "qgstransformeffect.h" #include "qgstransformeffect.h"
#include "qgscoloreffect.h" #include "qgscoloreffect.h"
#include "qgsstyle.h" #include "qgsstyle.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
// //
// draw source // draw source
@ -594,7 +594,7 @@ void QgsGlowWidget::applyColorRamp()
return; return;
} }
QgsVectorColorRamp* ramp = mRampComboBox->currentColorRamp(); QgsColorRamp* ramp = mRampComboBox->currentColorRamp();
if ( !ramp ) if ( !ramp )
return; return;

View File

@ -29,7 +29,7 @@
#define FRAME_MARGIN 2 #define FRAME_MARGIN 2
#define CLICK_THRESHOLD ( MARKER_WIDTH / 2 + 3 ) #define CLICK_THRESHOLD ( MARKER_WIDTH / 2 + 3 )
QgsGradientStopEditor::QgsGradientStopEditor( QWidget *parent, QgsVectorGradientColorRamp *ramp ) QgsGradientStopEditor::QgsGradientStopEditor( QWidget *parent, QgsGradientColorRamp *ramp )
: QWidget( parent ) : QWidget( parent )
, mSelectedStop( 0 ) , mSelectedStop( 0 )
{ {
@ -58,7 +58,7 @@ QgsGradientStopEditor::QgsGradientStopEditor( QWidget *parent, QgsVectorGradient
setAcceptDrops( true ); setAcceptDrops( true );
} }
void QgsGradientStopEditor::setGradientRamp( const QgsVectorGradientColorRamp &ramp ) void QgsGradientStopEditor::setGradientRamp( const QgsGradientColorRamp &ramp )
{ {
mGradient = ramp; mGradient = ramp;
mStops = mGradient.stops(); mStops = mGradient.stops();

View File

@ -16,7 +16,7 @@
#ifndef QGSGRADIENTSTOPEDITOR_H #ifndef QGSGRADIENTSTOPEDITOR_H
#define QGSGRADIENTSTOPEDITOR_H #define QGSGRADIENTSTOPEDITOR_H
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include <QWidget> #include <QWidget>
@ -37,18 +37,18 @@ class GUI_EXPORT QgsGradientStopEditor : public QWidget
* @param parent parent widget * @param parent parent widget
* @param ramp optional initial gradient ramp * @param ramp optional initial gradient ramp
*/ */
QgsGradientStopEditor( QWidget* parent = nullptr, QgsVectorGradientColorRamp* ramp = nullptr ); QgsGradientStopEditor( QWidget* parent = nullptr, QgsGradientColorRamp* ramp = nullptr );
/** Sets the current ramp shown in the editor. /** Sets the current ramp shown in the editor.
* @param ramp color ramp * @param ramp color ramp
* @see gradientRamp() * @see gradientRamp()
*/ */
void setGradientRamp( const QgsVectorGradientColorRamp& ramp ); void setGradientRamp( const QgsGradientColorRamp& ramp );
/** Returns the current ramp created by the editor. /** Returns the current ramp created by the editor.
* @see setGradientRamp() * @see setGradientRamp()
*/ */
QgsVectorGradientColorRamp gradientRamp() const { return mGradient; } QgsGradientColorRamp gradientRamp() const { return mGradient; }
/** Sets the currently selected stop. /** Sets the currently selected stop.
* @param index index of stop, where 0 corresponds to the first stop * @param index index of stop, where 0 corresponds to the first stop
@ -160,7 +160,7 @@ class GUI_EXPORT QgsGradientStopEditor : public QWidget
//! Returns the closest stop to a mouse x position, or -1 if no stops within tolerance //! Returns the closest stop to a mouse x position, or -1 if no stops within tolerance
int findClosestStop( int x, int threshold = -1 ) const; int findClosestStop( int x, int threshold = -1 ) const;
QgsVectorGradientColorRamp mGradient; QgsGradientColorRamp mGradient;
//! We keep a separate, unordered copy of the gradient stops so that the selected stop is not changed. //! We keep a separate, unordered copy of the gradient stops so that the selected stop is not changed.
QgsGradientStopsList mStops; QgsGradientStopsList mStops;

View File

@ -25,7 +25,7 @@
// for color ramps - todo add rasterStyle and refactor raster vs. vector ramps // for color ramps - todo add rasterStyle and refactor raster vs. vector ramps
#include "qgsstyle.h" #include "qgsstyle.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgscolordialog.h" #include "qgscolordialog.h"
#include <QFileDialog> #include <QFileDialog>
@ -332,7 +332,7 @@ void QgsSingleBandPseudoColorRendererWidget::on_mClassifyButton_clicked()
double min = lineEditValue( mMinLineEdit ); double min = lineEditValue( mMinLineEdit );
double max = lineEditValue( mMaxLineEdit ); double max = lineEditValue( mMaxLineEdit );
QScopedPointer< QgsVectorColorRamp > colorRamp( mColorRampComboBox->currentColorRamp() ); QScopedPointer< QgsColorRamp > colorRamp( mColorRampComboBox->currentColorRamp() );
if ( mClassificationModeComboBox->itemData( mClassificationModeComboBox->currentIndex() ).toInt() == Continuous ) if ( mClassificationModeComboBox->itemData( mClassificationModeComboBox->currentIndex() ).toInt() == Continuous )
{ {
@ -345,7 +345,7 @@ void QgsSingleBandPseudoColorRendererWidget::on_mClassifyButton_clicked()
double intervalDiff = max - min; double intervalDiff = max - min;
// remove last class when ColorRamp is gradient and discrete, as they are implemented with an extra stop // remove last class when ColorRamp is gradient and discrete, as they are implemented with an extra stop
QgsVectorGradientColorRamp* colorGradientRamp = dynamic_cast<QgsVectorGradientColorRamp*>( colorRamp.data() ); QgsGradientColorRamp* colorGradientRamp = dynamic_cast<QgsGradientColorRamp*>( colorRamp.data() );
if ( colorGradientRamp != NULL && colorGradientRamp->isDiscrete() ) if ( colorGradientRamp != NULL && colorGradientRamp->isDiscrete() )
{ {
numberOfEntries--; numberOfEntries--;
@ -515,7 +515,7 @@ void QgsSingleBandPseudoColorRendererWidget::on_mColorRampComboBox_currentIndexC
QSettings settings; QSettings settings;
settings.setValue( "/Raster/defaultPalette", mColorRampComboBox->currentText() ); settings.setValue( "/Raster/defaultPalette", mColorRampComboBox->currentText() );
QgsVectorColorRamp* ramp = mColorRampComboBox->currentColorRamp(); QgsColorRamp* ramp = mColorRampComboBox->currentColorRamp();
if ( !ramp ) if ( !ramp )
return; return;

View File

@ -20,7 +20,7 @@
#include "qgssymbol.h" #include "qgssymbol.h"
#include "qgssymbollayerutils.h" #include "qgssymbollayerutils.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgsstyle.h" #include "qgsstyle.h"
#include "qgslogger.h" #include "qgslogger.h"
@ -630,9 +630,9 @@ static void _createCategories( QgsCategoryList& cats, QList<QVariant>& values, Q
} }
} }
QgsVectorColorRamp* QgsCategorizedSymbolRendererWidget::getColorRamp() QgsColorRamp* QgsCategorizedSymbolRendererWidget::getColorRamp()
{ {
QgsVectorColorRamp* ramp = cboCategorizedColorRamp->currentColorRamp(); QgsColorRamp* ramp = cboCategorizedColorRamp->currentColorRamp();
if ( !ramp ) if ( !ramp )
{ {
if ( cboCategorizedColorRamp->count() == 0 ) if ( cboCategorizedColorRamp->count() == 0 )
@ -764,7 +764,7 @@ void QgsCategorizedSymbolRendererWidget::addCategories()
r->setScaleMethod( mRenderer->scaleMethod() ); r->setScaleMethod( mRenderer->scaleMethod() );
r->setSizeScaleField( mRenderer->sizeScaleField() ); r->setSizeScaleField( mRenderer->sizeScaleField() );
r->setInvertedColorRamp( cbxInvertedColorRamp->isChecked() ); r->setInvertedColorRamp( cbxInvertedColorRamp->isChecked() );
QgsVectorColorRamp* ramp = getColorRamp(); QgsColorRamp* ramp = getColorRamp();
if ( ramp ) r->setSourceColorRamp( ramp->clone() ); if ( ramp ) r->setSourceColorRamp( ramp->clone() );
if ( mModel ) if ( mModel )
@ -785,7 +785,7 @@ void QgsCategorizedSymbolRendererWidget::applyColorRamp()
else else
mButtonEditRamp->setEnabled( true ); mButtonEditRamp->setEnabled( true );
QgsVectorColorRamp* ramp = getColorRamp(); QgsColorRamp* ramp = getColorRamp();
if ( ramp ) if ( ramp )
{ {
mRenderer->updateColorRamp( ramp, cbxInvertedColorRamp->isChecked() ); mRenderer->updateColorRamp( ramp, cbxInvertedColorRamp->isChecked() );

View File

@ -159,7 +159,7 @@ class GUI_EXPORT QgsCategorizedSymbolRendererWidget : public QgsRendererWidget,
void changeCategorySymbol(); void changeCategorySymbol();
QgsVectorColorRamp* getColorRamp(); QgsColorRamp* getColorRamp();
QList<QgsSymbol*> selectedSymbols() override; QList<QgsSymbol*> selectedSymbols() override;
QgsCategoryList selectedCategoryList(); QgsCategoryList selectedCategoryList();

View File

@ -15,7 +15,7 @@
#include "qgscolorrampcombobox.h" #include "qgscolorrampcombobox.h"
#include "qgssymbollayerutils.h" #include "qgssymbollayerutils.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgsstyle.h" #include "qgsstyle.h"
#include "qgsstylemanagerdialog.h" #include "qgsstylemanagerdialog.h"
@ -51,7 +51,7 @@ void QgsColorRampComboBox::populate( QgsStyle* style )
QStringList rampNames = mStyle->colorRampNames(); QStringList rampNames = mStyle->colorRampNames();
for ( QStringList::iterator it = rampNames.begin(); it != rampNames.end(); ++it ) for ( QStringList::iterator it = rampNames.begin(); it != rampNames.end(); ++it )
{ {
QgsVectorColorRamp* ramp = style->colorRamp( *it ); QgsColorRamp* ramp = style->colorRamp( *it );
if ( !mShowGradientOnly || ramp->type() == "gradient" ) if ( !mShowGradientOnly || ramp->type() == "gradient" )
{ {
@ -68,13 +68,13 @@ void QgsColorRampComboBox::populate( QgsStyle* style )
connect( this, SIGNAL( activated( int ) ), SLOT( colorRampChanged( int ) ) ); connect( this, SIGNAL( activated( int ) ), SLOT( colorRampChanged( int ) ) );
} }
QgsVectorColorRamp* QgsColorRampComboBox::currentColorRamp() QgsColorRamp* QgsColorRampComboBox::currentColorRamp()
{ {
QString rampName = currentText(); QString rampName = currentText();
if ( rampName == tr( "Random colors" ) ) if ( rampName == tr( "Random colors" ) )
{ {
return new QgsRandomColors(); return new QgsRandomColorRamp();
} }
else if ( rampName == "[source]" && mSourceColorRamp ) else if ( rampName == "[source]" && mSourceColorRamp )
return mSourceColorRamp->clone(); return mSourceColorRamp->clone();
@ -88,7 +88,7 @@ bool QgsColorRampComboBox::createNewColorRampSelected() const
return index == count() - 1; //create new ramp is last item in combobox return index == count() - 1; //create new ramp is last item in combobox
} }
void QgsColorRampComboBox::setSourceColorRamp( QgsVectorColorRamp* sourceRamp ) void QgsColorRampComboBox::setSourceColorRamp( QgsColorRamp* sourceRamp )
{ {
delete mSourceColorRamp; delete mSourceColorRamp;
mSourceColorRamp = sourceRamp->clone(); mSourceColorRamp = sourceRamp->clone();
@ -120,7 +120,7 @@ void QgsColorRampComboBox::colorRampChanged( int index )
return; return;
// put newly added ramp into the combo // put newly added ramp into the combo
QgsVectorColorRamp* ramp = mStyle->colorRamp( rampName ); QgsColorRamp* ramp = mStyle->colorRamp( rampName );
QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp, rampIconSize ); QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp, rampIconSize );
blockSignals( true ); // avoid calling this method again! blockSignals( true ); // avoid calling this method again!
@ -138,15 +138,15 @@ void QgsColorRampComboBox::colorRampChanged( int index )
void QgsColorRampComboBox::editSourceRamp() void QgsColorRampComboBox::editSourceRamp()
{ {
QgsVectorColorRamp* currentRamp = currentColorRamp(); QgsColorRamp* currentRamp = currentColorRamp();
if ( !currentRamp ) if ( !currentRamp )
return; return;
QScopedPointer<QgsVectorColorRamp> newRamp( currentRamp->clone() ); QScopedPointer<QgsColorRamp> newRamp( currentRamp->clone() );
if ( newRamp->type() == "gradient" ) if ( newRamp->type() == "gradient" )
{ {
QgsVectorGradientColorRamp* gradRamp = static_cast<QgsVectorGradientColorRamp*>( newRamp.data() ); QgsGradientColorRamp* gradRamp = static_cast<QgsGradientColorRamp*>( newRamp.data() );
QgsVectorGradientColorRampDialog dlg( gradRamp, this ); QgsVectorGradientColorRampDialog dlg( gradRamp, this );
if ( dlg.exec() && gradRamp ) if ( dlg.exec() && gradRamp )
{ {
@ -156,7 +156,7 @@ void QgsColorRampComboBox::editSourceRamp()
} }
else if ( newRamp->type() == "random" ) else if ( newRamp->type() == "random" )
{ {
QgsVectorRandomColorRamp* randRamp = static_cast<QgsVectorRandomColorRamp*>( newRamp.data() ); QgsLimitedRandomColorRamp* randRamp = static_cast<QgsLimitedRandomColorRamp*>( newRamp.data() );
QgsVectorRandomColorRampDialog dlg( randRamp, this ); QgsVectorRandomColorRampDialog dlg( randRamp, this );
if ( dlg.exec() ) if ( dlg.exec() )
{ {
@ -166,7 +166,7 @@ void QgsColorRampComboBox::editSourceRamp()
} }
else if ( newRamp->type() == "colorbrewer" ) else if ( newRamp->type() == "colorbrewer" )
{ {
QgsVectorColorBrewerColorRamp* brewerRamp = static_cast<QgsVectorColorBrewerColorRamp*>( newRamp.data() ); QgsColorBrewerColorRamp* brewerRamp = static_cast<QgsColorBrewerColorRamp*>( newRamp.data() );
QgsVectorColorBrewerColorRampDialog dlg( brewerRamp, this ); QgsVectorColorBrewerColorRampDialog dlg( brewerRamp, this );
if ( dlg.exec() ) if ( dlg.exec() )
{ {

View File

@ -18,7 +18,7 @@
#include <QComboBox> #include <QComboBox>
class QgsStyle; class QgsStyle;
class QgsVectorColorRamp; class QgsColorRamp;
/** \ingroup gui /** \ingroup gui
* \class QgsColorRampComboBox * \class QgsColorRampComboBox
@ -35,10 +35,10 @@ class GUI_EXPORT QgsColorRampComboBox : public QComboBox
void populate( QgsStyle* style ); void populate( QgsStyle* style );
//! add/select color ramp which was used previously by the renderer //! add/select color ramp which was used previously by the renderer
void setSourceColorRamp( QgsVectorColorRamp* sourceRamp ); void setSourceColorRamp( QgsColorRamp* sourceRamp );
//! return new instance of the current color ramp or NULL if there is no active color ramp //! return new instance of the current color ramp or NULL if there is no active color ramp
QgsVectorColorRamp* currentColorRamp(); QgsColorRamp* currentColorRamp();
/** Returns true if the current selection in the combo box is the option for creating /** Returns true if the current selection in the combo box is the option for creating
* a new color ramp * a new color ramp
@ -74,7 +74,7 @@ class GUI_EXPORT QgsColorRampComboBox : public QComboBox
protected: protected:
QgsStyle* mStyle; QgsStyle* mStyle;
QgsVectorColorRamp* mSourceColorRamp; // owns the copy QgsColorRamp* mSourceColorRamp; // owns the copy
private: private:
bool mShowGradientOnly; bool mShowGradientOnly;

View File

@ -16,7 +16,7 @@
#include "qgscptcitycolorrampdialog.h" #include "qgscptcitycolorrampdialog.h"
#include "qgscptcityarchive.h" #include "qgscptcityarchive.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgslogger.h" #include "qgslogger.h"
#include "qgsapplication.h" #include "qgsapplication.h"
#include "qgsdialog.h" #include "qgsdialog.h"

View File

@ -17,7 +17,7 @@
#include "qgssymbol.h" #include "qgssymbol.h"
#include "qgssymbollayerutils.h" #include "qgssymbollayerutils.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgsstyle.h" #include "qgsstyle.h"
#include "qgsvectorlayer.h" #include "qgsvectorlayer.h"
@ -657,7 +657,7 @@ void QgsGraduatedSymbolRendererWidget::on_methodComboBox_currentIndexChanged( in
if ( idx == 0 ) if ( idx == 0 )
{ {
mRenderer->setGraduatedMethod( QgsGraduatedSymbolRenderer::GraduatedColor ); mRenderer->setGraduatedMethod( QgsGraduatedSymbolRenderer::GraduatedColor );
QgsVectorColorRamp* ramp = cboGraduatedColorRamp->currentColorRamp(); QgsColorRamp* ramp = cboGraduatedColorRamp->currentColorRamp();
if ( !ramp ) if ( !ramp )
{ {
@ -742,7 +742,7 @@ void QgsGraduatedSymbolRendererWidget::classifyGraduated()
int nclasses = spinGraduatedClasses->value(); int nclasses = spinGraduatedClasses->value();
QSharedPointer<QgsVectorColorRamp> ramp( cboGraduatedColorRamp->currentColorRamp() ); QSharedPointer<QgsColorRamp> ramp( cboGraduatedColorRamp->currentColorRamp() );
if ( !ramp ) if ( !ramp )
{ {
if ( cboGraduatedColorRamp->count() == 0 ) if ( cboGraduatedColorRamp->count() == 0 )
@ -779,7 +779,7 @@ void QgsGraduatedSymbolRendererWidget::classifyGraduated()
if ( methodComboBox->currentIndex() == 0 ) if ( methodComboBox->currentIndex() == 0 )
{ {
QgsVectorColorRamp* ramp = cboGraduatedColorRamp->currentColorRamp(); QgsColorRamp* ramp = cboGraduatedColorRamp->currentColorRamp();
if ( !ramp ) if ( !ramp )
{ {
@ -811,7 +811,7 @@ void QgsGraduatedSymbolRendererWidget::classifyGraduated()
void QgsGraduatedSymbolRendererWidget::reapplyColorRamp() void QgsGraduatedSymbolRendererWidget::reapplyColorRamp()
{ {
QgsVectorColorRamp* ramp = cboGraduatedColorRamp->currentColorRamp(); QgsColorRamp* ramp = cboGraduatedColorRamp->currentColorRamp();
if ( !ramp ) if ( !ramp )
return; return;

View File

@ -20,7 +20,7 @@
#include "qgslogger.h" #include "qgslogger.h"
#include "qgsvectorlayer.h" #include "qgsvectorlayer.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgsstyle.h" #include "qgsstyle.h"
#include "qgsproject.h" #include "qgsproject.h"
#include "qgsmapcanvas.h" #include "qgsmapcanvas.h"
@ -142,7 +142,7 @@ void QgsHeatmapRendererWidget::applyColorRamp()
return; return;
} }
QgsVectorColorRamp* ramp = mRampComboBox->currentColorRamp(); QgsColorRamp* ramp = mRampComboBox->currentColorRamp();
if ( !ramp ) if ( !ramp )
return; return;

View File

@ -20,7 +20,7 @@
#include "qgsstyle.h" #include "qgsstyle.h"
#include "qgssymbol.h" #include "qgssymbol.h"
#include "qgssymbollayerutils.h" #include "qgssymbollayerutils.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgslogger.h" #include "qgslogger.h"
#include "qgsstylegroupselectiondialog.h" #include "qgsstylegroupselectiondialog.h"
@ -203,7 +203,7 @@ bool QgsStyleExportImportDialog::populateStyles( QgsStyle* style )
for ( int i = 0; i < styleNames.count(); ++i ) for ( int i = 0; i < styleNames.count(); ++i )
{ {
name = styleNames[i]; name = styleNames[i];
QgsVectorColorRamp* ramp = style->colorRamp( name ); QgsColorRamp* ramp = style->colorRamp( name );
QStandardItem* item = new QStandardItem( name ); QStandardItem* item = new QStandardItem( name );
QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp, listItems->iconSize() ); QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp, listItems->iconSize() );
@ -218,7 +218,7 @@ void QgsStyleExportImportDialog::moveStyles( QModelIndexList* selection, QgsStyl
{ {
QString symbolName; QString symbolName;
QgsSymbol* symbol; QgsSymbol* symbol;
QgsVectorColorRamp *ramp = nullptr; QgsColorRamp *ramp = nullptr;
QModelIndex index; QModelIndex index;
bool isSymbol = true; bool isSymbol = true;
bool prompt = true; bool prompt = true;

View File

@ -18,7 +18,7 @@
#include "qgsstyle.h" #include "qgsstyle.h"
#include "qgssymbol.h" #include "qgssymbol.h"
#include "qgssymbollayerutils.h" #include "qgssymbollayerutils.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgssymbolselectordialog.h" #include "qgssymbolselectordialog.h"
#include "qgsvectorgradientcolorrampdialog.h" #include "qgsvectorgradientcolorrampdialog.h"
@ -292,7 +292,7 @@ void QgsStyleManagerDialog::populateColorRamps( const QStringList& colorRamps, b
for ( int i = 0; i < colorRamps.count(); ++i ) for ( int i = 0; i < colorRamps.count(); ++i )
{ {
QString name = colorRamps[i]; QString name = colorRamps[i];
QgsVectorColorRamp* ramp = mStyle->colorRamp( name ); QgsColorRamp* ramp = mStyle->colorRamp( name );
QStandardItem* item = new QStandardItem( name ); QStandardItem* item = new QStandardItem( name );
QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp, listItems->iconSize() ); QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp, listItems->iconSize() );
@ -454,10 +454,10 @@ QString QgsStyleManagerDialog::addColorRampStatic( QWidget* parent, QgsStyle* st
QString name = tr( "new ramp" ); QString name = tr( "new ramp" );
QgsVectorColorRamp *ramp = nullptr; QgsColorRamp *ramp = nullptr;
if ( rampType == tr( "Gradient" ) ) if ( rampType == tr( "Gradient" ) )
{ {
QgsVectorGradientColorRamp* gradRamp = new QgsVectorGradientColorRamp(); QgsGradientColorRamp* gradRamp = new QgsGradientColorRamp();
QgsVectorGradientColorRampDialog dlg( gradRamp, parent ); QgsVectorGradientColorRampDialog dlg( gradRamp, parent );
if ( !dlg.exec() ) if ( !dlg.exec() )
{ {
@ -469,7 +469,7 @@ QString QgsStyleManagerDialog::addColorRampStatic( QWidget* parent, QgsStyle* st
} }
else if ( rampType == tr( "Random" ) ) else if ( rampType == tr( "Random" ) )
{ {
QgsVectorRandomColorRamp* randRamp = new QgsVectorRandomColorRamp(); QgsLimitedRandomColorRamp* randRamp = new QgsLimitedRandomColorRamp();
QgsVectorRandomColorRampDialog dlg( randRamp, parent ); QgsVectorRandomColorRampDialog dlg( randRamp, parent );
if ( !dlg.exec() ) if ( !dlg.exec() )
{ {
@ -481,7 +481,7 @@ QString QgsStyleManagerDialog::addColorRampStatic( QWidget* parent, QgsStyle* st
} }
else if ( rampType == tr( "ColorBrewer" ) ) else if ( rampType == tr( "ColorBrewer" ) )
{ {
QgsVectorColorBrewerColorRamp* brewerRamp = new QgsVectorColorBrewerColorRamp(); QgsColorBrewerColorRamp* brewerRamp = new QgsColorBrewerColorRamp();
QgsVectorColorBrewerColorRampDialog dlg( brewerRamp, parent ); QgsVectorColorBrewerColorRampDialog dlg( brewerRamp, parent );
if ( !dlg.exec() ) if ( !dlg.exec() )
{ {
@ -633,11 +633,11 @@ bool QgsStyleManagerDialog::editColorRamp()
if ( name.isEmpty() ) if ( name.isEmpty() )
return false; return false;
QgsVectorColorRamp* ramp = mStyle->colorRamp( name ); QgsColorRamp* ramp = mStyle->colorRamp( name );
if ( ramp->type() == "gradient" ) if ( ramp->type() == "gradient" )
{ {
QgsVectorGradientColorRamp* gradRamp = static_cast<QgsVectorGradientColorRamp*>( ramp ); QgsGradientColorRamp* gradRamp = static_cast<QgsGradientColorRamp*>( ramp );
QgsVectorGradientColorRampDialog dlg( gradRamp, this ); QgsVectorGradientColorRampDialog dlg( gradRamp, this );
if ( !dlg.exec() ) if ( !dlg.exec() )
{ {
@ -647,7 +647,7 @@ bool QgsStyleManagerDialog::editColorRamp()
} }
else if ( ramp->type() == "random" ) else if ( ramp->type() == "random" )
{ {
QgsVectorRandomColorRamp* randRamp = static_cast<QgsVectorRandomColorRamp*>( ramp ); QgsLimitedRandomColorRamp* randRamp = static_cast<QgsLimitedRandomColorRamp*>( ramp );
QgsVectorRandomColorRampDialog dlg( randRamp, this ); QgsVectorRandomColorRampDialog dlg( randRamp, this );
if ( !dlg.exec() ) if ( !dlg.exec() )
{ {
@ -657,7 +657,7 @@ bool QgsStyleManagerDialog::editColorRamp()
} }
else if ( ramp->type() == "colorbrewer" ) else if ( ramp->type() == "colorbrewer" )
{ {
QgsVectorColorBrewerColorRamp* brewerRamp = static_cast<QgsVectorColorBrewerColorRamp*>( ramp ); QgsColorBrewerColorRamp* brewerRamp = static_cast<QgsColorBrewerColorRamp*>( ramp );
QgsVectorColorBrewerColorRampDialog dlg( brewerRamp, this ); QgsVectorColorBrewerColorRampDialog dlg( brewerRamp, this );
if ( !dlg.exec() ) if ( !dlg.exec() )
{ {

View File

@ -27,7 +27,7 @@
#include "qgssymbolselectordialog.h" #include "qgssymbolselectordialog.h"
#include "qgssvgcache.h" #include "qgssvgcache.h"
#include "qgssymbollayerutils.h" #include "qgssymbollayerutils.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgsvectorgradientcolorrampdialog.h" #include "qgsvectorgradientcolorrampdialog.h"
#include "qgsdatadefined.h" #include "qgsdatadefined.h"
#include "qgsstyle.h" //for symbol selector dialog #include "qgsstyle.h" //for symbol selector dialog
@ -1233,7 +1233,7 @@ void QgsGradientFillSymbolLayerWidget::colorModeChanged()
void QgsGradientFillSymbolLayerWidget::applyColorRamp() void QgsGradientFillSymbolLayerWidget::applyColorRamp()
{ {
QgsVectorColorRamp* ramp = cboGradientColorRamp->currentColorRamp(); QgsColorRamp* ramp = cboGradientColorRamp->currentColorRamp();
if ( !ramp ) if ( !ramp )
return; return;
@ -1567,7 +1567,7 @@ void QgsShapeburstFillSymbolLayerWidget::on_mRadioUseWholeShape_toggled( bool va
void QgsShapeburstFillSymbolLayerWidget::applyColorRamp() void QgsShapeburstFillSymbolLayerWidget::applyColorRamp()
{ {
QgsVectorColorRamp* ramp = cboGradientColorRamp->currentColorRamp(); QgsColorRamp* ramp = cboGradientColorRamp->currentColorRamp();
if ( !ramp ) if ( !ramp )
return; return;

View File

@ -15,7 +15,7 @@
#include "qgsvectorcolorbrewercolorrampdialog.h" #include "qgsvectorcolorbrewercolorrampdialog.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgssymbollayerutils.h" #include "qgssymbollayerutils.h"
#include <QAbstractButton> #include <QAbstractButton>
@ -31,7 +31,7 @@ static void updateColorButton( QAbstractButton* button, QColor color )
///////// /////////
QgsVectorColorBrewerColorRampDialog::QgsVectorColorBrewerColorRampDialog( QgsVectorColorBrewerColorRamp* ramp, QWidget* parent ) QgsVectorColorBrewerColorRampDialog::QgsVectorColorBrewerColorRampDialog( QgsColorBrewerColorRamp* ramp, QWidget* parent )
: QDialog( parent ) : QDialog( parent )
, mRamp( ramp ) , mRamp( ramp )
{ {
@ -41,11 +41,11 @@ QgsVectorColorBrewerColorRampDialog::QgsVectorColorBrewerColorRampDialog( QgsVec
QSize iconSize( 50, 16 ); QSize iconSize( 50, 16 );
cboSchemeName->setIconSize( iconSize ); cboSchemeName->setIconSize( iconSize );
QStringList schemes = QgsVectorColorBrewerColorRamp::listSchemeNames(); QStringList schemes = QgsColorBrewerColorRamp::listSchemeNames();
Q_FOREACH ( const QString& schemeName, schemes ) Q_FOREACH ( const QString& schemeName, schemes )
{ {
// create a preview icon using five color variant // create a preview icon using five color variant
QgsVectorColorBrewerColorRamp* r = new QgsVectorColorBrewerColorRamp( schemeName, 5 ); QgsColorBrewerColorRamp* r = new QgsColorBrewerColorRamp( schemeName, 5 );
QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( r, iconSize ); QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( r, iconSize );
delete r; delete r;
cboSchemeName->addItem( icon, schemeName ); cboSchemeName->addItem( icon, schemeName );
@ -67,7 +67,7 @@ void QgsVectorColorBrewerColorRampDialog::populateVariants()
cboColors->clear(); cboColors->clear();
QString schemeName = cboSchemeName->currentText(); QString schemeName = cboSchemeName->currentText();
QList<int> variants = QgsVectorColorBrewerColorRamp::listSchemeVariants( schemeName ); QList<int> variants = QgsColorBrewerColorRamp::listSchemeVariants( schemeName );
Q_FOREACH ( int variant, variants ) Q_FOREACH ( int variant, variants )
{ {
cboColors->addItem( QString::number( variant ) ); cboColors->addItem( QString::number( variant ) );

View File

@ -20,7 +20,7 @@
#include "ui_qgsvectorcolorbrewercolorrampv2dialogbase.h" #include "ui_qgsvectorcolorbrewercolorrampv2dialogbase.h"
class QgsVectorColorBrewerColorRamp; class QgsColorBrewerColorRamp;
/** \ingroup gui /** \ingroup gui
* \class QgsVectorColorBrewerColorRampDialog * \class QgsVectorColorBrewerColorRampDialog
@ -30,7 +30,7 @@ class GUI_EXPORT QgsVectorColorBrewerColorRampDialog : public QDialog, private U
Q_OBJECT Q_OBJECT
public: public:
QgsVectorColorBrewerColorRampDialog( QgsVectorColorBrewerColorRamp* ramp, QWidget* parent = nullptr ); QgsVectorColorBrewerColorRampDialog( QgsColorBrewerColorRamp* ramp, QWidget* parent = nullptr );
public slots: public slots:
void setSchemeName(); void setSchemeName();
@ -42,7 +42,7 @@ class GUI_EXPORT QgsVectorColorBrewerColorRampDialog : public QDialog, private U
void updatePreview(); void updatePreview();
QgsVectorColorBrewerColorRamp* mRamp; QgsColorBrewerColorRamp* mRamp;
}; };
#endif #endif

View File

@ -15,7 +15,7 @@
#include "qgsvectorgradientcolorrampdialog.h" #include "qgsvectorgradientcolorrampdialog.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgsdialog.h" #include "qgsdialog.h"
#include "qgscolordialog.h" #include "qgscolordialog.h"
#include "qgscptcityarchive.h" #include "qgscptcityarchive.h"
@ -40,7 +40,7 @@
#include <qwt_symbol.h> #include <qwt_symbol.h>
#include <qwt_legend.h> #include <qwt_legend.h>
QgsVectorGradientColorRampDialog::QgsVectorGradientColorRampDialog( QgsVectorGradientColorRamp* ramp, QWidget* parent ) QgsVectorGradientColorRampDialog::QgsVectorGradientColorRampDialog( QgsGradientColorRamp* ramp, QWidget* parent )
: QDialog( parent ) : QDialog( parent )
, mRamp( ramp ) , mRamp( ramp )
, mCurrentPlotColorComponent( -1 ) , mCurrentPlotColorComponent( -1 )

View File

@ -20,7 +20,7 @@
#include "ui_qgsvectorgradientcolorrampv2dialogbase.h" #include "ui_qgsvectorgradientcolorrampv2dialogbase.h"
class QgsVectorGradientColorRamp; class QgsGradientColorRamp;
class QwtPlot; class QwtPlot;
class QwtPlotCurve; class QwtPlotCurve;
class QwtPlotMarker; class QwtPlotMarker;
@ -34,7 +34,7 @@ class GUI_EXPORT QgsVectorGradientColorRampDialog : public QDialog, private Ui::
Q_OBJECT Q_OBJECT
public: public:
QgsVectorGradientColorRampDialog( QgsVectorGradientColorRamp* ramp, QWidget* parent = nullptr ); QgsVectorGradientColorRampDialog( QgsGradientColorRamp* ramp, QWidget* parent = nullptr );
~QgsVectorGradientColorRampDialog(); ~QgsVectorGradientColorRampDialog();
public slots: public slots:
@ -46,7 +46,7 @@ class GUI_EXPORT QgsVectorGradientColorRampDialog : public QDialog, private Ui::
void on_btnInformation_pressed(); void on_btnInformation_pressed();
protected: protected:
QgsVectorGradientColorRamp* mRamp; QgsGradientColorRamp* mRamp;
private slots: private slots:

View File

@ -16,12 +16,12 @@
#include "qgsvectorrandomcolorrampdialog.h" #include "qgsvectorrandomcolorrampdialog.h"
#include "qgssymbollayerutils.h" #include "qgssymbollayerutils.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include <QColorDialog> #include <QColorDialog>
QgsVectorRandomColorRampDialog::QgsVectorRandomColorRampDialog( QgsVectorRandomColorRamp* ramp, QWidget* parent ) QgsVectorRandomColorRampDialog::QgsVectorRandomColorRampDialog( QgsLimitedRandomColorRamp* ramp, QWidget* parent )
: QDialog( parent ) : QDialog( parent )
, mRamp( ramp ) , mRamp( ramp )
{ {

View File

@ -20,7 +20,7 @@
#include "ui_qgsvectorrandomcolorrampv2dialogbase.h" #include "ui_qgsvectorrandomcolorrampv2dialogbase.h"
class QgsVectorRandomColorRamp; class QgsLimitedRandomColorRamp;
/** \ingroup gui /** \ingroup gui
* \class QgsVectorRandomColorRampDialog * \class QgsVectorRandomColorRampDialog
@ -30,7 +30,7 @@ class GUI_EXPORT QgsVectorRandomColorRampDialog : public QDialog, private Ui::Qg
Q_OBJECT Q_OBJECT
public: public:
QgsVectorRandomColorRampDialog( QgsVectorRandomColorRamp* ramp, QWidget* parent = nullptr ); QgsVectorRandomColorRampDialog( QgsLimitedRandomColorRamp* ramp, QWidget* parent = nullptr );
public slots: public slots:
void setCount( int val ); void setCount( int val );
@ -45,7 +45,7 @@ class GUI_EXPORT QgsVectorRandomColorRampDialog : public QDialog, private Ui::Qg
void updatePreview(); void updatePreview();
QgsVectorRandomColorRamp* mRamp; QgsLimitedRandomColorRamp* mRamp;
}; };
#endif #endif

View File

@ -30,7 +30,7 @@
#include <qgssymbol.h> #include <qgssymbol.h>
#include <qgssinglesymbolrenderer.h> #include <qgssinglesymbolrenderer.h>
#include <qgsfillsymbollayer.h> #include <qgsfillsymbollayer.h>
#include <qgsvectorcolorramp.h> #include <qgscolorramp.h>
//qgis test includes //qgis test includes
#include "qgsrenderchecker.h" #include "qgsrenderchecker.h"
@ -165,7 +165,7 @@ void TestQgsGradients::gradientSymbolColors()
void TestQgsGradients::gradientSymbolRamp() void TestQgsGradients::gradientSymbolRamp()
{ {
QgsVectorGradientColorRamp* gradientRamp = new QgsVectorGradientColorRamp( QColor( Qt::red ), QColor( Qt::blue ) ); QgsGradientColorRamp* gradientRamp = new QgsGradientColorRamp( QColor( Qt::red ), QColor( Qt::blue ) );
QgsGradientStopsList stops; QgsGradientStopsList stops;
stops.append( QgsGradientStop( 0.5, QColor( Qt::white ) ) ); stops.append( QgsGradientStop( 0.5, QColor( Qt::white ) ) );
gradientRamp->setStops( stops ); gradientRamp->setStops( stops );

View File

@ -16,7 +16,7 @@
***************************************************************************/ ***************************************************************************/
#include "qgsimageoperation.h" #include "qgsimageoperation.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include <QObject> #include <QObject>
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include "qgsrenderchecker.h" #include "qgsrenderchecker.h"
@ -286,7 +286,7 @@ void TestQgsImageOperation::overlayColor()
void TestQgsImageOperation::distanceTransformMaxDist() void TestQgsImageOperation::distanceTransformMaxDist()
{ {
QImage image( mTransparentSampleImage ); QImage image( mTransparentSampleImage );
QgsVectorGradientColorRamp ramp; QgsGradientColorRamp ramp;
QgsImageOperation::DistanceTransformProperties props; QgsImageOperation::DistanceTransformProperties props;
props.useMaxDistance = true; props.useMaxDistance = true;
props.ramp = &ramp; props.ramp = &ramp;
@ -301,7 +301,7 @@ void TestQgsImageOperation::distanceTransformMaxDist()
void TestQgsImageOperation::distanceTransformSetSpread() void TestQgsImageOperation::distanceTransformSetSpread()
{ {
QImage image( mTransparentSampleImage ); QImage image( mTransparentSampleImage );
QgsVectorGradientColorRamp ramp; QgsGradientColorRamp ramp;
QgsImageOperation::DistanceTransformProperties props; QgsImageOperation::DistanceTransformProperties props;
props.useMaxDistance = false; props.useMaxDistance = false;
props.spread = 10; props.spread = 10;
@ -317,7 +317,7 @@ void TestQgsImageOperation::distanceTransformSetSpread()
void TestQgsImageOperation::distanceTransformInterior() void TestQgsImageOperation::distanceTransformInterior()
{ {
QImage image( mTransparentSampleImage ); QImage image( mTransparentSampleImage );
QgsVectorGradientColorRamp ramp; QgsGradientColorRamp ramp;
QgsImageOperation::DistanceTransformProperties props; QgsImageOperation::DistanceTransformProperties props;
props.useMaxDistance = true; props.useMaxDistance = true;
props.ramp = &ramp; props.ramp = &ramp;
@ -344,7 +344,7 @@ void TestQgsImageOperation::distanceTransformMisc()
//zero spread //zero spread
QImage image2( mSampleImage ); QImage image2( mSampleImage );
QgsImageOperation::DistanceTransformProperties props2; QgsImageOperation::DistanceTransformProperties props2;
QgsVectorGradientColorRamp ramp; QgsGradientColorRamp ramp;
props2.useMaxDistance = false; props2.useMaxDistance = false;
props2.spread = 0; props2.spread = 0;
props2.ramp = &ramp; props2.ramp = &ramp;

View File

@ -27,7 +27,7 @@
#include "qgseffectstack.h" #include "qgseffectstack.h"
#include "qgsgloweffect.h" #include "qgsgloweffect.h"
#include "qgspainteffectregistry.h" #include "qgspainteffectregistry.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgssymbollayerutils.h" #include "qgssymbollayerutils.h"
#include "qgsmapsettings.h" #include "qgsmapsettings.h"
#include "qgsvectorlayer.h" #include "qgsvectorlayer.h"
@ -540,7 +540,7 @@ void TestQgsPaintEffect::glow()
effect->setSpreadMapUnitScale( QgsMapUnitScale( 1.0, 2.0 ) ); effect->setSpreadMapUnitScale( QgsMapUnitScale( 1.0, 2.0 ) );
QCOMPARE( effect->spreadMapUnitScale().minScale, 1.0 ); QCOMPARE( effect->spreadMapUnitScale().minScale, 1.0 );
QCOMPARE( effect->spreadMapUnitScale().maxScale, 2.0 ); QCOMPARE( effect->spreadMapUnitScale().maxScale, 2.0 );
effect->setRamp( new QgsVectorGradientColorRamp( QColor( 255, 0, 0 ), QColor( 0, 255, 0 ) ) ); effect->setRamp( new QgsGradientColorRamp( QColor( 255, 0, 0 ), QColor( 0, 255, 0 ) ) );
QCOMPARE( effect->ramp()->color( 0 ), QColor( 255, 0, 0 ) ); QCOMPARE( effect->ramp()->color( 0 ), QColor( 255, 0, 0 ) );
QCOMPARE( effect->ramp()->color( 1.0 ), QColor( 0, 255, 0 ) ); QCOMPARE( effect->ramp()->color( 1.0 ), QColor( 0, 255, 0 ) );
effect->setColorType( QgsGlowEffect::ColorRamp ); effect->setColorType( QgsGlowEffect::ColorRamp );

View File

@ -36,7 +36,7 @@
#include <qgssinglebandgrayrenderer.h> #include <qgssinglebandgrayrenderer.h>
#include <qgssinglebandpseudocolorrenderer.h> #include <qgssinglebandpseudocolorrenderer.h>
#include <qgsmultibandcolorrenderer.h> #include <qgsmultibandcolorrenderer.h>
#include <qgsvectorcolorramp.h> #include <qgscolorramp.h>
#include <qgscptcityarchive.h> #include <qgscptcityarchive.h>
#include "qgscolorrampshader.h" #include "qgscolorrampshader.h"
#include "qgsrasterdataprovider.h" #include "qgsrasterdataprovider.h"
@ -96,9 +96,9 @@ class TestQgsRasterLayer : public QObject
bool render( const QString& theFileName, int mismatchCount = 0 ); bool render( const QString& theFileName, int mismatchCount = 0 );
bool setQml( const QString& theType, QString& msg ); bool setQml( const QString& theType, QString& msg );
void populateColorRampShader( QgsColorRampShader* colorRampShader, void populateColorRampShader( QgsColorRampShader* colorRampShader,
QgsVectorColorRamp* colorRamp, QgsColorRamp* colorRamp,
int numberOfEntries ); int numberOfEntries );
bool testColorRamp( const QString& name, QgsVectorColorRamp* colorRamp, bool testColorRamp( const QString& name, QgsColorRamp* colorRamp,
QgsColorRampShader::ColorRamp_TYPE type, int numberOfEntries ); QgsColorRampShader::ColorRamp_TYPE type, int numberOfEntries );
QString mTestDataDir; QString mTestDataDir;
QgsRasterLayer * mpRasterLayer; QgsRasterLayer * mpRasterLayer;
@ -250,7 +250,7 @@ void TestQgsRasterLayer::pseudoColor()
} }
void TestQgsRasterLayer::populateColorRampShader( QgsColorRampShader* colorRampShader, void TestQgsRasterLayer::populateColorRampShader( QgsColorRampShader* colorRampShader,
QgsVectorColorRamp* colorRamp, QgsColorRamp* colorRamp,
int numberOfEntries ) int numberOfEntries )
{ {
@ -294,7 +294,7 @@ void TestQgsRasterLayer::populateColorRampShader( QgsColorRampShader* colorRampS
colorRampShader->setColorRampItemList( colorRampItems ); colorRampShader->setColorRampItemList( colorRampItems );
} }
bool TestQgsRasterLayer::testColorRamp( const QString& name, QgsVectorColorRamp* colorRamp, bool TestQgsRasterLayer::testColorRamp( const QString& name, QgsColorRamp* colorRamp,
QgsColorRampShader::ColorRamp_TYPE type, int numberOfEntries ) QgsColorRampShader::ColorRamp_TYPE type, int numberOfEntries )
{ {
QgsRasterShader* rasterShader = new QgsRasterShader(); QgsRasterShader* rasterShader = new QgsRasterShader();
@ -313,7 +313,7 @@ bool TestQgsRasterLayer::testColorRamp( const QString& name, QgsVectorColorRamp*
void TestQgsRasterLayer::colorRamp1() void TestQgsRasterLayer::colorRamp1()
{ {
// gradient ramp // gradient ramp
QgsVectorGradientColorRamp* colorRamp = new QgsVectorGradientColorRamp( QColor( Qt::red ), QColor( Qt::black ) ); QgsGradientColorRamp* colorRamp = new QgsGradientColorRamp( QColor( Qt::red ), QColor( Qt::black ) );
QgsGradientStopsList stops; QgsGradientStopsList stops;
stops.append( QgsGradientStop( 0.5, QColor( Qt::white ) ) ); stops.append( QgsGradientStop( 0.5, QColor( Qt::white ) ) );
colorRamp->setStops( stops ); colorRamp->setStops( stops );
@ -325,7 +325,7 @@ void TestQgsRasterLayer::colorRamp1()
void TestQgsRasterLayer::colorRamp2() void TestQgsRasterLayer::colorRamp2()
{ {
QgsVectorColorBrewerColorRamp ramp( "BrBG", 10 ); QgsColorBrewerColorRamp ramp( "BrBG", 10 );
// ColorBrewer ramp // ColorBrewer ramp
QVERIFY( testColorRamp( "raster_colorRamp2", QVERIFY( testColorRamp( "raster_colorRamp2",
&ramp, &ramp,

View File

@ -35,7 +35,7 @@
#include <qgsapplication.h> #include <qgsapplication.h>
#include <qgssinglebandgrayrenderer.h> #include <qgssinglebandgrayrenderer.h>
#include <qgssinglebandpseudocolorrenderer.h> #include <qgssinglebandpseudocolorrenderer.h>
#include <qgsvectorcolorramp.h> #include <qgscolorramp.h>
#include <qgscptcityarchive.h> #include <qgscptcityarchive.h>
//qgis unit test includes //qgis unit test includes

View File

@ -31,7 +31,7 @@
#include <qgssymbol.h> #include <qgssymbol.h>
#include <qgssinglesymbolrenderer.h> #include <qgssinglesymbolrenderer.h>
#include <qgsfillsymbollayer.h> #include <qgsfillsymbollayer.h>
#include <qgsvectorcolorramp.h> #include <qgscolorramp.h>
//qgis test includes //qgis test includes
#include "qgsmultirenderchecker.h" #include "qgsmultirenderchecker.h"
@ -160,7 +160,7 @@ void TestQgsShapeburst::shapeburstSymbolRamp()
{ {
mReport += "<h2>Shapeburst symbol renderer ramp test</h2>\n"; mReport += "<h2>Shapeburst symbol renderer ramp test</h2>\n";
QgsVectorGradientColorRamp* gradientRamp = new QgsVectorGradientColorRamp( QColor( Qt::yellow ), QColor( 255, 105, 180 ) ); QgsGradientColorRamp* gradientRamp = new QgsGradientColorRamp( QColor( Qt::yellow ), QColor( 255, 105, 180 ) );
QgsGradientStopsList stops; QgsGradientStopsList stops;
stops.append( QgsGradientStop( 0.5, QColor( 255, 255, 255, 0 ) ) ); stops.append( QgsGradientStop( 0.5, QColor( 255, 255, 255, 0 ) ) );
gradientRamp->setStops( stops ); gradientRamp->setStops( stops );

View File

@ -23,7 +23,7 @@
#include <qgsapplication.h> #include <qgsapplication.h>
#include "qgsconfig.h" #include "qgsconfig.h"
#include "qgslogger.h" #include "qgslogger.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgscptcityarchive.h" #include "qgscptcityarchive.h"
#include "qgsvectorlayer.h" #include "qgsvectorlayer.h"
#include "qgsmaplayerregistry.h" #include "qgsmaplayerregistry.h"
@ -50,7 +50,7 @@ class TestStyle : public QObject
QgsStyle *mStyle; QgsStyle *mStyle;
QString mTestDataDir; QString mTestDataDir;
bool testValidColor( QgsVectorColorRamp *ramp, double value, const QColor& expected ); bool testValidColor( QgsColorRamp *ramp, double value, const QColor& expected );
bool imageCheck( QgsMapSettings &ms, const QString &testName ); bool imageCheck( QgsMapSettings &ms, const QString &testName );
private slots: private slots:
@ -138,7 +138,7 @@ bool TestStyle::imageCheck( QgsMapSettings& ms, const QString& testName )
return result; return result;
} }
bool TestStyle::testValidColor( QgsVectorColorRamp *ramp, double value, const QColor& expected ) bool TestStyle::testValidColor( QgsColorRamp *ramp, double value, const QColor& expected )
{ {
QColor result = ramp->color( value ); QColor result = ramp->color( value );
//use int color components when testing (builds some fuzziness into test) //use int color components when testing (builds some fuzziness into test)
@ -155,20 +155,20 @@ bool TestStyle::testValidColor( QgsVectorColorRamp *ramp, double value, const QC
void TestStyle::testCreateColorRamps() void TestStyle::testCreateColorRamps()
{ {
// gradient ramp // gradient ramp
QgsVectorGradientColorRamp* gradientRamp = new QgsVectorGradientColorRamp( QColor( Qt::red ), QColor( Qt::blue ) ); QgsGradientColorRamp* gradientRamp = new QgsGradientColorRamp( QColor( Qt::red ), QColor( Qt::blue ) );
QgsGradientStopsList stops; QgsGradientStopsList stops;
stops.append( QgsGradientStop( 0.5, QColor( Qt::white ) ) ); stops.append( QgsGradientStop( 0.5, QColor( Qt::white ) ) );
gradientRamp->setStops( stops ); gradientRamp->setStops( stops );
QVERIFY( mStyle->addColorRamp( "test_gradient", gradientRamp, true ) ); QVERIFY( mStyle->addColorRamp( "test_gradient", gradientRamp, true ) );
// random ramp // random ramp
QgsVectorRandomColorRamp* randomRamp = new QgsVectorRandomColorRamp(); QgsLimitedRandomColorRamp* randomRamp = new QgsLimitedRandomColorRamp();
QVERIFY( mStyle->addColorRamp( "test_random", randomRamp, true ) ); QVERIFY( mStyle->addColorRamp( "test_random", randomRamp, true ) );
// color brewer ramp // color brewer ramp
QgsVectorColorBrewerColorRamp* cb1Ramp = new QgsVectorColorBrewerColorRamp(); QgsColorBrewerColorRamp* cb1Ramp = new QgsColorBrewerColorRamp();
QVERIFY( mStyle->addColorRamp( "test_cb1", cb1Ramp, true ) ); QVERIFY( mStyle->addColorRamp( "test_cb1", cb1Ramp, true ) );
QgsVectorColorBrewerColorRamp* cb2Ramp = new QgsVectorColorBrewerColorRamp( "RdYlGn", 6 ); QgsColorBrewerColorRamp* cb2Ramp = new QgsColorBrewerColorRamp( "RdYlGn", 6 );
QVERIFY( mStyle->addColorRamp( "test_cb2", cb2Ramp, true ) ); QVERIFY( mStyle->addColorRamp( "test_cb2", cb2Ramp, true ) );
// discrete ramp with no variant // discrete ramp with no variant
@ -216,7 +216,7 @@ void TestStyle::testLoadColorRamps()
{ {
QgsDebugMsg( "colorRamp " + name ); QgsDebugMsg( "colorRamp " + name );
QVERIFY( colorRamps.contains( name ) ); QVERIFY( colorRamps.contains( name ) );
QgsVectorColorRamp* ramp = mStyle->colorRamp( name ); QgsColorRamp* ramp = mStyle->colorRamp( name );
QVERIFY( ramp != 0 ); QVERIFY( ramp != 0 );
// test colors // test colors
if ( colorTests.contains( name ) ) if ( colorTests.contains( name ) )
@ -249,7 +249,7 @@ void TestStyle::testSaveLoad()
{ {
QgsDebugMsg( "colorRamp " + name ); QgsDebugMsg( "colorRamp " + name );
QVERIFY( colorRamps.contains( name ) ); QVERIFY( colorRamps.contains( name ) );
QgsVectorColorRamp* ramp = mStyle->colorRamp( name ); QgsColorRamp* ramp = mStyle->colorRamp( name );
QVERIFY( ramp != 0 ); QVERIFY( ramp != 0 );
if ( ramp ) if ( ramp )
delete ramp; delete ramp;

View File

@ -23,7 +23,7 @@
#include <qgsapplication.h> #include <qgsapplication.h>
#include "qgsconfig.h" #include "qgsconfig.h"
#include "qgslogger.h" #include "qgslogger.h"
#include "qgsvectorcolorramp.h" #include "qgscolorramp.h"
#include "qgscptcityarchive.h" #include "qgscptcityarchive.h"
#include "qgsvectorlayer.h" #include "qgsvectorlayer.h"
#include "qgsmaplayerregistry.h" #include "qgsmaplayerregistry.h"

View File

@ -19,7 +19,7 @@ from qgis.core import (QgsGraduatedSymbolRenderer,
QgsRendererRange, QgsRendererRange,
QgsRendererRangeLabelFormat, QgsRendererRangeLabelFormat,
QgsMarkerSymbol, QgsMarkerSymbol,
QgsVectorGradientColorRamp, QgsGradientColorRamp,
QgsVectorLayer, QgsVectorLayer,
QgsFeature, QgsFeature,
QgsGeometry, QgsGeometry,
@ -67,7 +67,7 @@ def createMemoryLayer(values):
def createColorRamp(): def createColorRamp():
return QgsVectorGradientColorRamp( return QgsGradientColorRamp(
QColor(255, 0, 0), QColor(255, 0, 0),
QColor(0, 0, 255) QColor(0, 0, 255)
) )

View File

@ -14,11 +14,11 @@ __revision__ = '$Format:%H$'
import qgis # NOQA import qgis # NOQA
from qgis.core import (QgsVectorGradientColorRamp, from qgis.core import (QgsGradientColorRamp,
QgsGradientStop, QgsGradientStop,
QgsVectorRandomColorRamp, QgsLimitedRandomColorRamp,
QgsRandomColors, QgsRandomColorRamp,
QgsVectorColorBrewerColorRamp) QgsColorBrewerColorRamp)
from qgis.PyQt.QtGui import QColor, QGradient from qgis.PyQt.QtGui import QColor, QGradient
from qgis.testing import unittest from qgis.testing import unittest
@ -35,7 +35,7 @@ class PyQgsVectorColorRamp(unittest.TestCase):
self.assertNotEqual(QgsGradientStop(0.1, QColor(180, 20, 30)), QgsGradientStop(0.1, QColor(180, 40, 30))) self.assertNotEqual(QgsGradientStop(0.1, QColor(180, 20, 30)), QgsGradientStop(0.1, QColor(180, 40, 30)))
# test gradient with only start/end color # test gradient with only start/end color
r = QgsVectorGradientColorRamp(QColor(200, 0, 0, 100), QColor(0, 200, 0, 200)) r = QgsGradientColorRamp(QColor(200, 0, 0, 100), QColor(0, 200, 0, 200))
self.assertEqual(r.type(), 'gradient') self.assertEqual(r.type(), 'gradient')
self.assertEqual(r.color1(), QColor(200, 0, 0, 100)) self.assertEqual(r.color1(), QColor(200, 0, 0, 100))
self.assertEqual(r.color2(), QColor(0, 200, 0, 200)) self.assertEqual(r.color2(), QColor(0, 200, 0, 200))
@ -49,7 +49,7 @@ class PyQgsVectorColorRamp(unittest.TestCase):
self.assertEqual(r.color(0.5), QColor(100, 100, 0, 150)) self.assertEqual(r.color(0.5), QColor(100, 100, 0, 150))
# test gradient with stops # test gradient with stops
r = QgsVectorGradientColorRamp(QColor(200, 0, 0), QColor(0, 200, 0), False, [QgsGradientStop(0.1, QColor(180, 20, 40)), r = QgsGradientColorRamp(QColor(200, 0, 0), QColor(0, 200, 0), False, [QgsGradientStop(0.1, QColor(180, 20, 40)),
QgsGradientStop(0.9, QColor(40, 60, 100))]) QgsGradientStop(0.9, QColor(40, 60, 100))])
self.assertEqual(r.color1(), QColor(200, 0, 0)) self.assertEqual(r.color1(), QColor(200, 0, 0))
self.assertEqual(r.color2(), QColor(0, 200, 0)) self.assertEqual(r.color2(), QColor(0, 200, 0))
@ -88,7 +88,7 @@ class PyQgsVectorColorRamp(unittest.TestCase):
# test creating from properties # test creating from properties
props = r.properties() props = r.properties()
fromProps = QgsVectorGradientColorRamp.create(props) fromProps = QgsGradientColorRamp.create(props)
self.assertEqual(fromProps.color1(), QColor(0, 0, 200)) self.assertEqual(fromProps.color1(), QColor(0, 0, 200))
self.assertEqual(fromProps.color2(), QColor(0, 0, 100)) self.assertEqual(fromProps.color2(), QColor(0, 0, 100))
s = fromProps.stops() s = fromProps.stops()
@ -115,13 +115,13 @@ class PyQgsVectorColorRamp(unittest.TestCase):
# test discrete ramps # test discrete ramps
# first with no stops # first with no stops
d = QgsVectorGradientColorRamp(QColor(200, 0, 0), QColor(0, 200, 0), True) d = QgsGradientColorRamp(QColor(200, 0, 0), QColor(0, 200, 0), True)
self.assertEqual(d.isDiscrete(), True) self.assertEqual(d.isDiscrete(), True)
self.assertEqual(d.color(0), QColor(200, 0, 0)) self.assertEqual(d.color(0), QColor(200, 0, 0))
self.assertEqual(d.color(0.5), QColor(200, 0, 0)) self.assertEqual(d.color(0.5), QColor(200, 0, 0))
self.assertEqual(d.color(1), QColor(0, 200, 0)) self.assertEqual(d.color(1), QColor(0, 200, 0))
# then with stops # then with stops
d = QgsVectorGradientColorRamp(QColor(200, 0, 0), QColor(0, 200, 0), True, [QgsGradientStop(0.1, QColor(180, 20, 40)), d = QgsGradientColorRamp(QColor(200, 0, 0), QColor(0, 200, 0), True, [QgsGradientStop(0.1, QColor(180, 20, 40)),
QgsGradientStop(0.9, QColor(40, 60, 100))]) QgsGradientStop(0.9, QColor(40, 60, 100))])
self.assertEqual(d.isDiscrete(), True) self.assertEqual(d.isDiscrete(), True)
self.assertEqual(d.color(0), QColor(200, 0, 0)) self.assertEqual(d.color(0), QColor(200, 0, 0))
@ -134,7 +134,7 @@ class PyQgsVectorColorRamp(unittest.TestCase):
# to gradient # to gradient
g = QGradient() g = QGradient()
r = QgsVectorGradientColorRamp(QColor(200, 0, 0), QColor(0, 200, 0), False, [QgsGradientStop(0.1, QColor(180, 20, 40)), r = QgsGradientColorRamp(QColor(200, 0, 0), QColor(0, 200, 0), False, [QgsGradientStop(0.1, QColor(180, 20, 40)),
QgsGradientStop(0.9, QColor(40, 60, 100))]) QgsGradientStop(0.9, QColor(40, 60, 100))])
r.addStopsToGradient(g, 0.5) r.addStopsToGradient(g, 0.5)
self.assertEqual(len(g.stops()), 4) self.assertEqual(len(g.stops()), 4)
@ -160,9 +160,9 @@ class PyQgsVectorColorRamp(unittest.TestCase):
self.assertEqual(s[3].offset, 0.8) self.assertEqual(s[3].offset, 0.8)
self.assertEqual(s[3].color, QColor(50, 20, 10)) self.assertEqual(s[3].color, QColor(50, 20, 10))
def testQgsVectorRandomColorRampV2(self): def testQgsLimitedRandomColorRampV2(self):
# test random color ramp # test random color ramp
r = QgsVectorRandomColorRamp(5) r = QgsLimitedRandomColorRamp(5)
self.assertEqual(r.type(), 'random') self.assertEqual(r.type(), 'random')
self.assertEqual(r.count(), 5) self.assertEqual(r.count(), 5)
self.assertEqual(r.value(0), 0) self.assertEqual(r.value(0), 0)
@ -208,7 +208,7 @@ class PyQgsVectorColorRamp(unittest.TestCase):
# test creating from properties # test creating from properties
props = r.properties() props = r.properties()
fromProps = QgsVectorRandomColorRamp.create(props) fromProps = QgsLimitedRandomColorRamp.create(props)
self.assertEqual(fromProps.count(), 5) self.assertEqual(fromProps.count(), 5)
self.assertEqual(fromProps.hueMin(), 10) self.assertEqual(fromProps.hueMin(), 10)
self.assertEqual(fromProps.hueMax(), 60) self.assertEqual(fromProps.hueMax(), 60)
@ -240,9 +240,9 @@ class PyQgsVectorColorRamp(unittest.TestCase):
self.assertTrue(c.value() >= 150) self.assertTrue(c.value() >= 150)
self.assertTrue(c.value() <= 180) self.assertTrue(c.value() <= 180)
def testQgsRandomColorsV2(self): def testQgsRandomColorRampV2(self):
# test random colors # test random colors
r = QgsRandomColors() r = QgsRandomColorRamp()
self.assertEqual(r.type(), 'randomcolors') self.assertEqual(r.type(), 'randomcolors')
self.assertEqual(r.count(), -1) # no color count self.assertEqual(r.count(), -1) # no color count
self.assertEqual(r.value(0), 0) # all values should be 0 self.assertEqual(r.value(0), 0) # all values should be 0
@ -254,7 +254,7 @@ class PyQgsVectorColorRamp(unittest.TestCase):
self.assertTrue(c.isValid()) self.assertTrue(c.isValid())
# test creating from properties # test creating from properties
# QgsRandomColors has no properties for now, but test to ensure no crash # QgsRandomColorRamp has no properties for now, but test to ensure no crash
props = r.properties() # NOQA props = r.properties() # NOQA
# test cloning ramp # test cloning ramp
@ -268,9 +268,9 @@ class PyQgsVectorColorRamp(unittest.TestCase):
c = r.color(j * 0.1) c = r.color(j * 0.1)
self.assertTrue(c.isValid()) self.assertTrue(c.isValid())
def testQgsVectorColorBrewerColorRampV2(self): def testQgsColorBrewerColorRampV2(self):
# test color brewer color ramps # test color brewer color ramps
r = QgsVectorColorBrewerColorRamp('OrRd', 6) r = QgsColorBrewerColorRamp('OrRd', 6)
self.assertEqual(r.type(), 'colorbrewer') self.assertEqual(r.type(), 'colorbrewer')
self.assertEqual(r.schemeName(), 'OrRd') self.assertEqual(r.schemeName(), 'OrRd')
self.assertEqual(r.count(), 6) self.assertEqual(r.count(), 6)
@ -291,13 +291,13 @@ class PyQgsVectorColorRamp(unittest.TestCase):
self.assertEqual(r.color(1.0), QColor(179, 0, 0)) self.assertEqual(r.color(1.0), QColor(179, 0, 0))
# try using an invalid scheme name # try using an invalid scheme name
bad = QgsVectorColorBrewerColorRamp('badscheme', 6) bad = QgsColorBrewerColorRamp('badscheme', 6)
self.assertFalse(bad.color(0).isValid()) self.assertFalse(bad.color(0).isValid())
self.assertEqual(bad.value(1), 0) self.assertEqual(bad.value(1), 0)
# test creating from properties # test creating from properties
props = r.properties() props = r.properties()
fromProps = QgsVectorColorBrewerColorRamp.create(props) fromProps = QgsColorBrewerColorRamp.create(props)
self.assertEqual(fromProps.type(), 'colorbrewer') self.assertEqual(fromProps.type(), 'colorbrewer')
self.assertEqual(fromProps.schemeName(), 'OrRd') self.assertEqual(fromProps.schemeName(), 'OrRd')
self.assertEqual(fromProps.count(), 6) self.assertEqual(fromProps.count(), 6)
@ -340,10 +340,10 @@ class PyQgsVectorColorRamp(unittest.TestCase):
self.assertEqual(r.color(1.0), QColor(222, 45, 38)) self.assertEqual(r.color(1.0), QColor(222, 45, 38))
# test static members # test static members
names = QgsVectorColorBrewerColorRamp.listSchemeNames() names = QgsColorBrewerColorRamp.listSchemeNames()
self.assertTrue('Reds' in names and 'OrRd' in names) self.assertTrue('Reds' in names and 'OrRd' in names)
self.assertEqual(len(QgsVectorColorBrewerColorRamp.listSchemeVariants('bad scheme')), 0) self.assertEqual(len(QgsColorBrewerColorRamp.listSchemeVariants('bad scheme')), 0)
variants = QgsVectorColorBrewerColorRamp.listSchemeVariants('Reds') variants = QgsColorBrewerColorRamp.listSchemeVariants('Reds')
self.assertEqual(variants, [3, 4, 5, 6, 7, 8, 9]) self.assertEqual(variants, [3, 4, 5, 6, 7, 8, 9])
if __name__ == '__main__': if __name__ == '__main__':