| 1 | // Copyright (C) 2016 The Qt Company Ltd. | 
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only | 
| 3 |  | 
| 4 | #include <QtCharts/qcategoryaxis.h> | 
| 5 | #include <QtCharts/qlogvalueaxis.h> | 
| 6 | #include <QtCore/qmath.h> | 
| 7 | #include <QtGui/qtextdocument.h> | 
| 8 | #include <private/chartpresenter_p.h> | 
| 9 | #include <private/linearrowitem_p.h> | 
| 10 | #include <private/polarchartaxisradial_p.h> | 
| 11 |  | 
| 12 | QT_BEGIN_NAMESPACE | 
| 13 |  | 
| 14 | PolarChartAxisRadial::PolarChartAxisRadial(QAbstractAxis *axis, QGraphicsItem *item, | 
| 15 |                                            bool intervalAxis) | 
| 16 |     : PolarChartAxis(axis, item, intervalAxis) | 
| 17 | { | 
| 18 | } | 
| 19 |  | 
| 20 | PolarChartAxisRadial::~PolarChartAxisRadial() | 
| 21 | { | 
| 22 | } | 
| 23 |  | 
| 24 | void PolarChartAxisRadial::updateGeometry() | 
| 25 | { | 
| 26 |     const QList<qreal> &layout = this->layout(); | 
| 27 |     if (layout.isEmpty() && axis()->type() != QAbstractAxis::AxisTypeLogValue) | 
| 28 |         return; | 
| 29 |  | 
| 30 |     createAxisLabels(layout); | 
| 31 |     QStringList labelList = labels(); | 
| 32 |     QPointF center = axisGeometry().center(); | 
| 33 |     QList<QGraphicsItem *> arrowItemList = arrowItems(); | 
| 34 |     QList<QGraphicsItem *> gridItemList = gridItems(); | 
| 35 |     QList<QGraphicsItem *> labelItemList = labelItems(); | 
| 36 |     QList<QGraphicsItem *> shadeItemList = shadeItems(); | 
| 37 |     QList<QGraphicsItem *> minorGridItemList = minorGridItems(); | 
| 38 |     QList<QGraphicsItem *> minorArrowItemList = minorArrowItems(); | 
| 39 |     QGraphicsTextItem* title = titleItem(); | 
| 40 |     qreal radius = axisGeometry().height() / 2.0; | 
| 41 |  | 
| 42 |     QLineF line(center, center + QPointF(0, -radius)); | 
| 43 |     QGraphicsLineItem *axisLine = static_cast<QGraphicsLineItem *>(arrowItemList.at(i: 0)); | 
| 44 |     axisLine->setLine(line); | 
| 45 |  | 
| 46 |     QRectF previousLabelRect; | 
| 47 |     bool firstShade = true; | 
| 48 |     bool nextTickVisible = false; | 
| 49 |     if (layout.size()) | 
| 50 |         nextTickVisible = !(layout.at(i: 0) < 0.0 || layout.at(i: 0) > radius); | 
| 51 |  | 
| 52 |     for (int i = 0; i < layout.size(); ++i) { | 
| 53 |         qreal radialCoordinate = layout.at(i); | 
| 54 |  | 
| 55 |         QGraphicsEllipseItem *gridItem = static_cast<QGraphicsEllipseItem *>(gridItemList.at(i)); | 
| 56 |         QGraphicsLineItem *tickItem = static_cast<QGraphicsLineItem *>(arrowItemList.at(i: i + 1)); | 
| 57 |         QGraphicsTextItem *labelItem = static_cast<QGraphicsTextItem *>(labelItemList.at(i)); | 
| 58 |         QGraphicsPathItem *shadeItem = 0; | 
| 59 |         if (i == 0) | 
| 60 |             shadeItem = static_cast<QGraphicsPathItem *>(shadeItemList.at(i: 0)); | 
| 61 |         else if (i % 2) | 
| 62 |             shadeItem = static_cast<QGraphicsPathItem *>(shadeItemList.at(i: (i / 2) + 1)); | 
| 63 |  | 
| 64 |         // Ignore ticks outside valid range | 
| 65 |         bool currentTickVisible = nextTickVisible; | 
| 66 |         if ((i == layout.size() - 1) | 
| 67 |             || layout.at(i: i + 1) < 0.0 | 
| 68 |             || layout.at(i: i + 1) > radius) { | 
| 69 |             nextTickVisible = false; | 
| 70 |         } else { | 
| 71 |             nextTickVisible = true; | 
| 72 |         } | 
| 73 |  | 
| 74 |         qreal labelCoordinate = radialCoordinate; | 
| 75 |         bool labelVisible = currentTickVisible; | 
| 76 |         qreal labelPad = labelPadding() / 2.0; | 
| 77 |         bool centeredLabel = true; // Only used with interval axes | 
| 78 |         if (intervalAxis()) { | 
| 79 |             qreal farEdge; | 
| 80 |             if (i == (layout.size() - 1)) | 
| 81 |                 farEdge = radius; | 
| 82 |             else | 
| 83 |                 farEdge = qMin(a: radius, b: layout.at(i: i + 1)); | 
| 84 |  | 
| 85 |             // Adjust the labelCoordinate to show it if next tick is visible | 
| 86 |             if (nextTickVisible) | 
| 87 |                 labelCoordinate = qMax(a: qreal(0.0), b: labelCoordinate); | 
| 88 |  | 
| 89 |             if (axis()->type() == QAbstractAxis::AxisTypeCategory) { | 
| 90 |                 QCategoryAxis *categoryAxis = static_cast<QCategoryAxis *>(axis()); | 
| 91 |                 if (categoryAxis->labelsPosition() == QCategoryAxis::AxisLabelsPositionOnValue) | 
| 92 |                     centeredLabel = false; | 
| 93 |             } | 
| 94 |             if (centeredLabel) { | 
| 95 |                 labelCoordinate = (labelCoordinate + farEdge) / 2.0; | 
| 96 |                 if (labelCoordinate > 0.0 && labelCoordinate < radius) | 
| 97 |                     labelVisible =  true; | 
| 98 |                 else | 
| 99 |                     labelVisible = false; | 
| 100 |             } else { | 
| 101 |                 labelVisible = nextTickVisible; | 
| 102 |                 labelCoordinate = farEdge; | 
| 103 |             } | 
| 104 |         } | 
| 105 |  | 
| 106 |         // Radial axis label | 
| 107 |         if (axis()->labelsVisible() && labelVisible) { | 
| 108 |             QRectF boundingRect = ChartPresenter::textBoundingRect(font: axis()->labelsFont(), | 
| 109 |                                                                    text: labelList.at(i), | 
| 110 |                                                                    angle: axis()->labelsAngle()); | 
| 111 |             labelItem->setTextWidth(boundingRect.width()); | 
| 112 |             labelItem->setHtml(labelList.at(i)); | 
| 113 |             QRectF labelRect = labelItem->boundingRect(); | 
| 114 |             QPointF labelCenter = labelRect.center(); | 
| 115 |             labelItem->setTransformOriginPoint(ax: labelCenter.x(), ay: labelCenter.y()); | 
| 116 |             boundingRect.moveCenter(p: labelCenter); | 
| 117 |             QPointF positionDiff(labelRect.topLeft() - boundingRect.topLeft()); | 
| 118 |             QPointF labelPoint = center; | 
| 119 |             if (intervalAxis() && centeredLabel) | 
| 120 |                 labelPoint += QPointF(labelPad, -labelCoordinate - (boundingRect.height() / 2.0)); | 
| 121 |             else | 
| 122 |                 labelPoint += QPointF(labelPad, labelPad - labelCoordinate); | 
| 123 |             labelRect.moveTopLeft(p: labelPoint); | 
| 124 |             labelItem->setPos(labelRect.topLeft() + positionDiff); | 
| 125 |  | 
| 126 |             // Label overlap detection | 
| 127 |             labelRect.setSize(boundingRect.size()); | 
| 128 |             if ((i && previousLabelRect.intersects(r: labelRect)) | 
| 129 |                  || !axisGeometry().contains(r: labelRect)) { | 
| 130 |                 labelVisible = false; | 
| 131 |             } else { | 
| 132 |                 previousLabelRect = labelRect; | 
| 133 |                 labelVisible = true; | 
| 134 |             } | 
| 135 |         } | 
| 136 |  | 
| 137 |         labelItem->setVisible(labelVisible); | 
| 138 |         if (!currentTickVisible) { | 
| 139 |             gridItem->setVisible(false); | 
| 140 |             tickItem->setVisible(false); | 
| 141 |             if (shadeItem) | 
| 142 |                 shadeItem->setVisible(false); | 
| 143 |             continue; | 
| 144 |         } | 
| 145 |  | 
| 146 |         // Radial grid line | 
| 147 |         QRectF gridRect; | 
| 148 |         gridRect.setWidth(radialCoordinate * 2.0); | 
| 149 |         gridRect.setHeight(radialCoordinate * 2.0); | 
| 150 |         gridRect.moveCenter(p: center); | 
| 151 |  | 
| 152 |         gridItem->setRect(gridRect); | 
| 153 |         gridItem->setVisible(true); | 
| 154 |  | 
| 155 |         // Tick | 
| 156 |         QLineF tickLine(-tickWidth(), 0.0, tickWidth(), 0.0); | 
| 157 |         tickLine.translate(adx: center.rx(), ady: gridRect.top()); | 
| 158 |         tickItem->setLine(tickLine); | 
| 159 |         tickItem->setVisible(true); | 
| 160 |  | 
| 161 |         // Shades | 
| 162 |         if (i % 2 || (i == 0 && !nextTickVisible)) { | 
| 163 |             QPainterPath path; | 
| 164 |             if (i == 0) { | 
| 165 |                 // If first tick is also the last, we need to custom fill the inner circle | 
| 166 |                 // or it won't get filled. | 
| 167 |                 QRectF innerCircle(0.0, 0.0, layout.at(i: 0) * 2.0, layout.at(i: 0) * 2.0); | 
| 168 |                 innerCircle.moveCenter(p: center); | 
| 169 |                 path.addEllipse(rect: innerCircle); | 
| 170 |             } else { | 
| 171 |                 QRectF otherGridRect; | 
| 172 |                 if (!nextTickVisible) { // Last visible tick | 
| 173 |                     otherGridRect = axisGeometry(); | 
| 174 |                 } else { | 
| 175 |                     qreal otherGridRectDimension = layout.at(i: i + 1) * 2.0; | 
| 176 |                     otherGridRect.setWidth(otherGridRectDimension); | 
| 177 |                     otherGridRect.setHeight(otherGridRectDimension); | 
| 178 |                     otherGridRect.moveCenter(p: center); | 
| 179 |                 } | 
| 180 |                 path.addEllipse(rect: gridRect); | 
| 181 |                 path.addEllipse(rect: otherGridRect); | 
| 182 |  | 
| 183 |                 // Add additional shading in first visible shade item if there is a partial tick | 
| 184 |                 // to be filled at the center (log & category axes) | 
| 185 |                 if (firstShade) { | 
| 186 |                     QGraphicsPathItem *specialShadeItem = static_cast<QGraphicsPathItem *>(shadeItemList.at(i: 0)); | 
| 187 |                     if (layout.at(i: i - 1) > 0.0) { | 
| 188 |                         QRectF innerCircle(0.0, 0.0, layout.at(i: i - 1) * 2.0, layout.at(i: i - 1) * 2.0); | 
| 189 |                         innerCircle.moveCenter(p: center); | 
| 190 |                         QPainterPath specialPath; | 
| 191 |                         specialPath.addEllipse(rect: innerCircle); | 
| 192 |                         specialShadeItem->setPath(specialPath); | 
| 193 |                         specialShadeItem->setVisible(true); | 
| 194 |                     } else { | 
| 195 |                         specialShadeItem->setVisible(false); | 
| 196 |                     } | 
| 197 |                 } | 
| 198 |             } | 
| 199 |             shadeItem->setPath(path); | 
| 200 |             shadeItem->setVisible(true); | 
| 201 |             firstShade = false; | 
| 202 |         } | 
| 203 |     } | 
| 204 |  | 
| 205 |     updateMinorTickGeometry(); | 
| 206 |  | 
| 207 |     // Title, along the 0 axis | 
| 208 |     QString titleText = axis()->titleText(); | 
| 209 |     if (!titleText.isEmpty() && axis()->isTitleVisible()) { | 
| 210 |         QRectF truncatedRect; | 
| 211 |         title->setHtml(ChartPresenter::truncatedText(font: axis()->titleFont(), text: titleText, angle: qreal(0.0), | 
| 212 |                                                      maxWidth: radius, maxHeight: radius, boundingRect&: truncatedRect)); | 
| 213 |         title->setTextWidth(truncatedRect.width()); | 
| 214 |  | 
| 215 |         QRectF titleBoundingRect = title->boundingRect(); | 
| 216 |         QPointF titleCenter = titleBoundingRect.center(); | 
| 217 |         QPointF arrowCenter = axisLine->boundingRect().center(); | 
| 218 |         QPointF titleCenterDiff = arrowCenter - titleCenter; | 
| 219 |         title->setPos(ax: titleCenterDiff.x() - titlePadding() - (titleBoundingRect.height() / 2.0), ay: titleCenterDiff.y()); | 
| 220 |         title->setTransformOriginPoint(titleCenter); | 
| 221 |         title->setRotation(270.0); | 
| 222 |     } | 
| 223 |  | 
| 224 |     QGraphicsLayoutItem::updateGeometry(); | 
| 225 | } | 
| 226 |  | 
| 227 | Qt::Orientation PolarChartAxisRadial::orientation() const | 
| 228 | { | 
| 229 |     return Qt::Vertical; | 
| 230 | } | 
| 231 |  | 
| 232 | void PolarChartAxisRadial::createItems(int count) | 
| 233 | { | 
| 234 |      if (arrowItems().size() == 0) { | 
| 235 |         // radial axis center line | 
| 236 |         QGraphicsLineItem *arrow = new LineArrowItem(this, presenter()->rootItem()); | 
| 237 |         arrow->setPen(axis()->linePen()); | 
| 238 |         arrowGroup()->addToGroup(item: arrow); | 
| 239 |     } | 
| 240 |  | 
| 241 |     QGraphicsTextItem *title = titleItem(); | 
| 242 |     title->setFont(axis()->titleFont()); | 
| 243 |     title->setDefaultTextColor(axis()->titleBrush().color()); | 
| 244 |     title->setHtml(axis()->titleText()); | 
| 245 |  | 
| 246 |     for (int i = 0; i < count; ++i) { | 
| 247 |         QGraphicsLineItem *arrow = new QGraphicsLineItem(presenter()->rootItem()); | 
| 248 |         QGraphicsEllipseItem *grid = new QGraphicsEllipseItem(presenter()->rootItem()); | 
| 249 |         QGraphicsTextItem *label = new QGraphicsTextItem(presenter()->rootItem()); | 
| 250 |         label->document()->setDocumentMargin(ChartPresenter::textMargin()); | 
| 251 |         arrow->setPen(axis()->linePen()); | 
| 252 |         grid->setPen(axis()->gridLinePen()); | 
| 253 |         label->setFont(axis()->labelsFont()); | 
| 254 |         label->setDefaultTextColor(axis()->labelsBrush().color()); | 
| 255 |         label->setRotation(axis()->labelsAngle()); | 
| 256 |         arrowGroup()->addToGroup(item: arrow); | 
| 257 |         gridGroup()->addToGroup(item: grid); | 
| 258 |         labelGroup()->addToGroup(item: label); | 
| 259 |         if (gridItems().size() == 1 || (((gridItems().size() + 1) % 2) && gridItems().size() > 0)) { | 
| 260 |             QGraphicsPathItem *shade = new QGraphicsPathItem(presenter()->rootItem()); | 
| 261 |             shade->setPen(axis()->shadesPen()); | 
| 262 |             shade->setBrush(axis()->shadesBrush()); | 
| 263 |             shadeGroup()->addToGroup(item: shade); | 
| 264 |         } | 
| 265 |     } | 
| 266 | } | 
| 267 |  | 
| 268 | void PolarChartAxisRadial::handleArrowPenChanged(const QPen &pen) | 
| 269 | { | 
| 270 |     const auto items = arrowItems(); | 
| 271 |     for (QGraphicsItem *item : items) | 
| 272 |         static_cast<QGraphicsLineItem *>(item)->setPen(pen); | 
| 273 | } | 
| 274 |  | 
| 275 | void PolarChartAxisRadial::handleGridPenChanged(const QPen &pen) | 
| 276 | { | 
| 277 |     const auto items = gridItems(); | 
| 278 |     for (QGraphicsItem *item : items) | 
| 279 |         static_cast<QGraphicsEllipseItem *>(item)->setPen(pen); | 
| 280 | } | 
| 281 |  | 
| 282 | void PolarChartAxisRadial::handleMinorArrowPenChanged(const QPen &pen) | 
| 283 | { | 
| 284 |     const auto items = minorArrowItems(); | 
| 285 |     for (QGraphicsItem *item : items) | 
| 286 |         static_cast<QGraphicsLineItem *>(item)->setPen(pen); | 
| 287 | } | 
| 288 |  | 
| 289 | void PolarChartAxisRadial::handleMinorGridPenChanged(const QPen &pen) | 
| 290 | { | 
| 291 |     const auto items = minorGridItems(); | 
| 292 |     for (QGraphicsItem *item : items) | 
| 293 |         static_cast<QGraphicsEllipseItem *>(item)->setPen(pen); | 
| 294 | } | 
| 295 |  | 
| 296 | void PolarChartAxisRadial::handleGridLineColorChanged(const QColor &color) | 
| 297 | { | 
| 298 |     const auto items = gridItems(); | 
| 299 |     for (QGraphicsItem *item : items) { | 
| 300 |         QGraphicsEllipseItem *ellipseItem = static_cast<QGraphicsEllipseItem *>(item); | 
| 301 |         QPen pen = ellipseItem->pen(); | 
| 302 |         pen.setColor(color); | 
| 303 |         ellipseItem->setPen(pen); | 
| 304 |     } | 
| 305 | } | 
| 306 |  | 
| 307 | void PolarChartAxisRadial::handleMinorGridLineColorChanged(const QColor &color) | 
| 308 | { | 
| 309 |     const auto items = minorGridItems(); | 
| 310 |     for (QGraphicsItem *item : items) { | 
| 311 |         QGraphicsEllipseItem *ellipseItem = static_cast<QGraphicsEllipseItem *>(item); | 
| 312 |         QPen pen = ellipseItem->pen(); | 
| 313 |         pen.setColor(color); | 
| 314 |         ellipseItem->setPen(pen); | 
| 315 |     } | 
| 316 | } | 
| 317 |  | 
| 318 | QSizeF PolarChartAxisRadial::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const | 
| 319 | { | 
| 320 |     Q_UNUSED(which); | 
| 321 |     Q_UNUSED(constraint); | 
| 322 |     return QSizeF(-1.0, -1.0); | 
| 323 | } | 
| 324 |  | 
| 325 | qreal PolarChartAxisRadial::preferredAxisRadius(const QSizeF &maxSize) | 
| 326 | { | 
| 327 |     qreal radius = maxSize.height() / 2.0; | 
| 328 |     if (maxSize.width() < maxSize.height()) | 
| 329 |         radius = maxSize.width() / 2.0; | 
| 330 |     return radius; | 
| 331 | } | 
| 332 |  | 
| 333 | void PolarChartAxisRadial::updateMinorTickGeometry() | 
| 334 | { | 
| 335 |     if (!axis()) | 
| 336 |         return; | 
| 337 |  | 
| 338 |     QList<qreal> layout = ChartAxisElement::layout(); | 
| 339 |     int minorTickCount = 0; | 
| 340 |     qreal tickRadius = 0.0; | 
| 341 |     QList<qreal> minorTickRadiuses; | 
| 342 |     switch (axis()->type()) { | 
| 343 |     case QAbstractAxis::AxisTypeValue: { | 
| 344 |         const QValueAxis *valueAxis = qobject_cast<QValueAxis *>(object: axis()); | 
| 345 |  | 
| 346 |         minorTickCount = valueAxis->minorTickCount(); | 
| 347 |  | 
| 348 |         if (valueAxis->tickCount() >= 2) | 
| 349 |             tickRadius = layout.at(i: 1) - layout.at(i: 0); | 
| 350 |  | 
| 351 |         for (int i = 0; i < minorTickCount; ++i) { | 
| 352 |             const qreal ratio = (1.0 / qreal(minorTickCount + 1)) * qreal(i + 1); | 
| 353 |             minorTickRadiuses.append(t: tickRadius * ratio); | 
| 354 |         } | 
| 355 |         break; | 
| 356 |     } | 
| 357 |     case QAbstractAxis::AxisTypeLogValue: { | 
| 358 |         const QLogValueAxis *logValueAxis = qobject_cast<QLogValueAxis *>(object: axis()); | 
| 359 |         const qreal base = logValueAxis->base(); | 
| 360 |         const qreal logBase = qLn(v: base); | 
| 361 |  | 
| 362 |         minorTickCount = logValueAxis->minorTickCount(); | 
| 363 |         if (minorTickCount < 0) | 
| 364 |             minorTickCount = qMax(a: qFloor(v: base) - 2, b: 0); | 
| 365 |  | 
| 366 |         // Two "virtual" ticks are required to make sure that all minor ticks | 
| 367 |         // are displayed properly (even for the partially visible segments of | 
| 368 |         // the chart). | 
| 369 |         if (layout.size() >= 2) { | 
| 370 |             // Calculate tickRadius as a difference between visible ticks | 
| 371 |             // whenever it is possible. Virtual ticks will not be correctly | 
| 372 |             // positioned when the layout is animating. | 
| 373 |             tickRadius = layout.at(i: 1) - layout.at(i: 0); | 
| 374 |             layout.prepend(t: layout.at(i: 0) - tickRadius); | 
| 375 |             layout.append(t: layout.at(i: layout.size() - 1) + tickRadius); | 
| 376 |         } else { | 
| 377 |             const qreal logMax = qLn(v: logValueAxis->max()); | 
| 378 |             const qreal logMin = qLn(v: logValueAxis->min()); | 
| 379 |             const qreal  = qLn(v: qPow(x: base, y: qFloor(v: logMax / logBase) + 1.0)); | 
| 380 |             const qreal  = qLn(v: qPow(x: base, y: qCeil(v: logMin / logBase) - 1.0)); | 
| 381 |             const qreal edge = qMin(a: logMin, b: logMax); | 
| 382 |             const qreal delta = (axisGeometry().width() / 2.0) / qAbs(t: logMax - logMin); | 
| 383 |             const qreal  = edge + (logExtraMaxTick - edge) * delta; | 
| 384 |             const qreal  = edge + (logExtraMinTick - edge) * delta; | 
| 385 |  | 
| 386 |             // Calculate tickRadius using one (if layout.size() == 1) or two | 
| 387 |             // (if layout.size() == 0) "virtual" ticks. In both cases animation | 
| 388 |             // will not work as expected. This should be fixed later. | 
| 389 |             layout.prepend(t: extraMinTick); | 
| 390 |             layout.append(t: extraMaxTick); | 
| 391 |             tickRadius = layout.at(i: 1) - layout.at(i: 0); | 
| 392 |         } | 
| 393 |  | 
| 394 |         const qreal minorTickStepValue = qFabs(v: base - 1.0) / qreal(minorTickCount + 1); | 
| 395 |         for (int i = 0; i < minorTickCount; ++i) { | 
| 396 |             const qreal x = minorTickStepValue * qreal(i + 1) + 1.0; | 
| 397 |             const qreal minorTickSpacing = tickRadius * (qLn(v: x) / logBase); | 
| 398 |             minorTickRadiuses.append(t: minorTickSpacing); | 
| 399 |         } | 
| 400 |         break; | 
| 401 |     } | 
| 402 |     default: | 
| 403 |         // minor ticks are not supported | 
| 404 |         break; | 
| 405 |     } | 
| 406 |  | 
| 407 |     if (minorTickCount < 1 || tickRadius == 0.0 || minorTickRadiuses.size() != minorTickCount) | 
| 408 |         return; | 
| 409 |  | 
| 410 |     const QPointF axisCenter = axisGeometry().center(); | 
| 411 |     const qreal axisRadius = axisGeometry().height() / 2.0; | 
| 412 |  | 
| 413 |     for (int i = 0; i < layout.size() - 1; ++i) { | 
| 414 |         for (int j = 0; j < minorTickCount; ++j) { | 
| 415 |             const int minorItemIndex = i * minorTickCount + j; | 
| 416 |             QGraphicsEllipseItem *minorGridLineItem = | 
| 417 |                     static_cast<QGraphicsEllipseItem *>(minorGridItems().at(i: minorItemIndex)); | 
| 418 |             QGraphicsLineItem *minorArrowLineItem = | 
| 419 |                     static_cast<QGraphicsLineItem *>(minorArrowItems().at(i: minorItemIndex)); | 
| 420 |             if (!minorGridLineItem || !minorArrowLineItem) | 
| 421 |                 continue; | 
| 422 |  | 
| 423 |             const qreal minorTickRadius = layout.at(i) + minorTickRadiuses.value(i: j, defaultValue: 0.0); | 
| 424 |             const qreal minorTickDiameter = minorTickRadius * 2.0; | 
| 425 |  | 
| 426 |             QRectF minorGridLine(0.0, 0.0, minorTickDiameter, minorTickDiameter); | 
| 427 |             minorGridLine.moveCenter(p: axisCenter); | 
| 428 |             minorGridLineItem->setRect(minorGridLine); | 
| 429 |  | 
| 430 |             QLineF minorArrowLine(-tickWidth() + 1.0, 0.0, tickWidth() - 1.0, 0.0); | 
| 431 |             minorArrowLine.translate(adx: axisCenter.x(), ady: minorGridLine.top()); | 
| 432 |             minorArrowLineItem->setLine(minorArrowLine); | 
| 433 |  | 
| 434 |             // check if the minor grid line and the minor axis arrow should be shown | 
| 435 |             bool minorGridLineVisible = (minorTickRadius >= 0.0 && minorTickRadius <= axisRadius); | 
| 436 |             minorGridLineItem->setVisible(minorGridLineVisible); | 
| 437 |             minorArrowLineItem->setVisible(minorGridLineVisible); | 
| 438 |         } | 
| 439 |     } | 
| 440 | } | 
| 441 |  | 
| 442 | void PolarChartAxisRadial::updateMinorTickItems() | 
| 443 | { | 
| 444 |     int currentCount = minorArrowItems().size(); | 
| 445 |     int expectedCount = 0; | 
| 446 |     if (axis()->type() == QAbstractAxis::AxisTypeValue) { | 
| 447 |         QValueAxis *valueAxis = qobject_cast<QValueAxis *>(object: axis()); | 
| 448 |         expectedCount = valueAxis->minorTickCount() * (valueAxis->tickCount() - 1); | 
| 449 |         expectedCount = qMax(a: expectedCount, b: 0); | 
| 450 |     } else if (axis()->type() == QAbstractAxis::AxisTypeLogValue) { | 
| 451 |         QLogValueAxis *logValueAxis = qobject_cast<QLogValueAxis *>(object: axis()); | 
| 452 |  | 
| 453 |         int minorTickCount = logValueAxis->minorTickCount(); | 
| 454 |         if (minorTickCount < 0) | 
| 455 |             minorTickCount = qMax(a: qFloor(v: logValueAxis->base()) - 2, b: 0); | 
| 456 |  | 
| 457 |         expectedCount = minorTickCount * (logValueAxis->tickCount() + 1); | 
| 458 |         expectedCount = qMax(a: expectedCount, b: logValueAxis->minorTickCount()); | 
| 459 |     } else { | 
| 460 |         // minor ticks are not supported | 
| 461 |         return; | 
| 462 |     } | 
| 463 |  | 
| 464 |     int diff = expectedCount - currentCount; | 
| 465 |     if (diff > 0) { | 
| 466 |         for (int i = 0; i < diff; ++i) { | 
| 467 |             QGraphicsEllipseItem *minorGridItem = new QGraphicsEllipseItem(presenter()->rootItem()); | 
| 468 |             minorGridItem->setPen(axis()->minorGridLinePen()); | 
| 469 |             minorGridGroup()->addToGroup(item: minorGridItem); | 
| 470 |  | 
| 471 |             QGraphicsLineItem *minorArrowItem = new QGraphicsLineItem(presenter()->rootItem()); | 
| 472 |             minorArrowItem->setPen(axis()->linePen()); | 
| 473 |             minorArrowGroup()->addToGroup(item: minorArrowItem); | 
| 474 |         } | 
| 475 |     } else { | 
| 476 |         QList<QGraphicsItem *> minorGridItemsList = minorGridItems(); | 
| 477 |         QList<QGraphicsItem *> minorArrowItemsList = minorArrowItems(); | 
| 478 |         for (int i = 0; i > diff; --i) { | 
| 479 |             if (!minorGridItemsList.isEmpty()) | 
| 480 |                 delete minorGridItemsList.takeLast(); | 
| 481 |  | 
| 482 |             if (!minorArrowItemsList.isEmpty()) | 
| 483 |                 delete minorArrowItemsList.takeLast(); | 
| 484 |         } | 
| 485 |     } | 
| 486 | } | 
| 487 |  | 
| 488 | QT_END_NAMESPACE | 
| 489 |  | 
| 490 | #include "moc_polarchartaxisradial_p.cpp" | 
| 491 |  |