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

Method updatePlotRectAndAxis

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

Source from the content-addressed store, hash-verified

908}
909
910void PlotViewWidget::updatePlotRectAndAxis(QPainter &painter)
911{
912 const QPointF thicknessDirectionX(fadeBoxThickness, 0);
913 const QPointF thicknessDirectionY(0, fadeBoxThickness);
914 const auto widgetRect = QRectF(this->rect());
915
916 // Update axis based on the widget rect first (we don't know the plotRect yet)
917 this->propertiesAxis[0].line = {widgetRect.bottomLeft() + thicknessDirectionX,
918 widgetRect.bottomRight() - thicknessDirectionX};
919 this->propertiesAxis[1].line = {widgetRect.bottomLeft() - thicknessDirectionY,
920 widgetRect.topLeft() + thicknessDirectionY};
921
922 {
923 const auto axisRangeX = getAxisRange(Axis::X, this->propertiesAxis[0]);
924 const auto axisRangeY = getAxisRange(Axis::Y, this->propertiesAxis[1]);
925
926 const auto ticksX = this->getAxisTicksToShow(Axis::X, axisRangeX);
927 const auto ticksY = this->getAxisTicksToShow(Axis::Y, axisRangeY);
928
929 const auto maxLabelSizeX = this->getMaxLabelDrawSize(painter, Axis::X, ticksX);
930 const auto maxLabelSizeY = this->getMaxLabelDrawSize(painter, Axis::Y, ticksY);
931
932 const auto marginTopLeft =
933 QPointF(maxLabelSizeY.width() + tickLength + tickToTextSpace, marginTop);
934 const auto marginBottomRight =
935 QPointF(marginRight, maxLabelSizeX.height() + tickLength + tickToTextSpace);
936
937 this->plotRect = QRectF(marginTopLeft, widgetRect.bottomRight() - marginBottomRight);
938 }
939
940 {
941 // Now we can use the plotRect for the axis update
942 this->propertiesAxis[0].line = {this->plotRect.bottomLeft() + thicknessDirectionX,
943 this->plotRect.bottomRight() - thicknessDirectionX};
944 this->propertiesAxis[1].line = {this->plotRect.bottomLeft() - thicknessDirectionY,
945 this->plotRect.topLeft() + thicknessDirectionY};
946 }
947
948 DEBUG_PLOT("PlotViewWidget::updatePlotRectAndAxis plotRect "
949 << this->plotRect << " lineX " << this->propertiesAxis[0].line << " lineY "
950 << this->propertiesAxis[1].line);
951}
952
953QPointF PlotViewWidget::convertPlotPosToPixelPos(const QPointF & plotPos,
954 std::optional<double> zoomFactor) const

Callers 1

paintEventMethod · 0.95

Calls 2

getAxisTicksToShowMethod · 0.95
getMaxLabelDrawSizeMethod · 0.95

Tested by

no test coverage detected