qlineseries.cpp
116 lines
| 3.1 KiB
| text/x-c
|
CppLexer
Jani Honkonen
|
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
|
r349 | #include "qlineseries.h" | ||
Michal Klocek
|
r938 | #include "qlineseries_p.h" | ||
Michal Klocek
|
r943 | #include "linechartitem_p.h" | ||
#include "chartdataset_p.h" | ||||
#include "charttheme_p.h" | ||||
#include "chartanimator_p.h" | ||||
Michal Klocek
|
r21 | |||
Tero Ahola
|
r30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||
Michal Klocek
|
r21 | |||
Michal Klocek
|
r331 | /*! | ||
Michal Klocek
|
r350 | \class QLineSeries | ||
\brief The QLineSeries class is used for making line charts. | ||||
Michal Klocek
|
r331 | |||
\mainclass | ||||
A line chart is used to show information as a series of data points | ||||
connected by straight lines. | ||||
\image linechart.png | ||||
Michal Klocek
|
r369 | Creating basic line chart is simple: | ||
\code | ||||
QLineSeries* series = new QLineSeries(); | ||||
Jani Honkonen
|
r796 | series->append(0, 6); | ||
series->append(2, 4); | ||||
Michal Klocek
|
r369 | ... | ||
chartView->addSeries(series); | ||||
\endcode | ||||
Michal Klocek
|
r331 | */ | ||
/*! | ||||
Michal Klocek
|
r360 | \fn virtual QSeriesType QLineSeries::type() const | ||
Michal Klocek
|
r331 | \brief Returns type of series. | ||
Michal Klocek
|
r360 | \sa QSeries, QSeriesType | ||
Michal Klocek
|
r331 | */ | ||
Michal Klocek
|
r374 | /*! | ||
Michal Klocek
|
r470 | Constructs empty series object which is a child of \a parent. | ||
Michal Klocek
|
r974 | When series object is added to QChartView or QChart instance ownerships is transferred. | ||
Michal Klocek
|
r331 | */ | ||
Michal Klocek
|
r938 | QLineSeries::QLineSeries(QObject *parent) : QXYSeries(*new QLineSeriesPrivate(this),parent) | ||
{ | ||||
} | ||||
Tero Ahola
|
r973 | /*! | ||
\internal | ||||
*/ | ||||
Michal Klocek
|
r938 | QLineSeries::QLineSeries(QLineSeriesPrivate &d,QObject *parent) : QXYSeries (d,parent) | ||
Michal Klocek
|
r470 | { | ||
Michal Klocek
|
r331 | |||
Michal Klocek
|
r470 | } | ||
Michal Klocek
|
r392 | /*! | ||
Michal Klocek
|
r470 | Destroys the object. Series added to QChartView or QChart instances are owned by those, | ||
and are deleted when mentioned object are destroyed. | ||||
Michal Klocek
|
r392 | */ | ||
Michal Klocek
|
r470 | QLineSeries::~QLineSeries() | ||
{ | ||||
} | ||||
Michal Klocek
|
r392 | |||
Michal Klocek
|
r938 | QSeries::QSeriesType QLineSeries::type() const | ||
Michal Klocek
|
r21 | { | ||
Michal Klocek
|
r938 | return QSeries::SeriesTypeLine; | ||
Michal Klocek
|
r21 | } | ||
Michal Klocek
|
r938 | /* | ||
Michal Klocek
|
r349 | QDebug operator<< (QDebug debug, const QLineSeries series) | ||
Michal Klocek
|
r21 | { | ||
Michal Klocek
|
r938 | Q_ASSERT(series.d_func()->m_x.size() == series.d_func()->m_y.size()); | ||
int size = series.d_func()->m_x.size(); | ||||
sauimone
|
r743 | for (int i=0; i<size; i++) { | ||
Michal Klocek
|
r938 | debug.nospace() << "(" << series.d_func()->m_x.at(i) << ','<< series.d_func()->m_y.at(i) << ") "; | ||
Michal Klocek
|
r21 | } | ||
return debug.space(); | ||||
} | ||||
Michal Klocek
|
r938 | */ | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
QLineSeriesPrivate::QLineSeriesPrivate(QLineSeries* q):QXYSeriesPrivate(q) | ||||
{ | ||||
}; | ||||
Michal Klocek
|
r21 | |||
Michal Klocek
|
r943 | Chart* QLineSeriesPrivate::createGraphics(ChartPresenter* presenter) | ||
{ | ||||
Q_Q(QLineSeries); | ||||
LineChartItem* line = new LineChartItem(q,presenter); | ||||
if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { | ||||
presenter->animator()->addAnimation(line); | ||||
} | ||||
presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); | ||||
return line; | ||||
} | ||||
Tero Ahola
|
r30 | QTCOMMERCIALCHART_END_NAMESPACE | ||