diff options
Diffstat (limited to 'src/layout')
-rw-r--r-- | src/layout/abstractchartlayout.cpp | 197 | ||||
-rw-r--r-- | src/layout/abstractchartlayout_p.h | 82 | ||||
-rw-r--r-- | src/layout/cartesianchartlayout.cpp | 246 | ||||
-rw-r--r-- | src/layout/cartesianchartlayout_p.h | 50 | ||||
-rw-r--r-- | src/layout/layout.pri | 12 | ||||
-rw-r--r-- | src/layout/polarchartlayout.cpp | 83 | ||||
-rw-r--r-- | src/layout/polarchartlayout_p.h | 50 |
7 files changed, 720 insertions, 0 deletions
diff --git a/src/layout/abstractchartlayout.cpp b/src/layout/abstractchartlayout.cpp new file mode 100644 index 00000000..092e8c0c --- /dev/null +++ b/src/layout/abstractchartlayout.cpp @@ -0,0 +1,197 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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$ +** +****************************************************************************/ + +#include "abstractchartlayout_p.h" +#include "chartpresenter_p.h" +#include "qlegend_p.h" +#include "chartaxiselement_p.h" +#include "charttitle_p.h" +#include "chartbackground_p.h" +#include <QDebug> + +QTCOMMERCIALCHART_BEGIN_NAMESPACE + +static const qreal golden_ratio = 0.4; + +AbstractChartLayout::AbstractChartLayout(ChartPresenter *presenter) + : m_presenter(presenter), + m_margins(20, 20, 20, 20), + m_minChartRect(0, 0, 200, 200) +{ +} + +AbstractChartLayout::~AbstractChartLayout() +{ +} + +void AbstractChartLayout::setGeometry(const QRectF &rect) +{ + if (!rect.isValid()) + return; + + QList<ChartAxisElement *> axes = m_presenter->axisItems(); + ChartTitle *title = m_presenter->titleElement(); + QLegend *legend = m_presenter->legend(); + ChartBackground *background = m_presenter->backgroundElement(); + + QRectF contentGeometry = calculateBackgroundGeometry(rect, background); + + contentGeometry = calculateContentGeometry(contentGeometry); + + if (title && title->isVisible()) + contentGeometry = calculateTitleGeometry(contentGeometry, title); + + if (legend->isAttachedToChart() && legend->isVisible()) + contentGeometry = calculateLegendGeometry(contentGeometry, legend); + + contentGeometry = calculateAxisGeometry(contentGeometry, axes); + + m_presenter->setGeometry(contentGeometry); + + QGraphicsLayout::setGeometry(rect); +} + +QRectF AbstractChartLayout::calculateContentGeometry(const QRectF &geometry) const +{ + return geometry.adjusted(m_margins.left(), m_margins.top(), -m_margins.right(), -m_margins.bottom()); +} + +QRectF AbstractChartLayout::calculateContentMinimum(const QRectF &minimum) const +{ + return minimum.adjusted(0, 0, m_margins.left() + m_margins.right(), m_margins.top() + m_margins.bottom()); +} + + +QRectF AbstractChartLayout::calculateBackgroundGeometry(const QRectF &geometry, ChartBackground *background) const +{ + qreal left; + qreal top; + qreal right; + qreal bottom; + getContentsMargins(&left, &top, &right, &bottom); + QRectF backgroundGeometry = geometry.adjusted(left, top, -right, -bottom); + if (background) + background->setRect(backgroundGeometry); + return backgroundGeometry; +} + +QRectF AbstractChartLayout::calculateBackgroundMinimum(const QRectF &minimum) const +{ + qreal left; + qreal top; + qreal right; + qreal bottom; + getContentsMargins(&left, &top, &right, &bottom); + return minimum.adjusted(0, 0, left + right, top + bottom); +} + +QRectF AbstractChartLayout::calculateLegendGeometry(const QRectF &geometry, QLegend *legend) const +{ + QSizeF size = legend->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1)); + QRectF legendRect; + QRectF result; + + switch (legend->alignment()) { + case Qt::AlignTop: { + legendRect = QRectF(geometry.topLeft(), QSizeF(geometry.width(), size.height())); + result = geometry.adjusted(0, legendRect.height(), 0, 0); + break; + } + case Qt::AlignBottom: { + legendRect = QRectF(QPointF(geometry.left(), geometry.bottom() - size.height()), QSizeF(geometry.width(), size.height())); + result = geometry.adjusted(0, 0, 0, -legendRect.height()); + break; + } + case Qt::AlignLeft: { + qreal width = qMin(size.width(), geometry.width() * golden_ratio); + legendRect = QRectF(geometry.topLeft(), QSizeF(width, geometry.height())); + result = geometry.adjusted(width, 0, 0, 0); + break; + } + case Qt::AlignRight: { + qreal width = qMin(size.width(), geometry.width() * golden_ratio); + legendRect = QRectF(QPointF(geometry.right() - width, geometry.top()), QSizeF(width, geometry.height())); + result = geometry.adjusted(0, 0, -width, 0); + break; + } + default: { + legendRect = QRectF(0, 0, 0, 0); + result = geometry; + break; + } + } + + legend->setGeometry(legendRect); + + return result; +} + +QRectF AbstractChartLayout::calculateLegendMinimum(const QRectF &geometry, QLegend *legend) const +{ + QSizeF minSize = legend->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, -1)); + return geometry.adjusted(0, 0, minSize.width(), minSize.height()); +} + +QRectF AbstractChartLayout::calculateTitleGeometry(const QRectF &geometry, ChartTitle *title) const +{ + title->setGeometry(geometry); + QPointF center = geometry.center() - title->boundingRect().center(); + title->setPos(center.x(), title->pos().y()); + return geometry.adjusted(0, title->boundingRect().height()+1, 0, 0); +} + +QRectF AbstractChartLayout::calculateTitleMinimum(const QRectF &minimum, ChartTitle *title) const +{ + QSizeF min = title->sizeHint(Qt::MinimumSize); + return minimum.adjusted(0, 0, min.width(), min.height()); +} + +QSizeF AbstractChartLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const +{ + Q_UNUSED(constraint); + if (which == Qt::MinimumSize) { + QList<ChartAxisElement *> axes = m_presenter->axisItems(); + ChartTitle *title = m_presenter->titleElement(); + QLegend *legend = m_presenter->legend(); + QRectF minimumRect(0, 0, 0, 0); + minimumRect = calculateBackgroundMinimum(minimumRect); + minimumRect = calculateContentMinimum(minimumRect); + minimumRect = calculateTitleMinimum(minimumRect, title); + minimumRect = calculateLegendMinimum(minimumRect, legend); + minimumRect = calculateAxisMinimum(minimumRect, axes); + return minimumRect.united(m_minChartRect).size().toSize(); + } + return QSize(-1, -1); +} + +void AbstractChartLayout::setMargins(const QMargins &margins) +{ + if (m_margins != margins) { + m_margins = margins; + updateGeometry(); + } +} + +QMargins AbstractChartLayout::margins() const +{ + return m_margins; +} + +QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/layout/abstractchartlayout_p.h b/src/layout/abstractchartlayout_p.h new file mode 100644 index 00000000..d28af3d2 --- /dev/null +++ b/src/layout/abstractchartlayout_p.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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$ +** +****************************************************************************/ + +// W A R N I N G +// ------------- +// +// This file is not part of the QtCommercial Chart API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#ifndef ABSTRACTCHARTLAYOUT_H +#define ABSTRACTCHARTLAYOUT_H + +#include <QGraphicsLayout> +#include <QMargins> +#include "qchartglobal.h" + +QTCOMMERCIALCHART_BEGIN_NAMESPACE + +class ChartTitle; +class ChartAxisElement; +class ChartPresenter; +class QLegend; +class ChartBackground; + +class AbstractChartLayout : public QGraphicsLayout +{ +public: + AbstractChartLayout(ChartPresenter *presenter); + virtual ~AbstractChartLayout(); + + virtual void setMargins(const QMargins &margins); + virtual QMargins margins() const; + virtual void setGeometry(const QRectF &rect); + +protected: + virtual QRectF calculateBackgroundGeometry(const QRectF &geometry, ChartBackground *background) const; + virtual QRectF calculateBackgroundMinimum(const QRectF &minimum) const; + virtual QRectF calculateContentGeometry(const QRectF &geometry) const; + virtual QRectF calculateContentMinimum(const QRectF &minimum) const; + virtual QRectF calculateTitleGeometry(const QRectF &geometry, ChartTitle *title) const; + virtual QRectF calculateTitleMinimum(const QRectF &minimum, ChartTitle *title) const; + virtual QRectF calculateLegendGeometry(const QRectF &geometry, QLegend *legend) const; + virtual QRectF calculateLegendMinimum(const QRectF &minimum, QLegend *legend) const; + + virtual QRectF calculateAxisGeometry(const QRectF &geometry, const QList<ChartAxisElement *>& axes) const = 0; + virtual QRectF calculateAxisMinimum(const QRectF &minimum, const QList<ChartAxisElement *>& axes) const = 0; + + // from QGraphicsLayout + QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; + int count() const { return 0; } + QGraphicsLayoutItem *itemAt(int) const { return 0; }; + void removeAt(int) {}; + + ChartPresenter *m_presenter; + QMargins m_margins; + QRectF m_minChartRect; + QRectF m_minAxisRect; +}; + +QTCOMMERCIALCHART_END_NAMESPACE + +#endif // ABSTRACTCHARTLAYOUT_H diff --git a/src/layout/cartesianchartlayout.cpp b/src/layout/cartesianchartlayout.cpp new file mode 100644 index 00000000..f5317752 --- /dev/null +++ b/src/layout/cartesianchartlayout.cpp @@ -0,0 +1,246 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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$ +** +****************************************************************************/ + +#include "cartesianchartlayout_p.h" +#include "chartpresenter_p.h" +#include "chartaxiselement_p.h" +#include <QDebug> + +QTCOMMERCIALCHART_BEGIN_NAMESPACE + +static const qreal maxAxisPortion = 0.4; + +CartesianChartLayout::CartesianChartLayout(ChartPresenter *presenter) + : AbstractChartLayout(presenter) +{ +} + +CartesianChartLayout::~CartesianChartLayout() +{ +} + +QRectF CartesianChartLayout::calculateAxisGeometry(const QRectF &geometry, const QList<ChartAxisElement *> &axes) const +{ + QSizeF left(0,0); + QSizeF minLeft(0,0); + QSizeF right(0,0); + QSizeF minRight(0,0); + QSizeF bottom(0,0); + QSizeF minBottom(0,0); + QSizeF top(0,0); + QSizeF minTop(0,0); + QSizeF labelExtents(0,0); + int leftCount = 0; + int rightCount = 0; + int topCount = 0; + int bottomCount = 0; + + foreach (ChartAxisElement *axis , axes) { + + if (!axis->isVisible()) + continue; + + + QSizeF size = axis->effectiveSizeHint(Qt::PreferredSize); + //this is used to get single thick font size + QSizeF minSize = axis->effectiveSizeHint(Qt::MinimumSize); + + switch (axis->axis()->alignment()) { + case Qt::AlignLeft: + left.setWidth(left.width()+size.width()); + left.setHeight(qMax(left.height(),size.height())); + minLeft.setWidth(minLeft.width()+minSize.width()); + minLeft.setHeight(qMax(minLeft.height(),minSize.height())); + labelExtents.setHeight(qMax(size.height(), labelExtents.height())); + leftCount++; + break; + case Qt::AlignRight: + right.setWidth(right.width()+size.width()); + right.setHeight(qMax(right.height(),size.height())); + minRight.setWidth(minRight.width()+minSize.width()); + minRight.setHeight(qMax(minRight.height(),minSize.height())); + labelExtents.setHeight(qMax(size.height(), labelExtents.height())); + rightCount++; + break; + case Qt::AlignTop: + top.setWidth(qMax(top.width(),size.width())); + top.setHeight(top.height()+size.height()); + minTop.setWidth(qMax(minTop.width(),minSize.width())); + minTop.setHeight(minTop.height()+minSize.height()); + labelExtents.setWidth(qMax(size.width(), labelExtents.width())); + topCount++; + break; + case Qt::AlignBottom: + bottom.setWidth(qMax(bottom.width(), size.width())); + bottom.setHeight(bottom.height() + size.height()); + minBottom.setWidth(qMax(minBottom.width(),minSize.width())); + minBottom.setHeight(minBottom.height() + minSize.height()); + labelExtents.setWidth(qMax(size.width(), labelExtents.width())); + bottomCount++; + break; + default: + qWarning()<<"Axis is without alignment !"; + break; + } + } + + qreal totalVerticalAxes = leftCount + rightCount; + qreal leftSqueezeRatio = 1.0; + qreal rightSqueezeRatio = 1.0; + qreal vratio = 0; + + if (totalVerticalAxes > 0) + vratio = (maxAxisPortion * geometry.width()) / totalVerticalAxes; + + if (leftCount > 0) { + int maxWidth = vratio * leftCount; + if (left.width() > maxWidth) { + leftSqueezeRatio = maxWidth / left.width(); + left.setWidth(maxWidth); + } + } + if (rightCount > 0) { + int maxWidth = vratio * rightCount; + if (right.width() > maxWidth) { + rightSqueezeRatio = maxWidth / right.width(); + right.setWidth(maxWidth); + } + } + + qreal totalHorizontalAxes = topCount + bottomCount; + qreal topSqueezeRatio = 1.0; + qreal bottomSqueezeRatio = 1.0; + qreal hratio = 0; + + if (totalHorizontalAxes > 0) + hratio = (maxAxisPortion * geometry.height()) / totalHorizontalAxes; + + if (topCount > 0) { + int maxHeight = hratio * topCount; + if (top.height() > maxHeight) { + topSqueezeRatio = maxHeight / top.height(); + top.setHeight(maxHeight); + } + } + if (bottomCount > 0) { + int maxHeight = hratio * bottomCount; + if (bottom.height() > maxHeight) { + bottomSqueezeRatio = maxHeight / bottom.height(); + bottom.setHeight(maxHeight); + } + } + + qreal minHeight = qMax(minLeft.height(),minRight.height()) + 1; + qreal minWidth = qMax(minTop.width(),minBottom.width()) + 1; + + // Ensure that there is enough space for first and last tick labels. + left.setWidth(qMax(labelExtents.width(), left.width())); + right.setWidth(qMax(labelExtents.width(), right.width())); + top.setHeight(qMax(labelExtents.height(), top.height())); + bottom.setHeight(qMax(labelExtents.height(), bottom.height())); + + QRectF chartRect = geometry.adjusted(qMax(left.width(),minWidth/2), qMax(top.height(), minHeight/2),-qMax(right.width(),minWidth/2),-qMax(bottom.height(),minHeight/2)); + + qreal leftOffset = 0; + qreal rightOffset = 0; + qreal topOffset = 0; + qreal bottomOffset = 0; + + foreach (ChartAxisElement *axis , axes) { + + if (!axis->isVisible()) + continue; + + QSizeF size = axis->effectiveSizeHint(Qt::PreferredSize); + + switch (axis->axis()->alignment()){ + case Qt::AlignLeft:{ + qreal width = size.width(); + if (leftSqueezeRatio < 1.0) + width *= leftSqueezeRatio; + leftOffset+=width; + axis->setGeometry(QRect(chartRect.left()-leftOffset, geometry.top(),width, geometry.bottom()),chartRect); + break; + } + case Qt::AlignRight:{ + qreal width = size.width(); + if (rightSqueezeRatio < 1.0) + width *= rightSqueezeRatio; + axis->setGeometry(QRect(chartRect.right()+rightOffset,geometry.top(),width,geometry.bottom()),chartRect); + rightOffset+=width; + break; + } + case Qt::AlignTop: { + qreal height = size.height(); + if (topSqueezeRatio < 1.0) + height *= topSqueezeRatio; + axis->setGeometry(QRect(geometry.left(), chartRect.top() - topOffset - height, geometry.width(), height), chartRect); + topOffset += height; + break; + } + case Qt::AlignBottom: + qreal height = size.height(); + if (bottomSqueezeRatio < 1.0) + height *= bottomSqueezeRatio; + axis->setGeometry(QRect(geometry.left(), chartRect.bottom() + bottomOffset, geometry.width(), height), chartRect); + bottomOffset += height; + break; + } + } + + return chartRect; +} + +QRectF CartesianChartLayout::calculateAxisMinimum(const QRectF &minimum, const QList<ChartAxisElement *> &axes) const +{ + QSizeF left; + QSizeF right; + QSizeF bottom; + QSizeF top; + + foreach (ChartAxisElement *axis, axes) { + QSizeF size = axis->effectiveSizeHint(Qt::MinimumSize); + + if (!axis->isVisible()) + continue; + + switch (axis->axis()->alignment()) { + case Qt::AlignLeft: + left.setWidth(left.width() + size.width()); + left.setHeight(qMax(left.height() * 2, size.height())); + break; + case Qt::AlignRight: + right.setWidth(right.width() + size.width()); + right.setHeight(qMax(right.height() * 2, size.height())); + break; + case Qt::AlignTop: + top.setWidth(qMax(top.width(), size.width())); + top.setHeight(top.height() + size.height()); + break; + case Qt::AlignBottom: + bottom.setWidth(qMax(bottom.width(), size.width())); + bottom.setHeight(bottom.height() + size.height()); + break; + } + } + return minimum.adjusted(0, 0, left.width() + right.width() + qMax(top.width(), bottom.width()), top.height() + bottom.height() + qMax(left.height(), right.height())); +} + +QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/layout/cartesianchartlayout_p.h b/src/layout/cartesianchartlayout_p.h new file mode 100644 index 00000000..88d540b0 --- /dev/null +++ b/src/layout/cartesianchartlayout_p.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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$ +** +****************************************************************************/ + +// W A R N I N G +// ------------- +// +// This file is not part of the QtCommercial Chart API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#ifndef CARTESIANCHARTLAYOUT_H +#define CARTESIANCHARTLAYOUT_H + +#include "abstractchartlayout_p.h" + +QTCOMMERCIALCHART_BEGIN_NAMESPACE + +class CartesianChartLayout : public AbstractChartLayout +{ +public: + CartesianChartLayout(ChartPresenter *presenter); + virtual ~CartesianChartLayout(); + + // from AbstractChartLayout + QRectF calculateAxisMinimum(const QRectF &minimum, const QList<ChartAxisElement *> &axes) const; + QRectF calculateAxisGeometry(const QRectF &geometry, const QList<ChartAxisElement *> &axes) const; +}; + +QTCOMMERCIALCHART_END_NAMESPACE + +#endif // CARTESIANCHARTLAYOUT_H diff --git a/src/layout/layout.pri b/src/layout/layout.pri new file mode 100644 index 00000000..159eab13 --- /dev/null +++ b/src/layout/layout.pri @@ -0,0 +1,12 @@ +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD + +SOURCES += \ + $$PWD/abstractchartlayout.cpp \ + $$PWD/cartesianchartlayout.cpp \ + $$PWD/polarchartlayout.cpp + +PRIVATE_HEADERS += \ + $$PWD/abstractchartlayout_p.h \ + $$PWD/cartesianchartlayout_p.h \ + $$PWD/polarchartlayout_p.h diff --git a/src/layout/polarchartlayout.cpp b/src/layout/polarchartlayout.cpp new file mode 100644 index 00000000..ad48244a --- /dev/null +++ b/src/layout/polarchartlayout.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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$ +** +****************************************************************************/ + +#include "polarchartlayout_p.h" +#include "chartpresenter_p.h" +#include "polarchartaxis_p.h" +#include <QDebug> +#include <QFontMetrics> + +QTCOMMERCIALCHART_BEGIN_NAMESPACE + +static const qreal golden_ratio = 0.4; + +PolarChartLayout::PolarChartLayout(ChartPresenter *presenter) + : AbstractChartLayout(presenter) +{ +} + +PolarChartLayout::~PolarChartLayout() +{ +} + +QRectF PolarChartLayout::calculateAxisGeometry(const QRectF &geometry, const QList<ChartAxisElement *> &axes) const +{ + // How to handle multiple angular/radial axes? + qreal axisRadius = geometry.height() / 2.0; + if (geometry.width() < geometry.height()) + axisRadius = geometry.width() / 2.0; + + int titleHeight = 0; + foreach (ChartAxisElement *chartAxis, axes) { + if (!chartAxis->isVisible()) + continue; + + PolarChartAxis *polarChartAxis = static_cast<PolarChartAxis *>(chartAxis); + qreal radius = polarChartAxis->preferredAxisRadius(geometry.size()); + if (radius < axisRadius) + axisRadius = radius; + + if (chartAxis->axis()->orientation() == Qt::Horizontal + && chartAxis->axis()->isTitleVisible() + && !chartAxis->axis()->titleText().isEmpty()) { + // If axis has angular title, adjust geometry down by the space title takes + QFontMetrics titleMetrics(chartAxis->axis()->titleFont()); + titleHeight = (titleMetrics.boundingRect(chartAxis->axis()->titleText()).height() / 2) + chartAxis->titlePadding(); + } + } + + QRectF axisRect; + axisRect.setSize(QSizeF(axisRadius * 2.0, axisRadius * 2.0)); + axisRect.moveCenter(geometry.center()); + axisRect.adjust(0, titleHeight, 0, titleHeight); + + foreach (ChartAxisElement *chartAxis, axes) + chartAxis->setGeometry(axisRect, QRectF()); + + return axisRect; +} + +QRectF PolarChartLayout::calculateAxisMinimum(const QRectF &minimum, const QList<ChartAxisElement *> &axes) const +{ + Q_UNUSED(axes); + return minimum; +} + +QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/layout/polarchartlayout_p.h b/src/layout/polarchartlayout_p.h new file mode 100644 index 00000000..e8d5db44 --- /dev/null +++ b/src/layout/polarchartlayout_p.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2013 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$ +** +****************************************************************************/ + +// W A R N I N G +// ------------- +// +// This file is not part of the QtCommercial Chart API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#ifndef POLARCHARTLAYOUT_H +#define POLARCHARTLAYOUT_H + +#include "abstractchartlayout_p.h" + +QTCOMMERCIALCHART_BEGIN_NAMESPACE + +class PolarChartLayout : public AbstractChartLayout +{ +public: + PolarChartLayout(ChartPresenter *presenter); + virtual ~PolarChartLayout(); + + // from AbstractChartLayout + QRectF calculateAxisMinimum(const QRectF &minimum, const QList<ChartAxisElement *> &axes) const; + QRectF calculateAxisGeometry(const QRectF &geometry, const QList<ChartAxisElement *> &axes) const; +}; + +QTCOMMERCIALCHART_END_NAMESPACE + +#endif // POLARCHARTLAYOUT_H |