@@ -105,11 +105,14 void ChartPresenter::handleAxisAdded(QChartAxis* axis,Domain* domain) | |||
|
105 | 105 | } |
|
106 | 106 | |
|
107 | 107 | if(axis==m_dataset->axisX()){ |
|
108 | m_chartTheme->decorate(axis,true); | |
|
108 | 109 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int))); |
|
109 | 110 | //initialize |
|
110 | 111 | item->handleRangeChanged(domain->minX(),domain->maxX(),domain->tickXCount()); |
|
112 | ||
|
111 | 113 | } |
|
112 | 114 | else{ |
|
115 | m_chartTheme->decorate(axis,false); | |
|
113 | 116 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int))); |
|
114 | 117 | //initialize |
|
115 | 118 | item->handleRangeChanged(domain->minY(),domain->maxY(),domain->tickYCount()); |
@@ -118,7 +121,6 void ChartPresenter::handleAxisAdded(QChartAxis* axis,Domain* domain) | |||
|
118 | 121 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); |
|
119 | 122 | //initialize |
|
120 | 123 | item->handleGeometryChanged(m_rect); |
|
121 | m_chartTheme->decorate(axis, m_chart); | |
|
122 | 124 | m_axisItems.insert(axis, item); |
|
123 | 125 | } |
|
124 | 126 | |
@@ -144,7 +146,7 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain) | |||
|
144 | 146 | if(m_options.testFlag(QChart::SeriesAnimations)) { |
|
145 | 147 | m_animator->addAnimation(line); |
|
146 | 148 | } |
|
147 |
m_chartTheme->decorate( |
|
|
149 | m_chartTheme->decorate(lineSeries, m_dataset->seriesIndex(series)); | |
|
148 | 150 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),line,SLOT(handleGeometryChanged(const QRectF&))); |
|
149 | 151 | QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),line,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); |
|
150 | 152 | item = line; |
@@ -159,7 +161,7 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain) | |||
|
159 | 161 | m_animator->addAnimation(area->upperLineItem()); |
|
160 | 162 | if(areaSeries->lowerSeries()) m_animator->addAnimation(area->lowerLineItem()); |
|
161 | 163 | } |
|
162 |
m_chartTheme->decorate( |
|
|
164 | m_chartTheme->decorate(areaSeries, m_dataset->seriesIndex(series)); | |
|
163 | 165 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),area,SLOT(handleGeometryChanged(const QRectF&))); |
|
164 | 166 | QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),area,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); |
|
165 | 167 | item=area; |
@@ -211,7 +213,7 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain) | |||
|
211 | 213 | if(m_options.testFlag(QChart::SeriesAnimations)) { |
|
212 | 214 | m_animator->addAnimation(scatter); |
|
213 | 215 | } |
|
214 |
m_chartTheme->decorate( |
|
|
216 | m_chartTheme->decorate(scatterSeries, m_dataset->seriesIndex(series)); | |
|
215 | 217 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),scatter,SLOT(handleGeometryChanged(const QRectF&))); |
|
216 | 218 | QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),scatter,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); |
|
217 | 219 | item = scatter; |
@@ -244,7 +246,7 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain) | |||
|
244 | 246 | if(m_options.testFlag(QChart::SeriesAnimations)) { |
|
245 | 247 | m_animator->addAnimation(spline); |
|
246 | 248 | } |
|
247 |
m_chartTheme->decorate( |
|
|
249 | m_chartTheme->decorate(splineSeries, m_dataset->seriesIndex(series)); | |
|
248 | 250 | QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),spline,SLOT(handleGeometryChanged(const QRectF&))); |
|
249 | 251 | QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),spline,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); |
|
250 | 252 | item=spline; |
@@ -71,7 +71,7 void ChartTheme::decorate(QLegend* legend) | |||
|
71 | 71 | legend->setBackgroundBrush(m_backgroundGradient); |
|
72 | 72 | } |
|
73 | 73 | |
|
74 |
void ChartTheme::decorate( |
|
|
74 | void ChartTheme::decorate(QAreaSeries* series, int index) | |
|
75 | 75 | { |
|
76 | 76 | QPen pen; |
|
77 | 77 | QBrush brush; |
@@ -89,7 +89,7 void ChartTheme::decorate(AreaChartItem* item, QAreaSeries* series, int index) | |||
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | |
|
92 |
void ChartTheme::decorate( |
|
|
92 | void ChartTheme::decorate(QLineSeries* series,int index) | |
|
93 | 93 | { |
|
94 | 94 | QPen pen; |
|
95 | 95 | if(pen == series->pen()){ |
@@ -159,10 +159,8 void ChartTheme::decorate(PercentBarPresenter* item, QPercentBarSeries* series,i | |||
|
159 | 159 | } |
|
160 | 160 | } |
|
161 | 161 | |
|
162 |
void ChartTheme::decorate( |
|
|
162 | void ChartTheme::decorate(QScatterSeries* series, int index) | |
|
163 | 163 | { |
|
164 | Q_ASSERT(item); | |
|
165 | Q_ASSERT(series); | |
|
166 | 164 | |
|
167 | 165 | QPen pen; |
|
168 | 166 | QBrush brush; |
@@ -191,45 +189,26 void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int index) | |||
|
191 | 189 | } |
|
192 | 190 | } |
|
193 | 191 | |
|
194 |
void ChartTheme::decorate( |
|
|
192 | void ChartTheme::decorate(QSplineSeries* series, int index) | |
|
195 | 193 | { |
|
196 | Q_ASSERT(item); | |
|
197 | Q_ASSERT(series); | |
|
198 | ||
|
199 | 194 | QPen pen; |
|
200 | 195 | |
|
201 |
if(pen |
|
|
202 | item->setLinePen(series->pen()); | |
|
203 | }else{ | |
|
196 | if(pen == series->pen()){ | |
|
204 | 197 | pen.setColor(m_seriesColors.at(index%m_seriesColors.size())); |
|
205 |
pen.setWidthF( |
|
|
206 |
|
|
|
198 | pen.setWidthF(2); | |
|
199 | series->setPen(pen); | |
|
207 | 200 | } |
|
208 | ||
|
209 | // QColor color = m_seriesColors.at(index % m_seriesColors.size()); | |
|
210 | // TODO: define alpha in the theme? or in the series? | |
|
211 | //color.setAlpha(120); | |
|
212 | ||
|
213 | // QBrush brush(color, Qt::SolidPattern); | |
|
214 | // presenter->m_markerBrush = brush; | |
|
215 | ||
|
216 | // QPen pen(brush, 3); | |
|
217 | // pen.setColor(color); | |
|
218 | // presenter->m_markerPen = pen; | |
|
219 | 201 | } |
|
220 | 202 | |
|
221 |
void ChartTheme::decorate(QChartAxis* axis, |
|
|
203 | void ChartTheme::decorate(QChartAxis* axis,bool axisX) | |
|
222 | 204 | { |
|
223 | Q_ASSERT(axis); | |
|
224 | Q_ASSERT(parent); | |
|
225 | ||
|
226 | 205 | if (axis->isAxisVisible()) { |
|
227 | 206 | axis->setLabelsBrush(m_axisLabelBrush); |
|
228 | 207 | axis->setLabelsPen(m_axisLabelPen); |
|
229 | 208 | // TODO: check the axis type (x or y) should define whether to show the shades or not |
|
230 | 209 | if (m_backgroundShades == BackgroundShadesBoth |
|
231 |
|| (m_backgroundShades == BackgroundShadesVertical && |
|
|
232 |
|| (m_backgroundShades == BackgroundShadesHorizontal && |
|
|
210 | || (m_backgroundShades == BackgroundShadesVertical && axisX) | |
|
211 | || (m_backgroundShades == BackgroundShadesHorizontal && !axisX)) { | |
|
233 | 212 | axis->setShadesPen(m_backgroundShadesPen); |
|
234 | 213 | axis->setShadesBrush(m_backgroundShadesBrush); |
|
235 | 214 | } else { |
@@ -48,12 +48,12 public: | |||
|
48 | 48 | void decorate(BarPresenter* item, QBarSeries* series, int index); |
|
49 | 49 | void decorate(StackedBarPresenter* item, QStackedBarSeries* series, int index); |
|
50 | 50 | void decorate(PercentBarPresenter* item, QPercentBarSeries* series, int index); |
|
51 |
void decorate( |
|
|
52 |
void decorate( |
|
|
53 |
void decorate( |
|
|
51 | void decorate(QLineSeries* series, int index); | |
|
52 | void decorate(QAreaSeries* series, int index); | |
|
53 | void decorate(QScatterSeries* series, int index); | |
|
54 | 54 | void decorate(PiePresenter* item, QPieSeries* series, int index); |
|
55 |
void decorate( |
|
|
56 |
void decorate(QChartAxis* axis, |
|
|
55 | void decorate(QSplineSeries* series, int index); | |
|
56 | void decorate(QChartAxis* axis, bool axisX); | |
|
57 | 57 | |
|
58 | 58 | public: // utils |
|
59 | 59 | void generateSeriesGradients(); |
@@ -53,17 +53,12 void SplineChartItem::setLayout(QVector<QPointF>& points) | |||
|
53 | 53 | XYChartItem::setLayout(points); |
|
54 | 54 | } |
|
55 | 55 | |
|
56 | void SplineChartItem::setLinePen(const QPen& pen) | |
|
57 | { | |
|
58 | m_pen = pen; | |
|
59 | } | |
|
60 | ||
|
61 | 56 | //handlers |
|
62 | 57 | |
|
63 | 58 | void SplineChartItem::handleUpdated() |
|
64 | 59 | { |
|
65 | 60 | //m_items.setVisible(m_series->pointsVisible()); |
|
66 |
|
|
|
61 | m_pen = m_series->pen(); | |
|
67 | 62 | update(); |
|
68 | 63 | } |
|
69 | 64 |
General Comments 0
You need to be logged in to leave comments.
Login now