| 1 | // Copyright (C) 2016 The Qt Company Ltd. | 
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only | 
| 3 |  | 
| 4 | #include <private/polarchartdatetimeaxisradial_p.h> | 
| 5 | #include <private/chartpresenter_p.h> | 
| 6 | #include <private/abstractchartlayout_p.h> | 
| 7 | #include <QtCharts/QDateTimeAxis> | 
| 8 |  | 
| 9 | QT_BEGIN_NAMESPACE | 
| 10 |  | 
| 11 | PolarChartDateTimeAxisRadial::PolarChartDateTimeAxisRadial(QDateTimeAxis *axis, QGraphicsItem *item) | 
| 12 |     : PolarChartAxisRadial(axis, item) | 
| 13 | { | 
| 14 |     QObject::connect(sender: axis, SIGNAL(tickCountChanged(int)), receiver: this, SLOT(handleTickCountChanged(int))); | 
| 15 |     QObject::connect(sender: axis, SIGNAL(formatChanged(QString)), receiver: this, SLOT(handleFormatChanged(QString))); | 
| 16 | } | 
| 17 |  | 
| 18 | PolarChartDateTimeAxisRadial::~PolarChartDateTimeAxisRadial() | 
| 19 | { | 
| 20 | } | 
| 21 |  | 
| 22 | QList<qreal> PolarChartDateTimeAxisRadial::calculateLayout() const | 
| 23 | { | 
| 24 |     int tickCount = static_cast<QDateTimeAxis *>(axis())->tickCount(); | 
| 25 |     Q_ASSERT(tickCount >= 2); | 
| 26 |  | 
| 27 |     QList<qreal> points; | 
| 28 |     points.resize(size: tickCount); | 
| 29 |  | 
| 30 |     const qreal d = (axisGeometry().width() / 2) / qreal(tickCount - 1); | 
| 31 |  | 
| 32 |     for (int i = 0; i < tickCount; ++i) { | 
| 33 |         qreal radialCoordinate = qreal(i) * d; | 
| 34 |         points[i] = radialCoordinate; | 
| 35 |     } | 
| 36 |  | 
| 37 |     return points; | 
| 38 | } | 
| 39 | void PolarChartDateTimeAxisRadial::createAxisLabels(const QList<qreal> &layout) | 
| 40 | { | 
| 41 |     setLabels(createDateTimeLabels(max: min(), min: max(), ticks: layout.size(), format: static_cast<QDateTimeAxis *>(axis())->format())); | 
| 42 | } | 
| 43 |  | 
| 44 | void PolarChartDateTimeAxisRadial::handleTickCountChanged(int tick) | 
| 45 | { | 
| 46 |     Q_UNUSED(tick); | 
| 47 |     QGraphicsLayoutItem::updateGeometry(); | 
| 48 |     if (presenter()) | 
| 49 |         presenter()->layout()->invalidate(); | 
| 50 | } | 
| 51 |  | 
| 52 | void PolarChartDateTimeAxisRadial::handleFormatChanged(const QString &format) | 
| 53 | { | 
| 54 |     Q_UNUSED(format); | 
| 55 |     QGraphicsLayoutItem::updateGeometry(); | 
| 56 |     if (presenter()) | 
| 57 |         presenter()->layout()->invalidate(); | 
| 58 | } | 
| 59 |  | 
| 60 | QT_END_NAMESPACE | 
| 61 |  | 
| 62 | #include "moc_polarchartdatetimeaxisradial_p.cpp" | 
| 63 |  |