##// END OF EJS Templates
Fix QLogValueAxis update...
Titta Heikkala -
r2759:8e20d47d8440
parent child
Show More
@@ -37,14 +37,12 void HorizontalAxis::updateGeometry()
37 {
37 {
38 const QVector<qreal> &layout = ChartAxisElement::layout();
38 const QVector<qreal> &layout = ChartAxisElement::layout();
39
39
40 if (layout.isEmpty())
40 if (layout.isEmpty() && axis()->type() != QAbstractAxis::AxisTypeLogValue)
41 return;
41 return;
42
42
43 QStringList labelList = labels();
43 QStringList labelList = labels();
44
44
45 QList<QGraphicsItem *> lines = gridItems();
46 QList<QGraphicsItem *> labels = labelItems();
45 QList<QGraphicsItem *> labels = labelItems();
47 QList<QGraphicsItem *> shades = shadeItems();
48 QList<QGraphicsItem *> arrow = arrowItems();
46 QList<QGraphicsItem *> arrow = arrowItems();
49 QGraphicsTextItem *title = titleItem();
47 QGraphicsTextItem *title = titleItem();
50
48
@@ -90,6 +88,12 void HorizontalAxis::updateGeometry()
90 availableSpace -= titleBoundingRect.height();
88 availableSpace -= titleBoundingRect.height();
91 }
89 }
92
90
91 if (layout.isEmpty() && axis()->type() == QAbstractAxis::AxisTypeLogValue)
92 return;
93
94 QList<QGraphicsItem *> lines = gridItems();
95 QList<QGraphicsItem *> shades = shadeItems();
96
93 for (int i = 0; i < layout.size(); ++i) {
97 for (int i = 0; i < layout.size(); ++i) {
94 //items
98 //items
95 QGraphicsLineItem *gridItem = static_cast<QGraphicsLineItem*>(lines.at(i));
99 QGraphicsLineItem *gridItem = static_cast<QGraphicsLineItem*>(lines.at(i));
@@ -48,10 +48,10 QVector<qreal> ChartLogValueAxisX::calculateLayout() const
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 + 1);
51 points.resize(tickCount);
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;
@@ -60,8 +60,6 QVector<qreal> ChartLogValueAxisX::calculateLayout() const
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())
64 return;
65 setLabels(createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), layout.size(), m_axis->labelFormat()));
63 setLabels(createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), layout.size(), m_axis->labelFormat()));
66 HorizontalAxis::updateGeometry();
64 HorizontalAxis::updateGeometry();
67 }
65 }
@@ -47,10 +47,10 QVector<qreal> ChartLogValueAxisY::calculateLayout() const
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 + 1);
50 points.resize(tickCount);
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;
@@ -60,8 +60,6 QVector<qreal> ChartLogValueAxisY::calculateLayout() const
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())
64 return;
65 setLabels(createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), layout.size(), m_axis->labelFormat()));
63 setLabels(createLogValueLabels(m_axis->min(), m_axis->max(), m_axis->base(), layout.size(), m_axis->labelFormat()));
66 VerticalAxis::updateGeometry();
64 VerticalAxis::updateGeometry();
67 }
65 }
@@ -36,14 +36,12 void VerticalAxis::updateGeometry()
36 {
36 {
37 const QVector<qreal> &layout = ChartAxisElement::layout();
37 const QVector<qreal> &layout = ChartAxisElement::layout();
38
38
39 if (layout.isEmpty())
39 if (layout.isEmpty() && axis()->type() != QAbstractAxis::AxisTypeLogValue)
40 return;
40 return;
41
41
42 QStringList labelList = labels();
42 QStringList labelList = labels();
43
43
44 QList<QGraphicsItem *> lines = gridItems();
45 QList<QGraphicsItem *> labels = labelItems();
44 QList<QGraphicsItem *> labels = labelItems();
46 QList<QGraphicsItem *> shades = shadeItems();
47 QList<QGraphicsItem *> arrow = arrowItems();
45 QList<QGraphicsItem *> arrow = arrowItems();
48 QGraphicsTextItem *title = titleItem();
46 QGraphicsTextItem *title = titleItem();
49
47
@@ -55,7 +53,6 void VerticalAxis::updateGeometry()
55
53
56 qreal height = axisRect.bottom();
54 qreal height = axisRect.bottom();
57
55
58
59 //arrow
56 //arrow
60 QGraphicsLineItem *arrowItem = static_cast<QGraphicsLineItem*>(arrow.at(0));
57 QGraphicsLineItem *arrowItem = static_cast<QGraphicsLineItem*>(arrow.at(0));
61
58
@@ -93,6 +90,12 void VerticalAxis::updateGeometry()
93 availableSpace -= titleBoundingRect.height();
90 availableSpace -= titleBoundingRect.height();
94 }
91 }
95
92
93 if (layout.isEmpty() && axis()->type() == QAbstractAxis::AxisTypeLogValue)
94 return;
95
96 QList<QGraphicsItem *> lines = gridItems();
97 QList<QGraphicsItem *> shades = shadeItems();
98
96 for (int i = 0; i < layout.size(); ++i) {
99 for (int i = 0; i < layout.size(); ++i) {
97 //items
100 //items
98 QGraphicsLineItem *gridItem = static_cast<QGraphicsLineItem *>(lines.at(i));
101 QGraphicsLineItem *gridItem = static_cast<QGraphicsLineItem *>(lines.at(i));
General Comments 0
You need to be logged in to leave comments. Login now