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" ) ); } }