| 488 | } |
| 489 | |
| 490 | void PlotViewWidget::drawGridLines(QPainter & painter, |
| 491 | const PlotViewWidget::AxisProperties &properties, |
| 492 | const QList<TickValue> & ticks, |
| 493 | Range<double> visibleRange) const |
| 494 | { |
| 495 | auto drawStart = |
| 496 | (properties.axis == Axis::X) ? this->plotRect.topLeft() : this->plotRect.bottomLeft(); |
| 497 | auto drawEnd = |
| 498 | (properties.axis == Axis::X) ? this->plotRect.bottomLeft() : this->plotRect.bottomRight(); |
| 499 | |
| 500 | for (auto tick : ticks) |
| 501 | { |
| 502 | // The ticks list contains more ticks then we have to draw lines for (because of the labels) |
| 503 | if (tick.value < visibleRange.min || tick.value > visibleRange.max) |
| 504 | continue; |
| 505 | |
| 506 | if (properties.axis == Axis::X) |
| 507 | { |
| 508 | drawStart.setX(tick.pixelPosInWidget); |
| 509 | drawEnd.setX(tick.pixelPosInWidget); |
| 510 | } |
| 511 | else |
| 512 | { |
| 513 | drawStart.setY(tick.pixelPosInWidget); |
| 514 | drawEnd.setY(tick.pixelPosInWidget); |
| 515 | } |
| 516 | |
| 517 | painter.setPen(tick.minorTick ? gridLineMinor : gridLineMajor); |
| 518 | painter.drawLine(drawStart, drawEnd); |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | void PlotViewWidget::drawFadeBoxes(QPainter &painter, const QRectF &widgetRect) const |
| 523 | { |