Add UNITS_CHANGED handling to 3D preview controls.

Fixes https://gitlab.com/kicad/code/kicad/issues/14156
This commit is contained in:
Jeff Young 2023-03-04 12:11:16 +00:00
parent d714ff8549
commit 915b352d9b
2 changed files with 26 additions and 0 deletions

View File

@ -142,6 +142,9 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM
this ); this );
} }
aFrame->Connect( UNITS_CHANGED, wxCommandEventHandler( PANEL_PREVIEW_3D_MODEL::onUnitsChanged ),
nullptr, this );
#ifdef __WXOSX__ #ifdef __WXOSX__
// Call layout once to get the proper button sizes after the bitmaps have been set // Call layout once to get the proper button sizes after the bitmaps have been set
Layout(); Layout();
@ -540,6 +543,27 @@ void PANEL_PREVIEW_3D_MODEL::onMouseWheelOffset( wxMouseEvent& event )
} }
void PANEL_PREVIEW_3D_MODEL::onUnitsChanged( wxCommandEvent& aEvent )
{
double xoff_mm = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits,
xoff->GetValue() )
/ pcbIUScale.IU_PER_MM;
double yoff_mm = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits,
yoff->GetValue() )
/ pcbIUScale.IU_PER_MM;
double zoff_mm = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits,
zoff->GetValue() )
/ pcbIUScale.IU_PER_MM;
PCB_BASE_FRAME* frame = static_cast<PCB_BASE_FRAME*>( aEvent.GetClientData() );
m_userUnits = frame->GetUserUnits();
xoff->SetValue( formatOffsetValue( xoff_mm ) );
yoff->SetValue( formatOffsetValue( yoff_mm ) );
zoff->SetValue( formatOffsetValue( zoff_mm ) );
}
void PANEL_PREVIEW_3D_MODEL::UpdateDummyFootprint( bool aReloadRequired ) void PANEL_PREVIEW_3D_MODEL::UpdateDummyFootprint( bool aReloadRequired )
{ {
m_dummyFootprint->Models().clear(); m_dummyFootprint->Models().clear();

View File

@ -141,6 +141,8 @@ private:
void doIncrementRotation( wxSpinEvent& aEvent, double aSign ); void doIncrementRotation( wxSpinEvent& aEvent, double aSign );
void doIncrementOffset( wxSpinEvent& aEvent, double aSign ); void doIncrementOffset( wxSpinEvent& aEvent, double aSign );
void onUnitsChanged( wxCommandEvent& aEvent );
wxString formatScaleValue( double aValue ); wxString formatScaleValue( double aValue );
wxString formatRotationValue( double aValue ); wxString formatRotationValue( double aValue );
wxString formatOffsetValue( double aValue ); wxString formatOffsetValue( double aValue );