Choose centering after zoom

When we zoom after centering, the screen does not display the item at
the appropriate location until you center again.  Choose the zoom first
to set the appropriate scale before translating the viewport
This commit is contained in:
Seth Hillbrand 2021-09-29 16:30:52 -07:00
parent e7ae3a181f
commit 13d913a014
1 changed files with 2 additions and 23 deletions

View File

@ -119,30 +119,8 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString& aReference,
if( crossProbingSettings.center_on_items ) if( crossProbingSettings.center_on_items )
{ {
m_frame->FocusOnLocation( pos );
if( crossProbingSettings.zoom_to_fit ) if( crossProbingSettings.zoom_to_fit )
{ {
//#define COMP_1_TO_1_RATIO // Un-comment for normal KiCad full screen zoom cross-probe
#ifdef COMP_1_TO_1_RATIO
// Pass "false" to only include visible fields of symbol in bbox calculations
EDA_RECT bbox = symbol->GetBoundingBox( false );
wxSize bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
VECTOR2D screenSize = getView()->GetViewport().GetSize();
// NOTE: The 1:1 here is using the default KiCad sizing, which adds a margin of 20%
screenSize.x = std::max( 10.0, screenSize.x );
screenSize.y = std::max( 10.0, screenSize.y );
double ratio = std::max(
fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) );
// Try not to zoom on every cross-probe; it gets very noisy
if( ratio < 0.5 || ratio > 1.0 )
getView()->SetScale( getView()->GetScale() / ratio );
#endif // COMP_1_TO_1_RATIO
#ifndef COMP_1_TO_1_RATIO // Do the scaled zoom
EDA_RECT bbox = symbol->GetBoundingBox(); EDA_RECT bbox = symbol->GetBoundingBox();
wxSize bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize(); wxSize bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
VECTOR2D screenSize = getView()->GetViewport().GetSize(); VECTOR2D screenSize = getView()->GetViewport().GetSize();
@ -247,8 +225,9 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString& aReference,
// Try not to zoom on every cross-probe; it gets very noisy // Try not to zoom on every cross-probe; it gets very noisy
if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom ) if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
getView()->SetScale( getView()->GetScale() / ratio ); getView()->SetScale( getView()->GetScale() / ratio );
#endif // ifndef COMP_1_TO_1_RATIO
} }
m_frame->FocusOnItem( symbol );
} }
} }