##// END OF EJS Templates
removed some of the todo comments
removed some of the todo comments

File last commit:

r1818:2fbaf0e7842a
r1896:232ea264e05e
Show More
qareaseries.cpp
396 lines | 10.5 KiB | text/x-c | CppLexer
Jani Honkonen
Add license headers
r794 /****************************************************************************
**
** Copyright (C) 2012 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the Qt Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE$
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
** $QT_END_LICENSE$
**
****************************************************************************/
Michal Klocek
Adds area chart...
r421 #include "qareaseries.h"
Michal Klocek
Adds big fat pimpl to series classes...
r938 #include "qareaseries_p.h"
Michal Klocek
Adds area chart...
r421 #include "qlineseries.h"
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 #include "areachartitem_p.h"
Michal Klocek
Adds qlegend pimpl...
r950 #include "legendmarker_p.h"
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 #include "domain_p.h"
#include "chartdataset_p.h"
#include "charttheme_p.h"
Marek Rosa
renamed QValueAxis related files
r1805 #include "qvalueaxis.h"
Michal Klocek
Adds area chart...
r421
QTCOMMERCIALCHART_BEGIN_NAMESPACE
/*!
\class QAreaSeries
\brief The QAreaSeries class is used for making area charts.
\mainclass
An area chart is used to show quantitative data. It is based on line chart, in the way that area between axis and the line
is emphasized with color. Since the area chart is based on line chart, QAreaSeries constructor needs QLineSeries instance,
Michal Klocek
typos in docs
r424 which defines "upper" boundary of the area. "Lower" boundary is defined by default by axis X. Instead of axis X "lower" boundary can be specified by other line.
Marek Rosa
Few docs fixes to area series
r1515 In that case QAreaSeries should be initiated with two QLineSeries instances. Please note terms "upper" and "lower" boundary can be misleading in cases
Michal Klocek
typos in docs
r424 where "lower" boundary had bigger values than the "upper" one, however the main point that area between these two boundary lines will be filled.
Michal Klocek
Adds area chart...
r421
Tero Ahola
Documentation fixes....
r995 See the \l {AreaChart Example} {area chart example} to learn how to create a simple area chart.
\image examples_areachart.png
Michal Klocek
Adds area chart...
r421 */
Tero Ahola
Documenting xy-series
r1491 /*!
\qmlclass AreaSeries QAreaSeries
The following QML shows how to create a simple area chart:
\snippet ../demos/qmlchart/qml/qmlchart/View4.qml 1
\beginfloatleft
\image demos_qmlchart4.png
\endfloat
\clearfloat
*/
Michal Klocek
Adds area chart...
r421
/*!
Tero Ahola
Minor modifications to properties of abstract, area and bar series
r1462 \property QAreaSeries::upperSeries
\brief The upper one of the two line series used to define area series boundaries.
Michal Klocek
Adds area chart...
r421 */
Tero Ahola
Documenting xy-series
r1491 /*!
\qmlproperty LineSeries AreaSeries::upperSeries
The upper one of the two line series used to define area series boundaries.
*/
Michal Klocek
Adds area chart...
r421
/*!
Tero Ahola
Minor modifications to properties of abstract, area and bar series
r1462 \property QAreaSeries::lowerSeries
The lower one of the two line series used to define are series boundaries. Note if
QAreaSeries was counstucted wihtout a\ lowerSeries this is null.
Michal Klocek
Adds area chart...
r421 */
Tero Ahola
Documenting xy-series
r1491 /*!
\qmlproperty LineSeries AreaSeries::lowerSeries
The lower one of the two line series used to define are series boundaries. Note if
AreaSeries was counstucted wihtout a\ lowerSeries this is null.
*/
Michal Klocek
Adds area chart...
r421
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481 /*!
\property QAreaSeries::color
Fill (brush) color of the series. This is a convenience property for modifying the color of brush.
\sa QAreaSeries::brush()
*/
Tero Ahola
Documenting xy-series
r1491 /*!
\qmlproperty color AreaSeries::color
Fill (brush) color of the series.
*/
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481
/*!
\property QAreaSeries::borderColor
Line (pen) color of the series. This is a convenience property for modifying the color of pen.
\sa QAreaSeries::pen()
*/
Tero Ahola
Documenting xy-series
r1491 /*!
\qmlproperty color AreaSeries::borderColor
Line (pen) color of the series.
*/
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481
Michal Klocek
Adds area chart...
r421 /*!
\fn QPen QAreaSeries::pen() const
\brief Returns the pen used to draw line for this series.
\sa setPen()
*/
/*!
\fn QPen QAreaSeries::brush() const
\brief Returns the brush used to draw line for this series.
\sa setBrush()
*/
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481 /*!
\fn void QAreaSeries::colorChanged(QColor color)
\brief Signal is emitted when the fill (brush) color has changed to \a color.
*/
Tero Ahola
Documenting xy-series
r1491 /*!
Tero Ahola
QML signals documentation
r1531 \qmlsignal AreaSeries::onColorChanged(color color)
Tero Ahola
Documenting xy-series
r1491 Signal is emitted when the fill (brush) color has changed to \a color.
*/
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481
/*!
\fn void QAreaSeries::borderColorChanged(QColor color)
\brief Signal is emitted when the line (pen) color has changed to \a color.
*/
Michal Klocek
Adds area chart...
r421 /*!
Tero Ahola
QML signals documentation
r1531 \qmlsignal AreaSeries::onBorderColorChanged(color color)
Tero Ahola
Documenting xy-series
r1491 Signal is emitted when the line (pen) color has changed to \a color.
Michal Klocek
Adds area chart...
r421 */
Michal Klocek
Updates presenter example documentation
r574 /*!
\fn void QAreaSeries::clicked(const QPointF& point)
\brief Signal is emitted when user clicks the \a point on area chart.
*/
Tero Ahola
Documenting xy-series
r1491 /*!
Tero Ahola
QML signals documentation
r1531 \qmlsignal AreaSeries::onClicked(QPointF point)
Tero Ahola
Documenting xy-series
r1491 Signal is emitted when user clicks the \a point on area chart.
*/
Michal Klocek
Updates presenter example documentation
r574
Tero Ahola
Updated documentation, warnings from legend and area left
r973 /*!
\fn void QAreaSeries::selected()
The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be
implemented by the user of QAreaSeries API.
*/
Tero Ahola
Documenting xy-series
r1491 /*!
Tero Ahola
QML signals documentation
r1531 \qmlsignal AreaSeries::onSelected()
Tero Ahola
Documenting xy-series
r1491 The signal is emitted if the user selects/deselects the XY series. The logic for maintaining selections should be
implemented by the user of AreaSeries API.
*/
Tero Ahola
Updated documentation, warnings from legend and area left
r973
Michal Klocek
Adds area chart...
r421 /*!
Marek Rosa
gdpbarchart moved to test. Few small doc fixes
r940 \fn void QAreaSeriesPrivate::updated()
Michal Klocek
Adds area chart...
r421 \brief \internal
*/
/*!
Constructs area series object which is a child of \a upperSeries. Area will be spanned between \a
upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead.
Michal Klocek
Krazy reported errors...
r974 When series object is added to QChartView or QChart instance ownerships is transferred.
Michal Klocek
Adds area chart...
r421 */
Tero Ahola
Internal review: fixed minor issues in Area and XySeries
r761 QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries)
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 : QAbstractSeries(*new QAreaSeriesPrivate(upperSeries,lowerSeries,this),upperSeries)
Michal Klocek
Adds area chart...
r421 {
}
Tero Ahola
Internal review: fixed minor issues in Area and XySeries
r761
Tero Ahola
Separated series model stuff from data api in QML examples
r1202 /*!
Jani Honkonen
random doc updates
r1351 Constructs area series object without upper or lower series with \a parent object.
Tero Ahola
Separated series model stuff from data api in QML examples
r1202 */
QAreaSeries::QAreaSeries(QObject *parent)
: QAbstractSeries(*new QAreaSeriesPrivate(0, 0, this), parent)
{
}
Michal Klocek
Adds area chart...
r421 /*!
Marek Rosa
Few docs fixes to area series
r1515 Destroys the object.
Michal Klocek
Adds area chart...
r421 */
QAreaSeries::~QAreaSeries()
{
Michal Klocek
Fixes wrong bar destruction by adding destructor for bar*series , note this breaks ABI
r1727 Q_D(QAreaSeries);
if(d->m_dataset){
d->m_dataset->removeSeries(this);
}
Michal Klocek
Adds area chart...
r421 }
Jani Honkonen
Fix series type() docs
r1345 /*!
Returns QChartSeries::SeriesTypeArea.
*/
Michal Klocek
Fixes to API , QSeriesType -> SeriesType , add missing getters
r1107 QAbstractSeries::SeriesType QAreaSeries::type() const
Michal Klocek
Adds big fat pimpl to series classes...
r938 {
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 return QAbstractSeries::SeriesTypeArea;
Michal Klocek
Adds big fat pimpl to series classes...
r938 }
Marek Rosa
Added documentation for BarModelMapper example
r1369 /*!
Sets the \a series that is to be used as the area chart upper series.
*/
Tero Ahola
Separated series model stuff from data api in QML examples
r1202 void QAreaSeries::setUpperSeries(QLineSeries* series)
{
Q_D(QAreaSeries);
d->m_upperSeries = series;
}
Michal Klocek
Adds big fat pimpl to series classes...
r938 QLineSeries* QAreaSeries::upperSeries() const
{
Q_D(const QAreaSeries);
return d->m_upperSeries;
}
Marek Rosa
Added documentation for BarModelMapper example
r1369 /*!
Sets the \a series that is to be used as the area chart lower series.
*/
Tero Ahola
Separated series model stuff from data api in QML examples
r1202 void QAreaSeries::setLowerSeries(QLineSeries* series)
{
Q_D(QAreaSeries);
d->m_lowerSeries = series;
}
Michal Klocek
Adds big fat pimpl to series classes...
r938 QLineSeries* QAreaSeries::lowerSeries() const
{
Q_D(const QAreaSeries);
return d->m_lowerSeries;
}
Michal Klocek
Adds area chart...
r421 /*!
Sets \a pen used for drawing area outline.
*/
Tero Ahola
Internal review: fixed minor issues in Area and XySeries
r761 void QAreaSeries::setPen(const QPen &pen)
Michal Klocek
Adds area chart...
r421 {
Michal Klocek
Adds big fat pimpl to series classes...
r938 Q_D(QAreaSeries);
if (d->m_pen != pen) {
d->m_pen = pen;
emit d->updated();
Michal Klocek
Refactors click signal to line,area,spline,scatter charts
r571 }
Michal Klocek
Adds area chart...
r421 }
Michal Klocek
Adds big fat pimpl to series classes...
r938 QPen QAreaSeries::pen() const
{
Q_D(const QAreaSeries);
return d->m_pen;
}
Michal Klocek
Adds area chart...
r421 /*!
Sets \a brush used for filling the area.
*/
sauimone
minor code review issues. indent, spaces, brackets etc.
r743 void QAreaSeries::setBrush(const QBrush &brush)
Michal Klocek
Adds area chart...
r421 {
Michal Klocek
Adds big fat pimpl to series classes...
r938 Q_D(QAreaSeries);
if (d->m_brush != brush) {
d->m_brush = brush;
emit d->updated();
Michal Klocek
Refactors click signal to line,area,spline,scatter charts
r571 }
Michal Klocek
Adds area chart...
r421 }
Michal Klocek
Adds big fat pimpl to series classes...
r938
QBrush QAreaSeries::brush() const
{
Q_D(const QAreaSeries);
return d->m_brush;
}
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481
void QAreaSeries::setColor(const QColor &color)
{
QBrush b = brush();
if (b.color() != color) {
b.setColor(color);
setBrush(b);
emit colorChanged(color);
}
}
QColor QAreaSeries::color() const
{
return brush().color();
}
void QAreaSeries::setBorderColor(const QColor &color)
{
QPen p = pen();
if (p.color() != color) {
p.setColor(color);
setPen(p);
emit borderColorChanged(color);
}
}
QColor QAreaSeries::borderColor() const
{
return pen().color();
}
Michal Klocek
Adds area chart...
r421 /*!
Sets if data points are \a visible and should be drawn on line.
*/
void QAreaSeries::setPointsVisible(bool visible)
{
Michal Klocek
Adds big fat pimpl to series classes...
r938 Q_D(QAreaSeries);
if (d->m_pointsVisible != visible) {
d->m_pointsVisible = visible;
emit d->updated();
Michal Klocek
Refactors click signal to line,area,spline,scatter charts
r571 }
Michal Klocek
Adds area chart...
r421 }
Tero Ahola
Documenting xy-series
r1491 /*!
Returns if the points are drawn for this series.
\sa setPointsVisible()
*/
Michal Klocek
Adds big fat pimpl to series classes...
r938 bool QAreaSeries::pointsVisible() const
{
Q_D(const QAreaSeries);
return d->m_pointsVisible;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Tero Ahola
Updated documentation, warnings from legend and area left
r973 QAreaSeriesPrivate::QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q) :
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 QAbstractSeriesPrivate(q),
Tero Ahola
Updated documentation, warnings from legend and area left
r973 m_upperSeries(upperSeries),
m_lowerSeries(lowerSeries),
m_pointsVisible(false)
Michal Klocek
Adds big fat pimpl to series classes...
r938 {
Tero Ahola
Updated documentation, warnings from legend and area left
r973 }
Michal Klocek
Adds big fat pimpl to series classes...
r938
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 void QAreaSeriesPrivate::scaleDomain(Domain& domain)
{
Q_Q(QAreaSeries);
qreal minX(domain.minX());
qreal minY(domain.minY());
qreal maxX(domain.maxX());
qreal maxY(domain.maxY());
QLineSeries* upperSeries = q->upperSeries();
QLineSeries* lowerSeries = q->lowerSeries();
Michal Klocek
Fixes and improvments to series API...
r1057 const QList<QPointF>& points = upperSeries->points();
for (int i = 0; i < points.count(); i++)
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 {
Michal Klocek
Fixes and improvments to series API...
r1057 qreal x = points[i].x();
qreal y = points[i].y();
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 minX = qMin(minX, x);
minY = qMin(minY, y);
maxX = qMax(maxX, x);
maxY = qMax(maxY, y);
}
if(lowerSeries) {
Michal Klocek
Fixes and improvments to series API...
r1057
Michal Klocek
Fix xy series model issues due to API changes
r1059 const QList<QPointF>& points = lowerSeries->points();
Michal Klocek
Fixes and improvments to series API...
r1057
for (int i = 0; i < points.count(); i++)
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 {
Michal Klocek
Fixes and improvments to series API...
r1057 qreal x = points[i].x();
qreal y = points[i].y();
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 minX = qMin(minX, x);
minY = qMin(minY, y);
maxX = qMax(maxX, x);
maxY = qMax(maxY, y);
}}
Michal Klocek
Refactors Domain and Axis...
r1698 domain.setRange(minX,maxX,minY,maxY);
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 }
Michal Klocek
Refactors Chart to ChartElement
r1736 ChartElement* QAreaSeriesPrivate::createGraphics(ChartPresenter* presenter)
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 {
Q_Q(QAreaSeries);
AreaChartItem* area = new AreaChartItem(q,presenter);
if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
Michal Klocek
Refactors animation handling for xyseries
r1217 area->upperLineItem()->setAnimation(new XYAnimation(area->upperLineItem()));
if(q->lowerSeries()) {
area->lowerLineItem()->setAnimation(new XYAnimation(area->lowerLineItem()));
}
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 }
presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
return area;
}
Michal Klocek
Adds qlegend pimpl...
r950 QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend)
{
Q_Q(QAreaSeries);
QList<LegendMarker*> list;
return list << new AreaLegendMarker(q,legend);
}
sauimone
added createAxis methods to private series
r1545
Michal Klocek
Adds axis domain intialization
r1695 void QAreaSeriesPrivate::initializeAxis(QAbstractAxis* axis)
sauimone
added createAxis methods to private series
r1545 {
Michal Klocek
Adds createDefaultAxes logic
r1588 Q_UNUSED(axis);
sauimone
added createAxis methods to private series
r1545 }
Michal Klocek
Adds axis domain intialization
r1695 QAbstractAxis::AxisType QAreaSeriesPrivate::defaultAxisType(Qt::Orientation orientation) const
Michal Klocek
Adds createDefaultAxes logic
r1588 {
Michal Klocek
Adds axis domain intialization
r1695 Q_UNUSED(orientation);
Marek Rosa
updated AxisType names
r1818 return QAbstractAxis::AxisTypeValue;
sauimone
added createAxis methods to private series
r1545 }
Michal Klocek
Adds area chart...
r421 #include "moc_qareaseries.cpp"
Michal Klocek
Adds big fat pimpl to series classes...
r938 #include "moc_qareaseries_p.cpp"
Michal Klocek
Adds area chart...
r421
QTCOMMERCIALCHART_END_NAMESPACE