kchart

#include <KDChartPainter.h>

Inheritance diagram for KDChartPainter:
KDChartAxesPainter KDChartPiePainter KDChartPolarPainter KDChartRingPainter KDChartBWPainter KDChartBarPainter KDChartHiLoPainter KDChartLinesPainter KDChartAreaPainter

Public Member Functions

virtual ~KDChartPainter ()
virtual void setupGeometry (TQPainter *painter, KDChartTableDataBase *data, const TQRect &rect)
virtual void paint (TQPainter *painter, KDChartTableDataBase *data, bool paintFirst, bool paintLast, KDChartDataRegionList *regions=0, const TQRect *rect=0, bool mustCalculateGeometry=true)
virtual TQRect outermostRect () const

Static Public Member Functions

static KDChartPainter * create (KDChartParams *params, bool make2nd=false)
static void registerPainter (const TQString &painterName, KDChartPainter *painter)
static void unregisterPainter (const TQString &painterName)
static void drawMarker (TQPainter *painter, int style, const TQColor &color, const TQPoint &p, const TQSize &size, uint align=TQt::AlignCenter)

Protected Member Functions

 KDChartPainter (KDChartParams *)
virtual void paintArea (TQPainter *painter, uint area, KDChartDataRegionList *regions=0, uint dataRow=0, uint dataCol=0, uint data3rd=0)
virtual void paintDataRegionAreas (TQPainter *painter, KDChartDataRegionList *regions)
virtual void paintAreaWithGap (TQPainter *painter, TQRect rect, const KDChartParams::KDChartFrameSettings &settings)
virtual void paintCustomBoxes (TQPainter *painter, KDChartDataRegionList *regions)
virtual void paintData (TQPainter *painter, KDChartTableDataBase *data, bool paint2nd, KDChartDataRegionList *regions=0)=0
virtual void paintDataValues (TQPainter *painter, KDChartTableDataBase *data, KDChartDataRegionList *regions)
virtual void paintAxes (TQPainter *painter, KDChartTableDataBase *data)
virtual void paintLegend (TQPainter *painter, KDChartTableDataBase *data)
virtual void paintHeaderFooter (TQPainter *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 (TQPainter *painter, bool finalPrecision, KDChartTableDataBase *data)
virtual TQPoint calculateAnchor (const KDChartCustomBox &box, KDChartDataRegionList *regions=0) const
virtual TQRect calculateAreaRect (bool &allCustomBoxes, uint area, uint dataRow, uint dataCol, uint data3rd, KDChartDataRegionList *regions) const
virtual TQString fallbackLegendText (uint dataset) const
virtual uint numLegendFallbackTexts (KDChartTableDataBase *data) const
const KDChartParams * params () const
virtual bool calculateAllAxesLabelTextsAndCalcValues (TQPainter *painter, KDChartTableDataBase *data, double areaWidthP1000, double areaHeightP1000, double &delimLen)
virtual void drawExtraLinesAndMarkers (KDChartPropertySet &propSet, const TQPen &defaultPen, const KDChartParams::LineMarkerStyle &defaultMarkerStyle, int myPointX, int myPointY, TQPainter *painter, const KDChartAxisParams *abscissaPara, const KDChartAxisParams *ordinatePara, const double areaWidthP1000, const double areaHeightP1000, bool bDrawInFront=false)

Static Protected Member Functions

static TQPoint pointOnCircle (const TQRect &rect, double angle)
static void makeArc (TQPointArray &points, const TQRect &rect, double startAngle, double angles)
static KDChartDataRegion * drawMarker (TQPainter *painter, const KDChartParams *params, double areaWidthP1000, double areaHeightP1000, int deltaX, int deltaY, int style, const TQColor &color, const TQPoint &p, uint dataset, uint value, uint chart, KDChartDataRegionList *regions=0, int *width=0, int *height=0, uint align=TQt::AlignCenter)

Protected Attributes

TQRect _outermostRect
TQRect _innermostRect
TQRect _dataRect
TQRect _axesRect
TQRect _legendRect
int _legendEMSpace
int _legendSpacing
int _legendHeight
int _legendLeading
KDChartTextPiece * _legendTitle
int _numLegendTexts
int _logicalWidth
int _logicalHeight
double _areaWidthP1000
double _areaHeightP1000
TQMap< int, TQString > _legendTexts
internal__KDChart__CalcValues calcVal [KDCHART_MAX_AXES]

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.

Constructor & Destructor Documentation

◆ ~KDChartPainter()

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::KDChartPainter ( KDChartParams * params)
protected

Constructor.

Will only be called by subclass constructors since this class can never be instantiated directly.

Parameters
paramsthe parameters of the chart to be drawn

Definition at line 96 of file KDChartPainter.cpp.

Member Function Documentation

◆ axesOverlapping()

bool KDChartPainter::axesOverlapping ( int axis1,
int axis2 )
protectedvirtual

Definition at line 1546 of file KDChartPainter.cpp.

◆ calculateAllAxesLabelTextsAndCalcValues()

bool KDChartPainter::calculateAllAxesLabelTextsAndCalcValues ( TQPainter * painter,
KDChartTableDataBase * data,
double areaWidthP1000,
double areaHeightP1000,
double & delimLen )
protectedvirtual

Definition at line 118 of file KDChartPainter.cpp.

◆ calculateAllAxesRects()

void KDChartPainter::calculateAllAxesRects ( TQPainter * painter,
bool finalPrecision,
KDChartTableDataBase * data )
protectedvirtual

Definition at line 1827 of file KDChartPainter.cpp.

◆ calculateAnchor()

TQPoint KDChartPainter::calculateAnchor ( const KDChartCustomBox & box,
KDChartDataRegionList * regions = 0 ) const
protectedvirtual

Calculated the top left corner of a custom box.

Definition at line 964 of file KDChartPainter.cpp.

◆ calculateAreaRect()

TQRect KDChartPainter::calculateAreaRect ( bool & allCustomBoxes,
uint area,
uint dataRow,
uint dataCol,
uint data3rd,
KDChartDataRegionList * regions ) const
protectedvirtual

Calculated the rectangle covered by an area.

NOTE: KDChartCustomBox areas are not calculated here.

Definition at line 1025 of file KDChartPainter.cpp.

◆ create()

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
paramsthe 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.

◆ drawExtraLinesAndMarkers()

void KDChartPainter::drawExtraLinesAndMarkers ( KDChartPropertySet & propSet,
const TQPen & defaultPen,
const KDChartParams::LineMarkerStyle & defaultMarkerStyle,
int myPointX,
int myPointY,
TQPainter * painter,
const KDChartAxisParams * abscissaPara,
const KDChartAxisParams * ordinatePara,
const double areaWidthP1000,
const double areaHeightP1000,
bool bDrawInFront = false )
protectedvirtual

Definition at line 2838 of file KDChartPainter.cpp.

◆ drawMarker() [1/2]

KDChartDataRegion * KDChartPainter::drawMarker ( TQPainter * painter,
const KDChartParams * params,
double areaWidthP1000,
double areaHeightP1000,
int deltaX,
int deltaY,
int style,
const TQColor & color,
const TQPoint & _p,
uint dataset,
uint value,
uint chart,
KDChartDataRegionList * regions = 0,
int * width = 0,
int * height = 0,
uint align = TQt::AlignCenter )
staticprotected

Draws the marker for one data point according to the specified style.

Parameters
painterthe painter to draw on
stylewhat kind of marker is drawn (square, diamond, circle, ...)
colorthe color in which to draw the marker
pthe center of the marker
datasetthe dataset which this marker represents
valuethe value which this marker represents
regionsa 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 2612 of file KDChartPainter.cpp.

◆ drawMarker() [2/2]

void KDChartPainter::drawMarker ( TQPainter * painter,
int style,
const TQColor & color,
const TQPoint & p,
const TQSize & size,
uint align = TQt::AlignCenter )
static

Draws the marker for one data point according to the specified style, color, size.

Parameters
painterthe painter to draw on
stylewhat kind of marker is drawn (square, diamond, circle, ...)
colorthe color in which to draw the marker
pthe center of the marker
sizethe width and height of the marker: both values must be positive.

Definition at line 2573 of file KDChartPainter.cpp.

◆ fallbackLegendText()

TQString KDChartPainter::fallbackLegendText ( uint dataset) const
protectedvirtual

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
uintdataset 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 2540 of file KDChartPainter.cpp.

◆ findChartDatasets()

void KDChartPainter::findChartDatasets ( KDChartTableDataBase * data,
bool paint2nd,
uint chart,
uint & chartDatasetStart,
uint & chartDatasetEnd )
protectedvirtual

Definition at line 1790 of file KDChartPainter.cpp.

◆ makeArc()

void KDChartPainter::makeArc ( TQPointArray & points,
const TQRect & rect,
double startAngle,
double angles )
staticprotected

Definition at line 1183 of file KDChartPainter.cpp.

◆ numLegendFallbackTexts()

uint KDChartPainter::numLegendFallbackTexts ( KDChartTableDataBase * data) const
protectedvirtual

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 2558 of file KDChartPainter.cpp.

◆ outermostRect()

virtual TQRect KDChartPainter::outermostRect ( ) const
inlinevirtual

Definition at line 110 of file KDChartPainter.h.

◆ paint()

void KDChartPainter::paint ( TQPainter * painter,
KDChartTableDataBase * data,
bool paintFirst,
bool paintLast,
KDChartDataRegionList * regions = 0,
const TQRect * rect = 0,
bool mustCalculateGeometry = true )
virtual

Paints the chart for which this chart painter is configured on a TQPainter.

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
painterthe TQPainter onto which the chart should be drawn
datathe data which will be displayed as a chart
regionsa 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.

◆ paintArea()

void KDChartPainter::paintArea ( TQPainter * painter,
uint area,
KDChartDataRegionList * regions = 0,
uint dataRow = 0,
uint dataCol = 0,
uint data3rd = 0 )
protectedvirtual

Paints an area frame.

Definition at line 332 of file KDChartPainter.cpp.

◆ paintAreaWithGap()

void KDChartPainter::paintAreaWithGap ( TQPainter * painter,
TQRect rect,
const KDChartParams::KDChartFrameSettings & settings )
protectedvirtual

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.

◆ paintAxes()

void KDChartPainter::paintAxes ( TQPainter * painter,
KDChartTableDataBase * data )
protectedvirtual

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
painterthe TQPainter onto which the chart should be drawn
datathe data that will be displayed as a chart

Reimplemented in KDChartAxesPainter.

Definition at line 1228 of file KDChartPainter.cpp.

◆ paintCustomBoxes()

void KDChartPainter::paintCustomBoxes ( TQPainter * painter,
KDChartDataRegionList * regions )
protectedvirtual

Paints all custom boxes.

Definition at line 920 of file KDChartPainter.cpp.

◆ paintData()

virtual void KDChartPainter::paintData ( TQPainter * painter,
KDChartTableDataBase * data,
bool paint2nd,
KDChartDataRegionList * regions = 0 )
protectedpure virtual

◆ paintDataRegionAreas()

void KDChartPainter::paintDataRegionAreas ( TQPainter * painter,
KDChartDataRegionList * regions )
protectedvirtual

Definition at line 356 of file KDChartPainter.cpp.

◆ paintDataValues()

void KDChartPainter::paintDataValues ( TQPainter * painter,
KDChartTableDataBase * data,
KDChartDataRegionList * regions )
protectedvirtual

Paints the data value texts near the data representations.

Definition at line 424 of file KDChartPainter.cpp.

◆ paintHeaderFooter()

void KDChartPainter::paintHeaderFooter ( TQPainter * painter,
KDChartTableDataBase * data )
protectedvirtual

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
painterthe TQPainter onto which the chart should be drawn
datathe data that will be displayed as a chart

Definition at line 1636 of file KDChartPainter.cpp.

◆ paintLegend()

void KDChartPainter::paintLegend ( TQPainter * painter,
KDChartTableDataBase * data )
protectedvirtual

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
painterthe TQPainter onto which the chart should be drawn
datathe data that will be displayed as a chart

Definition at line 1374 of file KDChartPainter.cpp.

◆ params()

const KDChartParams * KDChartPainter::params ( ) const
inlineprotected

Definition at line 181 of file KDChartPainter.h.

◆ pointOnCircle()

TQPoint KDChartPainter::pointOnCircle ( const TQRect & rect,
double angle )
staticprotected

Definition at line 1163 of file KDChartPainter.cpp.

◆ registerPainter()

void KDChartPainter::registerPainter ( const TQString & 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
painterNamethe name under which the painter implementation should be registered. This will be matched against the user-defined chart type name in the KDChartParams structure.
painteran implementation object of a user-defined chart implementation

Definition at line 191 of file KDChartPainter.cpp.

◆ setupGeometry()

void KDChartPainter::setupGeometry ( TQPainter * painter,
KDChartTableDataBase * data,
const TQRect & 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
datathe data that will be displayed as a chart
drawRectthe position and size of the area where the chart is to be displayed in

Definition at line 2156 of file KDChartPainter.cpp.

◆ unregisterPainter()

void KDChartPainter::unregisterPainter ( const TQString & 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
thename under which the painter implementation is registered

Definition at line 208 of file KDChartPainter.cpp.

Member Data Documentation

◆ _areaHeightP1000

double KDChartPainter::_areaHeightP1000
protected

Definition at line 221 of file KDChartPainter.h.

◆ _areaWidthP1000

double KDChartPainter::_areaWidthP1000
protected

Definition at line 220 of file KDChartPainter.h.

◆ _axesRect

TQRect KDChartPainter::_axesRect
protected

Definition at line 197 of file KDChartPainter.h.

◆ _dataRect

TQRect KDChartPainter::_dataRect
protected

Definition at line 195 of file KDChartPainter.h.

◆ _innermostRect

TQRect KDChartPainter::_innermostRect
protected

Definition at line 189 of file KDChartPainter.h.

◆ _legendEMSpace

int KDChartPainter::_legendEMSpace
protected

Definition at line 208 of file KDChartPainter.h.

◆ _legendHeight

int KDChartPainter::_legendHeight
protected

Definition at line 210 of file KDChartPainter.h.

◆ _legendLeading

int KDChartPainter::_legendLeading
protected

Definition at line 211 of file KDChartPainter.h.

◆ _legendRect

TQRect KDChartPainter::_legendRect
protected

Definition at line 203 of file KDChartPainter.h.

◆ _legendSpacing

int KDChartPainter::_legendSpacing
protected

Definition at line 209 of file KDChartPainter.h.

◆ _legendTexts

TQMap< int, TQString > KDChartPainter::_legendTexts
protected

Definition at line 223 of file KDChartPainter.h.

◆ _legendTitle

KDChartTextPiece* KDChartPainter::_legendTitle
protected

Definition at line 214 of file KDChartPainter.h.

◆ _logicalHeight

int KDChartPainter::_logicalHeight
protected

Definition at line 219 of file KDChartPainter.h.

◆ _logicalWidth

int KDChartPainter::_logicalWidth
protected

Definition at line 218 of file KDChartPainter.h.

◆ _numLegendTexts

int KDChartPainter::_numLegendTexts
protected

Definition at line 216 of file KDChartPainter.h.

◆ _outermostRect

TQRect KDChartPainter::_outermostRect
protected

Definition at line 186 of file KDChartPainter.h.

◆ calcVal

internal__KDChart__CalcValues KDChartPainter::calcVal[KDCHART_MAX_AXES]
protected

Definition at line 225 of file KDChartPainter.h.


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