QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgscolorramp.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscolorramp.h
3 ---------------------
4 begin : November 2009
5 copyright : (C) 2009 by Martin Dobias
6 email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSCOLORRAMP_H
17#define QGSCOLORRAMP_H
18
19#include "qgis_core.h"
20#include <QColor>
21#include "qgis.h"
22
28class CORE_EXPORT QgsColorRamp
29{
30
31#ifdef SIP_RUN
33 if ( sipCpp->type() == QgsGradientColorRamp::typeString() )
34 sipType = sipType_QgsGradientColorRamp;
35 else if ( sipCpp->type() == QgsLimitedRandomColorRamp::typeString() )
36 sipType = sipType_QgsLimitedRandomColorRamp;
37 else if ( sipCpp->type() == QgsRandomColorRamp::typeString() )
38 sipType = sipType_QgsRandomColorRamp;
39 else if ( sipCpp->type() == QgsPresetSchemeColorRamp::typeString() )
40 sipType = sipType_QgsPresetSchemeColorRamp;
41 else if ( sipCpp->type() == QgsColorBrewerColorRamp::typeString() )
42 sipType = sipType_QgsColorBrewerColorRamp;
43 else if ( sipCpp->type() == QgsCptCityColorRamp::typeString() )
44 sipType = sipType_QgsCptCityColorRamp;
45 else
46 sipType = 0;
48#endif
49 public:
50
51 virtual ~QgsColorRamp();
52
56 virtual int count() const = 0;
57
61 virtual double value( int index ) const = 0;
62
68 virtual QColor color( double value ) const = 0;
69
73 virtual QString type() const = 0;
74
75
79 virtual void invert() {}
80
84 virtual QgsColorRamp *clone() const = 0 SIP_FACTORY;
85
89 virtual QVariantMap properties() const = 0;
90
100 static QList< QPair< QString, QString > > rampTypes();
101};
102
103#endif
static QString typeString()
Returns the string identifier for QgsColorBrewerColorRamp.
Abstract base class for color ramps.
Definition: qgscolorramp.h:29
virtual QColor color(double value) const =0
Returns the color corresponding to a specified value.
virtual int count() const =0
Returns number of defined colors, or -1 if undefined.
virtual double value(int index) const =0
Returns relative value between [0,1] of color at specified index.
virtual QVariantMap properties() const =0
Returns a string map containing all the color ramp's properties.
virtual QgsColorRamp * clone() const =0
Creates a clone of the color ramp.
virtual QString type() const =0
Returns a string representing the color ramp type.
virtual ~QgsColorRamp()
virtual void invert()
Inverts the ordering of the color ramp.
Definition: qgscolorramp.h:79
static QString typeString()
Returns the string identifier for QgsCptCityColorRamp.
static QString typeString()
Returns the string identifier for QgsGradientColorRamp.
static QString typeString()
Returns the string identifier for QgsLimitedRandomColorRamp.
static QString typeString()
Returns the string identifier for QgsPresetSchemeColorRamp.
static QString typeString()
Returns the string identifier for QgsRandomColorRamp.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:191
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_END
Definition: qgis_sip.h:208