@@ -1,156 +1,168 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qscatterseries.h" |
|
22 | 22 | #include "qscatterseries_p.h" |
|
23 | 23 | #include "scatterchartitem_p.h" |
|
24 | 24 | #include "chartdataset_p.h" |
|
25 | 25 | #include "charttheme_p.h" |
|
26 | 26 | #include "chartanimator_p.h" |
|
27 | 27 | |
|
28 | 28 | /*! |
|
29 | 29 | \class QScatterSeries |
|
30 | 30 | \brief The QScatterSeries class is used for making scatter charts. |
|
31 | 31 | |
|
32 | 32 | \mainclass |
|
33 | 33 | |
|
34 | 34 | The scatter data is displayed as a collection of points on the chart. Each point determines the position on the horizontal axis |
|
35 | 35 | and the vertical axis. |
|
36 | 36 | |
|
37 | 37 | \image examples_scatterchart.png |
|
38 | 38 | |
|
39 | 39 | Creating basic scatter chart is simple: |
|
40 | 40 | \code |
|
41 | 41 | QScatterSeries* series = new QScatterSeries(); |
|
42 | 42 | series->append(0, 6); |
|
43 | 43 | series->append(2, 4); |
|
44 | 44 | ... |
|
45 | 45 | chart->addSeries(series); |
|
46 | 46 | \endcode |
|
47 | 47 | */ |
|
48 | 48 | |
|
49 | 49 | /*! |
|
50 | 50 | \enum QScatterSeries::MarkerShape |
|
51 | 51 | |
|
52 | 52 | This enum describes the shape used when rendering marker items. |
|
53 | 53 | |
|
54 | 54 | \value MarkerShapeCircle |
|
55 | 55 | \value MarkerShapeRectangle |
|
56 | 56 | */ |
|
57 | 57 | |
|
58 | 58 | /*! |
|
59 | \property QScatterSeries::markerShape | |
|
60 | ||
|
61 | Defines the shape of the marker used to draw the points in the series. | |
|
62 | */ | |
|
63 | ||
|
64 | /*! | |
|
65 | \property QScatterSeries::markerSize | |
|
66 | ||
|
67 | Defines the size of the marker used to draw the points in the series. | |
|
68 | */ | |
|
69 | ||
|
70 | /*! | |
|
59 | 71 | \fn QChartSeriesType QScatterSeries::type() const |
|
60 | 72 | \brief Returns QChartSeries::SeriesTypeScatter. |
|
61 | 73 | \sa QAbstractSeries, SeriesType |
|
62 | 74 | */ |
|
63 | 75 | |
|
64 | 76 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
65 | 77 | |
|
66 | 78 | /*! |
|
67 | 79 | Constructs a series object which is a child of \a parent. |
|
68 | 80 | */ |
|
69 | 81 | QScatterSeries::QScatterSeries(QObject *parent) : QXYSeries(*new QScatterSeriesPrivate(this),parent) |
|
70 | 82 | { |
|
71 | 83 | } |
|
72 | 84 | |
|
73 | 85 | /*! |
|
74 | 86 | Destroys the object. Note that adding series to QChart transfers the ownership to the chart. |
|
75 | 87 | */ |
|
76 | 88 | QScatterSeries::~QScatterSeries() |
|
77 | 89 | { |
|
78 | 90 | Q_D(QScatterSeries); |
|
79 | 91 | if(d->m_dataset) { |
|
80 | 92 | d->m_dataset->removeSeries(this); |
|
81 | 93 | } |
|
82 | 94 | } |
|
83 | 95 | |
|
84 | 96 | QAbstractSeries::SeriesType QScatterSeries::type() const |
|
85 | 97 | { |
|
86 | 98 | return QAbstractSeries::SeriesTypeScatter; |
|
87 | 99 | } |
|
88 | 100 | |
|
89 | 101 | /*! |
|
90 | 102 | Returns the shape used for drawing markers. |
|
91 | 103 | */ |
|
92 | 104 | QScatterSeries::MarkerShape QScatterSeries::markerShape() const |
|
93 | 105 | { |
|
94 | 106 | Q_D(const QScatterSeries); |
|
95 | 107 | return d->m_shape; |
|
96 | 108 | } |
|
97 | 109 | |
|
98 | 110 | /*! |
|
99 | 111 | Overrides the default shape of the marker items with a user defined \a shape. The default shape |
|
100 | 112 | is defined by chart theme setting. |
|
101 | 113 | */ |
|
102 | 114 | void QScatterSeries::setMarkerShape(MarkerShape shape) |
|
103 | 115 | { |
|
104 | 116 | Q_D(QScatterSeries); |
|
105 | 117 | if (d->m_shape != shape) { |
|
106 | 118 | d->m_shape = shape; |
|
107 | 119 | emit d->updated(); |
|
108 | 120 | } |
|
109 | 121 | } |
|
110 | 122 | |
|
111 | 123 | /*! |
|
112 | 124 | Returns the size of the marker items. |
|
113 | 125 | */ |
|
114 | 126 | qreal QScatterSeries::markerSize() const |
|
115 | 127 | { |
|
116 | 128 | Q_D(const QScatterSeries); |
|
117 | 129 | return d->m_size; |
|
118 | 130 | } |
|
119 | 131 | |
|
120 | 132 | /*! |
|
121 | 133 | Set the \a size of the marker items. The default size is 15. |
|
122 | 134 | */ |
|
123 | 135 | void QScatterSeries::setMarkerSize(qreal size) |
|
124 | 136 | { |
|
125 | 137 | Q_D(QScatterSeries); |
|
126 | 138 | |
|
127 | 139 | if (!qFuzzyIsNull(d->m_size - size)) { |
|
128 | 140 | d->m_size = size; |
|
129 | 141 | emit d->updated(); |
|
130 | 142 | } |
|
131 | 143 | } |
|
132 | 144 | |
|
133 | 145 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
134 | 146 | |
|
135 | 147 | QScatterSeriesPrivate::QScatterSeriesPrivate(QScatterSeries* q):QXYSeriesPrivate(q), |
|
136 | 148 | m_shape(QScatterSeries::MarkerShapeCircle), |
|
137 | 149 | m_size(15.0) |
|
138 | 150 | { |
|
139 | 151 | |
|
140 | 152 | }; |
|
141 | 153 | |
|
142 | 154 | Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) |
|
143 | 155 | { |
|
144 | 156 | Q_Q(QScatterSeries); |
|
145 | 157 | ScatterChartItem *scatter = new ScatterChartItem(q,presenter); |
|
146 | 158 | if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) { |
|
147 | 159 | scatter->setAnimator(presenter->animator()); |
|
148 | 160 | scatter->setAnimation(new XYAnimation(scatter)); |
|
149 | 161 | } |
|
150 | 162 | presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q)); |
|
151 | 163 | return scatter; |
|
152 | 164 | } |
|
153 | 165 | |
|
154 | 166 | #include "moc_qscatterseries.cpp" |
|
155 | 167 | |
|
156 | 168 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now