kchart
KDChartPainter Class Reference
#include <KDChartPainter.h>
Inheritance diagram for KDChartPainter:

Detailed Description
An abstract base class that defines an interface for classes that implement chart drawing.Applications don't use this class directly (except for registering/unregistering, see below) new chart implementations, but instead use the method KDChart::paint() which takes care of the correct creation and deletion of the painter implementation used. Or they use KDChartWidget which handles everything automatically.
This class cannot be instantiated directly. Even the concrete subclasses are not instantiated directly, but are instantiated via KDChartPainter::create() which creates a subclass according to the parameters passed.
Application developers can provide their own chart implementations by subclassing from KDChartPainter, instantiating their subclass and registering their implementation with KDChartPainter::registerPainter(). These registrations can be removed with KDChartPainter::unregisterPainter().
Definition at line 87 of file KDChartPainter.h.
Public Member Functions | |
virtual | ~KDChartPainter () |
virtual void | setupGeometry (QPainter *painter, KDChartTableDataBase *data, const QRect &rect) |
virtual void | paint (QPainter *painter, KDChartTableDataBase *data, bool paintFirst, bool paintLast, KDChartDataRegionList *regions=0, const QRect *rect=0, bool mustCalculateGeometry=true) |
virtual QRect | outermostRect () const |
Static Public Member Functions | |
static KDChartPainter * | create (KDChartParams *params, bool make2nd=false) |
static void | registerPainter (const QString &painterName, KDChartPainter *painter) |
static void | unregisterPainter (const QString &painterName) |
static void | drawMarker (QPainter *painter, int style, const QColor &color, const QPoint &p, const QSize &size, uint align=Qt::AlignCenter) |
Protected Member Functions | |
KDChartPainter (KDChartParams *) | |
virtual void | paintArea (QPainter *painter, uint area, KDChartDataRegionList *regions=0, uint dataRow=0, uint dataCol=0, uint data3rd=0) |
virtual void | paintDataRegionAreas (QPainter *painter, KDChartDataRegionList *regions) |
virtual void | paintAreaWithGap (QPainter *painter, QRect rect, const KDChartParams::KDChartFrameSettings &settings) |
virtual void | paintCustomBoxes (QPainter *painter, KDChartDataRegionList *regions) |
virtual void | paintData (QPainter *painter, KDChartTableDataBase *data, bool paint2nd, KDChartDataRegionList *regions=0)=0 |
virtual void | paintDataValues (QPainter *painter, KDChartTableDataBase *data, KDChartDataRegionList *regions) |
virtual void | paintAxes (QPainter *painter, KDChartTableDataBase *data) |
virtual void | paintLegend (QPainter *painter, KDChartTableDataBase *data) |
virtual void | paintHeaderFooter (QPainter *painter, KDChartTableDataBase *data) |
virtual bool | axesOverlapping (int axis1, int axis2) |
virtual void | findChartDatasets (KDChartTableDataBase *data, bool paint2nd, uint chart, uint &chartDatasetStart, uint &chartDatasetEnd) |
virtual void | calculateAllAxesRects (QPainter *painter, bool finalPrecision, KDChartTableDataBase *data) |
virtual QPoint | calculateAnchor (const KDChartCustomBox &box, KDChartDataRegionList *regions=0) const |
virtual QRect | calculateAreaRect (bool &allCustomBoxes, uint area, uint dataRow, uint dataCol, uint data3rd, KDChartDataRegionList *regions) const |
virtual QString | fallbackLegendText (uint dataset) const |
virtual uint | numLegendFallbackTexts (KDChartTableDataBase *data) const |
const KDChartParams * | params () const |
virtual bool | calculateAllAxesLabelTextsAndCalcValues (QPainter *painter, KDChartTableDataBase *data, double areaWidthP1000, double areaHeightP1000, double &delimLen) |
virtual void | drawExtraLinesAndMarkers (KDChartPropertySet &propSet, const QPen &defaultPen, const KDChartParams::LineMarkerStyle &defaultMarkerStyle, int myPointX, int myPointY, QPainter *painter, const KDChartAxisParams *abscissaPara, const KDChartAxisParams *ordinatePara, const double areaWidthP1000, const double areaHeightP1000, bool bDrawInFront=FALSE) |
Static Protected Member Functions | |
static QPoint | pointOnCircle (const QRect &rect, double angle) |
static void | makeArc (QPointArray &points, const QRect &rect, double startAngle, double angles) |
static KDChartDataRegion * | drawMarker (QPainter *painter, const KDChartParams *params, double areaWidthP1000, double areaHeightP1000, int deltaX, int deltaY, int style, const QColor &color, const QPoint &p, uint dataset, uint value, uint chart, KDChartDataRegionList *regions=0, int *width=0, int *height=0, uint align=Qt::AlignCenter) |
Protected Attributes | |
QRect | _outermostRect |
QRect | _innermostRect |
QRect | _dataRect |
QRect | _axesRect |
QRect | _legendRect |
int | _legendEMSpace |
int | _legendSpacing |
int | _legendHeight |
int | _legendLeading |
KDChartTextPiece * | _legendTitle |
int | _numLegendTexts |
int | _logicalWidth |
int | _logicalHeight |
double | _areaWidthP1000 |
double | _areaHeightP1000 |
QMap< int, QString > | _legendTexts |
internal__KDChart__CalcValues | calcVal [KDCHART_MAX_AXES] |
Constructor & Destructor Documentation
KDChartPainter::~KDChartPainter | ( | ) | [virtual] |
Destructor.
Cleans up any data structures that might have been allocated in the meantime.
Definition at line 113 of file KDChartPainter.cpp.
KDChartPainter::KDChartPainter | ( | KDChartParams * | params | ) | [protected] |
Constructor.
Will only be called by subclass constructors since this class can never be instantiated directly.
- Parameters:
-
params the parameters of the chart to be drawn
Definition at line 96 of file KDChartPainter.cpp.
Member Function Documentation
QPoint KDChartPainter::calculateAnchor | ( | const KDChartCustomBox & | box, | |
KDChartDataRegionList * | regions = 0 | |||
) | const [protected, virtual] |
QRect KDChartPainter::calculateAreaRect | ( | bool & | allCustomBoxes, | |
uint | area, | |||
uint | dataRow, | |||
uint | dataCol, | |||
uint | data3rd, | |||
KDChartDataRegionList * | regions | |||
) | const [protected, virtual] |
Calculated the rectangle covered by an area.
NOTE: KDChartCustomBox areas are _not_ calculated here.
Definition at line 1022 of file KDChartPainter.cpp.
KDChartPainter * KDChartPainter::create | ( | KDChartParams * | params, | |
bool | make2nd = false | |||
) | [static] |
Creates an object of a concrete subclass of KDChartPainter that KDChart::paint() (and consequently, the application) can use to have charts painted.
The subclass is determined on the base of the params parameter which among other things indicates the type of the chart.
- Parameters:
-
params the parameter set which is used to determine the painter implementation to be used
- Returns:
- a pointer to an object of a subclass of KDChartPainter that can be used to draw charts as defined by the params parameter. Returns 0 if there is no registered KDChartPainter subclass for the type specified in params. This can only happen with user-defined chart types.
Definition at line 145 of file KDChartPainter.cpp.
KDChartDataRegion * KDChartPainter::drawMarker | ( | QPainter * | painter, | |
const KDChartParams * | params, | |||
double | areaWidthP1000, | |||
double | areaHeightP1000, | |||
int | deltaX, | |||
int | deltaY, | |||
int | style, | |||
const QColor & | color, | |||
const QPoint & | _p, | |||
uint | dataset, | |||
uint | value, | |||
uint | chart, | |||
KDChartDataRegionList * | regions = 0 , |
|||
int * | width = 0 , |
|||
int * | height = 0 , |
|||
uint | align = Qt::AlignCenter | |||
) | [static, protected] |
Draws the marker for one data point according to the specified style.
- Parameters:
-
painter the painter to draw on style what kind of marker is drawn (square, diamond, circle, ...) color the color in which to draw the marker p the center of the marker dataset the dataset which this marker represents value the value which this marker represents regions a list of regions for data points, a new region for the new marker will be appended to this list if it is not 0
- Returns:
- pointer to the KDChartDataRegion that was appended to the regions list, or zero if if parameter regions was zero
Definition at line 2584 of file KDChartPainter.cpp.
void KDChartPainter::drawMarker | ( | QPainter * | painter, | |
int | style, | |||
const QColor & | color, | |||
const QPoint & | p, | |||
const QSize & | size, | |||
uint | align = Qt::AlignCenter | |||
) | [static] |
Draws the marker for one data point according to the specified style, color, size.
- Parameters:
-
painter the painter to draw on style what kind of marker is drawn (square, diamond, circle, ...) color the color in which to draw the marker p the center of the marker size the width and height of the marker: both values must be positive.
Definition at line 2545 of file KDChartPainter.cpp.
QString KDChartPainter::fallbackLegendText | ( | uint | dataset | ) | const [protected, virtual] |
This method provides a fallback legend text for the specified dataset, if there was no other way to determine a legend text, but a legend should be shown nevertheless.
The default is to return "Series" plus a dataset number (with datasets starting at 1 for this purpose; inherited painter implementations can override this.
This method is only used when automatic legends are used, because manual and first-column legends do not need fallback texts.
- Parameters:
-
uint dataset the dataset number for which to generate a fallback text
- Returns:
- the fallback text to use for describing the specified dataset in the legend
Reimplemented in KDChartBWPainter, KDChartHiLoPainter, KDChartPiePainter, KDChartPolarPainter, and KDChartRingPainter.
Definition at line 2512 of file KDChartPainter.cpp.
uint KDChartPainter::numLegendFallbackTexts | ( | KDChartTableDataBase * | data | ) | const [protected, virtual] |
This methods returns the number of elements to be shown in the legend in case fallback texts are used.
By default, this will be the number of datasets, but specialized painters can override this (e.g., painters that draw charts that can only display one dataset will return the number of values instead).
This method is only used when automatic legends are used, because manual and first-column legends do not need fallback texts.
- Returns:
- the number of fallback texts to use
Reimplemented in KDChartBWPainter, KDChartHiLoPainter, KDChartPiePainter, KDChartPolarPainter, and KDChartRingPainter.
Definition at line 2530 of file KDChartPainter.cpp.
void KDChartPainter::paint | ( | QPainter * | painter, | |
KDChartTableDataBase * | data, | |||
bool | paintFirst, | |||
bool | paintLast, | |||
KDChartDataRegionList * | regions = 0 , |
|||
const QRect * | rect = 0 , |
|||
bool | mustCalculateGeometry = true | |||
) | [virtual] |
Paints the chart for which this chart painter is configured on a QPainter.
This is the method that bundles all the painting functions that paint specific parts of the chart like axes or legends. Subclasses can override this method, but should rarely need to do so.
- Parameters:
-
painter the QPainter onto which the chart should be drawn data the data which will be displayed as a chart regions a pointer to a region list that will be filled with regions representing the data segments if not null
Definition at line 227 of file KDChartPainter.cpp.
void KDChartPainter::paintArea | ( | QPainter * | painter, | |
uint | area, | |||
KDChartDataRegionList * | regions = 0 , |
|||
uint | dataRow = 0 , |
|||
uint | dataCol = 0 , |
|||
uint | data3rd = 0 | |||
) | [protected, virtual] |
void KDChartPainter::paintAreaWithGap | ( | QPainter * | painter, | |
QRect | rect, | |||
const KDChartParams::KDChartFrameSettings & | settings | |||
) | [protected, virtual] |
Paints an area frame.
This methode is called internally by KDChartPainter::paintArea. NOTE: areas around KDChartCustomBoxes are _not_ drawn here but in KDChartCustomBox::paint() which is called by paintCustomBoxes().
Definition at line 410 of file KDChartPainter.cpp.
void KDChartPainter::paintAxes | ( | QPainter * | painter, | |
KDChartTableDataBase * | data | |||
) | [protected, virtual] |
Paints the axes for the chart.
The implementation in KDChartPainter does nothing; subclasses for chart types that have axes will provide the appropriate drawing code here. This method serves as a fallback for chart types that do not have axes (like pies).
- Parameters:
-
painter the QPainter onto which the chart should be drawn data the data that will be displayed as a chart
Reimplemented in KDChartAxesPainter.
Definition at line 1225 of file KDChartPainter.cpp.
void KDChartPainter::paintCustomBoxes | ( | QPainter * | painter, | |
KDChartDataRegionList * | regions | |||
) | [protected, virtual] |
void KDChartPainter::paintDataValues | ( | QPainter * | painter, | |
KDChartTableDataBase * | data, | |||
KDChartDataRegionList * | regions | |||
) | [protected, virtual] |
Paints the data value texts near the data representations.
Definition at line 424 of file KDChartPainter.cpp.
void KDChartPainter::paintHeaderFooter | ( | QPainter * | painter, | |
KDChartTableDataBase * | data | |||
) | [protected, virtual] |
Paints the header and footers for the chart.
The implementation in KDChartPainter draws a standard header that should be suitable for most chart types. Subclasses can provide their own implementations.
- Parameters:
-
painter the QPainter onto which the chart should be drawn data the data that will be displayed as a chart
Definition at line 1620 of file KDChartPainter.cpp.
void KDChartPainter::paintLegend | ( | QPainter * | painter, | |
KDChartTableDataBase * | data | |||
) | [protected, virtual] |
Paints the legend for the chart.
The implementation in KDChartPainter draws a standard legend that should be suitable for most chart types. Subclasses can provide their own implementations.
- Parameters:
-
painter the QPainter onto which the chart should be drawn data the data that will be displayed as a chart
Definition at line 1358 of file KDChartPainter.cpp.
void KDChartPainter::registerPainter | ( | const QString & | painterName, | |
KDChartPainter * | painter | |||
) | [static] |
Registers a user-defined painter implementation which is identified by a string.
If there is already a painter implementation registered under that name, the old registration will be deleted.
KDChartPainter does not assume ownership of the registered painter, but you should unregister a painter before deleting an implementation object to avoid that that object is called after its deletion.
- Parameters:
-
painterName the name under which the painter implementation should be registered. This will be matched against the user-defined chart type name in the KDChartParams structure. painter an implementation object of a user-defined chart implementation
Definition at line 191 of file KDChartPainter.cpp.
void KDChartPainter::setupGeometry | ( | QPainter * | painter, | |
KDChartTableDataBase * | data, | |||
const QRect & | drawRect | |||
) | [virtual] |
This method will be called whenever any parameters that affect geometry have been changed.
It will compute the appropriate positions for the various parts of the chart (legend, axes, data area etc.). The implementation in KDChartPainter computes a standard geometry that should be suitable for most chart types. Subclasses can provide their own implementations.
- Parameters:
-
data the data that will be displayed as a chart drawRect the position and size of the area where the chart is to be displayed in
Definition at line 2120 of file KDChartPainter.cpp.
void KDChartPainter::unregisterPainter | ( | const QString & | painterName | ) | [static] |
Unregisters a user-defined painter implementation.
Does not delete the implementation object. If no implementation has been registered under this name, an exception is thrown if KDChart is compiled with exceptions, otherwise nothing happens.
- Parameters:
-
the name under which the painter implementation is registered
Definition at line 208 of file KDChartPainter.cpp.
The documentation for this class was generated from the following files: