Honour shift-key for spin buttons in 3D preview.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17541
This commit is contained in:
Jeff Young 2024-05-23 17:00:55 +01:00
parent 98496dfa60
commit f7c7791b6c
2 changed files with 26 additions and 11 deletions

View File

@ -426,10 +426,15 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementScale( wxSpinEvent& event, double aSign
else if( spinCtrl == m_spinZscale ) else if( spinCtrl == m_spinZscale )
textCtrl = zscale; textCtrl = zscale;
double step = SCALE_INCREMENT;
if( wxGetMouseState().ShiftDown( ) )
step = SCALE_INCREMENT_FINE;
double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED, double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED,
textCtrl->GetValue() ); textCtrl->GetValue() );
curr_value += ( SCALE_INCREMENT * aSign ); curr_value += ( step * aSign );
curr_value = std::max( 1/MAX_SCALE, curr_value ); curr_value = std::max( 1/MAX_SCALE, curr_value );
curr_value = std::min( curr_value, MAX_SCALE ); curr_value = std::min( curr_value, MAX_SCALE );
@ -447,10 +452,15 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementRotation( wxSpinEvent& aEvent, double aS
else if( spinCtrl == m_spinZrot ) else if( spinCtrl == m_spinZrot )
textCtrl = zrot; textCtrl = zrot;
double step = ROTATION_INCREMENT;
if( wxGetMouseState().ShiftDown( ) )
step = ROTATION_INCREMENT_FINE;
double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES, double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, EDA_UNITS::DEGREES,
textCtrl->GetValue() ); textCtrl->GetValue() );
curr_value += ( ROTATION_INCREMENT * aSign ); curr_value += ( step * aSign );
curr_value = std::max( -MAX_ROTATION, curr_value ); curr_value = std::max( -MAX_ROTATION, curr_value );
curr_value = std::min( curr_value, MAX_ROTATION ); curr_value = std::min( curr_value, MAX_ROTATION );
@ -470,16 +480,22 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementOffset( wxSpinEvent& event, double aSign
textCtrl = zoff; textCtrl = zoff;
double step_mm = OFFSET_INCREMENT_MM; double step_mm = OFFSET_INCREMENT_MM;
double curr_value_mm =
EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits, if( wxGetMouseState().ShiftDown( ) )
textCtrl->GetValue() ) step_mm = OFFSET_INCREMENT_MM_FINE;
/ pcbIUScale.IU_PER_MM;
if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCHES ) if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCHES )
{ {
step_mm = 25.4*OFFSET_INCREMENT_MIL/1000; step_mm = 25.4*OFFSET_INCREMENT_MIL/1000;
if( wxGetMouseState().ShiftDown( ) )
step_mm = 25.4*OFFSET_INCREMENT_MIL_FINE/1000;;
} }
double curr_value_mm = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits,
textCtrl->GetValue() )
/ pcbIUScale.IU_PER_MM;
curr_value_mm += ( step_mm * aSign ); curr_value_mm += ( step_mm * aSign );
curr_value_mm = std::max( -MAX_OFFSET, curr_value_mm ); curr_value_mm = std::max( -MAX_OFFSET, curr_value_mm );
curr_value_mm = std::min( curr_value_mm, MAX_OFFSET ); curr_value_mm = std::min( curr_value_mm, MAX_OFFSET );
@ -515,10 +531,10 @@ void PANEL_PREVIEW_3D_MODEL::onMouseWheelRot( wxMouseEvent& event )
{ {
wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject(); wxTextCtrl* textCtrl = (wxTextCtrl*) event.GetEventObject();
double step = ROTATION_INCREMENT_WHEEL; double step = ROTATION_INCREMENT;
if( event.ShiftDown( ) ) if( event.ShiftDown( ) )
step = ROTATION_INCREMENT_WHEEL_FINE; step = ROTATION_INCREMENT_FINE;
if( event.GetWheelRotation() >= 0 ) if( event.GetWheelRotation() >= 0 )
step = -step; step = -step;

View File

@ -43,9 +43,8 @@
#define SCALE_INCREMENT_FINE 0.02 #define SCALE_INCREMENT_FINE 0.02
#define SCALE_INCREMENT 0.1 #define SCALE_INCREMENT 0.1
#define ROTATION_INCREMENT 90 // in degrees, for spin button command #define ROTATION_INCREMENT 90 // in degrees
#define ROTATION_INCREMENT_WHEEL 90 // in degrees, for mouse wheel command #define ROTATION_INCREMENT_FINE 1 // in degrees
#define ROTATION_INCREMENT_WHEEL_FINE 1 // in degrees, for mouse wheel command
#define OFFSET_INCREMENT_MM 0.5 #define OFFSET_INCREMENT_MM 0.5
#define OFFSET_INCREMENT_MM_FINE 0.1 #define OFFSET_INCREMENT_MM_FINE 0.1