@@ -1,534 +1,531 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "chartaxis_p.h" |
|
21 | #include "chartaxis_p.h" | |
22 | #include "qabstractaxis.h" |
|
22 | #include "qabstractaxis.h" | |
23 | #include "qabstractaxis_p.h" |
|
23 | #include "qabstractaxis_p.h" | |
24 | #include "chartpresenter_p.h" |
|
24 | #include "chartpresenter_p.h" | |
25 | #include "chartlayout_p.h" |
|
25 | #include "chartlayout_p.h" | |
26 | #include "abstractdomain_p.h" |
|
26 | #include "abstractdomain_p.h" | |
27 | #include <qmath.h> |
|
27 | #include <qmath.h> | |
28 | #include <QDateTime> |
|
28 | #include <QDateTime> | |
29 | #include <QValueAxis> |
|
29 | #include <QValueAxis> | |
30 | #include <QLogValueAxis> |
|
30 | #include <QLogValueAxis> | |
31 | #include <QGraphicsLayout> |
|
31 | #include <QGraphicsLayout> | |
32 | #include <QFontMetrics> |
|
32 | #include <QFontMetrics> | |
33 |
|
33 | |||
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
35 |
|
35 | |||
36 | ChartAxis::ChartAxis(QAbstractAxis *axis, QGraphicsItem* item , bool intervalAxis) |
|
36 | ChartAxis::ChartAxis(QAbstractAxis *axis, QGraphicsItem* item , bool intervalAxis) | |
37 | : ChartElement(item), |
|
37 | : ChartElement(item), | |
38 | m_axis(axis), |
|
38 | m_axis(axis), | |
39 | m_labelsAngle(0), |
|
39 | m_labelsAngle(0), | |
40 | m_grid(new QGraphicsItemGroup(item)), |
|
40 | m_grid(new QGraphicsItemGroup(item)), | |
41 | m_arrow(new QGraphicsItemGroup(item)), |
|
41 | m_arrow(new QGraphicsItemGroup(item)), | |
42 | m_shades(new QGraphicsItemGroup(item)), |
|
42 | m_shades(new QGraphicsItemGroup(item)), | |
43 | m_labels(new QGraphicsItemGroup(item)), |
|
43 | m_labels(new QGraphicsItemGroup(item)), | |
44 | m_title(new QGraphicsSimpleTextItem(item)), |
|
44 | m_title(new QGraphicsSimpleTextItem(item)), | |
45 | m_animation(0), |
|
45 | m_animation(0), | |
46 | m_labelPadding(5), |
|
46 | m_labelPadding(5), | |
47 | m_intervalAxis(intervalAxis) |
|
47 | m_intervalAxis(intervalAxis) | |
48 | { |
|
48 | { | |
49 | Q_ASSERT(item); |
|
49 | Q_ASSERT(item); | |
50 | //initial initialization |
|
50 | //initial initialization | |
51 | m_arrow->setHandlesChildEvents(false); |
|
51 | m_arrow->setHandlesChildEvents(false); | |
52 | m_arrow->setZValue(ChartPresenter::AxisZValue); |
|
52 | m_arrow->setZValue(ChartPresenter::AxisZValue); | |
53 | m_arrow->setVisible(m_axis->isLineVisible()); |
|
|||
54 | m_labels->setZValue(ChartPresenter::AxisZValue); |
|
53 | m_labels->setZValue(ChartPresenter::AxisZValue); | |
55 | m_labels->setVisible(m_axis->labelsVisible()); |
|
|||
56 | m_shades->setZValue(ChartPresenter::ShadesZValue); |
|
54 | m_shades->setZValue(ChartPresenter::ShadesZValue); | |
57 | m_shades->setVisible(m_axis->shadesVisible()); |
|
|||
58 | m_grid->setZValue(ChartPresenter::GridZValue); |
|
55 | m_grid->setZValue(ChartPresenter::GridZValue); | |
59 | m_grid->setVisible(m_axis->isGridLineVisible()); |
|
|||
60 | m_title->setZValue(ChartPresenter::GridZValue); |
|
56 | m_title->setZValue(ChartPresenter::GridZValue); | |
|
57 | handleVisibleChanged(m_axis->isVisible()); | |||
61 | connectSlots(); |
|
58 | connectSlots(); | |
62 |
|
59 | |||
63 | setFlag(QGraphicsItem::ItemHasNoContents,true); |
|
60 | setFlag(QGraphicsItem::ItemHasNoContents,true); | |
64 | } |
|
61 | } | |
65 |
|
62 | |||
66 | void ChartAxis::connectSlots() |
|
63 | void ChartAxis::connectSlots() | |
67 | { |
|
64 | { | |
68 | QObject::connect(m_axis,SIGNAL(visibleChanged(bool)),this,SLOT(handleVisibleChanged(bool))); |
|
65 | QObject::connect(m_axis,SIGNAL(visibleChanged(bool)),this,SLOT(handleVisibleChanged(bool))); | |
69 | QObject::connect(m_axis,SIGNAL(lineVisibleChanged(bool)),this,SLOT(handleArrowVisibleChanged(bool))); |
|
66 | QObject::connect(m_axis,SIGNAL(lineVisibleChanged(bool)),this,SLOT(handleArrowVisibleChanged(bool))); | |
70 | QObject::connect(m_axis,SIGNAL(gridVisibleChanged(bool)),this,SLOT(handleGridVisibleChanged(bool))); |
|
67 | QObject::connect(m_axis,SIGNAL(gridVisibleChanged(bool)),this,SLOT(handleGridVisibleChanged(bool))); | |
71 | QObject::connect(m_axis,SIGNAL(labelsVisibleChanged(bool)),this,SLOT(handleLabelsVisibleChanged(bool))); |
|
68 | QObject::connect(m_axis,SIGNAL(labelsVisibleChanged(bool)),this,SLOT(handleLabelsVisibleChanged(bool))); | |
72 | QObject::connect(m_axis,SIGNAL(shadesVisibleChanged(bool)),this,SLOT(handleShadesVisibleChanged(bool))); |
|
69 | QObject::connect(m_axis,SIGNAL(shadesVisibleChanged(bool)),this,SLOT(handleShadesVisibleChanged(bool))); | |
73 | QObject::connect(m_axis,SIGNAL(labelsAngleChanged(int)),this,SLOT(handleLabelsAngleChanged(int))); |
|
70 | QObject::connect(m_axis,SIGNAL(labelsAngleChanged(int)),this,SLOT(handleLabelsAngleChanged(int))); | |
74 | QObject::connect(m_axis,SIGNAL(linePenChanged(const QPen&)),this,SLOT(handleArrowPenChanged(const QPen&))); |
|
71 | QObject::connect(m_axis,SIGNAL(linePenChanged(const QPen&)),this,SLOT(handleArrowPenChanged(const QPen&))); | |
75 | QObject::connect(m_axis,SIGNAL(labelsPenChanged(const QPen&)),this,SLOT(handleLabelsPenChanged(const QPen&))); |
|
72 | QObject::connect(m_axis,SIGNAL(labelsPenChanged(const QPen&)),this,SLOT(handleLabelsPenChanged(const QPen&))); | |
76 | QObject::connect(m_axis,SIGNAL(labelsBrushChanged(const QBrush&)),this,SLOT(handleLabelsBrushChanged(const QBrush&))); |
|
73 | QObject::connect(m_axis,SIGNAL(labelsBrushChanged(const QBrush&)),this,SLOT(handleLabelsBrushChanged(const QBrush&))); | |
77 | QObject::connect(m_axis,SIGNAL(labelsFontChanged(const QFont&)),this,SLOT(handleLabelsFontChanged(const QFont&))); |
|
74 | QObject::connect(m_axis,SIGNAL(labelsFontChanged(const QFont&)),this,SLOT(handleLabelsFontChanged(const QFont&))); | |
78 | QObject::connect(m_axis,SIGNAL(gridLinePenChanged(const QPen&)),this,SLOT(handleGridPenChanged(const QPen&))); |
|
75 | QObject::connect(m_axis,SIGNAL(gridLinePenChanged(const QPen&)),this,SLOT(handleGridPenChanged(const QPen&))); | |
79 | QObject::connect(m_axis,SIGNAL(shadesPenChanged(const QPen&)),this,SLOT(handleShadesPenChanged(const QPen&))); |
|
76 | QObject::connect(m_axis,SIGNAL(shadesPenChanged(const QPen&)),this,SLOT(handleShadesPenChanged(const QPen&))); | |
80 | QObject::connect(m_axis,SIGNAL(shadesBrushChanged(const QBrush&)),this,SLOT(handleShadesBrushChanged(const QBrush&))); |
|
77 | QObject::connect(m_axis,SIGNAL(shadesBrushChanged(const QBrush&)),this,SLOT(handleShadesBrushChanged(const QBrush&))); | |
81 | QObject::connect(m_axis,SIGNAL(titleTextChanged(const QString&)),this,SLOT(handleTitleTextChanged(const QString&))); |
|
78 | QObject::connect(m_axis,SIGNAL(titleTextChanged(const QString&)),this,SLOT(handleTitleTextChanged(const QString&))); | |
82 | QObject::connect(m_axis,SIGNAL(titleFontChanged(const QFont&)),this,SLOT(handleTitleFontChanged(const QFont&))); |
|
79 | QObject::connect(m_axis,SIGNAL(titleFontChanged(const QFont&)),this,SLOT(handleTitleFontChanged(const QFont&))); | |
83 | QObject::connect(m_axis,SIGNAL(titlePenChanged(const QPen&)),this,SLOT(handleTitlePenChanged(const QPen&))); |
|
80 | QObject::connect(m_axis,SIGNAL(titlePenChanged(const QPen&)),this,SLOT(handleTitlePenChanged(const QPen&))); | |
84 | QObject::connect(m_axis,SIGNAL(titleBrushChanged(const QBrush&)),this,SLOT(handleTitleBrushChanged(const QBrush&))); |
|
81 | QObject::connect(m_axis,SIGNAL(titleBrushChanged(const QBrush&)),this,SLOT(handleTitleBrushChanged(const QBrush&))); | |
85 | QObject::connect(m_axis,SIGNAL(titleVisibleChanged(bool)),this,SLOT(handleTitleVisibleChanged(bool))); |
|
82 | QObject::connect(m_axis,SIGNAL(titleVisibleChanged(bool)),this,SLOT(handleTitleVisibleChanged(bool))); | |
86 | QObject::connect(m_axis->d_ptr.data(),SIGNAL(rangeChanged(qreal,qreal)),this,SLOT(handleRangeChanged(qreal,qreal))); |
|
83 | QObject::connect(m_axis->d_ptr.data(),SIGNAL(rangeChanged(qreal,qreal)),this,SLOT(handleRangeChanged(qreal,qreal))); | |
87 | } |
|
84 | } | |
88 |
|
85 | |||
89 | ChartAxis::~ChartAxis() |
|
86 | ChartAxis::~ChartAxis() | |
90 | { |
|
87 | { | |
91 | } |
|
88 | } | |
92 |
|
89 | |||
93 | void ChartAxis::setAnimation(AxisAnimation *animation) |
|
90 | void ChartAxis::setAnimation(AxisAnimation *animation) | |
94 | { |
|
91 | { | |
95 | m_animation = animation; |
|
92 | m_animation = animation; | |
96 | } |
|
93 | } | |
97 |
|
94 | |||
98 | void ChartAxis::setLayout(QVector<qreal> &layout) |
|
95 | void ChartAxis::setLayout(QVector<qreal> &layout) | |
99 | { |
|
96 | { | |
100 | m_layoutVector = layout; |
|
97 | m_layoutVector = layout; | |
101 | } |
|
98 | } | |
102 |
|
99 | |||
103 | void ChartAxis::createItems(int count) |
|
100 | void ChartAxis::createItems(int count) | |
104 | { |
|
101 | { | |
105 | if (m_arrow->childItems().size() == 0){ |
|
102 | if (m_arrow->childItems().size() == 0){ | |
106 | QGraphicsLineItem* arrow = new ArrowItem(this, this); |
|
103 | QGraphicsLineItem* arrow = new ArrowItem(this, this); | |
107 | arrow->setPen(m_axis->linePen()); |
|
104 | arrow->setPen(m_axis->linePen()); | |
108 | m_arrow->addToGroup(arrow); |
|
105 | m_arrow->addToGroup(arrow); | |
109 | } |
|
106 | } | |
110 |
|
107 | |||
111 | if (m_intervalAxis && m_grid->childItems().size() == 0) { |
|
108 | if (m_intervalAxis && m_grid->childItems().size() == 0) { | |
112 | for (int i = 0 ; i < 2 ; i ++){ |
|
109 | for (int i = 0 ; i < 2 ; i ++){ | |
113 | QGraphicsLineItem* item = new QGraphicsLineItem(this); |
|
110 | QGraphicsLineItem* item = new QGraphicsLineItem(this); | |
114 | item->setPen(m_axis->gridLinePen()); |
|
111 | item->setPen(m_axis->gridLinePen()); | |
115 | m_grid->addToGroup(item); |
|
112 | m_grid->addToGroup(item); | |
116 | } |
|
113 | } | |
117 | } |
|
114 | } | |
118 |
|
115 | |||
119 | for (int i = 0; i < count; ++i) { |
|
116 | for (int i = 0; i < count; ++i) { | |
120 | QGraphicsLineItem* arrow = new QGraphicsLineItem(this); |
|
117 | QGraphicsLineItem* arrow = new QGraphicsLineItem(this); | |
121 | arrow->setPen(m_axis->linePen()); |
|
118 | arrow->setPen(m_axis->linePen()); | |
122 | QGraphicsLineItem* grid = new QGraphicsLineItem(this); |
|
119 | QGraphicsLineItem* grid = new QGraphicsLineItem(this); | |
123 | grid->setPen(m_axis->gridLinePen()); |
|
120 | grid->setPen(m_axis->gridLinePen()); | |
124 | QGraphicsSimpleTextItem* label = new QGraphicsSimpleTextItem(this); |
|
121 | QGraphicsSimpleTextItem* label = new QGraphicsSimpleTextItem(this); | |
125 | label->setFont(m_axis->labelsFont()); |
|
122 | label->setFont(m_axis->labelsFont()); | |
126 | label->setPen(m_axis->labelsPen()); |
|
123 | label->setPen(m_axis->labelsPen()); | |
127 | label->setBrush(m_axis->labelsBrush()); |
|
124 | label->setBrush(m_axis->labelsBrush()); | |
128 | m_arrow->addToGroup(arrow); |
|
125 | m_arrow->addToGroup(arrow); | |
129 | m_grid->addToGroup(grid); |
|
126 | m_grid->addToGroup(grid); | |
130 | m_labels->addToGroup(label); |
|
127 | m_labels->addToGroup(label); | |
131 |
|
128 | |||
132 | if ((m_grid->childItems().size()) % 2 && m_grid->childItems().size() > 2){ |
|
129 | if ((m_grid->childItems().size()) % 2 && m_grid->childItems().size() > 2){ | |
133 | QGraphicsRectItem* shades = new QGraphicsRectItem(this); |
|
130 | QGraphicsRectItem* shades = new QGraphicsRectItem(this); | |
134 | shades->setPen(m_axis->shadesPen()); |
|
131 | shades->setPen(m_axis->shadesPen()); | |
135 | shades->setBrush(m_axis->shadesBrush()); |
|
132 | shades->setBrush(m_axis->shadesBrush()); | |
136 | m_shades->addToGroup(shades); |
|
133 | m_shades->addToGroup(shades); | |
137 | } |
|
134 | } | |
138 | } |
|
135 | } | |
139 |
|
136 | |||
140 | } |
|
137 | } | |
141 |
|
138 | |||
142 | void ChartAxis::deleteItems(int count) |
|
139 | void ChartAxis::deleteItems(int count) | |
143 | { |
|
140 | { | |
144 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
141 | QList<QGraphicsItem *> lines = m_grid->childItems(); | |
145 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
142 | QList<QGraphicsItem *> labels = m_labels->childItems(); | |
146 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
143 | QList<QGraphicsItem *> shades = m_shades->childItems(); | |
147 | QList<QGraphicsItem *> axis = m_arrow->childItems(); |
|
144 | QList<QGraphicsItem *> axis = m_arrow->childItems(); | |
148 |
|
145 | |||
149 | for (int i = 0; i < count; ++i) { |
|
146 | for (int i = 0; i < count; ++i) { | |
150 | if (lines.size() % 2 && lines.size() > 1) |
|
147 | if (lines.size() % 2 && lines.size() > 1) | |
151 | delete(shades.takeLast()); |
|
148 | delete(shades.takeLast()); | |
152 | delete(lines.takeLast()); |
|
149 | delete(lines.takeLast()); | |
153 | delete(labels.takeLast()); |
|
150 | delete(labels.takeLast()); | |
154 | delete(axis.takeLast()); |
|
151 | delete(axis.takeLast()); | |
155 | } |
|
152 | } | |
156 | } |
|
153 | } | |
157 |
|
154 | |||
158 | void ChartAxis::updateLayout(QVector<qreal> &layout) |
|
155 | void ChartAxis::updateLayout(QVector<qreal> &layout) | |
159 | { |
|
156 | { | |
160 | int diff = m_layoutVector.size() - layout.size(); |
|
157 | int diff = m_layoutVector.size() - layout.size(); | |
161 |
|
158 | |||
162 | if (diff > 0) |
|
159 | if (diff > 0) | |
163 | deleteItems(diff); |
|
160 | deleteItems(diff); | |
164 | else if (diff < 0) |
|
161 | else if (diff < 0) | |
165 | createItems(-diff); |
|
162 | createItems(-diff); | |
166 |
|
163 | |||
167 | if (m_animation) { |
|
164 | if (m_animation) { | |
168 | switch (presenter()->state()) { |
|
165 | switch (presenter()->state()) { | |
169 | case ChartPresenter::ZoomInState: |
|
166 | case ChartPresenter::ZoomInState: | |
170 | m_animation->setAnimationType(AxisAnimation::ZoomInAnimation); |
|
167 | m_animation->setAnimationType(AxisAnimation::ZoomInAnimation); | |
171 | m_animation->setAnimationPoint(presenter()->statePoint()); |
|
168 | m_animation->setAnimationPoint(presenter()->statePoint()); | |
172 | break; |
|
169 | break; | |
173 | case ChartPresenter::ZoomOutState: |
|
170 | case ChartPresenter::ZoomOutState: | |
174 | m_animation->setAnimationType(AxisAnimation::ZoomOutAnimation); |
|
171 | m_animation->setAnimationType(AxisAnimation::ZoomOutAnimation); | |
175 | m_animation->setAnimationPoint(presenter()->statePoint()); |
|
172 | m_animation->setAnimationPoint(presenter()->statePoint()); | |
176 | break; |
|
173 | break; | |
177 | case ChartPresenter::ScrollUpState: |
|
174 | case ChartPresenter::ScrollUpState: | |
178 | case ChartPresenter::ScrollLeftState: |
|
175 | case ChartPresenter::ScrollLeftState: | |
179 | m_animation->setAnimationType(AxisAnimation::MoveBackwordAnimation); |
|
176 | m_animation->setAnimationType(AxisAnimation::MoveBackwordAnimation); | |
180 | break; |
|
177 | break; | |
181 | case ChartPresenter::ScrollDownState: |
|
178 | case ChartPresenter::ScrollDownState: | |
182 | case ChartPresenter::ScrollRightState: |
|
179 | case ChartPresenter::ScrollRightState: | |
183 | m_animation->setAnimationType(AxisAnimation::MoveForwardAnimation); |
|
180 | m_animation->setAnimationType(AxisAnimation::MoveForwardAnimation); | |
184 | break; |
|
181 | break; | |
185 | case ChartPresenter::ShowState: |
|
182 | case ChartPresenter::ShowState: | |
186 | m_animation->setAnimationType(AxisAnimation::DefaultAnimation); |
|
183 | m_animation->setAnimationType(AxisAnimation::DefaultAnimation); | |
187 | break; |
|
184 | break; | |
188 | } |
|
185 | } | |
189 | m_animation->setValues(m_layoutVector, layout); |
|
186 | m_animation->setValues(m_layoutVector, layout); | |
190 | presenter()->startAnimation(m_animation); |
|
187 | presenter()->startAnimation(m_animation); | |
191 | } else { |
|
188 | } else { | |
192 | setLayout(layout); |
|
189 | setLayout(layout); | |
193 | updateGeometry(); |
|
190 | updateGeometry(); | |
194 | } |
|
191 | } | |
195 | } |
|
192 | } | |
196 |
|
193 | |||
197 | void ChartAxis::setLabelPadding(int padding) |
|
194 | void ChartAxis::setLabelPadding(int padding) | |
198 | { |
|
195 | { | |
199 | m_labelPadding = padding; |
|
196 | m_labelPadding = padding; | |
200 | } |
|
197 | } | |
201 |
|
198 | |||
202 | bool ChartAxis::isEmpty() |
|
199 | bool ChartAxis::isEmpty() | |
203 | { |
|
200 | { | |
204 | return m_axisRect.isEmpty() || m_gridRect.isEmpty() || qFuzzyCompare(min(),max()); |
|
201 | return m_axisRect.isEmpty() || m_gridRect.isEmpty() || qFuzzyCompare(min(),max()); | |
205 | } |
|
202 | } | |
206 |
|
203 | |||
207 | void ChartAxis::setGeometry(const QRectF &axis, const QRectF &grid) |
|
204 | void ChartAxis::setGeometry(const QRectF &axis, const QRectF &grid) | |
208 | { |
|
205 | { | |
209 | m_gridRect = grid; |
|
206 | m_gridRect = grid; | |
210 | m_axisRect = axis; |
|
207 | m_axisRect = axis; | |
211 |
|
208 | |||
212 | if (isEmpty()) |
|
209 | if (isEmpty()) | |
213 | return; |
|
210 | return; | |
214 |
|
211 | |||
215 | QVector<qreal> layout = calculateLayout(); |
|
212 | QVector<qreal> layout = calculateLayout(); | |
216 | updateLayout(layout); |
|
213 | updateLayout(layout); | |
217 | } |
|
214 | } | |
218 |
|
215 | |||
219 | qreal ChartAxis::min() const |
|
216 | qreal ChartAxis::min() const | |
220 | { |
|
217 | { | |
221 | return m_axis->d_ptr->min(); |
|
218 | return m_axis->d_ptr->min(); | |
222 | } |
|
219 | } | |
223 |
|
220 | |||
224 | qreal ChartAxis::max() const |
|
221 | qreal ChartAxis::max() const | |
225 | { |
|
222 | { | |
226 | return m_axis->d_ptr->max(); |
|
223 | return m_axis->d_ptr->max(); | |
227 | } |
|
224 | } | |
228 |
|
225 | |||
229 | QFont ChartAxis::font() const |
|
226 | QFont ChartAxis::font() const | |
230 | { |
|
227 | { | |
231 | return m_axis->labelsFont(); |
|
228 | return m_axis->labelsFont(); | |
232 | } |
|
229 | } | |
233 |
|
230 | |||
234 | QFont ChartAxis::titleFont() const |
|
231 | QFont ChartAxis::titleFont() const | |
235 | { |
|
232 | { | |
236 | return m_axis->titleFont(); |
|
233 | return m_axis->titleFont(); | |
237 | } |
|
234 | } | |
238 |
|
235 | |||
239 | QString ChartAxis::titleText() const |
|
236 | QString ChartAxis::titleText() const | |
240 | { |
|
237 | { | |
241 | return m_axis->titleText(); |
|
238 | return m_axis->titleText(); | |
242 | } |
|
239 | } | |
243 |
|
240 | |||
244 | void ChartAxis::axisSelected() |
|
241 | void ChartAxis::axisSelected() | |
245 | { |
|
242 | { | |
246 | emit clicked(); |
|
243 | emit clicked(); | |
247 | } |
|
244 | } | |
248 |
|
245 | |||
249 | Qt::Orientation ChartAxis::orientation() const |
|
246 | Qt::Orientation ChartAxis::orientation() const | |
250 | { |
|
247 | { | |
251 | return m_axis->orientation(); |
|
248 | return m_axis->orientation(); | |
252 | } |
|
249 | } | |
253 |
|
250 | |||
254 | Qt::Alignment ChartAxis::alignment() const |
|
251 | Qt::Alignment ChartAxis::alignment() const | |
255 | { |
|
252 | { | |
256 | return m_axis->alignment(); |
|
253 | return m_axis->alignment(); | |
257 | } |
|
254 | } | |
258 |
|
255 | |||
259 | void ChartAxis::setLabels(const QStringList &labels) |
|
256 | void ChartAxis::setLabels(const QStringList &labels) | |
260 | { |
|
257 | { | |
261 | m_labelsList = labels; |
|
258 | m_labelsList = labels; | |
262 | } |
|
259 | } | |
263 |
|
260 | |||
264 | QSizeF ChartAxis::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
261 | QSizeF ChartAxis::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const | |
265 | { |
|
262 | { | |
266 | Q_UNUSED(which); |
|
263 | Q_UNUSED(which); | |
267 | Q_UNUSED(constraint); |
|
264 | Q_UNUSED(constraint); | |
268 | return QSizeF(); |
|
265 | return QSizeF(); | |
269 | } |
|
266 | } | |
270 |
|
267 | |||
271 | //handlers |
|
268 | //handlers | |
272 |
|
269 | |||
273 | void ChartAxis::handleArrowVisibleChanged(bool visible) |
|
270 | void ChartAxis::handleArrowVisibleChanged(bool visible) | |
274 | { |
|
271 | { | |
275 | m_arrow->setVisible(visible); |
|
272 | m_arrow->setVisible(visible); | |
276 | } |
|
273 | } | |
277 |
|
274 | |||
278 | void ChartAxis::handleGridVisibleChanged(bool visible) |
|
275 | void ChartAxis::handleGridVisibleChanged(bool visible) | |
279 | { |
|
276 | { | |
280 | m_grid->setVisible(visible); |
|
277 | m_grid->setVisible(visible); | |
281 | } |
|
278 | } | |
282 |
|
279 | |||
283 | void ChartAxis::handleLabelsVisibleChanged(bool visible) |
|
280 | void ChartAxis::handleLabelsVisibleChanged(bool visible) | |
284 | { |
|
281 | { | |
285 | m_labels->setVisible(visible); |
|
282 | m_labels->setVisible(visible); | |
286 | } |
|
283 | } | |
287 |
|
284 | |||
288 | void ChartAxis::handleShadesVisibleChanged(bool visible) |
|
285 | void ChartAxis::handleShadesVisibleChanged(bool visible) | |
289 | { |
|
286 | { | |
290 | m_shades->setVisible(visible); |
|
287 | m_shades->setVisible(visible); | |
291 | } |
|
288 | } | |
292 |
|
289 | |||
293 | void ChartAxis::handleTitleVisibleChanged(bool visible) |
|
290 | void ChartAxis::handleTitleVisibleChanged(bool visible) | |
294 | { |
|
291 | { | |
295 | m_title->setVisible(visible); |
|
292 | m_title->setVisible(visible); | |
296 | presenter()->layout()->invalidate(); |
|
293 | presenter()->layout()->invalidate(); | |
297 | } |
|
294 | } | |
298 |
|
295 | |||
299 | void ChartAxis::handleLabelsAngleChanged(int angle) |
|
296 | void ChartAxis::handleLabelsAngleChanged(int angle) | |
300 | { |
|
297 | { | |
301 | foreach (QGraphicsItem *item, m_labels->childItems()) |
|
298 | foreach (QGraphicsItem *item, m_labels->childItems()) | |
302 | item->setRotation(angle); |
|
299 | item->setRotation(angle); | |
303 |
|
300 | |||
304 | m_labelsAngle = angle; |
|
301 | m_labelsAngle = angle; | |
305 | } |
|
302 | } | |
306 |
|
303 | |||
307 | void ChartAxis::handleLabelsPenChanged(const QPen &pen) |
|
304 | void ChartAxis::handleLabelsPenChanged(const QPen &pen) | |
308 | { |
|
305 | { | |
309 | foreach (QGraphicsItem *item , m_labels->childItems()) |
|
306 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
310 | static_cast<QGraphicsSimpleTextItem *>(item)->setPen(pen); |
|
307 | static_cast<QGraphicsSimpleTextItem *>(item)->setPen(pen); | |
311 | } |
|
308 | } | |
312 |
|
309 | |||
313 | void ChartAxis::handleLabelsBrushChanged(const QBrush &brush) |
|
310 | void ChartAxis::handleLabelsBrushChanged(const QBrush &brush) | |
314 | { |
|
311 | { | |
315 | foreach (QGraphicsItem *item , m_labels->childItems()) |
|
312 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
316 | static_cast<QGraphicsSimpleTextItem *>(item)->setBrush(brush); |
|
313 | static_cast<QGraphicsSimpleTextItem *>(item)->setBrush(brush); | |
317 | } |
|
314 | } | |
318 |
|
315 | |||
319 | void ChartAxis::handleLabelsFontChanged(const QFont &font) |
|
316 | void ChartAxis::handleLabelsFontChanged(const QFont &font) | |
320 | { |
|
317 | { | |
321 | foreach (QGraphicsItem *item , m_labels->childItems()) |
|
318 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
322 | static_cast<QGraphicsSimpleTextItem *>(item)->setFont(font); |
|
319 | static_cast<QGraphicsSimpleTextItem *>(item)->setFont(font); | |
323 | QGraphicsLayoutItem::updateGeometry(); |
|
320 | QGraphicsLayoutItem::updateGeometry(); | |
324 | presenter()->layout()->invalidate(); |
|
321 | presenter()->layout()->invalidate(); | |
325 | } |
|
322 | } | |
326 |
|
323 | |||
327 | void ChartAxis::handleShadesBrushChanged(const QBrush &brush) |
|
324 | void ChartAxis::handleShadesBrushChanged(const QBrush &brush) | |
328 | { |
|
325 | { | |
329 | foreach (QGraphicsItem *item , m_shades->childItems()) |
|
326 | foreach (QGraphicsItem *item , m_shades->childItems()) | |
330 | static_cast<QGraphicsRectItem *>(item)->setBrush(brush); |
|
327 | static_cast<QGraphicsRectItem *>(item)->setBrush(brush); | |
331 | } |
|
328 | } | |
332 |
|
329 | |||
333 | void ChartAxis::handleShadesPenChanged(const QPen &pen) |
|
330 | void ChartAxis::handleShadesPenChanged(const QPen &pen) | |
334 | { |
|
331 | { | |
335 | foreach (QGraphicsItem *item , m_shades->childItems()) |
|
332 | foreach (QGraphicsItem *item , m_shades->childItems()) | |
336 | static_cast<QGraphicsRectItem *>(item)->setPen(pen); |
|
333 | static_cast<QGraphicsRectItem *>(item)->setPen(pen); | |
337 | } |
|
334 | } | |
338 |
|
335 | |||
339 | void ChartAxis::handleArrowPenChanged(const QPen &pen) |
|
336 | void ChartAxis::handleArrowPenChanged(const QPen &pen) | |
340 | { |
|
337 | { | |
341 | foreach (QGraphicsItem *item , m_arrow->childItems()) |
|
338 | foreach (QGraphicsItem *item , m_arrow->childItems()) | |
342 | static_cast<QGraphicsLineItem *>(item)->setPen(pen); |
|
339 | static_cast<QGraphicsLineItem *>(item)->setPen(pen); | |
343 | } |
|
340 | } | |
344 |
|
341 | |||
345 | void ChartAxis::handleGridPenChanged(const QPen &pen) |
|
342 | void ChartAxis::handleGridPenChanged(const QPen &pen) | |
346 | { |
|
343 | { | |
347 | foreach (QGraphicsItem *item , m_grid->childItems()) |
|
344 | foreach (QGraphicsItem *item , m_grid->childItems()) | |
348 | static_cast<QGraphicsLineItem *>(item)->setPen(pen); |
|
345 | static_cast<QGraphicsLineItem *>(item)->setPen(pen); | |
349 | } |
|
346 | } | |
350 |
|
347 | |||
351 | void ChartAxis::handleTitleTextChanged(const QString &title) |
|
348 | void ChartAxis::handleTitleTextChanged(const QString &title) | |
352 | { |
|
349 | { | |
353 | Q_UNUSED(title) |
|
350 | Q_UNUSED(title) | |
354 | QGraphicsLayoutItem::updateGeometry(); |
|
351 | QGraphicsLayoutItem::updateGeometry(); | |
355 | presenter()->layout()->invalidate(); |
|
352 | presenter()->layout()->invalidate(); | |
356 | } |
|
353 | } | |
357 |
|
354 | |||
358 |
|
355 | |||
359 | void ChartAxis::handleTitlePenChanged(const QPen &pen) |
|
356 | void ChartAxis::handleTitlePenChanged(const QPen &pen) | |
360 | { |
|
357 | { | |
361 | m_title->setPen(pen); |
|
358 | m_title->setPen(pen); | |
362 | } |
|
359 | } | |
363 |
|
360 | |||
364 | void ChartAxis::handleTitleBrushChanged(const QBrush &brush) |
|
361 | void ChartAxis::handleTitleBrushChanged(const QBrush &brush) | |
365 | { |
|
362 | { | |
366 | m_title->setBrush(brush); |
|
363 | m_title->setBrush(brush); | |
367 | } |
|
364 | } | |
368 |
|
365 | |||
369 | void ChartAxis::handleTitleFontChanged(const QFont &font) |
|
366 | void ChartAxis::handleTitleFontChanged(const QFont &font) | |
370 | { |
|
367 | { | |
371 | if(m_title->font() != font){ |
|
368 | if(m_title->font() != font){ | |
372 | m_title->setFont(font); |
|
369 | m_title->setFont(font); | |
373 | QGraphicsLayoutItem::updateGeometry(); |
|
370 | QGraphicsLayoutItem::updateGeometry(); | |
374 | presenter()->layout()->invalidate(); |
|
371 | presenter()->layout()->invalidate(); | |
375 | } |
|
372 | } | |
376 | } |
|
373 | } | |
377 |
|
374 | |||
378 | void ChartAxis::handleVisibleChanged(bool visible) |
|
375 | void ChartAxis::handleVisibleChanged(bool visible) | |
379 | { |
|
376 | { | |
380 | setVisible(visible); |
|
377 | setVisible(visible); | |
381 | if(!visible) { |
|
378 | if(!visible) { | |
382 | m_grid->setVisible(visible); |
|
379 | m_grid->setVisible(visible); | |
383 | m_arrow->setVisible(visible); |
|
380 | m_arrow->setVisible(visible); | |
384 | m_shades->setVisible(visible); |
|
381 | m_shades->setVisible(visible); | |
385 | m_labels->setVisible(visible); |
|
382 | m_labels->setVisible(visible); | |
386 | m_title->setVisible(visible); |
|
383 | m_title->setVisible(visible); | |
387 | }else { |
|
384 | }else { | |
388 | m_grid->setVisible(m_axis->isGridLineVisible()); |
|
385 | m_grid->setVisible(m_axis->isGridLineVisible()); | |
389 | m_arrow->setVisible(m_axis->isLineVisible()); |
|
386 | m_arrow->setVisible(m_axis->isLineVisible()); | |
390 | m_shades->setVisible(m_axis->shadesVisible()); |
|
387 | m_shades->setVisible(m_axis->shadesVisible()); | |
391 | m_labels->setVisible(m_axis->labelsVisible()); |
|
388 | m_labels->setVisible(m_axis->labelsVisible()); | |
392 | m_title->setVisible(m_axis->isTitleVisible()); |
|
389 | m_title->setVisible(m_axis->isTitleVisible()); | |
393 | } |
|
390 | } | |
394 |
|
391 | |||
395 | presenter()->layout()->invalidate(); |
|
392 | if(presenter()) presenter()->layout()->invalidate(); | |
396 | } |
|
393 | } | |
397 |
|
394 | |||
398 | void ChartAxis::handleRangeChanged(qreal min, qreal max) |
|
395 | void ChartAxis::handleRangeChanged(qreal min, qreal max) | |
399 | { |
|
396 | { | |
400 | Q_UNUSED(min); |
|
397 | Q_UNUSED(min); | |
401 | Q_UNUSED(max); |
|
398 | Q_UNUSED(max); | |
402 |
|
399 | |||
403 | if (!isEmpty()) { |
|
400 | if (!isEmpty()) { | |
404 |
|
401 | |||
405 | QVector<qreal> layout = calculateLayout(); |
|
402 | QVector<qreal> layout = calculateLayout(); | |
406 | updateLayout(layout); |
|
403 | updateLayout(layout); | |
407 | QSizeF before = effectiveSizeHint(Qt::PreferredSize); |
|
404 | QSizeF before = effectiveSizeHint(Qt::PreferredSize); | |
408 | QSizeF after = sizeHint(Qt::PreferredSize); |
|
405 | QSizeF after = sizeHint(Qt::PreferredSize); | |
409 |
|
406 | |||
410 | if (before != after) { |
|
407 | if (before != after) { | |
411 | QGraphicsLayoutItem::updateGeometry(); |
|
408 | QGraphicsLayoutItem::updateGeometry(); | |
412 | //we don't want to call invalidate on layout, since it will change minimum size of component, |
|
409 | //we don't want to call invalidate on layout, since it will change minimum size of component, | |
413 | //which we would like to avoid since it causes nasty flips when scrolling or zooming, |
|
410 | //which we would like to avoid since it causes nasty flips when scrolling or zooming, | |
414 | //instead recalculate layout and use plotArea for extra space. |
|
411 | //instead recalculate layout and use plotArea for extra space. | |
415 | presenter()->layout()->setGeometry(presenter()->layout()->geometry()); |
|
412 | presenter()->layout()->setGeometry(presenter()->layout()->geometry()); | |
416 | } |
|
413 | } | |
417 | } |
|
414 | } | |
418 |
|
415 | |||
419 | } |
|
416 | } | |
420 |
|
417 | |||
421 | //helpers |
|
418 | //helpers | |
422 |
|
419 | |||
423 | QStringList ChartAxis::createValueLabels(qreal min, qreal max, int ticks,const QString& format) |
|
420 | QStringList ChartAxis::createValueLabels(qreal min, qreal max, int ticks,const QString& format) | |
424 | { |
|
421 | { | |
425 | //TODO: Q_ASSERT(m_max > m_min); |
|
422 | //TODO: Q_ASSERT(m_max > m_min); | |
426 | //TODO: Q_ASSERT(ticks > 1); |
|
423 | //TODO: Q_ASSERT(ticks > 1); | |
427 |
|
424 | |||
428 | QStringList labels; |
|
425 | QStringList labels; | |
429 |
|
426 | |||
430 | if(max <= min || ticks < 1){ |
|
427 | if(max <= min || ticks < 1){ | |
431 | return labels; |
|
428 | return labels; | |
432 | } |
|
429 | } | |
433 |
|
430 | |||
434 | int n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0); |
|
431 | int n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0); | |
435 | n++; |
|
432 | n++; | |
436 |
|
433 | |||
437 | if (format.isNull()) { |
|
434 | if (format.isNull()) { | |
438 | for (int i = 0; i < ticks; i++) { |
|
435 | for (int i = 0; i < ticks; i++) { | |
439 | qreal value = min + (i * (max - min) / (ticks - 1)); |
|
436 | qreal value = min + (i * (max - min) / (ticks - 1)); | |
440 | labels << QString::number(value, 'f', n); |
|
437 | labels << QString::number(value, 'f', n); | |
441 | } |
|
438 | } | |
442 | } else { |
|
439 | } else { | |
443 | QByteArray array = format.toLatin1(); |
|
440 | QByteArray array = format.toLatin1(); | |
444 | for (int i = 0; i < ticks; i++) { |
|
441 | for (int i = 0; i < ticks; i++) { | |
445 | qreal value = min + (i * (max - min) / (ticks - 1)); |
|
442 | qreal value = min + (i * (max - min) / (ticks - 1)); | |
446 | if (format.contains("d") |
|
443 | if (format.contains("d") | |
447 | || format.contains("i") |
|
444 | || format.contains("i") | |
448 | || format.contains("c")) |
|
445 | || format.contains("c")) | |
449 | labels << QString().sprintf(array, (qint64)value); |
|
446 | labels << QString().sprintf(array, (qint64)value); | |
450 | else if (format.contains("u") |
|
447 | else if (format.contains("u") | |
451 | || format.contains("o") |
|
448 | || format.contains("o") | |
452 | || format.contains("x", Qt::CaseInsensitive)) |
|
449 | || format.contains("x", Qt::CaseInsensitive)) | |
453 | labels << QString().sprintf(array, (quint64)value); |
|
450 | labels << QString().sprintf(array, (quint64)value); | |
454 | else if (format.contains("f", Qt::CaseInsensitive) |
|
451 | else if (format.contains("f", Qt::CaseInsensitive) | |
455 | || format.contains("e", Qt::CaseInsensitive) |
|
452 | || format.contains("e", Qt::CaseInsensitive) | |
456 | || format.contains("g", Qt::CaseInsensitive)) |
|
453 | || format.contains("g", Qt::CaseInsensitive)) | |
457 | labels << QString().sprintf(array, value); |
|
454 | labels << QString().sprintf(array, value); | |
458 | else |
|
455 | else | |
459 | labels << QString(); |
|
456 | labels << QString(); | |
460 | } |
|
457 | } | |
461 | } |
|
458 | } | |
462 |
|
459 | |||
463 | return labels; |
|
460 | return labels; | |
464 | } |
|
461 | } | |
465 |
|
462 | |||
466 | QStringList ChartAxis::createLogValueLabels(qreal min, qreal max, qreal base, int ticks, const QString& format) |
|
463 | QStringList ChartAxis::createLogValueLabels(qreal min, qreal max, qreal base, int ticks, const QString& format) | |
467 | { |
|
464 | { | |
468 | // Q_ASSERT(m_max > m_min); |
|
465 | // Q_ASSERT(m_max > m_min); | |
469 | // Q_ASSERT(ticks > 1); |
|
466 | // Q_ASSERT(ticks > 1); | |
470 |
|
467 | |||
471 | QStringList labels; |
|
468 | QStringList labels; | |
472 |
|
469 | |||
473 | int n = 0; |
|
470 | int n = 0; | |
474 | if (ticks > 1) |
|
471 | if (ticks > 1) | |
475 | n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0); |
|
472 | n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0); | |
476 | n++; |
|
473 | n++; | |
477 |
|
474 | |||
478 | int firstTick; |
|
475 | int firstTick; | |
479 | if (base > 1) |
|
476 | if (base > 1) | |
480 | firstTick = ceil(log10(min) / log10(base)); |
|
477 | firstTick = ceil(log10(min) / log10(base)); | |
481 | else |
|
478 | else | |
482 | firstTick = ceil(log10(max) / log10(base)); |
|
479 | firstTick = ceil(log10(max) / log10(base)); | |
483 |
|
480 | |||
484 | if (format.isNull()) { |
|
481 | if (format.isNull()) { | |
485 | for (int i = firstTick; i < ticks + firstTick; i++) { |
|
482 | for (int i = firstTick; i < ticks + firstTick; i++) { | |
486 | qreal value = qPow(base, i); |
|
483 | qreal value = qPow(base, i); | |
487 | labels << QString::number(value, 'f', n); |
|
484 | labels << QString::number(value, 'f', n); | |
488 | } |
|
485 | } | |
489 | } else { |
|
486 | } else { | |
490 | QByteArray array = format.toLatin1(); |
|
487 | QByteArray array = format.toLatin1(); | |
491 | for (int i = firstTick; i < ticks + firstTick; i++) { |
|
488 | for (int i = firstTick; i < ticks + firstTick; i++) { | |
492 | qreal value = qPow(base, i); |
|
489 | qreal value = qPow(base, i); | |
493 | if (format.contains("d") |
|
490 | if (format.contains("d") | |
494 | || format.contains("i") |
|
491 | || format.contains("i") | |
495 | || format.contains("c")) |
|
492 | || format.contains("c")) | |
496 | labels << QString().sprintf(array, (qint64)value); |
|
493 | labels << QString().sprintf(array, (qint64)value); | |
497 | else if (format.contains("u") |
|
494 | else if (format.contains("u") | |
498 | || format.contains("o") |
|
495 | || format.contains("o") | |
499 | || format.contains("x", Qt::CaseInsensitive)) |
|
496 | || format.contains("x", Qt::CaseInsensitive)) | |
500 | labels << QString().sprintf(array, (quint64)value); |
|
497 | labels << QString().sprintf(array, (quint64)value); | |
501 | else if (format.contains("f", Qt::CaseInsensitive) |
|
498 | else if (format.contains("f", Qt::CaseInsensitive) | |
502 | || format.contains("e", Qt::CaseInsensitive) |
|
499 | || format.contains("e", Qt::CaseInsensitive) | |
503 | || format.contains("g", Qt::CaseInsensitive)) |
|
500 | || format.contains("g", Qt::CaseInsensitive)) | |
504 | labels << QString().sprintf(array, value); |
|
501 | labels << QString().sprintf(array, value); | |
505 | else |
|
502 | else | |
506 | labels << QString(); |
|
503 | labels << QString(); | |
507 | } |
|
504 | } | |
508 | } |
|
505 | } | |
509 |
|
506 | |||
510 | return labels; |
|
507 | return labels; | |
511 | } |
|
508 | } | |
512 |
|
509 | |||
513 | QStringList ChartAxis::createDateTimeLabels(qreal min, qreal max,int ticks,const QString& format) |
|
510 | QStringList ChartAxis::createDateTimeLabels(qreal min, qreal max,int ticks,const QString& format) | |
514 | { |
|
511 | { | |
515 | //TODO: Q_ASSERT(m_max > m_min); |
|
512 | //TODO: Q_ASSERT(m_max > m_min); | |
516 | //TODO: Q_ASSERT(ticks > 1); |
|
513 | //TODO: Q_ASSERT(ticks > 1); | |
517 | QStringList labels; |
|
514 | QStringList labels; | |
518 |
|
515 | |||
519 | if(max <= min || ticks < 1) { |
|
516 | if(max <= min || ticks < 1) { | |
520 | return labels; |
|
517 | return labels; | |
521 | } |
|
518 | } | |
522 |
|
519 | |||
523 | int n = qMax(int(-floor(log10((max - min) / (ticks - 1)))), 0); |
|
520 | int n = qMax(int(-floor(log10((max - min) / (ticks - 1)))), 0); | |
524 | n++; |
|
521 | n++; | |
525 | for (int i = 0; i < ticks; i++) { |
|
522 | for (int i = 0; i < ticks; i++) { | |
526 | qreal value = min + (i * (max - min) / (ticks - 1)); |
|
523 | qreal value = min + (i * (max - min) / (ticks - 1)); | |
527 | labels << QDateTime::fromMSecsSinceEpoch(value).toString(format); |
|
524 | labels << QDateTime::fromMSecsSinceEpoch(value).toString(format); | |
528 | } |
|
525 | } | |
529 | return labels; |
|
526 | return labels; | |
530 | } |
|
527 | } | |
531 |
|
528 | |||
532 | #include "moc_chartaxis_p.cpp" |
|
529 | #include "moc_chartaxis_p.cpp" | |
533 |
|
530 | |||
534 | QTCOMMERCIALCHART_END_NAMESPACE |
|
531 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,870 +1,871 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "qabstractaxis.h" |
|
21 | #include "qabstractaxis.h" | |
22 | #include "qabstractaxis_p.h" |
|
22 | #include "qabstractaxis_p.h" | |
23 | #include "chartdataset_p.h" |
|
23 | #include "chartdataset_p.h" | |
24 | #include "charttheme_p.h" |
|
24 | #include "charttheme_p.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | /*! |
|
28 | /*! | |
29 | \class QAbstractAxis |
|
29 | \class QAbstractAxis | |
30 | \brief The QAbstractAxis class is used for manipulating chart's axis. |
|
30 | \brief The QAbstractAxis class is used for manipulating chart's axis. | |
31 | \mainclass |
|
31 | \mainclass | |
32 |
|
32 | |||
33 | There is only one x Axis visible at the time, however there can be multiple y axes. |
|
33 | There is only one x Axis visible at the time, however there can be multiple y axes. | |
34 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
34 | Each chart series can be bound to exactly one Y axis and the shared common X axis. | |
35 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
35 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
36 | */ |
|
36 | */ | |
37 |
|
37 | |||
38 | /*! |
|
38 | /*! | |
39 | \qmlclass AbstractAxis QAbstractAxis |
|
39 | \qmlclass AbstractAxis QAbstractAxis | |
40 | \brief The Axis element is used for manipulating chart's axes |
|
40 | \brief The Axis element is used for manipulating chart's axes | |
41 |
|
41 | |||
42 | There is only one x Axis visible at the time, however there can be multiple y axes on a ChartView. |
|
42 | There is only one x Axis visible at the time, however there can be multiple y axes on a ChartView. | |
43 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
43 | Each chart series can be bound to exactly one Y axis and the shared common X axis. | |
44 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
44 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
45 |
|
45 | |||
46 | To access Axes you can use ChartView API. For example: |
|
46 | To access Axes you can use ChartView API. For example: | |
47 | \code |
|
47 | \code | |
48 | ChartView { |
|
48 | ChartView { | |
49 | axisX.min: 0 |
|
49 | axisX.min: 0 | |
50 | axisX.max: 3 |
|
50 | axisX.max: 3 | |
51 | axisX.ticksCount: 4 |
|
51 | axisX.ticksCount: 4 | |
52 | axisY.min: 0 |
|
52 | axisY.min: 0 | |
53 | axisY.max: 4 |
|
53 | axisY.max: 4 | |
54 | // Add a few series... |
|
54 | // Add a few series... | |
55 | } |
|
55 | } | |
56 | \endcode |
|
56 | \endcode | |
57 | */ |
|
57 | */ | |
58 |
|
58 | |||
59 | /*! |
|
59 | /*! | |
60 | \enum QAbstractAxis::AxisType |
|
60 | \enum QAbstractAxis::AxisType | |
61 |
|
61 | |||
62 | The type of the series object. |
|
62 | The type of the series object. | |
63 |
|
63 | |||
64 | \value AxisTypeNoAxis |
|
64 | \value AxisTypeNoAxis | |
65 | \value AxisTypeValue |
|
65 | \value AxisTypeValue | |
66 | \value AxisTypeBarCategory |
|
66 | \value AxisTypeBarCategory | |
67 | \value AxisTypeCategory |
|
67 | \value AxisTypeCategory | |
68 | \value AxisTypeDateTime |
|
68 | \value AxisTypeDateTime | |
69 | \value AxisTypeLogValue |
|
69 | \value AxisTypeLogValue | |
70 | */ |
|
70 | */ | |
71 |
|
71 | |||
72 | /*! |
|
72 | /*! | |
73 | *\fn void QAbstractAxis::type() const |
|
73 | *\fn void QAbstractAxis::type() const | |
74 | Returns the type of the axis |
|
74 | Returns the type of the axis | |
75 | */ |
|
75 | */ | |
76 |
|
76 | |||
77 | /*! |
|
77 | /*! | |
78 | \property QAbstractAxis::lineVisible |
|
78 | \property QAbstractAxis::lineVisible | |
79 | The visibility of the axis line |
|
79 | The visibility of the axis line | |
80 | */ |
|
80 | */ | |
81 | /*! |
|
81 | /*! | |
82 | \qmlproperty bool AbstractAxis::lineVisible |
|
82 | \qmlproperty bool AbstractAxis::lineVisible | |
83 | The visibility of the axis line |
|
83 | The visibility of the axis line | |
84 | */ |
|
84 | */ | |
85 |
|
85 | |||
86 | /*! |
|
86 | /*! | |
87 | \property QAbstractAxis::labelsVisible |
|
87 | \property QAbstractAxis::labelsVisible | |
88 | Defines if axis labels are visible. |
|
88 | Defines if axis labels are visible. | |
89 | */ |
|
89 | */ | |
90 | /*! |
|
90 | /*! | |
91 | \qmlproperty bool AbstractAxis::labelsVisible |
|
91 | \qmlproperty bool AbstractAxis::labelsVisible | |
92 | Defines if axis labels are visible. |
|
92 | Defines if axis labels are visible. | |
93 | */ |
|
93 | */ | |
94 |
|
94 | |||
95 | /*! |
|
95 | /*! | |
96 | \property QAbstractAxis::visible |
|
96 | \property QAbstractAxis::visible | |
97 | The visibility of the axis. |
|
97 | The visibility of the axis. | |
98 | */ |
|
98 | */ | |
99 | /*! |
|
99 | /*! | |
100 | \qmlproperty bool AbstractAxis::visible |
|
100 | \qmlproperty bool AbstractAxis::visible | |
101 | The visibility of the axis. |
|
101 | The visibility of the axis. | |
102 | */ |
|
102 | */ | |
103 |
|
103 | |||
104 | /*! |
|
104 | /*! | |
105 | \property QAbstractAxis::gridVisible |
|
105 | \property QAbstractAxis::gridVisible | |
106 | The visibility of the grid lines. |
|
106 | The visibility of the grid lines. | |
107 | */ |
|
107 | */ | |
108 | /*! |
|
108 | /*! | |
109 | \qmlproperty bool AbstractAxis::gridVisible |
|
109 | \qmlproperty bool AbstractAxis::gridVisible | |
110 | The visibility of the grid lines. |
|
110 | The visibility of the grid lines. | |
111 | */ |
|
111 | */ | |
112 |
|
112 | |||
113 | /*! |
|
113 | /*! | |
114 | \property QAbstractAxis::color |
|
114 | \property QAbstractAxis::color | |
115 | The color of the axis and ticks. |
|
115 | The color of the axis and ticks. | |
116 | */ |
|
116 | */ | |
117 | /*! |
|
117 | /*! | |
118 | \qmlproperty color AbstractAxis::color |
|
118 | \qmlproperty color AbstractAxis::color | |
119 | The color of the axis and ticks. |
|
119 | The color of the axis and ticks. | |
120 | */ |
|
120 | */ | |
121 |
|
121 | |||
122 | /*! |
|
122 | /*! | |
123 | \property QAbstractAxis::labelsFont |
|
123 | \property QAbstractAxis::labelsFont | |
124 | The font of the axis labels. |
|
124 | The font of the axis labels. | |
125 | */ |
|
125 | */ | |
126 |
|
126 | |||
127 | /*! |
|
127 | /*! | |
128 | \qmlproperty Font AbstractAxis::labelsFont |
|
128 | \qmlproperty Font AbstractAxis::labelsFont | |
129 | The font of the axis labels. |
|
129 | The font of the axis labels. | |
130 |
|
130 | |||
131 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
131 | See the \l {Font} {QML Font Element} for detailed documentation. | |
132 | */ |
|
132 | */ | |
133 |
|
133 | |||
134 | /*! |
|
134 | /*! | |
135 | \property QAbstractAxis::labelsColor |
|
135 | \property QAbstractAxis::labelsColor | |
136 | The color of the axis labels. |
|
136 | The color of the axis labels. | |
137 | */ |
|
137 | */ | |
138 | /*! |
|
138 | /*! | |
139 | \qmlproperty color AbstractAxis::labelsColor |
|
139 | \qmlproperty color AbstractAxis::labelsColor | |
140 | The color of the axis labels. |
|
140 | The color of the axis labels. | |
141 | */ |
|
141 | */ | |
142 |
|
142 | |||
143 | /*! |
|
143 | /*! | |
144 | \property QAbstractAxis::labelsAngle |
|
144 | \property QAbstractAxis::labelsAngle | |
145 | The angle of the axis labels in degrees. |
|
145 | The angle of the axis labels in degrees. | |
146 | */ |
|
146 | */ | |
147 | /*! |
|
147 | /*! | |
148 | \qmlproperty int AbstractAxis::labelsAngle |
|
148 | \qmlproperty int AbstractAxis::labelsAngle | |
149 | The angle of the axis labels in degrees. |
|
149 | The angle of the axis labels in degrees. | |
150 | */ |
|
150 | */ | |
151 |
|
151 | |||
152 | /*! |
|
152 | /*! | |
153 | \property QAbstractAxis::shadesVisible |
|
153 | \property QAbstractAxis::shadesVisible | |
154 | The visibility of the axis shades. |
|
154 | The visibility of the axis shades. | |
155 | */ |
|
155 | */ | |
156 | /*! |
|
156 | /*! | |
157 | \qmlproperty bool AbstractAxis::shadesVisible |
|
157 | \qmlproperty bool AbstractAxis::shadesVisible | |
158 | The visibility of the axis shades. |
|
158 | The visibility of the axis shades. | |
159 | */ |
|
159 | */ | |
160 |
|
160 | |||
161 | /*! |
|
161 | /*! | |
162 | \property QAbstractAxis::shadesColor |
|
162 | \property QAbstractAxis::shadesColor | |
163 | The fill (brush) color of the axis shades. |
|
163 | The fill (brush) color of the axis shades. | |
164 | */ |
|
164 | */ | |
165 | /*! |
|
165 | /*! | |
166 | \qmlproperty color AbstractAxis::shadesColor |
|
166 | \qmlproperty color AbstractAxis::shadesColor | |
167 | The fill (brush) color of the axis shades. |
|
167 | The fill (brush) color of the axis shades. | |
168 | */ |
|
168 | */ | |
169 |
|
169 | |||
170 | /*! |
|
170 | /*! | |
171 | \property QAbstractAxis::shadesBorderColor |
|
171 | \property QAbstractAxis::shadesBorderColor | |
172 | The border (pen) color of the axis shades. |
|
172 | The border (pen) color of the axis shades. | |
173 | */ |
|
173 | */ | |
174 | /*! |
|
174 | /*! | |
175 | \qmlproperty color AbstractAxis::shadesBorderColor |
|
175 | \qmlproperty color AbstractAxis::shadesBorderColor | |
176 | The border (pen) color of the axis shades. |
|
176 | The border (pen) color of the axis shades. | |
177 | */ |
|
177 | */ | |
178 |
|
178 | |||
179 | /*! |
|
179 | /*! | |
180 | \property QAbstractAxis::titleVisible |
|
180 | \property QAbstractAxis::titleVisible | |
181 | The visibility of the axis title. By default the value is true. |
|
181 | The visibility of the axis title. By default the value is true. | |
182 | */ |
|
182 | */ | |
183 | /*! |
|
183 | /*! | |
184 | \qmlproperty bool AbstractAxis::titleVisible |
|
184 | \qmlproperty bool AbstractAxis::titleVisible | |
185 | The visibility of the axis title. By default the value is true. |
|
185 | The visibility of the axis title. By default the value is true. | |
186 | */ |
|
186 | */ | |
187 |
|
187 | |||
188 | /*! |
|
188 | /*! | |
189 | \property QAbstractAxis::titleFont |
|
189 | \property QAbstractAxis::titleFont | |
190 | The font of the title of the axis. |
|
190 | The font of the title of the axis. | |
191 | */ |
|
191 | */ | |
192 | /*! |
|
192 | /*! | |
193 | \qmlproperty Font AbstractAxis::title |
|
193 | \qmlproperty Font AbstractAxis::title | |
194 | The font of the title of the axis. |
|
194 | The font of the title of the axis. | |
195 | */ |
|
195 | */ | |
196 |
|
196 | |||
197 | /*! |
|
197 | /*! | |
198 | \property QAbstractAxis::title |
|
198 | \property QAbstractAxis::title | |
199 | The title of the axis. Empty by default. |
|
199 | The title of the axis. Empty by default. | |
200 | */ |
|
200 | */ | |
201 | /*! |
|
201 | /*! | |
202 | \qmlproperty string AbstractAxis::title |
|
202 | \qmlproperty string AbstractAxis::title | |
203 | The title of the axis. Empty string by default. |
|
203 | The title of the axis. Empty string by default. | |
204 | */ |
|
204 | */ | |
205 |
|
205 | |||
206 | /*! |
|
206 | /*! | |
207 | \property QAbstractAxis::alignment |
|
207 | \property QAbstractAxis::alignment | |
208 | The alignment of the axis. Either Qt::AlignLeft or Qt::AlignBottom. |
|
208 | The alignment of the axis. Either Qt::AlignLeft or Qt::AlignBottom. | |
209 | */ |
|
209 | */ | |
210 | /*! |
|
210 | /*! | |
211 | \qmlproperty alignment AbstractAxis::alignment |
|
211 | \qmlproperty alignment AbstractAxis::alignment | |
212 | The alignment of the axis. Either Qt.AlignLeft or Qt.AlignBottom. |
|
212 | The alignment of the axis. Either Qt.AlignLeft or Qt.AlignBottom. | |
213 | */ |
|
213 | */ | |
214 |
|
214 | |||
215 | /*! |
|
215 | /*! | |
216 | \fn void QAbstractAxis::visibleChanged(bool visible) |
|
216 | \fn void QAbstractAxis::visibleChanged(bool visible) | |
217 | Visibility of the axis has changed to \a visible. |
|
217 | Visibility of the axis has changed to \a visible. | |
218 | */ |
|
218 | */ | |
219 | /*! |
|
219 | /*! | |
220 | \qmlsignal AbstractAxis::onVisibleChanged(bool visible) |
|
220 | \qmlsignal AbstractAxis::onVisibleChanged(bool visible) | |
221 | Visibility of the axis has changed to \a visible. |
|
221 | Visibility of the axis has changed to \a visible. | |
222 | */ |
|
222 | */ | |
223 |
|
223 | |||
224 | /*! |
|
224 | /*! | |
225 | \fn void QAbstractAxis::lineVisibleChanged(bool visible) |
|
225 | \fn void QAbstractAxis::lineVisibleChanged(bool visible) | |
226 | Visibility of the axis line has changed to \a visible. |
|
226 | Visibility of the axis line has changed to \a visible. | |
227 | */ |
|
227 | */ | |
228 | /*! |
|
228 | /*! | |
229 | \qmlsignal AbstractAxis::onLineVisibleChanged(bool visible) |
|
229 | \qmlsignal AbstractAxis::onLineVisibleChanged(bool visible) | |
230 | Visibility of the axis line has changed to \a visible. |
|
230 | Visibility of the axis line has changed to \a visible. | |
231 | */ |
|
231 | */ | |
232 |
|
232 | |||
233 | /*! |
|
233 | /*! | |
234 | \fn void QAbstractAxis::labelsVisibleChanged(bool visible) |
|
234 | \fn void QAbstractAxis::labelsVisibleChanged(bool visible) | |
235 | Visibility of the labels of the axis has changed to \a visible. |
|
235 | Visibility of the labels of the axis has changed to \a visible. | |
236 | */ |
|
236 | */ | |
237 | /*! |
|
237 | /*! | |
238 | \qmlsignal AbstractAxis::onLabelsVisibleChanged(bool visible) |
|
238 | \qmlsignal AbstractAxis::onLabelsVisibleChanged(bool visible) | |
239 | Visibility of the labels of the axis has changed to \a visible. |
|
239 | Visibility of the labels of the axis has changed to \a visible. | |
240 | */ |
|
240 | */ | |
241 |
|
241 | |||
242 | /*! |
|
242 | /*! | |
243 | \fn void QAbstractAxis::gridVisibleChanged(bool visible) |
|
243 | \fn void QAbstractAxis::gridVisibleChanged(bool visible) | |
244 | Visibility of the grid lines of the axis has changed to \a visible. |
|
244 | Visibility of the grid lines of the axis has changed to \a visible. | |
245 | */ |
|
245 | */ | |
246 | /*! |
|
246 | /*! | |
247 | \qmlsignal AbstractAxis::onGridVisibleChanged(bool visible) |
|
247 | \qmlsignal AbstractAxis::onGridVisibleChanged(bool visible) | |
248 | Visibility of the grid lines of the axis has changed to \a visible. |
|
248 | Visibility of the grid lines of the axis has changed to \a visible. | |
249 | */ |
|
249 | */ | |
250 |
|
250 | |||
251 | /*! |
|
251 | /*! | |
252 | \fn void QAbstractAxis::colorChanged(QColor color) |
|
252 | \fn void QAbstractAxis::colorChanged(QColor color) | |
253 | Emitted if the \a color of the axis is changed. |
|
253 | Emitted if the \a color of the axis is changed. | |
254 | */ |
|
254 | */ | |
255 | /*! |
|
255 | /*! | |
256 | \qmlsignal AbstractAxis::onColorChanged(QColor color) |
|
256 | \qmlsignal AbstractAxis::onColorChanged(QColor color) | |
257 | Emitted if the \a color of the axis is changed. |
|
257 | Emitted if the \a color of the axis is changed. | |
258 | */ |
|
258 | */ | |
259 |
|
259 | |||
260 | /*! |
|
260 | /*! | |
261 | \fn void QAbstractAxis::labelsColorChanged(QColor color) |
|
261 | \fn void QAbstractAxis::labelsColorChanged(QColor color) | |
262 | Emitted if the \a color of the axis labels is changed. |
|
262 | Emitted if the \a color of the axis labels is changed. | |
263 | */ |
|
263 | */ | |
264 | /*! |
|
264 | /*! | |
265 | \qmlsignal AbstractAxis::onLabelsColorChanged(QColor color) |
|
265 | \qmlsignal AbstractAxis::onLabelsColorChanged(QColor color) | |
266 | Emitted if the \a color of the axis labels is changed. |
|
266 | Emitted if the \a color of the axis labels is changed. | |
267 | */ |
|
267 | */ | |
268 |
|
268 | |||
269 | /*! |
|
269 | /*! | |
270 | \fn void QAbstractAxis::shadesVisibleChanged(bool) |
|
270 | \fn void QAbstractAxis::shadesVisibleChanged(bool) | |
271 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
271 | Emitted if the visibility of the axis shades is changed to \a visible. | |
272 | */ |
|
272 | */ | |
273 | /*! |
|
273 | /*! | |
274 | \qmlsignal AbstractAxis::onShadesVisibleChanged(bool visible) |
|
274 | \qmlsignal AbstractAxis::onShadesVisibleChanged(bool visible) | |
275 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
275 | Emitted if the visibility of the axis shades is changed to \a visible. | |
276 | */ |
|
276 | */ | |
277 |
|
277 | |||
278 | /*! |
|
278 | /*! | |
279 | \fn void QAbstractAxis::shadesColorChanged(QColor color) |
|
279 | \fn void QAbstractAxis::shadesColorChanged(QColor color) | |
280 | Emitted if the \a color of the axis shades is changed. |
|
280 | Emitted if the \a color of the axis shades is changed. | |
281 | */ |
|
281 | */ | |
282 | /*! |
|
282 | /*! | |
283 | \qmlsignal AbstractAxis::onShadesColorChanged(QColor color) |
|
283 | \qmlsignal AbstractAxis::onShadesColorChanged(QColor color) | |
284 | Emitted if the \a color of the axis shades is changed. |
|
284 | Emitted if the \a color of the axis shades is changed. | |
285 | */ |
|
285 | */ | |
286 |
|
286 | |||
287 | /*! |
|
287 | /*! | |
288 | \fn void QAbstractAxis::shadesBorderColorChanged(QColor) |
|
288 | \fn void QAbstractAxis::shadesBorderColorChanged(QColor) | |
289 | Emitted if the border \a color of the axis shades is changed. |
|
289 | Emitted if the border \a color of the axis shades is changed. | |
290 | */ |
|
290 | */ | |
291 | /*! |
|
291 | /*! | |
292 | \qmlsignal AbstractAxis::onBorderColorChanged(QColor color) |
|
292 | \qmlsignal AbstractAxis::onBorderColorChanged(QColor color) | |
293 | Emitted if the border \a color of the axis shades is changed. |
|
293 | Emitted if the border \a color of the axis shades is changed. | |
294 | */ |
|
294 | */ | |
295 |
|
295 | |||
296 | /*! |
|
296 | /*! | |
297 | \internal |
|
297 | \internal | |
298 | Constructs new axis object which is a child of \a parent. Ownership is taken by |
|
298 | Constructs new axis object which is a child of \a parent. Ownership is taken by | |
299 | QChart when axis added. |
|
299 | QChart when axis added. | |
300 | */ |
|
300 | */ | |
301 |
|
301 | |||
302 | QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) |
|
302 | QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) | |
303 | : QObject(parent), |
|
303 | : QObject(parent), | |
304 | d_ptr(&d) |
|
304 | d_ptr(&d) | |
305 | { |
|
305 | { | |
306 | } |
|
306 | } | |
307 |
|
307 | |||
308 | /*! |
|
308 | /*! | |
309 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. |
|
309 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. | |
310 | */ |
|
310 | */ | |
311 |
|
311 | |||
312 | QAbstractAxis::~QAbstractAxis() |
|
312 | QAbstractAxis::~QAbstractAxis() | |
313 | { |
|
313 | { | |
314 | if (d_ptr->m_chart) |
|
314 | if (d_ptr->m_chart) | |
315 | qFatal("Still binded axis detected !"); |
|
315 | qFatal("Still binded axis detected !"); | |
316 | } |
|
316 | } | |
317 |
|
317 | |||
318 | /*! |
|
318 | /*! | |
319 | Sets \a pen used to draw axis line and ticks. |
|
319 | Sets \a pen used to draw axis line and ticks. | |
320 | */ |
|
320 | */ | |
321 | void QAbstractAxis::setLinePen(const QPen &pen) |
|
321 | void QAbstractAxis::setLinePen(const QPen &pen) | |
322 | { |
|
322 | { | |
323 | if (d_ptr->m_axisPen != pen) { |
|
323 | if (d_ptr->m_axisPen != pen) { | |
324 | d_ptr->m_axisPen = pen; |
|
324 | d_ptr->m_axisPen = pen; | |
325 | emit linePenChanged(pen); |
|
325 | emit linePenChanged(pen); | |
326 | } |
|
326 | } | |
327 | } |
|
327 | } | |
328 |
|
328 | |||
329 | /*! |
|
329 | /*! | |
330 | Returns pen used to draw axis and ticks. |
|
330 | Returns pen used to draw axis and ticks. | |
331 | */ |
|
331 | */ | |
332 | QPen QAbstractAxis::linePen() const |
|
332 | QPen QAbstractAxis::linePen() const | |
333 | { |
|
333 | { | |
334 | return d_ptr->m_axisPen; |
|
334 | return d_ptr->m_axisPen; | |
335 | } |
|
335 | } | |
336 |
|
336 | |||
337 | //TODO: remove me |
|
337 | //TODO: remove me | |
338 | void QAbstractAxis::setLinePenColor(QColor color) |
|
338 | void QAbstractAxis::setLinePenColor(QColor color) | |
339 | { |
|
339 | { | |
340 | QPen p = d_ptr->m_axisPen; |
|
340 | QPen p = d_ptr->m_axisPen; | |
341 | if (p.color() != color) { |
|
341 | if (p.color() != color) { | |
342 | p.setColor(color); |
|
342 | p.setColor(color); | |
343 | setLinePen(p); |
|
343 | setLinePen(p); | |
344 | emit colorChanged(color); |
|
344 | emit colorChanged(color); | |
345 | } |
|
345 | } | |
346 | } |
|
346 | } | |
347 |
|
347 | |||
348 | QColor QAbstractAxis::linePenColor() const |
|
348 | QColor QAbstractAxis::linePenColor() const | |
349 | { |
|
349 | { | |
350 | return d_ptr->m_axisPen.color(); |
|
350 | return d_ptr->m_axisPen.color(); | |
351 | } |
|
351 | } | |
352 |
|
352 | |||
353 | /*! |
|
353 | /*! | |
354 | Sets if axis and ticks are \a visible. |
|
354 | Sets if axis and ticks are \a visible. | |
355 | */ |
|
355 | */ | |
356 | void QAbstractAxis::setLineVisible(bool visible) |
|
356 | void QAbstractAxis::setLineVisible(bool visible) | |
357 | { |
|
357 | { | |
358 | if (d_ptr->m_arrowVisible != visible) { |
|
358 | if (d_ptr->m_arrowVisible != visible) { | |
359 | d_ptr->m_arrowVisible = visible; |
|
359 | d_ptr->m_arrowVisible = visible; | |
360 | emit lineVisibleChanged(visible); |
|
360 | emit lineVisibleChanged(visible); | |
361 | } |
|
361 | } | |
362 | } |
|
362 | } | |
363 |
|
363 | |||
364 | bool QAbstractAxis::isLineVisible() const |
|
364 | bool QAbstractAxis::isLineVisible() const | |
365 | { |
|
365 | { | |
366 | return d_ptr->m_arrowVisible; |
|
366 | return d_ptr->m_arrowVisible; | |
367 | } |
|
367 | } | |
368 |
|
368 | |||
369 | void QAbstractAxis::setGridLineVisible(bool visible) |
|
369 | void QAbstractAxis::setGridLineVisible(bool visible) | |
370 | { |
|
370 | { | |
371 | if (d_ptr->m_gridLineVisible != visible) { |
|
371 | if (d_ptr->m_gridLineVisible != visible) { | |
372 | d_ptr->m_gridLineVisible = visible; |
|
372 | d_ptr->m_gridLineVisible = visible; | |
373 | emit gridVisibleChanged(visible); |
|
373 | emit gridVisibleChanged(visible); | |
374 | } |
|
374 | } | |
375 | } |
|
375 | } | |
376 |
|
376 | |||
377 | bool QAbstractAxis::isGridLineVisible() const |
|
377 | bool QAbstractAxis::isGridLineVisible() const | |
378 | { |
|
378 | { | |
379 | return d_ptr->m_gridLineVisible; |
|
379 | return d_ptr->m_gridLineVisible; | |
380 | } |
|
380 | } | |
381 |
|
381 | |||
382 | /*! |
|
382 | /*! | |
383 | Sets \a pen used to draw grid line. |
|
383 | Sets \a pen used to draw grid line. | |
384 | */ |
|
384 | */ | |
385 | void QAbstractAxis::setGridLinePen(const QPen &pen) |
|
385 | void QAbstractAxis::setGridLinePen(const QPen &pen) | |
386 | { |
|
386 | { | |
387 | if (d_ptr->m_gridLinePen != pen) { |
|
387 | if (d_ptr->m_gridLinePen != pen) { | |
388 | d_ptr->m_gridLinePen = pen; |
|
388 | d_ptr->m_gridLinePen = pen; | |
389 | emit gridLinePenChanged(pen); |
|
389 | emit gridLinePenChanged(pen); | |
390 | } |
|
390 | } | |
391 | } |
|
391 | } | |
392 |
|
392 | |||
393 | /*! |
|
393 | /*! | |
394 | Returns pen used to draw grid. |
|
394 | Returns pen used to draw grid. | |
395 | */ |
|
395 | */ | |
396 | QPen QAbstractAxis::gridLinePen() const |
|
396 | QPen QAbstractAxis::gridLinePen() const | |
397 | { |
|
397 | { | |
398 | return d_ptr->m_gridLinePen; |
|
398 | return d_ptr->m_gridLinePen; | |
399 | } |
|
399 | } | |
400 |
|
400 | |||
401 | void QAbstractAxis::setLabelsVisible(bool visible) |
|
401 | void QAbstractAxis::setLabelsVisible(bool visible) | |
402 | { |
|
402 | { | |
403 | if (d_ptr->m_labelsVisible != visible) { |
|
403 | if (d_ptr->m_labelsVisible != visible) { | |
404 | d_ptr->m_labelsVisible = visible; |
|
404 | d_ptr->m_labelsVisible = visible; | |
405 | emit labelsVisibleChanged(visible); |
|
405 | emit labelsVisibleChanged(visible); | |
406 | } |
|
406 | } | |
407 | } |
|
407 | } | |
408 |
|
408 | |||
409 | bool QAbstractAxis::labelsVisible() const |
|
409 | bool QAbstractAxis::labelsVisible() const | |
410 | { |
|
410 | { | |
411 | return d_ptr->m_labelsVisible; |
|
411 | return d_ptr->m_labelsVisible; | |
412 | } |
|
412 | } | |
413 |
|
413 | |||
414 | /*! |
|
414 | /*! | |
415 | Sets \a pen used to draw labels. |
|
415 | Sets \a pen used to draw labels. | |
416 | */ |
|
416 | */ | |
417 | void QAbstractAxis::setLabelsPen(const QPen &pen) |
|
417 | void QAbstractAxis::setLabelsPen(const QPen &pen) | |
418 | { |
|
418 | { | |
419 | if (d_ptr->m_labelsPen != pen) { |
|
419 | if (d_ptr->m_labelsPen != pen) { | |
420 | d_ptr->m_labelsPen = pen; |
|
420 | d_ptr->m_labelsPen = pen; | |
421 | emit labelsPenChanged(pen); |
|
421 | emit labelsPenChanged(pen); | |
422 | } |
|
422 | } | |
423 | } |
|
423 | } | |
424 |
|
424 | |||
425 | /*! |
|
425 | /*! | |
426 | Returns the pen used to labels. |
|
426 | Returns the pen used to labels. | |
427 | */ |
|
427 | */ | |
428 | QPen QAbstractAxis::labelsPen() const |
|
428 | QPen QAbstractAxis::labelsPen() const | |
429 | { |
|
429 | { | |
430 | return d_ptr->m_labelsPen; |
|
430 | return d_ptr->m_labelsPen; | |
431 | } |
|
431 | } | |
432 |
|
432 | |||
433 | /*! |
|
433 | /*! | |
434 | Sets \a brush used to draw labels. |
|
434 | Sets \a brush used to draw labels. | |
435 | */ |
|
435 | */ | |
436 | void QAbstractAxis::setLabelsBrush(const QBrush &brush) |
|
436 | void QAbstractAxis::setLabelsBrush(const QBrush &brush) | |
437 | { |
|
437 | { | |
438 | if (d_ptr->m_labelsBrush != brush) { |
|
438 | if (d_ptr->m_labelsBrush != brush) { | |
439 | d_ptr->m_labelsBrush = brush; |
|
439 | d_ptr->m_labelsBrush = brush; | |
440 | emit labelsBrushChanged(brush); |
|
440 | emit labelsBrushChanged(brush); | |
441 | } |
|
441 | } | |
442 | } |
|
442 | } | |
443 |
|
443 | |||
444 | /*! |
|
444 | /*! | |
445 | Returns brush used to draw labels. |
|
445 | Returns brush used to draw labels. | |
446 | */ |
|
446 | */ | |
447 | QBrush QAbstractAxis::labelsBrush() const |
|
447 | QBrush QAbstractAxis::labelsBrush() const | |
448 | { |
|
448 | { | |
449 | return d_ptr->m_labelsBrush; |
|
449 | return d_ptr->m_labelsBrush; | |
450 | } |
|
450 | } | |
451 |
|
451 | |||
452 | /*! |
|
452 | /*! | |
453 | Sets \a font used to draw labels. |
|
453 | Sets \a font used to draw labels. | |
454 | */ |
|
454 | */ | |
455 | void QAbstractAxis::setLabelsFont(const QFont &font) |
|
455 | void QAbstractAxis::setLabelsFont(const QFont &font) | |
456 | { |
|
456 | { | |
457 | if (d_ptr->m_labelsFont != font) { |
|
457 | if (d_ptr->m_labelsFont != font) { | |
458 | d_ptr->m_labelsFont = font; |
|
458 | d_ptr->m_labelsFont = font; | |
459 | emit labelsFontChanged(font); |
|
459 | emit labelsFontChanged(font); | |
460 | } |
|
460 | } | |
461 | } |
|
461 | } | |
462 |
|
462 | |||
463 | /*! |
|
463 | /*! | |
464 | Returns font used to draw labels. |
|
464 | Returns font used to draw labels. | |
465 | */ |
|
465 | */ | |
466 | QFont QAbstractAxis::labelsFont() const |
|
466 | QFont QAbstractAxis::labelsFont() const | |
467 | { |
|
467 | { | |
468 | return d_ptr->m_labelsFont; |
|
468 | return d_ptr->m_labelsFont; | |
469 | } |
|
469 | } | |
470 |
|
470 | |||
471 | void QAbstractAxis::setLabelsAngle(int angle) |
|
471 | void QAbstractAxis::setLabelsAngle(int angle) | |
472 | { |
|
472 | { | |
473 | if (d_ptr->m_labelsAngle != angle) { |
|
473 | if (d_ptr->m_labelsAngle != angle) { | |
474 | d_ptr->m_labelsAngle = angle; |
|
474 | d_ptr->m_labelsAngle = angle; | |
475 | emit labelsAngleChanged(angle); |
|
475 | emit labelsAngleChanged(angle); | |
476 | } |
|
476 | } | |
477 | } |
|
477 | } | |
478 |
|
478 | |||
479 | int QAbstractAxis::labelsAngle() const |
|
479 | int QAbstractAxis::labelsAngle() const | |
480 | { |
|
480 | { | |
481 | return d_ptr->m_labelsAngle; |
|
481 | return d_ptr->m_labelsAngle; | |
482 | } |
|
482 | } | |
483 | //TODO: remove me |
|
483 | //TODO: remove me | |
484 | void QAbstractAxis::setLabelsColor(QColor color) |
|
484 | void QAbstractAxis::setLabelsColor(QColor color) | |
485 | { |
|
485 | { | |
486 | QBrush b = d_ptr->m_labelsBrush; |
|
486 | QBrush b = d_ptr->m_labelsBrush; | |
487 | if (b.color() != color) { |
|
487 | if (b.color() != color) { | |
488 | b.setColor(color); |
|
488 | b.setColor(color); | |
489 | setLabelsBrush(b); |
|
489 | setLabelsBrush(b); | |
490 | emit labelsColorChanged(color); |
|
490 | emit labelsColorChanged(color); | |
491 | } |
|
491 | } | |
492 | } |
|
492 | } | |
493 |
|
493 | |||
494 | QColor QAbstractAxis::labelsColor() const |
|
494 | QColor QAbstractAxis::labelsColor() const | |
495 | { |
|
495 | { | |
496 | return d_ptr->m_labelsBrush.color(); |
|
496 | return d_ptr->m_labelsBrush.color(); | |
497 | } |
|
497 | } | |
498 |
|
498 | |||
499 | void QAbstractAxis::setTitleVisible(bool visible) |
|
499 | void QAbstractAxis::setTitleVisible(bool visible) | |
500 | { |
|
500 | { | |
501 | if (d_ptr->m_titleVisible != visible) { |
|
501 | if (d_ptr->m_titleVisible != visible) { | |
502 | d_ptr->m_titleVisible = visible; |
|
502 | d_ptr->m_titleVisible = visible; | |
503 | emit titleVisibleChanged(visible); |
|
503 | emit titleVisibleChanged(visible); | |
504 | } |
|
504 | } | |
505 | } |
|
505 | } | |
506 |
|
506 | |||
507 | bool QAbstractAxis::isTitleVisible() const |
|
507 | bool QAbstractAxis::isTitleVisible() const | |
508 | { |
|
508 | { | |
509 | return d_ptr->m_titleVisible; |
|
509 | return d_ptr->m_titleVisible; | |
510 | } |
|
510 | } | |
511 |
|
511 | |||
512 | /*! |
|
512 | /*! | |
513 | Sets \a pen used to draw title. |
|
513 | Sets \a pen used to draw title. | |
514 | */ |
|
514 | */ | |
515 | void QAbstractAxis::setTitlePen(const QPen &pen) |
|
515 | void QAbstractAxis::setTitlePen(const QPen &pen) | |
516 | { |
|
516 | { | |
517 | if (d_ptr->m_titlePen != pen) { |
|
517 | if (d_ptr->m_titlePen != pen) { | |
518 | d_ptr->m_titlePen = pen; |
|
518 | d_ptr->m_titlePen = pen; | |
519 | emit titlePenChanged(pen); |
|
519 | emit titlePenChanged(pen); | |
520 | } |
|
520 | } | |
521 | } |
|
521 | } | |
522 |
|
522 | |||
523 | /*! |
|
523 | /*! | |
524 | Returns the pen used to title. |
|
524 | Returns the pen used to title. | |
525 | */ |
|
525 | */ | |
526 | QPen QAbstractAxis::titlePen() const |
|
526 | QPen QAbstractAxis::titlePen() const | |
527 | { |
|
527 | { | |
528 | return d_ptr->m_titlePen; |
|
528 | return d_ptr->m_titlePen; | |
529 | } |
|
529 | } | |
530 |
|
530 | |||
531 | /*! |
|
531 | /*! | |
532 | Sets \a brush used to draw title. |
|
532 | Sets \a brush used to draw title. | |
533 | */ |
|
533 | */ | |
534 | void QAbstractAxis::setTitleBrush(const QBrush &brush) |
|
534 | void QAbstractAxis::setTitleBrush(const QBrush &brush) | |
535 | { |
|
535 | { | |
536 | if (d_ptr->m_titleBrush != brush) { |
|
536 | if (d_ptr->m_titleBrush != brush) { | |
537 | d_ptr->m_titleBrush = brush; |
|
537 | d_ptr->m_titleBrush = brush; | |
538 | emit titleBrushChanged(brush); |
|
538 | emit titleBrushChanged(brush); | |
539 | } |
|
539 | } | |
540 | } |
|
540 | } | |
541 |
|
541 | |||
542 | /*! |
|
542 | /*! | |
543 | Returns brush used to draw title. |
|
543 | Returns brush used to draw title. | |
544 | */ |
|
544 | */ | |
545 | QBrush QAbstractAxis::titleBrush() const |
|
545 | QBrush QAbstractAxis::titleBrush() const | |
546 | { |
|
546 | { | |
547 | return d_ptr->m_titleBrush; |
|
547 | return d_ptr->m_titleBrush; | |
548 | } |
|
548 | } | |
549 |
|
549 | |||
550 | /*! |
|
550 | /*! | |
551 | Sets \a font used to draw title. |
|
551 | Sets \a font used to draw title. | |
552 | */ |
|
552 | */ | |
553 | void QAbstractAxis::setTitleFont(const QFont &font) |
|
553 | void QAbstractAxis::setTitleFont(const QFont &font) | |
554 | { |
|
554 | { | |
555 | if (d_ptr->m_titleFont != font) { |
|
555 | if (d_ptr->m_titleFont != font) { | |
556 | d_ptr->m_titleFont = font; |
|
556 | d_ptr->m_titleFont = font; | |
557 | emit titleFontChanged(font); |
|
557 | emit titleFontChanged(font); | |
558 | } |
|
558 | } | |
559 | } |
|
559 | } | |
560 |
|
560 | |||
561 | /*! |
|
561 | /*! | |
562 | Returns font used to draw title. |
|
562 | Returns font used to draw title. | |
563 | */ |
|
563 | */ | |
564 | QFont QAbstractAxis::titleFont() const |
|
564 | QFont QAbstractAxis::titleFont() const | |
565 | { |
|
565 | { | |
566 | return d_ptr->m_titleFont; |
|
566 | return d_ptr->m_titleFont; | |
567 | } |
|
567 | } | |
568 |
|
568 | |||
569 | void QAbstractAxis::setTitleText(const QString &title) |
|
569 | void QAbstractAxis::setTitleText(const QString &title) | |
570 | { |
|
570 | { | |
571 | if (d_ptr->m_title != title) { |
|
571 | if (d_ptr->m_title != title) { | |
572 | d_ptr->m_title = title; |
|
572 | d_ptr->m_title = title; | |
573 | emit titleTextChanged(title); |
|
573 | emit titleTextChanged(title); | |
574 | } |
|
574 | } | |
575 | } |
|
575 | } | |
576 |
|
576 | |||
577 | QString QAbstractAxis::titleText() const |
|
577 | QString QAbstractAxis::titleText() const | |
578 | { |
|
578 | { | |
579 | return d_ptr->m_title; |
|
579 | return d_ptr->m_title; | |
580 | } |
|
580 | } | |
581 |
|
581 | |||
582 |
|
582 | |||
583 | void QAbstractAxis::setShadesVisible(bool visible) |
|
583 | void QAbstractAxis::setShadesVisible(bool visible) | |
584 | { |
|
584 | { | |
585 | if (d_ptr->m_shadesVisible != visible) { |
|
585 | if (d_ptr->m_shadesVisible != visible) { | |
586 | d_ptr->m_shadesVisible = visible; |
|
586 | d_ptr->m_shadesVisible = visible; | |
587 | emit shadesVisibleChanged(visible); |
|
587 | emit shadesVisibleChanged(visible); | |
588 | } |
|
588 | } | |
589 | } |
|
589 | } | |
590 |
|
590 | |||
591 | bool QAbstractAxis::shadesVisible() const |
|
591 | bool QAbstractAxis::shadesVisible() const | |
592 | { |
|
592 | { | |
593 | return d_ptr->m_shadesVisible; |
|
593 | return d_ptr->m_shadesVisible; | |
594 | } |
|
594 | } | |
595 |
|
595 | |||
596 | /*! |
|
596 | /*! | |
597 | Sets \a pen used to draw shades. |
|
597 | Sets \a pen used to draw shades. | |
598 | */ |
|
598 | */ | |
599 | void QAbstractAxis::setShadesPen(const QPen &pen) |
|
599 | void QAbstractAxis::setShadesPen(const QPen &pen) | |
600 | { |
|
600 | { | |
601 | if (d_ptr->m_shadesPen != pen) { |
|
601 | if (d_ptr->m_shadesPen != pen) { | |
602 | d_ptr->m_shadesPen = pen; |
|
602 | d_ptr->m_shadesPen = pen; | |
603 | emit shadesPenChanged(pen); |
|
603 | emit shadesPenChanged(pen); | |
604 | } |
|
604 | } | |
605 | } |
|
605 | } | |
606 |
|
606 | |||
607 | /*! |
|
607 | /*! | |
608 | Returns pen used to draw shades. |
|
608 | Returns pen used to draw shades. | |
609 | */ |
|
609 | */ | |
610 | QPen QAbstractAxis::shadesPen() const |
|
610 | QPen QAbstractAxis::shadesPen() const | |
611 | { |
|
611 | { | |
612 | return d_ptr->m_shadesPen; |
|
612 | return d_ptr->m_shadesPen; | |
613 | } |
|
613 | } | |
614 |
|
614 | |||
615 | /*! |
|
615 | /*! | |
616 | Sets \a brush used to draw shades. |
|
616 | Sets \a brush used to draw shades. | |
617 | */ |
|
617 | */ | |
618 | void QAbstractAxis::setShadesBrush(const QBrush &brush) |
|
618 | void QAbstractAxis::setShadesBrush(const QBrush &brush) | |
619 | { |
|
619 | { | |
620 | if (d_ptr->m_shadesBrush != brush) { |
|
620 | if (d_ptr->m_shadesBrush != brush) { | |
621 | d_ptr->m_shadesBrush = brush; |
|
621 | d_ptr->m_shadesBrush = brush; | |
622 | emit shadesBrushChanged(brush); |
|
622 | emit shadesBrushChanged(brush); | |
623 | } |
|
623 | } | |
624 | } |
|
624 | } | |
625 |
|
625 | |||
626 | /*! |
|
626 | /*! | |
627 | Returns brush used to draw shades. |
|
627 | Returns brush used to draw shades. | |
628 | */ |
|
628 | */ | |
629 | QBrush QAbstractAxis::shadesBrush() const |
|
629 | QBrush QAbstractAxis::shadesBrush() const | |
630 | { |
|
630 | { | |
631 | return d_ptr->m_shadesBrush; |
|
631 | return d_ptr->m_shadesBrush; | |
632 | } |
|
632 | } | |
633 |
|
633 | |||
634 | void QAbstractAxis::setShadesColor(QColor color) |
|
634 | void QAbstractAxis::setShadesColor(QColor color) | |
635 | { |
|
635 | { | |
636 | QBrush b = d_ptr->m_shadesBrush; |
|
636 | QBrush b = d_ptr->m_shadesBrush; | |
637 | if (b.color() != color) { |
|
637 | if (b.color() != color) { | |
638 | b.setColor(color); |
|
638 | b.setColor(color); | |
639 | setShadesBrush(b); |
|
639 | setShadesBrush(b); | |
640 | emit shadesColorChanged(color); |
|
640 | emit shadesColorChanged(color); | |
641 | } |
|
641 | } | |
642 | } |
|
642 | } | |
643 |
|
643 | |||
644 | QColor QAbstractAxis::shadesColor() const |
|
644 | QColor QAbstractAxis::shadesColor() const | |
645 | { |
|
645 | { | |
646 | return d_ptr->m_shadesBrush.color(); |
|
646 | return d_ptr->m_shadesBrush.color(); | |
647 | } |
|
647 | } | |
648 |
|
648 | |||
649 | void QAbstractAxis::setShadesBorderColor(QColor color) |
|
649 | void QAbstractAxis::setShadesBorderColor(QColor color) | |
650 | { |
|
650 | { | |
651 | QPen p = d_ptr->m_shadesPen; |
|
651 | QPen p = d_ptr->m_shadesPen; | |
652 | if (p.color() != color) { |
|
652 | if (p.color() != color) { | |
653 | p.setColor(color); |
|
653 | p.setColor(color); | |
654 | setShadesPen(p); |
|
654 | setShadesPen(p); | |
655 | emit shadesColorChanged(color); |
|
655 | emit shadesColorChanged(color); | |
656 | } |
|
656 | } | |
657 | } |
|
657 | } | |
658 |
|
658 | |||
659 | QColor QAbstractAxis::shadesBorderColor() const |
|
659 | QColor QAbstractAxis::shadesBorderColor() const | |
660 | { |
|
660 | { | |
661 | return d_ptr->m_shadesPen.color(); |
|
661 | return d_ptr->m_shadesPen.color(); | |
662 | } |
|
662 | } | |
663 |
|
663 | |||
664 |
|
664 | |||
665 | bool QAbstractAxis::isVisible() const |
|
665 | bool QAbstractAxis::isVisible() const | |
666 | { |
|
666 | { | |
667 | return d_ptr->m_visible; |
|
667 | return d_ptr->m_visible; | |
668 | } |
|
668 | } | |
669 |
|
669 | |||
670 | /*! |
|
670 | /*! | |
671 | Sets axis, shades, labels and grid lines to be visible. |
|
671 | Sets axis, shades, labels and grid lines to be visible. | |
672 | */ |
|
672 | */ | |
673 | void QAbstractAxis::setVisible(bool visible) |
|
673 | void QAbstractAxis::setVisible(bool visible) | |
674 | { |
|
674 | { | |
675 | if (d_ptr->m_visible != visible) { |
|
675 | if (d_ptr->m_visible != visible) { | |
676 | d_ptr->m_visible = visible; |
|
676 | d_ptr->m_visible = visible; | |
677 | emit visibleChanged(visible); |
|
677 | emit visibleChanged(visible); | |
678 | } |
|
678 | } | |
679 | } |
|
679 | } | |
680 |
|
680 | |||
681 |
|
681 | |||
682 | /*! |
|
682 | /*! | |
683 | Sets axis, shades, labels and grid lines to be visible. |
|
683 | Sets axis, shades, labels and grid lines to be visible. | |
684 | */ |
|
684 | */ | |
685 | void QAbstractAxis::show() |
|
685 | void QAbstractAxis::show() | |
686 | { |
|
686 | { | |
687 | setVisible(true); |
|
687 | setVisible(true); | |
688 | } |
|
688 | } | |
689 |
|
689 | |||
690 | /*! |
|
690 | /*! | |
691 | Sets axis, shades, labels and grid lines to not be visible. |
|
691 | Sets axis, shades, labels and grid lines to not be visible. | |
692 | */ |
|
692 | */ | |
693 | void QAbstractAxis::hide() |
|
693 | void QAbstractAxis::hide() | |
694 | { |
|
694 | { | |
695 | setVisible(false); |
|
695 | setVisible(false); | |
696 | } |
|
696 | } | |
697 |
|
697 | |||
698 | /*! |
|
698 | /*! | |
699 | Sets the minimum value shown on the axis. |
|
699 | Sets the minimum value shown on the axis. | |
700 | Depending on the actual axis type the \a min parameter is converted to appropriate type. |
|
700 | Depending on the actual axis type the \a min parameter is converted to appropriate type. | |
701 | If the conversion is impossible then the function call does nothing |
|
701 | If the conversion is impossible then the function call does nothing | |
702 | */ |
|
702 | */ | |
703 | void QAbstractAxis::setMin(const QVariant &min) |
|
703 | void QAbstractAxis::setMin(const QVariant &min) | |
704 | { |
|
704 | { | |
705 | d_ptr->setMin(min); |
|
705 | d_ptr->setMin(min); | |
706 | } |
|
706 | } | |
707 |
|
707 | |||
708 | /*! |
|
708 | /*! | |
709 | Sets the maximum value shown on the axis. |
|
709 | Sets the maximum value shown on the axis. | |
710 | Depending on the actual axis type the \a max parameter is converted to appropriate type. |
|
710 | Depending on the actual axis type the \a max parameter is converted to appropriate type. | |
711 | If the conversion is impossible then the function call does nothing |
|
711 | If the conversion is impossible then the function call does nothing | |
712 | */ |
|
712 | */ | |
713 | void QAbstractAxis::setMax(const QVariant &max) |
|
713 | void QAbstractAxis::setMax(const QVariant &max) | |
714 | { |
|
714 | { | |
715 | d_ptr->setMax(max); |
|
715 | d_ptr->setMax(max); | |
716 | } |
|
716 | } | |
717 |
|
717 | |||
718 | /*! |
|
718 | /*! | |
719 | Sets the range shown on the axis. |
|
719 | Sets the range shown on the axis. | |
720 | Depending on the actual axis type the \a min and \a max parameters are converted to appropriate types. |
|
720 | Depending on the actual axis type the \a min and \a max parameters are converted to appropriate types. | |
721 | If the conversion is impossible then the function call does nothing. |
|
721 | If the conversion is impossible then the function call does nothing. | |
722 | */ |
|
722 | */ | |
723 | void QAbstractAxis::setRange(const QVariant &min, const QVariant &max) |
|
723 | void QAbstractAxis::setRange(const QVariant &min, const QVariant &max) | |
724 | { |
|
724 | { | |
725 | d_ptr->setRange(min, max); |
|
725 | d_ptr->setRange(min, max); | |
726 | } |
|
726 | } | |
727 |
|
727 | |||
728 |
|
728 | |||
729 | /*! |
|
729 | /*! | |
730 | Returns the orientation in which the axis is being used (Vertical or Horizontal) |
|
730 | Returns the orientation in which the axis is being used (Vertical or Horizontal) | |
731 | */ |
|
731 | */ | |
732 | // NOTE: should have const but it breaks BC: |
|
732 | // NOTE: should have const but it breaks BC: | |
733 | // http://techbase.kde.org/Policies/Binary_Compatibility_Examples#Change_the_CV-qualifiers_of_a_member_function |
|
733 | // http://techbase.kde.org/Policies/Binary_Compatibility_Examples#Change_the_CV-qualifiers_of_a_member_function | |
734 | Qt::Orientation QAbstractAxis::orientation() |
|
734 | Qt::Orientation QAbstractAxis::orientation() | |
735 | { |
|
735 | { | |
736 | return d_ptr->orientation(); |
|
736 | return d_ptr->orientation(); | |
737 | } |
|
737 | } | |
738 |
|
738 | |||
739 | Qt::Alignment QAbstractAxis::alignment() const |
|
739 | Qt::Alignment QAbstractAxis::alignment() const | |
740 | { |
|
740 | { | |
741 | return d_ptr->alignment(); |
|
741 | return d_ptr->alignment(); | |
742 | } |
|
742 | } | |
743 |
|
743 | |||
744 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
744 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
745 |
|
745 | |||
746 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis *q) |
|
746 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis *q) | |
747 | : q_ptr(q), |
|
747 | : q_ptr(q), | |
748 | m_chart(0), |
|
748 | m_chart(0), | |
749 | m_alignment(0), |
|
749 | m_alignment(0), | |
750 | m_orientation(Qt::Orientation(0)), |
|
750 | m_orientation(Qt::Orientation(0)), | |
751 | m_visible(true), |
|
751 | m_visible(true), | |
752 | m_arrowVisible(true), |
|
752 | m_arrowVisible(true), | |
753 | m_gridLineVisible(true), |
|
753 | m_gridLineVisible(true), | |
754 | m_labelsVisible(true), |
|
754 | m_labelsVisible(true), | |
755 | m_labelsAngle(0), |
|
755 | m_labelsAngle(0), | |
|
756 | m_titleVisible(true), | |||
756 | m_shadesVisible(false), |
|
757 | m_shadesVisible(false), | |
757 | m_shadesBrush(Qt::SolidPattern), |
|
758 | m_shadesBrush(Qt::SolidPattern), | |
758 | m_shadesOpacity(1.0), |
|
759 | m_shadesOpacity(1.0), | |
759 | m_dirty(false) |
|
760 | m_dirty(false) | |
760 | { |
|
761 | { | |
761 |
|
762 | |||
762 | } |
|
763 | } | |
763 |
|
764 | |||
764 | QAbstractAxisPrivate::~QAbstractAxisPrivate() |
|
765 | QAbstractAxisPrivate::~QAbstractAxisPrivate() | |
765 | { |
|
766 | { | |
766 | } |
|
767 | } | |
767 |
|
768 | |||
768 | void QAbstractAxisPrivate::setAlignment( Qt::Alignment alignment) |
|
769 | void QAbstractAxisPrivate::setAlignment( Qt::Alignment alignment) | |
769 | { |
|
770 | { | |
770 | switch(alignment) { |
|
771 | switch(alignment) { | |
771 | case Qt::AlignTop: |
|
772 | case Qt::AlignTop: | |
772 | case Qt::AlignBottom: |
|
773 | case Qt::AlignBottom: | |
773 | m_orientation = Qt::Horizontal; |
|
774 | m_orientation = Qt::Horizontal; | |
774 | break; |
|
775 | break; | |
775 | case Qt::AlignLeft: |
|
776 | case Qt::AlignLeft: | |
776 | case Qt::AlignRight: |
|
777 | case Qt::AlignRight: | |
777 | m_orientation = Qt::Vertical; |
|
778 | m_orientation = Qt::Vertical; | |
778 | break; |
|
779 | break; | |
779 | default: |
|
780 | default: | |
780 | qWarning()<<"No alignment specified !"; |
|
781 | qWarning()<<"No alignment specified !"; | |
781 | break; |
|
782 | break; | |
782 | }; |
|
783 | }; | |
783 | m_alignment=alignment; |
|
784 | m_alignment=alignment; | |
784 | } |
|
785 | } | |
785 |
|
786 | |||
786 | void QAbstractAxisPrivate::initializeTheme(ChartTheme* theme, bool forced) |
|
787 | void QAbstractAxisPrivate::initializeTheme(ChartTheme* theme, bool forced) | |
787 | { |
|
788 | { | |
788 | QPen pen; |
|
789 | QPen pen; | |
789 | QBrush brush; |
|
790 | QBrush brush; | |
790 | QFont font; |
|
791 | QFont font; | |
791 |
|
792 | |||
792 | bool axisX = m_orientation == Qt::Horizontal; |
|
793 | bool axisX = m_orientation == Qt::Horizontal; | |
793 |
|
794 | |||
794 | if (m_arrowVisible) { |
|
795 | if (m_arrowVisible) { | |
795 |
|
796 | |||
796 | if (forced || brush == m_labelsBrush){ |
|
797 | if (forced || brush == m_labelsBrush){ | |
797 | q_ptr->setLabelsBrush(theme->labelBrush()); |
|
798 | q_ptr->setLabelsBrush(theme->labelBrush()); | |
798 | } |
|
799 | } | |
799 | //TODO: introduce axis brush |
|
800 | //TODO: introduce axis brush | |
800 | if (forced || brush == m_titleBrush){ |
|
801 | if (forced || brush == m_titleBrush){ | |
801 | q_ptr->setTitleBrush(theme->labelBrush()); |
|
802 | q_ptr->setTitleBrush(theme->labelBrush()); | |
802 | } |
|
803 | } | |
803 | if (forced || pen == m_labelsPen){ |
|
804 | if (forced || pen == m_labelsPen){ | |
804 | q_ptr->setLabelsPen(Qt::NoPen);// NoPen for performance reasons |
|
805 | q_ptr->setLabelsPen(Qt::NoPen);// NoPen for performance reasons | |
805 | } |
|
806 | } | |
806 | if (forced || pen == m_titlePen){ |
|
807 | if (forced || pen == m_titlePen){ | |
807 | q_ptr->setTitlePen(Qt::NoPen);// Noen for performance reasons |
|
808 | q_ptr->setTitlePen(Qt::NoPen);// Noen for performance reasons | |
808 | } |
|
809 | } | |
809 | if (forced || m_shadesVisible) { |
|
810 | if (forced || m_shadesVisible) { | |
810 |
|
811 | |||
811 | if (forced || brush == m_shadesBrush){ |
|
812 | if (forced || brush == m_shadesBrush){ | |
812 | q_ptr->setShadesBrush(theme->backgroundShadesBrush()); |
|
813 | q_ptr->setShadesBrush(theme->backgroundShadesBrush()); | |
813 | } |
|
814 | } | |
814 | if (forced || pen == m_shadesPen){ |
|
815 | if (forced || pen == m_shadesPen){ | |
815 | q_ptr->setShadesPen(theme->backgroundShadesPen()); |
|
816 | q_ptr->setShadesPen(theme->backgroundShadesPen()); | |
816 | } |
|
817 | } | |
817 | if (forced && (theme->backgroundShades() == ChartTheme::BackgroundShadesBoth |
|
818 | if (forced && (theme->backgroundShades() == ChartTheme::BackgroundShadesBoth | |
818 | || (theme->backgroundShades() == ChartTheme::BackgroundShadesVertical && axisX) |
|
819 | || (theme->backgroundShades() == ChartTheme::BackgroundShadesVertical && axisX) | |
819 | || (theme->backgroundShades() == ChartTheme::BackgroundShadesHorizontal && !axisX))) { |
|
820 | || (theme->backgroundShades() == ChartTheme::BackgroundShadesHorizontal && !axisX))) { | |
820 | q_ptr->setShadesVisible(true); |
|
821 | q_ptr->setShadesVisible(true); | |
821 | } |
|
822 | } | |
822 | } |
|
823 | } | |
823 |
|
824 | |||
824 | if (forced || pen == m_axisPen) { |
|
825 | if (forced || pen == m_axisPen) { | |
825 | q_ptr->setLinePen(theme->axisLinePen()); |
|
826 | q_ptr->setLinePen(theme->axisLinePen()); | |
826 | } |
|
827 | } | |
827 |
|
828 | |||
828 | if (forced || pen == m_gridLinePen) { |
|
829 | if (forced || pen == m_gridLinePen) { | |
829 | q_ptr->setGridLinePen(theme->girdLinePen()); |
|
830 | q_ptr->setGridLinePen(theme->girdLinePen()); | |
830 | } |
|
831 | } | |
831 |
|
832 | |||
832 | if (forced || font == m_labelsFont){ |
|
833 | if (forced || font == m_labelsFont){ | |
833 | q_ptr->setLabelsFont(theme->labelFont()); |
|
834 | q_ptr->setLabelsFont(theme->labelFont()); | |
834 | } |
|
835 | } | |
835 | //TODO: discuss with Tero |
|
836 | //TODO: discuss with Tero | |
836 | if (forced || font == m_titleFont){ |
|
837 | if (forced || font == m_titleFont){ | |
837 | QFont font(m_labelsFont); |
|
838 | QFont font(m_labelsFont); | |
838 | font.setBold(true); |
|
839 | font.setBold(true); | |
839 | q_ptr->setTitleFont(font); |
|
840 | q_ptr->setTitleFont(font); | |
840 | } |
|
841 | } | |
841 | } |
|
842 | } | |
842 | } |
|
843 | } | |
843 |
|
844 | |||
844 | void QAbstractAxisPrivate::handleRangeChanged(qreal min, qreal max) |
|
845 | void QAbstractAxisPrivate::handleRangeChanged(qreal min, qreal max) | |
845 | { |
|
846 | { | |
846 | setRange(min,max); |
|
847 | setRange(min,max); | |
847 | } |
|
848 | } | |
848 |
|
849 | |||
849 | void QAbstractAxisPrivate::initializeGraphics(QGraphicsItem* parent) |
|
850 | void QAbstractAxisPrivate::initializeGraphics(QGraphicsItem* parent) | |
850 | { |
|
851 | { | |
851 | Q_UNUSED(parent); |
|
852 | Q_UNUSED(parent); | |
852 | } |
|
853 | } | |
853 |
|
854 | |||
854 | void QAbstractAxisPrivate::initializeAnimations(QChart::AnimationOptions options) |
|
855 | void QAbstractAxisPrivate::initializeAnimations(QChart::AnimationOptions options) | |
855 | { |
|
856 | { | |
856 | ChartAxis* axis = m_item.data(); |
|
857 | ChartAxis* axis = m_item.data(); | |
857 | Q_ASSERT(axis); |
|
858 | Q_ASSERT(axis); | |
858 | if(options.testFlag(QChart::GridAxisAnimations)) { |
|
859 | if(options.testFlag(QChart::GridAxisAnimations)) { | |
859 | axis->setAnimation(new AxisAnimation(axis)); |
|
860 | axis->setAnimation(new AxisAnimation(axis)); | |
860 | }else{ |
|
861 | }else{ | |
861 | axis->setAnimation(0); |
|
862 | axis->setAnimation(0); | |
862 | } |
|
863 | } | |
863 | } |
|
864 | } | |
864 |
|
865 | |||
865 |
|
866 | |||
866 |
|
867 | |||
867 | #include "moc_qabstractaxis.cpp" |
|
868 | #include "moc_qabstractaxis.cpp" | |
868 | #include "moc_qabstractaxis_p.cpp" |
|
869 | #include "moc_qabstractaxis_p.cpp" | |
869 |
|
870 | |||
870 | QTCOMMERCIALCHART_END_NAMESPACE |
|
871 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now