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

Method drawPlot

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

Source from the content-addressed store, hash-verified

613}
614
615void PlotViewWidget::drawPlot(QPainter &painter) const
616{
617 if (!this->model)
618 return;
619
620 const auto plotXMin = this->convertPixelPosToPlotPos(this->plotRect.bottomLeft()).x() - 0.5;
621 const auto plotXMax = this->convertPixelPosToPlotPos(this->plotRect.bottomRight()).x() + 0.5;
622
623 DEBUG_PLOT("PlotViewWidget::drawPlot start");
624 for (auto streamIndex : this->showStreamList)
625 {
626 const auto param = this->model->getStreamParameter(streamIndex);
627 for (unsigned int plotIndex = 0; plotIndex < param.getNrPlots(); plotIndex++)
628 {
629 const auto plotParam = param.plotParameters[plotIndex];
630 bool detailedPainting = false;
631 if (plotParam.nrpoints > 0)
632 {
633 const auto firstPoint = model->getPlotPoint(streamIndex, plotIndex, 0);
634 if (firstPoint.width * this->zoomFactor > 1)
635 detailedPainting = true;
636 }
637
638 if (plotParam.type == PlotModel::PlotType::Bar)
639 {
640 auto setPainterColor = [&painter, &detailedPainting](bool isIntra, bool isHighlight) {
641 QColor color = isIntra ? QColor(200, 100, 0, 100) : QColor(0, 0, 200, 100);
642 if (isHighlight)
643 color = color.lighter(150);
644 if (detailedPainting)
645 painter.setPen(color);
646 else
647 painter.setPen(Qt::NoPen);
648 painter.setBrush(color);
649 };
650
651 QVector<QRectF> normalBars;
652 QVector<QRectF> intraBars;
653 for (unsigned int i = 0; i < plotParam.nrpoints; i++)
654 {
655 const auto value = model->getPlotPoint(streamIndex, plotIndex, i);
656
657 if (value.x < plotXMin || value.x > plotXMax)
658 continue;
659
660 const auto halfWidth = value.width / 2;
661 const auto barTopLeft =
662 this->convertPlotPosToPixelPos(QPointF(value.x - halfWidth, value.y));
663 const auto barBottomRight =
664 this->convertPlotPosToPixelPos(QPointF(value.x + halfWidth, 0));
665
666 const bool isHoveredBar =
667 this->currentlyHoveredPointPerStreamAndPlot.contains(streamIndex) &&
668 this->currentlyHoveredPointPerStreamAndPlot[streamIndex].contains(plotIndex) &&
669 this->currentlyHoveredPointPerStreamAndPlot[streamIndex][plotIndex] == i;
670
671 const auto r = QRectF(barTopLeft, barBottomRight);
672 if (isHoveredBar)

Callers 1

paintEventMethod · 0.95

Calls 8

getNrPlotsMethod · 0.80
containsMethod · 0.80
appendMethod · 0.80
getStreamParameterMethod · 0.45
getPlotPointMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected