@@ -0,0 +1,122 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | #include "chartlogvalueaxisx_p.h" | |||
|
22 | #include "chartpresenter_p.h" | |||
|
23 | #include "qlogvalueaxis.h" | |||
|
24 | #include "chartlayout_p.h" | |||
|
25 | #include <QGraphicsLayout> | |||
|
26 | #include <QFontMetrics> | |||
|
27 | #include <qmath.h> | |||
|
28 | ||||
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
30 | ||||
|
31 | ChartLogValueAxisX::ChartLogValueAxisX(QLogValueAxis *axis, QGraphicsItem* item) | |||
|
32 | : HorizontalAxis(axis, item), | |||
|
33 | m_axis(axis) | |||
|
34 | { | |||
|
35 | } | |||
|
36 | ||||
|
37 | ChartLogValueAxisX::~ChartLogValueAxisX() | |||
|
38 | { | |||
|
39 | } | |||
|
40 | ||||
|
41 | QVector<qreal> ChartLogValueAxisX::calculateLayout() const | |||
|
42 | { | |||
|
43 | QVector<qreal> points; | |||
|
44 | ||||
|
45 | qreal logMax = log10(m_axis->max()) / log10(m_axis->base()); | |||
|
46 | qreal logMin = log10(m_axis->min()) / log10(m_axis->base()); | |||
|
47 | int tickCount = qAbs(qRound(logMax - logMin)); | |||
|
48 | ||||
|
49 | points.resize(tickCount); | |||
|
50 | const QRectF &gridRect = gridGeometry(); | |||
|
51 | const qreal deltaX = gridRect.width() / qAbs(logMax - logMin); | |||
|
52 | for (int i = 0; i < tickCount; ++i) | |||
|
53 | if (logMax > logMin) | |||
|
54 | points[i] = ((int)logMin + i) * deltaX - logMin * deltaX + gridRect.left(); | |||
|
55 | else | |||
|
56 | points[i] = ((int)logMax + i) * deltaX - logMax * deltaX + gridRect.left(); | |||
|
57 | ||||
|
58 | return points; | |||
|
59 | } | |||
|
60 | ||||
|
61 | void ChartLogValueAxisX::updateGeometry() | |||
|
62 | { | |||
|
63 | const QVector<qreal>& layout = ChartAxis::layout(); | |||
|
64 | if (layout.isEmpty()) | |||
|
65 | return; | |||
|
66 | setLabels(createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), layout.size(), m_axis->labelFormat())); | |||
|
67 | HorizontalAxis::updateGeometry(); | |||
|
68 | } | |||
|
69 | ||||
|
70 | //void ChartLogValueAxisX::handleAxisUpdated() | |||
|
71 | //{ | |||
|
72 | // ChartAxis::handleAxisUpdated(); | |||
|
73 | //} | |||
|
74 | ||||
|
75 | QSizeF ChartLogValueAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const | |||
|
76 | { | |||
|
77 | Q_UNUSED(constraint) | |||
|
78 | ||||
|
79 | QFontMetrics fn(font()); | |||
|
80 | QSizeF sh; | |||
|
81 | ||||
|
82 | QSizeF base = HorizontalAxis::sizeHint(which, constraint); | |||
|
83 | QStringList ticksList; | |||
|
84 | qreal logMax = log10(m_axis->max()) / log10(m_axis->base()); | |||
|
85 | qreal logMin = log10(m_axis->min()) / log10(m_axis->base()); | |||
|
86 | int tickCount = qAbs(qRound(logMax - logMin)); | |||
|
87 | ||||
|
88 | if (m_axis->max() > m_axis->min() && tickCount > 1) | |||
|
89 | ticksList = createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), tickCount, m_axis->labelFormat()); | |||
|
90 | else | |||
|
91 | ticksList.append(QString(" ")); | |||
|
92 | qreal width = 0; | |||
|
93 | qreal height = 0; | |||
|
94 | ||||
|
95 | ||||
|
96 | switch (which) { | |||
|
97 | case Qt::MinimumSize:{ | |||
|
98 | int count = qMax(ticksList.last().count(),ticksList.first().count()); | |||
|
99 | width = fn.averageCharWidth() * count; | |||
|
100 | height = fn.height() + labelPadding(); | |||
|
101 | width = qMax(width,base.width()); | |||
|
102 | height += base.height(); | |||
|
103 | sh = QSizeF(width,height); | |||
|
104 | break; | |||
|
105 | } | |||
|
106 | case Qt::PreferredSize: { | |||
|
107 | int count = qMax(ticksList.last().count(),ticksList.first().count()); | |||
|
108 | width=fn.averageCharWidth() * count; | |||
|
109 | height=fn.height()+labelPadding(); | |||
|
110 | width=qMax(width,base.width()); | |||
|
111 | height+=base.height(); | |||
|
112 | sh = QSizeF(width,height); | |||
|
113 | break; | |||
|
114 | } | |||
|
115 | default: | |||
|
116 | break; | |||
|
117 | } | |||
|
118 | ||||
|
119 | return sh; | |||
|
120 | } | |||
|
121 | ||||
|
122 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,59 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | // W A R N I N G | |||
|
22 | // ------------- | |||
|
23 | // | |||
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |||
|
25 | // implementation detail. This header file may change from version to | |||
|
26 | // version without notice, or even be removed. | |||
|
27 | // | |||
|
28 | // We mean it. | |||
|
29 | ||||
|
30 | #ifndef CHARTLOGVALUEAXISX_H | |||
|
31 | #define CHARTLOGVALUEAXISX_H | |||
|
32 | ||||
|
33 | #include "horizontalaxis_p.h" | |||
|
34 | ||||
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
36 | ||||
|
37 | class QLogValueAxis; | |||
|
38 | class ChartPresenter; | |||
|
39 | ||||
|
40 | class ChartLogValueAxisX : public HorizontalAxis | |||
|
41 | { | |||
|
42 | public: | |||
|
43 | ChartLogValueAxisX(QLogValueAxis *axis, QGraphicsItem* item); | |||
|
44 | ~ChartLogValueAxisX(); | |||
|
45 | ||||
|
46 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; | |||
|
47 | ||||
|
48 | protected: | |||
|
49 | void handleAxisUpdated(); | |||
|
50 | QVector<qreal> calculateLayout() const; | |||
|
51 | void updateGeometry(); | |||
|
52 | ||||
|
53 | private: | |||
|
54 | QLogValueAxis *m_axis; | |||
|
55 | }; | |||
|
56 | ||||
|
57 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
58 | ||||
|
59 | #endif /* CHARTLOGVALUEAXISX_H */ |
@@ -0,0 +1,119 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | #include "chartlogvalueaxisy_p.h" | |||
|
22 | #include "chartpresenter_p.h" | |||
|
23 | #include "qlogvalueaxis.h" | |||
|
24 | #include "chartlayout_p.h" | |||
|
25 | #include <QGraphicsLayout> | |||
|
26 | #include <QFontMetrics> | |||
|
27 | #include <qmath.h> | |||
|
28 | ||||
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
30 | ||||
|
31 | ChartLogValueAxisY::ChartLogValueAxisY(QLogValueAxis *axis, QGraphicsItem* item) | |||
|
32 | : VerticalAxis(axis, item), | |||
|
33 | m_axis(axis) | |||
|
34 | { | |||
|
35 | } | |||
|
36 | ||||
|
37 | ChartLogValueAxisY::~ChartLogValueAxisY() | |||
|
38 | { | |||
|
39 | } | |||
|
40 | ||||
|
41 | QVector<qreal> ChartLogValueAxisY::calculateLayout() const | |||
|
42 | { | |||
|
43 | QVector<qreal> points; | |||
|
44 | qreal logMax = log10(m_axis->max()) / log10(m_axis->base()); | |||
|
45 | qreal logMin = log10(m_axis->min()) / log10(m_axis->base()); | |||
|
46 | int tickCount = qAbs(qRound(logMax - logMin)); | |||
|
47 | ||||
|
48 | points.resize(tickCount); | |||
|
49 | const QRectF &gridRect = gridGeometry(); | |||
|
50 | const qreal deltaY = gridRect.height() / qAbs(logMax - logMin); | |||
|
51 | for (int i = 0; i < tickCount; ++i) | |||
|
52 | if (logMax > logMin) | |||
|
53 | points[i] = ((int)logMin + i) * -deltaY - logMin * -deltaY + gridRect.bottom(); | |||
|
54 | else | |||
|
55 | points[i] = ((int)logMax + i) * -deltaY - logMax * -deltaY + gridRect.bottom(); | |||
|
56 | ||||
|
57 | return points; | |||
|
58 | } | |||
|
59 | ||||
|
60 | ||||
|
61 | void ChartLogValueAxisY::updateGeometry() | |||
|
62 | { | |||
|
63 | const QVector<qreal> &layout = ChartAxis::layout(); | |||
|
64 | if (layout.isEmpty()) | |||
|
65 | return; | |||
|
66 | setLabels(createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), layout.size(), m_axis->labelFormat())); | |||
|
67 | VerticalAxis::updateGeometry(); | |||
|
68 | } | |||
|
69 | ||||
|
70 | //void ChartLogValueAxisY::handleAxisUpdated() | |||
|
71 | //{ | |||
|
72 | // ChartAxis::handleAxisUpdated(); | |||
|
73 | //} | |||
|
74 | ||||
|
75 | QSizeF ChartLogValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const | |||
|
76 | { | |||
|
77 | Q_UNUSED(constraint) | |||
|
78 | ||||
|
79 | QFontMetrics fn(font()); | |||
|
80 | QSizeF sh; | |||
|
81 | ||||
|
82 | QSizeF base = VerticalAxis::sizeHint(which, constraint); | |||
|
83 | QStringList ticksList; | |||
|
84 | qreal logMax = log10(m_axis->max()) / log10(m_axis->base()); | |||
|
85 | qreal logMin = log10(m_axis->min()) / log10(m_axis->base()); | |||
|
86 | int tickCount = qAbs(qRound(logMax - logMin)); | |||
|
87 | if (m_axis->max() > m_axis->min() && tickCount > 1) | |||
|
88 | ticksList = createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), tickCount, m_axis->labelFormat()); | |||
|
89 | else | |||
|
90 | ticksList.append(QString(" ")); | |||
|
91 | qreal width = 0; | |||
|
92 | qreal height = 0; | |||
|
93 | ||||
|
94 | switch (which) { | |||
|
95 | case Qt::MinimumSize: { | |||
|
96 | width = fn.boundingRect("...").width() + labelPadding(); | |||
|
97 | width += base.width(); | |||
|
98 | height = fn.height(); | |||
|
99 | height = qMax(height,base.height()); | |||
|
100 | sh = QSizeF(width,height); | |||
|
101 | break; | |||
|
102 | } | |||
|
103 | case Qt::PreferredSize: { | |||
|
104 | int count = qMax(ticksList.first().count() , ticksList.last().count()); | |||
|
105 | width = count*fn.averageCharWidth() + labelPadding() + 2; //two pixels of tolerance | |||
|
106 | width += base.width(); | |||
|
107 | height = fn.height() * ticksList.count(); | |||
|
108 | height = qMax(height,base.height()); | |||
|
109 | sh = QSizeF(width,height); | |||
|
110 | break; | |||
|
111 | } | |||
|
112 | default: | |||
|
113 | break; | |||
|
114 | } | |||
|
115 | ||||
|
116 | return sh; | |||
|
117 | } | |||
|
118 | ||||
|
119 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,59 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | // W A R N I N G | |||
|
22 | // ------------- | |||
|
23 | // | |||
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |||
|
25 | // implementation detail. This header file may change from version to | |||
|
26 | // version without notice, or even be removed. | |||
|
27 | // | |||
|
28 | // We mean it. | |||
|
29 | ||||
|
30 | #ifndef CHARTLOGVALUEAXISY_H | |||
|
31 | #define CHARTLOGVALUEAXISY_H | |||
|
32 | ||||
|
33 | #include "verticalaxis_p.h" | |||
|
34 | ||||
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
36 | ||||
|
37 | class QLogValueAxis; | |||
|
38 | class ChartPresenter; | |||
|
39 | ||||
|
40 | class ChartLogValueAxisY : public VerticalAxis | |||
|
41 | { | |||
|
42 | public: | |||
|
43 | ChartLogValueAxisY(QLogValueAxis *axis, QGraphicsItem* item); | |||
|
44 | ~ChartLogValueAxisY(); | |||
|
45 | ||||
|
46 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; | |||
|
47 | ||||
|
48 | protected: | |||
|
49 | void handleAxisUpdated(); | |||
|
50 | QVector<qreal> calculateLayout() const; | |||
|
51 | void updateGeometry(); | |||
|
52 | ||||
|
53 | private: | |||
|
54 | QLogValueAxis *m_axis; | |||
|
55 | }; | |||
|
56 | ||||
|
57 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
58 | ||||
|
59 | #endif /* CHARTLOGVALUEAXISY_H */ |
@@ -0,0 +1,315 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | #include "qlogvalueaxis.h" | |||
|
22 | #include "qlogvalueaxis_p.h" | |||
|
23 | #include "chartlogvalueaxisx_p.h" | |||
|
24 | #include "chartlogvalueaxisy_p.h" | |||
|
25 | #include "domain_p.h" | |||
|
26 | #include <float.h> | |||
|
27 | #include <cmath> | |||
|
28 | ||||
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
30 | /*! | |||
|
31 | \class QLogValueAxis | |||
|
32 | \brief The QLogValueAxis class is used for manipulating chart's axis. | |||
|
33 | \mainclass | |||
|
34 | */ | |||
|
35 | ||||
|
36 | /*! | |||
|
37 | \qmlclass DateTimeAxis QLogValueAxis | |||
|
38 | \brief The DateTimeAxis element is used for manipulating chart's axes | |||
|
39 | \inherits AbstractAxis | |||
|
40 | */ | |||
|
41 | ||||
|
42 | /*! | |||
|
43 | \property QLogValueAxis::min | |||
|
44 | Defines the minimum value on the axis. | |||
|
45 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. | |||
|
46 | */ | |||
|
47 | /*! | |||
|
48 | \qmlproperty real ValuesAxis::min | |||
|
49 | Defines the minimum value on the axis. | |||
|
50 | When setting this property the max is adjusted if necessary, to ensure that the range remains valid. | |||
|
51 | */ | |||
|
52 | ||||
|
53 | /*! | |||
|
54 | \property QLogValueAxis::max | |||
|
55 | Defines the maximum value on the axis. | |||
|
56 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. | |||
|
57 | */ | |||
|
58 | /*! | |||
|
59 | \qmlproperty real ValuesAxis::max | |||
|
60 | Defines the maximum value on the axis. | |||
|
61 | When setting this property the min is adjusted if necessary, to ensure that the range remains valid. | |||
|
62 | */ | |||
|
63 | ||||
|
64 | /*! | |||
|
65 | \fn void QLogValueAxis::minChanged(qreal min) | |||
|
66 | Axis emits signal when \a min of axis has changed. | |||
|
67 | */ | |||
|
68 | /*! | |||
|
69 | \qmlsignal ValuesAxis::onMinChanged(qreal min) | |||
|
70 | Axis emits signal when \a min of axis has changed. | |||
|
71 | */ | |||
|
72 | ||||
|
73 | /*! | |||
|
74 | \fn void QLogValueAxis::maxChanged(qreal max) | |||
|
75 | Axis emits signal when \a max of axis has changed. | |||
|
76 | */ | |||
|
77 | /*! | |||
|
78 | \qmlsignal ValuesAxis::onMaxChanged(qreal max) | |||
|
79 | Axis emits signal when \a max of axis has changed. | |||
|
80 | */ | |||
|
81 | ||||
|
82 | /*! | |||
|
83 | \fn void QLogValueAxis::rangeChanged(qreal min, qreal max) | |||
|
84 | Axis emits signal when \a min or \a max of axis has changed. | |||
|
85 | */ | |||
|
86 | ||||
|
87 | /*! | |||
|
88 | Constructs an axis object which is a child of \a parent. | |||
|
89 | */ | |||
|
90 | QLogValueAxis::QLogValueAxis(QObject *parent) : | |||
|
91 | QAbstractAxis(*new QLogValueAxisPrivate(this), parent) | |||
|
92 | { | |||
|
93 | ||||
|
94 | } | |||
|
95 | ||||
|
96 | /*! | |||
|
97 | \internal | |||
|
98 | */ | |||
|
99 | QLogValueAxis::QLogValueAxis(QLogValueAxisPrivate &d, QObject *parent) : QAbstractAxis(d, parent) | |||
|
100 | { | |||
|
101 | ||||
|
102 | } | |||
|
103 | ||||
|
104 | /*! | |||
|
105 | Destroys the object | |||
|
106 | */ | |||
|
107 | QLogValueAxis::~QLogValueAxis() | |||
|
108 | { | |||
|
109 | ||||
|
110 | } | |||
|
111 | ||||
|
112 | void QLogValueAxis::setMin(qreal min) | |||
|
113 | { | |||
|
114 | Q_D(QLogValueAxis); | |||
|
115 | setRange(min, qMax(d->m_max, min)); | |||
|
116 | } | |||
|
117 | ||||
|
118 | qreal QLogValueAxis::min() const | |||
|
119 | { | |||
|
120 | Q_D(const QLogValueAxis); | |||
|
121 | return d->m_min; | |||
|
122 | } | |||
|
123 | ||||
|
124 | void QLogValueAxis::setMax(qreal max) | |||
|
125 | { | |||
|
126 | Q_D(QLogValueAxis); | |||
|
127 | setRange(qMin(d->m_min, max), max); | |||
|
128 | } | |||
|
129 | ||||
|
130 | qreal QLogValueAxis::max() const | |||
|
131 | { | |||
|
132 | Q_D(const QLogValueAxis); | |||
|
133 | return d->m_max; | |||
|
134 | } | |||
|
135 | ||||
|
136 | /*! | |||
|
137 | Sets range from \a min to \a max on the axis. | |||
|
138 | If min is greater than max then this function returns without making any changes. | |||
|
139 | */ | |||
|
140 | void QLogValueAxis::setRange(qreal min, qreal max) | |||
|
141 | { | |||
|
142 | Q_D(QLogValueAxis); | |||
|
143 | bool changed = false; | |||
|
144 | ||||
|
145 | if (min > max) | |||
|
146 | return; | |||
|
147 | ||||
|
148 | if (min > 0) { | |||
|
149 | if (!qFuzzyCompare(d->m_min, min)) { | |||
|
150 | d->m_min = min; | |||
|
151 | changed = true; | |||
|
152 | emit minChanged(min); | |||
|
153 | } | |||
|
154 | ||||
|
155 | if (!qFuzzyCompare(d->m_max, max)) { | |||
|
156 | d->m_max = max; | |||
|
157 | changed = true; | |||
|
158 | emit maxChanged(max); | |||
|
159 | } | |||
|
160 | ||||
|
161 | if (changed) { | |||
|
162 | emit rangeChanged(min, max); | |||
|
163 | emit d->rangeChanged(min,max); | |||
|
164 | } | |||
|
165 | } | |||
|
166 | } | |||
|
167 | ||||
|
168 | void QLogValueAxis::setLabelFormat(const QString &format) | |||
|
169 | { | |||
|
170 | Q_D(QLogValueAxis); | |||
|
171 | d->m_format = format; | |||
|
172 | } | |||
|
173 | ||||
|
174 | QString QLogValueAxis::labelFormat() const | |||
|
175 | { | |||
|
176 | Q_D(const QLogValueAxis); | |||
|
177 | return d->m_format; | |||
|
178 | } | |||
|
179 | ||||
|
180 | void QLogValueAxis::setBase(qreal base) | |||
|
181 | { | |||
|
182 | // check if base is correct | |||
|
183 | if (base <= 0 || qFuzzyCompare(base, 1)) | |||
|
184 | return; | |||
|
185 | ||||
|
186 | Q_D(QLogValueAxis); | |||
|
187 | d->m_base = base; | |||
|
188 | } | |||
|
189 | ||||
|
190 | qreal QLogValueAxis::base() const | |||
|
191 | { | |||
|
192 | Q_D(const QLogValueAxis); | |||
|
193 | return d->m_base; | |||
|
194 | } | |||
|
195 | ||||
|
196 | /*! | |||
|
197 | Returns the type of the axis | |||
|
198 | */ | |||
|
199 | QAbstractAxis::AxisType QLogValueAxis::type() const | |||
|
200 | { | |||
|
201 | return AxisTypeLogValue; | |||
|
202 | } | |||
|
203 | ||||
|
204 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |||
|
205 | ||||
|
206 | QLogValueAxisPrivate::QLogValueAxisPrivate(QLogValueAxis *q) | |||
|
207 | : QAbstractAxisPrivate(q), | |||
|
208 | m_min(1), | |||
|
209 | m_max(10), | |||
|
210 | m_base(10), | |||
|
211 | m_format(QString::null) | |||
|
212 | { | |||
|
213 | } | |||
|
214 | ||||
|
215 | QLogValueAxisPrivate::~QLogValueAxisPrivate() | |||
|
216 | { | |||
|
217 | ||||
|
218 | } | |||
|
219 | ||||
|
220 | void QLogValueAxisPrivate::setMin(const QVariant &min) | |||
|
221 | { | |||
|
222 | Q_Q(QLogValueAxis); | |||
|
223 | bool ok; | |||
|
224 | qreal value = min.toReal(&ok); | |||
|
225 | if (ok) | |||
|
226 | q->setMin(value); | |||
|
227 | } | |||
|
228 | ||||
|
229 | void QLogValueAxisPrivate::setMax(const QVariant &max) | |||
|
230 | { | |||
|
231 | ||||
|
232 | Q_Q(QLogValueAxis); | |||
|
233 | bool ok; | |||
|
234 | qreal value = max.toReal(&ok); | |||
|
235 | if (ok) | |||
|
236 | q->setMax(value); | |||
|
237 | } | |||
|
238 | ||||
|
239 | void QLogValueAxisPrivate::setRange(const QVariant &min, const QVariant &max) | |||
|
240 | { | |||
|
241 | Q_Q(QLogValueAxis); | |||
|
242 | bool ok1; | |||
|
243 | bool ok2; | |||
|
244 | qreal value1 = min.toReal(&ok1); | |||
|
245 | qreal value2 = max.toReal(&ok2); | |||
|
246 | if (ok1 && ok2) | |||
|
247 | q->setRange(value1, value2); | |||
|
248 | } | |||
|
249 | ||||
|
250 | void QLogValueAxisPrivate::setRange(qreal min, qreal max) | |||
|
251 | { | |||
|
252 | Q_Q(QLogValueAxis); | |||
|
253 | bool changed = false; | |||
|
254 | ||||
|
255 | if (min > max) | |||
|
256 | return; | |||
|
257 | ||||
|
258 | if (min > 0) { | |||
|
259 | if (!qFuzzyCompare(m_min, min)) { | |||
|
260 | m_min = min; | |||
|
261 | changed = true; | |||
|
262 | emit q->minChanged(min); | |||
|
263 | } | |||
|
264 | ||||
|
265 | if (!qFuzzyCompare(m_max, max)) { | |||
|
266 | m_max = max; | |||
|
267 | changed = true; | |||
|
268 | emit q->maxChanged(max); | |||
|
269 | } | |||
|
270 | ||||
|
271 | if (changed) { | |||
|
272 | emit q->rangeChanged(min, max); | |||
|
273 | emit rangeChanged(min,max); | |||
|
274 | } | |||
|
275 | } | |||
|
276 | } | |||
|
277 | ||||
|
278 | void QLogValueAxisPrivate::initializeGraphics(QGraphicsItem* parent) | |||
|
279 | { | |||
|
280 | Q_Q(QLogValueAxis); | |||
|
281 | ChartAxis* axis(0); | |||
|
282 | if (orientation() == Qt::Vertical) | |||
|
283 | axis = new ChartLogValueAxisY(q,parent); | |||
|
284 | if (orientation() == Qt::Horizontal) | |||
|
285 | axis = new ChartLogValueAxisX(q,parent); | |||
|
286 | ||||
|
287 | m_item.reset(axis); | |||
|
288 | QAbstractAxisPrivate::initializeGraphics(parent); | |||
|
289 | } | |||
|
290 | ||||
|
291 | ||||
|
292 | void QLogValueAxisPrivate::initializeDomain(Domain *domain) | |||
|
293 | { | |||
|
294 | if (orientation() == Qt::Vertical) { | |||
|
295 | if(!qFuzzyCompare(m_max, m_min)) { | |||
|
296 | domain->setRangeY(m_min, m_max); | |||
|
297 | } | |||
|
298 | else { | |||
|
299 | setRange(domain->minY() + 1, domain->maxY()); | |||
|
300 | } | |||
|
301 | } | |||
|
302 | if (orientation() == Qt::Horizontal) { | |||
|
303 | if(!qFuzzyCompare(m_max, m_min)) { | |||
|
304 | domain->setRangeX(m_min, m_max); | |||
|
305 | } | |||
|
306 | else { | |||
|
307 | setRange(domain->minX() + 1, domain->maxX()); | |||
|
308 | } | |||
|
309 | } | |||
|
310 | } | |||
|
311 | ||||
|
312 | #include "moc_qlogvalueaxis.cpp" | |||
|
313 | #include "moc_qlogvalueaxis_p.cpp" | |||
|
314 | ||||
|
315 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,74 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | #ifndef QLOGVALUEAXIS_H | |||
|
22 | #define QLOGVALUEAXIS_H | |||
|
23 | ||||
|
24 | #include "qabstractaxis.h" | |||
|
25 | ||||
|
26 | class QDateTime; | |||
|
27 | ||||
|
28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
29 | ||||
|
30 | class QLogValueAxisPrivate; | |||
|
31 | ||||
|
32 | class QTCOMMERCIALCHART_EXPORT QLogValueAxis : public QAbstractAxis | |||
|
33 | { | |||
|
34 | Q_OBJECT | |||
|
35 | Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged) | |||
|
36 | Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged) | |||
|
37 | Q_PROPERTY(QString labelFormat READ labelFormat WRITE setLabelFormat) | |||
|
38 | ||||
|
39 | public: | |||
|
40 | explicit QLogValueAxis(QObject *parent = 0); | |||
|
41 | ~QLogValueAxis(); | |||
|
42 | ||||
|
43 | protected: | |||
|
44 | QLogValueAxis(QLogValueAxisPrivate &d, QObject *parent = 0); | |||
|
45 | ||||
|
46 | public: | |||
|
47 | AxisType type() const; | |||
|
48 | ||||
|
49 | //range handling | |||
|
50 | void setMin(qreal min); | |||
|
51 | qreal min() const; | |||
|
52 | void setMax(qreal max); | |||
|
53 | qreal max() const; | |||
|
54 | void setRange(qreal min, qreal max); | |||
|
55 | ||||
|
56 | void setLabelFormat(const QString &format); | |||
|
57 | QString labelFormat() const; | |||
|
58 | ||||
|
59 | void setBase(qreal base); | |||
|
60 | qreal base() const; | |||
|
61 | ||||
|
62 | Q_SIGNALS: | |||
|
63 | void minChanged(qreal min); | |||
|
64 | void maxChanged(qreal max); | |||
|
65 | void rangeChanged(qreal min, qreal max); | |||
|
66 | ||||
|
67 | private: | |||
|
68 | Q_DECLARE_PRIVATE(QLogValueAxis) | |||
|
69 | Q_DISABLE_COPY(QLogValueAxis) | |||
|
70 | }; | |||
|
71 | ||||
|
72 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
73 | ||||
|
74 | #endif // QLOGVALUEAXIS_H |
@@ -0,0 +1,69 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | // W A R N I N G | |||
|
22 | // ------------- | |||
|
23 | // | |||
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |||
|
25 | // implementation detail. This header file may change from version to | |||
|
26 | // version without notice, or even be removed. | |||
|
27 | // | |||
|
28 | // We mean it. | |||
|
29 | ||||
|
30 | #ifndef QLOGVALUEAXIS_P_H | |||
|
31 | #define QLOGVALUEAXIS_P_H | |||
|
32 | ||||
|
33 | #include "qlogvalueaxis.h" | |||
|
34 | #include "qabstractaxis_p.h" | |||
|
35 | ||||
|
36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
37 | ||||
|
38 | class QLogValueAxisPrivate : public QAbstractAxisPrivate | |||
|
39 | { | |||
|
40 | Q_OBJECT | |||
|
41 | public: | |||
|
42 | QLogValueAxisPrivate(QLogValueAxis *q); | |||
|
43 | ~QLogValueAxisPrivate(); | |||
|
44 | ||||
|
45 | public: | |||
|
46 | void initializeGraphics(QGraphicsItem* parent); | |||
|
47 | void initializeDomain(Domain *domain); | |||
|
48 | ||||
|
49 | qreal min() { return m_min; } | |||
|
50 | qreal max() { return m_max; } | |||
|
51 | void setRange(qreal min,qreal max); | |||
|
52 | ||||
|
53 | protected: | |||
|
54 | void setMin(const QVariant &min); | |||
|
55 | void setMax(const QVariant &max); | |||
|
56 | void setRange(const QVariant &min, const QVariant &max); | |||
|
57 | int tickCount() const; | |||
|
58 | ||||
|
59 | protected: | |||
|
60 | qreal m_min; | |||
|
61 | qreal m_max; | |||
|
62 | qreal m_base; | |||
|
63 | QString m_format; | |||
|
64 | Q_DECLARE_PUBLIC(QLogValueAxis) | |||
|
65 | }; | |||
|
66 | ||||
|
67 | QTCOMMERCIALCHART_END_NAMESPACE | |||
|
68 | ||||
|
69 | #endif // QLOGVALUEAXIS_P_H |
@@ -1,68 +1,78 | |||||
1 | #Subdirectiores are defined here, because qt creator doesn't handle nested include(foo.pri) chains very well. |
|
1 | #Subdirectiores are defined here, because qt creator doesn't handle nested include(foo.pri) chains very well. | |
2 |
|
2 | |||
3 | INCLUDEPATH += $$PWD \ |
|
3 | INCLUDEPATH += $$PWD \ | |
4 | $$PWD/valueaxis \ |
|
4 | $$PWD/valueaxis \ | |
5 | $$PWD/barcategoryaxis \ |
|
5 | $$PWD/barcategoryaxis \ | |
6 | $$PWD/categoryaxis |
|
6 | $$PWD/categoryaxis \ | |
|
7 | $$PWD/logvalueaxis | |||
7 |
|
8 | |||
8 | DEPENDPATH += $$PWD \ |
|
9 | DEPENDPATH += $$PWD \ | |
9 | $$PWD/valueaxis \ |
|
10 | $$PWD/valueaxis \ | |
10 | $$PWD/barcategoryaxis \ |
|
11 | $$PWD/barcategoryaxis \ | |
11 | $$PWD/categoryaxis |
|
12 | $$PWD/categoryaxis \ | |
|
13 | $$PWD/logvalueaxis | |||
12 |
|
14 | |||
13 | SOURCES += \ |
|
15 | SOURCES += \ | |
14 | $$PWD/chartaxis.cpp \ |
|
16 | $$PWD/chartaxis.cpp \ | |
15 | $$PWD/qabstractaxis.cpp \ |
|
17 | $$PWD/qabstractaxis.cpp \ | |
16 | $$PWD/verticalaxis.cpp \ |
|
18 | $$PWD/verticalaxis.cpp \ | |
17 | $$PWD/horizontalaxis.cpp \ |
|
19 | $$PWD/horizontalaxis.cpp \ | |
18 | $$PWD/valueaxis/chartvalueaxisx.cpp \ |
|
20 | $$PWD/valueaxis/chartvalueaxisx.cpp \ | |
19 | $$PWD/valueaxis/chartvalueaxisy.cpp \ |
|
21 | $$PWD/valueaxis/chartvalueaxisy.cpp \ | |
20 | $$PWD/valueaxis/qvalueaxis.cpp \ |
|
22 | $$PWD/valueaxis/qvalueaxis.cpp \ | |
21 | $$PWD/barcategoryaxis/chartbarcategoryaxisx.cpp \ |
|
23 | $$PWD/barcategoryaxis/chartbarcategoryaxisx.cpp \ | |
22 | $$PWD/barcategoryaxis/chartbarcategoryaxisy.cpp \ |
|
24 | $$PWD/barcategoryaxis/chartbarcategoryaxisy.cpp \ | |
23 | $$PWD/barcategoryaxis/qbarcategoryaxis.cpp \ |
|
25 | $$PWD/barcategoryaxis/qbarcategoryaxis.cpp \ | |
24 | $$PWD/categoryaxis/chartcategoryaxisx.cpp \ |
|
26 | $$PWD/categoryaxis/chartcategoryaxisx.cpp \ | |
25 | $$PWD/categoryaxis/chartcategoryaxisy.cpp \ |
|
27 | $$PWD/categoryaxis/chartcategoryaxisy.cpp \ | |
26 | $$PWD/categoryaxis/qcategoryaxis.cpp |
|
28 | $$PWD/categoryaxis/qcategoryaxis.cpp \ | |
|
29 | $$PWD/logvalueaxis/chartlogvalueaxisx.cpp \ | |||
|
30 | $$PWD/logvalueaxis/chartlogvalueaxisy.cpp \ | |||
|
31 | $$PWD/logvalueaxis/qlogvalueaxis.cpp | |||
27 |
|
32 | |||
28 | PRIVATE_HEADERS += \ |
|
33 | PRIVATE_HEADERS += \ | |
29 | $$PWD/chartaxis_p.h \ |
|
34 | $$PWD/chartaxis_p.h \ | |
30 | $$PWD/qabstractaxis_p.h \ |
|
35 | $$PWD/qabstractaxis_p.h \ | |
31 | $$PWD/verticalaxis_p.h \ |
|
36 | $$PWD/verticalaxis_p.h \ | |
32 | $$PWD/horizontalaxis_p.h \ |
|
37 | $$PWD/horizontalaxis_p.h \ | |
33 | $$PWD/valueaxis/chartvalueaxisx_p.h \ |
|
38 | $$PWD/valueaxis/chartvalueaxisx_p.h \ | |
34 | $$PWD/valueaxis/chartvalueaxisy_p.h \ |
|
39 | $$PWD/valueaxis/chartvalueaxisy_p.h \ | |
35 | $$PWD/valueaxis/qvalueaxis_p.h \ |
|
40 | $$PWD/valueaxis/qvalueaxis_p.h \ | |
36 | $$PWD/barcategoryaxis/chartbarcategoryaxisx_p.h \ |
|
41 | $$PWD/barcategoryaxis/chartbarcategoryaxisx_p.h \ | |
37 | $$PWD/barcategoryaxis/chartbarcategoryaxisy_p.h \ |
|
42 | $$PWD/barcategoryaxis/chartbarcategoryaxisy_p.h \ | |
38 | $$PWD/barcategoryaxis/qbarcategoryaxis_p.h \ |
|
43 | $$PWD/barcategoryaxis/qbarcategoryaxis_p.h \ | |
39 | $$PWD/categoryaxis/chartcategoryaxisx_p.h \ |
|
44 | $$PWD/categoryaxis/chartcategoryaxisx_p.h \ | |
40 | $$PWD/categoryaxis/chartcategoryaxisy_p.h \ |
|
45 | $$PWD/categoryaxis/chartcategoryaxisy_p.h \ | |
41 | $$PWD/categoryaxis/qcategoryaxis_p.h |
|
46 | $$PWD/categoryaxis/qcategoryaxis_p.h \ | |
|
47 | $$PWD/logvalueaxis/chartlogvalueaxisx_p.h \ | |||
|
48 | $$PWD/logvalueaxis/chartlogvalueaxisy_p.h \ | |||
|
49 | $$PWD/logvalueaxis/qlogvalueaxis_p.h | |||
42 |
|
50 | |||
43 | PUBLIC_HEADERS += \ |
|
51 | PUBLIC_HEADERS += \ | |
44 | $$PWD/qabstractaxis.h \ |
|
52 | $$PWD/qabstractaxis.h \ | |
45 | $$PWD/valueaxis/qvalueaxis.h \ |
|
53 | $$PWD/valueaxis/qvalueaxis.h \ | |
46 | $$PWD/barcategoryaxis/qbarcategoryaxis.h \ |
|
54 | $$PWD/barcategoryaxis/qbarcategoryaxis.h \ | |
47 | $$PWD/categoryaxis/qcategoryaxis.h |
|
55 | $$PWD/categoryaxis/qcategoryaxis.h \ | |
|
56 | $$PWD/logvalueaxis/qlogvalueaxis.h \ | |||
48 |
|
57 | |||
49 | !linux-arm*: { |
|
58 | !linux-arm*: { | |
50 | INCLUDEPATH += \ |
|
59 | INCLUDEPATH += \ | |
51 | $$PWD/datetimeaxis |
|
60 | $$PWD/datetimeaxis | |
52 |
|
61 | |||
53 | DEPENDPATH += \ |
|
62 | DEPENDPATH += \ | |
54 | $$PWD/datetimeaxis |
|
63 | $$PWD/datetimeaxis | |
55 |
|
64 | |||
56 | SOURCES += \ |
|
65 | SOURCES += \ | |
57 | $$PWD/datetimeaxis/chartdatetimeaxisx.cpp \ |
|
66 | $$PWD/datetimeaxis/chartdatetimeaxisx.cpp \ | |
58 | $$PWD/datetimeaxis/chartdatetimeaxisy.cpp \ |
|
67 | $$PWD/datetimeaxis/chartdatetimeaxisy.cpp \ | |
59 | $$PWD/datetimeaxis/qdatetimeaxis.cpp |
|
68 | $$PWD/datetimeaxis/qdatetimeaxis.cpp | |
60 |
|
69 | |||
61 | PRIVATE_HEADERS += \ |
|
70 | PRIVATE_HEADERS += \ | |
62 | $$PWD/datetimeaxis/chartdatetimeaxisx_p.h \ |
|
71 | $$PWD/datetimeaxis/chartdatetimeaxisx_p.h \ | |
63 | $$PWD/datetimeaxis/chartdatetimeaxisy_p.h \ |
|
72 | $$PWD/datetimeaxis/chartdatetimeaxisy_p.h \ | |
64 | $$PWD/datetimeaxis/qdatetimeaxis_p.h |
|
73 | $$PWD/datetimeaxis/qdatetimeaxis_p.h | |
65 |
|
74 | |||
66 | PUBLIC_HEADERS += \ |
|
75 | PUBLIC_HEADERS += \ | |
67 | $$PWD/datetimeaxis/qdatetimeaxis.h |
|
76 | $$PWD/datetimeaxis/qdatetimeaxis.h | |
68 | } |
|
77 | } | |
|
78 |
@@ -1,462 +1,501 | |||||
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 "domain_p.h" |
|
26 | #include "domain_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 <QGraphicsLayout> |
|
31 | #include <QGraphicsLayout> | |
31 | #include <QFontMetrics> |
|
32 | #include <QFontMetrics> | |
32 |
|
33 | |||
33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
34 |
|
35 | |||
35 | ChartAxis::ChartAxis(QAbstractAxis *axis, QGraphicsItem* item , bool intervalAxis) |
|
36 | ChartAxis::ChartAxis(QAbstractAxis *axis, QGraphicsItem* item , bool intervalAxis) | |
36 | : ChartElement(item), |
|
37 | : ChartElement(item), | |
37 | m_axis(axis), |
|
38 | m_axis(axis), | |
38 | m_labelsAngle(0), |
|
39 | m_labelsAngle(0), | |
39 | m_grid(new QGraphicsItemGroup(item)), |
|
40 | m_grid(new QGraphicsItemGroup(item)), | |
40 | m_arrow(new QGraphicsItemGroup(item)), |
|
41 | m_arrow(new QGraphicsItemGroup(item)), | |
41 | m_shades(new QGraphicsItemGroup(item)), |
|
42 | m_shades(new QGraphicsItemGroup(item)), | |
42 | m_labels(new QGraphicsItemGroup(item)), |
|
43 | m_labels(new QGraphicsItemGroup(item)), | |
43 | m_title(new QGraphicsSimpleTextItem(item)), |
|
44 | m_title(new QGraphicsSimpleTextItem(item)), | |
44 | m_animation(0), |
|
45 | m_animation(0), | |
45 | m_labelPadding(5), |
|
46 | m_labelPadding(5), | |
46 | m_intervalAxis(intervalAxis) |
|
47 | m_intervalAxis(intervalAxis) | |
47 | { |
|
48 | { | |
48 | Q_ASSERT(item); |
|
49 | Q_ASSERT(item); | |
49 | //initial initialization |
|
50 | //initial initialization | |
50 | m_arrow->setHandlesChildEvents(false); |
|
51 | m_arrow->setHandlesChildEvents(false); | |
51 | m_arrow->setZValue(ChartPresenter::AxisZValue); |
|
52 | m_arrow->setZValue(ChartPresenter::AxisZValue); | |
52 | m_arrow->setVisible(m_axis->isLineVisible()); |
|
53 | m_arrow->setVisible(m_axis->isLineVisible()); | |
53 | m_labels->setZValue(ChartPresenter::AxisZValue); |
|
54 | m_labels->setZValue(ChartPresenter::AxisZValue); | |
54 | m_labels->setVisible(m_axis->labelsVisible()); |
|
55 | m_labels->setVisible(m_axis->labelsVisible()); | |
55 | m_shades->setZValue(ChartPresenter::ShadesZValue); |
|
56 | m_shades->setZValue(ChartPresenter::ShadesZValue); | |
56 | m_shades->setVisible(m_axis->shadesVisible()); |
|
57 | m_shades->setVisible(m_axis->shadesVisible()); | |
57 | m_grid->setZValue(ChartPresenter::GridZValue); |
|
58 | m_grid->setZValue(ChartPresenter::GridZValue); | |
58 | m_grid->setVisible(m_axis->isGridLineVisible()); |
|
59 | m_grid->setVisible(m_axis->isGridLineVisible()); | |
59 | m_title->setZValue(ChartPresenter::GridZValue); |
|
60 | m_title->setZValue(ChartPresenter::GridZValue); | |
60 | connectSlots(); |
|
61 | connectSlots(); | |
61 |
|
62 | |||
62 | setFlag(QGraphicsItem::ItemHasNoContents,true); |
|
63 | setFlag(QGraphicsItem::ItemHasNoContents,true); | |
63 | } |
|
64 | } | |
64 |
|
65 | |||
65 | void ChartAxis::connectSlots() |
|
66 | void ChartAxis::connectSlots() | |
66 | { |
|
67 | { | |
67 | QObject::connect(m_axis,SIGNAL(visibleChanged(bool)),this,SLOT(handleVisibleChanged(bool))); |
|
68 | QObject::connect(m_axis,SIGNAL(visibleChanged(bool)),this,SLOT(handleVisibleChanged(bool))); | |
68 | QObject::connect(m_axis,SIGNAL(lineVisibleChanged(bool)),this,SLOT(handleArrowVisibleChanged(bool))); |
|
69 | QObject::connect(m_axis,SIGNAL(lineVisibleChanged(bool)),this,SLOT(handleArrowVisibleChanged(bool))); | |
69 | QObject::connect(m_axis,SIGNAL(gridLineVisibleChanged(bool)),this,SLOT(handleGridVisibleChanged(bool))); |
|
70 | QObject::connect(m_axis,SIGNAL(gridLineVisibleChanged(bool)),this,SLOT(handleGridVisibleChanged(bool))); | |
70 | QObject::connect(m_axis,SIGNAL(labelsVisibleChanged(bool)),this,SLOT(handleLabelsVisibleChanged(bool))); |
|
71 | QObject::connect(m_axis,SIGNAL(labelsVisibleChanged(bool)),this,SLOT(handleLabelsVisibleChanged(bool))); | |
71 | QObject::connect(m_axis,SIGNAL(shadesVisibleChanged(bool)),this,SLOT(handleShadesVisibleChanged(bool))); |
|
72 | QObject::connect(m_axis,SIGNAL(shadesVisibleChanged(bool)),this,SLOT(handleShadesVisibleChanged(bool))); | |
72 | QObject::connect(m_axis,SIGNAL(labelsAngleChanged(int)),this,SLOT(handleLabelsAngleChanged(int))); |
|
73 | QObject::connect(m_axis,SIGNAL(labelsAngleChanged(int)),this,SLOT(handleLabelsAngleChanged(int))); | |
73 | QObject::connect(m_axis,SIGNAL(linePenChanged(const QPen&)),this,SLOT(handleArrowPenChanged(const QPen&))); |
|
74 | QObject::connect(m_axis,SIGNAL(linePenChanged(const QPen&)),this,SLOT(handleArrowPenChanged(const QPen&))); | |
74 | QObject::connect(m_axis,SIGNAL(labelsPenChanged(const QPen&)),this,SLOT(handleLabelsPenChanged(const QPen&))); |
|
75 | QObject::connect(m_axis,SIGNAL(labelsPenChanged(const QPen&)),this,SLOT(handleLabelsPenChanged(const QPen&))); | |
75 | QObject::connect(m_axis,SIGNAL(labelsBrushChanged(const QBrush&)),this,SLOT(handleLabelsBrushChanged(const QBrush&))); |
|
76 | QObject::connect(m_axis,SIGNAL(labelsBrushChanged(const QBrush&)),this,SLOT(handleLabelsBrushChanged(const QBrush&))); | |
76 | QObject::connect(m_axis,SIGNAL(labelsFontChanged(const QFont&)),this,SLOT(handleLabelsFontChanged(const QFont&))); |
|
77 | QObject::connect(m_axis,SIGNAL(labelsFontChanged(const QFont&)),this,SLOT(handleLabelsFontChanged(const QFont&))); | |
77 | QObject::connect(m_axis,SIGNAL(gridLinePenChanged(const QPen&)),this,SLOT(handleGridPenChanged(const QPen&))); |
|
78 | QObject::connect(m_axis,SIGNAL(gridLinePenChanged(const QPen&)),this,SLOT(handleGridPenChanged(const QPen&))); | |
78 | QObject::connect(m_axis,SIGNAL(shadesPenChanged(const QPen&)),this,SLOT(handleShadesPenChanged(const QPen&))); |
|
79 | QObject::connect(m_axis,SIGNAL(shadesPenChanged(const QPen&)),this,SLOT(handleShadesPenChanged(const QPen&))); | |
79 | QObject::connect(m_axis,SIGNAL(shadesBrushChanged(const QBrush&)),this,SLOT(handleShadesBrushChanged(const QBrush&))); |
|
80 | QObject::connect(m_axis,SIGNAL(shadesBrushChanged(const QBrush&)),this,SLOT(handleShadesBrushChanged(const QBrush&))); | |
80 | QObject::connect(m_axis,SIGNAL(titleTextChanged(const QString&)),this,SLOT(handleTitleTextChanged(const QString&))); |
|
81 | QObject::connect(m_axis,SIGNAL(titleTextChanged(const QString&)),this,SLOT(handleTitleTextChanged(const QString&))); | |
81 | QObject::connect(m_axis,SIGNAL(titleFontChanged(const QFont&)),this,SLOT(handleTitleFontChanged(const QFont&))); |
|
82 | QObject::connect(m_axis,SIGNAL(titleFontChanged(const QFont&)),this,SLOT(handleTitleFontChanged(const QFont&))); | |
82 | QObject::connect(m_axis,SIGNAL(titlePenChanged(const QPen&)),this,SLOT(handleTitlePenChanged(const QPen&))); |
|
83 | QObject::connect(m_axis,SIGNAL(titlePenChanged(const QPen&)),this,SLOT(handleTitlePenChanged(const QPen&))); | |
83 | QObject::connect(m_axis,SIGNAL(titleBrushChanged(const QBrush&)),this,SLOT(handleTitleBrushChanged(const QBrush&))); |
|
84 | QObject::connect(m_axis,SIGNAL(titleBrushChanged(const QBrush&)),this,SLOT(handleTitleBrushChanged(const QBrush&))); | |
84 | QObject::connect(m_axis->d_ptr.data(),SIGNAL(rangeChanged(qreal,qreal)),this,SLOT(handleRangeChanged(qreal,qreal))); |
|
85 | QObject::connect(m_axis->d_ptr.data(),SIGNAL(rangeChanged(qreal,qreal)),this,SLOT(handleRangeChanged(qreal,qreal))); | |
85 | } |
|
86 | } | |
86 |
|
87 | |||
87 | ChartAxis::~ChartAxis() |
|
88 | ChartAxis::~ChartAxis() | |
88 | { |
|
89 | { | |
89 | } |
|
90 | } | |
90 |
|
91 | |||
91 | void ChartAxis::setAnimation(AxisAnimation *animation) |
|
92 | void ChartAxis::setAnimation(AxisAnimation *animation) | |
92 | { |
|
93 | { | |
93 | m_animation = animation; |
|
94 | m_animation = animation; | |
94 | } |
|
95 | } | |
95 |
|
96 | |||
96 | void ChartAxis::setLayout(QVector<qreal> &layout) |
|
97 | void ChartAxis::setLayout(QVector<qreal> &layout) | |
97 | { |
|
98 | { | |
98 | m_layoutVector = layout; |
|
99 | m_layoutVector = layout; | |
99 | } |
|
100 | } | |
100 |
|
101 | |||
101 | void ChartAxis::createItems(int count) |
|
102 | void ChartAxis::createItems(int count) | |
102 | { |
|
103 | { | |
103 | if (m_arrow->children().size() == 0){ |
|
104 | if (m_arrow->children().size() == 0){ | |
104 | QGraphicsLineItem* arrow = new ArrowItem(this, this); |
|
105 | QGraphicsLineItem* arrow = new ArrowItem(this, this); | |
105 | arrow->setPen(m_axis->linePen()); |
|
106 | arrow->setPen(m_axis->linePen()); | |
106 | m_arrow->addToGroup(arrow); |
|
107 | m_arrow->addToGroup(arrow); | |
107 | } |
|
108 | } | |
108 |
|
109 | |||
109 | if (m_intervalAxis && m_grid->children().size() == 0) { |
|
110 | if (m_intervalAxis && m_grid->children().size() == 0) { | |
110 | for (int i = 0 ; i < 2 ; i ++){ |
|
111 | for (int i = 0 ; i < 2 ; i ++){ | |
111 | QGraphicsLineItem* item = new QGraphicsLineItem(this); |
|
112 | QGraphicsLineItem* item = new QGraphicsLineItem(this); | |
112 | item->setPen(m_axis->gridLinePen()); |
|
113 | item->setPen(m_axis->gridLinePen()); | |
113 | m_grid->addToGroup(item); |
|
114 | m_grid->addToGroup(item); | |
114 | } |
|
115 | } | |
115 | } |
|
116 | } | |
116 |
|
117 | |||
117 | for (int i = 0; i < count; ++i) { |
|
118 | for (int i = 0; i < count; ++i) { | |
118 | QGraphicsLineItem* arrow = new QGraphicsLineItem(this); |
|
119 | QGraphicsLineItem* arrow = new QGraphicsLineItem(this); | |
119 | arrow->setPen(m_axis->linePen()); |
|
120 | arrow->setPen(m_axis->linePen()); | |
120 | QGraphicsLineItem* grid = new QGraphicsLineItem(this); |
|
121 | QGraphicsLineItem* grid = new QGraphicsLineItem(this); | |
121 | grid->setPen(m_axis->gridLinePen()); |
|
122 | grid->setPen(m_axis->gridLinePen()); | |
122 | QGraphicsSimpleTextItem* label = new QGraphicsSimpleTextItem(this); |
|
123 | QGraphicsSimpleTextItem* label = new QGraphicsSimpleTextItem(this); | |
123 | label->setFont(m_axis->labelsFont()); |
|
124 | label->setFont(m_axis->labelsFont()); | |
124 | label->setPen(m_axis->labelsPen()); |
|
125 | label->setPen(m_axis->labelsPen()); | |
125 | label->setBrush(m_axis->labelsBrush()); |
|
126 | label->setBrush(m_axis->labelsBrush()); | |
126 | m_arrow->addToGroup(arrow); |
|
127 | m_arrow->addToGroup(arrow); | |
127 | m_grid->addToGroup(grid); |
|
128 | m_grid->addToGroup(grid); | |
128 | m_labels->addToGroup(label); |
|
129 | m_labels->addToGroup(label); | |
129 |
|
130 | |||
130 | if ((m_grid->childItems().size()) % 2 && m_grid->childItems().size() > 2){ |
|
131 | if ((m_grid->childItems().size()) % 2 && m_grid->childItems().size() > 2){ | |
131 | QGraphicsRectItem* shades = new QGraphicsRectItem(this); |
|
132 | QGraphicsRectItem* shades = new QGraphicsRectItem(this); | |
132 | shades->setPen(m_axis->shadesPen()); |
|
133 | shades->setPen(m_axis->shadesPen()); | |
133 | shades->setBrush(m_axis->shadesBrush()); |
|
134 | shades->setBrush(m_axis->shadesBrush()); | |
134 | m_shades->addToGroup(shades); |
|
135 | m_shades->addToGroup(shades); | |
135 | } |
|
136 | } | |
136 | } |
|
137 | } | |
137 |
|
138 | |||
138 | } |
|
139 | } | |
139 |
|
140 | |||
140 | void ChartAxis::deleteItems(int count) |
|
141 | void ChartAxis::deleteItems(int count) | |
141 | { |
|
142 | { | |
142 | QList<QGraphicsItem *> lines = m_grid->childItems(); |
|
143 | QList<QGraphicsItem *> lines = m_grid->childItems(); | |
143 | QList<QGraphicsItem *> labels = m_labels->childItems(); |
|
144 | QList<QGraphicsItem *> labels = m_labels->childItems(); | |
144 | QList<QGraphicsItem *> shades = m_shades->childItems(); |
|
145 | QList<QGraphicsItem *> shades = m_shades->childItems(); | |
145 | QList<QGraphicsItem *> axis = m_arrow->childItems(); |
|
146 | QList<QGraphicsItem *> axis = m_arrow->childItems(); | |
146 |
|
147 | |||
147 | for (int i = 0; i < count; ++i) { |
|
148 | for (int i = 0; i < count; ++i) { | |
148 | if (lines.size() % 2 && lines.size() > 1) |
|
149 | if (lines.size() % 2 && lines.size() > 1) | |
149 | delete(shades.takeLast()); |
|
150 | delete(shades.takeLast()); | |
150 | delete(lines.takeLast()); |
|
151 | delete(lines.takeLast()); | |
151 | delete(labels.takeLast()); |
|
152 | delete(labels.takeLast()); | |
152 | delete(axis.takeLast()); |
|
153 | delete(axis.takeLast()); | |
153 | } |
|
154 | } | |
154 | } |
|
155 | } | |
155 |
|
156 | |||
156 | void ChartAxis::updateLayout(QVector<qreal> &layout) |
|
157 | void ChartAxis::updateLayout(QVector<qreal> &layout) | |
157 | { |
|
158 | { | |
158 | int diff = m_layoutVector.size() - layout.size(); |
|
159 | int diff = m_layoutVector.size() - layout.size(); | |
159 |
|
160 | |||
160 | if (diff > 0) |
|
161 | if (diff > 0) | |
161 | deleteItems(diff); |
|
162 | deleteItems(diff); | |
162 | else if (diff < 0) |
|
163 | else if (diff < 0) | |
163 | createItems(-diff); |
|
164 | createItems(-diff); | |
164 |
|
165 | |||
165 | if (m_animation) { |
|
166 | if (m_animation) { | |
166 | switch (presenter()->state()) { |
|
167 | switch (presenter()->state()) { | |
167 | case ChartPresenter::ZoomInState: |
|
168 | case ChartPresenter::ZoomInState: | |
168 | m_animation->setAnimationType(AxisAnimation::ZoomInAnimation); |
|
169 | m_animation->setAnimationType(AxisAnimation::ZoomInAnimation); | |
169 | m_animation->setAnimationPoint(presenter()->statePoint()); |
|
170 | m_animation->setAnimationPoint(presenter()->statePoint()); | |
170 | break; |
|
171 | break; | |
171 | case ChartPresenter::ZoomOutState: |
|
172 | case ChartPresenter::ZoomOutState: | |
172 | m_animation->setAnimationType(AxisAnimation::ZoomOutAnimation); |
|
173 | m_animation->setAnimationType(AxisAnimation::ZoomOutAnimation); | |
173 | m_animation->setAnimationPoint(presenter()->statePoint()); |
|
174 | m_animation->setAnimationPoint(presenter()->statePoint()); | |
174 | break; |
|
175 | break; | |
175 | case ChartPresenter::ScrollUpState: |
|
176 | case ChartPresenter::ScrollUpState: | |
176 | case ChartPresenter::ScrollLeftState: |
|
177 | case ChartPresenter::ScrollLeftState: | |
177 | m_animation->setAnimationType(AxisAnimation::MoveBackwordAnimation); |
|
178 | m_animation->setAnimationType(AxisAnimation::MoveBackwordAnimation); | |
178 | break; |
|
179 | break; | |
179 | case ChartPresenter::ScrollDownState: |
|
180 | case ChartPresenter::ScrollDownState: | |
180 | case ChartPresenter::ScrollRightState: |
|
181 | case ChartPresenter::ScrollRightState: | |
181 | m_animation->setAnimationType(AxisAnimation::MoveForwardAnimation); |
|
182 | m_animation->setAnimationType(AxisAnimation::MoveForwardAnimation); | |
182 | break; |
|
183 | break; | |
183 | case ChartPresenter::ShowState: |
|
184 | case ChartPresenter::ShowState: | |
184 | m_animation->setAnimationType(AxisAnimation::DefaultAnimation); |
|
185 | m_animation->setAnimationType(AxisAnimation::DefaultAnimation); | |
185 | break; |
|
186 | break; | |
186 | } |
|
187 | } | |
187 | m_animation->setValues(m_layoutVector, layout); |
|
188 | m_animation->setValues(m_layoutVector, layout); | |
188 | presenter()->startAnimation(m_animation); |
|
189 | presenter()->startAnimation(m_animation); | |
189 | } else { |
|
190 | } else { | |
190 | setLayout(layout); |
|
191 | setLayout(layout); | |
191 | updateGeometry(); |
|
192 | updateGeometry(); | |
192 | } |
|
193 | } | |
193 | } |
|
194 | } | |
194 |
|
195 | |||
195 | void ChartAxis::setLabelPadding(int padding) |
|
196 | void ChartAxis::setLabelPadding(int padding) | |
196 | { |
|
197 | { | |
197 | m_labelPadding = padding; |
|
198 | m_labelPadding = padding; | |
198 | } |
|
199 | } | |
199 |
|
200 | |||
200 | bool ChartAxis::isEmpty() |
|
201 | bool ChartAxis::isEmpty() | |
201 | { |
|
202 | { | |
202 | return m_axisRect.isEmpty() || m_gridRect.isEmpty() || qFuzzyCompare(min(),max()); |
|
203 | return m_axisRect.isEmpty() || m_gridRect.isEmpty() || qFuzzyCompare(min(),max()); | |
203 | } |
|
204 | } | |
204 |
|
205 | |||
205 | void ChartAxis::setGeometry(const QRectF &axis, const QRectF &grid) |
|
206 | void ChartAxis::setGeometry(const QRectF &axis, const QRectF &grid) | |
206 | { |
|
207 | { | |
207 | m_gridRect = grid; |
|
208 | m_gridRect = grid; | |
208 | m_axisRect = axis; |
|
209 | m_axisRect = axis; | |
209 |
|
210 | |||
210 | if (isEmpty()) |
|
211 | if (isEmpty()) | |
211 | return; |
|
212 | return; | |
212 |
|
213 | |||
213 | QVector<qreal> layout = calculateLayout(); |
|
214 | QVector<qreal> layout = calculateLayout(); | |
214 | updateLayout(layout); |
|
215 | updateLayout(layout); | |
215 | } |
|
216 | } | |
216 |
|
217 | |||
217 | qreal ChartAxis::min() const |
|
218 | qreal ChartAxis::min() const | |
218 | { |
|
219 | { | |
219 | return m_axis->d_ptr->min(); |
|
220 | return m_axis->d_ptr->min(); | |
220 | } |
|
221 | } | |
221 |
|
222 | |||
222 | qreal ChartAxis::max() const |
|
223 | qreal ChartAxis::max() const | |
223 | { |
|
224 | { | |
224 | return m_axis->d_ptr->max(); |
|
225 | return m_axis->d_ptr->max(); | |
225 | } |
|
226 | } | |
226 |
|
227 | |||
227 | QFont ChartAxis::font() const |
|
228 | QFont ChartAxis::font() const | |
228 | { |
|
229 | { | |
229 | return m_axis->labelsFont(); |
|
230 | return m_axis->labelsFont(); | |
230 | } |
|
231 | } | |
231 |
|
232 | |||
232 | QFont ChartAxis::titleFont() const |
|
233 | QFont ChartAxis::titleFont() const | |
233 | { |
|
234 | { | |
234 | return m_axis->titleFont(); |
|
235 | return m_axis->titleFont(); | |
235 | } |
|
236 | } | |
236 |
|
237 | |||
237 | QString ChartAxis::titleText() const |
|
238 | QString ChartAxis::titleText() const | |
238 | { |
|
239 | { | |
239 | return m_axis->titleText(); |
|
240 | return m_axis->titleText(); | |
240 | } |
|
241 | } | |
241 |
|
242 | |||
242 | void ChartAxis::axisSelected() |
|
243 | void ChartAxis::axisSelected() | |
243 | { |
|
244 | { | |
244 | emit clicked(); |
|
245 | emit clicked(); | |
245 | } |
|
246 | } | |
246 |
|
247 | |||
247 | Qt::Orientation ChartAxis::orientation() const |
|
248 | Qt::Orientation ChartAxis::orientation() const | |
248 | { |
|
249 | { | |
249 | return m_axis->orientation(); |
|
250 | return m_axis->orientation(); | |
250 | } |
|
251 | } | |
251 |
|
252 | |||
252 | Qt::Alignment ChartAxis::alignment() const |
|
253 | Qt::Alignment ChartAxis::alignment() const | |
253 | { |
|
254 | { | |
254 | return m_axis->alignment(); |
|
255 | return m_axis->alignment(); | |
255 | } |
|
256 | } | |
256 |
|
257 | |||
257 | void ChartAxis::setLabels(const QStringList &labels) |
|
258 | void ChartAxis::setLabels(const QStringList &labels) | |
258 | { |
|
259 | { | |
259 | m_labelsList = labels; |
|
260 | m_labelsList = labels; | |
260 | } |
|
261 | } | |
261 |
|
262 | |||
262 | QSizeF ChartAxis::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
263 | QSizeF ChartAxis::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const | |
263 | { |
|
264 | { | |
264 | Q_UNUSED(which); |
|
265 | Q_UNUSED(which); | |
265 | Q_UNUSED(constraint); |
|
266 | Q_UNUSED(constraint); | |
266 | return QSizeF(); |
|
267 | return QSizeF(); | |
267 | } |
|
268 | } | |
268 |
|
269 | |||
269 | //handlers |
|
270 | //handlers | |
270 |
|
271 | |||
271 | void ChartAxis::handleArrowVisibleChanged(bool visible) |
|
272 | void ChartAxis::handleArrowVisibleChanged(bool visible) | |
272 | { |
|
273 | { | |
273 | m_arrow->setVisible(visible); |
|
274 | m_arrow->setVisible(visible); | |
274 | } |
|
275 | } | |
275 |
|
276 | |||
276 | void ChartAxis::handleGridVisibleChanged(bool visible) |
|
277 | void ChartAxis::handleGridVisibleChanged(bool visible) | |
277 | { |
|
278 | { | |
278 | m_grid->setVisible(visible); |
|
279 | m_grid->setVisible(visible); | |
279 | } |
|
280 | } | |
280 |
|
281 | |||
281 | void ChartAxis::handleLabelsVisibleChanged(bool visible) |
|
282 | void ChartAxis::handleLabelsVisibleChanged(bool visible) | |
282 | { |
|
283 | { | |
283 | m_labels->setVisible(visible); |
|
284 | m_labels->setVisible(visible); | |
284 | } |
|
285 | } | |
285 |
|
286 | |||
286 | void ChartAxis::handleShadesVisibleChanged(bool visible) |
|
287 | void ChartAxis::handleShadesVisibleChanged(bool visible) | |
287 | { |
|
288 | { | |
288 | m_shades->setVisible(visible); |
|
289 | m_shades->setVisible(visible); | |
289 | } |
|
290 | } | |
290 |
|
291 | |||
291 | void ChartAxis::handleLabelsAngleChanged(int angle) |
|
292 | void ChartAxis::handleLabelsAngleChanged(int angle) | |
292 | { |
|
293 | { | |
293 | foreach (QGraphicsItem *item, m_labels->childItems()) |
|
294 | foreach (QGraphicsItem *item, m_labels->childItems()) | |
294 | item->setRotation(angle); |
|
295 | item->setRotation(angle); | |
295 |
|
296 | |||
296 | m_labelsAngle = angle; |
|
297 | m_labelsAngle = angle; | |
297 | } |
|
298 | } | |
298 |
|
299 | |||
299 | void ChartAxis::handleLabelsPenChanged(const QPen &pen) |
|
300 | void ChartAxis::handleLabelsPenChanged(const QPen &pen) | |
300 | { |
|
301 | { | |
301 | foreach (QGraphicsItem *item , m_labels->childItems()) |
|
302 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
302 | static_cast<QGraphicsSimpleTextItem *>(item)->setPen(pen); |
|
303 | static_cast<QGraphicsSimpleTextItem *>(item)->setPen(pen); | |
303 | } |
|
304 | } | |
304 |
|
305 | |||
305 | void ChartAxis::handleLabelsBrushChanged(const QBrush &brush) |
|
306 | void ChartAxis::handleLabelsBrushChanged(const QBrush &brush) | |
306 | { |
|
307 | { | |
307 | foreach (QGraphicsItem *item , m_labels->childItems()) |
|
308 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
308 | static_cast<QGraphicsSimpleTextItem *>(item)->setBrush(brush); |
|
309 | static_cast<QGraphicsSimpleTextItem *>(item)->setBrush(brush); | |
309 | } |
|
310 | } | |
310 |
|
311 | |||
311 | void ChartAxis::handleLabelsFontChanged(const QFont &font) |
|
312 | void ChartAxis::handleLabelsFontChanged(const QFont &font) | |
312 | { |
|
313 | { | |
313 | foreach (QGraphicsItem *item , m_labels->childItems()) |
|
314 | foreach (QGraphicsItem *item , m_labels->childItems()) | |
314 | static_cast<QGraphicsSimpleTextItem *>(item)->setFont(font); |
|
315 | static_cast<QGraphicsSimpleTextItem *>(item)->setFont(font); | |
315 | QGraphicsLayoutItem::updateGeometry(); |
|
316 | QGraphicsLayoutItem::updateGeometry(); | |
316 | presenter()->layout()->invalidate(); |
|
317 | presenter()->layout()->invalidate(); | |
317 | } |
|
318 | } | |
318 |
|
319 | |||
319 | void ChartAxis::handleShadesBrushChanged(const QBrush &brush) |
|
320 | void ChartAxis::handleShadesBrushChanged(const QBrush &brush) | |
320 | { |
|
321 | { | |
321 | foreach (QGraphicsItem *item , m_shades->childItems()) |
|
322 | foreach (QGraphicsItem *item , m_shades->childItems()) | |
322 | static_cast<QGraphicsRectItem *>(item)->setBrush(brush); |
|
323 | static_cast<QGraphicsRectItem *>(item)->setBrush(brush); | |
323 | } |
|
324 | } | |
324 |
|
325 | |||
325 | void ChartAxis::handleShadesPenChanged(const QPen &pen) |
|
326 | void ChartAxis::handleShadesPenChanged(const QPen &pen) | |
326 | { |
|
327 | { | |
327 | foreach (QGraphicsItem *item , m_shades->childItems()) |
|
328 | foreach (QGraphicsItem *item , m_shades->childItems()) | |
328 | static_cast<QGraphicsRectItem *>(item)->setPen(pen); |
|
329 | static_cast<QGraphicsRectItem *>(item)->setPen(pen); | |
329 | } |
|
330 | } | |
330 |
|
331 | |||
331 | void ChartAxis::handleArrowPenChanged(const QPen &pen) |
|
332 | void ChartAxis::handleArrowPenChanged(const QPen &pen) | |
332 | { |
|
333 | { | |
333 | foreach (QGraphicsItem *item , m_arrow->childItems()) |
|
334 | foreach (QGraphicsItem *item , m_arrow->childItems()) | |
334 | static_cast<QGraphicsLineItem *>(item)->setPen(pen); |
|
335 | static_cast<QGraphicsLineItem *>(item)->setPen(pen); | |
335 | } |
|
336 | } | |
336 |
|
337 | |||
337 | void ChartAxis::handleGridPenChanged(const QPen &pen) |
|
338 | void ChartAxis::handleGridPenChanged(const QPen &pen) | |
338 | { |
|
339 | { | |
339 | foreach (QGraphicsItem *item , m_grid->childItems()) |
|
340 | foreach (QGraphicsItem *item , m_grid->childItems()) | |
340 | static_cast<QGraphicsLineItem *>(item)->setPen(pen); |
|
341 | static_cast<QGraphicsLineItem *>(item)->setPen(pen); | |
341 | } |
|
342 | } | |
342 |
|
343 | |||
343 | void ChartAxis::handleTitleTextChanged(const QString &title) |
|
344 | void ChartAxis::handleTitleTextChanged(const QString &title) | |
344 | { |
|
345 | { | |
345 | Q_UNUSED(title) |
|
346 | Q_UNUSED(title) | |
346 | QGraphicsLayoutItem::updateGeometry(); |
|
347 | QGraphicsLayoutItem::updateGeometry(); | |
347 | presenter()->layout()->invalidate(); |
|
348 | presenter()->layout()->invalidate(); | |
348 | } |
|
349 | } | |
349 |
|
350 | |||
350 |
|
351 | |||
351 | void ChartAxis::handleTitlePenChanged(const QPen &pen) |
|
352 | void ChartAxis::handleTitlePenChanged(const QPen &pen) | |
352 | { |
|
353 | { | |
353 | m_title->setPen(pen); |
|
354 | m_title->setPen(pen); | |
354 | } |
|
355 | } | |
355 |
|
356 | |||
356 | void ChartAxis::handleTitleBrushChanged(const QBrush &brush) |
|
357 | void ChartAxis::handleTitleBrushChanged(const QBrush &brush) | |
357 | { |
|
358 | { | |
358 | m_title->setBrush(brush); |
|
359 | m_title->setBrush(brush); | |
359 | } |
|
360 | } | |
360 |
|
361 | |||
361 | void ChartAxis::handleTitleFontChanged(const QFont &font) |
|
362 | void ChartAxis::handleTitleFontChanged(const QFont &font) | |
362 | { |
|
363 | { | |
363 | if(m_title->font() != font){ |
|
364 | if(m_title->font() != font){ | |
364 | m_title->setFont(font); |
|
365 | m_title->setFont(font); | |
365 | QGraphicsLayoutItem::updateGeometry(); |
|
366 | QGraphicsLayoutItem::updateGeometry(); | |
366 | presenter()->layout()->invalidate(); |
|
367 | presenter()->layout()->invalidate(); | |
367 | } |
|
368 | } | |
368 | } |
|
369 | } | |
369 |
|
370 | |||
370 | void ChartAxis::handleVisibleChanged(bool visible) |
|
371 | void ChartAxis::handleVisibleChanged(bool visible) | |
371 | { |
|
372 | { | |
372 | setVisible(visible); |
|
373 | setVisible(visible); | |
373 | } |
|
374 | } | |
374 |
|
375 | |||
375 | void ChartAxis::handleRangeChanged(qreal min, qreal max) |
|
376 | void ChartAxis::handleRangeChanged(qreal min, qreal max) | |
376 | { |
|
377 | { | |
377 | Q_UNUSED(min); |
|
378 | Q_UNUSED(min); | |
378 | Q_UNUSED(max); |
|
379 | Q_UNUSED(max); | |
379 |
|
380 | |||
380 | if (!isEmpty()) { |
|
381 | if (!isEmpty()) { | |
381 |
|
382 | |||
382 | QVector<qreal> layout = calculateLayout(); |
|
383 | QVector<qreal> layout = calculateLayout(); | |
383 | updateLayout(layout); |
|
384 | updateLayout(layout); | |
384 | QSizeF before = effectiveSizeHint(Qt::PreferredSize); |
|
385 | QSizeF before = effectiveSizeHint(Qt::PreferredSize); | |
385 | QSizeF after = sizeHint(Qt::PreferredSize); |
|
386 | QSizeF after = sizeHint(Qt::PreferredSize); | |
386 |
|
387 | |||
387 | if (before != after) { |
|
388 | if (before != after) { | |
388 | QGraphicsLayoutItem::updateGeometry(); |
|
389 | QGraphicsLayoutItem::updateGeometry(); | |
389 | //we don't want to call invalidate on layout, since it will change minimum size of component, |
|
390 | //we don't want to call invalidate on layout, since it will change minimum size of component, | |
390 | //which we would like to avoid since it causes nasty flips when scrolling or zooming, |
|
391 | //which we would like to avoid since it causes nasty flips when scrolling or zooming, | |
391 | //instead recalculate layout and use plotArea for extra space. |
|
392 | //instead recalculate layout and use plotArea for extra space. | |
392 | presenter()->layout()->setGeometry(presenter()->layout()->geometry()); |
|
393 | presenter()->layout()->setGeometry(presenter()->layout()->geometry()); | |
393 | } |
|
394 | } | |
394 | } |
|
395 | } | |
395 |
|
396 | |||
396 | } |
|
397 | } | |
397 |
|
398 | |||
398 | //helpers |
|
399 | //helpers | |
399 |
|
400 | |||
400 | QStringList ChartAxis::createValueLabels(qreal min, qreal max, int ticks,const QString& format) |
|
401 | QStringList ChartAxis::createValueLabels(qreal min, qreal max, int ticks,const QString& format) | |
401 | { |
|
402 | { | |
402 | //TODO: Q_ASSERT(m_max > m_min); |
|
403 | //TODO: Q_ASSERT(m_max > m_min); | |
403 | //TODO: Q_ASSERT(ticks > 1); |
|
404 | //TODO: Q_ASSERT(ticks > 1); | |
404 |
|
405 | |||
405 | QStringList labels; |
|
406 | QStringList labels; | |
406 |
|
407 | |||
407 | if(max <= min || ticks < 1){ |
|
408 | if(max <= min || ticks < 1){ | |
408 | return labels; |
|
409 | return labels; | |
409 | } |
|
410 | } | |
410 |
|
411 | |||
411 | int n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0); |
|
412 | int n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0); | |
412 | n++; |
|
413 | n++; | |
413 |
|
414 | |||
414 | if (format.isNull()) { |
|
415 | if (format.isNull()) { | |
415 | for (int i = 0; i < ticks; i++) { |
|
416 | for (int i = 0; i < ticks; i++) { | |
416 | qreal value = min + (i * (max - min) / (ticks - 1)); |
|
417 | qreal value = min + (i * (max - min) / (ticks - 1)); | |
417 | labels << QString::number(value, 'f', n); |
|
418 | labels << QString::number(value, 'f', n); | |
418 | } |
|
419 | } | |
419 | } else { |
|
420 | } else { | |
420 | QByteArray array = format.toLatin1(); |
|
421 | QByteArray array = format.toLatin1(); | |
421 | for (int i = 0; i < ticks; i++) { |
|
422 | for (int i = 0; i < ticks; i++) { | |
422 | qreal value = min + (i * (max - min) / (ticks - 1)); |
|
423 | qreal value = min + (i * (max - min) / (ticks - 1)); | |
423 | if (format.contains("d") |
|
424 | if (format.contains("d") | |
424 | || format.contains("i") |
|
425 | || format.contains("i") | |
425 | || format.contains("c")) |
|
426 | || format.contains("c")) | |
426 | labels << QString().sprintf(array, (qint64)value); |
|
427 | labels << QString().sprintf(array, (qint64)value); | |
427 | else if (format.contains("u") |
|
428 | else if (format.contains("u") | |
428 | || format.contains("o") |
|
429 | || format.contains("o") | |
429 | || format.contains("x", Qt::CaseInsensitive)) |
|
430 | || format.contains("x", Qt::CaseInsensitive)) | |
430 | labels << QString().sprintf(array, (quint64)value); |
|
431 | labels << QString().sprintf(array, (quint64)value); | |
431 | else if (format.contains("f", Qt::CaseInsensitive) |
|
432 | else if (format.contains("f", Qt::CaseInsensitive) | |
432 | || format.contains("e", Qt::CaseInsensitive) |
|
433 | || format.contains("e", Qt::CaseInsensitive) | |
433 | || format.contains("g", Qt::CaseInsensitive)) |
|
434 | || format.contains("g", Qt::CaseInsensitive)) | |
434 | labels << QString().sprintf(array, value); |
|
435 | labels << QString().sprintf(array, value); | |
435 | } |
|
436 | } | |
436 | } |
|
437 | } | |
437 |
|
438 | |||
438 | return labels; |
|
439 | return labels; | |
439 | } |
|
440 | } | |
440 |
|
441 | |||
|
442 | QStringList ChartAxis::createLogValueLabels(qreal min, qreal max, qreal base, int ticks, const QString& format) | |||
|
443 | { | |||
|
444 | // Q_ASSERT(m_max > m_min); | |||
|
445 | // Q_ASSERT(ticks > 1); | |||
|
446 | ||||
|
447 | QStringList labels; | |||
|
448 | ||||
|
449 | int n = 0; | |||
|
450 | if (ticks > 1) | |||
|
451 | n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0); | |||
|
452 | n++; | |||
|
453 | ||||
|
454 | // QLogValueAxis *axis = qobject_cast<QLogValueAxis *>(m_chartAxis); | |||
|
455 | ||||
|
456 | // QString format = axis->labelFormat(); | |||
|
457 | ||||
|
458 | int firstTick; | |||
|
459 | if (base > 1) | |||
|
460 | firstTick = (int)(log10(min) / log10(base)); | |||
|
461 | else | |||
|
462 | firstTick = (int)(log10(max) / log10(base)); | |||
|
463 | ||||
|
464 | if (format.isNull()) { | |||
|
465 | for (int i = firstTick; i < ticks + firstTick; i++) { | |||
|
466 | qreal value = qPow(base, i); | |||
|
467 | labels << QString::number(value, 'f', n); | |||
|
468 | } | |||
|
469 | } else { | |||
|
470 | QByteArray array = format.toAscii(); | |||
|
471 | for (int i = firstTick; i < ticks + firstTick; i++) { | |||
|
472 | qreal value = qPow(base, i); | |||
|
473 | labels << QString().sprintf(array, value); | |||
|
474 | } | |||
|
475 | } | |||
|
476 | ||||
|
477 | return labels; | |||
|
478 | } | |||
|
479 | ||||
441 | QStringList ChartAxis::createDateTimeLabels(qreal min, qreal max,int ticks,const QString& format) |
|
480 | QStringList ChartAxis::createDateTimeLabels(qreal min, qreal max,int ticks,const QString& format) | |
442 | { |
|
481 | { | |
443 | //TODO: Q_ASSERT(m_max > m_min); |
|
482 | //TODO: Q_ASSERT(m_max > m_min); | |
444 | //TODO: Q_ASSERT(ticks > 1); |
|
483 | //TODO: Q_ASSERT(ticks > 1); | |
445 | QStringList labels; |
|
484 | QStringList labels; | |
446 |
|
485 | |||
447 | if(max <= min || ticks < 1) { |
|
486 | if(max <= min || ticks < 1) { | |
448 | return labels; |
|
487 | return labels; | |
449 | } |
|
488 | } | |
450 |
|
489 | |||
451 | int n = qMax(int(-floor(log10((max - min) / (ticks - 1)))), 0); |
|
490 | int n = qMax(int(-floor(log10((max - min) / (ticks - 1)))), 0); | |
452 | n++; |
|
491 | n++; | |
453 | for (int i = 0; i < ticks; i++) { |
|
492 | for (int i = 0; i < ticks; i++) { | |
454 | qreal value = min + (i * (max - min) / (ticks - 1)); |
|
493 | qreal value = min + (i * (max - min) / (ticks - 1)); | |
455 | labels << QDateTime::fromMSecsSinceEpoch(value).toString(format); |
|
494 | labels << QDateTime::fromMSecsSinceEpoch(value).toString(format); | |
456 | } |
|
495 | } | |
457 | return labels; |
|
496 | return labels; | |
458 | } |
|
497 | } | |
459 |
|
498 | |||
460 | #include "moc_chartaxis_p.cpp" |
|
499 | #include "moc_chartaxis_p.cpp" | |
461 |
|
500 | |||
462 | QTCOMMERCIALCHART_END_NAMESPACE |
|
501 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,194 +1,195 | |||||
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 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef CHARTAXIS_H |
|
30 | #ifndef CHARTAXIS_H | |
31 | #define CHARTAXIS_H |
|
31 | #define CHARTAXIS_H | |
32 |
|
32 | |||
33 | #include "qchartglobal.h" |
|
33 | #include "qchartglobal.h" | |
34 | #include "chartelement_p.h" |
|
34 | #include "chartelement_p.h" | |
35 | #include "axisanimation_p.h" |
|
35 | #include "axisanimation_p.h" | |
36 | #include <QGraphicsItem> |
|
36 | #include <QGraphicsItem> | |
37 | #include <QGraphicsLayoutItem> |
|
37 | #include <QGraphicsLayoutItem> | |
38 | #include <QFont> |
|
38 | #include <QFont> | |
39 |
|
39 | |||
40 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
40 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
41 |
|
41 | |||
42 | class QAbstractAxis; |
|
42 | class QAbstractAxis; | |
43 | class ChartPresenter; |
|
43 | class ChartPresenter; | |
44 |
|
44 | |||
45 | class ChartAxis : public ChartElement, public QGraphicsLayoutItem |
|
45 | class ChartAxis : public ChartElement, public QGraphicsLayoutItem | |
46 | { |
|
46 | { | |
47 | Q_OBJECT |
|
47 | Q_OBJECT | |
48 | Q_INTERFACES(QGraphicsLayoutItem) |
|
48 | Q_INTERFACES(QGraphicsLayoutItem) | |
49 | public: |
|
49 | public: | |
50 |
|
50 | |||
51 | ChartAxis(QAbstractAxis *axis, QGraphicsItem* item = 0, bool intervalAxis = false); |
|
51 | ChartAxis(QAbstractAxis *axis, QGraphicsItem* item = 0, bool intervalAxis = false); | |
52 | ~ChartAxis(); |
|
52 | ~ChartAxis(); | |
53 |
|
53 | |||
54 | QAbstractAxis* axis() const { return m_axis; } |
|
54 | QAbstractAxis* axis() const { return m_axis; } | |
55 |
|
55 | |||
56 | void setLabelPadding(int padding); |
|
56 | void setLabelPadding(int padding); | |
57 | int labelPadding() const { return m_labelPadding;}; |
|
57 | int labelPadding() const { return m_labelPadding;}; | |
58 |
|
58 | |||
59 | QFont titleFont() const; |
|
59 | QFont titleFont() const; | |
60 | QString titleText() const; |
|
60 | QString titleText() const; | |
61 |
|
61 | |||
62 | void setLayout(QVector<qreal> &layout); |
|
62 | void setLayout(QVector<qreal> &layout); | |
63 | QVector<qreal> layout() const { return m_layoutVector; } |
|
63 | QVector<qreal> layout() const { return m_layoutVector; } | |
64 |
|
64 | |||
65 | void setAnimation(AxisAnimation *animation); |
|
65 | void setAnimation(AxisAnimation *animation); | |
66 | ChartAnimation *animation() const { return m_animation; }; |
|
66 | ChartAnimation *animation() const { return m_animation; }; | |
67 |
|
67 | |||
68 | Qt::Orientation orientation() const; |
|
68 | Qt::Orientation orientation() const; | |
69 | Qt::Alignment alignment() const; |
|
69 | Qt::Alignment alignment() const; | |
70 |
|
70 | |||
71 | void setGeometry(const QRectF &axis, const QRectF &grid); |
|
71 | void setGeometry(const QRectF &axis, const QRectF &grid); | |
72 | QRectF axisGeometry() const { return m_axisRect; } |
|
72 | QRectF axisGeometry() const { return m_axisRect; } | |
73 | QRectF gridGeometry() const { return m_gridRect; } |
|
73 | QRectF gridGeometry() const { return m_gridRect; } | |
74 |
|
74 | |||
75 | void setLabels(const QStringList &labels); |
|
75 | void setLabels(const QStringList &labels); | |
76 | QStringList labels() const { return m_labelsList; } |
|
76 | QStringList labels() const { return m_labelsList; } | |
77 |
|
77 | |||
78 | //this flag indicates that axis is used to show intervals it means labels are in between ticks |
|
78 | //this flag indicates that axis is used to show intervals it means labels are in between ticks | |
79 | bool intervalAxis() const { return m_intervalAxis; } |
|
79 | bool intervalAxis() const { return m_intervalAxis; } | |
80 |
|
80 | |||
81 | virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; |
|
81 | virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; | |
82 |
|
82 | |||
83 |
|
83 | |||
84 | QRectF boundingRect() const{ |
|
84 | QRectF boundingRect() const{ | |
85 | return QRectF(); |
|
85 | return QRectF(); | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) |
|
88 | void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) | |
89 | { |
|
89 | { | |
90 |
|
90 | |||
91 | } |
|
91 | } | |
92 |
|
92 | |||
93 | //helpers |
|
93 | //helpers | |
94 | static QStringList createValueLabels(qreal max, qreal min, int ticks, const QString &format); |
|
94 | static QStringList createValueLabels(qreal max, qreal min, int ticks, const QString &format); | |
|
95 | static QStringList createLogValueLabels(qreal min, qreal max, qreal base, int ticks, const QString& format); | |||
95 | static QStringList createDateTimeLabels(qreal max, qreal min, int ticks, const QString &format); |
|
96 | static QStringList createDateTimeLabels(qreal max, qreal min, int ticks, const QString &format); | |
96 |
|
97 | |||
97 | protected: |
|
98 | protected: | |
98 | void setGeometry(const QRectF &size) { Q_UNUSED(size);}; |
|
99 | void setGeometry(const QRectF &size) { Q_UNUSED(size);}; | |
99 | virtual void updateGeometry() = 0; |
|
100 | virtual void updateGeometry() = 0; | |
100 | virtual QVector<qreal> calculateLayout() const = 0; |
|
101 | virtual QVector<qreal> calculateLayout() const = 0; | |
101 |
|
102 | |||
102 | QList<QGraphicsItem *> lineItems() { return m_grid->childItems(); }; |
|
103 | QList<QGraphicsItem *> lineItems() { return m_grid->childItems(); }; | |
103 | QList<QGraphicsItem *> labelItems() { return m_labels->childItems();}; |
|
104 | QList<QGraphicsItem *> labelItems() { return m_labels->childItems();}; | |
104 | QList<QGraphicsItem *> shadeItems() { return m_shades->childItems();}; |
|
105 | QList<QGraphicsItem *> shadeItems() { return m_shades->childItems();}; | |
105 | QList<QGraphicsItem *> arrowItems() { return m_arrow->childItems();}; |
|
106 | QList<QGraphicsItem *> arrowItems() { return m_arrow->childItems();}; | |
106 | QGraphicsSimpleTextItem* titleItem() const { return m_title.data();} |
|
107 | QGraphicsSimpleTextItem* titleItem() const { return m_title.data();} | |
107 |
|
108 | |||
108 | QFont font() const; |
|
109 | QFont font() const; | |
109 | qreal min() const; |
|
110 | qreal min() const; | |
110 | qreal max() const; |
|
111 | qreal max() const; | |
111 |
|
112 | |||
112 | //handlers |
|
113 | //handlers | |
113 | public Q_SLOTS: |
|
114 | public Q_SLOTS: | |
114 | void handleVisibleChanged(bool visible); |
|
115 | void handleVisibleChanged(bool visible); | |
115 | void handleArrowVisibleChanged(bool visible); |
|
116 | void handleArrowVisibleChanged(bool visible); | |
116 | void handleGridVisibleChanged(bool visible); |
|
117 | void handleGridVisibleChanged(bool visible); | |
117 | void handleLabelsVisibleChanged(bool visible); |
|
118 | void handleLabelsVisibleChanged(bool visible); | |
118 | void handleShadesVisibleChanged(bool visible); |
|
119 | void handleShadesVisibleChanged(bool visible); | |
119 | void handleLabelsAngleChanged(int angle); |
|
120 | void handleLabelsAngleChanged(int angle); | |
120 | void handleShadesBrushChanged(const QBrush &brush); |
|
121 | void handleShadesBrushChanged(const QBrush &brush); | |
121 | void handleShadesPenChanged(const QPen &pen); |
|
122 | void handleShadesPenChanged(const QPen &pen); | |
122 | void handleArrowPenChanged(const QPen &pen); |
|
123 | void handleArrowPenChanged(const QPen &pen); | |
123 | void handleGridPenChanged(const QPen &pen); |
|
124 | void handleGridPenChanged(const QPen &pen); | |
124 | void handleLabelsPenChanged(const QPen &pen); |
|
125 | void handleLabelsPenChanged(const QPen &pen); | |
125 | void handleLabelsBrushChanged(const QBrush &brush); |
|
126 | void handleLabelsBrushChanged(const QBrush &brush); | |
126 | void handleLabelsFontChanged(const QFont &font); |
|
127 | void handleLabelsFontChanged(const QFont &font); | |
127 | void handleTitlePenChanged(const QPen &pen); |
|
128 | void handleTitlePenChanged(const QPen &pen); | |
128 | void handleTitleBrushChanged(const QBrush &brush); |
|
129 | void handleTitleBrushChanged(const QBrush &brush); | |
129 | void handleTitleFontChanged(const QFont &font); |
|
130 | void handleTitleFontChanged(const QFont &font); | |
130 | void handleTitleTextChanged(const QString &title); |
|
131 | void handleTitleTextChanged(const QString &title); | |
131 | void handleRangeChanged(qreal min , qreal max); |
|
132 | void handleRangeChanged(qreal min , qreal max); | |
132 |
|
133 | |||
133 | Q_SIGNALS: |
|
134 | Q_SIGNALS: | |
134 | void clicked(); |
|
135 | void clicked(); | |
135 |
|
136 | |||
136 | private: |
|
137 | private: | |
137 | inline bool isEmpty(); |
|
138 | inline bool isEmpty(); | |
138 | void createItems(int count); |
|
139 | void createItems(int count); | |
139 | void deleteItems(int count); |
|
140 | void deleteItems(int count); | |
140 | void updateLayout(QVector<qreal> &layout); |
|
141 | void updateLayout(QVector<qreal> &layout); | |
141 | void axisSelected(); |
|
142 | void axisSelected(); | |
142 | void connectSlots(); |
|
143 | void connectSlots(); | |
143 |
|
144 | |||
144 | private: |
|
145 | private: | |
145 | QAbstractAxis *m_axis; |
|
146 | QAbstractAxis *m_axis; | |
146 | int m_labelsAngle; |
|
147 | int m_labelsAngle; | |
147 | QRectF m_axisRect; |
|
148 | QRectF m_axisRect; | |
148 | QRectF m_gridRect; |
|
149 | QRectF m_gridRect; | |
149 | QScopedPointer<QGraphicsItemGroup> m_grid; |
|
150 | QScopedPointer<QGraphicsItemGroup> m_grid; | |
150 | QScopedPointer<QGraphicsItemGroup> m_arrow; |
|
151 | QScopedPointer<QGraphicsItemGroup> m_arrow; | |
151 | QScopedPointer<QGraphicsItemGroup> m_shades; |
|
152 | QScopedPointer<QGraphicsItemGroup> m_shades; | |
152 | QScopedPointer<QGraphicsItemGroup> m_labels; |
|
153 | QScopedPointer<QGraphicsItemGroup> m_labels; | |
153 | QScopedPointer<QGraphicsSimpleTextItem> m_title; |
|
154 | QScopedPointer<QGraphicsSimpleTextItem> m_title; | |
154 | QVector<qreal> m_layoutVector; |
|
155 | QVector<qreal> m_layoutVector; | |
155 | AxisAnimation *m_animation; |
|
156 | AxisAnimation *m_animation; | |
156 | int m_labelPadding; |
|
157 | int m_labelPadding; | |
157 | QStringList m_labelsList; |
|
158 | QStringList m_labelsList; | |
158 | bool m_intervalAxis; |
|
159 | bool m_intervalAxis; | |
159 |
|
160 | |||
160 | friend class AxisAnimation; |
|
161 | friend class AxisAnimation; | |
161 | friend class ArrowItem; |
|
162 | friend class ArrowItem; | |
162 |
|
163 | |||
163 | }; |
|
164 | }; | |
164 |
|
165 | |||
165 | class ArrowItem: public QGraphicsLineItem |
|
166 | class ArrowItem: public QGraphicsLineItem | |
166 | { |
|
167 | { | |
167 |
|
168 | |||
168 | public: |
|
169 | public: | |
169 | explicit ArrowItem(ChartAxis *axis, QGraphicsItem *parent = 0) : QGraphicsLineItem(parent), m_axis(axis) {} |
|
170 | explicit ArrowItem(ChartAxis *axis, QGraphicsItem *parent = 0) : QGraphicsLineItem(parent), m_axis(axis) {} | |
170 |
|
171 | |||
171 | protected: |
|
172 | protected: | |
172 | void mousePressEvent(QGraphicsSceneMouseEvent *event) { |
|
173 | void mousePressEvent(QGraphicsSceneMouseEvent *event) { | |
173 | Q_UNUSED(event) |
|
174 | Q_UNUSED(event) | |
174 | m_axis->axisSelected(); |
|
175 | m_axis->axisSelected(); | |
175 | } |
|
176 | } | |
176 |
|
177 | |||
177 | QRectF boundingRect() const { |
|
178 | QRectF boundingRect() const { | |
178 | return shape().boundingRect(); |
|
179 | return shape().boundingRect(); | |
179 | } |
|
180 | } | |
180 |
|
181 | |||
181 | QPainterPath shape() const { |
|
182 | QPainterPath shape() const { | |
182 | QPainterPath path = QGraphicsLineItem::shape(); |
|
183 | QPainterPath path = QGraphicsLineItem::shape(); | |
183 | QRectF rect = path.boundingRect(); |
|
184 | QRectF rect = path.boundingRect(); | |
184 | path.addRect(rect.adjusted(0, 0, m_axis->orientation() != Qt::Horizontal ? 8 : 0, m_axis->orientation() != Qt::Vertical ? 8 : 0)); |
|
185 | path.addRect(rect.adjusted(0, 0, m_axis->orientation() != Qt::Horizontal ? 8 : 0, m_axis->orientation() != Qt::Vertical ? 8 : 0)); | |
185 | return path; |
|
186 | return path; | |
186 | } |
|
187 | } | |
187 |
|
188 | |||
188 | private: |
|
189 | private: | |
189 | ChartAxis *m_axis; |
|
190 | ChartAxis *m_axis; | |
190 | }; |
|
191 | }; | |
191 |
|
192 | |||
192 | QTCOMMERCIALCHART_END_NAMESPACE |
|
193 | QTCOMMERCIALCHART_END_NAMESPACE | |
193 |
|
194 | |||
194 | #endif /* CHARTAXI_H */ |
|
195 | #endif /* CHARTAXI_H */ |
@@ -1,191 +1,192 | |||||
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 | #ifndef QABSTRACTAXIS_H |
|
21 | #ifndef QABSTRACTAXIS_H | |
22 | #define QABSTRACTAXIS_H |
|
22 | #define QABSTRACTAXIS_H | |
23 |
|
23 | |||
24 | #include <qchartglobal.h> |
|
24 | #include <qchartglobal.h> | |
25 | #include <QPen> |
|
25 | #include <QPen> | |
26 | #include <QFont> |
|
26 | #include <QFont> | |
27 | #include <QVariant> |
|
27 | #include <QVariant> | |
28 |
|
28 | |||
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
30 |
|
30 | |||
31 | class QAbstractAxisPrivate; |
|
31 | class QAbstractAxisPrivate; | |
32 |
|
32 | |||
33 | class QTCOMMERCIALCHART_EXPORT QAbstractAxis : public QObject |
|
33 | class QTCOMMERCIALCHART_EXPORT QAbstractAxis : public QObject | |
34 | { |
|
34 | { | |
35 | Q_OBJECT |
|
35 | Q_OBJECT | |
36 | //visibility |
|
36 | //visibility | |
37 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
|
37 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) | |
38 | //arrow |
|
38 | //arrow | |
39 | Q_PROPERTY(bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged) |
|
39 | Q_PROPERTY(bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged) | |
40 | Q_PROPERTY(QPen linePen READ linePen WRITE setLinePen NOTIFY linePenChanged) |
|
40 | Q_PROPERTY(QPen linePen READ linePen WRITE setLinePen NOTIFY linePenChanged) | |
41 | //TODO: make wrapping of color for qml |
|
41 | //TODO: make wrapping of color for qml | |
42 | Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged) |
|
42 | Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged) | |
43 | //labels |
|
43 | //labels | |
44 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) |
|
44 | Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged) | |
45 | Q_PROPERTY(QPen lablesPen READ labelsPen WRITE setLabelsPen NOTIFY labelsPenChanged) |
|
45 | Q_PROPERTY(QPen lablesPen READ labelsPen WRITE setLabelsPen NOTIFY labelsPenChanged) | |
46 | Q_PROPERTY(QBrush lablesBrush READ labelsBrush WRITE setLabelsBrush NOTIFY labelsBrushChanged) |
|
46 | Q_PROPERTY(QBrush lablesBrush READ labelsBrush WRITE setLabelsBrush NOTIFY labelsBrushChanged) | |
47 | //TODO: fix labels angles to work with layout |
|
47 | //TODO: fix labels angles to work with layout | |
48 | Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged) |
|
48 | Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged) | |
49 | Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont NOTIFY labelsFontChanged) |
|
49 | Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont NOTIFY labelsFontChanged) | |
50 | //TODO: make wrapping of color for qml |
|
50 | //TODO: make wrapping of color for qml | |
51 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) |
|
51 | Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged) | |
52 | //grid |
|
52 | //grid | |
53 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridLineVisibleChanged) |
|
53 | Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridLineVisibleChanged) | |
54 | Q_PROPERTY(QPen girdLinePen READ gridLinePen WRITE setGridLinePen NOTIFY gridLinePenChanged) |
|
54 | Q_PROPERTY(QPen girdLinePen READ gridLinePen WRITE setGridLinePen NOTIFY gridLinePenChanged) | |
55 | //shades |
|
55 | //shades | |
56 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) |
|
56 | Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged) | |
57 | //TODO: make wrapping of color for qml |
|
57 | //TODO: make wrapping of color for qml | |
58 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) |
|
58 | Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged) | |
59 | //TODO: make wrapping of border for qml |
|
59 | //TODO: make wrapping of border for qml | |
60 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) |
|
60 | Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged) | |
61 | Q_PROPERTY(QPen shadesPen READ shadesPen WRITE setShadesPen NOTIFY shadesPenChanged) |
|
61 | Q_PROPERTY(QPen shadesPen READ shadesPen WRITE setShadesPen NOTIFY shadesPenChanged) | |
62 | Q_PROPERTY(QBrush shadesBrush READ shadesBrush WRITE setShadesBrush NOTIFY shadesBrushChanged) |
|
62 | Q_PROPERTY(QBrush shadesBrush READ shadesBrush WRITE setShadesBrush NOTIFY shadesBrushChanged) | |
63 | //title |
|
63 | //title | |
64 | Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged) |
|
64 | Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged) | |
65 | Q_PROPERTY(QPen titlePen READ titlePen WRITE setTitlePen NOTIFY titlePenChanged) |
|
65 | Q_PROPERTY(QPen titlePen READ titlePen WRITE setTitlePen NOTIFY titlePenChanged) | |
66 | Q_PROPERTY(QBrush titleBrush READ titleBrush WRITE setTitleBrush NOTIFY titleBrushChanged) |
|
66 | Q_PROPERTY(QBrush titleBrush READ titleBrush WRITE setTitleBrush NOTIFY titleBrushChanged) | |
67 | Q_PROPERTY(bool titleVisible READ titleVisible WRITE setTitleVisible) |
|
67 | Q_PROPERTY(bool titleVisible READ titleVisible WRITE setTitleVisible) | |
68 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) |
|
68 | Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) | |
69 |
|
69 | |||
70 | public: |
|
70 | public: | |
71 |
|
71 | |||
72 | enum AxisType { |
|
72 | enum AxisType { | |
73 | AxisTypeNoAxis = 0x0, |
|
73 | AxisTypeNoAxis = 0x0, | |
74 | AxisTypeValue = 0x1, |
|
74 | AxisTypeValue = 0x1, | |
75 | AxisTypeBarCategory = 0x2, |
|
75 | AxisTypeBarCategory = 0x2, | |
76 | AxisTypeCategory = 0x3, |
|
76 | AxisTypeCategory = 0x3, | |
77 | AxisTypeDateTime = 0x4 |
|
77 | AxisTypeDateTime = 0x4, | |
|
78 | AxisTypeLogValue = 0x5 | |||
78 | }; |
|
79 | }; | |
79 |
|
80 | |||
80 | Q_DECLARE_FLAGS(AxisTypes, AxisType) |
|
81 | Q_DECLARE_FLAGS(AxisTypes, AxisType) | |
81 |
|
82 | |||
82 | protected: |
|
83 | protected: | |
83 | explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = 0); |
|
84 | explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = 0); | |
84 |
|
85 | |||
85 | public: |
|
86 | public: | |
86 | ~QAbstractAxis(); |
|
87 | ~QAbstractAxis(); | |
87 |
|
88 | |||
88 | virtual AxisType type() const = 0; |
|
89 | virtual AxisType type() const = 0; | |
89 |
|
90 | |||
90 | //visibility handling |
|
91 | //visibility handling | |
91 | bool isVisible() const; |
|
92 | bool isVisible() const; | |
92 | void setVisible(bool visible = true); |
|
93 | void setVisible(bool visible = true); | |
93 | void show(); |
|
94 | void show(); | |
94 | void hide(); |
|
95 | void hide(); | |
95 |
|
96 | |||
96 | //arrow handling |
|
97 | //arrow handling | |
97 | bool isLineVisible() const; |
|
98 | bool isLineVisible() const; | |
98 | void setLineVisible(bool visible = true); |
|
99 | void setLineVisible(bool visible = true); | |
99 | void setLinePen(const QPen &pen); |
|
100 | void setLinePen(const QPen &pen); | |
100 | QPen linePen() const; |
|
101 | QPen linePen() const; | |
101 | void setLinePenColor(QColor color); |
|
102 | void setLinePenColor(QColor color); | |
102 | QColor linePenColor() const; |
|
103 | QColor linePenColor() const; | |
103 |
|
104 | |||
104 | //grid handling |
|
105 | //grid handling | |
105 | bool isGridLineVisible() const; |
|
106 | bool isGridLineVisible() const; | |
106 | void setGridLineVisible(bool visible = true); |
|
107 | void setGridLineVisible(bool visible = true); | |
107 | void setGridLinePen(const QPen &pen); |
|
108 | void setGridLinePen(const QPen &pen); | |
108 | QPen gridLinePen() const; |
|
109 | QPen gridLinePen() const; | |
109 |
|
110 | |||
110 | //labels handling |
|
111 | //labels handling | |
111 | bool labelsVisible() const; |
|
112 | bool labelsVisible() const; | |
112 | void setLabelsVisible(bool visible = true); |
|
113 | void setLabelsVisible(bool visible = true); | |
113 | void setLabelsPen(const QPen &pen); |
|
114 | void setLabelsPen(const QPen &pen); | |
114 | QPen labelsPen() const; |
|
115 | QPen labelsPen() const; | |
115 | void setLabelsBrush(const QBrush &brush); |
|
116 | void setLabelsBrush(const QBrush &brush); | |
116 | QBrush labelsBrush() const; |
|
117 | QBrush labelsBrush() const; | |
117 | void setLabelsFont(const QFont &font); |
|
118 | void setLabelsFont(const QFont &font); | |
118 | QFont labelsFont() const; |
|
119 | QFont labelsFont() const; | |
119 | void setLabelsAngle(int angle); |
|
120 | void setLabelsAngle(int angle); | |
120 | int labelsAngle() const; |
|
121 | int labelsAngle() const; | |
121 | void setLabelsColor(QColor color); |
|
122 | void setLabelsColor(QColor color); | |
122 | QColor labelsColor() const; |
|
123 | QColor labelsColor() const; | |
123 |
|
124 | |||
124 | //title handling |
|
125 | //title handling | |
125 | bool titleVisible() const; |
|
126 | bool titleVisible() const; | |
126 | void setTitleVisible(bool visible = true); |
|
127 | void setTitleVisible(bool visible = true); | |
127 | void setTitlePen(const QPen &pen); |
|
128 | void setTitlePen(const QPen &pen); | |
128 | QPen titlePen() const; |
|
129 | QPen titlePen() const; | |
129 | void setTitleBrush(const QBrush &brush); |
|
130 | void setTitleBrush(const QBrush &brush); | |
130 | QBrush titleBrush() const; |
|
131 | QBrush titleBrush() const; | |
131 | void setTitleFont(const QFont &font); |
|
132 | void setTitleFont(const QFont &font); | |
132 | QFont titleFont() const; |
|
133 | QFont titleFont() const; | |
133 | void setTitleText(const QString &title); |
|
134 | void setTitleText(const QString &title); | |
134 | QString titleText() const; |
|
135 | QString titleText() const; | |
135 |
|
136 | |||
136 | //shades handling |
|
137 | //shades handling | |
137 | bool shadesVisible() const; |
|
138 | bool shadesVisible() const; | |
138 | void setShadesVisible(bool visible = true); |
|
139 | void setShadesVisible(bool visible = true); | |
139 | void setShadesPen(const QPen &pen); |
|
140 | void setShadesPen(const QPen &pen); | |
140 | QPen shadesPen() const; |
|
141 | QPen shadesPen() const; | |
141 | void setShadesBrush(const QBrush &brush); |
|
142 | void setShadesBrush(const QBrush &brush); | |
142 | QBrush shadesBrush() const; |
|
143 | QBrush shadesBrush() const; | |
143 | void setShadesColor(QColor color); |
|
144 | void setShadesColor(QColor color); | |
144 | QColor shadesColor() const; |
|
145 | QColor shadesColor() const; | |
145 | void setShadesBorderColor(QColor color); |
|
146 | void setShadesBorderColor(QColor color); | |
146 | QColor shadesBorderColor() const; |
|
147 | QColor shadesBorderColor() const; | |
147 |
|
148 | |||
148 | Qt::Orientation orientation(); //TODO: missing const <- BC |
|
149 | Qt::Orientation orientation(); //TODO: missing const <- BC | |
149 | Qt::Alignment alignment() const; |
|
150 | Qt::Alignment alignment() const; | |
150 |
|
151 | |||
151 | //range handling |
|
152 | //range handling | |
152 | void setMin(const QVariant &min); |
|
153 | void setMin(const QVariant &min); | |
153 | void setMax(const QVariant &max); |
|
154 | void setMax(const QVariant &max); | |
154 | void setRange(const QVariant &min, const QVariant &max); |
|
155 | void setRange(const QVariant &min, const QVariant &max); | |
155 |
|
156 | |||
156 | Q_SIGNALS: |
|
157 | Q_SIGNALS: | |
157 | void visibleChanged(bool visible); |
|
158 | void visibleChanged(bool visible); | |
158 | void linePenChanged(const QPen& pen); |
|
159 | void linePenChanged(const QPen& pen); | |
159 | void lineVisibleChanged(bool visible); |
|
160 | void lineVisibleChanged(bool visible); | |
160 | void labelsVisibleChanged(bool visible); |
|
161 | void labelsVisibleChanged(bool visible); | |
161 | void labelsPenChanged(const QPen& pen); |
|
162 | void labelsPenChanged(const QPen& pen); | |
162 | void labelsBrushChanged(const QBrush& brush); |
|
163 | void labelsBrushChanged(const QBrush& brush); | |
163 | void labelsFontChanged(const QFont& pen); |
|
164 | void labelsFontChanged(const QFont& pen); | |
164 | void labelsAngleChanged(int angle); |
|
165 | void labelsAngleChanged(int angle); | |
165 | void gridLinePenChanged(const QPen& pen); |
|
166 | void gridLinePenChanged(const QPen& pen); | |
166 | void gridLineVisibleChanged(bool visible); |
|
167 | void gridLineVisibleChanged(bool visible); | |
167 | void colorChanged(QColor color); |
|
168 | void colorChanged(QColor color); | |
168 | void labelsColorChanged(QColor color); |
|
169 | void labelsColorChanged(QColor color); | |
169 | void titleTextChanged(const QString& title); |
|
170 | void titleTextChanged(const QString& title); | |
170 | void titlePenChanged(const QPen& pen); |
|
171 | void titlePenChanged(const QPen& pen); | |
171 | void titleBrushChanged(const QBrush brush); |
|
172 | void titleBrushChanged(const QBrush brush); | |
172 | void titleVisibleChanged(bool visible); |
|
173 | void titleVisibleChanged(bool visible); | |
173 | void titleFontChanged(const QFont& font); |
|
174 | void titleFontChanged(const QFont& font); | |
174 | void shadesVisibleChanged(bool visible); |
|
175 | void shadesVisibleChanged(bool visible); | |
175 | void shadesColorChanged(QColor color); |
|
176 | void shadesColorChanged(QColor color); | |
176 | void shadesBorderColorChanged(QColor color); |
|
177 | void shadesBorderColorChanged(QColor color); | |
177 | void shadesPenChanged(const QPen& pen); |
|
178 | void shadesPenChanged(const QPen& pen); | |
178 | void shadesBrushChanged(const QBrush brush); |
|
179 | void shadesBrushChanged(const QBrush brush); | |
179 |
|
180 | |||
180 | protected: |
|
181 | protected: | |
181 | QScopedPointer<QAbstractAxisPrivate> d_ptr; |
|
182 | QScopedPointer<QAbstractAxisPrivate> d_ptr; | |
182 | Q_DISABLE_COPY(QAbstractAxis) |
|
183 | Q_DISABLE_COPY(QAbstractAxis) | |
183 | friend class ChartDataSet; |
|
184 | friend class ChartDataSet; | |
184 | friend class ChartAxis; |
|
185 | friend class ChartAxis; | |
185 | friend class ChartPresenter; |
|
186 | friend class ChartPresenter; | |
186 | friend class ChartThemeManager; |
|
187 | friend class ChartThemeManager; | |
187 | }; |
|
188 | }; | |
188 |
|
189 | |||
189 | QTCOMMERCIALCHART_END_NAMESPACE |
|
190 | QTCOMMERCIALCHART_END_NAMESPACE | |
190 |
|
191 | |||
191 | #endif // QABSTRACTAXIS_H |
|
192 | #endif // QABSTRACTAXIS_H |
General Comments 0
You need to be logged in to leave comments.
Login now