A chart with one or more diagrams. More...
#include <KDChartChart>
Signals | |
void | propertiesChanged () |
Emitted upon change of a property of the Chart or any of its components. | |
Public Member Functions | |
void | addCoordinatePlane (AbstractCoordinatePlane *plane) |
Adds a coordinate plane to the chart. | |
void | addHeaderFooter (HeaderFooter *headerFooter) |
Adds a header or a footer to the chart. | |
void | addLegend (Legend *legend) |
Add the given legend to the chart. | |
BackgroundAttributes | backgroundAttributes () const |
Chart (QWidget *parent=0) | |
AbstractCoordinatePlane * | coordinatePlane () |
Each chart must have at least one coordinate plane. | |
QLayout * | coordinatePlaneLayout () |
CoordinatePlaneList | coordinatePlanes () |
The list of coordinate planes. | |
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. | |
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. | |
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. | |
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. | |
HeaderFooter * | headerFooter () |
The first header or footer of the chart. | |
HeaderFooterList | headerFooters () |
The list of headers and footers associated with the chart. | |
Legend * | legend () |
The first legend of the chart or 0 if there was none added to the chart. | |
LegendList | legends () |
The list of all legends associated with the chart. | |
void | paint (QPainter *painter, const QRect &target) |
Paints all the contents of the chart. | |
void | reLayoutFloatingLegends () |
void | replaceCoordinatePlane (AbstractCoordinatePlane *plane, AbstractCoordinatePlane *oldPlane=0) |
Replaces the old coordinate plane, or appends the plane, it there is none yet. | |
void | replaceHeaderFooter (HeaderFooter *headerFooter, HeaderFooter *oldHeaderFooter=0) |
Replaces the old header (or footer, resp. | |
void | replaceLegend (Legend *legend, Legend *oldLegend=0) |
Replaces the old legend, or appends the new legend, it there is none yet. | |
void | setBackgroundAttributes (const BackgroundAttributes &a) |
Specify the background attributes to be used, by default there is no background. | |
void | setCoordinatePlaneLayout (QLayout *layout) |
Set the coordinate plane layout that should be used as model for the internal used layout. | |
void | setFrameAttributes (const FrameAttributes &a) |
Specify the frame attributes to be used, by default is it a thin black line. | |
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. | |
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. | |
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. | |
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. | |
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. | |
void | takeCoordinatePlane (AbstractCoordinatePlane *plane) |
Removes the coordinate plane from the chart, without deleting it. | |
void | takeHeaderFooter (HeaderFooter *headerFooter) |
Removes the header (or footer, resp. | |
void | takeLegend (Legend *legend) |
Removes the legend from the chart, without deleting it. | |
~Chart () | |
Protected Member Functions | |
bool | event (QEvent *event) |
reimp | |
void | mouseDoubleClickEvent (QMouseEvent *event) |
reimp | |
void | mouseMoveEvent (QMouseEvent *event) |
reimp | |
void | mousePressEvent (QMouseEvent *event) |
reimp | |
void | mouseReleaseEvent (QMouseEvent *event) |
reimp | |
void | paintEvent (QPaintEvent *event) |
Draws the background and frame, then calls paint(). | |
void | resizeEvent (QResizeEvent *event) |
Adjusts the internal layout when the chart is resized. | |
Properties | |
int | globalLeadingBottom |
int | globalLeadingLeft |
int | globalLeadingRight |
int | globalLeadingTop |
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 69 of file KDChartChart.h.
Chart::Chart | ( | QWidget * | parent = 0 |
) | [explicit] |
Definition at line 878 of file KDChartChart.cpp.
References addCoordinatePlane(), setFrameAttributes(), KDChart::FrameAttributes::setPadding(), and KDChart::FrameAttributes::setPen().
Chart::~Chart | ( | ) |
Definition at line 896 of file KDChartChart.cpp.
void Chart::addCoordinatePlane | ( | AbstractCoordinatePlane * | plane | ) |
Adds a coordinate plane to the chart.
The chart takes ownership.
plane | The coordinate plane to add. |
Definition at line 952 of file KDChartChart.cpp.
References d, propertiesChanged(), and KDChart::AbstractCoordinatePlane::setParent().
Referenced by Chart(), and replaceCoordinatePlane().
void Chart::addHeaderFooter | ( | HeaderFooter * | headerFooter | ) |
Adds a header or a footer to the chart.
The chart takes ownership.
headerFooter | The header (or footer, resp.) to add. |
Definition at line 1173 of file KDChartChart.cpp.
References d, and KDChart::HeaderFooter::setParent().
Referenced by replaceHeaderFooter().
void Chart::addLegend | ( | Legend * | legend | ) |
Add the given legend to the chart.
The chart takes ownership.
legend | The legend to add. |
Definition at line 1231 of file KDChartChart.cpp.
References d, KDChartEnums::MeasureOrientationMinimum, propertiesChanged(), KDChart::TextAttributes::setFontSize(), KDChart::Legend::setReferenceArea(), KDChart::Legend::setTextAttributes(), KDChart::Legend::setTitleTextAttributes(), KDChart::Legend::setVisible(), KDChart::Legend::textAttributes(), and KDChart::Legend::titleTextAttributes().
Referenced by replaceLegend().
BackgroundAttributes Chart::backgroundAttributes | ( | ) | const |
Definition at line 918 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.
Definition at line 936 of file KDChartChart.cpp.
References d.
QLayout * Chart::coordinatePlaneLayout | ( | ) |
Definition at line 931 of file KDChartChart.cpp.
References d.
CoordinatePlaneList Chart::coordinatePlanes | ( | ) |
The list of coordinate planes.
Definition at line 947 of file KDChartChart.cpp.
References d.
bool Chart::event | ( | QEvent * | event | ) | [protected] |
reimp
Definition at line 1598 of file KDChartChart.cpp.
References d, and KDChart::AbstractCoordinatePlane::diagrams().
FrameAttributes Chart::frameAttributes | ( | ) | const |
Definition at line 908 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.
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.
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.
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.
HeaderFooter * Chart::headerFooter | ( | ) |
The first header or footer of the chart.
By default there is none.
Definition at line 1217 of file KDChartChart.cpp.
References d.
HeaderFooterList Chart::headerFooters | ( | ) |
The list of headers and footers associated with the chart.
Definition at line 1226 of file KDChartChart.cpp.
References d.
Legend * Chart::legend | ( | ) |
The first legend of the chart or 0 if there was none added to the chart.
Definition at line 1318 of file KDChartChart.cpp.
References d.
LegendList Chart::legends | ( | ) |
The list of all legends associated with the chart.
Definition at line 1328 of file KDChartChart.cpp.
References d.
void Chart::mouseDoubleClickEvent | ( | QMouseEvent * | event | ) | [protected] |
reimp
Definition at line 1525 of file KDChartChart.cpp.
References d, KDChart::AbstractCoordinatePlane::diagrams(), KDChart::AbstractCoordinatePlane::geometry(), and KDChart::AbstractCoordinatePlane::mouseDoubleClickEvent().
void Chart::mouseMoveEvent | ( | QMouseEvent * | event | ) | [protected] |
reimp
Definition at line 1544 of file KDChartChart.cpp.
References d, KDChart::AbstractCoordinatePlane::diagrams(), KDChart::AbstractCoordinatePlane::geometry(), and KDChart::AbstractCoordinatePlane::mouseMoveEvent().
void Chart::mousePressEvent | ( | QMouseEvent * | event | ) | [protected] |
reimp
Definition at line 1334 of file KDChartChart.cpp.
References d, KDChart::AbstractCoordinatePlane::diagrams(), KDChart::AbstractCoordinatePlane::geometry(), and KDChart::AbstractCoordinatePlane::mousePressEvent().
void Chart::mouseReleaseEvent | ( | QMouseEvent * | event | ) | [protected] |
reimp
Definition at line 1570 of file KDChartChart.cpp.
References d, KDChart::AbstractCoordinatePlane::diagrams(), KDChart::AbstractCoordinatePlane::geometry(), and KDChart::AbstractCoordinatePlane::mouseReleaseEvent().
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.
painter | The painter to be drawn into.
|
Definition at line 1053 of file KDChartChart.cpp.
References d, KDChart::GlobalMeasureScaling::instance(), KDChart::GlobalMeasureScaling::paintDevice(), KDChart::AbstractAreaWidget::paintIntoRect(), 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().
Definition at line 1159 of file KDChartChart.cpp.
References d, and reLayoutFloatingLegends().
void KDChart::Chart::propertiesChanged | ( | ) | [signal] |
Emitted upon change of a property of the Chart or any of its components.
Referenced by addCoordinatePlane(), addLegend(), takeCoordinatePlane(), takeHeaderFooter(), and takeLegend().
void Chart::reLayoutFloatingLegends | ( | ) |
Definition at line 1127 of file KDChartChart.cpp.
References d, KDChart::Legend::floatingPosition(), KDChart::Position::isFloating(), KDChart::Legend::position(), and KDChart::Legend::sizeHint().
Referenced by paintEvent(), and resizeEvent().
void Chart::replaceCoordinatePlane | ( | AbstractCoordinatePlane * | plane, | |
AbstractCoordinatePlane * | oldPlane = 0 | |||
) |
Replaces the old coordinate plane, or appends the plane, it there is none yet.
plane | The coordinate plane to be used instead of the old plane. This parameter must not be zero, or the method will do nothing. | |
oldPlane | The 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. |
Definition at line 965 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.
headerFooter | The header or footer to be used instead of the old one. This parameter must not be zero, or the method will do nothing. | |
oldHeaderFooter | The 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. |
Definition at line 1184 of file KDChartChart.cpp.
References addHeaderFooter(), d, and takeHeaderFooter().
Replaces the old legend, or appends the new legend, it there is none yet.
legend | The legend to be used instead of the old one. This parameter must not be zero, or the method will do nothing. | |
oldLegend | The 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. |
Definition at line 1278 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 1117 of file KDChartChart.cpp.
References d, reLayoutFloatingLegends(), and KDChart::AbstractCoordinatePlane::setGridNeedsRecalculate().
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 );
Definition at line 913 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 924 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 );
Definition at line 903 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.
left | The padding on the left side.
|
Definition at line 1000 of file KDChartChart.cpp.
References d, 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.
leading | The padding value. |
Definition at line 1042 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.
leading | The padding value. |
Definition at line 1009 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.
leading | The padding value. |
Definition at line 1031 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.
leading | The padding value. |
Definition at line 1020 of file KDChartChart.cpp.
References d.
Referenced by setGlobalLeading().
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.
Definition at line 983 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.
Definition at line 1202 of file KDChartChart.cpp.
References d, propertiesChanged(), and KDChart::HeaderFooter::setParent().
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.
Definition at line 1295 of file KDChartChart.cpp.
References d, propertiesChanged(), and KDChart::Legend::setVisible().
Referenced by replaceLegend().
int Chart::globalLeadingBottom [read, write] |
Definition at line 73 of file KDChartChart.h.
int Chart::globalLeadingLeft [read, write] |
Definition at line 74 of file KDChartChart.h.
int Chart::globalLeadingRight [read, write] |
Definition at line 75 of file KDChartChart.h.
int Chart::globalLeadingTop [read, write] |
Definition at line 72 of file KDChartChart.h.