QGIS API Documentation  2.17.0-Master (0497e4a)
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
QgsVectorGradientColorRampV2 Class Reference

Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra color stops. More...

#include <qgsvectorcolorrampv2.h>

Inheritance diagram for QgsVectorGradientColorRampV2:
Inheritance graph
[legend]

Public Member Functions

 QgsVectorGradientColorRampV2 (const QColor &color1=DEFAULT_GRADIENT_COLOR1, const QColor &color2=DEFAULT_GRADIENT_COLOR2, bool discrete=false, const QgsGradientStopsList &stops=QgsGradientStopsList())
 Constructor for QgsVectorGradientColorRampV2. More...
 
void addStopsToGradient (QGradient *gradient, double alpha=1)
 Copy color ramp stops to a QGradient. More...
 
virtual QgsVectorGradientColorRampV2clone () const override
 Creates a clone of the color ramp. More...
 
virtual QColor color (double value) const override
 Returns the color corresponding to a specified value. More...
 
QColor color1 () const
 Returns the gradient start color. More...
 
QColor color2 () const
 Returns the gradient end color. More...
 
void convertToDiscrete (bool discrete)
 Converts a gradient with existing color stops to or from discrete interpolation. More...
 
virtual int count () const override
 Returns number of defined colors, or -1 if undefined. More...
 
QgsStringMap info () const
 Returns any additional info attached to the gradient ramp (eg authorship notes) More...
 
bool isDiscrete () const
 Returns true if the gradient is using discrete interpolation, rather than smoothly interpolating between colors. More...
 
virtual QgsStringMap properties () const override
 Returns a string map containing all the color ramp's properties. More...
 
void setColor1 (const QColor &color)
 Sets the gradient start color. More...
 
void setColor2 (const QColor &color)
 Sets the gradient end color. More...
 
void setDiscrete (bool discrete)
 Sets whether the gradient should use discrete interpolation, rather than smoothly interpolating between colors. More...
 
void setInfo (const QgsStringMap &info)
 Sets additional info to attach to the gradient ramp (eg authorship notes) More...
 
void setStops (const QgsGradientStopsList &stops)
 Sets the list of intermediate gradient stops for the ramp. More...
 
QgsGradientStopsList stops () const
 Returns the list of intermediate gradient stops for the ramp. More...
 
virtual QString type () const override
 Returns a string representing the color ramp type. More...
 
virtual double value (int index) const override
 Returns relative value between [0,1] of color at specified index. More...
 
- Public Member Functions inherited from QgsVectorColorRampV2
virtual ~QgsVectorColorRampV2 ()
 

Static Public Member Functions

static QgsVectorColorRampV2create (const QgsStringMap &properties=QgsStringMap())
 Creates a new QgsVectorColorRampV2 from a map of properties. More...
 

Protected Attributes

QColor mColor1
 
QColor mColor2
 
bool mDiscrete
 
QgsStringMap mInfo
 
QgsGradientStopsList mStops
 

Detailed Description

Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra color stops.

Definition at line 103 of file qgsvectorcolorrampv2.h.

Constructor & Destructor Documentation

§ QgsVectorGradientColorRampV2()

QgsVectorGradientColorRampV2::QgsVectorGradientColorRampV2 ( const QColor color1 = DEFAULT_GRADIENT_COLOR1,
const QColor color2 = DEFAULT_GRADIENT_COLOR2,
bool  discrete = false,
const QgsGradientStopsList stops = QgsGradientStopsList() 
)

Constructor for QgsVectorGradientColorRampV2.

Parameters
color1start color, corresponding to a position of 0.0
color2end color, corresponding to a position of 1.0
discreteset to true for discrete interpolation instead of smoothly interpolating between colors
stopsoptional list of additional color stops

Definition at line 45 of file qgsvectorcolorrampv2.cpp.

Member Function Documentation

§ addStopsToGradient()

void QgsVectorGradientColorRampV2::addStopsToGradient ( QGradient gradient,
double  alpha = 1 
)

Copy color ramp stops to a QGradient.

Parameters
gradientgradient to copy stops into
alphaalpha multiplier. Opacity of colors will be multiplied by this factor before adding to the gradient.
Note
added in 2.1

Definition at line 251 of file qgsvectorcolorrampv2.cpp.

§ clone()

QgsVectorGradientColorRampV2 * QgsVectorGradientColorRampV2::clone ( ) const
overridevirtual

Creates a clone of the color ramp.

Implements QgsVectorColorRampV2.

Reimplemented in QgsCptCityColorRampV2.

Definition at line 163 of file qgsvectorcolorrampv2.cpp.

§ color()

QColor QgsVectorGradientColorRampV2::color ( double  value) const
overridevirtual

Returns the color corresponding to a specified value.

Parameters
valuevalue between [0, 1] inclusive
Returns
color for value

Implements QgsVectorColorRampV2.

Definition at line 117 of file qgsvectorcolorrampv2.cpp.

§ color1()

QColor QgsVectorGradientColorRampV2::color1 ( ) const
inline

Returns the gradient start color.

See also
setColor1()
color2()

Definition at line 133 of file qgsvectorcolorrampv2.h.

§ color2()

QColor QgsVectorGradientColorRampV2::color2 ( ) const
inline

Returns the gradient end color.

See also
setColor2()
color1()

Definition at line 139 of file qgsvectorcolorrampv2.h.

§ convertToDiscrete()

void QgsVectorGradientColorRampV2::convertToDiscrete ( bool  discrete)

Converts a gradient with existing color stops to or from discrete interpolation.

Parameters
discreteset to true to convert the gradient stops to discrete, or false to convert them to smooth interpolation
See also
isDiscrete()

Definition at line 196 of file qgsvectorcolorrampv2.cpp.

§ count()

virtual int QgsVectorGradientColorRampV2::count ( ) const
inlineoverridevirtual

Returns number of defined colors, or -1 if undefined.

Implements QgsVectorColorRampV2.

Definition at line 122 of file qgsvectorcolorrampv2.h.

§ create()

QgsVectorColorRampV2 * QgsVectorGradientColorRampV2::create ( const QgsStringMap properties = QgsStringMap())
static

Creates a new QgsVectorColorRampV2 from a map of properties.

Definition at line 54 of file qgsvectorcolorrampv2.cpp.

§ info()

QgsStringMap QgsVectorGradientColorRampV2::info ( ) const
inline

Returns any additional info attached to the gradient ramp (eg authorship notes)

See also
setInfo()

Definition at line 193 of file qgsvectorcolorrampv2.h.

§ isDiscrete()

bool QgsVectorGradientColorRampV2::isDiscrete ( ) const
inline

Returns true if the gradient is using discrete interpolation, rather than smoothly interpolating between colors.

See also
setDiscrete()

Definition at line 159 of file qgsvectorcolorrampv2.h.

§ properties()

QgsStringMap QgsVectorGradientColorRampV2::properties ( ) const
overridevirtual

Returns a string map containing all the color ramp's properties.

Implements QgsVectorColorRampV2.

Reimplemented in QgsCptCityColorRampV2.

Definition at line 171 of file qgsvectorcolorrampv2.cpp.

§ setColor1()

void QgsVectorGradientColorRampV2::setColor1 ( const QColor color)
inline

Sets the gradient start color.

Parameters
colorstart color
See also
color1()
setColor2()

Definition at line 146 of file qgsvectorcolorrampv2.h.

§ setColor2()

void QgsVectorGradientColorRampV2::setColor2 ( const QColor color)
inline

Sets the gradient end color.

Parameters
colorend color
See also
color2()
setColor1()

Definition at line 153 of file qgsvectorcolorrampv2.h.

§ setDiscrete()

void QgsVectorGradientColorRampV2::setDiscrete ( bool  discrete)
inline

Sets whether the gradient should use discrete interpolation, rather than smoothly interpolating between colors.

Parameters
discreteset to true to use discrete interpolation
See also
convertToDiscrete()
isDiscrete()

Definition at line 167 of file qgsvectorcolorrampv2.h.

§ setInfo()

void QgsVectorGradientColorRampV2::setInfo ( const QgsStringMap info)
inline

Sets additional info to attach to the gradient ramp (eg authorship notes)

Parameters
infomap of string info to attach
See also
info()

Definition at line 199 of file qgsvectorcolorrampv2.h.

§ setStops()

void QgsVectorGradientColorRampV2::setStops ( const QgsGradientStopsList stops)

Sets the list of intermediate gradient stops for the ramp.

Parameters
stopslist of stops. Any existing color stops will be replaced. The stop list will be automatically reordered so that stops are listed in ascending offset order.
See also
stops()

Definition at line 243 of file qgsvectorcolorrampv2.cpp.

§ stops()

QgsGradientStopsList QgsVectorGradientColorRampV2::stops ( ) const
inline

Returns the list of intermediate gradient stops for the ramp.

See also
setStops()

Definition at line 188 of file qgsvectorcolorrampv2.h.

§ type()

virtual QString QgsVectorGradientColorRampV2::type ( ) const
inlineoverridevirtual

Returns a string representing the color ramp type.

Implements QgsVectorColorRampV2.

Reimplemented in QgsCptCityColorRampV2.

Definition at line 125 of file qgsvectorcolorrampv2.h.

§ value()

double QgsVectorGradientColorRampV2::value ( int  index) const
overridevirtual

Returns relative value between [0,1] of color at specified index.

Implements QgsVectorColorRampV2.

Definition at line 101 of file qgsvectorcolorrampv2.cpp.

Member Data Documentation

§ mColor1

QColor QgsVectorGradientColorRampV2::mColor1
protected

Definition at line 210 of file qgsvectorcolorrampv2.h.

§ mColor2

QColor QgsVectorGradientColorRampV2::mColor2
protected

Definition at line 211 of file qgsvectorcolorrampv2.h.

§ mDiscrete

bool QgsVectorGradientColorRampV2::mDiscrete
protected

Definition at line 212 of file qgsvectorcolorrampv2.h.

§ mInfo

QgsStringMap QgsVectorGradientColorRampV2::mInfo
protected

Definition at line 214 of file qgsvectorcolorrampv2.h.

§ mStops

QgsGradientStopsList QgsVectorGradientColorRampV2::mStops
protected

Definition at line 213 of file qgsvectorcolorrampv2.h.


The documentation for this class was generated from the following files: