Skip to content
Permalink
Browse files
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.
  • Loading branch information
nyalldawson committed Aug 24, 2016
1 parent 014409d commit 932e469
Show file tree
Hide file tree
Showing 70 changed files with 428 additions and 421 deletions.
@@ -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>QgsMultiSurfaceV2<td>QgsMultiSurface
<tr><td>QgsPointSequenceV2<td>QgsPointSequence
<tr><td>QgsRandomColorsV2<td>QgsRandomColors
<tr><td>QgsRandomColorsV2<td>QgsRandomColorRamp
<tr><td>QgsRendererCategoryV2<td>QgsRendererCategory
<tr><td>QgsRendererRangeV2<td>QgsRendererRange
<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>QgsSymbolV2SelectorWidget<td>QgsSymbolSelectorWidget
<tr><td>QgsSymbologyV2Conversion<td>QgsSymbologyConversion
<tr><td>QgsVectorColorBrewerColorRampV2<td>QgsVectorColorBrewerColorRamp
<tr><td>QgsVectorColorBrewerColorRampV2<td>QgsColorBrewerColorRamp
<tr><td>QgsVectorColorBrewerColorRampV2Dialog<td>QgsVectorColorBrewerColorRampDialog
<tr><td>QgsVectorColorBrewerColorRampV2DialogBase<td>QgsVectorColorBrewerColorRampDialogBase
<tr><td>QgsVectorColorRampV2<td>QgsVectorColorRamp
<tr><td>QgsVectorColorRampV2<td>QgsColorRamp
<tr><td>QgsVectorColorRampV2Map<td>QgsVectorColorRampMap
<tr><td>QgsVectorGradientColorRampV2<td>QgsVectorGradientColorRamp
<tr><td>QgsVectorGradientColorRampV2<td>QgsGradientColorRamp
<tr><td>QgsVectorGradientColorRampV2Dialog<td>QgsVectorGradientColorRampDialog
<tr><td>QgsVectorGradientColorRampV2DialogBase<td>QgsVectorGradientColorRampDialogBase
<tr><td>QgsVectorGradientRampV2<td>QgsVectorGradientRamp
<tr><td>QgsVectorLayersetRendererV2<td>QgsVectorLayersetRenderer
<tr><td>QgsVectorRandomColorRampV2<td>QgsVectorRandomColorRamp
<tr><td>QgsVectorRandomColorRampV2<td>QgsLimitedRandomColorRamp
<tr><td>QgsVectorRandomColorRampV2Dialog<td>QgsVectorRandomColorRampDialog
<tr><td>QgsVectorRandomColorRampV2DialogBase<td>QgsVectorRandomColorRampDialogBase
<tr><th>QgsSymbolV2<th>QgsSymbol
@@ -27,6 +27,7 @@
%Include qgsattributeeditorelement.sip
%Include qgsbrowsermodel.sip
%Include qgsclipper.sip
%Include qgscolorramp.sip
%Include qgscolorscheme.sip
%Include qgscolorschemeregistry.sip
%Include qgsconditionalstyle.sip
@@ -290,7 +291,6 @@
%Include symbology-ng/qgsstyle.sip
%Include symbology-ng/qgssvgcache.sip
%Include symbology-ng/qgssymbol.sip
%Include symbology-ng/qgsvectorcolorramp.sip

%Include symbology-ng/qgs25drenderer.sip
%Include symbology-ng/qgscategorizedsymbolrenderer.sip
@@ -129,15 +129,15 @@ class QgsGlowEffect : QgsPaintEffect
* @see ramp
* @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
* is set to ColorRamp. The glow will utilise colors from the ramp.
* @returns color ramp for glow
* @see setRamp
* @see colorType
*/
QgsVectorColorRamp* ramp() const;
QgsColorRamp* ramp() const;

/** Sets the blend mode for the effect
* @param mode blend mode used for drawing the effect on to a destination
@@ -153,7 +153,7 @@ class QgsGlowEffect : QgsPaintEffect
*/
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
* for the glow.
* @param colorType color type to use for glow
@@ -163,7 +163,7 @@ class QgsGlowEffect : QgsPaintEffect
*/
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.
* @returns current color mode used for the glow
* @see setColorType
@@ -96,7 +96,7 @@ class QgsImageOperation
double spread;
/** 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
@@ -1,23 +1,23 @@

/** \ingroup core
* \class QgsVectorColorRamp
* \class QgsColorRamp
* \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 QgsVectorColorRamp
class QgsColorRamp
{
%TypeHeaderCode
#include <qgsvectorcolorramp.h>
#include <qgscolorramp.h>
%End

%ConvertToSubClassCode
if (sipCpp->type() == "gradient")
sipType = sipType_QgsVectorGradientColorRamp;
sipType = sipType_QgsGradientColorRamp;
else if (sipCpp->type() == "random")
sipType = sipType_QgsVectorRandomColorRamp;
sipType = sipType_QgsLimitedRandomColorRamp;
else if (sipCpp->type() == "randomcolors")
sipType = sipType_QgsRandomColors;
sipType = sipType_QgsRandomColorRamp;
else if (sipCpp->type() == "colorbrewer")
sipType = sipType_QgsVectorColorBrewerColorRamp;
sipType = sipType_QgsColorBrewerColorRamp;
else if (sipCpp->type() == "cpt-city")
sipType = sipType_QgsCptCityColorRamp;
else
@@ -26,7 +26,7 @@ class QgsVectorColorRamp

public:

virtual ~QgsVectorColorRamp();
virtual ~QgsColorRamp();

/** Returns number of defined colors, or -1 if undefined
*/
@@ -48,7 +48,7 @@ class QgsVectorColorRamp

/** 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.
*/
@@ -58,20 +58,20 @@ class QgsVectorColorRamp

/** \ingroup core
* \class QgsGradientStop
* \brief Represents a color stop within a gradient color ramp.
* \brief Represents a color stop within a QgsGradientColorRamp color ramp.
*/
class QgsGradientStop
{
%TypeHeaderCode
#include <qgsvectorcolorramp.h>
#include <qgscolorramp.h>
%End
public:

/** Constructor for QgsGradientStop
* @param o positional offset for stop, between 0 and 1.0
* @param c color for stop
* @param offset positional offset for stop, between 0 and 1.0
* @param color color for stop
*/
QgsGradientStop( double o, const QColor& c );
QgsGradientStop( double offset, const QColor& color );

//! Relative positional offset, between 0 and 1
double offset;
@@ -86,38 +86,37 @@ class QgsGradientStop
typedef QList<QgsGradientStop> QgsGradientStopsList;

/** \ingroup core
* \class QgsVectorGradientColorRamp
* \class QgsGradientColorRamp
* \brief Gradient color ramp, which smoothly interpolates between two colors and also
* supports optional extra color stops.
*/
//TODO QGIS 3.0 - rename to QgsGradientColorRamp, since this is used by much more than just vectors
class QgsVectorGradientColorRamp : QgsVectorColorRamp
class QgsGradientColorRamp : QgsColorRamp
{
%TypeHeaderCode
#include <qgsvectorcolorramp.h>
#include <qgscolorramp.h>
%End
public:

/** Constructor for QgsVectorGradientColorRamp
/** Constructor for QgsGradientColorRamp
* @param color1 start color, corresponding to a position of 0.0
* @param color2 end color, corresponding to a position of 1.0
* @param discrete set to true for discrete interpolation instead of smoothly
* interpolating between colors
* @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),
bool discrete = false,
const QgsGradientStopsList& stops = QgsGradientStopsList() );

//! 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 double value( int index ) const;
virtual QColor color( double value ) const;
virtual QString type() const;
virtual QgsVectorGradientColorRamp* clone() const /Factory/;
virtual QgsGradientColorRamp* clone() const /Factory/;
virtual QgsStringMap properties() const;

/** Returns the gradient start color.
@@ -200,30 +199,29 @@ class QgsVectorGradientColorRamp : QgsVectorColorRamp
};

/** \ingroup core
* \class QgsVectorRandomColorRamp
* \brief Random color ramp, which returns random colors based on preset parameters.
* \class QgsLimitedRandomColorRamp
* \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 QgsVectorRandomColorRamp : QgsVectorColorRamp
class QgsLimitedRandomColorRamp : QgsColorRamp
{
%TypeHeaderCode
#include <qgsvectorcolorramp.h>
#include <qgscolorramp.h>
%End
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 satMin = DEFAULT_RANDOM_SAT_MIN, int satMax = DEFAULT_RANDOM_SAT_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 QColor color( double value ) const;

virtual QString type() const;

virtual QgsVectorRandomColorRamp* clone() const /Factory/;
virtual QgsLimitedRandomColorRamp* clone() const /Factory/;

virtual QgsStringMap properties() const;

@@ -254,11 +252,17 @@ class QgsVectorRandomColorRamp : QgsVectorColorRamp
void setValMax( int val );
};

class QgsRandomColors : QgsVectorColorRamp
/** \ingroup core
* \class QgsRandomColorRamp
*/
class QgsRandomColorRamp : QgsColorRamp
{
%TypeHeaderCode
#include <qgscolorramp.h>
%End
public:
QgsRandomColors();
~QgsRandomColors();
QgsRandomColorRamp();
~QgsRandomColorRamp();

int count() const;

@@ -276,29 +280,32 @@ class QgsRandomColors : QgsVectorColorRamp

QString type() const;

virtual QgsRandomColors* clone() const /Factory/;
virtual QgsRandomColorRamp* clone() const /Factory/;

QgsStringMap properties() const;
};

class QgsVectorColorBrewerColorRamp : QgsVectorColorRamp
/** \ingroup core
* \class QgsColorBrewerColorRamp
*/
class QgsColorBrewerColorRamp : QgsColorRamp
{
%TypeHeaderCode
#include <qgsvectorcolorramp.h>
#include <qgscolorramp.h>
%End
public:
QgsVectorColorBrewerColorRamp( const QString& schemeName = DEFAULT_COLORBREWER_SCHEMENAME,
QgsColorBrewerColorRamp( const QString& schemeName = DEFAULT_COLORBREWER_SCHEMENAME,
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 QColor color( double value ) const;

virtual QString type() const;

virtual QgsVectorColorBrewerColorRamp* clone() const /Factory/;
virtual QgsColorBrewerColorRamp* clone() const /Factory/;

virtual QgsStringMap properties() const;

@@ -318,10 +325,13 @@ class QgsVectorColorBrewerColorRamp : QgsVectorColorRamp
};


class QgsCptCityColorRamp : QgsVectorGradientColorRamp
/** \ingroup core
* \class QgsCptCityColorRamp
*/
class QgsCptCityColorRamp : QgsGradientColorRamp
{
%TypeHeaderCode
#include <qgsvectorcolorramp.h>
#include <qgscolorramp.h>
%End
public:
QgsCptCityColorRamp( const QString& schemeName = DEFAULT_CPTCITY_SCHEMENAME,
@@ -330,13 +340,13 @@ class QgsCptCityColorRamp : QgsVectorGradientColorRamp
QgsCptCityColorRamp( const QString& schemeName, const QStringList& variantList,
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 QgsCptCityColorRamp* clone() const /Factory/;
void copy( const QgsCptCityColorRamp* other );
QgsVectorGradientColorRamp* cloneGradientRamp() const /Factory/;
QgsGradientColorRamp* cloneGradientRamp() const /Factory/;

virtual QgsStringMap properties() const;

@@ -148,14 +148,14 @@ class QgsCategorizedSymbolRenderer : QgsFeatureRenderer
* @see setSourceColorRamp()
* @see sourceSymbol()
*/
QgsVectorColorRamp* sourceColorRamp();
QgsColorRamp* sourceColorRamp();

/** Sets the source color ramp.
* @param ramp color ramp. Ownership is transferred to the renderer
* @see sourceColorRamp()
* @see setSourceSymbol()
*/
void setSourceColorRamp( QgsVectorColorRamp* ramp /Transfer/ );
void setSourceColorRamp( QgsColorRamp* ramp /Transfer/ );

//! @note added in 2.1
bool invertedColorRamp();
@@ -166,7 +166,7 @@ class QgsCategorizedSymbolRenderer : QgsFeatureRenderer
* @param inverted set to true to invert ramp colors
* @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/;
QString rotationField() const /Deprecated/;

0 comments on commit 932e469

Please sign in to comment.