1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -217,8 +217,6 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain) | |||||
217 | case QSeries::SeriesTypeScatter: { |
|
217 | case QSeries::SeriesTypeScatter: { | |
218 | QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series); |
|
218 | QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series); | |
219 | ScatterPresenter *scatterPresenter = new ScatterPresenter(scatterSeries, m_chart); |
|
219 | ScatterPresenter *scatterPresenter = new ScatterPresenter(scatterSeries, m_chart); | |
220 | QObject::connect(scatterPresenter, SIGNAL(clicked(QPointF)), |
|
|||
221 | scatterSeries, SIGNAL(clicked(QPointF))); |
|
|||
222 | QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), |
|
220 | QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), | |
223 | scatterPresenter, SLOT(handleGeometryChanged(const QRectF&))); |
|
221 | scatterPresenter, SLOT(handleGeometryChanged(const QRectF&))); | |
224 | QObject::connect(domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal)), |
|
222 | QObject::connect(domain, SIGNAL(domainChanged(qreal,qreal,qreal,qreal)), |
@@ -33,6 +33,7 | |||||
33 | \value MarkerShapeDefault |
|
33 | \value MarkerShapeDefault | |
34 | \value MarkerShapeX |
|
34 | \value MarkerShapeX | |
35 | \value MarkerShapeRectangle |
|
35 | \value MarkerShapeRectangle | |
|
36 | \value MarkerShapeRoundedRectangle | |||
36 | \value MarkerShapeTiltedRectangle |
|
37 | \value MarkerShapeTiltedRectangle | |
37 | \value MarkerShapeTriangle |
|
38 | \value MarkerShapeTriangle | |
38 | \value MarkerShapeCircle |
|
39 | \value MarkerShapeCircle | |
@@ -50,14 +51,10 | |||||
50 | data point you can use closestPoint(). |
|
51 | data point you can use closestPoint(). | |
51 | */ |
|
52 | */ | |
52 |
|
53 | |||
53 | /*! |
|
|||
54 | \fn void QScatterSeries::changed() |
|
|||
55 | \brief TODO |
|
|||
56 | */ |
|
|||
57 |
|
||||
58 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
54 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
59 |
|
55 | |||
60 | QScatterSeriesPrivate::QScatterSeriesPrivate() : |
|
56 | QScatterSeriesPrivate::QScatterSeriesPrivate(QObject *parent) : | |
|
57 | QObject(parent), | |||
61 | m_data(QList<QPointF>()), |
|
58 | m_data(QList<QPointF>()), | |
62 | m_markerPen(QPen(QColor::Invalid)), |
|
59 | m_markerPen(QPen(QColor::Invalid)), | |
63 | m_markerBrush(QBrush(QColor::Invalid)), |
|
60 | m_markerBrush(QBrush(QColor::Invalid)), | |
@@ -66,12 +63,19 QScatterSeriesPrivate::QScatterSeriesPrivate() : | |||||
66 | { |
|
63 | { | |
67 | } |
|
64 | } | |
68 |
|
65 | |||
|
66 | void QScatterSeriesPrivate::emitChanged() | |||
|
67 | { | |||
|
68 | emit changed(); | |||
|
69 | } | |||
|
70 | ||||
|
71 | #include "moc_scatterseries_p.cpp" | |||
|
72 | ||||
69 | /*! |
|
73 | /*! | |
70 | Constructs a series object which is a child of \a parent. |
|
74 | Constructs a series object which is a child of \a parent. | |
71 | */ |
|
75 | */ | |
72 | QScatterSeries::QScatterSeries(QObject *parent) : |
|
76 | QScatterSeries::QScatterSeries(QObject *parent) : | |
73 | QSeries(parent), |
|
77 | QSeries(parent), | |
74 | d(new QScatterSeriesPrivate()) |
|
78 | d(new QScatterSeriesPrivate(this)) | |
75 | { |
|
79 | { | |
76 | } |
|
80 | } | |
77 |
|
81 | |||
@@ -89,7 +93,7 QScatterSeries::~QScatterSeries() | |||||
89 | void QScatterSeries::add(qreal x, qreal y) |
|
93 | void QScatterSeries::add(qreal x, qreal y) | |
90 | { |
|
94 | { | |
91 | d->m_data.append(QPointF(x, y)); |
|
95 | d->m_data.append(QPointF(x, y)); | |
92 |
|
|
96 | d->emitChanged(); | |
93 | } |
|
97 | } | |
94 |
|
98 | |||
95 | /*! |
|
99 | /*! | |
@@ -98,7 +102,7 void QScatterSeries::add(qreal x, qreal y) | |||||
98 | void QScatterSeries::add(QPointF value) |
|
102 | void QScatterSeries::add(QPointF value) | |
99 | { |
|
103 | { | |
100 | d->m_data.append(value); |
|
104 | d->m_data.append(value); | |
101 |
|
|
105 | d->emitChanged(); | |
102 | } |
|
106 | } | |
103 |
|
107 | |||
104 | /*! |
|
108 | /*! | |
@@ -107,7 +111,7 void QScatterSeries::add(QPointF value) | |||||
107 | void QScatterSeries::add(QList<QPointF> points) |
|
111 | void QScatterSeries::add(QList<QPointF> points) | |
108 | { |
|
112 | { | |
109 | d->m_data.append(points); |
|
113 | d->m_data.append(points); | |
110 |
|
|
114 | d->emitChanged(); | |
111 | } |
|
115 | } | |
112 |
|
116 | |||
113 | /*! |
|
117 | /*! | |
@@ -120,7 +124,7 void QScatterSeries::add(QList<QPointF> points) | |||||
120 | QScatterSeries& QScatterSeries::operator << (const QPointF &value) |
|
124 | QScatterSeries& QScatterSeries::operator << (const QPointF &value) | |
121 | { |
|
125 | { | |
122 | d->m_data.append(value); |
|
126 | d->m_data.append(value); | |
123 |
|
|
127 | d->emitChanged(); | |
124 | return *this; |
|
128 | return *this; | |
125 | } |
|
129 | } | |
126 |
|
130 | |||
@@ -131,7 +135,7 QScatterSeries& QScatterSeries::operator << (const QPointF &value) | |||||
131 | QScatterSeries& QScatterSeries::operator << (QList<QPointF> value) |
|
135 | QScatterSeries& QScatterSeries::operator << (QList<QPointF> value) | |
132 | { |
|
136 | { | |
133 | d->m_data.append(value); |
|
137 | d->m_data.append(value); | |
134 |
|
|
138 | d->emitChanged(); | |
135 | return *this; |
|
139 | return *this; | |
136 | } |
|
140 | } | |
137 |
|
141 | |||
@@ -141,7 +145,7 QScatterSeries& QScatterSeries::operator << (QList<QPointF> value) | |||||
141 | void QScatterSeries::setData(QList<QPointF> points) |
|
145 | void QScatterSeries::setData(QList<QPointF> points) | |
142 | { |
|
146 | { | |
143 | d->m_data = points; |
|
147 | d->m_data = points; | |
144 |
|
|
148 | d->emitChanged(); | |
145 | } |
|
149 | } | |
146 |
|
150 | |||
147 | /*! |
|
151 | /*! | |
@@ -160,7 +164,7 bool QScatterSeries::replace(int index, QPointF newPoint) | |||||
160 | { |
|
164 | { | |
161 | if (index >= 0 && index < d->m_data.count()) { |
|
165 | if (index >= 0 && index < d->m_data.count()) { | |
162 | d->m_data.replace(index, newPoint); |
|
166 | d->m_data.replace(index, newPoint); | |
163 |
|
|
167 | d->emitChanged(); | |
164 | return true; |
|
168 | return true; | |
165 | } |
|
169 | } | |
166 | return false; |
|
170 | return false; | |
@@ -174,7 +178,7 bool QScatterSeries::removeAt(int index) | |||||
174 | { |
|
178 | { | |
175 | if (index >=0 && index < d->m_data.count()) { |
|
179 | if (index >=0 && index < d->m_data.count()) { | |
176 | d->m_data.removeAt(index); |
|
180 | d->m_data.removeAt(index); | |
177 |
|
|
181 | d->emitChanged(); | |
178 | return true; |
|
182 | return true; | |
179 | } |
|
183 | } | |
180 | return false; |
|
184 | return false; | |
@@ -186,7 +190,7 bool QScatterSeries::removeAt(int index) | |||||
186 | int QScatterSeries::removeAll(QPointF point) |
|
190 | int QScatterSeries::removeAll(QPointF point) | |
187 | { |
|
191 | { | |
188 | int count = d->m_data.removeAll(point); |
|
192 | int count = d->m_data.removeAll(point); | |
189 |
|
|
193 | d->emitChanged(); | |
190 | return count; |
|
194 | return count; | |
191 | } |
|
195 | } | |
192 |
|
196 | |||
@@ -196,7 +200,7 int QScatterSeries::removeAll(QPointF point) | |||||
196 | void QScatterSeries::clear() |
|
200 | void QScatterSeries::clear() | |
197 | { |
|
201 | { | |
198 | d->m_data.clear(); |
|
202 | d->m_data.clear(); | |
199 |
|
|
203 | d->emitChanged(); | |
200 | } |
|
204 | } | |
201 |
|
205 | |||
202 | /*! |
|
206 | /*! | |
@@ -220,23 +224,32 int QScatterSeries::closestPoint(QPointF coordinate) | |||||
220 | } |
|
224 | } | |
221 |
|
225 | |||
222 | /*! |
|
226 | /*! | |
|
227 | Returns the pen used for drawing markers. | |||
|
228 | */ | |||
|
229 | QPen QScatterSeries::pen() const | |||
|
230 | { | |||
|
231 | return d->m_markerPen; | |||
|
232 | } | |||
|
233 | ||||
|
234 | /*! | |||
223 | Overrides the default pen used for drawing a marker item with a user defined \a pen. The |
|
235 | Overrides the default pen used for drawing a marker item with a user defined \a pen. The | |
224 | default pen is defined by chart theme setting. |
|
236 | default pen is defined by chart theme setting. | |
225 |
|
237 | |||
226 | \sa setBrush() |
|
238 | \sa setBrush() | |
227 | \sa QChart::setChartTheme() |
|
239 | \sa QChart::setChartTheme() | |
228 | */ |
|
240 | */ | |
229 | void QScatterSeries::setPen(QPen pen) |
|
241 | void QScatterSeries::setPen(const QPen &pen) | |
230 | { |
|
242 | { | |
231 | d->m_markerPen = pen; |
|
243 | d->m_markerPen = pen; | |
|
244 | d->emitChanged(); | |||
232 | } |
|
245 | } | |
233 |
|
246 | |||
234 | /*! |
|
247 | /*! | |
235 |
Returns the |
|
248 | Returns the brush used for drawing markers. | |
236 | */ |
|
249 | */ | |
237 |
Q |
|
250 | QBrush QScatterSeries::brush() const | |
238 | { |
|
251 | { | |
239 |
return d->m_marker |
|
252 | return d->m_markerBrush; | |
240 | } |
|
253 | } | |
241 |
|
254 | |||
242 | /*! |
|
255 | /*! | |
@@ -246,17 +259,18 QPen QScatterSeries::pen() | |||||
246 | \sa setPen() |
|
259 | \sa setPen() | |
247 | \sa QChart::setChartTheme() |
|
260 | \sa QChart::setChartTheme() | |
248 | */ |
|
261 | */ | |
249 | void QScatterSeries::setBrush(QBrush brush) |
|
262 | void QScatterSeries::setBrush(const QBrush &brush) | |
250 | { |
|
263 | { | |
251 | d->m_markerBrush = brush; |
|
264 | d->m_markerBrush = brush; | |
|
265 | d->emitChanged(); | |||
252 | } |
|
266 | } | |
253 |
|
267 | |||
254 | /*! |
|
268 | /*! | |
255 |
Returns the |
|
269 | Returns the shape used for drawing markers. | |
256 | */ |
|
270 | */ | |
257 | QBrush QScatterSeries::brush() |
|
271 | QScatterSeries::MarkerShape QScatterSeries::shape() const | |
258 | { |
|
272 | { | |
259 | return d->m_markerBrush; |
|
273 | return (QScatterSeries::MarkerShape) d->m_markerShape; | |
260 | } |
|
274 | } | |
261 |
|
275 | |||
262 | /*! |
|
276 | /*! | |
@@ -266,20 +280,13 QBrush QScatterSeries::brush() | |||||
266 | void QScatterSeries::setShape(MarkerShape shape) |
|
280 | void QScatterSeries::setShape(MarkerShape shape) | |
267 | { |
|
281 | { | |
268 | d->m_markerShape = shape; |
|
282 | d->m_markerShape = shape; | |
269 | } |
|
283 | d->emitChanged(); | |
270 |
|
||||
271 | /*! |
|
|||
272 | Returns the shape used for drawing markers. |
|
|||
273 | */ |
|
|||
274 | QScatterSeries::MarkerShape QScatterSeries::shape() |
|
|||
275 | { |
|
|||
276 | return (QScatterSeries::MarkerShape) d->m_markerShape; |
|
|||
277 | } |
|
284 | } | |
278 |
|
285 | |||
279 | /*! |
|
286 | /*! | |
280 | Returns the size of the marker items. |
|
287 | Returns the size of the marker items. | |
281 | */ |
|
288 | */ | |
282 | qreal QScatterSeries::size() |
|
289 | qreal QScatterSeries::size() const | |
283 | { |
|
290 | { | |
284 | return d->m_markerSize; |
|
291 | return d->m_markerSize; | |
285 | } |
|
292 | } | |
@@ -290,7 +297,7 qreal QScatterSeries::size() | |||||
290 | void QScatterSeries::setSize(qreal size) |
|
297 | void QScatterSeries::setSize(qreal size) | |
291 | { |
|
298 | { | |
292 | d->m_markerSize = size; |
|
299 | d->m_markerSize = size; | |
293 |
|
|
300 | d->emitChanged(); | |
294 | } |
|
301 | } | |
295 |
|
302 | |||
296 | #include "moc_qscatterseries.cpp" |
|
303 | #include "moc_qscatterseries.cpp" |
@@ -19,6 +19,7 public: | |||||
19 | MarkerShapeDefault = 0, |
|
19 | MarkerShapeDefault = 0, | |
20 | MarkerShapeX, |
|
20 | MarkerShapeX, | |
21 | MarkerShapeRectangle, |
|
21 | MarkerShapeRectangle, | |
|
22 | MarkerShapeRoundedRectangle, | |||
22 | MarkerShapeTiltedRectangle, |
|
23 | MarkerShapeTiltedRectangle, | |
23 | MarkerShapeTriangle, |
|
24 | MarkerShapeTriangle, | |
24 | MarkerShapeCircle |
|
25 | MarkerShapeCircle | |
@@ -46,26 +47,23 public: | |||||
46 | int closestPoint(QPointF coordinate); |
|
47 | int closestPoint(QPointF coordinate); | |
47 | //TODO: insert, replace...? |
|
48 | //TODO: insert, replace...? | |
48 |
|
49 | |||
49 | QPen pen(); |
|
50 | QPen pen() const; | |
50 | void setPen(QPen pen); |
|
51 | void setPen(const QPen &pen); | |
51 | QBrush brush(); |
|
52 | QBrush brush() const; | |
52 | void setBrush(QBrush brush); |
|
53 | void setBrush(const QBrush &brush); | |
53 | MarkerShape shape(); |
|
54 | MarkerShape shape() const; | |
54 | void setShape(MarkerShape shape); |
|
55 | void setShape(MarkerShape shape); | |
55 | qreal size(); |
|
56 | qreal size() const; | |
56 | void setSize(qreal size); |
|
57 | void setSize(qreal size); | |
57 |
|
58 | |||
58 | Q_SIGNALS: |
|
59 | Q_SIGNALS: | |
59 | void clicked(QPointF coordinate); |
|
60 | void clicked(QPointF coordinate); | |
60 | // TODO: move to PIMPL for simplicity or does the user ever need changed signals? |
|
|||
61 | // TODO: more finegrained signaling for performance reasons |
|
|||
62 | // (check QPieSeries implementation with change sets) |
|
|||
63 | void changed(); |
|
|||
64 |
|
61 | |||
65 | private: |
|
62 | private: | |
66 | Q_DECLARE_PRIVATE(QScatterSeries) |
|
63 | Q_DECLARE_PRIVATE(QScatterSeries) | |
67 | Q_DISABLE_COPY(QScatterSeries) |
|
64 | Q_DISABLE_COPY(QScatterSeries) | |
68 | QScatterSeriesPrivate *const d; |
|
65 | friend class ScatterPresenter; | |
|
66 | QScatterSeriesPrivate *d; | |||
69 | }; |
|
67 | }; | |
70 |
|
68 | |||
71 | QTCOMMERCIALCHART_END_NAMESPACE |
|
69 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,5 +1,6 | |||||
1 | #include "scatterpresenter_p.h" |
|
1 | #include "scatterpresenter_p.h" | |
2 | #include "qscatterseries.h" |
|
2 | #include "qscatterseries.h" | |
|
3 | #include "scatterseries_p.h" | |||
3 | #include "chartpresenter_p.h" |
|
4 | #include "chartpresenter_p.h" | |
4 | #include <QPen> |
|
5 | #include <QPen> | |
5 | #include <QPainter> |
|
6 | #include <QPainter> | |
@@ -20,13 +21,12 ScatterPresenter::ScatterPresenter(QScatterSeries *series, QGraphicsObject *pare | |||||
20 | m_series(series), |
|
21 | m_series(series), | |
21 | m_clippingRect() |
|
22 | m_clippingRect() | |
22 | { |
|
23 | { | |
23 |
|
|
24 | Q_ASSERT(parent); | |
24 | m_clippingRect = parent->boundingRect(); |
|
25 | Q_ASSERT(series); | |
25 |
|
||||
26 | if (series) { |
|
|||
27 | connect(series, SIGNAL(changed()), this, SLOT(handleModelChanged())); |
|
|||
28 | } |
|
|||
29 |
|
26 | |||
|
27 | m_clippingRect = parent->boundingRect(); | |||
|
28 | connect(series->d, SIGNAL(changed()), this, SLOT(handleModelChanged())); | |||
|
29 | connect(this, SIGNAL(clicked(QPointF)), series, SIGNAL(clicked(QPointF))); | |||
30 | setZValue(ChartPresenter::ScatterSeriesZValue); |
|
30 | setZValue(ChartPresenter::ScatterSeriesZValue); | |
31 |
|
31 | |||
32 | // TODO: how to draw a drop shadow? |
|
32 | // TODO: how to draw a drop shadow? | |
@@ -136,11 +136,21 void ScatterPresenter::changeGeometry() | |||||
136 | case QScatterSeries::MarkerShapeRectangle: |
|
136 | case QScatterSeries::MarkerShapeRectangle: | |
137 | m_path.addRect(x, y, size, size); |
|
137 | m_path.addRect(x, y, size, size); | |
138 | break; |
|
138 | break; | |
|
139 | case QScatterSeries::MarkerShapeRoundedRectangle: | |||
|
140 | m_path.addRoundedRect(x, y, size, size, size / 4.0, size / 4.0); | |||
|
141 | break; | |||
139 | case QScatterSeries::MarkerShapeTiltedRectangle: { |
|
142 | case QScatterSeries::MarkerShapeTiltedRectangle: { | |
140 | // TODO: tilt the rectangle |
|
143 | // TODO: tilt the rectangle | |
141 | m_path.addRect(x, y, size, size); |
|
144 | m_path.addRect(x, y, size, size); | |
142 | break; |
|
145 | break; | |
143 | } |
|
146 | } | |
|
147 | case QScatterSeries::MarkerShapeTriangle: { | |||
|
148 | QPolygonF polygon; | |||
|
149 | polygon << QPointF(0.0, -size) << QPointF(size / 2.0, 0.0) << QPointF(-size / 2, 0.0); | |||
|
150 | // TODO: the position is not exactly right... | |||
|
151 | m_path.addPolygon(polygon.translated(x + size / 2.0, y + size)); | |||
|
152 | break; | |||
|
153 | } | |||
144 | default: |
|
154 | default: | |
145 | // TODO: implement the rest of the shapes |
|
155 | // TODO: implement the rest of the shapes | |
146 | Q_ASSERT(false); |
|
156 | Q_ASSERT(false); |
@@ -3,6 +3,7 | |||||
3 |
|
3 | |||
4 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
5 | #include "qseries.h" |
|
5 | #include "qseries.h" | |
|
6 | #include <QObject> | |||
6 | #include <QPen> |
|
7 | #include <QPen> | |
7 |
|
8 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
@@ -10,10 +11,18 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||||
10 | /*! |
|
11 | /*! | |
11 | * The PIMPL class of QScatterSeries. |
|
12 | * The PIMPL class of QScatterSeries. | |
12 | */ |
|
13 | */ | |
13 | class QScatterSeriesPrivate |
|
14 | class QScatterSeriesPrivate : public QObject | |
14 | { |
|
15 | { | |
|
16 | Q_OBJECT | |||
|
17 | ||||
15 | public: |
|
18 | public: | |
16 | QScatterSeriesPrivate(); |
|
19 | QScatterSeriesPrivate(QObject *parent); | |
|
20 | void emitChanged(); | |||
|
21 | ||||
|
22 | Q_SIGNALS: | |||
|
23 | // TODO: more finegrained signaling for performance reasons | |||
|
24 | // (see for example QPieSeries implementation with change sets) | |||
|
25 | void changed(); | |||
17 |
|
26 | |||
18 | public: |
|
27 | public: | |
19 | QList<QPointF> m_data; |
|
28 | QList<QPointF> m_data; |
General Comments 0
You need to be logged in to leave comments.
Login now