##// END OF EJS Templates
Add 5.7.0 changes file...
Add 5.7.0 changes file Change-Id: I72ac7ecf67786a2fe4491e848863367fdfd54c01 Reviewed-by: Tomi Korpipää <tomi.korpipaa@theqtcompany.com> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>

File last commit:

r2854:46147b040d06
r2881:7bc9c012efbb
Show More
qscatterseries.cpp
367 lines | 10.2 KiB | text/x-c | CppLexer
Miikka Heikkinen
Updated license...
r2854 /****************************************************************************
Jani Honkonen
Add license headers
r794 **
Miikka Heikkinen
Updated license...
r2854 ** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
Jani Honkonen
Add license headers
r794 **
Miikka Heikkinen
Updated license...
r2854 ** This file is part of the Qt Charts module of the Qt Toolkit.
Jani Honkonen
Add license headers
r794 **
Miikka Heikkinen
Updated license...
r2854 ** $QT_BEGIN_LICENSE:GPL$
Titta Heikkala
Updated license headers...
r2845 ** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
Miikka Heikkinen
Updated license...
r2854 ** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
Jani Honkonen
Add license headers
r794 **
Titta Heikkala
Updated license headers...
r2845 ** $QT_END_LICENSE$
**
Miikka Heikkinen
Updated license...
r2854 ****************************************************************************/
Jani Honkonen
Add license headers
r794
Titta Heikkala
Fix include syntax...
r2714 #include <QtCharts/QScatterSeries>
#include <private/qscatterseries_p.h>
#include <private/scatterchartitem_p.h>
#include <private/chartdataset_p.h>
#include <private/charttheme_p.h>
#include <private/scatteranimation_p.h>
#include <private/qchart_p.h>
Tero Ahola
Integrated scatter type series...
r42
Tero Ahola
Scatter series documentation; now uses snippets
r300 /*!
\class QScatterSeries
Titta Heikkala
Fix Charts documentation...
r2639 \inmodule Qt Charts
Michal Klocek
Fixes for docs , adds xyseries docs
r481 \brief The QScatterSeries class is used for making scatter charts.
Tero Ahola
Integrated scatter type series...
r42
Michal Klocek
Fixes for docs , adds xyseries docs
r481 The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis
and the vertical axis.
Tero Ahola
Scatter series documentation; now uses snippets
r300
Tero Ahola
Documentation fixes....
r995 \image examples_scatterchart.png
Tero Ahola
Scatter series documentation; now uses snippets
r300
Michal Klocek
Fixes for docs , adds xyseries docs
r481 Creating basic scatter chart is simple:
\code
QScatterSeries* series = new QScatterSeries();
Jani Honkonen
rename functions add() -> append()
r796 series->append(0, 6);
series->append(2, 4);
Michal Klocek
Fixes for docs , adds xyseries docs
r481 ...
Tero Ahola
Documentation fixes....
r995 chart->addSeries(series);
Michal Klocek
Fixes for docs , adds xyseries docs
r481 \endcode
Tero Ahola
Scatter series documentation; now uses snippets
r300 */
Tero Ahola
Documenting xy-series
r1491 /*!
Titta Heikkala
Fix Charts documentation...
r2639 \qmltype ScatterSeries
\instantiates QScatterSeries
Titta Heikkala
Qt Charts project file structure change...
r2712 \inqmlmodule QtCharts
Tero Ahola
Documenting xy-series
r1491
Titta Heikkala
Qt Charts project file structure change...
r2712 \inherits XYSeries
\brief The ScatterSeries type is used for making scatter charts.
The following QML shows how to create a chart with two simple scatter series:
\snippet qmlchart/qml/qmlchart/View5.qml 1
Tero Ahola
Documenting xy-series
r1491
Titta Heikkala
Qt Charts project file structure change...
r2712 \beginfloatleft
\image examples_qmlchart5.png
\endfloat
\clearfloat
Tero Ahola
Documenting xy-series
r1491 */
Tero Ahola
Integrated scatter type series...
r42
Tero Ahola
Documenting QScatterSeries
r261 /*!
\enum QScatterSeries::MarkerShape
This enum describes the shape used when rendering marker items.
\value MarkerShapeCircle
Michal Klocek
Adds missing scatter intercation implementation...
r541 \value MarkerShapeRectangle
Tero Ahola
Documenting QScatterSeries
r261 */
Titta Heikkala
Add possibility to set brush image via QML API...
r2681 /*!
\property QScatterSeries::brush
Brush used to draw the series.
*/
Jani Honkonen
update scatter docs
r1341 /*!
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481 \property QScatterSeries::color
Fill (brush) color of the series. This is a convenience property for modifying the color of brush.
\sa QScatterSeries::brush()
Jani Honkonen
update scatter docs
r1341 */
Tero Ahola
Added notifiers for scatter properties
r1349 /*!
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481 \property QScatterSeries::borderColor
Line (pen) color of the series. This is a convenience property for modifying the color of pen.
\sa QScatterSeries::pen()
Tero Ahola
Added notifiers for scatter properties
r1349 */
Tero Ahola
Documentation fixes to QML ScatterSeries and AbstractBarSeries
r2115 /*!
\qmlproperty color ScatterSeries::borderColor
Border (pen) color of the series.
*/
Tero Ahola
Added notifiers for scatter properties
r1349
Tero Ahola
Adding missing QML series API line/border properties
r1904 /*!
\qmlproperty real ScatterSeries::borderWidth
The width of the border line. By default the width is 2.0.
*/
Tero Ahola
Added notifiers for scatter properties
r1349 /*!
Tero Ahola
Documenting xy-series
r1491 \property QScatterSeries::markerShape
Defines the shape of the marker used to draw the points in the series. The default shape is MarkerShapeCircle.
Tero Ahola
Added notifiers for scatter properties
r1349 */
Jani Honkonen
update scatter docs
r1341 /*!
Tero Ahola
Documenting xy-series
r1491 \qmlproperty MarkerShape ScatterSeries::markerShape
Defines the shape of the marker used to draw the points in the series. One of ScatterSeries
ScatterSeries.MarkerShapeCircle or ScatterSeries.MarkerShapeRectangle.
The default shape is ScatterSeries.MarkerShapeCircle.
*/
Jani Honkonen
update scatter docs
r1341
Tero Ahola
Documenting xy-series
r1491 /*!
\property QScatterSeries::markerSize
Defines the size of the marker used to draw the points in the series. The default size is 15.0.
*/
/*!
\qmlproperty real ScatterSeries::markerSize
Defines the size of the marker used to draw the points in the series. The default size is 15.0.
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481 */
Titta Heikkala
Add possibility to set brush image via QML API...
r2681 /*!
\qmlproperty QString ScatterSeries::brushFilename
The name of the file used as a brush for the series.
*/
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481 /*!
\fn void QScatterSeries::colorChanged(QColor 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 */
Miikka Heikkinen
Made OpenGL series respond to scatter color and size changes...
r2829 /*!
\qmlsignal ScatterSeries::onColorChanged(color color)
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 QScatterSeries::borderColorChanged(QColor color)
Tero Ahola
Documenting xy-series
r1491 Signal is emitted when the line (pen) color has changed to \a color.
*/
/*!
Miikka Heikkinen
Made OpenGL series respond to scatter color and size changes...
r2829 \qmlsignal ScatterSeries::onBorderColorChanged(color color)
Tero Ahola
Documenting xy-series
r1491 Signal is emitted when the line (pen) color has changed to \a color.
Jani Honkonen
update scatter docs
r1341 */
Tero Ahola
QDoc to use style sheets...
r260 /*!
Miikka Heikkinen
Fix some documentation issues...
r2520 \fn QAbstractSeries::SeriesType QScatterSeries::type() const
Returns QAbstractSeries::SeriesTypeScatter.
Michal Klocek
Fixes to API , QSeriesType -> SeriesType , add missing getters
r1107 \sa QAbstractSeries, SeriesType
Tero Ahola
Scatter series documentation; now uses snippets
r300 */
Tero Ahola
QDoc to use style sheets...
r260
Miikka Heikkinen
Made OpenGL series respond to scatter color and size changes...
r2829 /*!
\fn void QScatterSeries::markerShapeChanged(MarkerShape shape)
Signal is emitted when the marker shape has changed to \a shape.
*/
/*!
\qmlsignal ScatterSeries::onMarkerShapeChanged(MarkerShape shape)
Signal is emitted when the marker shape has changed to \a shape.
*/
/*!
\fn void QScatterSeries::markerSizeChanged(qreal size)
Signal is emitted when the marker size has changed to \a size.
*/
/*!
\qmlsignal ScatterSeries::onMarkerSizeChanged(real size)
Signal is emitted when the marker size has changed to \a size.
*/
Titta Heikkala
Qt Charts project file structure change...
r2712 QT_CHARTS_BEGIN_NAMESPACE
Tero Ahola
Scatter series documentation; now uses snippets
r300
Tero Ahola
Documenting QScatterSeries
r261 /*!
Constructs a series object which is a child of \a parent.
*/
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 QScatterSeries::QScatterSeries(QObject *parent)
: QXYSeries(*new QScatterSeriesPrivate(this), parent)
Tero Ahola
Integrated scatter type series...
r42 {
}
Tero Ahola
QDoc to use style sheets...
r260 /*!
Tero Ahola
Documenting QScatterSeries
r261 Destroys the object. Note that adding series to QChart transfers the ownership to the chart.
Tero Ahola
QDoc to use style sheets...
r260 */
Tero Ahola
Integrated scatter again. Missing functionality....
r158 QScatterSeries::~QScatterSeries()
Tero Ahola
Integrated scatter type series...
r42 {
Michal Klocek
Fix missing unbind call in destrutor in scatter series
r1270 Q_D(QScatterSeries);
Michal Klocek
Refactors internals...
r2273 if (d->m_chart)
d->m_chart->removeSeries(this);
Tero Ahola
Resizing of QGraphicItems now possible by resize signal from QChart
r48 }
Michal Klocek
Fixes to API , QSeriesType -> SeriesType , add missing getters
r1107 QAbstractSeries::SeriesType QScatterSeries::type() const
Michal Klocek
Adds big fat pimpl to series classes...
r938 {
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 return QAbstractSeries::SeriesTypeScatter;
Michal Klocek
Adds big fat pimpl to series classes...
r938 }
Marek Rosa
Scatterseries docs update
r1651 /*!
Sets \a pen used for drawing points' border on the chart. If the pen is not defined, the
pen from chart theme is used.
\sa QChart::setTheme()
*/
Tero Ahola
Color and border color properties of XYSeries
r1537 void QScatterSeries::setPen(const QPen &pen)
{
Q_D(QXYSeries);
if (d->m_pen != pen) {
bool emitColorChanged = d->m_pen.color() != pen.color();
d->m_pen = pen;
emit d->updated();
if (emitColorChanged)
emit borderColorChanged(pen.color());
}
}
Marek Rosa
Scatterseries docs update
r1651 /*!
Sets \a brush used for drawing points on the chart. If the brush is not defined, brush
from chart theme setting is used.
\sa QChart::setTheme()
*/
Tero Ahola
Color and border color properties of XYSeries
r1537 void QScatterSeries::setBrush(const QBrush &brush)
{
Q_D(QScatterSeries);
if (d->m_brush != brush) {
bool emitColorChanged = d->m_brush.color() != brush.color();
d->m_brush = brush;
emit d->updated();
if (emitColorChanged)
emit colorChanged(brush.color());
}
}
Titta Heikkala
Add possibility to set brush image via QML API...
r2681 QBrush QScatterSeries::brush() const
{
Q_D(const QScatterSeries);
if (d->m_brush == QChartPrivate::defaultBrush())
return QBrush();
else
return d->m_brush;
}
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481 void QScatterSeries::setColor(const QColor &color)
{
QBrush b = brush();
Titta Heikkala
Fix scatter series color...
r2670 if (b == QChartPrivate::defaultBrush())
b = QBrush();
Tero Ahola
Fixed a bug in setting scatter/area series brush color
r1933 if (b == QBrush())
b.setStyle(Qt::SolidPattern);
b.setColor(color);
setBrush(b);
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481 }
QColor QScatterSeries::color() const
{
return brush().color();
}
void QScatterSeries::setBorderColor(const QColor &color)
{
QPen p = pen();
Titta Heikkala
Fix scatter series color...
r2670 if (p == QChartPrivate::defaultPen())
p = QPen();
p.setColor(color);
setPen(p);
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481 }
QColor QScatterSeries::borderColor() const
{
return pen().color();
}
Tero Ahola
Scatter customization to QML api
r1276 QScatterSeries::MarkerShape QScatterSeries::markerShape() const
Tero Ahola
Scatter series marker visuals
r195 {
Michal Klocek
Adds big fat pimpl to series classes...
r938 Q_D(const QScatterSeries);
return d->m_shape;
Tero Ahola
Scatter series marker visuals
r195 }
Tero Ahola
Scatter customization to QML api
r1276 void QScatterSeries::setMarkerShape(MarkerShape shape)
Tero Ahola
Scatter series marker visuals
r195 {
Michal Klocek
Adds big fat pimpl to series classes...
r938 Q_D(QScatterSeries);
if (d->m_shape != shape) {
d->m_shape = shape;
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481 emit d->updated();
Miikka Heikkinen
Made OpenGL series respond to scatter color and size changes...
r2829 emit markerShapeChanged(shape);
Michal Klocek
minor. cleanuup in scatter API
r573 }
Tero Ahola
Scatter series marker visuals
r195 }
Tero Ahola
Scatter customization to QML api
r1276 qreal QScatterSeries::markerSize() const
Tero Ahola
Added size customization to QScatterSeries
r397 {
Michal Klocek
Adds big fat pimpl to series classes...
r938 Q_D(const QScatterSeries);
return d->m_size;
Tero Ahola
Added size customization to QScatterSeries
r397 }
Tero Ahola
Scatter customization to QML api
r1276 void QScatterSeries::setMarkerSize(qreal size)
Tero Ahola
Added size customization to QScatterSeries
r397 {
Michal Klocek
Adds big fat pimpl to series classes...
r938 Q_D(QScatterSeries);
Marek Rosa
Replaced qFuzzyIsNull with qFuzzyCompare. Once qchart test case still uses qFuzzyIsNull becasue it started failing when qFuzzyCompare was used
r2242 if (!qFuzzyCompare(d->m_size, size)) {
Michal Klocek
Adds big fat pimpl to series classes...
r938 d->m_size = size;
Tero Ahola
color and borderColor properties to XY charts; removed unnecessary signals
r1481 emit d->updated();
Miikka Heikkinen
Made OpenGL series respond to scatter color and size changes...
r2829 emit markerSizeChanged(size);
Michal Klocek
minor. cleanuup in scatter API
r573 }
Tero Ahola
Added size customization to QScatterSeries
r397 }
Michal Klocek
Adds big fat pimpl to series classes...
r938 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Jani Honkonen
more coding style fixes for src-folder...
r2104 QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries *q)
: QXYSeriesPrivate(q),
m_shape(QScatterSeries::MarkerShapeCircle),
m_size(15.0)
Michal Klocek
Adds big fat pimpl to series classes...
r938 {
Tero Ahola
Color and border color properties of XYSeries
r1537 }
Michal Klocek
Adds big fat pimpl to series classes...
r938
Michal Klocek
Refactors internals...
r2273 void QScatterSeriesPrivate::initializeGraphics(QGraphicsItem* parent)
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 {
Q_Q(QScatterSeries);
Michal Klocek
Refactors internals...
r2273 ScatterChartItem *scatter = new ScatterChartItem(q,parent);
m_item.reset(scatter);
QAbstractSeriesPrivate::initializeGraphics(parent);
}
void QScatterSeriesPrivate::initializeTheme(int index, ChartTheme* theme, bool forced)
{
Q_Q(QScatterSeries);
const QList<QColor> colors = theme->seriesColors();
const QList<QGradient> gradients = theme->seriesGradients();
Miikka Heikkinen
Fix explicitly set default pen/brush/font getting overridden by theme...
r2516 if (forced || QChartPrivate::defaultPen() == m_pen) {
QPen pen;
Michal Klocek
Refactors internals...
r2273 pen.setColor(ChartThemeManager::colorAt(gradients.at(index % gradients.size()), 0.0));
pen.setWidthF(2);
q->setPen(pen);
}
Miikka Heikkinen
Fix explicitly set default pen/brush/font getting overridden by theme...
r2516 if (forced || QChartPrivate::defaultBrush() == m_brush) {
Michal Klocek
Refactors internals...
r2273 QBrush brush(colors.at(index % colors.size()));
q->setBrush(brush);
}
Titta Heikkala
Added possibility to show series value...
r2689
if (forced || QChartPrivate::defaultPen().color() == m_pointLabelsColor) {
QColor color = theme->labelBrush().color();
q->setPointLabelsColor(color);
}
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 }
Titta Heikkala
Added possibility to set duration and easing curve for chart animation...
r2804 void QScatterSeriesPrivate::initializeAnimations(QChart::AnimationOptions options, int duration,
QEasingCurve &curve)
Miikka Heikkinen
Further animation fixes...
r2492 {
ScatterChartItem *item = static_cast<ScatterChartItem *>(m_item.data());
Q_ASSERT(item);
Miikka Heikkinen
Fix resetting animation options mid-animation....
r2555 if (item->animation())
item->animation()->stopAndDestroyLater();
Miikka Heikkinen
Further animation fixes...
r2492 if (options.testFlag(QChart::SeriesAnimations))
Titta Heikkala
Added possibility to set duration and easing curve for chart animation...
r2804 item->setAnimation(new ScatterAnimation(item, duration, curve));
Miikka Heikkinen
Further animation fixes...
r2492 else
item->setAnimation(0);
Titta Heikkala
Added possibility to set duration and easing curve for chart animation...
r2804 QAbstractSeriesPrivate::initializeAnimations(options, duration, curve);
Miikka Heikkinen
Further animation fixes...
r2492 }
Tero Ahola
Scatter customization to QML api
r1276 #include "moc_qscatterseries.cpp"
Michal Klocek
Adds big fat pimpl to series classes...
r938
Titta Heikkala
Qt Charts project file structure change...
r2712 QT_CHARTS_END_NAMESPACE