MCPcopy Create free account
hub / github.com/IENT/YUView / drawLimits

Method drawLimits

YUViewLib/src/ui/views/PlotViewWidget.cpp:565–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

563}
564
565void 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
615void PlotViewWidget::drawPlot(QPainter &painter) const
616{

Callers 1

paintEventMethod · 0.95

Calls 5

setSizeMethod · 0.80
getStreamParameterMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected