diff --git a/3d-viewer/dialogs/panel_3D_colors.cpp b/3d-viewer/dialogs/panel_3D_colors.cpp index 00847fcbe2..54bf291c62 100644 --- a/3d-viewer/dialogs/panel_3D_colors.cpp +++ b/3d-viewer/dialogs/panel_3D_colors.cpp @@ -107,3 +107,21 @@ bool PANEL_3D_COLORS::TransferDataFromWindow() return true; } + + +void PANEL_3D_COLORS::ResetPanel() +{ + COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings(); + + m_backgroundTop->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_BACKGROUND_TOP ), false ); + m_backgroundBottom->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_BACKGROUND_BOTTOM ), false ); + m_silkscreenTop->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_SILKSCREEN_TOP ), false ); + m_silkscreenBottom->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_SILKSCREEN_BOTTOM ), false ); + m_solderMaskTop->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_SOLDERMASK_TOP ), false ); + m_solderMaskBottom->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_SOLDERMASK_BOTTOM ), false ); + m_solderPaste->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_SOLDERPASTE ), false ); + m_surfaceFinish->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_COPPER ), false ); + m_boardBody->SetSwatchColor( colors->GetDefaultColor( LAYER_3D_BOARD ), false ); + + m_boardStackupRB->SetValue( true ); +} \ No newline at end of file diff --git a/3d-viewer/dialogs/panel_3D_colors.h b/3d-viewer/dialogs/panel_3D_colors.h index a26348ca39..782dc601d1 100644 --- a/3d-viewer/dialogs/panel_3D_colors.h +++ b/3d-viewer/dialogs/panel_3D_colors.h @@ -32,11 +32,10 @@ class PANEL_3D_COLORS : public PANEL_3D_COLORS_BASE public: explicit PANEL_3D_COLORS( wxWindow* aParent ); - /// Automatically called when clicking on the OK button bool TransferDataFromWindow() override; - - /// Automatically called after creating the dialog bool TransferDataToWindow() override; + + void ResetPanel() override; }; diff --git a/3d-viewer/dialogs/panel_3D_colors_base.cpp b/3d-viewer/dialogs/panel_3D_colors_base.cpp index 108b850c9f..7a7a1fc6e5 100644 --- a/3d-viewer/dialogs/panel_3D_colors_base.cpp +++ b/3d-viewer/dialogs/panel_3D_colors_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.9.0 Aug 10 2021) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -11,7 +11,7 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_3D_COLORS_BASE::PANEL_3D_COLORS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_3D_COLORS_BASE::PANEL_3D_COLORS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name ) { wxBoxSizer* bSizerMain; bSizerMain = new wxBoxSizer( wxVERTICAL ); diff --git a/3d-viewer/dialogs/panel_3D_colors_base.fbp b/3d-viewer/dialogs/panel_3D_colors_base.fbp index 0ceefbf5e4..6ef159bd87 100644 --- a/3d-viewer/dialogs/panel_3D_colors_base.fbp +++ b/3d-viewer/dialogs/panel_3D_colors_base.fbp @@ -14,7 +14,6 @@ panel_3D_colors_base 1000 none - 1 panel_3D_colors_base @@ -26,7 +25,6 @@ 1 1 UI - 0 0 0 @@ -46,9 +44,8 @@ PANEL_3D_COLORS_BASE -1,-1 - ; ; forward_declare + RESETTABLE_PANEL; widgets/resettable_panel.h; forward_declare - 0 wxTAB_TRAVERSAL diff --git a/3d-viewer/dialogs/panel_3D_colors_base.h b/3d-viewer/dialogs/panel_3D_colors_base.h index 80a646b505..2e1a0424c0 100644 --- a/3d-viewer/dialogs/panel_3D_colors_base.h +++ b/3d-viewer/dialogs/panel_3D_colors_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.9.0 Aug 10 2021) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -12,6 +12,7 @@ #include class COLOR_SWATCH; +#include "widgets/resettable_panel.h" #include #include #include @@ -29,7 +30,7 @@ class COLOR_SWATCH; /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_3D_COLORS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_3D_COLORS_BASE : public wxPanel +class PANEL_3D_COLORS_BASE : public RESETTABLE_PANEL { private: @@ -58,7 +59,6 @@ class PANEL_3D_COLORS_BASE : public wxPanel public: PANEL_3D_COLORS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); - ~PANEL_3D_COLORS_BASE(); }; diff --git a/3d-viewer/dialogs/panel_3D_display_options.cpp b/3d-viewer/dialogs/panel_3D_display_options.cpp index 292d976b36..e85e346333 100644 --- a/3d-viewer/dialogs/panel_3D_display_options.cpp +++ b/3d-viewer/dialogs/panel_3D_display_options.cpp @@ -41,32 +41,38 @@ void PANEL_3D_DISPLAY_OPTIONS::OnCheckEnableAnimation( wxCommandEvent& event ) } +void PANEL_3D_DISPLAY_OPTIONS::loadViewSettings( EDA_3D_VIEWER_SETTINGS* aCfg ) +{ + // Check/uncheck checkboxes + m_checkBoxRealisticMode->SetValue( aCfg->m_Render.realistic ); + m_checkBoxBoardBody->SetValue( aCfg->m_Render.show_board_body ); + m_checkBoxAreas->SetValue( aCfg->m_Render.show_zones ); + m_checkBoxSilkscreen->SetValue( aCfg->m_Render.show_silkscreen ); + m_checkBoxSolderMask->SetValue( aCfg->m_Render.show_soldermask ); + m_checkBoxSolderpaste->SetValue( aCfg->m_Render.show_solderpaste ); + m_checkBoxAdhesive->SetValue( aCfg->m_Render.show_adhesive ); + m_checkBoxComments->SetValue( aCfg->m_Render.show_comments ); + m_checkBoxECO->SetValue( aCfg->m_Render.show_eco ); + m_checkBoxSubtractMaskFromSilk->SetValue( aCfg->m_Render.subtract_mask_from_silk ); + m_checkBoxClipSilkOnViaAnnulus->SetValue( aCfg->m_Render.clip_silk_on_via_annulus ); + m_checkBoxRenderPlatedPadsAsPlated->SetValue( aCfg->m_Render.renderPlatedPadsAsPlated ); + + m_materialProperties->SetSelection( aCfg->m_Render.material_mode ); + + // Camera Options + m_checkBoxEnableAnimation->SetValue( aCfg->m_Camera.animation_enabled ); + m_sliderAnimationSpeed->SetValue( aCfg->m_Camera.moving_speed_multiplier ); + m_staticAnimationSpeed->Enable( aCfg->m_Camera.animation_enabled ); + m_sliderAnimationSpeed->Enable( aCfg->m_Camera.animation_enabled ); + m_spinCtrlRotationAngle->SetValue( aCfg->m_Camera.rotation_increment ); +} + + bool PANEL_3D_DISPLAY_OPTIONS::TransferDataToWindow() { EDA_3D_VIEWER_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); - // Check/uncheck checkboxes - m_checkBoxRealisticMode->SetValue( cfg->m_Render.realistic ); - m_checkBoxBoardBody->SetValue( cfg->m_Render.show_board_body ); - m_checkBoxAreas->SetValue( cfg->m_Render.show_zones ); - m_checkBoxSilkscreen->SetValue( cfg->m_Render.show_silkscreen ); - m_checkBoxSolderMask->SetValue( cfg->m_Render.show_soldermask ); - m_checkBoxSolderpaste->SetValue( cfg->m_Render.show_solderpaste ); - m_checkBoxAdhesive->SetValue( cfg->m_Render.show_adhesive ); - m_checkBoxComments->SetValue( cfg->m_Render.show_comments ); - m_checkBoxECO->SetValue( cfg->m_Render.show_eco ); - m_checkBoxSubtractMaskFromSilk->SetValue( cfg->m_Render.subtract_mask_from_silk ); - m_checkBoxClipSilkOnViaAnnulus->SetValue( cfg->m_Render.clip_silk_on_via_annulus ); - m_checkBoxRenderPlatedPadsAsPlated->SetValue( cfg->m_Render.renderPlatedPadsAsPlated ); - - m_materialProperties->SetSelection( cfg->m_Render.material_mode ); - - // Camera Options - m_checkBoxEnableAnimation->SetValue( cfg->m_Camera.animation_enabled ); - m_sliderAnimationSpeed->SetValue( cfg->m_Camera.moving_speed_multiplier ); - m_staticAnimationSpeed->Enable( cfg->m_Camera.animation_enabled ); - m_sliderAnimationSpeed->Enable( cfg->m_Camera.animation_enabled ); - m_spinCtrlRotationAngle->SetValue( cfg->m_Camera.rotation_increment ); + loadViewSettings( cfg ); return true; } @@ -103,3 +109,12 @@ bool PANEL_3D_DISPLAY_OPTIONS::TransferDataFromWindow() return true; } + + +void PANEL_3D_DISPLAY_OPTIONS::ResetPanel() +{ + EDA_3D_VIEWER_SETTINGS cfg; + cfg.Load(); // Loading without a file will init to defaults + + loadViewSettings( &cfg ); +} \ No newline at end of file diff --git a/3d-viewer/dialogs/panel_3D_display_options.h b/3d-viewer/dialogs/panel_3D_display_options.h index c1e8bb910c..32992f1bd8 100644 --- a/3d-viewer/dialogs/panel_3D_display_options.h +++ b/3d-viewer/dialogs/panel_3D_display_options.h @@ -36,11 +36,13 @@ public: void OnCheckEnableAnimation( wxCommandEvent& WXUNUSED( event ) ) override; - /// Automatically called when clicking on the OK button bool TransferDataFromWindow() override; - - /// Automatically called after creating the dialog bool TransferDataToWindow() override; + + void ResetPanel() override; + +private: + void loadViewSettings( EDA_3D_VIEWER_SETTINGS* aCfg ); }; diff --git a/3d-viewer/dialogs/panel_3D_display_options_base.cpp b/3d-viewer/dialogs/panel_3D_display_options_base.cpp index 4376252241..d21c5d6298 100644 --- a/3d-viewer/dialogs/panel_3D_display_options_base.cpp +++ b/3d-viewer/dialogs/panel_3D_display_options_base.cpp @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_3D_DISPLAY_OPTIONS_BASE::PANEL_3D_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_3D_DISPLAY_OPTIONS_BASE::PANEL_3D_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name ) { wxBoxSizer* bSizerMain; bSizerMain = new wxBoxSizer( wxHORIZONTAL ); diff --git a/3d-viewer/dialogs/panel_3D_display_options_base.fbp b/3d-viewer/dialogs/panel_3D_display_options_base.fbp index d05ba75cd5..7d9aa3185b 100644 --- a/3d-viewer/dialogs/panel_3D_display_options_base.fbp +++ b/3d-viewer/dialogs/panel_3D_display_options_base.fbp @@ -44,7 +44,7 @@ PANEL_3D_DISPLAY_OPTIONS_BASE -1,-1 - ; ; forward_declare + RESETTABLE_PANEL; widgets/resettable_panel.h; forward_declare diff --git a/3d-viewer/dialogs/panel_3D_display_options_base.h b/3d-viewer/dialogs/panel_3D_display_options_base.h index 9a020d3626..8ea61f6616 100644 --- a/3d-viewer/dialogs/panel_3D_display_options_base.h +++ b/3d-viewer/dialogs/panel_3D_display_options_base.h @@ -10,6 +10,7 @@ #include #include #include +#include "widgets/resettable_panel.h" #include #include #include @@ -31,7 +32,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_3D_DISPLAY_OPTIONS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_3D_DISPLAY_OPTIONS_BASE : public wxPanel +class PANEL_3D_DISPLAY_OPTIONS_BASE : public RESETTABLE_PANEL { private: diff --git a/3d-viewer/dialogs/panel_3D_opengl_options.cpp b/3d-viewer/dialogs/panel_3D_opengl_options.cpp index c122d42bed..7ed82885f3 100644 --- a/3d-viewer/dialogs/panel_3D_opengl_options.cpp +++ b/3d-viewer/dialogs/panel_3D_opengl_options.cpp @@ -37,21 +37,27 @@ PANEL_3D_OPENGL_OPTIONS::PANEL_3D_OPENGL_OPTIONS( wxWindow* aParent ) : } +void PANEL_3D_OPENGL_OPTIONS::loadSettings( EDA_3D_VIEWER_SETTINGS* aCfg ) +{ + m_checkBoxCuThickness->SetValue( aCfg->m_Render.opengl_copper_thickness ); + m_checkBoxBoundingBoxes->SetValue( aCfg->m_Render.opengl_show_model_bbox ); + m_checkBoxHighlightOnRollOver->SetValue( aCfg->m_Render.opengl_highlight_on_rollover ); + + m_choiceAntiAliasing->SetSelection( aCfg->m_Render.opengl_AA_mode ); + m_selectionColorSwatch->SetSwatchColor( aCfg->m_Render.opengl_selection_color, false ); + + m_checkBoxDisableAAMove->SetValue( aCfg->m_Render.opengl_AA_disableOnMove ); + m_checkBoxDisableMoveThickness->SetValue( aCfg->m_Render.opengl_thickness_disableOnMove ); + m_checkBoxDisableMoveVias->SetValue( aCfg->m_Render.opengl_vias_disableOnMove ); + m_checkBoxDisableMoveHoles->SetValue( aCfg->m_Render.opengl_holes_disableOnMove ); +} + + bool PANEL_3D_OPENGL_OPTIONS::TransferDataToWindow() { EDA_3D_VIEWER_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); - m_checkBoxCuThickness->SetValue( cfg->m_Render.opengl_copper_thickness ); - m_checkBoxBoundingBoxes->SetValue( cfg->m_Render.opengl_show_model_bbox ); - m_checkBoxHighlightOnRollOver->SetValue( cfg->m_Render.opengl_highlight_on_rollover ); - - m_choiceAntiAliasing->SetSelection( cfg->m_Render.opengl_AA_mode ); - m_selectionColorSwatch->SetSwatchColor( cfg->m_Render.opengl_selection_color, false ); - - m_checkBoxDisableAAMove->SetValue( cfg->m_Render.opengl_AA_disableOnMove ); - m_checkBoxDisableMoveThickness->SetValue( cfg->m_Render.opengl_thickness_disableOnMove ); - m_checkBoxDisableMoveVias->SetValue( cfg->m_Render.opengl_vias_disableOnMove ); - m_checkBoxDisableMoveHoles->SetValue( cfg->m_Render.opengl_holes_disableOnMove ); + loadSettings( cfg ); return true; } @@ -75,3 +81,12 @@ bool PANEL_3D_OPENGL_OPTIONS::TransferDataFromWindow() return true; } + + +void PANEL_3D_OPENGL_OPTIONS::ResetPanel() +{ + EDA_3D_VIEWER_SETTINGS cfg; + cfg.Load(); // Loading without a file will init to defaults + + loadSettings( &cfg ); +} \ No newline at end of file diff --git a/3d-viewer/dialogs/panel_3D_opengl_options.h b/3d-viewer/dialogs/panel_3D_opengl_options.h index 8ed3aa7822..ab853cdc37 100644 --- a/3d-viewer/dialogs/panel_3D_opengl_options.h +++ b/3d-viewer/dialogs/panel_3D_opengl_options.h @@ -33,11 +33,13 @@ class PANEL_3D_OPENGL_OPTIONS : public PANEL_3D_OPENGL_OPTIONS_BASE public: explicit PANEL_3D_OPENGL_OPTIONS( wxWindow* aParent ); - /// Automatically called when clicking on the OK button bool TransferDataFromWindow() override; - - /// Automatically called after creating the dialog bool TransferDataToWindow() override; + + void ResetPanel() override; + +private: + void loadSettings( EDA_3D_VIEWER_SETTINGS* aCfg ); }; diff --git a/3d-viewer/dialogs/panel_3D_opengl_options_base.cpp b/3d-viewer/dialogs/panel_3D_opengl_options_base.cpp index 13580cdcf7..44d32b053a 100644 --- a/3d-viewer/dialogs/panel_3D_opengl_options_base.cpp +++ b/3d-viewer/dialogs/panel_3D_opengl_options_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.9.0 Aug 10 2021) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -11,7 +11,7 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_3D_OPENGL_OPTIONS_BASE::PANEL_3D_OPENGL_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_3D_OPENGL_OPTIONS_BASE::PANEL_3D_OPENGL_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name ) { wxBoxSizer* bSizerMain; bSizerMain = new wxBoxSizer( wxVERTICAL ); diff --git a/3d-viewer/dialogs/panel_3D_opengl_options_base.fbp b/3d-viewer/dialogs/panel_3D_opengl_options_base.fbp index a220dcbd72..662341872c 100644 --- a/3d-viewer/dialogs/panel_3D_opengl_options_base.fbp +++ b/3d-viewer/dialogs/panel_3D_opengl_options_base.fbp @@ -14,7 +14,6 @@ panel_3D_opengl_options_base 1000 none - 1 panel_3D_opengl_optionS_base @@ -26,7 +25,6 @@ 1 1 UI - 0 0 0 @@ -46,9 +44,8 @@ PANEL_3D_OPENGL_OPTIONS_BASE -1,-1 - ; ; forward_declare + RESETTABLE_PANEL; widgets/resettable_panel.h; forward_declare - 0 wxTAB_TRAVERSAL diff --git a/3d-viewer/dialogs/panel_3D_opengl_options_base.h b/3d-viewer/dialogs/panel_3D_opengl_options_base.h index 366ee2b69c..bc67b49af7 100644 --- a/3d-viewer/dialogs/panel_3D_opengl_options_base.h +++ b/3d-viewer/dialogs/panel_3D_opengl_options_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.9.0 Aug 10 2021) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -12,6 +12,7 @@ #include class COLOR_SWATCH; +#include "widgets/resettable_panel.h" #include #include #include @@ -30,7 +31,7 @@ class COLOR_SWATCH; /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_3D_OPENGL_OPTIONS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_3D_OPENGL_OPTIONS_BASE : public wxPanel +class PANEL_3D_OPENGL_OPTIONS_BASE : public RESETTABLE_PANEL { private: @@ -50,7 +51,6 @@ class PANEL_3D_OPENGL_OPTIONS_BASE : public wxPanel public: PANEL_3D_OPENGL_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); - ~PANEL_3D_OPENGL_OPTIONS_BASE(); }; diff --git a/3d-viewer/dialogs/panel_3D_raytracing_options.cpp b/3d-viewer/dialogs/panel_3D_raytracing_options.cpp index 44a60e4ef0..8dc4c683b1 100644 --- a/3d-viewer/dialogs/panel_3D_raytracing_options.cpp +++ b/3d-viewer/dialogs/panel_3D_raytracing_options.cpp @@ -34,39 +34,29 @@ PANEL_3D_RAYTRACING_OPTIONS::PANEL_3D_RAYTRACING_OPTIONS( wxWindow* aParent ) : } -void PANEL_3D_RAYTRACING_OPTIONS::ResetPanel() +void PANEL_3D_RAYTRACING_OPTIONS::loadSettings( EDA_3D_VIEWER_SETTINGS* aCfg ) { - SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); - EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings(); + m_cbRaytracing_renderShadows->SetValue( aCfg->m_Render.raytrace_shadows ); + m_cbRaytracing_addFloor->SetValue( aCfg->m_Render.raytrace_backfloor ); + m_cbRaytracing_showRefractions->SetValue( aCfg->m_Render.raytrace_refractions ); + m_cbRaytracing_showReflections->SetValue( aCfg->m_Render.raytrace_reflections ); + m_cbRaytracing_postProcessing->SetValue( aCfg->m_Render.raytrace_post_processing ); + m_cbRaytracing_antiAliasing->SetValue( aCfg->m_Render.raytrace_anti_aliasing ); + m_cbRaytracing_proceduralTextures->SetValue( aCfg->m_Render.raytrace_procedural_textures ); - cfg->m_Render.raytrace_lightColorCamera = COLOR4D( 0.2, 0.2, 0.2, 1.0 ); - cfg->m_Render.raytrace_lightColorTop = COLOR4D( 0.247, 0.247, 0.247, 1.0 ); - cfg->m_Render.raytrace_lightColorBottom = COLOR4D( 0.247, 0.247, 0.247, 1.0 ); + m_numSamples_Shadows->SetValue( aCfg->m_Render.raytrace_nrsamples_shadows ); + m_numSamples_Reflections->SetValue( aCfg->m_Render.raytrace_nrsamples_reflections ); + m_numSamples_Refractions->SetValue( aCfg->m_Render.raytrace_nrsamples_refractions ); - const std::vector default_elevation = - { - 67, 67, 67, 67, -67, -67, -67, -67, - }; + m_spreadFactor_Shadows->SetValue( StringFromValue( EDA_UNITS::PERCENT, + aCfg->m_Render.raytrace_spread_shadows * 100.0f ) ); + m_spreadFactor_Reflections->SetValue( StringFromValue( EDA_UNITS::PERCENT, + aCfg->m_Render.raytrace_spread_reflections * 100.0f ) ); + m_spreadFactor_Refractions->SetValue( StringFromValue( EDA_UNITS::PERCENT, + aCfg->m_Render.raytrace_spread_refractions * 100.0f ) ); - const std::vector default_azimuth = - { - 45, 135, 225, 315, 45, 135, 225, 315, - }; - - for( size_t i = 0; i < 8; ++i ) - { - cfg->m_Render.raytrace_lightElevation[i] = default_elevation[i]; - cfg->m_Render.raytrace_lightAzimuth[i] = default_azimuth[i]; - } - - TransferColorDataToWindow(); -} - - -void PANEL_3D_RAYTRACING_OPTIONS::TransferColorDataToWindow() -{ - SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); - EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings(); + m_recursiveLevel_Reflections->SetValue( aCfg->m_Render.raytrace_recursivelevel_reflections ); + m_recursiveLevel_Refractions->SetValue( aCfg->m_Render.raytrace_recursivelevel_refractions ); auto transfer_color = []( COLOR4D aColor, COLOR_SWATCH *aTarget ) @@ -82,37 +72,37 @@ void PANEL_3D_RAYTRACING_OPTIONS::TransferColorDataToWindow() aCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, aValue ) ); }; - transfer_color( cfg->m_Render.raytrace_lightColorCamera, m_colourPickerCameraLight ); - transfer_color( cfg->m_Render.raytrace_lightColorTop, m_colourPickerTopLight ); - transfer_color( cfg->m_Render.raytrace_lightColorBottom, m_colourPickerBottomLight ); + transfer_color( aCfg->m_Render.raytrace_lightColorCamera, m_colourPickerCameraLight ); + transfer_color( aCfg->m_Render.raytrace_lightColorTop, m_colourPickerTopLight ); + transfer_color( aCfg->m_Render.raytrace_lightColorBottom, m_colourPickerBottomLight ); - transfer_color( cfg->m_Render.raytrace_lightColor[0], m_colourPickerLight1 ); - transfer_color( cfg->m_Render.raytrace_lightColor[1], m_colourPickerLight2 ); - transfer_color( cfg->m_Render.raytrace_lightColor[2], m_colourPickerLight3 ); - transfer_color( cfg->m_Render.raytrace_lightColor[3], m_colourPickerLight4 ); + transfer_color( aCfg->m_Render.raytrace_lightColor[0], m_colourPickerLight1 ); + transfer_color( aCfg->m_Render.raytrace_lightColor[1], m_colourPickerLight2 ); + transfer_color( aCfg->m_Render.raytrace_lightColor[2], m_colourPickerLight3 ); + transfer_color( aCfg->m_Render.raytrace_lightColor[3], m_colourPickerLight4 ); - transfer_color( cfg->m_Render.raytrace_lightColor[4], m_colourPickerLight5 ); - transfer_color( cfg->m_Render.raytrace_lightColor[5], m_colourPickerLight6 ); - transfer_color( cfg->m_Render.raytrace_lightColor[6], m_colourPickerLight7 ); - transfer_color( cfg->m_Render.raytrace_lightColor[7], m_colourPickerLight8 ); + transfer_color( aCfg->m_Render.raytrace_lightColor[4], m_colourPickerLight5 ); + transfer_color( aCfg->m_Render.raytrace_lightColor[5], m_colourPickerLight6 ); + transfer_color( aCfg->m_Render.raytrace_lightColor[6], m_colourPickerLight7 ); + transfer_color( aCfg->m_Render.raytrace_lightColor[7], m_colourPickerLight8 ); - transfer_value( m_lightElevation1, cfg->m_Render.raytrace_lightElevation[0] ); - transfer_value( m_lightElevation2, cfg->m_Render.raytrace_lightElevation[1] ); - transfer_value( m_lightElevation3, cfg->m_Render.raytrace_lightElevation[2] ); - transfer_value( m_lightElevation4, cfg->m_Render.raytrace_lightElevation[3] ); - transfer_value( m_lightElevation5, cfg->m_Render.raytrace_lightElevation[4] ); - transfer_value( m_lightElevation6, cfg->m_Render.raytrace_lightElevation[5] ); - transfer_value( m_lightElevation7, cfg->m_Render.raytrace_lightElevation[6] ); - transfer_value( m_lightElevation8, cfg->m_Render.raytrace_lightElevation[7] ); + transfer_value( m_lightElevation1, aCfg->m_Render.raytrace_lightElevation[0] ); + transfer_value( m_lightElevation2, aCfg->m_Render.raytrace_lightElevation[1] ); + transfer_value( m_lightElevation3, aCfg->m_Render.raytrace_lightElevation[2] ); + transfer_value( m_lightElevation4, aCfg->m_Render.raytrace_lightElevation[3] ); + transfer_value( m_lightElevation5, aCfg->m_Render.raytrace_lightElevation[4] ); + transfer_value( m_lightElevation6, aCfg->m_Render.raytrace_lightElevation[5] ); + transfer_value( m_lightElevation7, aCfg->m_Render.raytrace_lightElevation[6] ); + transfer_value( m_lightElevation8, aCfg->m_Render.raytrace_lightElevation[7] ); - transfer_value( m_lightAzimuth1, cfg->m_Render.raytrace_lightAzimuth[0] ); - transfer_value( m_lightAzimuth2, cfg->m_Render.raytrace_lightAzimuth[1] ); - transfer_value( m_lightAzimuth3, cfg->m_Render.raytrace_lightAzimuth[2] ); - transfer_value( m_lightAzimuth4, cfg->m_Render.raytrace_lightAzimuth[3] ); - transfer_value( m_lightAzimuth5, cfg->m_Render.raytrace_lightAzimuth[4] ); - transfer_value( m_lightAzimuth6, cfg->m_Render.raytrace_lightAzimuth[5] ); - transfer_value( m_lightAzimuth7, cfg->m_Render.raytrace_lightAzimuth[6] ); - transfer_value( m_lightAzimuth8, cfg->m_Render.raytrace_lightAzimuth[7] ); + transfer_value( m_lightAzimuth1, aCfg->m_Render.raytrace_lightAzimuth[0] ); + transfer_value( m_lightAzimuth2, aCfg->m_Render.raytrace_lightAzimuth[1] ); + transfer_value( m_lightAzimuth3, aCfg->m_Render.raytrace_lightAzimuth[2] ); + transfer_value( m_lightAzimuth4, aCfg->m_Render.raytrace_lightAzimuth[3] ); + transfer_value( m_lightAzimuth5, aCfg->m_Render.raytrace_lightAzimuth[4] ); + transfer_value( m_lightAzimuth6, aCfg->m_Render.raytrace_lightAzimuth[5] ); + transfer_value( m_lightAzimuth7, aCfg->m_Render.raytrace_lightAzimuth[6] ); + transfer_value( m_lightAzimuth8, aCfg->m_Render.raytrace_lightAzimuth[7] ); } @@ -121,29 +111,7 @@ bool PANEL_3D_RAYTRACING_OPTIONS::TransferDataToWindow() SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings(); - m_cbRaytracing_renderShadows->SetValue( cfg->m_Render.raytrace_shadows ); - m_cbRaytracing_addFloor->SetValue( cfg->m_Render.raytrace_backfloor ); - m_cbRaytracing_showRefractions->SetValue( cfg->m_Render.raytrace_refractions ); - m_cbRaytracing_showReflections->SetValue( cfg->m_Render.raytrace_reflections ); - m_cbRaytracing_postProcessing->SetValue( cfg->m_Render.raytrace_post_processing ); - m_cbRaytracing_antiAliasing->SetValue( cfg->m_Render.raytrace_anti_aliasing ); - m_cbRaytracing_proceduralTextures->SetValue( cfg->m_Render.raytrace_procedural_textures ); - - m_numSamples_Shadows->SetValue( cfg->m_Render.raytrace_nrsamples_shadows ); - m_numSamples_Reflections->SetValue( cfg->m_Render.raytrace_nrsamples_reflections ); - m_numSamples_Refractions->SetValue( cfg->m_Render.raytrace_nrsamples_refractions ); - - m_spreadFactor_Shadows->SetValue( StringFromValue( EDA_UNITS::PERCENT, - cfg->m_Render.raytrace_spread_shadows * 100.0f ) ); - m_spreadFactor_Reflections->SetValue( StringFromValue( EDA_UNITS::PERCENT, - cfg->m_Render.raytrace_spread_reflections * 100.0f ) ); - m_spreadFactor_Refractions->SetValue( StringFromValue( EDA_UNITS::PERCENT, - cfg->m_Render.raytrace_spread_refractions * 100.0f ) ); - - m_recursiveLevel_Reflections->SetValue( cfg->m_Render.raytrace_recursivelevel_reflections ); - m_recursiveLevel_Refractions->SetValue( cfg->m_Render.raytrace_recursivelevel_refractions ); - - TransferColorDataToWindow(); + loadSettings( cfg ); return true; } @@ -215,3 +183,12 @@ bool PANEL_3D_RAYTRACING_OPTIONS::TransferDataFromWindow() return true; } + + +void PANEL_3D_RAYTRACING_OPTIONS::ResetPanel() +{ + EDA_3D_VIEWER_SETTINGS cfg; + cfg.Load(); // Loading without a file will init to defaults + + loadSettings( &cfg ); +} \ No newline at end of file diff --git a/3d-viewer/dialogs/panel_3D_raytracing_options.h b/3d-viewer/dialogs/panel_3D_raytracing_options.h index 48998760c3..fcb22f43df 100644 --- a/3d-viewer/dialogs/panel_3D_raytracing_options.h +++ b/3d-viewer/dialogs/panel_3D_raytracing_options.h @@ -33,15 +33,13 @@ class PANEL_3D_RAYTRACING_OPTIONS : public PANEL_3D_RAYTRACING_OPTIONS_BASE public: explicit PANEL_3D_RAYTRACING_OPTIONS( wxWindow* aParent ); - void ResetPanel() override; - - /// Automatically called when clicking on the OK button bool TransferDataFromWindow() override; - - /// Automatically called after creating the dialog bool TransferDataToWindow() override; - void TransferColorDataToWindow(); + void ResetPanel() override; + +private: + void loadSettings( EDA_3D_VIEWER_SETTINGS* aCfg ); }; diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 752fcbd3b0..5a60f92b56 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -1024,7 +1024,7 @@ void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event ) expand.push_back( book->GetPageCount() ); book->AddPage( new wxPanel( book ), _( "Symbol Editor" ) ); - book->AddSubPage( CREATE_PANEL( PANEL_SYM_DISPLAY_OPTIONS ), _( "Display Options" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_SYM_DISP_OPTIONS ), _( "Display Options" ) ); book->AddSubPage( CREATE_PANEL( PANEL_SYM_EDIT_OPTIONS ), _( "Editing Options" ) ); book->AddSubPage( CREATE_PANEL( PANEL_SYM_COLORS ), _( "Colors" ) ); @@ -1032,7 +1032,7 @@ void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event ) expand.push_back( book->GetPageCount() ); book->AddPage( new wxPanel( book ), _( "Schematic Editor" ) ); - book->AddSubPage( CREATE_PANEL( PANEL_SCH_DISPLAY_OPTIONS ), _( "Display Options" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_SCH_DISP_OPTIONS ), _( "Display Options" ) ); book->AddSubPage( CREATE_PANEL( PANEL_SCH_EDIT_OPTIONS ), _( "Editing Options" ) ); book->AddSubPage( CREATE_PANEL( PANEL_SCH_COLORS ), _( "Colors" ) ); book->AddSubPage( CREATE_PANEL( PANEL_SCH_FIELD_NAME_TEMPLATES ), _( "Field Name Templates" ) ); diff --git a/common/widgets/gal_options_panel.cpp b/common/widgets/gal_options_panel.cpp index 7908ad28f2..862e26bf89 100644 --- a/common/widgets/gal_options_panel.cpp +++ b/common/widgets/gal_options_panel.cpp @@ -253,3 +253,17 @@ bool GAL_OPTIONS_PANEL::TransferDataFromWindow() return true; } + + +bool GAL_OPTIONS_PANEL::ResetPanel( APP_SETTINGS_BASE* aAppSettings ) +{ + APP_SETTINGS_BASE* saved = m_cfg; + + m_cfg = aAppSettings; + TransferDataToWindow(); + m_cfg = saved; + + return true; +} + + diff --git a/common/widgets/paged_dialog.cpp b/common/widgets/paged_dialog.cpp index 84c2c8df06..a79eeeec61 100644 --- a/common/widgets/paged_dialog.cpp +++ b/common/widgets/paged_dialog.cpp @@ -364,11 +364,15 @@ void PAGED_DIALOG::OnPageChange( wxBookCtrlEvent& event ) // Enable the reset button only if the page is re-settable if( m_resetButton ) { - if( auto panel = dynamic_cast( m_treebook->GetPage( page ) ) ) + // NB: dynamic_cast doesn't work over Kiway. + wxWindow* panel = m_treebook->GetPage( page ); + + if( panel && panel->GetWindowStyle() & wxRESETTABLE ) { m_resetButton->SetLabel( wxString::Format( _( "Reset %s to Defaults" ), m_treebook->GetPageText( page ) ) ); - m_resetButton->SetToolTip( panel->GetResetTooltip() ); + m_resetButton->SetToolTip( panel->GetHelpTextAtPoint( wxPoint( -INT_MAX, INT_MAX ), + wxHelpEvent::Origin_Unknown ) ); m_resetButton->Enable( true ); } else @@ -378,6 +382,7 @@ void PAGED_DIALOG::OnPageChange( wxBookCtrlEvent& event ) m_resetButton->Enable( false ); } + m_resetButton->GetParent()->Layout(); } // Work around an OSX bug where the wxGrid children don't get placed correctly until @@ -403,8 +408,12 @@ void PAGED_DIALOG::OnResetButton( wxCommandEvent& aEvent ) if( sel == wxNOT_FOUND ) return; - RESETTABLE_PANEL* panel = dynamic_cast( m_treebook->GetPage( sel ) ); + // NB: dynamic_cast doesn't work over Kiway + wxWindow* panel = m_treebook->GetPage( sel ); if( panel ) - panel->ResetPanel(); + { + wxCommandEvent resetCommand( wxEVT_COMMAND_BUTTON_CLICKED, ID_RESET_PANEL ); + panel->ProcessWindowEvent( resetCommand ); + } } diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 52f9116560..380467a017 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -125,6 +125,7 @@ set( EESCHEMA_DLGS dialogs/panel_setup_formatting_base.cpp dialogs/panel_setup_pinmap.cpp dialogs/panel_setup_pinmap_base.cpp + dialogs/panel_sym_display_options.cpp dialogs/panel_sym_editing_options.cpp dialogs/panel_sym_editing_options_base.cpp dialogs/panel_sym_color_settings.cpp diff --git a/eeschema/dialogs/panel_eeschema_display_options.cpp b/eeschema/dialogs/panel_eeschema_display_options.cpp index 2d589c0d7a..8ecd2f710b 100644 --- a/eeschema/dialogs/panel_eeschema_display_options.cpp +++ b/eeschema/dialogs/panel_eeschema_display_options.cpp @@ -41,11 +41,8 @@ PANEL_EESCHEMA_DISPLAY_OPTIONS::PANEL_EESCHEMA_DISPLAY_OPTIONS( wxWindow* aParen } -bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataToWindow() +void PANEL_EESCHEMA_DISPLAY_OPTIONS::loadEEschemaSettings( EESCHEMA_SETTINGS* cfg ) { - SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); - EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings(); - m_checkShowHiddenPins->SetValue( cfg->m_Appearance.show_hidden_pins ); m_checkShowHiddenFields->SetValue( cfg->m_Appearance.show_hidden_fields ); m_checkPageLimits->SetValue( cfg->m_Appearance.show_page_limits ); @@ -59,6 +56,15 @@ bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataToWindow() m_checkCrossProbeCenter->SetValue( cfg->m_CrossProbing.center_on_items ); m_checkCrossProbeZoom->SetValue( cfg->m_CrossProbing.zoom_to_fit ); m_checkCrossProbeAutoHighlight->SetValue( cfg->m_CrossProbing.auto_highlight ); +} + + +bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataToWindow() +{ + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings(); + + loadEEschemaSettings( cfg ); m_galOptsPanel->TransferDataToWindow(); @@ -91,3 +97,14 @@ bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow() } +void PANEL_EESCHEMA_DISPLAY_OPTIONS::ResetPanel() +{ + EESCHEMA_SETTINGS cfg; + cfg.Load(); // Loading without a file will init to defaults + + loadEEschemaSettings( &cfg ); + + m_galOptsPanel->ResetPanel( &cfg ); +} + + diff --git a/eeschema/dialogs/panel_eeschema_display_options.h b/eeschema/dialogs/panel_eeschema_display_options.h index c65c60f72b..c1bffe0138 100644 --- a/eeschema/dialogs/panel_eeschema_display_options.h +++ b/eeschema/dialogs/panel_eeschema_display_options.h @@ -24,6 +24,7 @@ class APP_SETTINGS_BASE; class GAL_OPTIONS_PANEL; +class EESCHEMA_SETTINGS; class PANEL_EESCHEMA_DISPLAY_OPTIONS : public PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE @@ -31,10 +32,15 @@ class PANEL_EESCHEMA_DISPLAY_OPTIONS : public PANEL_EESCHEMA_DISPLAY_OPTIONS_BAS public: PANEL_EESCHEMA_DISPLAY_OPTIONS( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ); -private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; + void ResetPanel() override; + +private: + void loadEEschemaSettings( EESCHEMA_SETTINGS* aCfg ); + +private: GAL_OPTIONS_PANEL* m_galOptsPanel; }; diff --git a/eeschema/dialogs/panel_eeschema_display_options_base.cpp b/eeschema/dialogs/panel_eeschema_display_options_base.cpp index a53b32a25e..268f63c7b2 100644 --- a/eeschema/dialogs/panel_eeschema_display_options_base.cpp +++ b/eeschema/dialogs/panel_eeschema_display_options_base.cpp @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE::PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE::PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name ) { wxBoxSizer* bPanelSizer; bPanelSizer = new wxBoxSizer( wxHORIZONTAL ); diff --git a/eeschema/dialogs/panel_eeschema_display_options_base.fbp b/eeschema/dialogs/panel_eeschema_display_options_base.fbp index 046f06e8fc..6053d69da7 100644 --- a/eeschema/dialogs/panel_eeschema_display_options_base.fbp +++ b/eeschema/dialogs/panel_eeschema_display_options_base.fbp @@ -44,7 +44,7 @@ PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE -1,-1 - ; forward_declare + RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare diff --git a/eeschema/dialogs/panel_eeschema_display_options_base.h b/eeschema/dialogs/panel_eeschema_display_options_base.h index f04c898d42..b68bb99f63 100644 --- a/eeschema/dialogs/panel_eeschema_display_options_base.h +++ b/eeschema/dialogs/panel_eeschema_display_options_base.h @@ -10,6 +10,7 @@ #include #include #include +#include "widgets/resettable_panel.h" #include #include #include @@ -28,7 +29,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE : public wxPanel +class PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE : public RESETTABLE_PANEL { private: diff --git a/eeschema/dialogs/panel_eeschema_editing_options.cpp b/eeschema/dialogs/panel_eeschema_editing_options.cpp index 04e46bcca5..9338c7752a 100644 --- a/eeschema/dialogs/panel_eeschema_editing_options.cpp +++ b/eeschema/dialogs/panel_eeschema_editing_options.cpp @@ -47,36 +47,43 @@ PANEL_EESCHEMA_EDITING_OPTIONS::PANEL_EESCHEMA_EDITING_OPTIONS( wxWindow* aWindo } +void PANEL_EESCHEMA_EDITING_OPTIONS::loadEEschemaSettings( EESCHEMA_SETTINGS* aCfg ) +{ + m_hPitch.SetValue( Mils2iu( aCfg->m_Drawing.default_repeat_offset_x ) ); + m_vPitch.SetValue( Mils2iu( aCfg->m_Drawing.default_repeat_offset_y ) ); + m_spinLabelRepeatStep->SetValue( aCfg->m_Drawing.repeat_label_increment ); + + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + COLOR_SETTINGS* settings = mgr.GetColorSettings(); + COLOR4D schematicBackground = settings->GetColor( LAYER_SCHEMATIC_BACKGROUND ); + + m_borderColorSwatch->SetSwatchBackground( schematicBackground ); + m_borderColorSwatch->SetSwatchColor( aCfg->m_Drawing.default_sheet_border_color, false ); + + m_backgroundColorSwatch->SetSwatchBackground( schematicBackground ); + m_backgroundColorSwatch->SetSwatchColor( aCfg->m_Drawing.default_sheet_background_color, false ); + + m_checkHVOrientation->SetValue( aCfg->m_Drawing.hv_lines_only ); + m_footprintPreview->SetValue( aCfg->m_Appearance.footprint_preview ); + m_navigatorStaysOpen->SetValue( aCfg->m_Appearance.navigator_stays_open ); + + m_checkAutoplaceFields->SetValue( aCfg->m_AutoplaceFields.enable ); + m_checkAutoplaceJustify->SetValue( aCfg->m_AutoplaceFields.allow_rejustify ); + m_checkAutoplaceAlign->SetValue( aCfg->m_AutoplaceFields.align_to_grid ); + + m_mouseDragIsDrag->SetValue( !aCfg->m_Input.drag_is_move ); + m_cbPinSelectionOpt->SetValue( aCfg->m_Selection.select_pin_selects_symbol ); + + m_cbAutoStartWires->SetValue( aCfg->m_Drawing.auto_start_wires ); +} + + bool PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataToWindow() { SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings(); - m_hPitch.SetValue( Mils2iu( cfg->m_Drawing.default_repeat_offset_x ) ); - m_vPitch.SetValue( Mils2iu( cfg->m_Drawing.default_repeat_offset_y ) ); - m_spinLabelRepeatStep->SetValue( cfg->m_Drawing.repeat_label_increment ); - - COLOR_SETTINGS* settings = mgr.GetColorSettings(); - COLOR4D schematicBackground = settings->GetColor( LAYER_SCHEMATIC_BACKGROUND ); - - m_borderColorSwatch->SetSwatchBackground( schematicBackground ); - m_borderColorSwatch->SetSwatchColor( cfg->m_Drawing.default_sheet_border_color, false ); - - m_backgroundColorSwatch->SetSwatchBackground( schematicBackground ); - m_backgroundColorSwatch->SetSwatchColor( cfg->m_Drawing.default_sheet_background_color, false ); - - m_checkHVOrientation->SetValue( cfg->m_Drawing.hv_lines_only ); - m_footprintPreview->SetValue( cfg->m_Appearance.footprint_preview ); - m_navigatorStaysOpen->SetValue( cfg->m_Appearance.navigator_stays_open ); - - m_checkAutoplaceFields->SetValue( cfg->m_AutoplaceFields.enable ); - m_checkAutoplaceJustify->SetValue( cfg->m_AutoplaceFields.allow_rejustify ); - m_checkAutoplaceAlign->SetValue( cfg->m_AutoplaceFields.align_to_grid ); - - m_mouseDragIsDrag->SetValue( !cfg->m_Input.drag_is_move ); - m_cbPinSelectionOpt->SetValue( cfg->m_Selection.select_pin_selects_symbol ); - - m_cbAutoStartWires->SetValue( cfg->m_Drawing.auto_start_wires ); + loadEEschemaSettings( cfg ); return true; } @@ -111,3 +118,12 @@ bool PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataFromWindow() } +void PANEL_EESCHEMA_EDITING_OPTIONS::ResetPanel() +{ + EESCHEMA_SETTINGS cfg; + cfg.Load(); // Loading without a file will init to defaults + + loadEEschemaSettings( &cfg ); +} + + diff --git a/eeschema/dialogs/panel_eeschema_editing_options.h b/eeschema/dialogs/panel_eeschema_editing_options.h index 84acf646e9..2a76bf6518 100644 --- a/eeschema/dialogs/panel_eeschema_editing_options.h +++ b/eeschema/dialogs/panel_eeschema_editing_options.h @@ -31,10 +31,15 @@ class PANEL_EESCHEMA_EDITING_OPTIONS : public PANEL_EESCHEMA_EDITING_OPTIONS_BAS public: PANEL_EESCHEMA_EDITING_OPTIONS( wxWindow* aWindow, EDA_BASE_FRAME* aUnitsProvider ); -private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; + void ResetPanel() override; + +private: + void loadEEschemaSettings( EESCHEMA_SETTINGS* aCfg ); + +private: UNIT_BINDER m_hPitch; UNIT_BINDER m_vPitch; }; diff --git a/eeschema/dialogs/panel_eeschema_editing_options_base.cpp b/eeschema/dialogs/panel_eeschema_editing_options_base.cpp index 06a3c52ca7..317cf3239c 100644 --- a/eeschema/dialogs/panel_eeschema_editing_options_base.cpp +++ b/eeschema/dialogs/panel_eeschema_editing_options_base.cpp @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_EESCHEMA_EDITING_OPTIONS_BASE::PANEL_EESCHEMA_EDITING_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_EESCHEMA_EDITING_OPTIONS_BASE::PANEL_EESCHEMA_EDITING_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name ) { wxBoxSizer* bPanelSizer; bPanelSizer = new wxBoxSizer( wxHORIZONTAL ); diff --git a/eeschema/dialogs/panel_eeschema_editing_options_base.fbp b/eeschema/dialogs/panel_eeschema_editing_options_base.fbp index 3300f45f46..15197b7235 100644 --- a/eeschema/dialogs/panel_eeschema_editing_options_base.fbp +++ b/eeschema/dialogs/panel_eeschema_editing_options_base.fbp @@ -44,7 +44,7 @@ PANEL_EESCHEMA_EDITING_OPTIONS_BASE -1,-1 - ; forward_declare + RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare diff --git a/eeschema/dialogs/panel_eeschema_editing_options_base.h b/eeschema/dialogs/panel_eeschema_editing_options_base.h index a9fd65a0c4..88ccbe0b2c 100644 --- a/eeschema/dialogs/panel_eeschema_editing_options_base.h +++ b/eeschema/dialogs/panel_eeschema_editing_options_base.h @@ -11,6 +11,7 @@ #include #include #include "widgets/color_swatch.h" +#include "widgets/resettable_panel.h" #include #include #include @@ -31,7 +32,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_EESCHEMA_EDITING_OPTIONS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_EESCHEMA_EDITING_OPTIONS_BASE : public wxPanel +class PANEL_EESCHEMA_EDITING_OPTIONS_BASE : public RESETTABLE_PANEL { private: diff --git a/eeschema/dialogs/panel_sym_display_options.cpp b/eeschema/dialogs/panel_sym_display_options.cpp new file mode 100644 index 0000000000..651d903a52 --- /dev/null +++ b/eeschema/dialogs/panel_sym_display_options.cpp @@ -0,0 +1,75 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include +#include +#include +#include + + +PANEL_SYM_DISPLAY_OPTIONS::PANEL_SYM_DISPLAY_OPTIONS( wxWindow* aParent, + APP_SETTINGS_BASE* aAppSettings ) : + RESETTABLE_PANEL( aParent ) +{ + wxBoxSizer* bPanelSizer = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bLeftCol = new wxBoxSizer( wxVERTICAL ); + + m_galOptsPanel = new GAL_OPTIONS_PANEL( this, aAppSettings ); + bLeftCol->Add( m_galOptsPanel, 1, wxEXPAND, 0 ); + + bPanelSizer->Add( bLeftCol, 1, wxEXPAND, 0 ); + bPanelSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + this->SetSizer( bPanelSizer ); + this->Layout(); + bPanelSizer->Fit( this ); +} + + +bool PANEL_SYM_DISPLAY_OPTIONS::TransferDataToWindow() +{ + m_galOptsPanel->TransferDataToWindow(); + + return true; +} + + +bool PANEL_SYM_DISPLAY_OPTIONS::TransferDataFromWindow() +{ + m_galOptsPanel->TransferDataFromWindow(); + + return true; +} + + +void PANEL_SYM_DISPLAY_OPTIONS::ResetPanel() +{ + SYMBOL_EDITOR_SETTINGS cfg; + cfg.Load(); // Loading without a file will init to defaults + + m_galOptsPanel->ResetPanel( &cfg ); +} + + diff --git a/eeschema/dialogs/panel_sym_display_options.h b/eeschema/dialogs/panel_sym_display_options.h new file mode 100644 index 0000000000..91573837ac --- /dev/null +++ b/eeschema/dialogs/panel_sym_display_options.h @@ -0,0 +1,45 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef PANEL_SYM_DISPLAY_OPTIONS_H +#define PANEL_SYM_DISPLAY_OPTIONS_H + +#include + + +class APP_SETTINGS_BASE; +class GAL_OPTIONS_PANEL; + + +class PANEL_SYM_DISPLAY_OPTIONS : public RESETTABLE_PANEL +{ +public: + PANEL_SYM_DISPLAY_OPTIONS( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ); + + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; + + void ResetPanel() override; + +private: + GAL_OPTIONS_PANEL* m_galOptsPanel; +}; + + +#endif // PANEL_SYM_DISPLAY_OPTIONS_H diff --git a/eeschema/dialogs/panel_sym_editing_options.cpp b/eeschema/dialogs/panel_sym_editing_options.cpp index 27c2c511ec..075a11f541 100644 --- a/eeschema/dialogs/panel_sym_editing_options.cpp +++ b/eeschema/dialogs/panel_sym_editing_options.cpp @@ -39,19 +39,25 @@ PANEL_SYM_EDITING_OPTIONS::PANEL_SYM_EDITING_OPTIONS( wxWindow* aWindow, {} +void PANEL_SYM_EDITING_OPTIONS::loadSymEditorSettings( SYMBOL_EDITOR_SETTINGS* aCfg ) +{ + m_lineWidth.SetValue( Mils2iu( aCfg->m_Defaults.line_width ) ); + m_textSize.SetValue( Mils2iu( aCfg->m_Defaults.text_size ) ); + m_pinLength.SetValue( Mils2iu( aCfg->m_Defaults.pin_length ) ); + m_pinNumberSize.SetValue( Mils2iu( aCfg->m_Defaults.pin_num_size ) ); + m_pinNameSize.SetValue( Mils2iu( aCfg->m_Defaults.pin_name_size ) ); + m_choicePinDisplacement->SetSelection( aCfg->m_Repeat.pin_step == 50 ? 1 : 0 ); + m_spinRepeatLabel->SetValue( aCfg->m_Repeat.label_delta ); + m_cbShowPinElectricalType->SetValue( aCfg->m_ShowPinElectricalType ); +} + + bool PANEL_SYM_EDITING_OPTIONS::TransferDataToWindow() { SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); SYMBOL_EDITOR_SETTINGS* settings = mgr.GetAppSettings(); - m_lineWidth.SetValue( Mils2iu( settings->m_Defaults.line_width ) ); - m_textSize.SetValue( Mils2iu( settings->m_Defaults.text_size ) ); - m_pinLength.SetValue( Mils2iu( settings->m_Defaults.pin_length ) ); - m_pinNumberSize.SetValue( Mils2iu( settings->m_Defaults.pin_num_size ) ); - m_pinNameSize.SetValue( Mils2iu( settings->m_Defaults.pin_name_size ) ); - m_choicePinDisplacement->SetSelection( settings->m_Repeat.pin_step == 50 ? 1 : 0 ); - m_spinRepeatLabel->SetValue( settings->m_Repeat.label_delta ); - m_cbShowPinElectricalType->SetValue( settings->m_ShowPinElectricalType ); + loadSymEditorSettings( settings ); return true; } @@ -75,3 +81,12 @@ bool PANEL_SYM_EDITING_OPTIONS::TransferDataFromWindow() } +void PANEL_SYM_EDITING_OPTIONS::ResetPanel() +{ + SYMBOL_EDITOR_SETTINGS cfg; + cfg.Load(); // Loading without a file will init to defaults + + loadSymEditorSettings( &cfg ); +} + + diff --git a/eeschema/dialogs/panel_sym_editing_options.h b/eeschema/dialogs/panel_sym_editing_options.h index 70c89c2568..1c0178febd 100644 --- a/eeschema/dialogs/panel_sym_editing_options.h +++ b/eeschema/dialogs/panel_sym_editing_options.h @@ -31,10 +31,15 @@ class PANEL_SYM_EDITING_OPTIONS : public PANEL_SYM_EDITING_OPTIONS_BASE public: PANEL_SYM_EDITING_OPTIONS( wxWindow* aWindow, EDA_BASE_FRAME* aUnitsProvider ); -private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; + void ResetPanel() override; + +private: + void loadSymEditorSettings( SYMBOL_EDITOR_SETTINGS* aCfg ); + +private: UNIT_BINDER m_lineWidth; UNIT_BINDER m_textSize; diff --git a/eeschema/dialogs/panel_sym_editing_options_base.cpp b/eeschema/dialogs/panel_sym_editing_options_base.cpp index 62319c68f1..628822074c 100644 --- a/eeschema/dialogs/panel_sym_editing_options_base.cpp +++ b/eeschema/dialogs/panel_sym_editing_options_base.cpp @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_SYM_EDITING_OPTIONS_BASE::PANEL_SYM_EDITING_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_SYM_EDITING_OPTIONS_BASE::PANEL_SYM_EDITING_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name ) { wxBoxSizer* p1mainSizer; p1mainSizer = new wxBoxSizer( wxHORIZONTAL ); diff --git a/eeschema/dialogs/panel_sym_editing_options_base.fbp b/eeschema/dialogs/panel_sym_editing_options_base.fbp index e484320b2b..4712caf290 100644 --- a/eeschema/dialogs/panel_sym_editing_options_base.fbp +++ b/eeschema/dialogs/panel_sym_editing_options_base.fbp @@ -44,7 +44,7 @@ PANEL_SYM_EDITING_OPTIONS_BASE -1,-1 - ; forward_declare + RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare diff --git a/eeschema/dialogs/panel_sym_editing_options_base.h b/eeschema/dialogs/panel_sym_editing_options_base.h index 3999ff842f..1dd89cb3f3 100644 --- a/eeschema/dialogs/panel_sym_editing_options_base.h +++ b/eeschema/dialogs/panel_sym_editing_options_base.h @@ -10,6 +10,7 @@ #include #include #include +#include "widgets/resettable_panel.h" #include #include #include @@ -30,7 +31,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_SYM_EDITING_OPTIONS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_SYM_EDITING_OPTIONS_BASE : public wxPanel +class PANEL_SYM_EDITING_OPTIONS_BASE : public RESETTABLE_PANEL { private: diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 806c376bc6..17b5f1b117 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -56,6 +56,7 @@ #include #include #include +#include // The main sheet of the project SCH_SHEET* g_RootSheet = nullptr; @@ -175,12 +176,12 @@ static struct IFACE : public KIFACE_BASE // Dialog has completed; nothing to return. return nullptr; - case PANEL_SYM_DISPLAY_OPTIONS: + case PANEL_SYM_DISP_OPTIONS: { SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); APP_SETTINGS_BASE* cfg = mgr.GetAppSettings(); - return new PANEL_GAL_DISPLAY_OPTIONS( aParent, cfg ); + return new PANEL_SYM_DISPLAY_OPTIONS( aParent, cfg ); } case PANEL_SYM_EDIT_OPTIONS: @@ -213,7 +214,7 @@ static struct IFACE : public KIFACE_BASE case PANEL_SYM_COLORS: return new PANEL_SYM_COLOR_SETTINGS( aParent ); - case PANEL_SCH_DISPLAY_OPTIONS: + case PANEL_SCH_DISP_OPTIONS: { SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); APP_SETTINGS_BASE* cfg = mgr.GetAppSettings(); diff --git a/gerbview/dialogs/panel_gerbview_display_options.cpp b/gerbview/dialogs/panel_gerbview_display_options.cpp index 5b56db822e..ac094f1cb8 100644 --- a/gerbview/dialogs/panel_gerbview_display_options.cpp +++ b/gerbview/dialogs/panel_gerbview_display_options.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2010-2014 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -50,30 +50,36 @@ PANEL_GERBVIEW_DISPLAY_OPTIONS::PANEL_GERBVIEW_DISPLAY_OPTIONS( wxWindow* aParen } -bool PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataToWindow( ) +void PANEL_GERBVIEW_DISPLAY_OPTIONS::loadSettings( GERBVIEW_SETTINGS* aCfg ) { - m_galOptsPanel->TransferDataToWindow(); - - GERBVIEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); - // Show Option Draw polygons - m_OptDisplayPolygons->SetValue( !cfg->m_Display.m_DisplayPolygonsFill ); + m_OptDisplayPolygons->SetValue( !aCfg->m_Display.m_DisplayPolygonsFill ); // Show Option Draw Lines. We use DisplayPcbTrackFill as Lines draw option - m_OptDisplayLines->SetValue( !cfg->m_Display.m_DisplayLinesFill ); - m_OptDisplayFlashedItems->SetValue( !cfg->m_Display.m_DisplayFlashedItemsFill ); - m_OptDisplayDCodes->SetValue( cfg->m_Appearance.show_dcodes ); + m_OptDisplayLines->SetValue( !aCfg->m_Display.m_DisplayLinesFill ); + m_OptDisplayFlashedItems->SetValue( !aCfg->m_Display.m_DisplayFlashedItemsFill ); + m_OptDisplayDCodes->SetValue( aCfg->m_Appearance.show_dcodes ); for( unsigned i = 0; i < arrayDim( gerberPageSizeList ); ++i ) { - if( gerberPageSizeList[i] == cfg->m_Appearance.page_type ) + if( gerberPageSizeList[i] == aCfg->m_Appearance.page_type ) { m_PageSize->SetSelection( i ); break; } } - m_ShowPageLimitsOpt->SetValue( cfg->m_Display.m_DisplayPageLimits ); + m_ShowPageLimitsOpt->SetValue( aCfg->m_Display.m_DisplayPageLimits ); +} + + +bool PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataToWindow() +{ + m_galOptsPanel->TransferDataToWindow(); + + GERBVIEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); + + loadSettings( cfg ); return true; } @@ -96,3 +102,15 @@ bool PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataFromWindow() return true; } + +void PANEL_GERBVIEW_DISPLAY_OPTIONS::ResetPanel() +{ + GERBVIEW_SETTINGS cfg; + cfg.Load(); // Loading without a file will init to defaults + + loadSettings( &cfg ); + + m_galOptsPanel->ResetPanel( &cfg ); +} + + diff --git a/gerbview/dialogs/panel_gerbview_display_options.h b/gerbview/dialogs/panel_gerbview_display_options.h index 3da1e9cd21..1d6a27040c 100644 --- a/gerbview/dialogs/panel_gerbview_display_options.h +++ b/gerbview/dialogs/panel_gerbview_display_options.h @@ -36,10 +36,15 @@ public: PANEL_GERBVIEW_DISPLAY_OPTIONS( wxWindow* aParent ); ~PANEL_GERBVIEW_DISPLAY_OPTIONS() {}; -private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; + void ResetPanel() override; + +private: + void loadSettings( GERBVIEW_SETTINGS* aCfg ); + +private: GAL_OPTIONS_PANEL* m_galOptsPanel; }; diff --git a/gerbview/dialogs/panel_gerbview_display_options_base.cpp b/gerbview/dialogs/panel_gerbview_display_options_base.cpp index 3026daf7e4..5774891ea1 100644 --- a/gerbview/dialogs/panel_gerbview_display_options_base.cpp +++ b/gerbview/dialogs/panel_gerbview_display_options_base.cpp @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE::PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE::PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name ) { wxBoxSizer* bDialogSizer; bDialogSizer = new wxBoxSizer( wxVERTICAL ); diff --git a/gerbview/dialogs/panel_gerbview_display_options_base.fbp b/gerbview/dialogs/panel_gerbview_display_options_base.fbp index 7fc84d1153..25c8276dac 100644 --- a/gerbview/dialogs/panel_gerbview_display_options_base.fbp +++ b/gerbview/dialogs/panel_gerbview_display_options_base.fbp @@ -44,7 +44,7 @@ PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE -1,-1 - ; forward_declare + RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare diff --git a/gerbview/dialogs/panel_gerbview_display_options_base.h b/gerbview/dialogs/panel_gerbview_display_options_base.h index 3010a79bf7..d8de82df03 100644 --- a/gerbview/dialogs/panel_gerbview_display_options_base.h +++ b/gerbview/dialogs/panel_gerbview_display_options_base.h @@ -10,6 +10,7 @@ #include #include #include +#include "widgets/resettable_panel.h" #include #include #include @@ -27,7 +28,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE : public wxPanel +class PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE : public RESETTABLE_PANEL { private: diff --git a/include/dialogs/panel_color_settings.h b/include/dialogs/panel_color_settings.h index 93f47cbdd2..36bf236670 100644 --- a/include/dialogs/panel_color_settings.h +++ b/include/dialogs/panel_color_settings.h @@ -45,7 +45,7 @@ public: virtual void ResetPanel() override; - virtual wxString GetResetTooltip() override + virtual wxString GetResetTooltip() const override { return _( "Reset all colors in this theme to the KiCad defaults" ); } diff --git a/include/frame_type.h b/include/frame_type.h index 464c21b77d..cda98de2c5 100644 --- a/include/frame_type.h +++ b/include/frame_type.h @@ -65,11 +65,11 @@ enum FRAME_T FRAME_T_COUNT, - PANEL_SYM_DISPLAY_OPTIONS = FRAME_T_COUNT, + PANEL_SYM_DISP_OPTIONS = FRAME_T_COUNT, PANEL_SYM_EDIT_OPTIONS, PANEL_SYM_COLORS, - PANEL_SCH_DISPLAY_OPTIONS, + PANEL_SCH_DISP_OPTIONS, PANEL_SCH_EDIT_OPTIONS, PANEL_SCH_COLORS, PANEL_SCH_FIELD_NAME_TEMPLATES, diff --git a/include/id.h b/include/id.h index d9591bb3dd..3630a8b0ff 100644 --- a/include/id.h +++ b/include/id.h @@ -90,6 +90,7 @@ enum main_id ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, ID_PREFERENCES_CONFIGURE_PATHS, + ID_PREFERENCES_RESET_PANEL, ID_EDIT_SYMBOL_LIBRARY_TABLE, ID_EDIT_FOOTPRINT_LIBRARY_TABLE, diff --git a/include/panel_hotkeys_editor.h b/include/panel_hotkeys_editor.h index d10fd806ea..adda6d38fb 100644 --- a/include/panel_hotkeys_editor.h +++ b/include/panel_hotkeys_editor.h @@ -50,7 +50,7 @@ public: void ResetPanel() override; - wxString GetResetTooltip() override + wxString GetResetTooltip() const override { return _( "Reset all hotkeys to the built-in KiCad defaults" ); } diff --git a/include/widgets/gal_options_panel.h b/include/widgets/gal_options_panel.h index c111949d9c..dcfe378485 100644 --- a/include/widgets/gal_options_panel.h +++ b/include/widgets/gal_options_panel.h @@ -53,6 +53,8 @@ public: */ bool TransferDataFromWindow() override; + bool ResetPanel( APP_SETTINGS_BASE* aAppSettings ); + private: wxBoxSizer* m_mainSizer; diff --git a/include/widgets/resettable_panel.h b/include/widgets/resettable_panel.h index bb82fc943b..1c1aca7c7b 100644 --- a/include/widgets/resettable_panel.h +++ b/include/widgets/resettable_panel.h @@ -21,9 +21,13 @@ #define RESETTABLE_PANEL_H_ #include +#include class PAGED_DIALOG; +#define wxRESETTABLE 0x00008000 +#define ID_RESET_PANEL ID_PREFERENCES_RESET_PANEL + /** * A wxPanel that is designed to be reset in a standard manner. */ @@ -35,8 +39,16 @@ public: const wxSize& aSize = wxSize( -1,-1 ), long aStyle = wxTAB_TRAVERSAL, const wxString& aName = wxEmptyString ) - : wxPanel( aParent, aId, aPos, aSize, aStyle, aName ) + : wxPanel( aParent, aId, aPos, aSize, aStyle | wxRESETTABLE, aName ) { + Bind( wxEVT_COMMAND_BUTTON_CLICKED, + [&]( wxCommandEvent& aCmd ) + { + if( aCmd.GetId() == ID_RESET_PANEL ) + ResetPanel(); + else + aCmd.Skip(); + } ); } /** @@ -49,10 +61,21 @@ public: * * @return the tooltip */ - virtual wxString GetResetTooltip() + virtual wxString GetResetTooltip() const { return _( "Reset all settings on this page to their default" ); } + + /** + * Overridden to supply the reset button tooltip when queried with { -INT_MAX, INT_MAX }. + */ + wxString GetHelpTextAtPoint( const wxPoint& aPt, wxHelpEvent::Origin aOrigin ) const override + { + if( aPt == wxPoint( -INT_MAX, INT_MAX ) ) + return GetResetTooltip(); + else + return wxPanel::GetHelpTextAtPoint( aPt, aOrigin ); + } }; #endif diff --git a/pagelayout_editor/CMakeLists.txt b/pagelayout_editor/CMakeLists.txt index 7d89db2ad3..24e5245989 100644 --- a/pagelayout_editor/CMakeLists.txt +++ b/pagelayout_editor/CMakeLists.txt @@ -22,6 +22,7 @@ set( DIALOGS_SRCS dialogs/design_inspector.cpp dialogs/panel_pl_editor_color_settings.cpp dialogs/panel_pl_editor_color_settings_base.cpp + dialogs/panel_pl_editor_display_options.cpp ) set( PL_EDITOR_SRCS diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp b/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp index dedb0dabfb..e46852eaa7 100644 --- a/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -70,4 +70,12 @@ bool PANEL_PL_EDITOR_COLOR_SETTINGS::TransferDataFromWindow() cfg->m_ColorTheme = colors->GetFilename(); return true; -} \ No newline at end of file +} + + +void PANEL_PL_EDITOR_COLOR_SETTINGS::ResetPanel() +{ + m_themes->SetStringSelection( _( "KiCad Default" ) ); +} + + diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings.h b/pagelayout_editor/dialogs/panel_pl_editor_color_settings.h index cf21aa0be2..f245842655 100644 --- a/pagelayout_editor/dialogs/panel_pl_editor_color_settings.h +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -28,10 +28,10 @@ class PANEL_PL_EDITOR_COLOR_SETTINGS : public PANEL_PL_EDITOR_COLOR_SETTINGS_BAS public: PANEL_PL_EDITOR_COLOR_SETTINGS( wxWindow* aParent ); -private: bool TransferDataToWindow() override; - bool TransferDataFromWindow() override; + + void ResetPanel() override; }; diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.cpp b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.cpp index 8b85c0a69a..004303c88b 100644 --- a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.cpp +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.cpp @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_PL_EDITOR_COLOR_SETTINGS_BASE::PANEL_PL_EDITOR_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_PL_EDITOR_COLOR_SETTINGS_BASE::PANEL_PL_EDITOR_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name ) { wxBoxSizer* p1mainSizer; p1mainSizer = new wxBoxSizer( wxHORIZONTAL ); diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.fbp b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.fbp index ee6613b3da..4fbf5ae27e 100644 --- a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.fbp +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.fbp @@ -44,7 +44,7 @@ PANEL_PL_EDITOR_COLOR_SETTINGS_BASE -1,-1 - ; forward_declare + RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.h b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.h index 26c05d08d7..7c79693e8a 100644 --- a/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.h +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings_base.h @@ -10,6 +10,7 @@ #include #include #include +#include "widgets/resettable_panel.h" #include #include #include @@ -27,7 +28,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_PL_EDITOR_COLOR_SETTINGS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_PL_EDITOR_COLOR_SETTINGS_BASE : public wxPanel +class PANEL_PL_EDITOR_COLOR_SETTINGS_BASE : public RESETTABLE_PANEL { private: diff --git a/pagelayout_editor/dialogs/panel_pl_editor_display_options.cpp b/pagelayout_editor/dialogs/panel_pl_editor_display_options.cpp new file mode 100644 index 0000000000..f5c84ad554 --- /dev/null +++ b/pagelayout_editor/dialogs/panel_pl_editor_display_options.cpp @@ -0,0 +1,75 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include +#include +#include +#include + + +PANEL_PL_EDITOR_DISPLAY_OPTIONS::PANEL_PL_EDITOR_DISPLAY_OPTIONS( wxWindow* aParent, + APP_SETTINGS_BASE* aAppSettings ) : + RESETTABLE_PANEL( aParent ) +{ + wxBoxSizer* bPanelSizer = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bLeftCol = new wxBoxSizer( wxVERTICAL ); + + m_galOptsPanel = new GAL_OPTIONS_PANEL( this, aAppSettings ); + bLeftCol->Add( m_galOptsPanel, 1, wxEXPAND, 0 ); + + bPanelSizer->Add( bLeftCol, 1, wxEXPAND, 0 ); + bPanelSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + this->SetSizer( bPanelSizer ); + this->Layout(); + bPanelSizer->Fit( this ); +} + + +bool PANEL_PL_EDITOR_DISPLAY_OPTIONS::TransferDataToWindow() +{ + m_galOptsPanel->TransferDataToWindow(); + + return true; +} + + +bool PANEL_PL_EDITOR_DISPLAY_OPTIONS::TransferDataFromWindow() +{ + m_galOptsPanel->TransferDataFromWindow(); + + return true; +} + + +void PANEL_PL_EDITOR_DISPLAY_OPTIONS::ResetPanel() +{ + PL_EDITOR_SETTINGS cfg; + cfg.Load(); // Loading without a file will init to defaults + + m_galOptsPanel->ResetPanel( &cfg ); +} + + diff --git a/pagelayout_editor/dialogs/panel_pl_editor_display_options.h b/pagelayout_editor/dialogs/panel_pl_editor_display_options.h new file mode 100644 index 0000000000..e4f9d35263 --- /dev/null +++ b/pagelayout_editor/dialogs/panel_pl_editor_display_options.h @@ -0,0 +1,45 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef PANEL_PL_EDITOR_DISPLAY_OPTIONS_H +#define PANEL_PL_EDITOR_DISPLAY_OPTIONS_H + +#include + + +class APP_SETTINGS_BASE; +class GAL_OPTIONS_PANEL; + + +class PANEL_PL_EDITOR_DISPLAY_OPTIONS : public RESETTABLE_PANEL +{ +public: + PANEL_PL_EDITOR_DISPLAY_OPTIONS( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ); + + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; + + void ResetPanel() override; + +private: + GAL_OPTIONS_PANEL* m_galOptsPanel; +}; + + +#endif // PANEL_PL_EDITOR_DISPLAY_OPTIONS_H diff --git a/pagelayout_editor/pl_editor.cpp b/pagelayout_editor/pl_editor.cpp index 6275208c0f..d68a03b782 100644 --- a/pagelayout_editor/pl_editor.cpp +++ b/pagelayout_editor/pl_editor.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include "pl_editor_frame.h" @@ -65,7 +65,7 @@ static struct IFACE : public KIFACE_BASE SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); APP_SETTINGS_BASE* cfg = mgr.GetAppSettings(); - return new PANEL_GAL_DISPLAY_OPTIONS( aParent, cfg ); + return new PANEL_PL_EDITOR_DISPLAY_OPTIONS( aParent, cfg ); } case PANEL_DS_COLORS: diff --git a/pcbnew/dialogs/panel_display_options.cpp b/pcbnew/dialogs/panel_display_options.cpp index 47a771de7b..b1d3e855a8 100644 --- a/pcbnew/dialogs/panel_display_options.cpp +++ b/pcbnew/dialogs/panel_display_options.cpp @@ -47,6 +47,22 @@ PANEL_DISPLAY_OPTIONS::PANEL_DISPLAY_OPTIONS( wxWindow* aParent, APP_SETTINGS_BA } +void PANEL_DISPLAY_OPTIONS::loadPCBSettings( PCBNEW_SETTINGS* aCfg ) +{ + int i = UTIL::GetConfigForVal( clearanceModeMap, aCfg->m_Display.m_ShowTrackClearanceMode ); + m_OptDisplayTracksClearance->SetSelection( i ); + + m_OptDisplayPadClearence->SetValue( aCfg->m_Display.m_DisplayPadClearance ); + m_OptDisplayPadNumber->SetValue( aCfg->m_Display.m_DisplayPadNum ); + m_OptDisplayPadNoConn->SetValue( aCfg->m_Display.m_DisplayPadNoConnects ); + m_ShowNetNamesOption->SetSelection( aCfg->m_Display.m_DisplayNetNamesMode ); + m_live3Drefresh->SetValue( aCfg->m_Display.m_Live3DRefresh ); + m_checkCrossProbeCenter->SetValue( aCfg->m_CrossProbing.center_on_items ); + m_checkCrossProbeZoom->SetValue( aCfg->m_CrossProbing.zoom_to_fit ); + m_checkCrossProbeAutoHighlight->SetValue( aCfg->m_CrossProbing.auto_highlight ); +} + + bool PANEL_DISPLAY_OPTIONS::TransferDataToWindow() { if( m_isPCBEdit ) @@ -54,17 +70,7 @@ bool PANEL_DISPLAY_OPTIONS::TransferDataToWindow() SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); PCBNEW_SETTINGS* cfg = mgr.GetAppSettings(); - int i = UTIL::GetConfigForVal( clearanceModeMap, cfg->m_Display.m_ShowTrackClearanceMode ); - m_OptDisplayTracksClearance->SetSelection( i ); - - m_OptDisplayPadClearence->SetValue( cfg->m_Display.m_DisplayPadClearance ); - m_OptDisplayPadNumber->SetValue( cfg->m_Display.m_DisplayPadNum ); - m_OptDisplayPadNoConn->SetValue( cfg->m_Display.m_DisplayPadNoConnects ); - m_ShowNetNamesOption->SetSelection( cfg->m_Display.m_DisplayNetNamesMode ); - m_live3Drefresh->SetValue( cfg->m_Display.m_Live3DRefresh ); - m_checkCrossProbeCenter->SetValue( cfg->m_CrossProbing.center_on_items ); - m_checkCrossProbeZoom->SetValue( cfg->m_CrossProbing.zoom_to_fit ); - m_checkCrossProbeAutoHighlight->SetValue( cfg->m_CrossProbing.auto_highlight ); + loadPCBSettings( cfg ); } m_galOptsPanel->TransferDataToWindow(); @@ -102,3 +108,15 @@ bool PANEL_DISPLAY_OPTIONS::TransferDataFromWindow() } +void PANEL_DISPLAY_OPTIONS::ResetPanel() +{ + PCBNEW_SETTINGS cfg; + cfg.Load(); // Loading without a file will init to defaults + + if( m_isPCBEdit ) + loadPCBSettings( &cfg ); + + m_galOptsPanel->ResetPanel( &cfg ); +} + + diff --git a/pcbnew/dialogs/panel_display_options.h b/pcbnew/dialogs/panel_display_options.h index 105294b7d2..5c360e9cde 100644 --- a/pcbnew/dialogs/panel_display_options.h +++ b/pcbnew/dialogs/panel_display_options.h @@ -20,6 +20,7 @@ #include "panel_display_options_base.h" +class PCBNEW_SETTINGS; class APP_SETTINGS_BASE; class GAL_OPTIONS_PANEL; @@ -32,6 +33,11 @@ public: bool TransferDataFromWindow() override; bool TransferDataToWindow() override; + void ResetPanel() override; + +private: + void loadPCBSettings( PCBNEW_SETTINGS* aCfg ); + private: bool m_isPCBEdit; GAL_OPTIONS_PANEL* m_galOptsPanel; diff --git a/pcbnew/dialogs/panel_display_options_base.cpp b/pcbnew/dialogs/panel_display_options_base.cpp index 34f0d903d8..aad076e38b 100644 --- a/pcbnew/dialogs/panel_display_options_base.cpp +++ b/pcbnew/dialogs/panel_display_options_base.cpp @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_DISPLAY_OPTIONS_BASE::PANEL_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_DISPLAY_OPTIONS_BASE::PANEL_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name ) { wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); diff --git a/pcbnew/dialogs/panel_display_options_base.fbp b/pcbnew/dialogs/panel_display_options_base.fbp index 7947bc9d3f..986e35c77d 100644 --- a/pcbnew/dialogs/panel_display_options_base.fbp +++ b/pcbnew/dialogs/panel_display_options_base.fbp @@ -44,7 +44,7 @@ PANEL_DISPLAY_OPTIONS_BASE -1,-1 - ; forward_declare + RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare diff --git a/pcbnew/dialogs/panel_display_options_base.h b/pcbnew/dialogs/panel_display_options_base.h index 341804732a..8b8db94e68 100644 --- a/pcbnew/dialogs/panel_display_options_base.h +++ b/pcbnew/dialogs/panel_display_options_base.h @@ -10,6 +10,7 @@ #include #include #include +#include "widgets/resettable_panel.h" #include #include #include @@ -27,7 +28,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_DISPLAY_OPTIONS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_DISPLAY_OPTIONS_BASE : public wxPanel +class PANEL_DISPLAY_OPTIONS_BASE : public RESETTABLE_PANEL { private: diff --git a/pcbnew/dialogs/panel_edit_options.cpp b/pcbnew/dialogs/panel_edit_options.cpp index f86939bbf7..e828b88ab8 100644 --- a/pcbnew/dialogs/panel_edit_options.cpp +++ b/pcbnew/dialogs/panel_edit_options.cpp @@ -51,6 +51,41 @@ PANEL_EDIT_OPTIONS::PANEL_EDIT_OPTIONS( wxWindow* aParent, bool isFootprintEdito } +void PANEL_EDIT_OPTIONS::loadPCBSettings( PCBNEW_SETTINGS* aCfg ) +{ + m_rotationAngle->SetValue( AngleToStringDegrees( (double) aCfg->m_RotationAngle ) ); + m_magneticPadChoice->SetSelection( static_cast( aCfg->m_MagneticItems.pads ) ); + m_magneticTrackChoice->SetSelection( static_cast( aCfg->m_MagneticItems.tracks ) ); + m_magneticGraphicsChoice->SetSelection( !aCfg->m_MagneticItems.graphics ); + m_flipLeftRight->SetValue( aCfg->m_FlipLeftRight ); + m_cbPcbGraphic45Mode->SetValue( aCfg->m_Use45DegreeLimit ); + + /* Set display options */ + m_OptDisplayCurvedRatsnestLines->SetValue( aCfg->m_Display.m_DisplayRatsnestLinesCurved ); + m_showSelectedRatsnest->SetValue( aCfg->m_Display.m_ShowModuleRatsnest ); + + switch( aCfg->m_TrackDragAction ) + { + case TRACK_DRAG_ACTION::MOVE: m_rbTrackDragMove->SetValue( true ); break; + case TRACK_DRAG_ACTION::DRAG: m_rbTrackDrag45->SetValue( true ); break; + case TRACK_DRAG_ACTION::DRAG_FREE_ANGLE: m_rbTrackDragFree->SetValue( true ); break; + } + + m_showPageLimits->SetValue( aCfg->m_ShowPageLimits ); + m_autoRefillZones->SetValue( aCfg->m_AutoRefillZones ); + m_allowFreePads->SetValue( aCfg->m_AllowFreePads ); +} + + +void PANEL_EDIT_OPTIONS::loadFPSettings( FOOTPRINT_EDITOR_SETTINGS* aCfg ) +{ + m_rotationAngle->SetValue( AngleToStringDegrees( (double) aCfg->m_RotationAngle ) ); + m_magneticPads->SetValue( aCfg->m_MagneticItems.pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS ); + m_magneticGraphics->SetValue( aCfg->m_MagneticItems.graphics ); + m_cbFpGraphic45Mode->SetValue( aCfg->m_Use45Limit ); +} + + bool PANEL_EDIT_OPTIONS::TransferDataToWindow() { SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); @@ -59,36 +94,13 @@ bool PANEL_EDIT_OPTIONS::TransferDataToWindow() { FOOTPRINT_EDITOR_SETTINGS* cfg = mgr.GetAppSettings(); - m_rotationAngle->SetValue( AngleToStringDegrees( (double) cfg->m_RotationAngle ) ); - m_magneticPads->SetValue( cfg->m_MagneticItems.pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS ); - m_magneticGraphics->SetValue( cfg->m_MagneticItems.graphics ); - m_cbFpGraphic45Mode->SetValue( cfg->m_Use45Limit ); + loadFPSettings( cfg ); } else { PCBNEW_SETTINGS* cfg = mgr.GetAppSettings(); - m_rotationAngle->SetValue( AngleToStringDegrees( (double) cfg->m_RotationAngle ) ); - m_magneticPadChoice->SetSelection( static_cast( cfg->m_MagneticItems.pads ) ); - m_magneticTrackChoice->SetSelection( static_cast( cfg->m_MagneticItems.tracks ) ); - m_magneticGraphicsChoice->SetSelection( !cfg->m_MagneticItems.graphics ); - m_flipLeftRight->SetValue( cfg->m_FlipLeftRight ); - m_cbPcbGraphic45Mode->SetValue( cfg->m_Use45DegreeLimit ); - - /* Set display options */ - m_OptDisplayCurvedRatsnestLines->SetValue( cfg->m_Display.m_DisplayRatsnestLinesCurved ); - m_showSelectedRatsnest->SetValue( cfg->m_Display.m_ShowModuleRatsnest ); - - switch( cfg->m_TrackDragAction ) - { - case TRACK_DRAG_ACTION::MOVE: m_rbTrackDragMove->SetValue( true ); break; - case TRACK_DRAG_ACTION::DRAG: m_rbTrackDrag45->SetValue( true ); break; - case TRACK_DRAG_ACTION::DRAG_FREE_ANGLE: m_rbTrackDragFree->SetValue( true ); break; - } - - m_showPageLimits->SetValue( cfg->m_ShowPageLimits ); - m_autoRefillZones->SetValue( cfg->m_AutoRefillZones ); - m_allowFreePads->SetValue( cfg->m_AllowFreePads ); + loadPCBSettings( cfg ); } return true; @@ -143,3 +155,22 @@ bool PANEL_EDIT_OPTIONS::TransferDataFromWindow() } +void PANEL_EDIT_OPTIONS::ResetPanel() +{ + if( m_isFootprintEditor ) + { + FOOTPRINT_EDITOR_SETTINGS cfg; + cfg.Load(); // Loading without a file will init to defaults + + loadFPSettings( &cfg ); + } + else + { + PCBNEW_SETTINGS cfg; + cfg.Load(); // Loading without a file will init to defaults + + loadPCBSettings( &cfg ); + } +} + + diff --git a/pcbnew/dialogs/panel_edit_options.h b/pcbnew/dialogs/panel_edit_options.h index f028263bb0..8f2670e102 100644 --- a/pcbnew/dialogs/panel_edit_options.h +++ b/pcbnew/dialogs/panel_edit_options.h @@ -28,15 +28,24 @@ #include "panel_edit_options_base.h" +class FOOTPRINT_EDITOR_SETTINGS; +class PCBNEW_SETTINGS; + + class PANEL_EDIT_OPTIONS : public PANEL_EDIT_OPTIONS_BASE { public: PANEL_EDIT_OPTIONS( wxWindow* aParent, bool isFootprintEditor ); -protected: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; + void ResetPanel() override; + +private: + void loadFPSettings( FOOTPRINT_EDITOR_SETTINGS* aCfg ); + void loadPCBSettings( PCBNEW_SETTINGS* aCfg ); + private: bool m_isFootprintEditor; }; diff --git a/pcbnew/dialogs/panel_edit_options_base.cpp b/pcbnew/dialogs/panel_edit_options_base.cpp index 04bd26226b..cf9ee15d9c 100644 --- a/pcbnew/dialogs/panel_edit_options_base.cpp +++ b/pcbnew/dialogs/panel_edit_options_base.cpp @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_EDIT_OPTIONS_BASE::PANEL_EDIT_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_EDIT_OPTIONS_BASE::PANEL_EDIT_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name ) { wxBoxSizer* bPanelSizer; bPanelSizer = new wxBoxSizer( wxHORIZONTAL ); diff --git a/pcbnew/dialogs/panel_edit_options_base.fbp b/pcbnew/dialogs/panel_edit_options_base.fbp index 971196dca6..7152192c5c 100644 --- a/pcbnew/dialogs/panel_edit_options_base.fbp +++ b/pcbnew/dialogs/panel_edit_options_base.fbp @@ -44,7 +44,7 @@ PANEL_EDIT_OPTIONS_BASE -1,-1 - ; forward_declare + RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare diff --git a/pcbnew/dialogs/panel_edit_options_base.h b/pcbnew/dialogs/panel_edit_options_base.h index 93db3a1f40..7769f8a5b4 100644 --- a/pcbnew/dialogs/panel_edit_options_base.h +++ b/pcbnew/dialogs/panel_edit_options_base.h @@ -10,6 +10,7 @@ #include #include #include +#include "widgets/resettable_panel.h" #include #include #include @@ -31,7 +32,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_EDIT_OPTIONS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_EDIT_OPTIONS_BASE : public wxPanel +class PANEL_EDIT_OPTIONS_BASE : public RESETTABLE_PANEL { private: diff --git a/pcbnew/dialogs/panel_fp_editor_defaults.cpp b/pcbnew/dialogs/panel_fp_editor_defaults.cpp index ca755ce63f..31f5ec4de5 100644 --- a/pcbnew/dialogs/panel_fp_editor_defaults.cpp +++ b/pcbnew/dialogs/panel_fp_editor_defaults.cpp @@ -215,7 +215,7 @@ PANEL_FP_EDITOR_DEFAULTS::~PANEL_FP_EDITOR_DEFAULTS() } -bool PANEL_FP_EDITOR_DEFAULTS::TransferDataToWindow() +void PANEL_FP_EDITOR_DEFAULTS::loadFPSettings( FOOTPRINT_EDITOR_SETTINGS* aCfg ) { wxColour disabledColour = wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ); @@ -226,12 +226,9 @@ bool PANEL_FP_EDITOR_DEFAULTS::TransferDataToWindow() m_graphicsGrid->SetReadOnly( row, col ); \ m_graphicsGrid->SetCellBackgroundColour( row, col, disabledColour ); - SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); - FOOTPRINT_EDITOR_SETTINGS* cfg = mgr.GetAppSettings(); - for( int i = 0; i < ROW_COUNT; ++i ) { - SET_MILS_CELL( i, COL_LINE_THICKNESS, cfg->m_DesignSettings.m_LineThickness[ i ] ); + SET_MILS_CELL( i, COL_LINE_THICKNESS, aCfg->m_DesignSettings.m_LineThickness[ i ] ); if( i == ROW_EDGES || i == ROW_COURTYARD ) { @@ -242,10 +239,10 @@ bool PANEL_FP_EDITOR_DEFAULTS::TransferDataToWindow() } else { - SET_MILS_CELL( i, COL_TEXT_WIDTH, cfg->m_DesignSettings.m_TextSize[ i ].x ); - SET_MILS_CELL( i, COL_TEXT_HEIGHT, cfg->m_DesignSettings.m_TextSize[ i ].y ); - SET_MILS_CELL( i, COL_TEXT_THICKNESS, cfg->m_DesignSettings.m_TextThickness[ i ] ); - m_graphicsGrid->SetCellValue( i, COL_TEXT_ITALIC, cfg->m_DesignSettings.m_TextItalic[ i ] ? "1" : "" ); + SET_MILS_CELL( i, COL_TEXT_WIDTH, aCfg->m_DesignSettings.m_TextSize[ i ].x ); + SET_MILS_CELL( i, COL_TEXT_HEIGHT, aCfg->m_DesignSettings.m_TextSize[ i ].y ); + SET_MILS_CELL( i, COL_TEXT_THICKNESS, aCfg->m_DesignSettings.m_TextThickness[ i ] ); + m_graphicsGrid->SetCellValue( i, COL_TEXT_ITALIC, aCfg->m_DesignSettings.m_TextItalic[ i ] ? "1" : "" ); auto attr = new wxGridCellAttr; attr->SetRenderer( new wxGridCellBoolRenderer() ); @@ -256,11 +253,12 @@ bool PANEL_FP_EDITOR_DEFAULTS::TransferDataToWindow() } // Footprint defaults - m_textItemsGrid->GetTable()->AppendRows( cfg->m_DesignSettings.m_DefaultFPTextItems.size() ); + m_textItemsGrid->GetTable()->DeleteRows( 0, m_textItemsGrid->GetNumberRows() ); + m_textItemsGrid->GetTable()->AppendRows( aCfg->m_DesignSettings.m_DefaultFPTextItems.size() ); - for( size_t i = 0; i < cfg->m_DesignSettings.m_DefaultFPTextItems.size(); ++i ) + for( size_t i = 0; i < aCfg->m_DesignSettings.m_DefaultFPTextItems.size(); ++i ) { - TEXT_ITEM_INFO item = cfg->m_DesignSettings.m_DefaultFPTextItems[i]; + TEXT_ITEM_INFO item = aCfg->m_DesignSettings.m_DefaultFPTextItems[i]; m_textItemsGrid->GetTable()->SetValue( i, 0, item.m_Text ); m_textItemsGrid->GetTable()->SetValueAsBool( i, 1, item.m_Visible ); @@ -280,6 +278,15 @@ bool PANEL_FP_EDITOR_DEFAULTS::TransferDataToWindow() m_graphicsGrid->SetRowLabelSize( m_graphicsGrid->GetVisibleWidth( -1, true, true, true ) ); Layout(); +} + + +bool PANEL_FP_EDITOR_DEFAULTS::TransferDataToWindow() +{ + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + FOOTPRINT_EDITOR_SETTINGS* cfg = mgr.GetAppSettings(); + + loadFPSettings( cfg ); return true; } @@ -438,3 +445,12 @@ void PANEL_FP_EDITOR_DEFAULTS::OnDeleteTextItem( wxCommandEvent& event ) } +void PANEL_FP_EDITOR_DEFAULTS::ResetPanel() +{ + FOOTPRINT_EDITOR_SETTINGS cfg; + cfg.Load(); // Loading without a file will init to defaults + + loadFPSettings( &cfg ); +} + + diff --git a/pcbnew/dialogs/panel_fp_editor_defaults.h b/pcbnew/dialogs/panel_fp_editor_defaults.h index 5404295d0d..5c1d501d86 100644 --- a/pcbnew/dialogs/panel_fp_editor_defaults.h +++ b/pcbnew/dialogs/panel_fp_editor_defaults.h @@ -23,6 +23,7 @@ #include class PAGED_DIALOG; +class FOOTPRINT_EDITOR_SETTINGS; class PANEL_FP_EDITOR_DEFAULTS : public PANEL_FP_EDITOR_DEFAULTS_BASE @@ -31,6 +32,11 @@ public: PANEL_FP_EDITOR_DEFAULTS( wxWindow* aParent, EDA_BASE_FRAME* aUnitsProvider ); ~PANEL_FP_EDITOR_DEFAULTS() override; + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; + + void ResetPanel() override; + private: virtual void OnAddTextItem( wxCommandEvent& event ) override; virtual void OnDeleteTextItem( wxCommandEvent& event ) override; @@ -41,8 +47,7 @@ private: bool validateData(); - bool TransferDataToWindow() override; - bool TransferDataFromWindow() override; + void loadFPSettings( FOOTPRINT_EDITOR_SETTINGS* aCfg ); private: EDA_UNITS m_units = EDA_UNITS::MILLIMETRES; diff --git a/pcbnew/dialogs/panel_fp_editor_defaults_base.cpp b/pcbnew/dialogs/panel_fp_editor_defaults_base.cpp index 8bb5325fed..c339e179e0 100644 --- a/pcbnew/dialogs/panel_fp_editor_defaults_base.cpp +++ b/pcbnew/dialogs/panel_fp_editor_defaults_base.cpp @@ -11,7 +11,7 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_FP_EDITOR_DEFAULTS_BASE::PANEL_FP_EDITOR_DEFAULTS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_FP_EDITOR_DEFAULTS_BASE::PANEL_FP_EDITOR_DEFAULTS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name ) { wxBoxSizer* bSizerMain; bSizerMain = new wxBoxSizer( wxVERTICAL ); diff --git a/pcbnew/dialogs/panel_fp_editor_defaults_base.fbp b/pcbnew/dialogs/panel_fp_editor_defaults_base.fbp index 3eadadf40f..0cd96faa9c 100644 --- a/pcbnew/dialogs/panel_fp_editor_defaults_base.fbp +++ b/pcbnew/dialogs/panel_fp_editor_defaults_base.fbp @@ -44,7 +44,7 @@ PANEL_FP_EDITOR_DEFAULTS_BASE -1,-1 - ; forward_declare + RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare diff --git a/pcbnew/dialogs/panel_fp_editor_defaults_base.h b/pcbnew/dialogs/panel_fp_editor_defaults_base.h index 7f90675599..930aa6874c 100644 --- a/pcbnew/dialogs/panel_fp_editor_defaults_base.h +++ b/pcbnew/dialogs/panel_fp_editor_defaults_base.h @@ -12,6 +12,7 @@ #include class WX_GRID; +#include "widgets/resettable_panel.h" #include #include #include @@ -33,7 +34,7 @@ class WX_GRID; /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_FP_EDITOR_DEFAULTS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_FP_EDITOR_DEFAULTS_BASE : public wxPanel +class PANEL_FP_EDITOR_DEFAULTS_BASE : public RESETTABLE_PANEL { private: diff --git a/pcbnew/dialogs/panel_pcbnew_display_origin.cpp b/pcbnew/dialogs/panel_pcbnew_display_origin.cpp index 2e28d0179a..3113c3902f 100644 --- a/pcbnew/dialogs/panel_pcbnew_display_origin.cpp +++ b/pcbnew/dialogs/panel_pcbnew_display_origin.cpp @@ -34,12 +34,11 @@ PANEL_PCBNEW_DISPLAY_ORIGIN::PANEL_PCBNEW_DISPLAY_ORIGIN( wxWindow* aParent ) : } -bool PANEL_PCBNEW_DISPLAY_ORIGIN::TransferDataToWindow() +void PANEL_PCBNEW_DISPLAY_ORIGIN::loadPCBSettings( PCBNEW_SETTINGS* aCfg ) { - PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); - int origin = 0; + int origin = 0; - switch( cfg->m_Display.m_DisplayOrigin ) + switch( aCfg->m_Display.m_DisplayOrigin ) { case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_PAGE: origin = 0; break; case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_AUX: origin = 1; break; @@ -47,8 +46,16 @@ bool PANEL_PCBNEW_DISPLAY_ORIGIN::TransferDataToWindow() } m_DisplayOrigin->SetSelection( origin ); - m_XAxisDirection->SetSelection( cfg->m_Display.m_DisplayInvertXAxis ? 1 : 0 ); - m_YAxisDirection->SetSelection( cfg->m_Display.m_DisplayInvertYAxis ? 0 : 1 ); + m_XAxisDirection->SetSelection( aCfg->m_Display.m_DisplayInvertXAxis ? 1 : 0 ); + m_YAxisDirection->SetSelection( aCfg->m_Display.m_DisplayInvertYAxis ? 0 : 1 ); +} + + +bool PANEL_PCBNEW_DISPLAY_ORIGIN::TransferDataToWindow() +{ + PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); + + loadPCBSettings( cfg ); return true; } @@ -70,3 +77,14 @@ bool PANEL_PCBNEW_DISPLAY_ORIGIN::TransferDataFromWindow() return true; } + + +void PANEL_PCBNEW_DISPLAY_ORIGIN::ResetPanel() +{ + PCBNEW_SETTINGS cfg; + cfg.Load(); // Loading without a file will init to defaults + + loadPCBSettings( &cfg ); +} + + diff --git a/pcbnew/dialogs/panel_pcbnew_display_origin.h b/pcbnew/dialogs/panel_pcbnew_display_origin.h index 76cb198fd3..1c2e57ce44 100644 --- a/pcbnew/dialogs/panel_pcbnew_display_origin.h +++ b/pcbnew/dialogs/panel_pcbnew_display_origin.h @@ -33,9 +33,13 @@ class PANEL_PCBNEW_DISPLAY_ORIGIN : public PANEL_PCBNEW_DISPLAY_ORIGIN_BASE public: PANEL_PCBNEW_DISPLAY_ORIGIN( wxWindow* aParent ); -protected: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; + + void ResetPanel() override; + +private: + void loadPCBSettings( PCBNEW_SETTINGS* aCfg ); }; diff --git a/pcbnew/dialogs/panel_pcbnew_display_origin_base.cpp b/pcbnew/dialogs/panel_pcbnew_display_origin_base.cpp index 2d64557880..726ee05c91 100644 --- a/pcbnew/dialogs/panel_pcbnew_display_origin_base.cpp +++ b/pcbnew/dialogs/panel_pcbnew_display_origin_base.cpp @@ -9,7 +9,7 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_PCBNEW_DISPLAY_ORIGIN_BASE::PANEL_PCBNEW_DISPLAY_ORIGIN_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_PCBNEW_DISPLAY_ORIGIN_BASE::PANEL_PCBNEW_DISPLAY_ORIGIN_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name ) { wxBoxSizer* bPanelSizer; bPanelSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -62,6 +62,7 @@ PANEL_PCBNEW_DISPLAY_ORIGIN_BASE::PANEL_PCBNEW_DISPLAY_ORIGIN_BASE( wxWindow* pa this->SetSizer( bPanelSizer ); this->Layout(); + bPanelSizer->Fit( this ); } PANEL_PCBNEW_DISPLAY_ORIGIN_BASE::~PANEL_PCBNEW_DISPLAY_ORIGIN_BASE() diff --git a/pcbnew/dialogs/panel_pcbnew_display_origin_base.fbp b/pcbnew/dialogs/panel_pcbnew_display_origin_base.fbp index 569553311c..2ba1f6dbc1 100644 --- a/pcbnew/dialogs/panel_pcbnew_display_origin_base.fbp +++ b/pcbnew/dialogs/panel_pcbnew_display_origin_base.fbp @@ -43,8 +43,8 @@ PANEL_PCBNEW_DISPLAY_ORIGIN_BASE - 500,300 - ; ; forward_declare + -1,-1 + RESETTABLE_PANEL; widgets/resettable_panel.h; forward_declare diff --git a/pcbnew/dialogs/panel_pcbnew_display_origin_base.h b/pcbnew/dialogs/panel_pcbnew_display_origin_base.h index 4996161975..f627409f13 100644 --- a/pcbnew/dialogs/panel_pcbnew_display_origin_base.h +++ b/pcbnew/dialogs/panel_pcbnew_display_origin_base.h @@ -10,6 +10,7 @@ #include #include #include +#include "widgets/resettable_panel.h" #include #include #include @@ -24,7 +25,7 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_PCBNEW_DISPLAY_ORIGIN_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_PCBNEW_DISPLAY_ORIGIN_BASE : public wxPanel +class PANEL_PCBNEW_DISPLAY_ORIGIN_BASE : public RESETTABLE_PANEL { private: @@ -35,7 +36,7 @@ class PANEL_PCBNEW_DISPLAY_ORIGIN_BASE : public wxPanel public: - PANEL_PCBNEW_DISPLAY_ORIGIN_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + PANEL_PCBNEW_DISPLAY_ORIGIN_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); ~PANEL_PCBNEW_DISPLAY_ORIGIN_BASE(); };