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