@@ -1,137 +1,137 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | #include <private/chartlogvalueaxisx_p.h> |
|
19 | #include <private/chartlogvalueaxisx_p.h> | |
20 | #include <private/chartpresenter_p.h> |
|
20 | #include <private/chartpresenter_p.h> | |
21 | #include <QtCharts/QLogValueAxis> |
|
21 | #include <QtCharts/QLogValueAxis> | |
22 | #include <private/abstractchartlayout_p.h> |
|
22 | #include <private/abstractchartlayout_p.h> | |
23 | #include <QtWidgets/QGraphicsLayout> |
|
23 | #include <QtWidgets/QGraphicsLayout> | |
24 | #include <QtCore/QtMath> |
|
24 | #include <QtCore/QtMath> | |
25 | #include <QtCore/QDebug> |
|
25 | #include <QtCore/QDebug> | |
26 |
|
26 | |||
27 | QT_CHARTS_BEGIN_NAMESPACE |
|
27 | QT_CHARTS_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | ChartLogValueAxisX::ChartLogValueAxisX(QLogValueAxis *axis, QGraphicsItem *item) |
|
29 | ChartLogValueAxisX::ChartLogValueAxisX(QLogValueAxis *axis, QGraphicsItem *item) | |
30 | : HorizontalAxis(axis, item), |
|
30 | : HorizontalAxis(axis, item), | |
31 | m_axis(axis) |
|
31 | m_axis(axis) | |
32 | { |
|
32 | { | |
33 | QObject::connect(m_axis, SIGNAL(baseChanged(qreal)), this, SLOT(handleBaseChanged(qreal))); |
|
33 | QObject::connect(m_axis, SIGNAL(baseChanged(qreal)), this, SLOT(handleBaseChanged(qreal))); | |
34 | QObject::connect(m_axis, SIGNAL(labelFormatChanged(QString)), this, SLOT(handleLabelFormatChanged(QString))); |
|
34 | QObject::connect(m_axis, SIGNAL(labelFormatChanged(QString)), this, SLOT(handleLabelFormatChanged(QString))); | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | ChartLogValueAxisX::~ChartLogValueAxisX() |
|
37 | ChartLogValueAxisX::~ChartLogValueAxisX() | |
38 | { |
|
38 | { | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | QVector<qreal> ChartLogValueAxisX::calculateLayout() const |
|
41 | QVector<qreal> ChartLogValueAxisX::calculateLayout() const | |
42 | { |
|
42 | { | |
43 | QVector<qreal> points; |
|
43 | QVector<qreal> points; | |
44 |
|
44 | |||
45 | qreal logMax = log10(m_axis->max()) / log10(m_axis->base()); |
|
45 | qreal logMax = log10(m_axis->max()) / log10(m_axis->base()); | |
46 | qreal logMin = log10(m_axis->min()) / log10(m_axis->base()); |
|
46 | qreal logMin = log10(m_axis->min()) / log10(m_axis->base()); | |
47 | qreal leftEdge = logMin < logMax ? logMin : logMax; |
|
47 | qreal leftEdge = logMin < logMax ? logMin : logMax; | |
48 | qreal ceilEdge = ceil(leftEdge); |
|
48 | qreal ceilEdge = ceil(leftEdge); | |
49 | int tickCount = qAbs(ceil(logMax) - ceil(logMin)); |
|
49 | int tickCount = qAbs(ceil(logMax) - ceil(logMin)); | |
50 |
|
50 | |||
51 | points.resize(tickCount); |
|
51 | points.resize(tickCount + 1); | |
52 | const QRectF &gridRect = gridGeometry(); |
|
52 | const QRectF &gridRect = gridGeometry(); | |
53 | const qreal deltaX = gridRect.width() / qAbs(logMax - logMin); |
|
53 | const qreal deltaX = gridRect.width() / qAbs(logMax - logMin); | |
54 | for (int i = 0; i < tickCount; ++i) |
|
54 | for (int i = 0; i <= tickCount; ++i) | |
55 | points[i] = (ceilEdge + qreal(i)) * deltaX - leftEdge * deltaX + gridRect.left(); |
|
55 | points[i] = (ceilEdge + qreal(i)) * deltaX - leftEdge * deltaX + gridRect.left(); | |
56 |
|
56 | |||
57 | return points; |
|
57 | return points; | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | void ChartLogValueAxisX::updateGeometry() |
|
60 | void ChartLogValueAxisX::updateGeometry() | |
61 | { |
|
61 | { | |
62 | const QVector<qreal>& layout = ChartAxisElement::layout(); |
|
62 | const QVector<qreal>& layout = ChartAxisElement::layout(); | |
63 | if (layout.isEmpty()) |
|
63 | if (layout.isEmpty()) | |
64 | return; |
|
64 | return; | |
65 | setLabels(createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), layout.size(), m_axis->labelFormat())); |
|
65 | setLabels(createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), layout.size(), m_axis->labelFormat())); | |
66 | HorizontalAxis::updateGeometry(); |
|
66 | HorizontalAxis::updateGeometry(); | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void ChartLogValueAxisX::handleBaseChanged(qreal base) |
|
69 | void ChartLogValueAxisX::handleBaseChanged(qreal base) | |
70 | { |
|
70 | { | |
71 | Q_UNUSED(base); |
|
71 | Q_UNUSED(base); | |
72 | QGraphicsLayoutItem::updateGeometry(); |
|
72 | QGraphicsLayoutItem::updateGeometry(); | |
73 | if(presenter()) presenter()->layout()->invalidate(); |
|
73 | if(presenter()) presenter()->layout()->invalidate(); | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | void ChartLogValueAxisX::handleLabelFormatChanged(const QString &format) |
|
76 | void ChartLogValueAxisX::handleLabelFormatChanged(const QString &format) | |
77 | { |
|
77 | { | |
78 | Q_UNUSED(format); |
|
78 | Q_UNUSED(format); | |
79 | QGraphicsLayoutItem::updateGeometry(); |
|
79 | QGraphicsLayoutItem::updateGeometry(); | |
80 | if(presenter()) presenter()->layout()->invalidate(); |
|
80 | if(presenter()) presenter()->layout()->invalidate(); | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 | QSizeF ChartLogValueAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
83 | QSizeF ChartLogValueAxisX::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const | |
84 | { |
|
84 | { | |
85 | Q_UNUSED(constraint) |
|
85 | Q_UNUSED(constraint) | |
86 |
|
86 | |||
87 | QSizeF sh; |
|
87 | QSizeF sh; | |
88 |
|
88 | |||
89 | QSizeF base = HorizontalAxis::sizeHint(which, constraint); |
|
89 | QSizeF base = HorizontalAxis::sizeHint(which, constraint); | |
90 | QStringList ticksList; |
|
90 | QStringList ticksList; | |
91 | qreal logMax = log10(m_axis->max()) / log10(m_axis->base()); |
|
91 | qreal logMax = log10(m_axis->max()) / log10(m_axis->base()); | |
92 | qreal logMin = log10(m_axis->min()) / log10(m_axis->base()); |
|
92 | qreal logMin = log10(m_axis->min()) / log10(m_axis->base()); | |
93 | int tickCount = qAbs(ceil(logMax) - ceil(logMin)); |
|
93 | int tickCount = qAbs(ceil(logMax) - ceil(logMin)); | |
94 | if (m_axis->max() > m_axis->min() && tickCount > 0) |
|
94 | if (m_axis->max() > m_axis->min() && tickCount > 0) | |
95 | ticksList = createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), tickCount, m_axis->labelFormat()); |
|
95 | ticksList = createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), tickCount, m_axis->labelFormat()); | |
96 | else |
|
96 | else | |
97 | ticksList.append(QStringLiteral(" ")); |
|
97 | ticksList.append(QStringLiteral(" ")); | |
98 | // Width of horizontal axis sizeHint indicates the maximum distance labels can extend past |
|
98 | // Width of horizontal axis sizeHint indicates the maximum distance labels can extend past | |
99 | // first and last ticks. Base width is irrelevant. |
|
99 | // first and last ticks. Base width is irrelevant. | |
100 | qreal width = 0; |
|
100 | qreal width = 0; | |
101 | qreal height = 0; |
|
101 | qreal height = 0; | |
102 |
|
102 | |||
103 | switch (which) { |
|
103 | switch (which) { | |
104 | case Qt::MinimumSize:{ |
|
104 | case Qt::MinimumSize:{ | |
105 | QRectF boundingRect = ChartPresenter::textBoundingRect(axis()->labelsFont(), |
|
105 | QRectF boundingRect = ChartPresenter::textBoundingRect(axis()->labelsFont(), | |
106 | QStringLiteral("..."), |
|
106 | QStringLiteral("..."), | |
107 | axis()->labelsAngle()); |
|
107 | axis()->labelsAngle()); | |
108 | width = boundingRect.width() / 2.0; |
|
108 | width = boundingRect.width() / 2.0; | |
109 | height = boundingRect.height() + labelPadding() + base.height() + 1.0; |
|
109 | height = boundingRect.height() + labelPadding() + base.height() + 1.0; | |
110 | sh = QSizeF(width, height); |
|
110 | sh = QSizeF(width, height); | |
111 | break; |
|
111 | break; | |
112 | } |
|
112 | } | |
113 | case Qt::PreferredSize: { |
|
113 | case Qt::PreferredSize: { | |
114 | qreal labelHeight = 0.0; |
|
114 | qreal labelHeight = 0.0; | |
115 | qreal firstWidth = -1.0; |
|
115 | qreal firstWidth = -1.0; | |
116 | foreach (const QString& s, ticksList) { |
|
116 | foreach (const QString& s, ticksList) { | |
117 | QRectF rect = ChartPresenter::textBoundingRect(axis()->labelsFont(), s, axis()->labelsAngle()); |
|
117 | QRectF rect = ChartPresenter::textBoundingRect(axis()->labelsFont(), s, axis()->labelsAngle()); | |
118 | labelHeight = qMax(rect.height(), labelHeight); |
|
118 | labelHeight = qMax(rect.height(), labelHeight); | |
119 | width = rect.width(); |
|
119 | width = rect.width(); | |
120 | if (firstWidth < 0.0) |
|
120 | if (firstWidth < 0.0) | |
121 | firstWidth = width; |
|
121 | firstWidth = width; | |
122 | } |
|
122 | } | |
123 | height = labelHeight + labelPadding() + base.height() + 1.0; |
|
123 | height = labelHeight + labelPadding() + base.height() + 1.0; | |
124 | width = qMax(width, firstWidth) / 2.0; |
|
124 | width = qMax(width, firstWidth) / 2.0; | |
125 | sh = QSizeF(width, height); |
|
125 | sh = QSizeF(width, height); | |
126 | break; |
|
126 | break; | |
127 | } |
|
127 | } | |
128 | default: |
|
128 | default: | |
129 | break; |
|
129 | break; | |
130 | } |
|
130 | } | |
131 |
|
131 | |||
132 | return sh; |
|
132 | return sh; | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | #include "moc_chartlogvalueaxisx_p.cpp" |
|
135 | #include "moc_chartlogvalueaxisx_p.cpp" | |
136 |
|
136 | |||
137 | QT_CHARTS_END_NAMESPACE |
|
137 | QT_CHARTS_END_NAMESPACE |
@@ -1,137 +1,137 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2014 Digia Plc |
|
3 | ** Copyright (C) 2014 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.io |
|
5 | ** For any questions to Digia, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and Digia. |
|
12 | ** agreement between you and Digia. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | #include <private/chartlogvalueaxisy_p.h> |
|
19 | #include <private/chartlogvalueaxisy_p.h> | |
20 | #include <private/chartpresenter_p.h> |
|
20 | #include <private/chartpresenter_p.h> | |
21 | #include <QtCharts/QLogValueAxis> |
|
21 | #include <QtCharts/QLogValueAxis> | |
22 | #include <private/abstractchartlayout_p.h> |
|
22 | #include <private/abstractchartlayout_p.h> | |
23 | #include <QtWidgets/QGraphicsLayout> |
|
23 | #include <QtWidgets/QGraphicsLayout> | |
24 | #include <QtCore/QtMath> |
|
24 | #include <QtCore/QtMath> | |
25 | #include <QtCore/QDebug> |
|
25 | #include <QtCore/QDebug> | |
26 |
|
26 | |||
27 | QT_CHARTS_BEGIN_NAMESPACE |
|
27 | QT_CHARTS_BEGIN_NAMESPACE | |
28 |
|
28 | |||
29 | ChartLogValueAxisY::ChartLogValueAxisY(QLogValueAxis *axis, QGraphicsItem *item) |
|
29 | ChartLogValueAxisY::ChartLogValueAxisY(QLogValueAxis *axis, QGraphicsItem *item) | |
30 | : VerticalAxis(axis, item), |
|
30 | : VerticalAxis(axis, item), | |
31 | m_axis(axis) |
|
31 | m_axis(axis) | |
32 | { |
|
32 | { | |
33 | QObject::connect(m_axis, SIGNAL(baseChanged(qreal)), this, SLOT(handleBaseChanged(qreal))); |
|
33 | QObject::connect(m_axis, SIGNAL(baseChanged(qreal)), this, SLOT(handleBaseChanged(qreal))); | |
34 | QObject::connect(m_axis, SIGNAL(labelFormatChanged(QString)), this, SLOT(handleLabelFormatChanged(QString))); |
|
34 | QObject::connect(m_axis, SIGNAL(labelFormatChanged(QString)), this, SLOT(handleLabelFormatChanged(QString))); | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | ChartLogValueAxisY::~ChartLogValueAxisY() |
|
37 | ChartLogValueAxisY::~ChartLogValueAxisY() | |
38 | { |
|
38 | { | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | QVector<qreal> ChartLogValueAxisY::calculateLayout() const |
|
41 | QVector<qreal> ChartLogValueAxisY::calculateLayout() const | |
42 | { |
|
42 | { | |
43 | QVector<qreal> points; |
|
43 | QVector<qreal> points; | |
44 | qreal logMax = log10(m_axis->max()) / log10(m_axis->base()); |
|
44 | qreal logMax = log10(m_axis->max()) / log10(m_axis->base()); | |
45 | qreal logMin = log10(m_axis->min()) / log10(m_axis->base()); |
|
45 | qreal logMin = log10(m_axis->min()) / log10(m_axis->base()); | |
46 | qreal leftEdge = logMin < logMax ? logMin : logMax; |
|
46 | qreal leftEdge = logMin < logMax ? logMin : logMax; | |
47 | qreal ceilEdge = ceil(leftEdge); |
|
47 | qreal ceilEdge = ceil(leftEdge); | |
48 | int tickCount = qAbs(ceil(logMax) - ceil(logMin)); |
|
48 | int tickCount = qAbs(ceil(logMax) - ceil(logMin)); | |
49 |
|
49 | |||
50 | points.resize(tickCount); |
|
50 | points.resize(tickCount + 1); | |
51 | const QRectF &gridRect = gridGeometry(); |
|
51 | const QRectF &gridRect = gridGeometry(); | |
52 | const qreal deltaY = gridRect.height() / qAbs(logMax - logMin); |
|
52 | const qreal deltaY = gridRect.height() / qAbs(logMax - logMin); | |
53 | for (int i = 0; i < tickCount; ++i) |
|
53 | for (int i = 0; i <= tickCount; ++i) | |
54 | points[i] = (ceilEdge + qreal(i)) * -deltaY - leftEdge * -deltaY + gridRect.bottom(); |
|
54 | points[i] = (ceilEdge + qreal(i)) * -deltaY - leftEdge * -deltaY + gridRect.bottom(); | |
55 |
|
55 | |||
56 | return points; |
|
56 | return points; | |
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 |
|
59 | |||
60 | void ChartLogValueAxisY::updateGeometry() |
|
60 | void ChartLogValueAxisY::updateGeometry() | |
61 | { |
|
61 | { | |
62 | const QVector<qreal> &layout = ChartAxisElement::layout(); |
|
62 | const QVector<qreal> &layout = ChartAxisElement::layout(); | |
63 | if (layout.isEmpty()) |
|
63 | if (layout.isEmpty()) | |
64 | return; |
|
64 | return; | |
65 | setLabels(createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), layout.size(), m_axis->labelFormat())); |
|
65 | setLabels(createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), layout.size(), m_axis->labelFormat())); | |
66 | VerticalAxis::updateGeometry(); |
|
66 | VerticalAxis::updateGeometry(); | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void ChartLogValueAxisY::handleBaseChanged(qreal base) |
|
69 | void ChartLogValueAxisY::handleBaseChanged(qreal base) | |
70 | { |
|
70 | { | |
71 | Q_UNUSED(base); |
|
71 | Q_UNUSED(base); | |
72 | QGraphicsLayoutItem::updateGeometry(); |
|
72 | QGraphicsLayoutItem::updateGeometry(); | |
73 | if(presenter()) presenter()->layout()->invalidate(); |
|
73 | if(presenter()) presenter()->layout()->invalidate(); | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | void ChartLogValueAxisY::handleLabelFormatChanged(const QString &format) |
|
76 | void ChartLogValueAxisY::handleLabelFormatChanged(const QString &format) | |
77 | { |
|
77 | { | |
78 | Q_UNUSED(format); |
|
78 | Q_UNUSED(format); | |
79 | QGraphicsLayoutItem::updateGeometry(); |
|
79 | QGraphicsLayoutItem::updateGeometry(); | |
80 | if(presenter()) presenter()->layout()->invalidate(); |
|
80 | if(presenter()) presenter()->layout()->invalidate(); | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 | QSizeF ChartLogValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
83 | QSizeF ChartLogValueAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const | |
84 | { |
|
84 | { | |
85 | Q_UNUSED(constraint) |
|
85 | Q_UNUSED(constraint) | |
86 |
|
86 | |||
87 | QSizeF sh; |
|
87 | QSizeF sh; | |
88 |
|
88 | |||
89 | QSizeF base = VerticalAxis::sizeHint(which, constraint); |
|
89 | QSizeF base = VerticalAxis::sizeHint(which, constraint); | |
90 | QStringList ticksList; |
|
90 | QStringList ticksList; | |
91 | qreal logMax = log10(m_axis->max()) / log10(m_axis->base()); |
|
91 | qreal logMax = log10(m_axis->max()) / log10(m_axis->base()); | |
92 | qreal logMin = log10(m_axis->min()) / log10(m_axis->base()); |
|
92 | qreal logMin = log10(m_axis->min()) / log10(m_axis->base()); | |
93 | int tickCount = qAbs(ceil(logMax) - ceil(logMin)); |
|
93 | int tickCount = qAbs(ceil(logMax) - ceil(logMin)); | |
94 | if (m_axis->max() > m_axis->min() && tickCount > 0) |
|
94 | if (m_axis->max() > m_axis->min() && tickCount > 0) | |
95 | ticksList = createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), tickCount, m_axis->labelFormat()); |
|
95 | ticksList = createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), tickCount, m_axis->labelFormat()); | |
96 | else |
|
96 | else | |
97 | ticksList.append(QStringLiteral(" ")); |
|
97 | ticksList.append(QStringLiteral(" ")); | |
98 | qreal width = 0; |
|
98 | qreal width = 0; | |
99 | // Height of vertical axis sizeHint indicates the maximum distance labels can extend past |
|
99 | // Height of vertical axis sizeHint indicates the maximum distance labels can extend past | |
100 | // first and last ticks. Base height is irrelevant. |
|
100 | // first and last ticks. Base height is irrelevant. | |
101 | qreal height = 0; |
|
101 | qreal height = 0; | |
102 |
|
102 | |||
103 | switch (which) { |
|
103 | switch (which) { | |
104 | case Qt::MinimumSize: { |
|
104 | case Qt::MinimumSize: { | |
105 | QRectF boundingRect = ChartPresenter::textBoundingRect(axis()->labelsFont(), |
|
105 | QRectF boundingRect = ChartPresenter::textBoundingRect(axis()->labelsFont(), | |
106 | QStringLiteral("..."), |
|
106 | QStringLiteral("..."), | |
107 | axis()->labelsAngle()); |
|
107 | axis()->labelsAngle()); | |
108 | width = boundingRect.width() + labelPadding() + base.width() + 1.0; |
|
108 | width = boundingRect.width() + labelPadding() + base.width() + 1.0; | |
109 | height = boundingRect.height() / 2.0; |
|
109 | height = boundingRect.height() / 2.0; | |
110 | sh = QSizeF(width, height); |
|
110 | sh = QSizeF(width, height); | |
111 | break; |
|
111 | break; | |
112 | } |
|
112 | } | |
113 | case Qt::PreferredSize: { |
|
113 | case Qt::PreferredSize: { | |
114 | qreal labelWidth = 0.0; |
|
114 | qreal labelWidth = 0.0; | |
115 | qreal firstHeight = -1.0; |
|
115 | qreal firstHeight = -1.0; | |
116 | foreach (const QString& s, ticksList) { |
|
116 | foreach (const QString& s, ticksList) { | |
117 | QRectF rect = ChartPresenter::textBoundingRect(axis()->labelsFont(), s, axis()->labelsAngle()); |
|
117 | QRectF rect = ChartPresenter::textBoundingRect(axis()->labelsFont(), s, axis()->labelsAngle()); | |
118 | labelWidth = qMax(rect.width(), labelWidth); |
|
118 | labelWidth = qMax(rect.width(), labelWidth); | |
119 | height = rect.height(); |
|
119 | height = rect.height(); | |
120 | if (firstHeight < 0.0) |
|
120 | if (firstHeight < 0.0) | |
121 | firstHeight = height; |
|
121 | firstHeight = height; | |
122 | } |
|
122 | } | |
123 | width = labelWidth + labelPadding() + base.width() + 2.0; //two pixels of tolerance |
|
123 | width = labelWidth + labelPadding() + base.width() + 2.0; //two pixels of tolerance | |
124 | height = qMax(height, firstHeight) / 2.0; |
|
124 | height = qMax(height, firstHeight) / 2.0; | |
125 | sh = QSizeF(width, height); |
|
125 | sh = QSizeF(width, height); | |
126 | break; |
|
126 | break; | |
127 | } |
|
127 | } | |
128 | default: |
|
128 | default: | |
129 | break; |
|
129 | break; | |
130 | } |
|
130 | } | |
131 |
|
131 | |||
132 | return sh; |
|
132 | return sh; | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | #include "moc_chartlogvalueaxisy_p.cpp" |
|
135 | #include "moc_chartlogvalueaxisy_p.cpp" | |
136 |
|
136 | |||
137 | QT_CHARTS_END_NAMESPACE |
|
137 | QT_CHARTS_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now