KD Chart 2  [rev.2.5.1]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
Signals | Public Member Functions | Protected Member Functions | Properties | List of all members
KDChart::Chart Class Reference

A chart with one or more diagrams. More...

#include <KDChartChart>

Inheritance diagram for KDChart::Chart:
Inheritance graph
[legend]
Collaboration diagram for KDChart::Chart:
Collaboration graph
[legend]

Signals

void finishedDrawing ()
 
void propertiesChanged ()
 Emitted upon change of a property of the Chart or any of its components. More...
 

Public Member Functions

void addCoordinatePlane (AbstractCoordinatePlane *plane)
 Adds a coordinate plane to the chart. More...
 
void addHeaderFooter (HeaderFooter *headerFooter)
 Adds a header or a footer to the chart. More...
 
void addLegend (Legend *legend)
 Add the given legend to the chart. More...
 
BackgroundAttributes backgroundAttributes () const
 
 Chart (QWidget *parent=0)
 
AbstractCoordinatePlanecoordinatePlane ()
 Each chart must have at least one coordinate plane. More...
 
QLayout * coordinatePlaneLayout ()
 
CoordinatePlaneList coordinatePlanes ()
 The list of coordinate planes. More...
 
FrameAttributes frameAttributes () const
 
int globalLeadingBottom () const
 The padding between the start of the widget and the start of the area that is used for drawing at the bottom. More...
 
int globalLeadingLeft () const
 The padding between the start of the widget and the start of the area that is used for drawing on the left. More...
 
int globalLeadingRight () const
 The padding between the start of the widget and the start of the area that is used for drawing on the right. More...
 
int globalLeadingTop () const
 The padding between the start of the widget and the start of the area that is used for drawing at the top. More...
 
HeaderFooterheaderFooter ()
 The first header or footer of the chart. More...
 
HeaderFooterList headerFooters ()
 The list of headers and footers associated with the chart. More...
 
void insertCoordinatePlane (int index, AbstractCoordinatePlane *plane)
 Inserts a coordinate plane to the chart at index index. More...
 
Legendlegend ()
 The first legend of the chart or 0 if there was none added to the chart. More...
 
LegendList legends ()
 The list of all legends associated with the chart. More...
 
void paint (QPainter *painter, const QRect &target)
 Paints all the contents of the chart. More...
 
void reLayoutFloatingLegends ()
 
void replaceCoordinatePlane (AbstractCoordinatePlane *plane, AbstractCoordinatePlane *oldPlane=0)
 Replaces the old coordinate plane, or appends the plane, it there is none yet. More...
 
void replaceHeaderFooter (HeaderFooter *headerFooter, HeaderFooter *oldHeaderFooter=0)
 Replaces the old header (or footer, resp.), or appends the new header or footer, it there is none yet. More...
 
void replaceLegend (Legend *legend, Legend *oldLegend=0)
 Replaces the old legend, or appends the new legend, it there is none yet. More...
 
void setBackgroundAttributes (const BackgroundAttributes &a)
 Specify the background attributes to be used, by default there is no background. More...
 
void setCoordinatePlaneLayout (QLayout *layout)
 Set the coordinate plane layout that should be used as model for the internal used layout. More...
 
void setFrameAttributes (const FrameAttributes &a)
 Specify the frame attributes to be used, by default is it a thin black line. More...
 
void setGlobalLeading (int left, int top, int right, int bottom)
 Set the padding between the margin of the widget and the area that the contents are drawn into. More...
 
void setGlobalLeadingBottom (int leading)
 Set the padding between the start of the widget and the start of the area that is used for drawing on the bottom. More...
 
void setGlobalLeadingLeft (int leading)
 Set the padding between the start of the widget and the start of the area that is used for drawing on the left. More...
 
void setGlobalLeadingRight (int leading)
 Set the padding between the start of the widget and the start of the area that is used for drawing on the right. More...
 
void setGlobalLeadingTop (int leading)
 Set the padding between the start of the widget and the start of the area that is used for drawing at the top. More...
 
void setUseNewLayoutSystem (bool value)
 
void takeCoordinatePlane (AbstractCoordinatePlane *plane)
 Removes the coordinate plane from the chart, without deleting it. More...
 
void takeHeaderFooter (HeaderFooter *headerFooter)
 Removes the header (or footer, resp.) from the chart, without deleting it. More...
 
void takeLegend (Legend *legend)
 Removes the legend from the chart, without deleting it. More...
 
bool useNewLayoutSystem () const
 useNewLayoutSystem Be very careful activating the new layout system, its still experimental and works only if the user knows what he is doing. More...
 
 ~Chart ()
 

Protected Member Functions

bool event (QEvent *event)
 reimp More...
 
void mouseDoubleClickEvent (QMouseEvent *event)
 reimp More...
 
void mouseMoveEvent (QMouseEvent *event)
 reimp More...
 
void mousePressEvent (QMouseEvent *event)
 reimp More...
 
void mouseReleaseEvent (QMouseEvent *event)
 reimp More...
 
void paintEvent (QPaintEvent *event)
 Draws the background and frame, then calls paint(). More...
 
void resizeEvent (QResizeEvent *event)
 Adjusts the internal layout when the chart is resized. More...
 

Properties

int globalLeadingBottom
 
int globalLeadingLeft
 
int globalLeadingRight
 
int globalLeadingTop
 
bool useNewLayoutSystem
 

Detailed Description

A chart with one or more diagrams.

The Chart class represents a drawing consisting of one or more diagrams and various optional elements such as legends, axes, text boxes, headers or footers. It takes ownership of all these elements when they are assigned to it. Each diagram is associated with a coordinate plane, of which the chart can have more than one. The coordinate planes (and thus the associated diagrams) can be laid out in various ways.

The Chart class makes heavy use of the Qt Interview framework for model/view programming, and thus requires data to be presented to it in a QAbstractItemModel compatible way. For many simple charts, especially if the visualized data is static, KDChart::Widget provides an abstracted interface, that hides the complexity of Interview to a large extent.

Definition at line 98 of file KDChartChart.h.

Constructor & Destructor Documentation

Chart::Chart ( QWidget parent = 0)
explicit
Chart::~Chart ( )

Definition at line 1015 of file KDChartChart.cpp.

References d.

Member Function Documentation

void Chart::addCoordinatePlane ( AbstractCoordinatePlane plane)

Adds a coordinate plane to the chart.

The chart takes ownership.

Parameters
planeThe coordinate plane to add.
See Also
replaceCoordinatePlane, takeCoordinatePlane

Definition at line 1068 of file KDChartChart.cpp.

References d, and insertCoordinatePlane().

Referenced by Chart(), and replaceCoordinatePlane().

void Chart::addHeaderFooter ( HeaderFooter headerFooter)
void Chart::addLegend ( Legend legend)

Add the given legend to the chart.

The chart takes ownership.

Parameters
legendThe legend to add.
See Also
replaceLegend, takeLegend

Definition at line 1390 of file KDChartChart.cpp.

References propertiesChanged().

Referenced by replaceLegend().

BackgroundAttributes Chart::backgroundAttributes ( ) const

Definition at line 1035 of file KDChartChart.cpp.

References d.

AbstractCoordinatePlane * Chart::coordinatePlane ( )

Each chart must have at least one coordinate plane.

Initially a default CartesianCoordinatePlane is created. Use replaceCoordinatePlane() to replace it with a different one, such as a PolarCoordinatePlane.

Returns
The first coordinate plane of the chart.

Definition at line 1053 of file KDChartChart.cpp.

References d.

QLayout * Chart::coordinatePlaneLayout ( )

Definition at line 1048 of file KDChartChart.cpp.

References d.

CoordinatePlaneList Chart::coordinatePlanes ( )

The list of coordinate planes.

Returns
The list of coordinate planes.

Definition at line 1063 of file KDChartChart.cpp.

References d.

bool Chart::event ( QEvent *  event)
protected
void KDChart::Chart::finishedDrawing ( )
signal

Referenced by paintEvent().

FrameAttributes Chart::frameAttributes ( ) const

Definition at line 1025 of file KDChartChart.cpp.

References d.

int KDChart::Chart::globalLeadingBottom ( ) const

The padding between the start of the widget and the start of the area that is used for drawing at the bottom.

Returns
The padding between the start of the widget and the start of the area that is used for drawing at the bottom.
See Also
setGlobalLeading
int KDChart::Chart::globalLeadingLeft ( ) const

The padding between the start of the widget and the start of the area that is used for drawing on the left.

Returns
The padding between the start of the widget and the start of the area that is used for drawing on the left.
See Also
setGlobalLeading
int KDChart::Chart::globalLeadingRight ( ) const

The padding between the start of the widget and the start of the area that is used for drawing on the right.

Returns
The padding between the start of the widget and the start of the area that is used for drawing on the right.
See Also
setGlobalLeading
int KDChart::Chart::globalLeadingTop ( ) const

The padding between the start of the widget and the start of the area that is used for drawing at the top.

Returns
The padding between the start of the widget and the start of the area that is used for drawing at the top.
See Also
setGlobalLeading
HeaderFooter * Chart::headerFooter ( )

The first header or footer of the chart.

By default there is none.

Returns
The first header or footer of the chart or 0 if there was none added to the chart.

Definition at line 1368 of file KDChartChart.cpp.

References d.

HeaderFooterList Chart::headerFooters ( )

The list of headers and footers associated with the chart.

Returns
The list of headers and footers associated with the chart.

Definition at line 1377 of file KDChartChart.cpp.

References d.

void Chart::insertCoordinatePlane ( int  index,
AbstractCoordinatePlane plane 
)

Inserts a coordinate plane to the chart at index index.

    The chart takes ownership.
Parameters
indexThe index where to add the plane
planeThe coordinate plane to add.
See Also
replaceCoordinatePlane, takeCoordinatePlane

Definition at line 1074 of file KDChartChart.cpp.

References d, propertiesChanged(), and KDChart::AbstractCoordinatePlane::setParent().

Referenced by addCoordinatePlane().

Legend * Chart::legend ( )

The first legend of the chart or 0 if there was none added to the chart.

Returns
The first legend of the chart or 0 if none exists.

Definition at line 1525 of file KDChartChart.cpp.

References d.

LegendList Chart::legends ( )

The list of all legends associated with the chart.

Returns
The list of all legends associated with the chart.

Definition at line 1530 of file KDChartChart.cpp.

References d.

void Chart::mouseDoubleClickEvent ( QMouseEvent *  event)
protected
void Chart::mouseMoveEvent ( QMouseEvent *  event)
protected
void Chart::mousePressEvent ( QMouseEvent *  event)
protected
void Chart::mouseReleaseEvent ( QMouseEvent *  event)
protected
void Chart::paint ( QPainter *  painter,
const QRect &  target 
)

Paints all the contents of the chart.

Use this method to make KDChart draw into your QPainter.

Note
Any global leading settings will be used by the paint method too, so make sure to set them to zero, if you want the drawing to have the exact size of the target rectangle.
Parameters
painterThe painter to be drawn into.
targetThe rectangle to be filled by the Chart's drawing.
See Also
setGlobalLeading

Definition at line 1182 of file KDChartChart.cpp.

References d, KDChart::GlobalMeasureScaling::instance(), KDChart::GlobalMeasureScaling::paintDevice(), KDChart::GlobalMeasureScaling::resetFactors(), KDChart::PrintingParameters::resetScaleFactor(), KDChart::GlobalMeasureScaling::setFactors(), KDChart::GlobalMeasureScaling::setPaintDevice(), and KDChart::PrintingParameters::setScaleFactor().

void Chart::paintEvent ( QPaintEvent *  event)
protected

Draws the background and frame, then calls paint().

In most cases there is no need to override this method in a derived class, but if you do, do not forget to call paint().

See Also
paint

Definition at line 1281 of file KDChartChart.cpp.

References d, and finishedDrawing().

void KDChart::Chart::propertiesChanged ( )
signal

Emitted upon change of a property of the Chart or any of its components.

Referenced by addLegend(), insertCoordinatePlane(), takeCoordinatePlane(), and takeLegend().

void Chart::reLayoutFloatingLegends ( )
void Chart::replaceCoordinatePlane ( AbstractCoordinatePlane plane,
AbstractCoordinatePlane oldPlane = 0 
)

Replaces the old coordinate plane, or appends the plane, it there is none yet.

Parameters
planeThe coordinate plane to be used instead of the old plane. This parameter must not be zero, or the method will do nothing.
oldPlaneThe coordinate plane to be removed by the new plane. This plane will be deleted automatically. If the parameter is omitted, the very first coordinate plane will be replaced. In case, there was no plane yet, the new plane will just be added.
Note
If you want to re-use the old coordinate plane, call takeCoordinatePlane and addCoordinatePlane, instead of using replaceCoordinatePlane.
See Also
addCoordinatePlane, takeCoordinatePlane

Definition at line 1091 of file KDChartChart.cpp.

References addCoordinatePlane(), d, and takeCoordinatePlane().

void Chart::replaceHeaderFooter ( HeaderFooter headerFooter,
HeaderFooter oldHeaderFooter = 0 
)

Replaces the old header (or footer, resp.), or appends the new header or footer, it there is none yet.

Parameters
headerFooterThe header or footer to be used instead of the old one. This parameter must not be zero, or the method will do nothing.
oldHeaderFooterThe header or footer to be removed by the new one. This header or footer will be deleted automatically. If the parameter is omitted, the very first header or footer will be replaced. In case, there was no header and no footer yet, the new header or footer will just be added.
Note
If you want to re-use the old header or footer, call takeHeaderFooter and addHeaderFooter, instead of using replaceHeaderFooter.
See Also
addHeaderFooter, takeHeaderFooter

Definition at line 1327 of file KDChartChart.cpp.

References addHeaderFooter(), d, and takeHeaderFooter().

void Chart::replaceLegend ( Legend legend,
Legend oldLegend = 0 
)

Replaces the old legend, or appends the new legend, it there is none yet.

Parameters
legendThe legend to be used instead of the old one. This parameter must not be zero, or the method will do nothing.
oldLegendThe legend to be removed by the new one. This legend will be deleted automatically. If the parameter is omitted, the very first legend will be replaced. In case, there was no legend yet, the new legend will just be added.

If you want to re-use the old legend, call takeLegend and addLegend, instead of using replaceLegend.

Note
Whenever addLegend is called the font sizes used by the Legend are set to relative and they get coupled to the Chart's size, with their relative values being 20 for the item texts and 24 to the title text. So if you want to use custom font sizes for the Legend make sure to set them after calling addLegend.
See Also
addLegend, takeLegend

Definition at line 1491 of file KDChartChart.cpp.

References addLegend(), d, and takeLegend().

void Chart::resizeEvent ( QResizeEvent *  event)
protected

Adjusts the internal layout when the chart is resized.

Definition at line 1242 of file KDChartChart.cpp.

References d.

void Chart::setBackgroundAttributes ( const BackgroundAttributes a)

Specify the background attributes to be used, by default there is no background.

To set a light blue background, you could do something like this:

KDChart::BackgroundAttributes backgroundAttrs( my_chart->backgroundAttributes() );
backgroundAttrs.setVisible( true );
backgroundAttrs.setBrush( QColor(0xd0,0xd0,0xff) );
my_chart->setBackgroundAttributes( backgroundAttrs );
See Also
setFrameAttributes

Definition at line 1030 of file KDChartChart.cpp.

References d.

void Chart::setCoordinatePlaneLayout ( QLayout *  layout)

Set the coordinate plane layout that should be used as model for the internal used layout.

The layout needs to be an instance of QHBoxLayout or QVBoxLayout.

Definition at line 1041 of file KDChartChart.cpp.

References d.

void Chart::setFrameAttributes ( const FrameAttributes a)

Specify the frame attributes to be used, by default is it a thin black line.

To hide the frame line, you could do something like this:

KDChart::FrameAttributes frameAttrs( my_chart->frameAttributes() );
frameAttrs.setVisible( false );
my_chart->setFrameAttributes( frameAttrs );
See Also
setBackgroundAttributes

Definition at line 1020 of file KDChartChart.cpp.

References d.

Referenced by Chart().

void Chart::setGlobalLeading ( int  left,
int  top,
int  right,
int  bottom 
)

Set the padding between the margin of the widget and the area that the contents are drawn into.

Parameters
leftThe padding on the left side.
topThe padding at the top.
rightThe padding on the left hand side.
bottomThe padding on the bottom.
Note
Using previous versions of KD Chart you might have called setGlobalLeading() to make room for long Abscissa labels (or for an overlapping top label of an Ordinate axis, resp.) that would not fit into the normal axis area. This is no longer needed because KD Chart now is using hidden auto-spacer items reserving as much free space as is needed for axes with overlaping content at the respective sides.
See Also
setGlobalLeadingTop, setGlobalLeadingBottom, setGlobalLeadingLeft, setGlobalLeadingRight
globalLeadingTop, globalLeadingBottom, globalLeadingLeft, globalLeadingRight

Definition at line 1126 of file KDChartChart.cpp.

References setGlobalLeadingBottom(), setGlobalLeadingLeft(), setGlobalLeadingRight(), and setGlobalLeadingTop().

void Chart::setGlobalLeadingBottom ( int  leading)

Set the padding between the start of the widget and the start of the area that is used for drawing on the bottom.

Parameters
leadingThe padding value.
See Also
setGlobalLeading

Definition at line 1170 of file KDChartChart.cpp.

References d.

Referenced by setGlobalLeading().

void Chart::setGlobalLeadingLeft ( int  leading)

Set the padding between the start of the widget and the start of the area that is used for drawing on the left.

Parameters
leadingThe padding value.
See Also
setGlobalLeading

Definition at line 1134 of file KDChartChart.cpp.

References d.

Referenced by setGlobalLeading().

void Chart::setGlobalLeadingRight ( int  leading)

Set the padding between the start of the widget and the start of the area that is used for drawing on the right.

Parameters
leadingThe padding value.
See Also
setGlobalLeading

Definition at line 1158 of file KDChartChart.cpp.

References d.

Referenced by setGlobalLeading().

void Chart::setGlobalLeadingTop ( int  leading)

Set the padding between the start of the widget and the start of the area that is used for drawing at the top.

Parameters
leadingThe padding value.
See Also
setGlobalLeading

Definition at line 1146 of file KDChartChart.cpp.

References d.

Referenced by setGlobalLeading().

void Chart::setUseNewLayoutSystem ( bool  value)

Definition at line 1626 of file KDChartChart.cpp.

References useNewLayoutSystem().

void Chart::takeCoordinatePlane ( AbstractCoordinatePlane plane)

Removes the coordinate plane from the chart, without deleting it.

The chart no longer owns the plane, so it is the caller's responsibility to delete the plane.

See Also
addCoordinatePlane, takeCoordinatePlane

Definition at line 1109 of file KDChartChart.cpp.

References d, propertiesChanged(), KDChart::AbstractLayoutItem::removeFromParentLayout(), and KDChart::AbstractCoordinatePlane::setParent().

Referenced by replaceCoordinatePlane().

void Chart::takeHeaderFooter ( HeaderFooter headerFooter)

Removes the header (or footer, resp.) from the chart, without deleting it.

The chart no longer owns the header or footer, so it is the caller's responsibility to delete the header or footer.

See Also
addHeaderFooter, replaceHeaderFooter

Definition at line 1345 of file KDChartChart.cpp.

References d, KDChart::AbstractLayoutItem::removeFromParentLayout(), and KDChart::AbstractLayoutItem::setParentLayout().

Referenced by replaceHeaderFooter().

void Chart::takeLegend ( Legend legend)

Removes the legend from the chart, without deleting it.

The chart no longer owns the legend, so it is the caller's responsibility to delete the legend.

See Also
addLegend, takeLegend

Definition at line 1508 of file KDChartChart.cpp.

References d, and propertiesChanged().

Referenced by replaceLegend().

bool KDChart::Chart::useNewLayoutSystem ( ) const

useNewLayoutSystem Be very careful activating the new layout system, its still experimental and works only if the user knows what he is doing.

The reason is that the system does not prevent the user from creating sharing graphs that are not layoutable in a plane and still needs assistance from the user.

Referenced by setUseNewLayoutSystem().

Property Documentation

int Chart::globalLeadingBottom
readwrite

Definition at line 103 of file KDChartChart.h.

int Chart::globalLeadingLeft
readwrite

Definition at line 104 of file KDChartChart.h.

int Chart::globalLeadingRight
readwrite

Definition at line 105 of file KDChartChart.h.

int Chart::globalLeadingTop
readwrite

Definition at line 102 of file KDChartChart.h.

bool Chart::useNewLayoutSystem
readwrite

Definition at line 106 of file KDChartChart.h.


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

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
http://www.kdab.com/products/kd-chart/