##// END OF EJS Templates
Fix zooming when presenter dimensions are not integers...
Fix zooming when presenter dimensions are not integers If presenter width (or height) is not an integer, zooming using vertical (or horizontal) rubberband will cause the fixed dimension to change, because rubberband uses QRect instead of QRectF. Fixed by forcing the corresponding plotArea dimension for the fixed rubberband dimension when calling zoomIn() in mouseReleaseEvent. Task-number: QTRD-1905 Reviewed-by: Mika Salmela

File last commit:

r2412:38736d0999b4
r2416:25b2e1c316cb
Show More
chartcategoryaxisy.cpp
120 lines | 3.4 KiB | text/x-c | CppLexer
/ src / axis / categoryaxis / chartcategoryaxisy.cpp
Marek Rosa
QIntervalsAxis working somewhat
r1701 /****************************************************************************
**
** Copyright (C) 2012 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the Qt Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE$
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
** $QT_END_LICENSE$
**
****************************************************************************/
Marek Rosa
Renamed QCategoryAxis related files
r1817 #include "chartcategoryaxisy_p.h"
#include "qcategoryaxis.h"
Marek Rosa
QIntervalsAxis working somewhat
r1701 #include "qabstractaxis.h"
#include "chartpresenter_p.h"
#include <QGraphicsLayout>
#include <QFontMetrics>
Michal Klocek
Refactor animator...
r1735 #include <qmath.h>
Michal Klocek
Fixes categoryaxis sizeHints
r2136 #include <QDebug>
Michal Klocek
Refactor animator...
r1735
Marek Rosa
QIntervalsAxis working somewhat
r1701 QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
Refactors internals...
r2273 ChartCategoryAxisY::ChartCategoryAxisY(QCategoryAxis *axis, QGraphicsItem* item)
: VerticalAxis(axis, item, true),
Jani Honkonen
src folder: another massive victory for coding style police
r2131 m_axis(axis)
Marek Rosa
QIntervalsAxis working somewhat
r1701 {
}
Marek Rosa
Renamed QCategoryAxis related files
r1817 ChartCategoryAxisY::~ChartCategoryAxisY()
Marek Rosa
QIntervalsAxis working somewhat
r1701 {
}
Marek Rosa
Renamed QCategoryAxis related files
r1817 QVector<qreal> ChartCategoryAxisY::calculateLayout() const
Marek Rosa
QIntervalsAxis working somewhat
r1701 {
Michal Klocek
Refactors axis updateGeometry handling...
r2111 int tickCount = m_axis->categoriesLabels().count() + 1;
Marek Rosa
QIntervalsAxis working somewhat
r1701 QVector<qreal> points;
Marek Rosa
Fixes and tests to Interval axis
r1708
if (tickCount < 2)
return points;
Jani Honkonen
src folder: another massive victory for coding style police
r2131 const QRectF &gridRect = gridGeometry();
Michal Klocek
Fixes categoryaxis sizeHints
r2136 qreal range = max() - min();
Marek Rosa
Fixed range handling in categoryAxis
r1846 if (range > 0) {
points.resize(tickCount);
Michal Klocek
Refactors axis updateGeometry handling...
r2111 qreal scale = gridRect.height() / range;
Jani Honkonen
src folder: another massive victory for coding style police
r2131 for (int i = 0; i < tickCount; ++i) {
Marek Rosa
Fixed range handling in categoryAxis
r1846 if (i < tickCount - 1) {
Michal Klocek
Fixes categoryaxis sizeHints
r2136 int y = -(m_axis->startValue(m_axis->categoriesLabels().at(i)) - min()) * scale + gridRect.bottom();
Marek Rosa
Fixed range handling in categoryAxis
r1846 points[i] = y;
} else {
Michal Klocek
Fixes categoryaxis sizeHints
r2136 int y = -(m_axis->endValue(m_axis->categoriesLabels().at(i - 1)) - min()) * scale + gridRect.bottom();
Marek Rosa
Fixed range handling in categoryAxis
r1846 points[i] = y;
}
Jani Honkonen
src folder: another massive victory for coding style police
r2131 }
Marek Rosa
Fixed range handling in categoryAxis
r1846 }
Marek Rosa
QIntervalsAxis working somewhat
r1701
return points;
}
Marek Rosa
Renamed QCategoryAxis related files
r1817 void ChartCategoryAxisY::updateGeometry()
Marek Rosa
QIntervalsAxis working somewhat
r1701 {
Jani Honkonen
src folder: another massive victory for coding style police
r2131 setLabels(m_axis->categoriesLabels() << "");
Michal Klocek
Refactors axis updateGeometry handling...
r2111 VerticalAxis::updateGeometry();
Marek Rosa
QIntervalsAxis working somewhat
r1701 }
Marek Rosa
Renamed QCategoryAxis related files
r1817 void ChartCategoryAxisY::handleAxisUpdated()
Marek Rosa
Added posibility to replace interval's label in QIntervalsAxis
r1777 {
Michal Klocek
Revert "TODOs removed from code. Undo me after release"...
r2407 updateGeometry();
//TODO:: ChartAxis::handleAxisUpdated();
Marek Rosa
Added posibility to replace interval's label in QIntervalsAxis
r1777 }
Jani Honkonen
src folder: another massive victory for coding style police
r2131 QSizeF ChartCategoryAxisY::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
Michal Klocek
Refactors layout...
r1965 {
Q_UNUSED(constraint)
Michal Klocek
Refactors axis updateGeometry handling...
r2111 QFontMetrics fn(font());
Michal Klocek
Refactors layout...
r1965 QSizeF sh;
Michal Klocek
Refactors ChartAxis...
r2138 QSizeF base = VerticalAxis::sizeHint(which, constraint);
Michal Klocek
Fixes categoryaxis sizeHints
r2136 QStringList ticksList = m_axis->categoriesLabels();
Jani Honkonen
src folder: another massive victory for coding style police
r2131 qreal width = 0;
qreal height = 0;
switch (which) {
Miikka Heikkinen
Fix axis sizehints when labels are angled...
r2412 case Qt::MinimumSize: {
QRectF boundingRect = labelBoundingRect(fn, "...");
width = boundingRect.width() + labelPadding();
Michal Klocek
Fixes categoryaxis sizeHints
r2136 width += base.width();
Miikka Heikkinen
Fix axis sizehints when labels are angled...
r2412 height = qMax(boundingRect.height(), base.height());
Jani Honkonen
src folder: another massive victory for coding style police
r2131 sh = QSizeF(width, height);
break;
Miikka Heikkinen
Fix axis sizehints when labels are angled...
r2412 }
Jani Honkonen
src folder: another massive victory for coding style police
r2131 case Qt::PreferredSize: {
Miikka Heikkinen
Fix axis sizehints when labels are angled...
r2412 int labelWidth = 0;
foreach (const QString& s, ticksList) {
QRect rect = labelBoundingRect(fn, s);
labelWidth = qMax(rect.width(), labelWidth);
Jani Honkonen
src folder: another massive victory for coding style police
r2131 height += rect.height();
Michal Klocek
Refactors layout...
r1965 }
Miikka Heikkinen
Fix axis sizehints when labels are angled...
r2412 width = labelWidth + labelPadding() + 1;
Jani Honkonen
src folder: another massive victory for coding style police
r2131 width += base.width();
Miikka Heikkinen
Fix axis sizehints when labels are angled...
r2412 height = qMax(height, base.height());
Jani Honkonen
src folder: another massive victory for coding style police
r2131 sh = QSizeF(width, height);
break;
}
default:
break;
}
return sh;
Michal Klocek
Refactors layout...
r1965 }
Marek Rosa
QIntervalsAxis working somewhat
r1701 QTCOMMERCIALCHART_END_NAMESPACE