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
This commit is contained in:
jean-pierre charras 2024-03-10 13:04:39 +01:00
parent f341ab9b00
commit 821063e5b1
2 changed files with 22 additions and 2 deletions

View File

@ -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;

View File

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