KD Chart API Documentation  3.1
Signals | Public Member Functions | Static Public Member Functions | List of all members
KDChart::Palette Class Reference

A Palette is a set of brushes (or colors) to be used for painting data sets. More...

#include <KDChartPalette.h>

Inheritance diagram for KDChart::Palette:

Signals

void changed ()
 

Public Member Functions

 Palette (const Palette &)
 
 Palette (QObject *parent=nullptr)
 
 ~Palette () override
 
void addBrush (const QBrush &brush, int position=-1)
 
QBrush getBrush (int position) const
 
bool isValid () const
 
Paletteoperator= (const Palette &)
 
void removeBrush (int position)
 
int size () const
 

Static Public Member Functions

static const PalettedefaultPalette ()
 
static const PaletterainbowPalette ()
 
static const PalettesubduedPalette ()
 

Detailed Description

A Palette is a set of brushes (or colors) to be used for painting data sets.

The palette class encapsulates a collection of brushes, which in the simplest case are colors, to be used for painting a series of data sets. When asked for the m-th color, a palette of size n will wrap around and thus cycle through the available colors.

Three builtin palettes are provided for convenience, one with a default set of colors, one with a subdued color selection, one with rainbow colors.

When a palette changes, it emits a changed() signal. Hook up to it, if you want to repaint when the color selection changes.

Definition at line 37 of file KDChartPalette.h.

Constructor & Destructor Documentation

◆ Palette() [1/2]

Palette::Palette ( QObject *  parent = nullptr)
explicit

Definition at line 119 of file KDChartPalette.cpp.

◆ Palette() [2/2]

Palette::Palette ( const Palette r)

Definition at line 131 of file KDChartPalette.cpp.

◆ ~Palette()

Palette::~Palette ( )
override

Definition at line 125 of file KDChartPalette.cpp.

Member Function Documentation

◆ addBrush()

void Palette::addBrush ( const QBrush &  brush,
int  position = -1 
)

Adds brush to the palette. If no position is specified, the brush is appended.

Definition at line 156 of file KDChartPalette.cpp.

References changed(), d, and size().

◆ changed

void KDChart::Palette::changed ( )
signal

Emitted whenever the palette changes. Views listen to this and repaing.

Referenced by addBrush(), and removeBrush().

◆ defaultPalette()

const Palette & Palette::defaultPalette ( )
static

Provide access to the three builtin palettes, one with standard bright colors, one with more subdued colors, and one with rainbow colors.

Definition at line 101 of file KDChartPalette.cpp.

Referenced by KDChart::Legend::setDefaultColors(), and KDChart::AttributesModel::setPaletteType().

◆ getBrush()

QBrush Palette::getBrush ( int  position) const

Query the palette for a brush at the specified position. If the position exceeds the size of the palette, it wraps around.

Definition at line 166 of file KDChartPalette.cpp.

References d, isValid(), and size().

Referenced by KDChart::Legend::setDefaultColors(), KDChart::Legend::setRainbowColors(), and KDChart::Legend::setSubduedColors().

◆ isValid()

bool Palette::isValid ( ) const
Returns
whether this represents a valid palette. For a palette to be valid it needs to have at least one brush associated.

Definition at line 146 of file KDChartPalette.cpp.

References d.

Referenced by getBrush().

◆ operator=()

Palette & Palette::operator= ( const Palette r)

Definition at line 137 of file KDChartPalette.cpp.

◆ rainbowPalette()

const Palette & Palette::rainbowPalette ( )
static

◆ removeBrush()

void Palette::removeBrush ( int  position)

Remove the brush at position position, if there is one.

Definition at line 173 of file KDChartPalette.cpp.

References changed(), d, and size().

◆ size()

int Palette::size ( ) const
Returns
the number of brushed in the palette.

Definition at line 151 of file KDChartPalette.cpp.

References d.

Referenced by addBrush(), getBrush(), removeBrush(), KDChart::Legend::setDefaultColors(), KDChart::Legend::setRainbowColors(), and KDChart::Legend::setSubduedColors().

◆ subduedPalette()

const Palette & Palette::subduedPalette ( )
static

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

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated by doxygen 1.9.1