Skip to content

Commit 932e469

Browse files
committed
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.
1 parent 014409d commit 932e469

File tree

70 files changed

+428
-421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+428
-421
lines changed

doc/api_break.dox

+5-5
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ This page tries to maintain a list with incompatible changes that happened in pr
7272
<tr><td>QgsMultiLineStringV2<td>QgsMultiLineString
7373
<tr><td>QgsMultiSurfaceV2<td>QgsMultiSurface
7474
<tr><td>QgsPointSequenceV2<td>QgsPointSequence
75-
<tr><td>QgsRandomColorsV2<td>QgsRandomColors
75+
<tr><td>QgsRandomColorsV2<td>QgsRandomColorRamp
7676
<tr><td>QgsRendererCategoryV2<td>QgsRendererCategory
7777
<tr><td>QgsRendererRangeV2<td>QgsRendererRange
7878
<tr><td>QgsRendererRangeV2LabelFomat<td>QgsRendererRangeLabelFomat
@@ -125,17 +125,17 @@ This page tries to maintain a list with incompatible changes that happened in pr
125125
<tr><td>QgsSymbolV2SelectorDialog<td>QgsSymbolSelectorDialog
126126
<tr><td>QgsSymbolV2SelectorWidget<td>QgsSymbolSelectorWidget
127127
<tr><td>QgsSymbologyV2Conversion<td>QgsSymbologyConversion
128-
<tr><td>QgsVectorColorBrewerColorRampV2<td>QgsVectorColorBrewerColorRamp
128+
<tr><td>QgsVectorColorBrewerColorRampV2<td>QgsColorBrewerColorRamp
129129
<tr><td>QgsVectorColorBrewerColorRampV2Dialog<td>QgsVectorColorBrewerColorRampDialog
130130
<tr><td>QgsVectorColorBrewerColorRampV2DialogBase<td>QgsVectorColorBrewerColorRampDialogBase
131-
<tr><td>QgsVectorColorRampV2<td>QgsVectorColorRamp
131+
<tr><td>QgsVectorColorRampV2<td>QgsColorRamp
132132
<tr><td>QgsVectorColorRampV2Map<td>QgsVectorColorRampMap
133-
<tr><td>QgsVectorGradientColorRampV2<td>QgsVectorGradientColorRamp
133+
<tr><td>QgsVectorGradientColorRampV2<td>QgsGradientColorRamp
134134
<tr><td>QgsVectorGradientColorRampV2Dialog<td>QgsVectorGradientColorRampDialog
135135
<tr><td>QgsVectorGradientColorRampV2DialogBase<td>QgsVectorGradientColorRampDialogBase
136136
<tr><td>QgsVectorGradientRampV2<td>QgsVectorGradientRamp
137137
<tr><td>QgsVectorLayersetRendererV2<td>QgsVectorLayersetRenderer
138-
<tr><td>QgsVectorRandomColorRampV2<td>QgsVectorRandomColorRamp
138+
<tr><td>QgsVectorRandomColorRampV2<td>QgsLimitedRandomColorRamp
139139
<tr><td>QgsVectorRandomColorRampV2Dialog<td>QgsVectorRandomColorRampDialog
140140
<tr><td>QgsVectorRandomColorRampV2DialogBase<td>QgsVectorRandomColorRampDialogBase
141141
<tr><th>QgsSymbolV2<th>QgsSymbol

python/core/core.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
%Include qgsattributeeditorelement.sip
2828
%Include qgsbrowsermodel.sip
2929
%Include qgsclipper.sip
30+
%Include qgscolorramp.sip
3031
%Include qgscolorscheme.sip
3132
%Include qgscolorschemeregistry.sip
3233
%Include qgsconditionalstyle.sip
@@ -290,7 +291,6 @@
290291
%Include symbology-ng/qgsstyle.sip
291292
%Include symbology-ng/qgssvgcache.sip
292293
%Include symbology-ng/qgssymbol.sip
293-
%Include symbology-ng/qgsvectorcolorramp.sip
294294

295295
%Include symbology-ng/qgs25drenderer.sip
296296
%Include symbology-ng/qgscategorizedsymbolrenderer.sip

python/core/effects/qgsgloweffect.sip

+4-4
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ class QgsGlowEffect : QgsPaintEffect
129129
* @see ramp
130130
* @see setColorType
131131
*/
132-
void setRamp( QgsVectorColorRamp* ramp /Transfer/ );
132+
void setRamp( QgsColorRamp* ramp /Transfer/ );
133133

134134
/** Returns the color ramp used for the glow. This only applies if the @link colorType @endlink
135135
* is set to ColorRamp. The glow will utilise colors from the ramp.
136136
* @returns color ramp for glow
137137
* @see setRamp
138138
* @see colorType
139139
*/
140-
QgsVectorColorRamp* ramp() const;
140+
QgsColorRamp* ramp() const;
141141

142142
/** Sets the blend mode for the effect
143143
* @param mode blend mode used for drawing the effect on to a destination
@@ -153,7 +153,7 @@ class QgsGlowEffect : QgsPaintEffect
153153
*/
154154
QPainter::CompositionMode blendMode() const;
155155

156-
/** Sets the color mode to use for the glow. The glow can either be drawn using a QgsVectorColorRamp
156+
/** Sets the color mode to use for the glow. The glow can either be drawn using a QgsColorRamp
157157
* color ramp or by simply specificing a single color. setColorType is used to specify which mode to use
158158
* for the glow.
159159
* @param colorType color type to use for glow
@@ -163,7 +163,7 @@ class QgsGlowEffect : QgsPaintEffect
163163
*/
164164
void setColorType( GlowColorType colorType );
165165

166-
/** Returns the color mode used for the glow. The glow can either be drawn using a QgsVectorColorRamp
166+
/** Returns the color mode used for the glow. The glow can either be drawn using a QgsColorRamp
167167
* color ramp or by specificing a single color.
168168
* @returns current color mode used for the glow
169169
* @see setColorType

python/core/effects/qgsimageoperation.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class QgsImageOperation
9696
double spread;
9797
/** Color ramp to use for shading the distance transform
9898
*/
99-
QgsVectorColorRamp* ramp;
99+
QgsColorRamp* ramp;
100100
};
101101

102102
/** Performs a distance transform on the source image and shades the result

python/core/symbology-ng/qgsvectorcolorramp.sip python/core/qgscolorramp.sip

+54-44
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1+
12
/** \ingroup core
2-
* \class QgsVectorColorRamp
3+
* \class QgsColorRamp
34
* \brief Abstract base class for color ramps
45
*/
5-
//TODO QGIS 3.0 - rename to QgsColorRamp, since this is used by much more than just vectors
6-
class QgsVectorColorRamp
6+
class QgsColorRamp
77
{
88
%TypeHeaderCode
9-
#include <qgsvectorcolorramp.h>
9+
#include <qgscolorramp.h>
1010
%End
1111

1212
%ConvertToSubClassCode
1313
if (sipCpp->type() == "gradient")
14-
sipType = sipType_QgsVectorGradientColorRamp;
14+
sipType = sipType_QgsGradientColorRamp;
1515
else if (sipCpp->type() == "random")
16-
sipType = sipType_QgsVectorRandomColorRamp;
16+
sipType = sipType_QgsLimitedRandomColorRamp;
1717
else if (sipCpp->type() == "randomcolors")
18-
sipType = sipType_QgsRandomColors;
18+
sipType = sipType_QgsRandomColorRamp;
1919
else if (sipCpp->type() == "colorbrewer")
20-
sipType = sipType_QgsVectorColorBrewerColorRamp;
20+
sipType = sipType_QgsColorBrewerColorRamp;
2121
else if (sipCpp->type() == "cpt-city")
2222
sipType = sipType_QgsCptCityColorRamp;
2323
else
@@ -26,7 +26,7 @@ class QgsVectorColorRamp
2626

2727
public:
2828

29-
virtual ~QgsVectorColorRamp();
29+
virtual ~QgsColorRamp();
3030

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

4949
/** Creates a clone of the color ramp.
5050
*/
51-
virtual QgsVectorColorRamp* clone() const = 0 /Factory/;
51+
virtual QgsColorRamp* clone() const = 0 /Factory/;
5252

5353
/** Returns a string map containing all the color ramp's properties.
5454
*/
@@ -58,20 +58,20 @@ class QgsVectorColorRamp
5858

5959
/** \ingroup core
6060
* \class QgsGradientStop
61-
* \brief Represents a color stop within a gradient color ramp.
61+
* \brief Represents a color stop within a QgsGradientColorRamp color ramp.
6262
*/
6363
class QgsGradientStop
6464
{
6565
%TypeHeaderCode
66-
#include <qgsvectorcolorramp.h>
66+
#include <qgscolorramp.h>
6767
%End
6868
public:
6969

7070
/** Constructor for QgsGradientStop
71-
* @param o positional offset for stop, between 0 and 1.0
72-
* @param c color for stop
71+
* @param offset positional offset for stop, between 0 and 1.0
72+
* @param color color for stop
7373
*/
74-
QgsGradientStop( double o, const QColor& c );
74+
QgsGradientStop( double offset, const QColor& color );
7575

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

8888
/** \ingroup core
89-
* \class QgsVectorGradientColorRamp
89+
* \class QgsGradientColorRamp
9090
* \brief Gradient color ramp, which smoothly interpolates between two colors and also
9191
* supports optional extra color stops.
9292
*/
93-
//TODO QGIS 3.0 - rename to QgsGradientColorRamp, since this is used by much more than just vectors
94-
class QgsVectorGradientColorRamp : QgsVectorColorRamp
93+
class QgsGradientColorRamp : QgsColorRamp
9594
{
9695
%TypeHeaderCode
97-
#include <qgsvectorcolorramp.h>
96+
#include <qgscolorramp.h>
9897
%End
9998
public:
10099

101-
/** Constructor for QgsVectorGradientColorRamp
100+
/** Constructor for QgsGradientColorRamp
102101
* @param color1 start color, corresponding to a position of 0.0
103102
* @param color2 end color, corresponding to a position of 1.0
104103
* @param discrete set to true for discrete interpolation instead of smoothly
105104
* interpolating between colors
106105
* @param stops optional list of additional color stops
107106
*/
108-
QgsVectorGradientColorRamp( const QColor& color1 = DEFAULT_GRADIENT_COLOR1,
107+
QgsGradientColorRamp( const QColor& color1 = DEFAULT_GRADIENT_COLOR1,
109108
const QColor& color2 = QColor(0,255,0),
110109
bool discrete = false,
111110
const QgsGradientStopsList& stops = QgsGradientStopsList() );
112111

113112
//! Creates a new QgsVectorColorRamp from a map of properties
114-
static QgsVectorColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;
113+
static QgsColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;
115114

116115
virtual int count() const;
117116
virtual double value( int index ) const;
118117
virtual QColor color( double value ) const;
119118
virtual QString type() const;
120-
virtual QgsVectorGradientColorRamp* clone() const /Factory/;
119+
virtual QgsGradientColorRamp* clone() const /Factory/;
121120
virtual QgsStringMap properties() const;
122121

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

202201
/** \ingroup core
203-
* \class QgsVectorRandomColorRamp
204-
* \brief Random color ramp, which returns random colors based on preset parameters.
202+
* \class QgsLimitedRandomColorRamp
203+
* \brief Constrained random color ramp, which returns random colors based on preset parameters.
205204
*/
206-
//TODO QGIS 3.0 - rename to QgsRandomColorRamp, since this is used by much more than just vectors
207-
class QgsVectorRandomColorRamp : QgsVectorColorRamp
205+
class QgsLimitedRandomColorRamp : QgsColorRamp
208206
{
209207
%TypeHeaderCode
210-
#include <qgsvectorcolorramp.h>
208+
#include <qgscolorramp.h>
211209
%End
212210
public:
213-
QgsVectorRandomColorRamp( int count = DEFAULT_RANDOM_COUNT,
211+
QgsLimitedRandomColorRamp( int count = DEFAULT_RANDOM_COUNT,
214212
int hueMin = DEFAULT_RANDOM_HUE_MIN, int hueMax = DEFAULT_RANDOM_HUE_MAX,
215213
int satMin = DEFAULT_RANDOM_SAT_MIN, int satMax = DEFAULT_RANDOM_SAT_MAX,
216214
int valMin = DEFAULT_RANDOM_VAL_MIN, int valMax = DEFAULT_RANDOM_VAL_MAX );
217215

218-
static QgsVectorColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;
216+
static QgsColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;
219217

220218
virtual double value( int index ) const;
221219

222220
virtual QColor color( double value ) const;
223221

224222
virtual QString type() const;
225223

226-
virtual QgsVectorRandomColorRamp* clone() const /Factory/;
224+
virtual QgsLimitedRandomColorRamp* clone() const /Factory/;
227225

228226
virtual QgsStringMap properties() const;
229227

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

257-
class QgsRandomColors : QgsVectorColorRamp
255+
/** \ingroup core
256+
* \class QgsRandomColorRamp
257+
*/
258+
class QgsRandomColorRamp : QgsColorRamp
258259
{
260+
%TypeHeaderCode
261+
#include <qgscolorramp.h>
262+
%End
259263
public:
260-
QgsRandomColors();
261-
~QgsRandomColors();
264+
QgsRandomColorRamp();
265+
~QgsRandomColorRamp();
262266

263267
int count() const;
264268

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

277281
QString type() const;
278282

279-
virtual QgsRandomColors* clone() const /Factory/;
283+
virtual QgsRandomColorRamp* clone() const /Factory/;
280284

281285
QgsStringMap properties() const;
282286
};
283287

284-
class QgsVectorColorBrewerColorRamp : QgsVectorColorRamp
288+
/** \ingroup core
289+
* \class QgsColorBrewerColorRamp
290+
*/
291+
class QgsColorBrewerColorRamp : QgsColorRamp
285292
{
286293
%TypeHeaderCode
287-
#include <qgsvectorcolorramp.h>
294+
#include <qgscolorramp.h>
288295
%End
289296
public:
290-
QgsVectorColorBrewerColorRamp( const QString& schemeName = DEFAULT_COLORBREWER_SCHEMENAME,
297+
QgsColorBrewerColorRamp( const QString& schemeName = DEFAULT_COLORBREWER_SCHEMENAME,
291298
int colors = DEFAULT_COLORBREWER_COLORS );
292299

293-
static QgsVectorColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;
300+
static QgsColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;
294301

295302
virtual double value( int index ) const;
296303

297304
virtual QColor color( double value ) const;
298305

299306
virtual QString type() const;
300307

301-
virtual QgsVectorColorBrewerColorRamp* clone() const /Factory/;
308+
virtual QgsColorBrewerColorRamp* clone() const /Factory/;
302309

303310
virtual QgsStringMap properties() const;
304311

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

320327

321-
class QgsCptCityColorRamp : QgsVectorGradientColorRamp
328+
/** \ingroup core
329+
* \class QgsCptCityColorRamp
330+
*/
331+
class QgsCptCityColorRamp : QgsGradientColorRamp
322332
{
323333
%TypeHeaderCode
324-
#include <qgsvectorcolorramp.h>
334+
#include <qgscolorramp.h>
325335
%End
326336
public:
327337
QgsCptCityColorRamp( const QString& schemeName = DEFAULT_CPTCITY_SCHEMENAME,
@@ -330,13 +340,13 @@ class QgsCptCityColorRamp : QgsVectorGradientColorRamp
330340
QgsCptCityColorRamp( const QString& schemeName, const QStringList& variantList,
331341
const QString& variantName = QString(), bool doLoadFile = true );
332342

333-
static QgsVectorColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;
343+
static QgsColorRamp* create( const QgsStringMap& properties = QgsStringMap() ) /Factory/;
334344

335345
virtual QString type() const;
336346

337347
virtual QgsCptCityColorRamp* clone() const /Factory/;
338348
void copy( const QgsCptCityColorRamp* other );
339-
QgsVectorGradientColorRamp* cloneGradientRamp() const /Factory/;
349+
QgsGradientColorRamp* cloneGradientRamp() const /Factory/;
340350

341351
virtual QgsStringMap properties() const;
342352

python/core/symbology-ng/qgscategorizedsymbolrenderer.sip

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,14 @@ class QgsCategorizedSymbolRenderer : QgsFeatureRenderer
148148
* @see setSourceColorRamp()
149149
* @see sourceSymbol()
150150
*/
151-
QgsVectorColorRamp* sourceColorRamp();
151+
QgsColorRamp* sourceColorRamp();
152152

153153
/** Sets the source color ramp.
154154
* @param ramp color ramp. Ownership is transferred to the renderer
155155
* @see sourceColorRamp()
156156
* @see setSourceSymbol()
157157
*/
158-
void setSourceColorRamp( QgsVectorColorRamp* ramp /Transfer/ );
158+
void setSourceColorRamp( QgsColorRamp* ramp /Transfer/ );
159159

160160
//! @note added in 2.1
161161
bool invertedColorRamp();
@@ -166,7 +166,7 @@ class QgsCategorizedSymbolRenderer : QgsFeatureRenderer
166166
* @param inverted set to true to invert ramp colors
167167
* @note added in 2.5
168168
*/
169-
void updateColorRamp( QgsVectorColorRamp* ramp /Transfer/, bool inverted = false );
169+
void updateColorRamp( QgsColorRamp* ramp /Transfer/, bool inverted = false );
170170

171171
void setRotationField( const QString& fieldOrExpression ) /Deprecated/;
172172
QString rotationField() const /Deprecated/;

0 commit comments

Comments
 (0)