@@ -100,7 +100,7 void ChartCategoriesAxisX::updateGeometry() | |||
|
100 | 100 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
101 | 101 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
102 | 102 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
103 |
QList<QGraphicsItem *> axis = m_a |
|
|
103 | QList<QGraphicsItem *> axis = m_arrow->childItems(); | |
|
104 | 104 | |
|
105 | 105 | Q_ASSERT(labels.size() == ticksList.size()); |
|
106 | 106 | Q_ASSERT(layout.size() == ticksList.size()); |
@@ -97,7 +97,7 void ChartCategoriesAxisY::updateGeometry() | |||
|
97 | 97 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
98 | 98 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
99 | 99 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
100 |
QList<QGraphicsItem *> axis = m_a |
|
|
100 | QList<QGraphicsItem *> axis = m_arrow->childItems(); | |
|
101 | 101 | |
|
102 | 102 | Q_ASSERT(labels.size() == ticksList.size()); |
|
103 | 103 | Q_ASSERT(layout.size() == ticksList.size()); |
@@ -35,7 +35,7 ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter) : Chart(pres | |||
|
35 | 35 | m_grid(new QGraphicsItemGroup(presenter->rootItem())), |
|
36 | 36 | m_shades(new QGraphicsItemGroup(presenter->rootItem())), |
|
37 | 37 | m_labels(new QGraphicsItemGroup(presenter->rootItem())), |
|
38 |
m_a |
|
|
38 | m_arrow(new QGraphicsItemGroup(presenter->rootItem())), | |
|
39 | 39 | m_min(0), |
|
40 | 40 | m_max(0), |
|
41 | 41 | m_animation(0), |
@@ -43,8 +43,8 ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter) : Chart(pres | |||
|
43 | 43 | m_minHeight(0) |
|
44 | 44 | { |
|
45 | 45 | //initial initialization |
|
46 |
m_a |
|
|
47 |
m_a |
|
|
46 | m_arrow->setZValue(ChartPresenter::AxisZValue); | |
|
47 | m_arrow->setHandlesChildEvents(false); | |
|
48 | 48 | |
|
49 | 49 | m_shades->setZValue(ChartPresenter::ShadesZValue); |
|
50 | 50 | m_grid->setZValue(ChartPresenter::GridZValue); |
@@ -71,12 +71,12 void ChartAxis::setLayout(QVector<qreal> &layout) | |||
|
71 | 71 | |
|
72 | 72 | void ChartAxis::createItems(int count) |
|
73 | 73 | { |
|
74 |
if (m_a |
|
|
75 |
m_a |
|
|
74 | if (m_arrow->children().size() == 0) | |
|
75 | m_arrow->addToGroup(new AxisItem(this)); | |
|
76 | 76 | for (int i = 0; i < count; ++i) { |
|
77 | 77 | m_grid->addToGroup(new QGraphicsLineItem()); |
|
78 | 78 | m_labels->addToGroup(new QGraphicsSimpleTextItem()); |
|
79 |
m_a |
|
|
79 | m_arrow->addToGroup(new QGraphicsLineItem()); | |
|
80 | 80 | if ((m_grid->childItems().size())%2 && m_grid->childItems().size()>2) m_shades->addToGroup(new QGraphicsRectItem()); |
|
81 | 81 | } |
|
82 | 82 | } |
@@ -86,7 +86,7 void ChartAxis::deleteItems(int count) | |||
|
86 | 86 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
87 | 87 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
88 | 88 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
89 |
QList<QGraphicsItem *> axis = m_a |
|
|
89 | QList<QGraphicsItem *> axis = m_arrow->childItems(); | |
|
90 | 90 | |
|
91 | 91 | for (int i = 0; i < count; ++i) { |
|
92 | 92 | if (lines.size()%2 && lines.size() > 1) delete(shades.takeLast()); |
@@ -140,14 +140,19 void ChartAxis::updateLayout(QVector<qreal> &layout) | |||
|
140 | 140 | } |
|
141 | 141 | } |
|
142 | 142 | |
|
143 |
void ChartAxis::setA |
|
|
143 | void ChartAxis::setArrowOpacity(qreal opacity) | |
|
144 | 144 | { |
|
145 |
m_a |
|
|
145 | m_arrow->setOpacity(opacity); | |
|
146 | 146 | } |
|
147 | 147 | |
|
148 |
qreal ChartAxis::a |
|
|
148 | qreal ChartAxis::arrowOpacity() const | |
|
149 | 149 | { |
|
150 |
return m_a |
|
|
150 | return m_arrow->opacity(); | |
|
151 | } | |
|
152 | ||
|
153 | void ChartAxis::setArrowVisibility(bool visible) | |
|
154 | { | |
|
155 | m_arrow->setOpacity(visible); | |
|
151 | 156 | } |
|
152 | 157 | |
|
153 | 158 | void ChartAxis::setGridOpacity(qreal opacity) |
@@ -160,6 +165,11 qreal ChartAxis::gridOpacity() const | |||
|
160 | 165 | return m_grid->opacity(); |
|
161 | 166 | } |
|
162 | 167 | |
|
168 | void ChartAxis::setGridVisibility(bool visible) | |
|
169 | { | |
|
170 | m_grid->setOpacity(visible); | |
|
171 | } | |
|
172 | ||
|
163 | 173 | void ChartAxis::setLabelsOpacity(qreal opacity) |
|
164 | 174 | { |
|
165 | 175 | m_labels->setOpacity(opacity); |
@@ -170,6 +180,11 qreal ChartAxis::labelsOpacity() const | |||
|
170 | 180 | return m_labels->opacity(); |
|
171 | 181 | } |
|
172 | 182 | |
|
183 | void ChartAxis::setLabelsVisibility(bool visible) | |
|
184 | { | |
|
185 | m_labels->setOpacity(visible); | |
|
186 | } | |
|
187 | ||
|
173 | 188 | void ChartAxis::setShadesOpacity(qreal opacity) |
|
174 | 189 | { |
|
175 | 190 | m_shades->setOpacity(opacity); |
@@ -180,6 +195,11 qreal ChartAxis::shadesOpacity() const | |||
|
180 | 195 | return m_shades->opacity(); |
|
181 | 196 | } |
|
182 | 197 | |
|
198 | void ChartAxis::setShadesVisibility(bool visible) | |
|
199 | { | |
|
200 | m_shades->setVisible(visible); | |
|
201 | } | |
|
202 | ||
|
183 | 203 | void ChartAxis::setLabelsAngle(int angle) |
|
184 | 204 | { |
|
185 | 205 | foreach(QGraphicsItem* item , m_labels->childItems()) { |
@@ -225,9 +245,9 void ChartAxis::setShadesPen(const QPen &pen) | |||
|
225 | 245 | } |
|
226 | 246 | } |
|
227 | 247 | |
|
228 |
void ChartAxis::setA |
|
|
248 | void ChartAxis::setArrowPen(const QPen &pen) | |
|
229 | 249 | { |
|
230 |
foreach(QGraphicsItem* item , m_a |
|
|
250 | foreach(QGraphicsItem* item , m_arrow->childItems()) { | |
|
231 | 251 | static_cast<QGraphicsLineItem*>(item)->setPen(pen); |
|
232 | 252 | } |
|
233 | 253 | } |
@@ -276,45 +296,16 void ChartAxis::handleAxisUpdated() | |||
|
276 | 296 | { |
|
277 | 297 | if(isEmpty()) return; |
|
278 | 298 | |
|
279 | if (!m_chartAxis->isVisible()) { | |
|
280 | setAxisOpacity(0); | |
|
281 | setGridOpacity(0); | |
|
282 | setLabelsOpacity(0); | |
|
283 | setShadesOpacity(0); | |
|
284 | } | |
|
285 | else { | |
|
286 | ||
|
287 | if (m_chartAxis->isArrowVisible()) { | |
|
288 | setAxisOpacity(100); | |
|
289 | } | |
|
290 | else { | |
|
291 | setAxisOpacity(0); | |
|
292 | } | |
|
293 | 299 | |
|
294 |
|
|
|
295 | setGridOpacity(100); | |
|
296 | } | |
|
297 | else { | |
|
298 | setGridOpacity(0); | |
|
299 | } | |
|
300 | ||
|
301 | if (m_chartAxis->labelsVisible()) { | |
|
302 | setLabelsOpacity(100); | |
|
303 | } | |
|
304 | else { | |
|
305 | setLabelsOpacity(0); | |
|
306 | } | |
|
300 | bool visible = m_chartAxis->isVisible(); | |
|
307 | 301 | |
|
308 | if (m_chartAxis->shadesVisible()) { | |
|
309 | setShadesOpacity(100); | |
|
310 | } | |
|
311 | else { | |
|
312 | setShadesOpacity(0); | |
|
313 | } | |
|
314 | } | |
|
302 | setArrowVisibility(visible && m_chartAxis->isArrowVisible()); | |
|
303 | setGridVisibility(visible && m_chartAxis->isGridLineVisible()); | |
|
304 | setLabelsVisibility(visible && m_chartAxis->labelsVisible()); | |
|
305 | setShadesVisibility(visible && m_chartAxis->shadesVisible()); | |
|
315 | 306 | |
|
316 | 307 | setLabelsAngle(m_chartAxis->labelsAngle()); |
|
317 |
setA |
|
|
308 | setArrowPen(m_chartAxis->axisPen()); | |
|
318 | 309 | setLabelsPen(m_chartAxis->labelsPen()); |
|
319 | 310 | setLabelsBrush(m_chartAxis->labelsBrush()); |
|
320 | 311 | setLabelsFont(m_chartAxis->labelsFont()); |
@@ -324,6 +315,14 void ChartAxis::handleAxisUpdated() | |||
|
324 | 315 | |
|
325 | 316 | } |
|
326 | 317 | |
|
318 | void ChartAxis::hide() | |
|
319 | { | |
|
320 | setArrowVisibility(false); | |
|
321 | setGridVisibility(false); | |
|
322 | setLabelsVisibility(false); | |
|
323 | setShadesVisibility(false); | |
|
324 | } | |
|
325 | ||
|
327 | 326 | void ChartAxis::handleGeometryChanged(const QRectF &rect) |
|
328 | 327 | { |
|
329 | 328 | if(m_rect != rect) |
@@ -52,17 +52,21 public: | |||
|
52 | 52 | |
|
53 | 53 | virtual AxisType axisType() const = 0; |
|
54 | 54 | |
|
55 |
void setA |
|
|
56 |
qreal a |
|
|
55 | void setArrowOpacity(qreal opacity); | |
|
56 | qreal arrowOpacity() const; | |
|
57 | void setArrowVisibility(bool visible); | |
|
57 | 58 | |
|
58 | 59 | void setGridOpacity(qreal opacity); |
|
59 | 60 | qreal gridOpacity() const; |
|
61 | void setGridVisibility(bool visible); | |
|
60 | 62 | |
|
61 | 63 | void setLabelsOpacity(qreal opacity); |
|
62 | 64 | qreal labelsOpacity() const; |
|
65 | void setLabelsVisibility(bool visible); | |
|
63 | 66 | |
|
64 | 67 | void setShadesOpacity(qreal opacity); |
|
65 | 68 | qreal shadesOpacity() const; |
|
69 | void setShadesVisibility(bool visible); | |
|
66 | 70 | |
|
67 | 71 | void setLabelsAngle(int angle); |
|
68 | 72 | int labelsAngle()const { return m_labelsAngle; } |
@@ -70,7 +74,7 public: | |||
|
70 | 74 | void setShadesBrush(const QBrush &brush); |
|
71 | 75 | void setShadesPen(const QPen &pen); |
|
72 | 76 | |
|
73 |
void setA |
|
|
77 | void setArrowPen(const QPen &pen); | |
|
74 | 78 | void setGridPen(const QPen &pen); |
|
75 | 79 | |
|
76 | 80 | void setLabelsPen(const QPen &pen); |
@@ -88,6 +92,8 public: | |||
|
88 | 92 | qreal minimumWidth(); |
|
89 | 93 | qreal minimumHeight(); |
|
90 | 94 | |
|
95 | void hide(); | |
|
96 | ||
|
91 | 97 | protected: |
|
92 | 98 | virtual void updateGeometry() = 0; |
|
93 | 99 | virtual QVector<qreal> calculateLayout() const = 0; |
@@ -112,7 +118,7 protected: | |||
|
112 | 118 | QScopedPointer<QGraphicsItemGroup> m_grid; |
|
113 | 119 | QScopedPointer<QGraphicsItemGroup> m_shades; |
|
114 | 120 | QScopedPointer<QGraphicsItemGroup> m_labels; |
|
115 |
QScopedPointer<QGraphicsItemGroup> m_a |
|
|
121 | QScopedPointer<QGraphicsItemGroup> m_arrow; | |
|
116 | 122 | QVector<qreal> m_layoutVector; |
|
117 | 123 | qreal m_min; |
|
118 | 124 | qreal m_max; |
@@ -88,7 +88,7 void ChartDateTimeAxisX::updateGeometry() | |||
|
88 | 88 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
89 | 89 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
90 | 90 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
91 |
QList<QGraphicsItem *> axis = m_a |
|
|
91 | QList<QGraphicsItem *> axis = m_arrow->childItems(); | |
|
92 | 92 | |
|
93 | 93 | Q_ASSERT(labels.size() == ticksList.size()); |
|
94 | 94 | Q_ASSERT(layout.size() == ticksList.size()); |
@@ -88,7 +88,7 void ChartDateTimeAxisY::updateGeometry() | |||
|
88 | 88 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
89 | 89 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
90 | 90 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
91 |
QList<QGraphicsItem *> axis = m_a |
|
|
91 | QList<QGraphicsItem *> axis = m_arrow->childItems(); | |
|
92 | 92 | |
|
93 | 93 | Q_ASSERT(labels.size() == ticksList.size()); |
|
94 | 94 | Q_ASSERT(layout.size() == ticksList.size()); |
@@ -82,7 +82,7 void ChartIntervalAxisX::updateGeometry() | |||
|
82 | 82 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
83 | 83 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
84 | 84 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
85 |
QList<QGraphicsItem *> axis = m_a |
|
|
85 | QList<QGraphicsItem *> axis = m_arrow->childItems(); | |
|
86 | 86 | |
|
87 | 87 | // Q_ASSERT(labels.size() == ticksList.size()); |
|
88 | 88 | // Q_ASSERT(layout.size() == ticksList.size()); |
@@ -79,7 +79,7 void ChartIntervalAxisY::updateGeometry() | |||
|
79 | 79 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
80 | 80 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
81 | 81 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
82 |
QList<QGraphicsItem *> axis = m_a |
|
|
82 | QList<QGraphicsItem *> axis = m_arrow->childItems(); | |
|
83 | 83 | |
|
84 | 84 | // Q_ASSERT(labels.size() == ticksList.size()); |
|
85 | 85 | // Q_ASSERT(layout.size() == ticksList.size()); |
@@ -72,7 +72,7 void ChartValuesAxisX::updateGeometry() | |||
|
72 | 72 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
73 | 73 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
74 | 74 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
75 |
QList<QGraphicsItem *> axis = m_a |
|
|
75 | QList<QGraphicsItem *> axis = m_arrow->childItems(); | |
|
76 | 76 | |
|
77 | 77 | Q_ASSERT(labels.size() == ticksList.size()); |
|
78 | 78 | Q_ASSERT(layout.size() == ticksList.size()); |
@@ -72,7 +72,7 void ChartValuesAxisY::updateGeometry() | |||
|
72 | 72 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
73 | 73 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
74 | 74 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
75 |
QList<QGraphicsItem *> axis = m_a |
|
|
75 | QList<QGraphicsItem *> axis = m_arrow->childItems(); | |
|
76 | 76 | |
|
77 | 77 | Q_ASSERT(labels.size() == ticksList.size()); |
|
78 | 78 | Q_ASSERT(layout.size() == ticksList.size()); |
@@ -423,10 +423,11 void ChartDataSet::setAxis(QAbstractSeries *series, QAbstractAxis *axis, Qt::Ori | |||
|
423 | 423 | |
|
424 | 424 | QAbstractAxis *oldAxis = seriesAxisMap->take(series); |
|
425 | 425 | QList<QAbstractAxis*> axes = seriesAxisMap->values(); |
|
426 | ||
|
427 | 426 | if(oldAxis) { |
|
428 | 427 | if(axes.indexOf(oldAxis)==-1) { |
|
429 | 428 | emit axisRemoved(oldAxis); |
|
429 | oldAxis->disconnect(); | |
|
430 | QObject::disconnect(domain,0,oldAxis,0); | |
|
430 | 431 | oldAxis->d_ptr->m_dataset=0; |
|
431 | 432 | oldAxis->deleteLater(); |
|
432 | 433 | } |
@@ -99,6 +99,9 void ChartPresenter::handleAxisRemoved(QAbstractAxis* axis) | |||
|
99 | 99 | Q_ASSERT(item); |
|
100 | 100 | selectVisibleAxis(); |
|
101 | 101 | if(m_animator) m_animator->removeAnimation(item); |
|
102 | item->hide(); | |
|
103 | item->disconnect(); | |
|
104 | QObject::disconnect(this,0,item,0); | |
|
102 | 105 | item->deleteLater(); |
|
103 | 106 | } |
|
104 | 107 |
General Comments 0
You need to be logged in to leave comments.
Login now