From 821063e5b1c503ba19ce769e857253de3d8a1d32 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 10 Mar 2024 13:04:39 +0100 Subject: [PATCH] Pcbnew, pdf plotter: fixes and enhancements. * To select a footprint info, Use the bbox with not text as selectable area * Fix also incorrect position of footprint bbox when plotting with offset Fixes https://gitlab.com/kicad/code/kicad/-/issues/17355 --- include/plotters/plotter.h | 7 +++++++ pcbnew/plot_board_layers.cpp | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/plotters/plotter.h b/include/plotters/plotter.h index 663e1c2117..32785ce98e 100644 --- a/include/plotters/plotter.h +++ b/include/plotters/plotter.h @@ -543,6 +543,12 @@ public: */ virtual void EndBlock( void* aData ) {} + /** + * @return the plot offset in IUs, set by SetViewport() and used + * to plot items. + */ + VECTOR2I GetPlotOffsetUserUnits() {return m_plotOffset; } + protected: /** @@ -631,6 +637,7 @@ protected: double GetDashGapLenIU( int aLineWidth ) const; + protected: // variables used in most of plotters: /// Plot scale - chosen by the user (even implicitly with 'fit in a4') double m_plotScale; diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 636da3f8c6..8c23631d93 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -118,9 +118,22 @@ void PlotInteractiveLayer( BOARD* aBoard, PLOTTER* aPlotter, const PCB_PLOT_PARA _( "Keywords" ), fp->GetKeywords() ) ); #endif - aPlotter->HyperlinkMenu( fp->GetBoundingBox(), properties ); + // Draw items are plotted with a position offset. So we need to move + // our boxes (which are not plotted) by the same offset. + VECTOR2I offset = -aPlotter->GetPlotOffsetUserUnits(); - aPlotter->Bookmark( fp->GetBoundingBox(), fp->GetReference(), _( "Footprints" ) ); + // Use a footprint bbox without texts to create the hyperlink area + BOX2I bbox = fp->GetBoundingBox( false, false ); + bbox.Move( offset ); + aPlotter->HyperlinkMenu( bbox, properties ); + + // Use a footprint bbox with visible texts only to create the bookmark area + // which is the area to zoom on ft selection + // However the bbox need to be inflated for a better look. + bbox = fp->GetBoundingBox( true, false ); + bbox.Move( offset ); + bbox.Inflate( bbox.GetWidth() /2, bbox.GetHeight() /2 ); + aPlotter->Bookmark( bbox, fp->GetReference(), _( "Footprints" ) ); } }