3D preferences bug fixes.

1) Make sure prefs get saved when closing parent frame.
2) Add camera projection mode to settings.

Fixes https://gitlab.com/kicad/code/kicad/issues/8110

Fixes https://gitlab.com/kicad/code/kicad/issues/8626
This commit is contained in:
Jeff Young 2021-06-17 12:21:06 +01:00
parent 0484ca5564
commit 16047b7419
10 changed files with 45 additions and 45 deletions

View File

@ -118,34 +118,20 @@ public:
/**
* Enable or disable camera animation when switching to a pre-defined view.
*
* @param aAnimationEnabled animation enabled state to set.
*/
void AnimationEnabledSet( bool aAnimationEnabled ) { m_animation_enabled = aAnimationEnabled; }
/**
* Return whether camera animation is enabled when switching to a pre-defined view.
*
* @return true if animation is enabled.
*/
bool AnimationEnabledGet() const { return m_animation_enabled; }
void SetAnimationEnabled( bool aEnable ) { m_animation_enabled = aEnable; }
bool GetAnimationEnabled() const { return m_animation_enabled; }
/**
* Set the camera animation moving speed multiplier option.
*
* @param aMovingSpeedMultiplier one of the possible integer options: [1,2,3,4,5].
* @param aMultiplier one of the possible integer options: [1,2,3,4,5].
*/
void MovingSpeedMultiplierSet( int aMovingSpeedMultiplier )
{
m_moving_speed_multiplier = aMovingSpeedMultiplier;
}
void SetMovingSpeedMultiplier( int aMultiplier ) { m_moving_speed_multiplier = aMultiplier; }
int GetMovingSpeedMultiplier() const { return m_moving_speed_multiplier; }
/**
* Return the current camera animation moving speed multiplier option.
*
* @return current moving speed multiplier option, one of [1,2,3,4,5].
*/
int MovingSpeedMultiplierGet() const { return m_moving_speed_multiplier; }
int GetProjectionMode() const { return (int) m_camera.GetProjection(); };
void SetProjectionMode( int aMode ) { m_camera.SetProjection( (PROJECTION_TYPE) aMode ); }
/**
* Notify that the render engine was changed.

View File

@ -36,7 +36,7 @@
enum class PROJECTION_TYPE
{
ORTHO,
ORTHO = 0,
PERSPECTIVE
};
@ -158,6 +158,7 @@ public:
void ToggleProjection();
PROJECTION_TYPE GetProjection() { return m_projectionType; }
void SetProjection( PROJECTION_TYPE aProjection ) { m_projectionType = aProjection; }
/**
* Update the windows size of the camera.

View File

@ -193,6 +193,8 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS()
&m_Camera.moving_speed_multiplier, 3 ) );
m_params.emplace_back( new PARAM<double>( "camera.rotation_increment",
&m_Camera.rotation_increment, 10.0 ) );
m_params.emplace_back( new PARAM<int>( "camera.projection_mode",
&m_Camera.projection_mode, 1 ) );
}

View File

@ -93,6 +93,7 @@ public:
bool animation_enabled;
int moving_speed_multiplier;
double rotation_increment;
int projection_mode;
};
EDA_3D_VIEWER_SETTINGS();

View File

@ -76,10 +76,10 @@ bool PANEL_3D_DISPLAY_OPTIONS::TransferDataToWindow()
}
// Camera Options
m_checkBoxEnableAnimation->SetValue( m_canvas->AnimationEnabledGet() );
m_sliderAnimationSpeed->SetValue( m_canvas->MovingSpeedMultiplierGet() );
m_staticAnimationSpeed->Enable( m_canvas->AnimationEnabledGet() );
m_sliderAnimationSpeed->Enable( m_canvas->AnimationEnabledGet() );
m_checkBoxEnableAnimation->SetValue( m_canvas->GetAnimationEnabled() );
m_sliderAnimationSpeed->SetValue( m_canvas->GetMovingSpeedMultiplier() );
m_staticAnimationSpeed->Enable( m_canvas->GetAnimationEnabled() );
m_sliderAnimationSpeed->Enable( m_canvas->GetAnimationEnabled() );
EDA_3D_CONTROLLER* ctrlTool = m_frame->GetToolManager()->GetTool<EDA_3D_CONTROLLER>();
m_spinCtrlRotationAngle->SetValue( ctrlTool->GetRotationIncrement() );
@ -123,8 +123,8 @@ bool PANEL_3D_DISPLAY_OPTIONS::TransferDataFromWindow()
m_settings.SetFlag( FL_ECO, m_checkBoxECO->GetValue( ) );
// Camera Options
m_canvas->AnimationEnabledSet( m_checkBoxEnableAnimation->GetValue() );
m_canvas->MovingSpeedMultiplierSet( m_sliderAnimationSpeed->GetValue() );
m_canvas->SetAnimationEnabled( m_checkBoxEnableAnimation->GetValue());
m_canvas->SetMovingSpeedMultiplier( m_sliderAnimationSpeed->GetValue());
EDA_3D_CONTROLLER* ctrlTool = m_frame->GetToolManager()->GetTool<EDA_3D_CONTROLLER>();
ctrlTool->SetRotationIncrement( m_spinCtrlRotationAngle->GetValue() );

View File

@ -531,8 +531,9 @@ void EDA_3D_VIEWER::LoadSettings( APP_SETTINGS_BASE *aCfg )
m_boardAdapter.SetMaterialMode( static_cast<MATERIAL_MODE>( cfg->m_Render.material_mode ) );
m_canvas->AnimationEnabledSet( cfg->m_Camera.animation_enabled );
m_canvas->MovingSpeedMultiplierSet( cfg->m_Camera.moving_speed_multiplier );
m_canvas->SetAnimationEnabled( cfg->m_Camera.animation_enabled );
m_canvas->SetMovingSpeedMultiplier( cfg->m_Camera.moving_speed_multiplier );
m_canvas->SetProjectionMode( cfg->m_Camera.projection_mode );
#undef TRANSFER_SETTING
}
@ -630,8 +631,9 @@ void EDA_3D_VIEWER::SaveSettings( APP_SETTINGS_BASE *aCfg )
save_color( m_boardAdapter.m_OpenGlSelectionColor, cfg->m_Render.opengl_selection_color );
cfg->m_Camera.animation_enabled = m_canvas->AnimationEnabledGet();
cfg->m_Camera.moving_speed_multiplier = m_canvas->MovingSpeedMultiplierGet();
cfg->m_Camera.animation_enabled = m_canvas->GetAnimationEnabled();
cfg->m_Camera.moving_speed_multiplier = m_canvas->GetMovingSpeedMultiplier();
cfg->m_Camera.projection_mode = m_canvas->GetProjectionMode();
if( EDA_3D_CONTROLLER* ctrlTool = GetToolManager()->GetTool<EDA_3D_CONTROLLER>() )
cfg->m_Camera.rotation_increment = ctrlTool->GetRotationIncrement();

View File

@ -350,15 +350,8 @@ public:
virtual void SwitchLayer( wxDC* DC, PCB_LAYER_ID layer );
virtual void SetActiveLayer( PCB_LAYER_ID aLayer )
{
GetScreen()->m_Active_Layer = aLayer;
}
virtual PCB_LAYER_ID GetActiveLayer() const
{
return GetScreen()->m_Active_Layer;
}
virtual void SetActiveLayer( PCB_LAYER_ID aLayer ) { GetScreen()->m_Active_Layer = aLayer; }
virtual PCB_LAYER_ID GetActiveLayer() const { return GetScreen()->m_Active_Layer; }
SEVERITY GetSeverity( int aErrorCode ) const override;
@ -395,6 +388,7 @@ public:
virtual bool GetAutoZoom() { return false; }
protected:
bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
/**
* Attempts to load \a aFootprintId from the footprint library table.
@ -407,12 +401,13 @@ protected:
*/
FOOTPRINT* loadFootprint( const LIB_ID& aFootprintId );
virtual void unitsChangeRefresh() override;
protected:
BOARD* m_pcb;
PCB_DISPLAY_OPTIONS m_displayOptions;
PCB_ORIGIN_TRANSFORMS m_originTransforms;
PCBNEW_SETTINGS* m_settings; // No ownership, just a shortcut
virtual void unitsChangeRefresh() override;
};
#endif // PCB_BASE_FRAME_H

View File

@ -632,7 +632,7 @@ bool FOOTPRINT_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
}
}
return true;
return PCB_BASE_EDIT_FRAME::canCloseWindow( aEvent );
}

View File

@ -83,6 +83,19 @@ PCB_BASE_FRAME::~PCB_BASE_FRAME()
}
bool PCB_BASE_FRAME::canCloseWindow( wxCloseEvent& aEvent )
{
// Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
// board.
wxWindow* viewer3D = Get3DViewerFrame();
if( viewer3D )
viewer3D->Close( true );
return true;
}
EDA_3D_VIEWER* PCB_BASE_FRAME::Get3DViewerFrame()
{
return dynamic_cast<EDA_3D_VIEWER*>( FindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( this ) ) );

View File

@ -840,7 +840,7 @@ bool PCB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
if( open_dlg )
open_dlg->Close( true );
return true;
return PCB_BASE_EDIT_FRAME::canCloseWindow( aEvent );
}