| 563 | } |
| 564 | |
| 565 | void PlotViewWidget::drawLimits(QPainter &painter) const |
| 566 | { |
| 567 | const auto plotMin = this->convertPixelPosToPlotPos(this->plotRect.bottomLeft()); |
| 568 | const auto plotMax = this->convertPixelPosToPlotPos(this->plotRect.topRight()); |
| 569 | |
| 570 | DEBUG_PLOT("PlotViewWidget::drawLimits"); |
| 571 | for (auto streamIndex : this->showStreamList) |
| 572 | { |
| 573 | const auto param = this->model->getStreamParameter(streamIndex); |
| 574 | for (const auto &limit : param.limits) |
| 575 | { |
| 576 | // Only draw visible limits |
| 577 | QLineF line; |
| 578 | if (limit.axis == Axis::X) |
| 579 | { |
| 580 | if (limit.value < plotMin.x() || limit.value > plotMax.x()) |
| 581 | continue; |
| 582 | const auto dummyPointForX = this->convertPlotPosToPixelPos(QPointF(limit.value, 0)); |
| 583 | line.setP1(QPointF(dummyPointForX.x(), 0)); |
| 584 | line.setP2(QPointF(dummyPointForX.x(), this->plotRect.height())); |
| 585 | } |
| 586 | else |
| 587 | { |
| 588 | if (limit.value < plotMin.y() || limit.value > plotMax.y()) |
| 589 | continue; |
| 590 | const auto dummyPointForY = this->convertPlotPosToPixelPos(QPointF(0, limit.value)); |
| 591 | line.setP1(QPointF(0, dummyPointForY.y())); |
| 592 | line.setP2(QPointF(this->plotRect.right(), dummyPointForY.y())); |
| 593 | |
| 594 | // Set the QRect where to show the text |
| 595 | QFont displayFont = painter.font(); |
| 596 | QFontMetrics metrics(displayFont); |
| 597 | QSize textSize = metrics.size(0, limit.name); |
| 598 | |
| 599 | QRect textRect; |
| 600 | textRect.setSize(textSize); |
| 601 | textRect.moveTop(dummyPointForY.y()); |
| 602 | textRect.moveRight(this->plotRect.right() - fadeBoxThickness); |
| 603 | painter.setPen(Qt::black); |
| 604 | painter.drawText(textRect, Qt::AlignCenter, limit.name); |
| 605 | } |
| 606 | |
| 607 | QPen limitPen(Qt::black); |
| 608 | limitPen.setWidth(2); |
| 609 | painter.setPen(limitPen); |
| 610 | painter.drawLine(line); |
| 611 | } |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | void PlotViewWidget::drawPlot(QPainter &painter) const |
| 616 | { |
no test coverage detected