From 33f1ada4cdce67d75c8424488f12a635342ec2ce Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 18 Sep 2025 12:25:12 +0100 Subject: [PATCH] Make sure marker zoom is correctly set before fetching scale. --- include/marker_base.h | 11 +++++------ pcbnew/drc/drc_test_provider_clearance_base.cpp | 1 + pcbnew/pcb_marker.cpp | 2 +- pcbnew/pcb_marker.h | 11 ++--------- pcbnew/pcb_painter.cpp | 14 +++++++------- 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/include/marker_base.h b/include/marker_base.h index 51fee6290d..b6cf3b21a1 100644 --- a/include/marker_base.h +++ b/include/marker_base.h @@ -67,7 +67,7 @@ public: * The scaling factor to convert polygonal shape coordinates to internal units. */ int MarkerScale() const { return m_scalingFactor; } - void SetMarkerScale( int aScale ) { m_scalingFactor = aScale; } + void SetMarkerScale( int aScale ) const { m_scalingFactor = aScale; } /** * Return the shape polygon in internal units in a #SHAPE_LINE_CHAIN the coordinates @@ -145,11 +145,10 @@ protected: wxString m_comment; ///< User supplied comment. std::shared_ptr m_rcItem; - int m_scalingFactor; ///< Scaling factor to convert corners coordinates - ///< to internal units coordinates. - BOX2I m_shapeBoundingBox; ///< Bounding box of the graphic symbol relative - ///< to the position of the shape in marker shape - ///< units. + mutable int m_scalingFactor; ///< Scaling factor to convert corners coordinates to internal + ///< units. Dependant on current zoom. + BOX2I m_shapeBoundingBox; ///< Bounding box of the graphic symbol relative to the position + ///< of the shape in marker shape units. }; diff --git a/pcbnew/drc/drc_test_provider_clearance_base.cpp b/pcbnew/drc/drc_test_provider_clearance_base.cpp index 0d1f5a8276..b13f9f0fd9 100644 --- a/pcbnew/drc/drc_test_provider_clearance_base.cpp +++ b/pcbnew/drc/drc_test_provider_clearance_base.cpp @@ -59,6 +59,7 @@ DRC_TEST_PROVIDER_CLEARANCE_BASE::GetGraphicsHandler( const std::vector 0 ) { PCB_SHAPE s1, s2; diff --git a/pcbnew/pcb_marker.cpp b/pcbnew/pcb_marker.cpp index f1da7b757b..57b68ae1f3 100644 --- a/pcbnew/pcb_marker.cpp +++ b/pcbnew/pcb_marker.cpp @@ -363,7 +363,7 @@ KIGFX::COLOR4D PCB_MARKER::getColor() const } -void PCB_MARKER::SetZoom( double aZoomFactor ) +void PCB_MARKER::SetZoom( double aZoomFactor ) const { SetMarkerScale( SCALING_FACTOR * aZoomFactor ); } diff --git a/pcbnew/pcb_marker.h b/pcbnew/pcb_marker.h index c172bfdeed..5a92935521 100644 --- a/pcbnew/pcb_marker.h +++ b/pcbnew/pcb_marker.h @@ -22,8 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef PCB_MARKER_H -#define PCB_MARKER_H +#pragma once #include @@ -32,10 +31,6 @@ #include class DRC_ITEM; - -// Coordinates count for the basic shape marker -#define MARKER_SHAPE_POINT_COUNT 9 - class MSG_PANEL_ITEM; @@ -123,7 +118,7 @@ public: BITMAPS GetMenuImage() const override; - void SetZoom( double aZoomFactor ); + void SetZoom( double aZoomFactor ) const; const BOX2I ViewBBox() const override; @@ -167,5 +162,3 @@ protected: std::vector m_shapes1; // Shown on LAYER_DRC_SHAPE1 std::vector m_shapes2; // Shown on LAYER_DRC_SHAPE2 }; - -#endif // PCB_MARKER_H diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 35f2980ab1..220131f534 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -3050,6 +3050,13 @@ void PCB_PAINTER::draw( const PCB_POINT* aPoint, int aLayer ) void PCB_PAINTER::draw( const PCB_MARKER* aMarker, int aLayer ) { + // Don't paint invisible markers. + // It would be nice to do this through layer dependencies but we can't do an "or" there today + if( aMarker->GetBoard() && !aMarker->GetBoard()->IsElementVisible( aMarker->GetColorLayer() ) ) + return; + + aMarker->SetZoom( 1.0 / sqrt( m_gal->GetZoomFactor() ) ); + switch( aLayer ) { case LAYER_MARKER_SHADOWS: @@ -3058,13 +3065,6 @@ void PCB_PAINTER::draw( const PCB_MARKER* aMarker, int aLayer ) { bool isShadow = aLayer == LAYER_MARKER_SHADOWS; - // Don't paint invisible markers. - // It would be nice to do this through layer dependencies but we can't do an "or" there today - if( aMarker->GetBoard() && !aMarker->GetBoard()->IsElementVisible( aMarker->GetColorLayer() ) ) - return; - - const_cast( aMarker )->SetZoom( 1.0 / sqrt( m_gal->GetZoomFactor() ) ); - SHAPE_LINE_CHAIN polygon; aMarker->ShapeToPolygon( polygon );