@@ -1,62 +1,61 | |||
|
1 | 1 | #include "qchartaxiscategories.h" |
|
2 | 2 | |
|
3 | 3 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
4 | 4 | |
|
5 | 5 | QChartAxisCategories::QChartAxisCategories() |
|
6 | 6 | { |
|
7 | 7 | // TODO Auto-generated constructor stub |
|
8 | 8 | |
|
9 | 9 | } |
|
10 | 10 | |
|
11 | 11 | QChartAxisCategories::~QChartAxisCategories() |
|
12 | 12 | { |
|
13 | 13 | // TODO Auto-generated destructor stub |
|
14 | 14 | } |
|
15 | 15 | |
|
16 | 16 | void QChartAxisCategories::insert(const QBarCategories &categories) |
|
17 | 17 | { |
|
18 | 18 | int i=1; |
|
19 | 19 | foreach (QString string , categories) { |
|
20 | 20 | m_map.insert(i,string); |
|
21 | 21 | i++; |
|
22 | 22 | } |
|
23 | 23 | emit updated(); |
|
24 | 24 | } |
|
25 | 25 | |
|
26 | 26 | void QChartAxisCategories::insert(qreal value,QString label) |
|
27 | 27 | { |
|
28 | 28 | m_map.insert(value,label); |
|
29 | 29 | emit updated(); |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | 32 | void QChartAxisCategories::remove(qreal value) |
|
33 | 33 | { |
|
34 | 34 | m_map.remove(value); |
|
35 | 35 | emit updated(); |
|
36 | 36 | } |
|
37 | 37 | |
|
38 | 38 | void QChartAxisCategories::clear() |
|
39 | 39 | { |
|
40 | 40 | m_map.clear(); |
|
41 | 41 | emit updated(); |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | int QChartAxisCategories::count() |
|
45 | 45 | { |
|
46 | 46 | return m_map.count(); |
|
47 | emit updated(); | |
|
48 | 47 | } |
|
49 | 48 | |
|
50 | 49 | QList<qreal> QChartAxisCategories::values() const |
|
51 | 50 | { |
|
52 | 51 | return m_map.keys(); |
|
53 | 52 | } |
|
54 | 53 | |
|
55 | 54 | QString QChartAxisCategories::label(qreal value) const |
|
56 | 55 | { |
|
57 | 56 | return m_map.value(value); |
|
58 | 57 | } |
|
59 | 58 | |
|
60 | 59 | #include "moc_qchartaxiscategories.cpp" |
|
61 | 60 | |
|
62 | 61 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,346 +1,345 | |||
|
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 "chartdataset_p.h" |
|
22 | 22 | #include "qchartaxis.h" |
|
23 | 23 | //series |
|
24 | 24 | #include "qlineseries.h" |
|
25 | 25 | #include "qareaseries.h" |
|
26 | 26 | #include "qbarseries.h" |
|
27 | 27 | #include "qstackedbarseries.h" |
|
28 | 28 | #include "qpercentbarseries.h" |
|
29 | 29 | #include "qpieseries.h" |
|
30 | 30 | #include "qscatterseries.h" |
|
31 | 31 | #include "qsplineseries.h" |
|
32 | 32 | |
|
33 | 33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | 34 | |
|
35 | 35 | ChartDataSet::ChartDataSet(QObject *parent):QObject(parent), |
|
36 | 36 | m_axisX(new QChartAxis(this)), |
|
37 | 37 | m_axisY(new QChartAxis(this)), |
|
38 | 38 | m_domainIndex(0), |
|
39 | 39 | m_axisXInitialized(false) |
|
40 | 40 | { |
|
41 | 41 | } |
|
42 | 42 | |
|
43 | 43 | ChartDataSet::~ChartDataSet() |
|
44 | 44 | { |
|
45 | 45 | } |
|
46 | 46 | |
|
47 | 47 | void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY) |
|
48 | 48 | { |
|
49 | 49 | if(axisY==0) axisY = m_axisY; |
|
50 | 50 | |
|
51 | 51 | QChartAxis* axis = m_seriesAxisMap.value(series); |
|
52 | 52 | |
|
53 | 53 | if(axis) { |
|
54 | 54 | qWarning() << "Can not add series. Series already on the chart"; |
|
55 | 55 | return; |
|
56 | 56 | } |
|
57 | 57 | |
|
58 | 58 | if(!series->parent()){ |
|
59 | 59 | series->setParent(this); // take ownership |
|
60 | 60 | }; |
|
61 | 61 | |
|
62 | 62 | if(!axisY->parent()){ |
|
63 | 63 | axisY->setParent(this); // take ownership |
|
64 | 64 | } |
|
65 | 65 | |
|
66 | 66 | Domain* domain = m_axisDomainMap.value(axisY); |
|
67 | 67 | |
|
68 | 68 | if(!domain) { |
|
69 | 69 | domain = new Domain(); |
|
70 | 70 | QObject::connect(axisY,SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool))); |
|
71 | 71 | QObject::connect(axisX(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool))); |
|
72 | 72 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY,SLOT(handleAxisRangeChanged(qreal,qreal,int))); |
|
73 | 73 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axisX(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); |
|
74 | 74 | //initialize |
|
75 | 75 | m_axisDomainMap.insert(axisY,domain); |
|
76 | 76 | emit axisAdded(axisY,domain); |
|
77 | 77 | } |
|
78 | 78 | |
|
79 | 79 | if(!m_axisXInitialized){ |
|
80 | 80 | emit axisAdded(axisX(),domain); |
|
81 | 81 | m_axisXInitialized=true; |
|
82 | 82 | } |
|
83 | 83 | |
|
84 | 84 | calculateDomain(series,domain); |
|
85 | 85 | |
|
86 | 86 | m_seriesAxisMap.insert(series,axisY); |
|
87 | 87 | emit seriesAdded(series,domain); |
|
88 | 88 | |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | void ChartDataSet::removeSeries(QSeries* series) |
|
92 | 92 | { |
|
93 | 93 | |
|
94 | 94 | QChartAxis* axis = m_seriesAxisMap.value(series); |
|
95 | 95 | |
|
96 | 96 | if(!axis){ |
|
97 | 97 | qWarning()<<"Can not remove series. Series not found on the chart."; |
|
98 | 98 | return; |
|
99 | 99 | } |
|
100 | 100 | emit seriesRemoved(series); |
|
101 | 101 | m_seriesAxisMap.remove(series); |
|
102 | 102 | |
|
103 | 103 | if(series->parent()==this){ |
|
104 | 104 | delete series; |
|
105 | 105 | series=0; |
|
106 | 106 | } |
|
107 | 107 | |
|
108 | 108 | QList<QChartAxis*> axes = m_seriesAxisMap.values(); |
|
109 | 109 | |
|
110 | 110 | int i = axes.indexOf(axis); |
|
111 | 111 | |
|
112 | 112 | if(i==-1){ |
|
113 | 113 | Domain* domain = m_axisDomainMap.take(axis); |
|
114 | 114 | emit axisRemoved(axis); |
|
115 | 115 | if(axis!=axisY()){ |
|
116 | 116 | if(axis->parent()==this){ |
|
117 | 117 | delete axis; |
|
118 | 118 | axis=0; |
|
119 | 119 | } |
|
120 | 120 | } |
|
121 | 121 | delete domain; |
|
122 | 122 | } |
|
123 | 123 | |
|
124 | 124 | if(m_seriesAxisMap.values().size()==0) |
|
125 | 125 | { |
|
126 | 126 | m_axisXInitialized=false; |
|
127 | 127 | emit axisRemoved(axisX()); |
|
128 | 128 | } |
|
129 | 129 | } |
|
130 | 130 | |
|
131 | 131 | void ChartDataSet::removeAllSeries() |
|
132 | 132 | { |
|
133 | 133 | |
|
134 | 134 | QList<QSeries*> series = m_seriesAxisMap.keys(); |
|
135 | 135 | |
|
136 | 136 | foreach(QSeries* s , series) { |
|
137 | 137 | removeSeries(s); |
|
138 | 138 | } |
|
139 | 139 | |
|
140 | 140 | Q_ASSERT(m_seriesAxisMap.count()==0); |
|
141 | 141 | Q_ASSERT(m_axisDomainMap.count()==0); |
|
142 | 142 | |
|
143 | 143 | } |
|
144 | 144 | |
|
145 | 145 | //to be removed with PIMPL |
|
146 | 146 | void ChartDataSet::calculateDomain(QSeries* series,Domain* domain) |
|
147 | 147 | { |
|
148 | 148 | qreal minX(domain->minX()); |
|
149 | 149 | qreal minY(domain->minY()); |
|
150 | 150 | qreal maxX(domain->maxX()); |
|
151 | 151 | qreal maxY(domain->maxY()); |
|
152 | 152 | int tickXCount(domain->tickXCount()); |
|
153 | 153 | int tickYCount(domain->tickYCount()); |
|
154 | 154 | |
|
155 | 155 | |
|
156 | 156 | switch(series->type()) |
|
157 | 157 | { |
|
158 | 158 | case QSeries::SeriesTypeLine: |
|
159 | 159 | case QSeries::SeriesTypeSpline: |
|
160 | 160 | case QSeries::SeriesTypeScatter: |
|
161 | 161 | { |
|
162 | 162 | |
|
163 | 163 | QXYSeries* xySeries = static_cast<QXYSeries*>(series); |
|
164 | 164 | |
|
165 | 165 | for (int i = 0; i < xySeries->count(); i++) |
|
166 | 166 | { |
|
167 | 167 | qreal x = xySeries->x(i); |
|
168 | 168 | qreal y = xySeries->y(i); |
|
169 | 169 | minX = qMin(minX, x); |
|
170 | 170 | minY = qMin(minY, y); |
|
171 | 171 | maxX = qMax(maxX, x); |
|
172 | 172 | maxY = qMax(maxY, y); |
|
173 | 173 | } |
|
174 | 174 | break; |
|
175 | 175 | } |
|
176 | 176 | case QSeries::SeriesTypeArea: { |
|
177 | 177 | |
|
178 | 178 | QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series); |
|
179 | 179 | QLineSeries* upperSeries = areaSeries->upperSeries(); |
|
180 | 180 | QLineSeries* lowerSeries = areaSeries->lowerSeries(); |
|
181 | 181 | |
|
182 | 182 | for (int i = 0; i < upperSeries->count(); i++) |
|
183 | 183 | { |
|
184 | 184 | qreal x = upperSeries->x(i); |
|
185 | 185 | qreal y = upperSeries->y(i); |
|
186 | 186 | minX = qMin(minX, x); |
|
187 | 187 | minY = qMin(minY, y); |
|
188 | 188 | maxX = qMax(maxX, x); |
|
189 | 189 | maxY = qMax(maxY, y); |
|
190 | 190 | } |
|
191 | 191 | if(lowerSeries) { |
|
192 | 192 | for (int i = 0; i < lowerSeries->count(); i++) |
|
193 | 193 | { |
|
194 | 194 | qreal x = lowerSeries->x(i); |
|
195 | 195 | qreal y = lowerSeries->y(i); |
|
196 | 196 | minX = qMin(minX, x); |
|
197 | 197 | minY = qMin(minY, y); |
|
198 | 198 | maxX = qMax(maxX, x); |
|
199 | 199 | maxY = qMax(maxY, y); |
|
200 | 200 | }} |
|
201 | 201 | break; |
|
202 | 202 | } |
|
203 | 203 | case QSeries::SeriesTypeBar: { |
|
204 | 204 | |
|
205 | 205 | QBarSeries* barSeries = static_cast<QBarSeries*>(series); |
|
206 | 206 | qreal x = barSeries->categoryCount(); |
|
207 | 207 | qreal y = barSeries->max(); |
|
208 | 208 | minX = qMin(minX, x); |
|
209 | 209 | minY = qMin(minY, y); |
|
210 | 210 | maxX = qMax(maxX, x); |
|
211 | 211 | maxY = qMax(maxY, y); |
|
212 | 212 | tickXCount = x+1; |
|
213 | 213 | setupCategories(barSeries); |
|
214 | 214 | break; |
|
215 | 215 | } |
|
216 | 216 | case QSeries::SeriesTypeStackedBar: { |
|
217 | 217 | |
|
218 | 218 | QStackedBarSeries* stackedBarSeries = static_cast<QStackedBarSeries*>(series); |
|
219 | 219 | qreal x = stackedBarSeries->categoryCount(); |
|
220 | 220 | qreal y = stackedBarSeries->maxCategorySum(); |
|
221 | 221 | minX = qMin(minX, x); |
|
222 | 222 | minY = qMin(minY, y); |
|
223 | 223 | maxX = qMax(maxX, x); |
|
224 | 224 | maxY = qMax(maxY, y); |
|
225 | 225 | tickXCount = x+1; |
|
226 | 226 | setupCategories(stackedBarSeries); |
|
227 | 227 | break; |
|
228 | 228 | } |
|
229 | 229 | case QSeries::SeriesTypePercentBar: { |
|
230 | 230 | |
|
231 | 231 | QPercentBarSeries* percentBarSeries = static_cast<QPercentBarSeries*>(series); |
|
232 | 232 | qreal x = percentBarSeries->categoryCount(); |
|
233 | 233 | minX = qMin(minX, x); |
|
234 | 234 | maxX = qMax(maxX, x); |
|
235 | 235 | minY = 0; |
|
236 | 236 | maxY = 100; |
|
237 | 237 | setupCategories(percentBarSeries); |
|
238 | 238 | break; |
|
239 | 239 | } |
|
240 | 240 | |
|
241 | 241 | case QSeries::SeriesTypePie: { |
|
242 | 242 | //QPieSeries *pieSeries = static_cast<QPieSeries *>(series); |
|
243 | 243 | // TODO: domain stuff |
|
244 | 244 | break; |
|
245 | 245 | } |
|
246 | 246 | |
|
247 | 247 | |
|
248 | 248 | default: { |
|
249 | 249 | qDebug()<<__FUNCTION__<<"type" << series->type()<<"not supported"; |
|
250 | 250 | return; |
|
251 | break; | |
|
252 | 251 | } |
|
253 | 252 | |
|
254 | 253 | } |
|
255 | 254 | |
|
256 | 255 | domain->setRangeX(minX,maxX,tickXCount); |
|
257 | 256 | domain->setRangeY(minY,maxY,tickYCount); |
|
258 | 257 | } |
|
259 | 258 | |
|
260 | 259 | |
|
261 | 260 | void ChartDataSet::setupCategories(QBarSeries* series) |
|
262 | 261 | { |
|
263 | 262 | QChartAxisCategories* categories = axisX()->categories(); |
|
264 | 263 | categories->clear(); |
|
265 | 264 | categories->insert(series->categories()); |
|
266 | 265 | } |
|
267 | 266 | |
|
268 | 267 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) |
|
269 | 268 | { |
|
270 | 269 | QMapIterator<QChartAxis*, Domain*> i(m_axisDomainMap); |
|
271 | 270 | while (i.hasNext()) { |
|
272 | 271 | i.next(); |
|
273 | 272 | i.value()->zoomIn(rect,size); |
|
274 | 273 | } |
|
275 | 274 | } |
|
276 | 275 | |
|
277 | 276 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) |
|
278 | 277 | { |
|
279 | 278 | QMapIterator<QChartAxis*, Domain*> i(m_axisDomainMap); |
|
280 | 279 | while (i.hasNext()) { |
|
281 | 280 | i.next(); |
|
282 | 281 | i.value()->zoomOut(rect,size); |
|
283 | 282 | } |
|
284 | 283 | } |
|
285 | 284 | |
|
286 | 285 | int ChartDataSet::seriesCount(QSeries::QSeriesType type) |
|
287 | 286 | { |
|
288 | 287 | int count=0; |
|
289 | 288 | QMapIterator<QSeries*, QChartAxis*> i(m_seriesAxisMap); |
|
290 | 289 | while (i.hasNext()) { |
|
291 | 290 | i.next(); |
|
292 | 291 | if(i.key()->type()==type) count++; |
|
293 | 292 | } |
|
294 | 293 | return count; |
|
295 | 294 | } |
|
296 | 295 | |
|
297 | 296 | int ChartDataSet::seriesIndex(QSeries *series) |
|
298 | 297 | { |
|
299 | 298 | int count=-1; |
|
300 | 299 | QMapIterator<QSeries*, QChartAxis*> i(m_seriesAxisMap); |
|
301 | 300 | while (i.hasNext()) { |
|
302 | 301 | i.next(); |
|
303 | 302 | count++; |
|
304 | 303 | if (i.key() == series) |
|
305 | 304 | return count; |
|
306 | 305 | } |
|
307 | 306 | return count; |
|
308 | 307 | } |
|
309 | 308 | |
|
310 | 309 | QChartAxis* ChartDataSet::axisY(QSeries* series) const |
|
311 | 310 | { |
|
312 | 311 | if(series == 0) return m_axisY; |
|
313 | 312 | return m_seriesAxisMap.value(series); |
|
314 | 313 | } |
|
315 | 314 | |
|
316 | 315 | Domain* ChartDataSet::domain(QSeries* series) const |
|
317 | 316 | { |
|
318 | 317 | QChartAxis* axis = m_seriesAxisMap.value(series); |
|
319 | 318 | if(axis){ |
|
320 | 319 | return m_axisDomainMap.value(axis); |
|
321 | 320 | }else |
|
322 | 321 | return 0; |
|
323 | 322 | } |
|
324 | 323 | |
|
325 | 324 | Domain* ChartDataSet::domain(QChartAxis* axis) const |
|
326 | 325 | { |
|
327 | 326 | if(!axis || axis==axisX()) { |
|
328 | 327 | return m_axisDomainMap.value(axisY()); |
|
329 | 328 | } |
|
330 | 329 | else { |
|
331 | 330 | return m_axisDomainMap.value(axis); |
|
332 | 331 | } |
|
333 | 332 | } |
|
334 | 333 | |
|
335 | 334 | void ChartDataSet::scrollDomain(int dx,int dy,const QSizeF& size) |
|
336 | 335 | { |
|
337 | 336 | QMapIterator<QChartAxis*, Domain*> i( m_axisDomainMap); |
|
338 | 337 | while (i.hasNext()) { |
|
339 | 338 | i.next(); |
|
340 | 339 | i.value()->move(dx,dy,size); |
|
341 | 340 | } |
|
342 | 341 | } |
|
343 | 342 | |
|
344 | 343 | #include "moc_chartdataset_p.cpp" |
|
345 | 344 | |
|
346 | 345 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,120 +1,120 | |||
|
1 | 1 | #ifndef SCATTERPRESENTER_H |
|
2 | 2 | #define SCATTERPRESENTER_H |
|
3 | 3 | |
|
4 | 4 | #include "qchartglobal.h" |
|
5 | 5 | #include "xychartitem_p.h" |
|
6 | 6 | #include <QGraphicsEllipseItem> |
|
7 | 7 | #include <QPen> |
|
8 | 8 | |
|
9 | 9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | 10 | |
|
11 | 11 | class QScatterSeries; |
|
12 | 12 | class Marker; |
|
13 | 13 | |
|
14 | 14 | class ScatterChartItem : public XYChartItem |
|
15 | 15 | { |
|
16 | 16 | Q_OBJECT |
|
17 | 17 | public: |
|
18 | 18 | explicit ScatterChartItem(QScatterSeries *series, ChartPresenter *presenter); |
|
19 | 19 | |
|
20 | 20 | public: |
|
21 | 21 | //from QGraphicsItem |
|
22 | 22 | QRectF boundingRect() const; |
|
23 | 23 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |
|
24 | 24 | |
|
25 | 25 | void setPen(const QPen &pen); |
|
26 | 26 | void setBrush(const QBrush &brush); |
|
27 | 27 | |
|
28 | 28 | void markerSelected(Marker *item); |
|
29 | 29 | |
|
30 | 30 | public Q_SLOTS: |
|
31 | 31 | void handleUpdated(); |
|
32 | 32 | |
|
33 | 33 | private: |
|
34 | 34 | void createPoints(int count); |
|
35 | 35 | void deletePoints(int count); |
|
36 | 36 | |
|
37 | 37 | protected: |
|
38 | 38 | void setLayout(QVector<QPointF> &points); |
|
39 | 39 | |
|
40 | 40 | private: |
|
41 | 41 | QScatterSeries *m_series; |
|
42 | 42 | QGraphicsItemGroup m_items; |
|
43 | 43 | int m_shape; |
|
44 | 44 | int m_size; |
|
45 | 45 | QRectF m_rect; |
|
46 | 46 | |
|
47 | 47 | }; |
|
48 | 48 | |
|
49 | 49 | |
|
50 | 50 | class Marker: public QAbstractGraphicsShapeItem |
|
51 | 51 | { |
|
52 | 52 | |
|
53 | 53 | public: |
|
54 | 54 | |
|
55 | Marker(QAbstractGraphicsShapeItem *item , ScatterChartItem *parent) : QAbstractGraphicsShapeItem(0) ,m_item(item), m_parent(parent) | |
|
55 | Marker(QAbstractGraphicsShapeItem *item , ScatterChartItem *parent) : QAbstractGraphicsShapeItem(0) ,m_item(item), m_parent(parent), m_index(-1) | |
|
56 | 56 | { |
|
57 | 57 | }; |
|
58 | 58 | |
|
59 | 59 | ~Marker() |
|
60 | 60 | { |
|
61 | 61 | delete m_item; |
|
62 | 62 | } |
|
63 | 63 | |
|
64 | 64 | void setIndex(int index) |
|
65 | 65 | { |
|
66 | 66 | m_index=index; |
|
67 | 67 | } |
|
68 | 68 | |
|
69 | 69 | int index() const |
|
70 | 70 | { |
|
71 | 71 | return m_index; |
|
72 | 72 | } |
|
73 | 73 | |
|
74 | 74 | QPainterPath shape() const |
|
75 | 75 | { |
|
76 | 76 | return m_item->shape(); |
|
77 | 77 | } |
|
78 | 78 | |
|
79 | 79 | QRectF boundingRect() const |
|
80 | 80 | { |
|
81 | 81 | return m_item->boundingRect(); |
|
82 | 82 | } |
|
83 | 83 | |
|
84 | 84 | bool contains(const QPointF &point) const |
|
85 | 85 | { |
|
86 | 86 | return m_item->contains(point); |
|
87 | 87 | } |
|
88 | 88 | |
|
89 | 89 | void setPen(const QPen &pen) |
|
90 | 90 | { |
|
91 | 91 | m_item->setPen(pen); |
|
92 | 92 | } |
|
93 | 93 | |
|
94 | 94 | void setBrush(const QBrush &brush) |
|
95 | 95 | { |
|
96 | 96 | m_item->setBrush(brush); |
|
97 | 97 | } |
|
98 | 98 | |
|
99 | 99 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
100 | 100 | { |
|
101 | 101 | m_item->paint(painter,option,widget); |
|
102 | 102 | } |
|
103 | 103 | |
|
104 | 104 | protected: |
|
105 | 105 | |
|
106 | 106 | void mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
107 | 107 | { |
|
108 | 108 | Q_UNUSED(event) |
|
109 | 109 | m_parent->markerSelected(this); |
|
110 | 110 | } |
|
111 | 111 | |
|
112 | 112 | private: |
|
113 | 113 | QAbstractGraphicsShapeItem* m_item; |
|
114 | 114 | ScatterChartItem* m_parent; |
|
115 | 115 | int m_index; |
|
116 | 116 | }; |
|
117 | 117 | |
|
118 | 118 | QTCOMMERCIALCHART_END_NAMESPACE |
|
119 | 119 | |
|
120 | 120 | #endif // SCATTERPRESENTER_H |
General Comments 0
You need to be logged in to leave comments.
Login now