| 908 | } |
| 909 | |
| 910 | void 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 | |
| 953 | QPointF PlotViewWidget::convertPlotPosToPixelPos(const QPointF & plotPos, |
| 954 | std::optional<double> zoomFactor) const |
no test coverage detected