diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp index a328f186f0..8bfb453d48 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include "eda_3d_viewer_frame.h" #include #include <3d_viewer_id.h> @@ -49,12 +48,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include #include /** @@ -228,21 +221,6 @@ void EDA_3D_VIEWER_FRAME::setupUIConditions() } -void EDA_3D_VIEWER_FRAME::InstallPreferences( PAGED_DIALOG* aParent, - PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) -{ - wxTreebook* book = aParent->GetTreebook(); - - book->AddPage( new wxPanel( book ), _( "3D Viewer" ) ); - book->AddSubPage( new PANEL_3D_DISPLAY_OPTIONS( this, book ), _( "General" ) ); - book->AddSubPage( new PANEL_3D_OPENGL_OPTIONS( this, book ), _( "Realtime Renderer" ) ); - book->AddSubPage( new PANEL_3D_RAYTRACING_OPTIONS( this, book ), _( "Raytracing Renderer" ) ); - book->AddSubPage( new PANEL_3D_COLORS( this, book ), _( "Colors" ) ); - - aHotkeysPanel->AddHotKeys( GetToolManager() ); -} - - void EDA_3D_VIEWER_FRAME::ReloadRequest() { // This will schedule a request to load later @@ -632,6 +610,7 @@ void EDA_3D_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTex ReCreateMainToolbar(); loadCommonSettings(); + LoadSettings( Pgm().GetSettingsManager().GetAppSettings() ); NewDisplay( true ); } diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_frame.h b/3d-viewer/3d_viewer/eda_3d_viewer_frame.h index 7a0d6d8f6f..ff2ca577da 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_frame.h +++ b/3d-viewer/3d_viewer/eda_3d_viewer_frame.h @@ -73,8 +73,6 @@ public: wxWindow* GetToolCanvas() const override { return m_canvas; } - void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override; - /** * Request reloading the 3D view. * diff --git a/3d-viewer/dialogs/panel_3D_colors.cpp b/3d-viewer/dialogs/panel_3D_colors.cpp index b064c1e47a..00847fcbe2 100644 --- a/3d-viewer/dialogs/panel_3D_colors.cpp +++ b/3d-viewer/dialogs/panel_3D_colors.cpp @@ -27,31 +27,30 @@ #include -PANEL_3D_COLORS::PANEL_3D_COLORS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent ) : - PANEL_3D_COLORS_BASE( aParent ), - m_boardAdapter( aFrame->GetAdapter() ) +PANEL_3D_COLORS::PANEL_3D_COLORS( wxWindow* aParent ) : + PANEL_3D_COLORS_BASE( aParent ) { - m_backgroundTop->SetDefaultColor( m_boardAdapter.g_DefaultBackgroundTop ); - m_backgroundBottom->SetDefaultColor( m_boardAdapter.g_DefaultBackgroundBot ); + m_backgroundTop->SetDefaultColor( BOARD_ADAPTER::g_DefaultBackgroundTop ); + m_backgroundBottom->SetDefaultColor( BOARD_ADAPTER::g_DefaultBackgroundBot ); - m_silkscreenTop->SetUserColors( &m_boardAdapter.g_SilkscreenColors ); - m_silkscreenTop->SetDefaultColor( m_boardAdapter.g_DefaultSilkscreen ); - m_silkscreenBottom->SetUserColors( &m_boardAdapter.g_SilkscreenColors ); - m_silkscreenBottom->SetDefaultColor( m_boardAdapter.g_DefaultSilkscreen ); + m_silkscreenTop->SetUserColors( &BOARD_ADAPTER::g_SilkscreenColors ); + m_silkscreenTop->SetDefaultColor( BOARD_ADAPTER::g_DefaultSilkscreen ); + m_silkscreenBottom->SetUserColors( &BOARD_ADAPTER::g_SilkscreenColors ); + m_silkscreenBottom->SetDefaultColor( BOARD_ADAPTER::g_DefaultSilkscreen ); - m_solderMaskTop->SetUserColors( &m_boardAdapter.g_MaskColors ); - m_solderMaskTop->SetDefaultColor( m_boardAdapter.g_DefaultSolderMask ); - m_solderMaskBottom->SetUserColors( &m_boardAdapter.g_MaskColors ); - m_solderMaskBottom->SetDefaultColor( m_boardAdapter.g_DefaultSolderMask ); + m_solderMaskTop->SetUserColors( &BOARD_ADAPTER::g_MaskColors ); + m_solderMaskTop->SetDefaultColor( BOARD_ADAPTER::g_DefaultSolderMask ); + m_solderMaskBottom->SetUserColors( &BOARD_ADAPTER::g_MaskColors ); + m_solderMaskBottom->SetDefaultColor( BOARD_ADAPTER::g_DefaultSolderMask ); - m_solderPaste->SetUserColors( &m_boardAdapter.g_PasteColors ); - m_solderPaste->SetDefaultColor( m_boardAdapter.g_DefaultSolderPaste ); + m_solderPaste->SetUserColors( &BOARD_ADAPTER::g_PasteColors ); + m_solderPaste->SetDefaultColor( BOARD_ADAPTER::g_DefaultSolderPaste ); - m_surfaceFinish->SetUserColors( &m_boardAdapter.g_FinishColors ); - m_surfaceFinish->SetDefaultColor( m_boardAdapter.g_DefaultSurfaceFinish ); + m_surfaceFinish->SetUserColors( &BOARD_ADAPTER::g_FinishColors ); + m_surfaceFinish->SetDefaultColor( BOARD_ADAPTER::g_DefaultSurfaceFinish ); - m_boardBody->SetUserColors( &m_boardAdapter.g_BoardColors ); - m_boardBody->SetDefaultColor( m_boardAdapter.g_DefaultBoardBody ); + m_boardBody->SetUserColors( &BOARD_ADAPTER::g_BoardColors ); + m_boardBody->SetDefaultColor( BOARD_ADAPTER::g_DefaultBoardBody ); } diff --git a/3d-viewer/dialogs/panel_3D_colors.h b/3d-viewer/dialogs/panel_3D_colors.h index 096696e24a..a26348ca39 100644 --- a/3d-viewer/dialogs/panel_3D_colors.h +++ b/3d-viewer/dialogs/panel_3D_colors.h @@ -30,16 +30,13 @@ class PANEL_3D_COLORS : public PANEL_3D_COLORS_BASE { public: - explicit PANEL_3D_COLORS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent ); + 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; - -private: - BOARD_ADAPTER& m_boardAdapter; }; diff --git a/3d-viewer/dialogs/panel_3D_display_options.cpp b/3d-viewer/dialogs/panel_3D_display_options.cpp index b179953807..292d976b36 100644 --- a/3d-viewer/dialogs/panel_3D_display_options.cpp +++ b/3d-viewer/dialogs/panel_3D_display_options.cpp @@ -22,18 +22,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include +#include +#include #include "panel_3D_display_options.h" -#include <3d_canvas/board_adapter.h> -#include <3d_viewer/eda_3d_viewer_frame.h> -#include <3d_viewer/tools/eda_3d_controller.h> -#include -PANEL_3D_DISPLAY_OPTIONS::PANEL_3D_DISPLAY_OPTIONS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent ) : - PANEL_3D_DISPLAY_OPTIONS_BASE( aParent ), - m_frame( aFrame ), - m_settings( aFrame->GetAdapter() ), - m_canvas( aFrame->GetCanvas() ) +PANEL_3D_DISPLAY_OPTIONS::PANEL_3D_DISPLAY_OPTIONS( wxWindow* aParent ) : + PANEL_3D_DISPLAY_OPTIONS_BASE( aParent ) { } @@ -47,38 +43,30 @@ void PANEL_3D_DISPLAY_OPTIONS::OnCheckEnableAnimation( wxCommandEvent& event ) bool PANEL_3D_DISPLAY_OPTIONS::TransferDataToWindow() { + EDA_3D_VIEWER_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); + // Check/uncheck checkboxes - m_checkBoxRealisticMode->SetValue( m_settings.GetFlag( FL_USE_REALISTIC_MODE ) ); - m_checkBoxBoardBody->SetValue( m_settings.GetFlag( FL_SHOW_BOARD_BODY ) ); - m_checkBoxAreas->SetValue( m_settings.GetFlag( FL_ZONE ) ); + 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_checkBoxSilkscreen->SetValue( m_settings.GetFlag( FL_SILKSCREEN ) ); - m_checkBoxSolderMask->SetValue( m_settings.GetFlag( FL_SOLDERMASK ) ); - m_checkBoxSolderpaste->SetValue( m_settings.GetFlag( FL_SOLDERPASTE ) ); - m_checkBoxAdhesive->SetValue( m_settings.GetFlag( FL_ADHESIVE ) ); - m_checkBoxComments->SetValue( m_settings.GetFlag( FL_COMMENTS ) ); - m_checkBoxECO->SetValue( m_settings.GetFlag( FL_ECO ) ); - m_checkBoxSubtractMaskFromSilk->SetValue( m_settings.GetFlag( FL_SUBTRACT_MASK_FROM_SILK ) ); - m_checkBoxClipSilkOnViaAnnulus->SetValue( m_settings.GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) ); - m_checkBoxRenderPlatedPadsAsPlated->SetValue( - m_settings.GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) ); - - switch( m_settings.GetMaterialMode() ) - { - default: - case MATERIAL_MODE::NORMAL: m_materialProperties->SetSelection( 0 ); break; - case MATERIAL_MODE::DIFFUSE_ONLY: m_materialProperties->SetSelection( 1 ); break; - case MATERIAL_MODE::CAD_MODE: m_materialProperties->SetSelection( 2 ); break; - } + m_materialProperties->SetSelection( cfg->m_Render.material_mode ); // Camera Options - m_checkBoxEnableAnimation->SetValue( m_canvas->GetAnimationEnabled() ); - m_sliderAnimationSpeed->SetValue( m_canvas->GetMovingSpeedMultiplier() ); - m_staticAnimationSpeed->Enable( m_canvas->GetAnimationEnabled() ); - m_sliderAnimationSpeed->Enable( m_canvas->GetAnimationEnabled() ); - - EDA_3D_CONTROLLER* ctrlTool = m_frame->GetToolManager()->GetTool(); - m_spinCtrlRotationAngle->SetValue( ctrlTool->GetRotationIncrement() ); + 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 ); return true; } @@ -86,41 +74,32 @@ bool PANEL_3D_DISPLAY_OPTIONS::TransferDataToWindow() bool PANEL_3D_DISPLAY_OPTIONS::TransferDataFromWindow() { + EDA_3D_VIEWER_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); + // Set render mode - m_settings.SetFlag( FL_USE_REALISTIC_MODE, m_checkBoxRealisticMode->GetValue() ); + cfg->m_Render.realistic = m_checkBoxRealisticMode->GetValue(); // Set visibility of items - m_settings.SetFlag( FL_SHOW_BOARD_BODY, m_checkBoxBoardBody->GetValue() ); - m_settings.SetFlag( FL_ZONE, m_checkBoxAreas->GetValue() ); - m_settings.SetFlag( FL_SUBTRACT_MASK_FROM_SILK, m_checkBoxSubtractMaskFromSilk->GetValue() ); - m_settings.SetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS, m_checkBoxClipSilkOnViaAnnulus->GetValue() ); - m_settings.SetFlag( FL_RENDER_PLATED_PADS_AS_PLATED, - m_checkBoxRenderPlatedPadsAsPlated->GetValue() ); + cfg->m_Render.show_board_body = m_checkBoxBoardBody->GetValue(); + cfg->m_Render.show_zones = m_checkBoxAreas->GetValue(); + cfg->m_Render.subtract_mask_from_silk = m_checkBoxSubtractMaskFromSilk->GetValue(); + cfg->m_Render.clip_silk_on_via_annulus = m_checkBoxClipSilkOnViaAnnulus->GetValue(); + cfg->m_Render.renderPlatedPadsAsPlated = m_checkBoxRenderPlatedPadsAsPlated->GetValue(); - switch( m_materialProperties->GetSelection() ) - { - default: - case 0: m_settings.SetMaterialMode( MATERIAL_MODE::NORMAL ); break; - case 1: m_settings.SetMaterialMode( MATERIAL_MODE::DIFFUSE_ONLY ); break; - case 2: m_settings.SetMaterialMode( MATERIAL_MODE::CAD_MODE ); break; - } + cfg->m_Render.material_mode = m_materialProperties->GetSelection(); // Set Layer visibility - m_settings.SetFlag( FL_SILKSCREEN, m_checkBoxSilkscreen->GetValue() ); - m_settings.SetFlag( FL_SOLDERMASK, m_checkBoxSolderMask->GetValue() ); - m_settings.SetFlag( FL_SOLDERPASTE, m_checkBoxSolderpaste->GetValue() ); - m_settings.SetFlag( FL_ADHESIVE, m_checkBoxAdhesive->GetValue() ); - m_settings.SetFlag( FL_COMMENTS, m_checkBoxComments->GetValue() ); - m_settings.SetFlag( FL_ECO, m_checkBoxECO->GetValue( ) ); + cfg->m_Render.show_silkscreen = m_checkBoxSilkscreen->GetValue(); + cfg->m_Render.show_soldermask = m_checkBoxSolderMask->GetValue(); + cfg->m_Render.show_solderpaste = m_checkBoxSolderpaste->GetValue(); + cfg->m_Render.show_adhesive = m_checkBoxAdhesive->GetValue(); + cfg->m_Render.show_comments = m_checkBoxComments->GetValue(); + cfg->m_Render.show_eco = m_checkBoxECO->GetValue( ); // Camera Options - m_canvas->SetAnimationEnabled( m_checkBoxEnableAnimation->GetValue()); - m_canvas->SetMovingSpeedMultiplier( m_sliderAnimationSpeed->GetValue()); - - EDA_3D_CONTROLLER* ctrlTool = m_frame->GetToolManager()->GetTool(); - ctrlTool->SetRotationIncrement( m_spinCtrlRotationAngle->GetValue() ); - - // The 3D scene will be rebuilt by the caller + cfg->m_Camera.animation_enabled = m_checkBoxEnableAnimation->GetValue(); + cfg->m_Camera.moving_speed_multiplier = m_sliderAnimationSpeed->GetValue(); + cfg->m_Camera.rotation_increment = m_spinCtrlRotationAngle->GetValue(); return true; } diff --git a/3d-viewer/dialogs/panel_3D_display_options.h b/3d-viewer/dialogs/panel_3D_display_options.h index 85f6027006..c1e8bb910c 100644 --- a/3d-viewer/dialogs/panel_3D_display_options.h +++ b/3d-viewer/dialogs/panel_3D_display_options.h @@ -32,7 +32,7 @@ class PANEL_3D_DISPLAY_OPTIONS : public PANEL_3D_DISPLAY_OPTIONS_BASE { public: - explicit PANEL_3D_DISPLAY_OPTIONS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent ); + explicit PANEL_3D_DISPLAY_OPTIONS( wxWindow* aParent ); void OnCheckEnableAnimation( wxCommandEvent& WXUNUSED( event ) ) override; @@ -41,13 +41,6 @@ public: /// Automatically called after creating the dialog bool TransferDataToWindow() override; - - void TransferColorDataToWindow(); - -private: - EDA_3D_VIEWER_FRAME* m_frame; - BOARD_ADAPTER& m_settings; - EDA_3D_CANVAS* m_canvas; }; diff --git a/3d-viewer/dialogs/panel_3D_opengl_options.cpp b/3d-viewer/dialogs/panel_3D_opengl_options.cpp index 418af7d563..c122d42bed 100644 --- a/3d-viewer/dialogs/panel_3D_opengl_options.cpp +++ b/3d-viewer/dialogs/panel_3D_opengl_options.cpp @@ -22,16 +22,15 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "panel_3D_opengl_options.h" +#include +#include +#include #include -#include <3d_canvas/board_adapter.h> -#include <3d_viewer/eda_3d_viewer_frame.h> -#include <3d_viewer/tools/eda_3d_controller.h> +#include "panel_3D_opengl_options.h" -PANEL_3D_OPENGL_OPTIONS::PANEL_3D_OPENGL_OPTIONS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent ) : - PANEL_3D_OPENGL_OPTIONS_BASE( aParent ), - m_settings( aFrame->GetAdapter() ), - m_canvas( aFrame->GetCanvas() ) + +PANEL_3D_OPENGL_OPTIONS::PANEL_3D_OPENGL_OPTIONS( wxWindow* aParent ) : + PANEL_3D_OPENGL_OPTIONS_BASE( aParent ) { m_selectionColorSwatch->SetDefaultColor( COLOR4D( 0.0, 1.0, 0.0, 1.0 ) ); m_selectionColorSwatch->SetSupportsOpacity( false ); @@ -40,25 +39,19 @@ PANEL_3D_OPENGL_OPTIONS::PANEL_3D_OPENGL_OPTIONS( EDA_3D_VIEWER_FRAME* aFrame, w bool PANEL_3D_OPENGL_OPTIONS::TransferDataToWindow() { - m_checkBoxCuThickness->SetValue( m_settings.GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) ); - m_checkBoxBoundingBoxes->SetValue( m_settings.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) ); - m_checkBoxHighlightOnRollOver->SetValue( m_settings.GetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM ) ); + EDA_3D_VIEWER_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); - m_choiceAntiAliasing->SetSelection( static_cast( m_settings.GetAntiAliasingMode() ) ); - m_selectionColorSwatch->SetSwatchColor( COLOR4D( m_settings.m_OpenGlSelectionColor.r, - m_settings.m_OpenGlSelectionColor.g, - m_settings.m_OpenGlSelectionColor.b, - 1.0 ), - false ); + 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_checkBoxDisableAAMove->SetValue( - m_settings.GetFlag( FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE ) ); - m_checkBoxDisableMoveThickness->SetValue( - m_settings.GetFlag( FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE ) ); - m_checkBoxDisableMoveVias->SetValue( - m_settings.GetFlag( FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE ) ); - m_checkBoxDisableMoveHoles->SetValue( - m_settings.GetFlag( FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE ) ); + 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 ); return true; } @@ -66,24 +59,19 @@ bool PANEL_3D_OPENGL_OPTIONS::TransferDataToWindow() bool PANEL_3D_OPENGL_OPTIONS::TransferDataFromWindow() { - m_settings.SetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS, m_checkBoxCuThickness->GetValue() ); - m_settings.SetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX, m_checkBoxBoundingBoxes->GetValue() ); - m_settings.SetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM, m_checkBoxHighlightOnRollOver->GetValue() ); + EDA_3D_VIEWER_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); - m_settings.SetAntiAliasingMode( - static_cast( m_choiceAntiAliasing->GetSelection() ) ); - m_settings.m_OpenGlSelectionColor = SFVEC3F( m_selectionColorSwatch->GetSwatchColor().r, - m_selectionColorSwatch->GetSwatchColor().g, - m_selectionColorSwatch->GetSwatchColor().b ); + cfg->m_Render.opengl_copper_thickness = m_checkBoxCuThickness->GetValue(); + cfg->m_Render.opengl_show_model_bbox = m_checkBoxBoundingBoxes->GetValue(); + cfg->m_Render.opengl_highlight_on_rollover = m_checkBoxHighlightOnRollOver->GetValue(); - m_settings.SetFlag( FL_RENDER_OPENGL_AA_DISABLE_ON_MOVE, - m_checkBoxDisableAAMove->GetValue() ); - m_settings.SetFlag( FL_RENDER_OPENGL_THICKNESS_DISABLE_ON_MOVE, - m_checkBoxDisableMoveThickness->GetValue() ); - m_settings.SetFlag( FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE, - m_checkBoxDisableMoveVias->GetValue() ); - m_settings.SetFlag( FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE, - m_checkBoxDisableMoveHoles->GetValue() ); + cfg->m_Render.opengl_AA_mode = m_choiceAntiAliasing->GetSelection(); + cfg->m_Render.opengl_selection_color = m_selectionColorSwatch->GetSwatchColor(); + + cfg->m_Render.opengl_AA_disableOnMove = m_checkBoxDisableAAMove->GetValue(); + cfg->m_Render.opengl_thickness_disableOnMove = m_checkBoxDisableMoveThickness->GetValue(); + cfg->m_Render.opengl_vias_disableOnMove = m_checkBoxDisableMoveVias->GetValue(); + cfg->m_Render.opengl_holes_disableOnMove = m_checkBoxDisableMoveHoles->GetValue(); return true; } diff --git a/3d-viewer/dialogs/panel_3D_opengl_options.h b/3d-viewer/dialogs/panel_3D_opengl_options.h index 1a42469a27..8ed3aa7822 100644 --- a/3d-viewer/dialogs/panel_3D_opengl_options.h +++ b/3d-viewer/dialogs/panel_3D_opengl_options.h @@ -31,17 +31,13 @@ class PANEL_3D_OPENGL_OPTIONS : public PANEL_3D_OPENGL_OPTIONS_BASE { public: - explicit PANEL_3D_OPENGL_OPTIONS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent ); + 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; - -private: - BOARD_ADAPTER& m_settings; - EDA_3D_CANVAS* m_canvas; }; diff --git a/3d-viewer/dialogs/panel_3D_raytracing_options.cpp b/3d-viewer/dialogs/panel_3D_raytracing_options.cpp index ad1a00c9ba..44a60e4ef0 100644 --- a/3d-viewer/dialogs/panel_3D_raytracing_options.cpp +++ b/3d-viewer/dialogs/panel_3D_raytracing_options.cpp @@ -22,28 +22,26 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include +#include +#include #include "panel_3D_raytracing_options.h" -#include <3d_canvas/board_adapter.h> -#include <3d_viewer/eda_3d_viewer_frame.h> -#include <3d_viewer/tools/eda_3d_controller.h> -#include -#include -PANEL_3D_RAYTRACING_OPTIONS::PANEL_3D_RAYTRACING_OPTIONS( EDA_3D_VIEWER_FRAME* aFrame, - wxWindow* aParent ) : - PANEL_3D_RAYTRACING_OPTIONS_BASE( aParent ), - m_settings( aFrame->GetAdapter() ), - m_canvas( aFrame->GetCanvas() ) +PANEL_3D_RAYTRACING_OPTIONS::PANEL_3D_RAYTRACING_OPTIONS( wxWindow* aParent ) : + PANEL_3D_RAYTRACING_OPTIONS_BASE( aParent ) { } void PANEL_3D_RAYTRACING_OPTIONS::ResetPanel() { - m_settings.m_RtCameraLightColor = SFVEC3F( 0.2f ); - m_settings.m_RtLightColorTop = SFVEC3F( 0.247f ); - m_settings.m_RtLightColorBottom = SFVEC3F( 0.247f ); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings(); + + 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 ); const std::vector default_elevation = { @@ -55,14 +53,10 @@ void PANEL_3D_RAYTRACING_OPTIONS::ResetPanel() 45, 135, 225, 315, 45, 135, 225, 315, }; - for( size_t i = 0; i < m_settings.m_RtLightSphericalCoords.size(); ++i ) + for( size_t i = 0; i < 8; ++i ) { - m_settings.m_RtLightColor[i] = SFVEC3F( 0.168f ); - - m_settings.m_RtLightSphericalCoords[i].x = - ( (float) default_elevation[i] + 90.0f ) / 180.0f; - - m_settings.m_RtLightSphericalCoords[i].y = (float) default_azimuth[i] / 180.0f; + cfg->m_Render.raytrace_lightElevation[i] = default_elevation[i]; + cfg->m_Render.raytrace_lightAzimuth[i] = default_azimuth[i]; } TransferColorDataToWindow(); @@ -71,91 +65,83 @@ void PANEL_3D_RAYTRACING_OPTIONS::ResetPanel() void PANEL_3D_RAYTRACING_OPTIONS::TransferColorDataToWindow() { - auto transfer_color = [] ( const SFVEC3F& aSource, COLOR_SWATCH *aTarget ) - { - aTarget->SetSupportsOpacity( false ); - aTarget->SetDefaultColor( KIGFX::COLOR4D( 0.5, 0.5, 0.5, 1.0 ) ); - aTarget->SetSwatchColor( COLOR4D( aSource.r, aSource.g, aSource.b, 1.0 ), false ); - }; + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings(); - transfer_color( m_settings.m_RtCameraLightColor, m_colourPickerCameraLight ); - transfer_color( m_settings.m_RtLightColorTop, m_colourPickerTopLight ); - transfer_color( m_settings.m_RtLightColorBottom, m_colourPickerBottomLight ); + auto transfer_color = + []( COLOR4D aColor, COLOR_SWATCH *aTarget ) + { + aTarget->SetSupportsOpacity( false ); + aTarget->SetDefaultColor( KIGFX::COLOR4D( 0.5, 0.5, 0.5, 1.0 ) ); + aTarget->SetSwatchColor( aColor, false ); + }; - transfer_color( m_settings.m_RtLightColor[0], m_colourPickerLight1 ); - transfer_color( m_settings.m_RtLightColor[1], m_colourPickerLight2 ); - transfer_color( m_settings.m_RtLightColor[2], m_colourPickerLight3 ); - transfer_color( m_settings.m_RtLightColor[3], m_colourPickerLight4 ); + auto transfer_value = + []( wxTextCtrl* aCtrl, int aValue ) + { + aCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, aValue ) ); + }; - transfer_color( m_settings.m_RtLightColor[4], m_colourPickerLight5 ); - transfer_color( m_settings.m_RtLightColor[5], m_colourPickerLight6 ); - transfer_color( m_settings.m_RtLightColor[6], m_colourPickerLight7 ); - transfer_color( m_settings.m_RtLightColor[7], m_colourPickerLight8 ); + 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 ); - m_spinCtrlLightElevation1->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[0].x * 180.0f - 90.0f ) ); - m_spinCtrlLightElevation2->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[1].x * 180.0f - 90.0f ) ); - m_spinCtrlLightElevation3->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[2].x * 180.0f - 90.0f ) ); - m_spinCtrlLightElevation4->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[3].x * 180.0f - 90.0f ) ); - m_spinCtrlLightElevation5->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[4].x * 180.0f - 90.0f ) ); - m_spinCtrlLightElevation6->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[5].x * 180.0f - 90.0f ) ); - m_spinCtrlLightElevation7->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[6].x * 180.0f - 90.0f ) ); - m_spinCtrlLightElevation8->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[7].x * 180.0f - 90.0f ) ); + 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 ); - m_spinCtrlLightAzimuth1->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[0].y * 180.0f ) ); - m_spinCtrlLightAzimuth2->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[1].y * 180.0f ) ); - m_spinCtrlLightAzimuth3->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[2].y * 180.0f ) ); - m_spinCtrlLightAzimuth4->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[3].y * 180.0f ) ); - m_spinCtrlLightAzimuth5->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[4].y * 180.0f ) ); - m_spinCtrlLightAzimuth6->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[5].y * 180.0f ) ); - m_spinCtrlLightAzimuth7->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[6].y * 180.0f ) ); - m_spinCtrlLightAzimuth8->SetValue( - (int)( m_settings.m_RtLightSphericalCoords[7].y * 180.0f ) ); + 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_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_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] ); } bool PANEL_3D_RAYTRACING_OPTIONS::TransferDataToWindow() { - m_checkBoxRaytracing_renderShadows->SetValue( - m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ) ); - m_checkBoxRaytracing_addFloor->SetValue( m_settings.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR ) ); - m_checkBoxRaytracing_showRefractions->SetValue( - m_settings.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS ) ); - m_checkBoxRaytracing_showReflections->SetValue( - m_settings.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ) ); - m_checkBoxRaytracing_postProcessing->SetValue( - m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) ); - m_checkBoxRaytracing_antiAliasing->SetValue( - m_settings.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) ); - m_checkBoxRaytracing_proceduralTextures->SetValue( - m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings(); - m_spinCtrl_NrSamples_Shadows->SetValue( m_settings.m_RtShadowSampleCount ); - m_spinCtrl_NrSamples_Reflections->SetValue( m_settings.m_RtReflectionSampleCount ); - m_spinCtrl_NrSamples_Refractions->SetValue( m_settings.m_RtRefractionSampleCount ); + 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_spinCtrlDouble_SpreadFactor_Shadows->SetValue( m_settings.m_RtSpreadShadows * 100.0f ); - m_spinCtrlDouble_SpreadFactor_Reflections->SetValue( - m_settings.m_RtSpreadReflections * 100.0f ); - m_spinCtrlDouble_SpreadFactor_Refractions->SetValue( - m_settings.m_RtSpreadRefractions * 100.0f ); + 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_spinCtrlRecursiveLevel_Reflections->SetValue( m_settings.m_RtRecursiveReflectionCount ); - m_spinCtrlRecursiveLevel_Refractions->SetValue( m_settings.m_RtRecursiveRefractionCount ); + 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(); @@ -165,89 +151,67 @@ bool PANEL_3D_RAYTRACING_OPTIONS::TransferDataToWindow() bool PANEL_3D_RAYTRACING_OPTIONS::TransferDataFromWindow() { - m_settings.SetFlag( FL_RENDER_RAYTRACING_SHADOWS, - m_checkBoxRaytracing_renderShadows->GetValue() ); - m_settings.SetFlag( FL_RENDER_RAYTRACING_BACKFLOOR, - m_checkBoxRaytracing_addFloor->GetValue() ); - m_settings.SetFlag( FL_RENDER_RAYTRACING_REFRACTIONS, - m_checkBoxRaytracing_showRefractions->GetValue() ); - m_settings.SetFlag( FL_RENDER_RAYTRACING_REFLECTIONS, - m_checkBoxRaytracing_showReflections->GetValue() ); - m_settings.SetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING, - m_checkBoxRaytracing_postProcessing->GetValue() ); - m_settings.SetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING, - m_checkBoxRaytracing_antiAliasing->GetValue() ); - m_settings.SetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES, - m_checkBoxRaytracing_proceduralTextures->GetValue() ); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + EDA_3D_VIEWER_SETTINGS* cfg = mgr.GetAppSettings(); - m_settings.m_RtShadowSampleCount = m_spinCtrl_NrSamples_Shadows->GetValue(); - m_settings.m_RtReflectionSampleCount = m_spinCtrl_NrSamples_Reflections->GetValue(); - m_settings.m_RtRefractionSampleCount= m_spinCtrl_NrSamples_Refractions->GetValue(); + cfg->m_Render.raytrace_shadows = m_cbRaytracing_renderShadows->GetValue(); + cfg->m_Render.raytrace_backfloor = m_cbRaytracing_addFloor->GetValue(); + cfg->m_Render.raytrace_refractions = m_cbRaytracing_showRefractions->GetValue(); + cfg->m_Render.raytrace_reflections = m_cbRaytracing_showReflections->GetValue(); + cfg->m_Render.raytrace_post_processing = m_cbRaytracing_postProcessing->GetValue(); + cfg->m_Render.raytrace_anti_aliasing = m_cbRaytracing_antiAliasing->GetValue(); + cfg->m_Render.raytrace_procedural_textures = m_cbRaytracing_proceduralTextures->GetValue(); - m_settings.m_RtSpreadShadows = - static_cast( m_spinCtrlDouble_SpreadFactor_Shadows->GetValue() ) / 100.0f; - m_settings.m_RtSpreadReflections = - static_cast( m_spinCtrlDouble_SpreadFactor_Reflections->GetValue() ) / 100.0f; - m_settings.m_RtSpreadRefractions = - static_cast( m_spinCtrlDouble_SpreadFactor_Refractions->GetValue() ) / 100.0f; + cfg->m_Render.raytrace_nrsamples_shadows = m_numSamples_Shadows->GetValue(); + cfg->m_Render.raytrace_nrsamples_reflections = m_numSamples_Reflections->GetValue(); + cfg->m_Render.raytrace_nrsamples_refractions = m_numSamples_Refractions->GetValue(); - m_settings.m_RtRecursiveReflectionCount = m_spinCtrlRecursiveLevel_Reflections->GetValue(); - m_settings.m_RtRecursiveRefractionCount = m_spinCtrlRecursiveLevel_Refractions->GetValue(); + cfg->m_Render.raytrace_spread_shadows = + DoubleValueFromString( EDA_UNITS::PERCENT, m_spreadFactor_Shadows->GetValue() ) / 100.0f; + cfg->m_Render.raytrace_spread_reflections = + DoubleValueFromString( EDA_UNITS::PERCENT, m_spreadFactor_Reflections->GetValue() ) / 100.0f; + cfg->m_Render.raytrace_spread_refractions = + DoubleValueFromString( EDA_UNITS::PERCENT, m_spreadFactor_Refractions->GetValue() ) / 100.0f; - auto transfer_color = [] ( SFVEC3F& aTarget, COLOR_SWATCH *aSource ) - { - const COLOR4D color = aSource->GetSwatchColor(); + cfg->m_Render.raytrace_recursivelevel_reflections = m_recursiveLevel_Reflections->GetValue(); + cfg->m_Render.raytrace_recursivelevel_refractions = m_recursiveLevel_Refractions->GetValue(); - aTarget = SFVEC3F( color.r, color.g, color.b ); - }; + cfg->m_Render.raytrace_lightColorCamera = m_colourPickerCameraLight->GetSwatchColor(); + cfg->m_Render.raytrace_lightColorTop = m_colourPickerTopLight->GetSwatchColor(); + cfg->m_Render.raytrace_lightColorBottom = m_colourPickerBottomLight->GetSwatchColor(); - transfer_color( m_settings.m_RtCameraLightColor, m_colourPickerCameraLight ); - transfer_color( m_settings.m_RtLightColorTop, m_colourPickerTopLight ); - transfer_color( m_settings.m_RtLightColorBottom, m_colourPickerBottomLight ); + cfg->m_Render.raytrace_lightColor[0] = m_colourPickerLight1->GetSwatchColor(); + cfg->m_Render.raytrace_lightColor[1] = m_colourPickerLight2->GetSwatchColor(); + cfg->m_Render.raytrace_lightColor[2] = m_colourPickerLight3->GetSwatchColor(); + cfg->m_Render.raytrace_lightColor[3] = m_colourPickerLight4->GetSwatchColor(); + cfg->m_Render.raytrace_lightColor[4] = m_colourPickerLight5->GetSwatchColor(); + cfg->m_Render.raytrace_lightColor[5] = m_colourPickerLight6->GetSwatchColor(); + cfg->m_Render.raytrace_lightColor[6] = m_colourPickerLight7->GetSwatchColor(); + cfg->m_Render.raytrace_lightColor[7] = m_colourPickerLight8->GetSwatchColor(); - transfer_color( m_settings.m_RtLightColor[0], m_colourPickerLight1 ); - transfer_color( m_settings.m_RtLightColor[1], m_colourPickerLight2 ); - transfer_color( m_settings.m_RtLightColor[2], m_colourPickerLight3 ); - transfer_color( m_settings.m_RtLightColor[3], m_colourPickerLight4 ); - transfer_color( m_settings.m_RtLightColor[4], m_colourPickerLight5 ); - transfer_color( m_settings.m_RtLightColor[5], m_colourPickerLight6 ); - transfer_color( m_settings.m_RtLightColor[6], m_colourPickerLight7 ); - transfer_color( m_settings.m_RtLightColor[7], m_colourPickerLight8 ); + auto get_value = + []( wxTextCtrl* aCtrl ) + { + return DoubleValueFromString( EDA_UNITS::UNSCALED, aCtrl->GetValue() ); + }; - m_settings.m_RtLightSphericalCoords[0].x = - ( m_spinCtrlLightElevation1->GetValue() + 90.0f ) / 180.0f; - m_settings.m_RtLightSphericalCoords[1].x = - ( m_spinCtrlLightElevation2->GetValue() + 90.0f ) / 180.0f; - m_settings.m_RtLightSphericalCoords[2].x = - ( m_spinCtrlLightElevation3->GetValue() + 90.0f ) / 180.0f; - m_settings.m_RtLightSphericalCoords[3].x = - ( m_spinCtrlLightElevation4->GetValue() + 90.0f ) / 180.0f; - m_settings.m_RtLightSphericalCoords[4].x = - ( m_spinCtrlLightElevation5->GetValue() + 90.0f ) / 180.0f; - m_settings.m_RtLightSphericalCoords[5].x = - ( m_spinCtrlLightElevation6->GetValue() + 90.0f ) / 180.0f; - m_settings.m_RtLightSphericalCoords[6].x = - ( m_spinCtrlLightElevation7->GetValue() + 90.0f ) / 180.0f; - m_settings.m_RtLightSphericalCoords[7].x = - ( m_spinCtrlLightElevation8->GetValue() + 90.0f ) / 180.0f; + cfg->m_Render.raytrace_lightElevation[0] = get_value( m_lightElevation1 ); + cfg->m_Render.raytrace_lightElevation[1] = get_value( m_lightElevation2 ); + cfg->m_Render.raytrace_lightElevation[2] = get_value( m_lightElevation3 ); + cfg->m_Render.raytrace_lightElevation[3] = get_value( m_lightElevation4 ); + cfg->m_Render.raytrace_lightElevation[4] = get_value( m_lightElevation5 ); + cfg->m_Render.raytrace_lightElevation[5] = get_value( m_lightElevation6 ); + cfg->m_Render.raytrace_lightElevation[6] = get_value( m_lightElevation7 ); + cfg->m_Render.raytrace_lightElevation[7] = get_value( m_lightElevation8 ); - m_settings.m_RtLightSphericalCoords[0].y = m_spinCtrlLightAzimuth1->GetValue() / 180.0f; - m_settings.m_RtLightSphericalCoords[1].y = m_spinCtrlLightAzimuth2->GetValue() / 180.0f; - m_settings.m_RtLightSphericalCoords[2].y = m_spinCtrlLightAzimuth3->GetValue() / 180.0f; - m_settings.m_RtLightSphericalCoords[3].y = m_spinCtrlLightAzimuth4->GetValue() / 180.0f; - m_settings.m_RtLightSphericalCoords[4].y = m_spinCtrlLightAzimuth5->GetValue() / 180.0f; - m_settings.m_RtLightSphericalCoords[5].y = m_spinCtrlLightAzimuth6->GetValue() / 180.0f; - m_settings.m_RtLightSphericalCoords[6].y = m_spinCtrlLightAzimuth7->GetValue() / 180.0f; - m_settings.m_RtLightSphericalCoords[7].y = m_spinCtrlLightAzimuth8->GetValue() / 180.0f; - - for( size_t i = 0; i < m_settings.m_RtLightSphericalCoords.size(); ++i ) - { - m_settings.m_RtLightSphericalCoords[i].x = - glm::clamp( m_settings.m_RtLightSphericalCoords[i].x, 0.0f, 1.0f ); - - m_settings.m_RtLightSphericalCoords[i].y = - glm::clamp( m_settings.m_RtLightSphericalCoords[i].y, 0.0f, 2.0f ); - } + cfg->m_Render.raytrace_lightAzimuth[0] = get_value( m_lightAzimuth1 ); + cfg->m_Render.raytrace_lightAzimuth[1] = get_value( m_lightAzimuth2 ); + cfg->m_Render.raytrace_lightAzimuth[2] = get_value( m_lightAzimuth3 ); + cfg->m_Render.raytrace_lightAzimuth[3] = get_value( m_lightAzimuth4 ); + cfg->m_Render.raytrace_lightAzimuth[4] = get_value( m_lightAzimuth5 ); + cfg->m_Render.raytrace_lightAzimuth[5] = get_value( m_lightAzimuth6 ); + cfg->m_Render.raytrace_lightAzimuth[6] = get_value( m_lightAzimuth7 ); + cfg->m_Render.raytrace_lightAzimuth[7] = get_value( m_lightAzimuth8 ); return true; } diff --git a/3d-viewer/dialogs/panel_3D_raytracing_options.h b/3d-viewer/dialogs/panel_3D_raytracing_options.h index d66f40a003..48998760c3 100644 --- a/3d-viewer/dialogs/panel_3D_raytracing_options.h +++ b/3d-viewer/dialogs/panel_3D_raytracing_options.h @@ -31,7 +31,7 @@ class PANEL_3D_RAYTRACING_OPTIONS : public PANEL_3D_RAYTRACING_OPTIONS_BASE { public: - explicit PANEL_3D_RAYTRACING_OPTIONS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent ); + explicit PANEL_3D_RAYTRACING_OPTIONS( wxWindow* aParent ); void ResetPanel() override; @@ -42,10 +42,6 @@ public: bool TransferDataToWindow() override; void TransferColorDataToWindow(); - -private: - BOARD_ADAPTER& m_settings; - EDA_3D_CANVAS* m_canvas; }; diff --git a/3d-viewer/dialogs/panel_3D_raytracing_options_base.cpp b/3d-viewer/dialogs/panel_3D_raytracing_options_base.cpp index b12aea8575..2edce7ed59 100644 --- a/3d-viewer/dialogs/panel_3D_raytracing_options_base.cpp +++ b/3d-viewer/dialogs/panel_3D_raytracing_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! @@ -24,21 +24,21 @@ PANEL_3D_RAYTRACING_OPTIONS_BASE::PANEL_3D_RAYTRACING_OPTIONS_BASE( wxWindow* pa wxGridSizer* gSizer1; gSizer1 = new wxGridSizer( 0, 1, 0, 20 ); - m_checkBoxRaytracing_proceduralTextures = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Procedural textures (slow)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkBoxRaytracing_proceduralTextures->SetValue(true); - gSizer1->Add( m_checkBoxRaytracing_proceduralTextures, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_cbRaytracing_proceduralTextures = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Procedural textures (slow)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbRaytracing_proceduralTextures->SetValue(true); + gSizer1->Add( m_cbRaytracing_proceduralTextures, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_checkBoxRaytracing_addFloor = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Add floor (slow)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkBoxRaytracing_addFloor->SetValue(true); - gSizer1->Add( m_checkBoxRaytracing_addFloor, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_cbRaytracing_addFloor = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Add floor (slow)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbRaytracing_addFloor->SetValue(true); + gSizer1->Add( m_cbRaytracing_addFloor, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_checkBoxRaytracing_antiAliasing = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Anti-aliasing (slow)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkBoxRaytracing_antiAliasing->SetValue(true); - gSizer1->Add( m_checkBoxRaytracing_antiAliasing, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_cbRaytracing_antiAliasing = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Anti-aliasing (slow)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbRaytracing_antiAliasing->SetValue(true); + gSizer1->Add( m_cbRaytracing_antiAliasing, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_checkBoxRaytracing_postProcessing = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Screen space ambient occlusions and global illumination reflections (slow)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkBoxRaytracing_postProcessing->SetValue(true); - gSizer1->Add( m_checkBoxRaytracing_postProcessing, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_cbRaytracing_postProcessing = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Screen space ambient occlusions and global illumination reflections (slow)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbRaytracing_postProcessing->SetValue(true); + gSizer1->Add( m_cbRaytracing_postProcessing, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); sbSizerRaytracingRenderOptions->Add( gSizer1, 1, wxEXPAND|wxBOTTOM, 5 ); @@ -63,63 +63,54 @@ PANEL_3D_RAYTRACING_OPTIONS_BASE::PANEL_3D_RAYTRACING_OPTIONS_BASE( wxWindow* pa m_staticText211->Wrap( -1 ); fgSizer111->Add( m_staticText211, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); - m_checkBoxRaytracing_renderShadows = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Shadows:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkBoxRaytracing_renderShadows->SetValue(true); - fgSizer111->Add( m_checkBoxRaytracing_renderShadows, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + m_cbRaytracing_renderShadows = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Shadows:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbRaytracing_renderShadows->SetValue(true); + fgSizer111->Add( m_cbRaytracing_renderShadows, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - m_spinCtrl_NrSamples_Shadows = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 64, 0 ); - m_spinCtrl_NrSamples_Shadows->SetToolTip( _("Number of rays that will be cast, into light direction, to evaluate a shadow point") ); + m_numSamples_Shadows = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 64, 0 ); + m_numSamples_Shadows->SetToolTip( _("Number of rays that will be cast, into light direction, to evaluate a shadow point") ); - fgSizer111->Add( m_spinCtrl_NrSamples_Shadows, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + fgSizer111->Add( m_numSamples_Shadows, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - m_spinCtrlDouble_SpreadFactor_Shadows = new wxSpinCtrlDouble( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 0.1, 25, 0, 1 ); - m_spinCtrlDouble_SpreadFactor_Shadows->SetDigits( 1 ); - m_spinCtrlDouble_SpreadFactor_Shadows->SetToolTip( _("Random direction factor of the cast rays") ); - - fgSizer111->Add( m_spinCtrlDouble_SpreadFactor_Shadows, 0, wxRIGHT|wxLEFT, 5 ); + m_spreadFactor_Shadows = new wxTextCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer111->Add( m_spreadFactor_Shadows, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); fgSizer111->Add( 0, 0, 1, wxEXPAND, 5 ); - m_checkBoxRaytracing_showReflections = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Reflections:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkBoxRaytracing_showReflections->SetValue(true); - fgSizer111->Add( m_checkBoxRaytracing_showReflections, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + m_cbRaytracing_showReflections = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Reflections:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbRaytracing_showReflections->SetValue(true); + fgSizer111->Add( m_cbRaytracing_showReflections, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - m_spinCtrl_NrSamples_Reflections = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 32, 0 ); - m_spinCtrl_NrSamples_Reflections->SetToolTip( _("Number of rays that will be cast to evaluate a reflection point") ); + m_numSamples_Reflections = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 32, 0 ); + m_numSamples_Reflections->SetToolTip( _("Number of rays that will be cast to evaluate a reflection point") ); - fgSizer111->Add( m_spinCtrl_NrSamples_Reflections, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + fgSizer111->Add( m_numSamples_Reflections, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); - m_spinCtrlDouble_SpreadFactor_Reflections = new wxSpinCtrlDouble( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 0.1, 25, 0, 1 ); - m_spinCtrlDouble_SpreadFactor_Reflections->SetDigits( 1 ); - m_spinCtrlDouble_SpreadFactor_Reflections->SetToolTip( _("Random direction factor of the cast rays") ); + m_spreadFactor_Reflections = new wxTextCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer111->Add( m_spreadFactor_Reflections, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - fgSizer111->Add( m_spinCtrlDouble_SpreadFactor_Reflections, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + m_recursiveLevel_Reflections = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 5, 0 ); + m_recursiveLevel_Reflections->SetToolTip( _("Interactions number that a ray can travel through objects. (higher number of levels improve results, specially on very transparent boards)") ); - m_spinCtrlRecursiveLevel_Reflections = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 5, 0 ); - m_spinCtrlRecursiveLevel_Reflections->SetToolTip( _("Interactions number that a ray can travel through objects. (higher number of levels improve results, specially on very transparent boards)") ); + fgSizer111->Add( m_recursiveLevel_Reflections, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - fgSizer111->Add( m_spinCtrlRecursiveLevel_Reflections, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + m_cbRaytracing_showRefractions = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Refractions:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbRaytracing_showRefractions->SetValue(true); + fgSizer111->Add( m_cbRaytracing_showRefractions, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - m_checkBoxRaytracing_showRefractions = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Refractions:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_checkBoxRaytracing_showRefractions->SetValue(true); - fgSizer111->Add( m_checkBoxRaytracing_showRefractions, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + m_numSamples_Refractions = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 5, 0 ); + m_numSamples_Refractions->SetToolTip( _("Number of rays that will be cast to evaluate a refraction point") ); - m_spinCtrl_NrSamples_Refractions = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 5, 0 ); - m_spinCtrl_NrSamples_Refractions->SetToolTip( _("Number of rays that will be cast to evaluate a refraction point") ); + fgSizer111->Add( m_numSamples_Refractions, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - fgSizer111->Add( m_spinCtrl_NrSamples_Refractions, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + m_spreadFactor_Refractions = new wxTextCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer111->Add( m_spreadFactor_Refractions, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); - m_spinCtrlDouble_SpreadFactor_Refractions = new wxSpinCtrlDouble( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 0.1, 25, 0, 1 ); - m_spinCtrlDouble_SpreadFactor_Refractions->SetDigits( 1 ); - m_spinCtrlDouble_SpreadFactor_Refractions->SetToolTip( _("Random direction factor of the cast rays") ); + m_recursiveLevel_Refractions = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 7, 0 ); + m_recursiveLevel_Refractions->SetToolTip( _("Number of bounces that a ray can hit reflective objects") ); - fgSizer111->Add( m_spinCtrlDouble_SpreadFactor_Refractions, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - - m_spinCtrlRecursiveLevel_Refractions = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 7, 0 ); - m_spinCtrlRecursiveLevel_Refractions->SetToolTip( _("Number of bounces that a ray can hit reflective objects") ); - - fgSizer111->Add( m_spinCtrlRecursiveLevel_Refractions, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + fgSizer111->Add( m_recursiveLevel_Refractions, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); sbSizerRaytracingRenderOptions->Add( fgSizer111, 0, wxTOP|wxBOTTOM|wxRIGHT|wxEXPAND, 5 ); @@ -218,11 +209,11 @@ PANEL_3D_RAYTRACING_OPTIONS_BASE::PANEL_3D_RAYTRACING_OPTIONS_BASE( wxWindow* pa fgSizer11->Add( m_colourPickerLight1, 0, wxALL, 5 ); - m_spinCtrlLightElevation1 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 ); - fgSizer11->Add( m_spinCtrlLightElevation1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightElevation1 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightElevation1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - m_spinCtrlLightAzimuth1 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 ); - fgSizer11->Add( m_spinCtrlLightAzimuth1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightAzimuth1 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightAzimuth1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 ); fgSizer11->Add( 10, 0, 0, 0, 5 ); @@ -236,11 +227,11 @@ PANEL_3D_RAYTRACING_OPTIONS_BASE::PANEL_3D_RAYTRACING_OPTIONS_BASE( wxWindow* pa fgSizer11->Add( m_colourPickerLight5, 0, wxALL, 5 ); - m_spinCtrlLightElevation5 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 ); - fgSizer11->Add( m_spinCtrlLightElevation5, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightElevation5 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightElevation5, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); - m_spinCtrlLightAzimuth5 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 ); - fgSizer11->Add( m_spinCtrlLightAzimuth5, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightAzimuth5 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightAzimuth5, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); m_staticText23 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Light 2:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText23->Wrap( -1 ); @@ -251,11 +242,11 @@ PANEL_3D_RAYTRACING_OPTIONS_BASE::PANEL_3D_RAYTRACING_OPTIONS_BASE( wxWindow* pa fgSizer11->Add( m_colourPickerLight2, 0, wxALL, 5 ); - m_spinCtrlLightElevation2 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 ); - fgSizer11->Add( m_spinCtrlLightElevation2, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightElevation2 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightElevation2, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); - m_spinCtrlLightAzimuth2 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 ); - fgSizer11->Add( m_spinCtrlLightAzimuth2, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightAzimuth2 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightAzimuth2, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); fgSizer11->Add( 0, 0, 0, 0, 5 ); @@ -269,11 +260,11 @@ PANEL_3D_RAYTRACING_OPTIONS_BASE::PANEL_3D_RAYTRACING_OPTIONS_BASE( wxWindow* pa fgSizer11->Add( m_colourPickerLight6, 0, wxALL, 5 ); - m_spinCtrlLightElevation6 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 ); - fgSizer11->Add( m_spinCtrlLightElevation6, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightElevation6 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightElevation6, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); - m_spinCtrlLightAzimuth6 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 ); - fgSizer11->Add( m_spinCtrlLightAzimuth6, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightAzimuth6 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightAzimuth6, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); m_staticText25 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Light 3:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText25->Wrap( -1 ); @@ -284,11 +275,11 @@ PANEL_3D_RAYTRACING_OPTIONS_BASE::PANEL_3D_RAYTRACING_OPTIONS_BASE( wxWindow* pa fgSizer11->Add( m_colourPickerLight3, 0, wxALL, 5 ); - m_spinCtrlLightElevation3 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 ); - fgSizer11->Add( m_spinCtrlLightElevation3, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightElevation3 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightElevation3, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - m_spinCtrlLightAzimuth3 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 ); - fgSizer11->Add( m_spinCtrlLightAzimuth3, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightAzimuth3 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightAzimuth3, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); fgSizer11->Add( 0, 0, 0, 0, 5 ); @@ -302,11 +293,11 @@ PANEL_3D_RAYTRACING_OPTIONS_BASE::PANEL_3D_RAYTRACING_OPTIONS_BASE( wxWindow* pa fgSizer11->Add( m_colourPickerLight7, 0, wxALL, 5 ); - m_spinCtrlLightElevation7 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 ); - fgSizer11->Add( m_spinCtrlLightElevation7, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightElevation7 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightElevation7, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); - m_spinCtrlLightAzimuth7 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 ); - fgSizer11->Add( m_spinCtrlLightAzimuth7, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightAzimuth7 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightAzimuth7, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); m_staticText171 = new wxStaticText( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, _("Light 4:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText171->Wrap( -1 ); @@ -317,11 +308,11 @@ PANEL_3D_RAYTRACING_OPTIONS_BASE::PANEL_3D_RAYTRACING_OPTIONS_BASE( wxWindow* pa fgSizer11->Add( m_colourPickerLight4, 0, wxALL, 5 ); - m_spinCtrlLightElevation4 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 ); - fgSizer11->Add( m_spinCtrlLightElevation4, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightElevation4 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightElevation4, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); - m_spinCtrlLightAzimuth4 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 ); - fgSizer11->Add( m_spinCtrlLightAzimuth4, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightAzimuth4 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightAzimuth4, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); fgSizer11->Add( 0, 0, 0, 0, 5 ); @@ -335,14 +326,14 @@ PANEL_3D_RAYTRACING_OPTIONS_BASE::PANEL_3D_RAYTRACING_OPTIONS_BASE( wxWindow* pa fgSizer11->Add( m_colourPickerLight8, 0, wxALL, 5 ); - m_spinCtrlLightElevation8 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, -90, 90, 0 ); - fgSizer11->Add( m_spinCtrlLightElevation8, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightElevation8 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightElevation8, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); - m_spinCtrlLightAzimuth8 = new wxSpinCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 ); - fgSizer11->Add( m_spinCtrlLightAzimuth8, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 1 ); + m_lightAzimuth8 = new wxTextCtrl( sbSizerRaytracingLightConfiguration->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer11->Add( m_lightAzimuth8, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); - sbSizerRaytracingLightConfiguration->Add( fgSizer11, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + sbSizerRaytracingLightConfiguration->Add( fgSizer11, 0, wxEXPAND|wxALL, 5 ); bSizerMargins->Add( sbSizerRaytracingLightConfiguration, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); diff --git a/3d-viewer/dialogs/panel_3D_raytracing_options_base.fbp b/3d-viewer/dialogs/panel_3D_raytracing_options_base.fbp index 6e391e95fc..48aaa61e5d 100644 --- a/3d-viewer/dialogs/panel_3D_raytracing_options_base.fbp +++ b/3d-viewer/dialogs/panel_3D_raytracing_options_base.fbp @@ -14,7 +14,6 @@ panel_3D_raytracing_options_base 1000 none - 1 panel_3D_raytracing_options_base @@ -26,7 +25,6 @@ 1 1 UI - 0 0 0 @@ -48,7 +46,6 @@ -1,-1 RESETTABLE_PANEL; widgets/resettable_panel.h; forward_declare - 0 wxTAB_TRAVERSAL @@ -131,7 +128,7 @@ 0 1 - m_checkBoxRaytracing_proceduralTextures + m_cbRaytracing_proceduralTextures 1 @@ -195,7 +192,7 @@ 0 1 - m_checkBoxRaytracing_addFloor + m_cbRaytracing_addFloor 1 @@ -259,7 +256,7 @@ 0 1 - m_checkBoxRaytracing_antiAliasing + m_cbRaytracing_antiAliasing 1 @@ -323,7 +320,7 @@ 0 1 - m_checkBoxRaytracing_postProcessing + m_cbRaytracing_postProcessing 1 @@ -598,7 +595,7 @@ 0 1 - m_checkBoxRaytracing_renderShadows + m_cbRaytracing_renderShadows 1 @@ -663,7 +660,7 @@ 0 1 - m_spinCtrl_NrSamples_Shadows + m_numSamples_Shadows 1 @@ -683,11 +680,11 @@ - + 5 - wxRIGHT|wxLEFT + wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 - + 1 1 1 @@ -705,7 +702,6 @@ 1 0 - 1 Dock 0 Left @@ -716,18 +712,15 @@ 0 0 wxID_ANY - 1 - 0 - 25 0 - 0.1 + 0 1 - m_spinCtrlDouble_SpreadFactor_Shadows + m_spreadFactor_Shadows 1 @@ -736,11 +729,15 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS + + ; ; forward_declare 0 - Random direction factor of the cast rays + + + wxFILTER_NONE + wxDefaultValidator + @@ -798,7 +795,7 @@ 0 1 - m_checkBoxRaytracing_showReflections + m_cbRaytracing_showReflections 1 @@ -863,7 +860,7 @@ 0 1 - m_spinCtrl_NrSamples_Reflections + m_numSamples_Reflections 1 @@ -883,11 +880,11 @@ - + 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND 0 - + 1 1 1 @@ -905,7 +902,6 @@ 1 0 - 1 Dock 0 Left @@ -916,18 +912,15 @@ 0 0 wxID_ANY - 1 - 0 - 25 0 - 0.1 + 0 1 - m_spinCtrlDouble_SpreadFactor_Reflections + m_spreadFactor_Reflections 1 @@ -936,11 +929,15 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS + + ; ; forward_declare 0 - Random direction factor of the cast rays + + + wxFILTER_NONE + wxDefaultValidator + @@ -989,7 +986,7 @@ 0 1 - m_spinCtrlRecursiveLevel_Reflections + m_recursiveLevel_Reflections 1 @@ -1050,7 +1047,7 @@ 0 1 - m_checkBoxRaytracing_showRefractions + m_cbRaytracing_showRefractions 1 @@ -1115,7 +1112,7 @@ 0 1 - m_spinCtrl_NrSamples_Refractions + m_numSamples_Refractions 1 @@ -1135,11 +1132,11 @@ - + 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -1157,7 +1154,6 @@ 1 0 - 1 Dock 0 Left @@ -1168,18 +1164,15 @@ 0 0 wxID_ANY - 1 - 0 - 25 0 - 0.1 + 0 1 - m_spinCtrlDouble_SpreadFactor_Refractions + m_spreadFactor_Refractions 1 @@ -1188,11 +1181,15 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS + + ; ; forward_declare 0 - Random direction factor of the cast rays + + + wxFILTER_NONE + wxDefaultValidator + @@ -1241,7 +1238,7 @@ 0 1 - m_spinCtrlRecursiveLevel_Refractions + m_recursiveLevel_Refractions 1 @@ -1689,7 +1686,7 @@ 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + wxEXPAND|wxALL 0 9 @@ -2120,11 +2117,11 @@ - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND 0 - + 1 1 1 @@ -2152,17 +2149,15 @@ 0 0 wxID_ANY - 0 - 90 0 - -90 + 0 1 - m_spinCtrlLightElevation1 + m_lightElevation1 1 @@ -2171,22 +2166,26 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND 0 - + 1 1 1 @@ -2214,17 +2213,15 @@ 0 0 wxID_ANY - 0 - 359 0 - 0 + 0 1 - m_spinCtrlLightAzimuth1 + m_lightAzimuth1 1 @@ -2233,11 +2230,15 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS|wxSP_WRAP + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + @@ -2377,11 +2378,11 @@ - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -2409,17 +2410,15 @@ 0 0 wxID_ANY - 0 - 90 0 - -90 + 0 1 - m_spinCtrlLightElevation5 + m_lightElevation5 1 @@ -2428,22 +2427,26 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -2471,17 +2474,15 @@ 0 0 wxID_ANY - 0 - 359 0 - 0 + 0 1 - m_spinCtrlLightAzimuth5 + m_lightAzimuth5 1 @@ -2490,11 +2491,15 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS|wxSP_WRAP + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + @@ -2624,11 +2629,11 @@ - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -2656,17 +2661,15 @@ 0 0 wxID_ANY - 0 - 90 0 - -90 + 0 1 - m_spinCtrlLightElevation2 + m_lightElevation2 1 @@ -2675,22 +2678,26 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -2718,17 +2725,15 @@ 0 0 wxID_ANY - 0 - 359 0 - 0 + 0 1 - m_spinCtrlLightAzimuth2 + m_lightAzimuth2 1 @@ -2737,11 +2742,15 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS|wxSP_WRAP + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + @@ -2881,11 +2890,11 @@ - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -2913,17 +2922,15 @@ 0 0 wxID_ANY - 0 - 90 0 - -90 + 0 1 - m_spinCtrlLightElevation6 + m_lightElevation6 1 @@ -2932,22 +2939,26 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + - - 1 + + 5 wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -2975,17 +2986,15 @@ 0 0 wxID_ANY - 0 - 359 0 - 0 + 0 1 - m_spinCtrlLightAzimuth6 + m_lightAzimuth6 1 @@ -2994,11 +3003,15 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS|wxSP_WRAP + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + @@ -3128,11 +3141,11 @@ - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxEXPAND 0 - + 1 1 1 @@ -3160,17 +3173,15 @@ 0 0 wxID_ANY - 0 - 90 0 - -90 + 0 1 - m_spinCtrlLightElevation3 + m_lightElevation3 1 @@ -3179,22 +3190,26 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -3222,17 +3237,15 @@ 0 0 wxID_ANY - 0 - 359 0 - 0 + 0 1 - m_spinCtrlLightAzimuth3 + m_lightAzimuth3 1 @@ -3241,11 +3254,15 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS|wxSP_WRAP + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + @@ -3385,11 +3402,11 @@ - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -3417,17 +3434,15 @@ 0 0 wxID_ANY - 0 - 90 0 - -90 + 0 1 - m_spinCtrlLightElevation7 + m_lightElevation7 1 @@ -3436,22 +3451,26 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -3479,17 +3498,15 @@ 0 0 wxID_ANY - 0 - 359 0 - 0 + 0 1 - m_spinCtrlLightAzimuth7 + m_lightAzimuth7 1 @@ -3498,11 +3515,15 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS|wxSP_WRAP + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + @@ -3632,11 +3653,11 @@ - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -3664,17 +3685,15 @@ 0 0 wxID_ANY - 0 - 90 0 - -90 + 0 1 - m_spinCtrlLightElevation4 + m_lightElevation4 1 @@ -3683,22 +3702,26 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -3726,17 +3749,15 @@ 0 0 wxID_ANY - 0 - 359 0 - 0 + 0 1 - m_spinCtrlLightAzimuth4 + m_lightAzimuth4 1 @@ -3745,11 +3766,15 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS|wxSP_WRAP + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + @@ -3889,11 +3914,11 @@ - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -3921,17 +3946,15 @@ 0 0 wxID_ANY - 0 - 90 0 - -90 + 0 1 - m_spinCtrlLightElevation8 + m_lightElevation8 1 @@ -3940,22 +3963,26 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + - - 1 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -3983,17 +4010,15 @@ 0 0 wxID_ANY - 0 - 359 0 - 0 + 0 1 - m_spinCtrlLightAzimuth8 + m_lightAzimuth8 1 @@ -4002,11 +4027,15 @@ Resizable 1 - 124,-1 - wxSP_ARROW_KEYS|wxSP_WRAP + + ; ; forward_declare 0 + + wxFILTER_NONE + wxDefaultValidator + diff --git a/3d-viewer/dialogs/panel_3D_raytracing_options_base.h b/3d-viewer/dialogs/panel_3D_raytracing_options_base.h index 06e9000c99..6f863da936 100644 --- a/3d-viewer/dialogs/panel_3D_raytracing_options_base.h +++ b/3d-viewer/dialogs/panel_3D_raytracing_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! @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -35,24 +36,24 @@ class PANEL_3D_RAYTRACING_OPTIONS_BASE : public RESETTABLE_PANEL private: protected: - wxCheckBox* m_checkBoxRaytracing_proceduralTextures; - wxCheckBox* m_checkBoxRaytracing_addFloor; - wxCheckBox* m_checkBoxRaytracing_antiAliasing; - wxCheckBox* m_checkBoxRaytracing_postProcessing; + wxCheckBox* m_cbRaytracing_proceduralTextures; + wxCheckBox* m_cbRaytracing_addFloor; + wxCheckBox* m_cbRaytracing_antiAliasing; + wxCheckBox* m_cbRaytracing_postProcessing; wxStaticText* m_staticText19; wxStaticText* m_staticText201; wxStaticText* m_staticText211; - wxCheckBox* m_checkBoxRaytracing_renderShadows; - wxSpinCtrl* m_spinCtrl_NrSamples_Shadows; - wxSpinCtrlDouble* m_spinCtrlDouble_SpreadFactor_Shadows; - wxCheckBox* m_checkBoxRaytracing_showReflections; - wxSpinCtrl* m_spinCtrl_NrSamples_Reflections; - wxSpinCtrlDouble* m_spinCtrlDouble_SpreadFactor_Reflections; - wxSpinCtrl* m_spinCtrlRecursiveLevel_Reflections; - wxCheckBox* m_checkBoxRaytracing_showRefractions; - wxSpinCtrl* m_spinCtrl_NrSamples_Refractions; - wxSpinCtrlDouble* m_spinCtrlDouble_SpreadFactor_Refractions; - wxSpinCtrl* m_spinCtrlRecursiveLevel_Refractions; + wxCheckBox* m_cbRaytracing_renderShadows; + wxSpinCtrl* m_numSamples_Shadows; + wxTextCtrl* m_spreadFactor_Shadows; + wxCheckBox* m_cbRaytracing_showReflections; + wxSpinCtrl* m_numSamples_Reflections; + wxTextCtrl* m_spreadFactor_Reflections; + wxSpinCtrl* m_recursiveLevel_Reflections; + wxCheckBox* m_cbRaytracing_showRefractions; + wxSpinCtrl* m_numSamples_Refractions; + wxTextCtrl* m_spreadFactor_Refractions; + wxSpinCtrl* m_recursiveLevel_Refractions; wxStaticText* m_staticText17; COLOR_SWATCH* m_colourPickerCameraLight; wxStaticText* m_staticText5; @@ -65,41 +66,40 @@ class PANEL_3D_RAYTRACING_OPTIONS_BASE : public RESETTABLE_PANEL wxStaticText* m_staticText28; wxStaticText* m_staticText21; COLOR_SWATCH* m_colourPickerLight1; - wxSpinCtrl* m_spinCtrlLightElevation1; - wxSpinCtrl* m_spinCtrlLightAzimuth1; + wxTextCtrl* m_lightElevation1; + wxTextCtrl* m_lightAzimuth1; wxStaticText* m_staticText22; COLOR_SWATCH* m_colourPickerLight5; - wxSpinCtrl* m_spinCtrlLightElevation5; - wxSpinCtrl* m_spinCtrlLightAzimuth5; + wxTextCtrl* m_lightElevation5; + wxTextCtrl* m_lightAzimuth5; wxStaticText* m_staticText23; COLOR_SWATCH* m_colourPickerLight2; - wxSpinCtrl* m_spinCtrlLightElevation2; - wxSpinCtrl* m_spinCtrlLightAzimuth2; + wxTextCtrl* m_lightElevation2; + wxTextCtrl* m_lightAzimuth2; wxStaticText* m_staticText24; COLOR_SWATCH* m_colourPickerLight6; - wxSpinCtrl* m_spinCtrlLightElevation6; - wxSpinCtrl* m_spinCtrlLightAzimuth6; + wxTextCtrl* m_lightElevation6; + wxTextCtrl* m_lightAzimuth6; wxStaticText* m_staticText25; COLOR_SWATCH* m_colourPickerLight3; - wxSpinCtrl* m_spinCtrlLightElevation3; - wxSpinCtrl* m_spinCtrlLightAzimuth3; + wxTextCtrl* m_lightElevation3; + wxTextCtrl* m_lightAzimuth3; wxStaticText* m_staticText26; COLOR_SWATCH* m_colourPickerLight7; - wxSpinCtrl* m_spinCtrlLightElevation7; - wxSpinCtrl* m_spinCtrlLightAzimuth7; + wxTextCtrl* m_lightElevation7; + wxTextCtrl* m_lightAzimuth7; wxStaticText* m_staticText171; COLOR_SWATCH* m_colourPickerLight4; - wxSpinCtrl* m_spinCtrlLightElevation4; - wxSpinCtrl* m_spinCtrlLightAzimuth4; + wxTextCtrl* m_lightElevation4; + wxTextCtrl* m_lightAzimuth4; wxStaticText* m_staticText181; COLOR_SWATCH* m_colourPickerLight8; - wxSpinCtrl* m_spinCtrlLightElevation8; - wxSpinCtrl* m_spinCtrlLightAzimuth8; + wxTextCtrl* m_lightElevation8; + wxTextCtrl* m_lightAzimuth8; public: PANEL_3D_RAYTRACING_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_RAYTRACING_OPTIONS_BASE(); }; diff --git a/bitmaps_png/png/icon_pcm_48.png b/bitmaps_png/png/icon_pcm_48.png index fecc8a5744..d19e1844ec 100644 Binary files a/bitmaps_png/png/icon_pcm_48.png and b/bitmaps_png/png/icon_pcm_48.png differ diff --git a/bitmaps_png/png/icon_pcm_dark_48.png b/bitmaps_png/png/icon_pcm_dark_48.png index fecc8a5744..d19e1844ec 100644 Binary files a/bitmaps_png/png/icon_pcm_dark_48.png and b/bitmaps_png/png/icon_pcm_dark_48.png differ diff --git a/common/dialogs/dialog_hotkey_list.cpp b/common/dialogs/dialog_hotkey_list.cpp index 5c07fbb137..d76cbfeeda 100644 --- a/common/dialogs/dialog_hotkey_list.cpp +++ b/common/dialogs/dialog_hotkey_list.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KICAD, a free EDA CAD application. * - * Copyright (C) 2018-2020 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-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 @@ -22,22 +22,22 @@ */ #include - +#include #include #include #include #include - -DIALOG_LIST_HOTKEYS::DIALOG_LIST_HOTKEYS( EDA_BASE_FRAME* aParent, TOOL_MANAGER* aToolMgr ): +DIALOG_LIST_HOTKEYS::DIALOG_LIST_HOTKEYS( EDA_BASE_FRAME* aParent ): DIALOG_SHIM( aParent, wxID_ANY, _( "Hotkey List" ) ) { const int margin = KIUI::GetStdMargin(); wxBoxSizer* main_sizer = new wxBoxSizer( wxVERTICAL ); m_hk_list = new PANEL_HOTKEYS_EDITOR( aParent, this, true ); - m_hk_list->AddHotKeys( aToolMgr ); + + Kiface().GetActions( m_hk_list->ActionsList() ); main_sizer->Add( m_hk_list, 1, wxTOP | wxLEFT | wxRIGHT | wxEXPAND, margin ); diff --git a/common/dialogs/dialog_unit_entry.cpp b/common/dialogs/dialog_unit_entry.cpp index 76bc7b9d5f..d0fe19d147 100644 --- a/common/dialogs/dialog_unit_entry.cpp +++ b/common/dialogs/dialog_unit_entry.cpp @@ -22,13 +22,15 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include WX_UNIT_ENTRY_DIALOG::WX_UNIT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aLabel, - const wxString& aCaption, const long long& aDefaultValue ) - : WX_UNIT_ENTRY_DIALOG_BASE( ( wxWindow* ) aParent, wxID_ANY, aCaption ), - m_unit_binder( aParent, m_label, m_textCtrl, m_unit_label, true ) + const wxString& aCaption, + const long long& aDefaultValue ) : + WX_UNIT_ENTRY_DIALOG_BASE( ( wxWindow* ) aParent, wxID_ANY, aCaption ), + m_unit_binder( aParent, m_label, m_textCtrl, m_unit_label, true ) { m_label->SetLabel( aLabel ); m_unit_binder.SetValue( aDefaultValue ); diff --git a/common/dialogs/panel_color_settings.cpp b/common/dialogs/panel_color_settings.cpp index bddb3135d9..93541577a0 100644 --- a/common/dialogs/panel_color_settings.cpp +++ b/common/dialogs/panel_color_settings.cpp @@ -184,14 +184,21 @@ void PANEL_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event ) void PANEL_COLOR_SETTINGS::updateSwatches() { - bool isReadOnly = m_currentSettings->IsReadOnly(); - COLOR4D background = m_currentSettings->GetColor( m_backgroundLayer ); - - for( std::pair pair : m_swatches ) + if( m_swatches.empty() ) { - pair.second->SetSwatchBackground( background ); - pair.second->SetSwatchColor( m_currentSettings->GetColor( pair.first ), false ); - pair.second->SetReadOnly( isReadOnly ); + createSwatches(); + } + else + { + bool isReadOnly = m_currentSettings->IsReadOnly(); + COLOR4D background = m_currentSettings->GetColor( m_backgroundLayer ); + + for( std::pair pair : m_swatches ) + { + pair.second->SetSwatchBackground( background ); + pair.second->SetSwatchColor( m_currentSettings->GetColor( pair.first ), false ); + pair.second->SetReadOnly( isReadOnly ); + } } } diff --git a/common/dialogs/panel_gal_display_options.cpp b/common/dialogs/panel_gal_display_options.cpp index 1f3a963456..d4a13332f5 100644 --- a/common/dialogs/panel_gal_display_options.cpp +++ b/common/dialogs/panel_gal_display_options.cpp @@ -17,26 +17,21 @@ * with this program. If not, see . */ -#include -#include #include #include #include -#include - -PANEL_GAL_DISPLAY_OPTIONS::PANEL_GAL_DISPLAY_OPTIONS( EDA_DRAW_FRAME* aFrame, - PAGED_DIALOG* aParent ) : - wxPanel( aParent->GetTreebook(), wxID_ANY ), - m_frame( aFrame ) +PANEL_GAL_DISPLAY_OPTIONS::PANEL_GAL_DISPLAY_OPTIONS( wxWindow* aParent, + APP_SETTINGS_BASE* aAppSettings ) : + wxPanel( aParent, wxID_ANY ) { auto mainSizer = new wxBoxSizer( wxHORIZONTAL ); SetSizer( mainSizer ); // install GAL options pane - m_galOptsPanel = new GAL_OPTIONS_PANEL( this, m_frame ); + m_galOptsPanel = new GAL_OPTIONS_PANEL( this, aAppSettings ); mainSizer->Add( m_galOptsPanel, 1, wxEXPAND | wxLEFT, 5 ); // a spacer to take up the other half of the width @@ -55,12 +50,5 @@ bool PANEL_GAL_DISPLAY_OPTIONS::TransferDataToWindow() bool PANEL_GAL_DISPLAY_OPTIONS::TransferDataFromWindow() { m_galOptsPanel->TransferDataFromWindow(); - - // refresh view - KIGFX::VIEW* view = m_frame->GetCanvas()->GetView(); - view->RecacheAllItems(); - view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); - m_frame->GetCanvas()->Refresh(); - return true; } diff --git a/common/dialogs/panel_hotkeys_editor.cpp b/common/dialogs/panel_hotkeys_editor.cpp index cb520b011f..39a7b94a78 100644 --- a/common/dialogs/panel_hotkeys_editor.cpp +++ b/common/dialogs/panel_hotkeys_editor.cpp @@ -106,9 +106,15 @@ PANEL_HOTKEYS_EDITOR::PANEL_HOTKEYS_EDITOR( EDA_BASE_FRAME* aFrame, wxWindow* aW } -void PANEL_HOTKEYS_EDITOR::AddHotKeys( TOOL_MANAGER* aToolMgr ) +bool PANEL_HOTKEYS_EDITOR::Show( bool show ) { - m_toolManagers.push_back( aToolMgr ); + if( show && m_hotkeyStore.GetSections().empty() ) + { + m_hotkeyStore.Init( m_actions, m_readOnly ); + return m_hotkeyListCtrl->TransferDataToControl(); + } + + return RESETTABLE_PANEL::Show( show ); } @@ -165,8 +171,9 @@ void PANEL_HOTKEYS_EDITOR::installButtons( wxSizer* aSizer ) bool PANEL_HOTKEYS_EDITOR::TransferDataToWindow() { - m_hotkeyStore.Init( m_toolManagers, m_readOnly ); - return m_hotkeyListCtrl->TransferDataToControl(); + // Deferred to Show() for performance when opening preferences + + return true; } @@ -178,9 +185,7 @@ bool PANEL_HOTKEYS_EDITOR::TransferDataFromWindow() if( m_readOnly ) return true; - // save the hotkeys - for( TOOL_MANAGER* toolMgr : m_toolManagers ) - WriteHotKeyConfig( toolMgr->GetActions() ); + WriteHotKeyConfig( m_actions ); return true; } diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 9fa852edee..752fcbd3b0 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -62,6 +62,7 @@ #include #include +#include wxDEFINE_EVENT( UNITS_CHANGED, wxCommandEvent ); @@ -1003,42 +1004,103 @@ void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event ) PAGED_DIALOG dlg( this, _( "Preferences" ), true ); wxTreebook* book = dlg.GetTreebook(); + PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( this, book, false ); + KIFACE* kiface = nullptr; + std::vector expand; + + Kiway().GetActions( hotkeysPanel->ActionsList() ); + book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) ); - book->AddPage( new PANEL_MOUSE_SETTINGS( &dlg, book ), _( "Mouse and Touchpad" ) ); - - PANEL_HOTKEYS_EDITOR* hotkeysPanel = new PANEL_HOTKEYS_EDITOR( this, book, false ); book->AddPage( hotkeysPanel, _( "Hotkeys" ) ); - wxWindow* viewer3D = nullptr; +#define CREATE_PANEL( key ) kiface->CreateWindow( book, key, &Kiway() ) - for( unsigned i = 0; i < KIWAY_PLAYER_COUNT; ++i ) - { - KIWAY_PLAYER* frame = dlg.Kiway().Player( (FRAME_T) i, false ); + kiface = Kiway().KiFACE( KIWAY::FACE_SCH ); - if( frame ) - { - frame->InstallPreferences( &dlg, hotkeysPanel ); + kiface->GetActions( hotkeysPanel->ActionsList() ); - if( !viewer3D ) - viewer3D = wxFindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( frame ) ); - } - } + if( GetFrameType() == FRAME_SCH_SYMBOL_EDITOR ) + expand.push_back( book->GetPageCount() ); - if( viewer3D ) - static_cast( viewer3D )->InstallPreferences( &dlg, hotkeysPanel ); + book->AddPage( new wxPanel( book ), _( "Symbol Editor" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_SYM_DISPLAY_OPTIONS ), _( "Display Options" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_SYM_EDIT_OPTIONS ), _( "Editing Options" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_SYM_COLORS ), _( "Colors" ) ); - // The Kicad manager frame is not a player so we have to add it by hand - wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME ); + if( GetFrameType() == FRAME_SCH ) + expand.push_back( book->GetPageCount() ); - if( manager ) - static_cast( manager )->InstallPreferences( &dlg, hotkeysPanel ); + book->AddPage( new wxPanel( book ), _( "Schematic Editor" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_SCH_DISPLAY_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" ) ); + + kiface = Kiway().KiFACE( KIWAY::FACE_PCB ); + + kiface->GetActions( hotkeysPanel->ActionsList() ); + + if( GetFrameType() == FRAME_FOOTPRINT_EDITOR ) + expand.push_back( book->GetPageCount() ); + + book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_FP_DISPLAY_OPTIONS ), _( "Display Options" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_FP_EDIT_OPTIONS ), _( "Editing Options" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_FP_COLORS ), _( "Colors" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_FP_DEFAULT_VALUES ), _( "Default Values" ) ); + + if( GetFrameType() == FRAME_PCB_EDITOR ) + expand.push_back( book->GetPageCount() ); + + book->AddPage( new wxPanel( book ), _( "PCB Editor" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_PCB_DISPLAY_OPTIONS ), _( "Display Options" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_PCB_EDIT_OPTIONS ), _( "Editing Options" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_PCB_COLORS ), _( "Colors" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_PCB_ACTION_PLUGINS ), _( "Action Plugins" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_PCB_ORIGINS_AXES ), _( "Origins & Axes" ) ); + + if( Kiway().Player( FRAME_PCB_DISPLAY3D, false ) ) + expand.push_back( book->GetPageCount() ); + + book->AddPage( new wxPanel( book ), _( "3D Viewer" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_3DV_DISPLAY_OPTIONS ), _( "General" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_3DV_OPENGL ), _( "Realtime Renderer" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_3DV_RAYTRACING ), _( "Raytracing Renderer" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_3DV_COLORS ), _( "Colors" ) ); + + kiface = Kiway().KiFACE( KIWAY::FACE_GERBVIEW ); + + kiface->GetActions( hotkeysPanel->ActionsList() ); + + if( GetFrameType() == FRAME_GERBER ) + expand.push_back( book->GetPageCount() ); + + book->AddPage( new wxPanel( book ), _( "GerbView" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_GBR_DISPLAY_OPTIONS ), _( "Display Options" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_GBR_EXCELLON_OPTIONS ), _( "Excellon Options" ) ); + + kiface = Kiway().KiFACE( KIWAY::FACE_PL_EDITOR ); + + kiface->GetActions( hotkeysPanel->ActionsList() ); + + if( GetFrameType() == FRAME_PL_EDITOR ) + expand.push_back( book->GetPageCount() ); + + book->AddPage( new wxPanel( book ), _( "Drawing Sheet Editor" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_DS_DISPLAY_OPTIONS ), _( "Display Options" ) ); + book->AddSubPage( CREATE_PANEL( PANEL_DS_COLORS ), _( "Colors" ) ); for( size_t i = 0; i < book->GetPageCount(); ++i ) book->GetPage( i )->Layout(); + for( int page : expand ) + book->ExpandNode( page ); + if( dlg.ShowModal() == wxID_OK ) dlg.Kiway().CommonSettingsChanged( false, false ); + +#undef CREATE_PANEL } diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index 739dbd40c4..8c3481b415 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -297,6 +297,17 @@ void EDA_DRAW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars m_galDisplayOptions.ReadCommonConfig( *settings, this ); +#ifndef __WXMAC__ + EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE; + APP_SETTINGS_BASE* cfg = Kiface().KifaceSettings(); + + if( cfg ) + canvasType = static_cast( cfg->m_Graphics.canvas_type ); + + if( canvasType != GetCanvas()->GetBackend() ) + GetCanvas()->SwitchBackend( canvasType ); +#endif + // Notify all tools the preferences have changed if( m_toolManager ) m_toolManager->RunAction( ACTIONS::updatePreferences, true ); diff --git a/common/hotkey_store.cpp b/common/hotkey_store.cpp index 9b562aeb2f..fb6a03a4c4 100644 --- a/common/hotkey_store.cpp +++ b/common/hotkey_store.cpp @@ -90,35 +90,28 @@ HOTKEY_STORE::HOTKEY_STORE() } -void HOTKEY_STORE::Init( std::vector aToolManagerList, bool aIncludeReadOnlyCmds ) +void HOTKEY_STORE::Init( std::vector aActionsList, bool aIncludeReadOnlyCmds ) { - m_toolManagers = std::move( aToolManagerList ); - - // Collect all action maps into a single master map. This will re-group everything - // and collect duplicates together std::map masterMap; - for( TOOL_MANAGER* toolMgr : m_toolManagers ) + for( TOOL_ACTION* action : aActionsList ) { - for( const std::pair& entry : toolMgr->GetActions() ) + // Internal actions probably shouldn't be allowed hotkeys + if( action->GetLabel().IsEmpty() ) + continue; + + if( !ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes ) { - // Internal actions probably shouldn't be allowed hotkeys - if( entry.second->GetLabel().IsEmpty() ) - continue; - - if( !ADVANCED_CFG::GetCfg().m_ExtraZoneDisplayModes ) + if( action->GetName() == "pcbnew.Control.zoneDisplayOutlines" + || action->GetName() == "pcbnew.Control.zoneDisplayTesselation" ) { - if( entry.second->GetName() == "pcbnew.Control.zoneDisplayOutlines" - || entry.second->GetName() == "pcbnew.Control.zoneDisplayTesselation" ) - { - continue; - } + continue; } - - HOTKEY& hotkey = masterMap[ entry.first ]; - hotkey.m_Actions.push_back( entry.second ); - hotkey.m_EditKeycode = entry.second->GetHotKey(); } + + HOTKEY& hotkey = masterMap[ action->GetName() ]; + hotkey.m_Actions.push_back( action ); + hotkey.m_EditKeycode = action->GetHotKey(); } wxString currentApp; diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index e993b74729..bc157218fb 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -316,9 +316,9 @@ int KeyCodeFromKeyName( const wxString& keyname ) /* * Displays the hotkeys registered with the given tool manager. */ -void DisplayHotkeyList( EDA_BASE_FRAME* aParent, TOOL_MANAGER* aToolManager ) +void DisplayHotkeyList( EDA_BASE_FRAME* aParent ) { - DIALOG_LIST_HOTKEYS dlg( aParent, aToolManager ); + DIALOG_LIST_HOTKEYS dlg( aParent ); dlg.ShowModal(); } @@ -361,7 +361,7 @@ void ReadHotKeyConfig( const wxString& aFileName, std::map& aH } -int WriteHotKeyConfig( const std::map& aActionMap ) +int WriteHotKeyConfig( const std::vector& aActions ) { std::map hotkeys; wxFileName fn( "user" ); @@ -373,16 +373,15 @@ int WriteHotKeyConfig( const std::map& aActionMap ) ReadHotKeyConfig( fn.GetFullPath(), hotkeys ); // Overlay the current app's hotkey definitions onto the map - for( const auto& ii : aActionMap ) - hotkeys[ ii.first ] = ii.second->GetHotKey(); + for( const TOOL_ACTION* action : aActions ) + hotkeys[ action->GetName() ] = action->GetHotKey(); // Write entire hotkey set wxFFileOutputStream outStream( fn.GetFullPath() ); wxTextOutputStream txtStream( outStream, wxEOL_UNIX ); - for( const auto& ii : hotkeys ) - txtStream << wxString::Format( "%s\t%s", ii.first, - KeyNameFromKeyCode( ii.second ) ) << endl; + for( const std::pair& entry : hotkeys ) + txtStream << entry.first << "\t" << KeyNameFromKeyCode( entry.second ) << endl; txtStream.Flush(); outStream.Close(); diff --git a/common/kiway.cpp b/common/kiway.cpp index ab84801f1d..069acc2add 100644 --- a/common/kiway.cpp +++ b/common/kiway.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -483,6 +484,13 @@ void KIWAY::ExpressMail( FRAME_T aDestination, MAIL_T aCommand, std::string& aPa } +void KIWAY::GetActions( std::vector& aActions ) const +{ + for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() ) + aActions.push_back( action ); +} + + void KIWAY::SetLanguage( int aLanguage ) { wxString errMsg; diff --git a/common/tool/common_control.cpp b/common/tool/common_control.cpp index df02776c2b..00244f7d2e 100644 --- a/common/tool/common_control.cpp +++ b/common/tool/common_control.cpp @@ -256,7 +256,7 @@ int COMMON_CONTROL::ShowHelp( const TOOL_EVENT& aEvent ) int COMMON_CONTROL::ListHotKeys( const TOOL_EVENT& aEvent ) { - DisplayHotkeyList( m_frame, m_toolMgr ); + DisplayHotkeyList( m_frame ); return 0; } diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index c169f142a2..817378440b 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -372,12 +372,6 @@ void TOOL_MANAGER::PostEvent( const TOOL_EVENT& aEvent ) } -const std::map& TOOL_MANAGER::GetActions() const -{ - return m_actionMgr->GetActions(); -} - - int TOOL_MANAGER::GetHotKey( const TOOL_ACTION& aAction ) const { return m_actionMgr->GetHotKey( aAction ); diff --git a/common/widgets/gal_options_panel.cpp b/common/widgets/gal_options_panel.cpp index 8319f89d3e..7908ad28f2 100644 --- a/common/widgets/gal_options_panel.cpp +++ b/common/widgets/gal_options_panel.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -65,10 +66,9 @@ static const UTIL::CFG_MAP gridSnapConfigVals = }; -GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL( wxWindow* aParent, EDA_DRAW_FRAME* aDrawFrame ) : +GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ) : wxPanel( aParent, wxID_ANY ), - m_drawFrame( aDrawFrame ), - m_galOptions( aDrawFrame->GetGalDisplayOptions() ) + m_cfg( aAppSettings ) { // the main sizer that holds "columns" of settings m_mainSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -215,27 +215,21 @@ GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL( wxWindow* aParent, EDA_DRAW_FRAME* aDrawFr bool GAL_OPTIONS_PANEL::TransferDataToWindow() { #ifndef __WXMAC__ - if( m_drawFrame->GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) + auto canvasType = static_cast( m_cfg->m_Graphics.canvas_type ); + + if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) m_renderingEngine->SetSelection( 0 ); else m_renderingEngine->SetSelection( 1 ); -#else - ignore_unused( m_drawFrame ); #endif - m_gridSnapOptions->SetSelection( UTIL::GetConfigForVal( gridSnapConfigVals, - m_galOptions.m_gridSnapping ) ); + m_gridSnapOptions->SetSelection( m_cfg->m_Window.grid.snap ); + m_gridStyle->SetSelection( m_cfg->m_Window.grid.style ); + m_gridLineWidth->SetValue( m_cfg->m_Window.grid.line_width ); + m_gridMinSpacing->SetValue( m_cfg->m_Window.grid.min_spacing ); - m_gridStyle->SetSelection( UTIL::GetConfigForVal( gridStyleSelectMap, - m_galOptions.m_gridStyle ) ); - - m_gridLineWidth->SetValue( m_galOptions.m_gridLineWidth ); - - m_gridMinSpacing->SetValue( m_galOptions.m_gridMinSpacing ); - - m_cursorShape->SetSelection( m_galOptions.m_fullscreenCursor ); - - m_forceCursorDisplay->SetValue( m_galOptions.m_forceDisplayCursor ); + m_cursorShape->SetSelection( m_cfg->m_Window.cursor.fullscreen_cursor ); + m_forceCursorDisplay->SetValue( m_cfg->m_Window.cursor.always_show_cursor ); return true; } @@ -243,28 +237,18 @@ bool GAL_OPTIONS_PANEL::TransferDataToWindow() bool GAL_OPTIONS_PANEL::TransferDataFromWindow() { - m_galOptions.m_gridSnapping = UTIL::GetValFromConfig( gridSnapConfigVals, - m_gridSnapOptions->GetSelection() ); + m_cfg->m_Window.grid.snap = m_gridSnapOptions->GetSelection(); + m_cfg->m_Window.grid.style = m_gridStyle->GetSelection(); + m_cfg->m_Window.grid.line_width = m_gridLineWidth->GetValue(); + m_cfg->m_Window.grid.min_spacing = m_gridMinSpacing->GetValue(); - m_galOptions.m_gridStyle = UTIL::GetValFromConfig( gridStyleSelectMap, - m_gridStyle->GetSelection() ); - - m_galOptions.m_gridLineWidth = m_gridLineWidth->GetValue(); - - m_galOptions.m_gridMinSpacing = m_gridMinSpacing->GetValue(); - - m_galOptions.m_fullscreenCursor = m_cursorShape->GetSelection(); - - m_galOptions.m_forceDisplayCursor = m_forceCursorDisplay->GetValue(); + m_cfg->m_Window.cursor.fullscreen_cursor = m_cursorShape->GetSelection(); + m_cfg->m_Window.cursor.always_show_cursor = m_forceCursorDisplay->GetValue(); #ifndef __WXMAC__ - EDA_DRAW_PANEL_GAL::GAL_TYPE wantedType = m_renderingEngine->GetSelection() == 0 ? + m_cfg->m_Graphics.canvas_type = m_renderingEngine->GetSelection() == 0 ? EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL : EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; - EDA_DRAW_PANEL_GAL::GAL_TYPE currentType = m_drawFrame->GetCanvas()->GetBackend(); - - if( wantedType != currentType ) - m_drawFrame->GetCanvas()->SwitchBackend( wantedType ); #endif return true; diff --git a/common/widgets/paged_dialog.cpp b/common/widgets/paged_dialog.cpp index 27671e2849..84c2c8df06 100644 --- a/common/widgets/paged_dialog.cpp +++ b/common/widgets/paged_dialog.cpp @@ -128,10 +128,7 @@ void PAGED_DIALOG::finishInitialization() m_treebook->GetTreeCtrl()->InvalidateBestSize(); for( size_t i = 0; i < m_treebook->GetPageCount(); ++i ) - { - m_treebook->ExpandNode( i ); m_treebook->GetPage( i )->Layout(); - } m_treebook->Layout(); m_treebook->Fit(); diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index cd67b694e8..07f121a5f0 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -37,7 +37,7 @@ wxDEFINE_EVENT( DELAY_FOCUS, wxCommandEvent ); -UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent, wxStaticText* aLabel, wxWindow* aValueCtrl, +UNIT_BINDER::UNIT_BINDER( EDA_BASE_FRAME* aParent, wxStaticText* aLabel, wxWindow* aValueCtrl, wxStaticText* aUnitLabel, bool allowEval ) : m_frame( aParent ), m_label( aLabel ), diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index 9b957c9859..527e1b9663 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -97,6 +97,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa // Initialize some display options auto displ_opts = GetDisplayOptions(); displ_opts.m_DisplayPadClearance = false; // Pad clearance has no meaning here + displ_opts.m_DisplayPadNoConnects = false; // Nor do connections // Track and via clearance has no meaning here. displ_opts.m_ShowTrackClearanceMode = PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE; diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 79b4fe6b2d..4918e0ec35 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -113,8 +113,8 @@ set( EESCHEMA_DLGS dialogs/dialog_update_symbol_fields.cpp dialogs/dialog_update_symbol_fields_base.cpp dialogs/panel_eeschema_color_settings.cpp - dialogs/panel_eeschema_template_fieldnames.cpp - dialogs/panel_eeschema_template_fieldnames_base.cpp + dialogs/panel_template_fieldnames.cpp + dialogs/panel_template_fieldnames_base.cpp dialogs/panel_eeschema_display_options.cpp dialogs/panel_eeschema_display_options_base.cpp dialogs/panel_eeschema_editing_options.cpp diff --git a/eeschema/dialogs/dialog_schematic_setup.cpp b/eeschema/dialogs/dialog_schematic_setup.cpp index 55a50a944f..5b34a231d2 100644 --- a/eeschema/dialogs/dialog_schematic_setup.cpp +++ b/eeschema/dialogs/dialog_schematic_setup.cpp @@ -32,7 +32,7 @@ #include #include #include "dialog_schematic_setup.h" -#include "panel_eeschema_template_fieldnames.h" +#include "panel_template_fieldnames.h" #include @@ -42,11 +42,15 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) : m_frame( aFrame ), m_severities( nullptr ) { - PROJECT_FILE& project = aFrame->Prj().GetProjectFile(); - SCHEMATIC& schematic = aFrame->Schematic(); + PROJECT_FILE& project = aFrame->Prj().GetProjectFile(); + SCHEMATIC& schematic = aFrame->Schematic(); + SCHEMATIC_SETTINGS& settings = schematic.Settings(); m_formatting = new PANEL_SETUP_FORMATTING( m_treebook, aFrame ); - m_fieldNameTemplates = new PANEL_EESCHEMA_TEMPLATE_FIELDNAMES( aFrame, m_treebook, false ); + + m_fieldNameTemplates = new PANEL_TEMPLATE_FIELDNAMES( m_treebook, + &settings.m_TemplateFieldNames ); + m_pinMap = new PANEL_SETUP_PINMAP( m_treebook, aFrame ); m_pinToPinError = ERC_ITEM::Create( ERCE_PIN_TO_PIN_WARNING ); @@ -76,7 +80,10 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) : m_treebook->AddSubPage( m_textVars, _( "Text Variables" ) ); for( size_t i = 0; i < m_treebook->GetPageCount(); ++i ) + { + m_treebook->ExpandNode( i ); m_macHack.push_back( true ); + } // Connect Events m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED, @@ -163,7 +170,6 @@ void DIALOG_SCHEMATIC_SETUP::OnAuxiliaryAction( wxCommandEvent& event ) PROJECT* otherPrj = m_frame->GetSettingsManager()->GetProject( projectFn.GetFullPath() ); SCHEMATIC otherSch( otherPrj ); - TEMPLATES templateMgr; PROJECT_FILE& file = otherPrj->GetProjectFile(); wxASSERT( file.m_SchematicSettings ); diff --git a/eeschema/dialogs/dialog_schematic_setup.h b/eeschema/dialogs/dialog_schematic_setup.h index c1d2e621ef..13498e9ad2 100644 --- a/eeschema/dialogs/dialog_schematic_setup.h +++ b/eeschema/dialogs/dialog_schematic_setup.h @@ -25,7 +25,7 @@ class SCH_EDIT_FRAME; class PANEL_SETUP_SEVERITIES; -class PANEL_EESCHEMA_TEMPLATE_FIELDNAMES; +class PANEL_TEMPLATE_FIELDNAMES; class PANEL_SETUP_FORMATTING; class PANEL_SETUP_PINMAP; class PANEL_TEXT_VARIABLES; @@ -42,17 +42,17 @@ public: protected: void OnAuxiliaryAction( wxCommandEvent& event ) override; - SCH_EDIT_FRAME* m_frame; + SCH_EDIT_FRAME* m_frame; - PANEL_SETUP_FORMATTING* m_formatting; - PANEL_EESCHEMA_TEMPLATE_FIELDNAMES* m_fieldNameTemplates; - PANEL_SETUP_PINMAP* m_pinMap; - PANEL_SETUP_SEVERITIES* m_severities; - PANEL_SETUP_NETCLASSES* m_netclasses; - PANEL_TEXT_VARIABLES* m_textVars; - std::shared_ptr m_pinToPinError; + PANEL_SETUP_FORMATTING* m_formatting; + PANEL_TEMPLATE_FIELDNAMES* m_fieldNameTemplates; + PANEL_SETUP_PINMAP* m_pinMap; + PANEL_SETUP_SEVERITIES* m_severities; + PANEL_SETUP_NETCLASSES* m_netclasses; + PANEL_TEXT_VARIABLES* m_textVars; + std::shared_ptr m_pinToPinError; - std::vector m_macHack; + std::vector m_macHack; // event handlers void OnPageChange( wxBookCtrlEvent& event ); diff --git a/eeschema/dialogs/dialog_sheet_properties.cpp b/eeschema/dialogs/dialog_sheet_properties.cpp index 72e96f4319..70bf11ab0f 100644 --- a/eeschema/dialogs/dialog_sheet_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_properties.cpp @@ -354,7 +354,7 @@ bool DIALOG_SHEET_PROPERTIES::TransferDataFromWindow() { wxPanel temp( this ); temp.Hide(); - PANEL_EESCHEMA_COLOR_SETTINGS prefs( m_frame, &temp ); + PANEL_EESCHEMA_COLOR_SETTINGS prefs( &temp ); wxString checkboxLabel = prefs.m_optOverrideColors->GetLabel(); KIDIALOG dlg( this, _( "Note: item colors are overridden in the current color theme." ), diff --git a/eeschema/dialogs/panel_eeschema_color_settings.cpp b/eeschema/dialogs/panel_eeschema_color_settings.cpp index e0954d380f..88cc37756e 100644 --- a/eeschema/dialogs/panel_eeschema_color_settings.cpp +++ b/eeschema/dialogs/panel_eeschema_color_settings.cpp @@ -54,10 +54,8 @@ std::set g_excludedLayers = }; -PANEL_EESCHEMA_COLOR_SETTINGS::PANEL_EESCHEMA_COLOR_SETTINGS( SCH_BASE_FRAME* aFrame, - wxWindow* aParent ) : +PANEL_EESCHEMA_COLOR_SETTINGS::PANEL_EESCHEMA_COLOR_SETTINGS( wxWindow* aParent ) : PANEL_COLOR_SETTINGS( aParent ), - m_frame( aFrame ), m_preview( nullptr ), m_page( nullptr ), m_titleBlock( nullptr ), @@ -67,9 +65,6 @@ PANEL_EESCHEMA_COLOR_SETTINGS::PANEL_EESCHEMA_COLOR_SETTINGS( SCH_BASE_FRAME* aF m_colorNamespace = "schematic"; SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); - - mgr.ReloadColorSettings(); - COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings(); EESCHEMA_SETTINGS* app_settings = mgr.GetAppSettings(); COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme ); @@ -94,26 +89,10 @@ PANEL_EESCHEMA_COLOR_SETTINGS::PANEL_EESCHEMA_COLOR_SETTINGS( SCH_BASE_FRAME* aF m_backgroundLayer = LAYER_SCHEMATIC_BACKGROUND; - createSwatches(); - m_galDisplayOptions.ReadConfig( *common_settings, app_settings->m_Window, this ); m_galDisplayOptions.m_forceDisplayCursor = false; - auto type = static_cast( app_settings->m_Graphics.canvas_type ); - - m_preview = new SCH_PREVIEW_PANEL( this, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ), - m_galDisplayOptions, type ); - m_preview->SetStealsFocus( false ); - m_preview->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER ); - m_preview->GetGAL()->SetAxesEnabled( false ); - - m_colorsMainSizer->Add( 10, 0, 0, wxEXPAND, 5 ); - m_colorsMainSizer->Add( m_preview, 1, wxALL | wxEXPAND, 5 ); - m_colorsMainSizer->Add( 10, 0, 0, wxEXPAND, 5 ); - - createPreviewItems(); - updatePreview(); - zoomFitPreview(); + m_galType = static_cast( app_settings->m_Graphics.canvas_type ); } @@ -136,8 +115,6 @@ bool PANEL_EESCHEMA_COLOR_SETTINGS::TransferDataFromWindow() if( !saveCurrentTheme( true ) ) return false; - m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings()->LoadColors( m_currentSettings ); - SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager(); EESCHEMA_SETTINGS* app_settings = settingsMgr.GetAppSettings(); app_settings->m_ColorTheme = m_currentSettings->GetFilename(); @@ -231,6 +208,22 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createSwatches() int min_width = m_colorsGridSizer->GetMinSize().x; const int margin = 20; // A margin around the sizer m_colorsListWindow->SetMinSize( wxSize( min_width + margin, -1 ) ); + + m_preview = new SCH_PREVIEW_PANEL( this, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ), + m_galDisplayOptions, m_galType ); + m_preview->SetStealsFocus( false ); + m_preview->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER ); + m_preview->GetGAL()->SetAxesEnabled( false ); + + m_colorsMainSizer->Add( 10, 0, 0, wxEXPAND, 5 ); + m_colorsMainSizer->Add( m_preview, 1, wxALL | wxEXPAND, 5 ); + m_colorsMainSizer->Add( 10, 0, 0, wxEXPAND, 5 ); + + m_colorsMainSizer->Layout(); + + createPreviewItems(); + updatePreview(); + zoomFitPreview(); } @@ -495,18 +488,21 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::updatePreview() void PANEL_EESCHEMA_COLOR_SETTINGS::zoomFitPreview() { - KIGFX::VIEW* view = m_preview->GetView(); + if( m_preview ) + { + KIGFX::VIEW* view = m_preview->GetView(); - view->SetScale( 1.0 ); - VECTOR2D screenSize = view->ToWorld( m_preview->GetClientSize(), false ); + view->SetScale( 1.0 ); + VECTOR2D screenSize = view->ToWorld( m_preview->GetClientSize(), false ); - VECTOR2I psize( m_page->GetWidthIU(), m_page->GetHeightIU() ); - double scale = view->GetScale() / std::max( fabs( psize.x / screenSize.x ), - fabs( psize.y / screenSize.y ) ); + VECTOR2I psize( m_page->GetWidthIU(), m_page->GetHeightIU() ); + double scale = view->GetScale() / std::max( fabs( psize.x / screenSize.x ), + fabs( psize.y / screenSize.y ) ); - view->SetScale( scale * m_galDisplayOptions.m_scaleFactor * 0.8 /* margin */ ); - view->SetCenter( m_drawingSheet->ViewBBox().Centre() ); - m_preview->ForceRefresh(); + view->SetScale( scale * m_galDisplayOptions.m_scaleFactor * 0.8 /* margin */ ); + view->SetCenter( m_drawingSheet->ViewBBox().Centre() ); + m_preview->ForceRefresh(); + } } diff --git a/eeschema/dialogs/panel_eeschema_color_settings.h b/eeschema/dialogs/panel_eeschema_color_settings.h index 08f8080fbe..ca840cbae3 100644 --- a/eeschema/dialogs/panel_eeschema_color_settings.h +++ b/eeschema/dialogs/panel_eeschema_color_settings.h @@ -22,15 +22,11 @@ #ifndef PANEL_EESCHEMA_COLOR_SETTINGS_H_ #define PANEL_EESCHEMA_COLOR_SETTINGS_H_ -#include -#include -#include #include +#include -class COLOR_SETTINGS; -class SCH_BASE_FRAME; class PAGE_INFO; -class SCH_ITEM; +class EDA_ITEM; class SCH_PREVIEW_PANEL; class TITLE_BLOCK; class DS_PROXY_VIEW_ITEM; @@ -39,7 +35,7 @@ class DS_PROXY_VIEW_ITEM; class PANEL_EESCHEMA_COLOR_SETTINGS : public PANEL_COLOR_SETTINGS { public: - PANEL_EESCHEMA_COLOR_SETTINGS( SCH_BASE_FRAME* aFrame, wxWindow* aParent ); + PANEL_EESCHEMA_COLOR_SETTINGS( wxWindow* aParent ); ~PANEL_EESCHEMA_COLOR_SETTINGS() override; @@ -59,23 +55,23 @@ protected: bool saveCurrentTheme( bool aValidate ) override; -private: - SCH_BASE_FRAME* m_frame; - - SCH_PREVIEW_PANEL* m_preview; - PAGE_INFO* m_page; - TITLE_BLOCK* m_titleBlock; - DS_PROXY_VIEW_ITEM* m_drawingSheet; - std::vector m_previewItems; - - KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions; + void createSwatches() override; private: void createPreviewItems(); - void createSwatches(); void updatePreview(); void zoomFitPreview(); + +private: + SCH_PREVIEW_PANEL* m_preview; + PAGE_INFO* m_page; + TITLE_BLOCK* m_titleBlock; + DS_PROXY_VIEW_ITEM* m_drawingSheet; + std::vector m_previewItems; + + KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions; + EDA_DRAW_PANEL_GAL::GAL_TYPE m_galType; }; diff --git a/eeschema/dialogs/panel_eeschema_display_options.cpp b/eeschema/dialogs/panel_eeschema_display_options.cpp index e8add0f2ca..838ffc434b 100644 --- a/eeschema/dialogs/panel_eeschema_display_options.cpp +++ b/eeschema/dialogs/panel_eeschema_display_options.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2009 Wayne Stambaugh - * Copyright (C) 1992-2020 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 @@ -22,18 +22,18 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include +#include +#include +#include #include #include -#include +#include -PANEL_EESCHEMA_DISPLAY_OPTIONS::PANEL_EESCHEMA_DISPLAY_OPTIONS( SCH_EDIT_FRAME* aFrame, - wxWindow* aWindow ) : - PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE( aWindow ), - m_frame( aFrame ) +PANEL_EESCHEMA_DISPLAY_OPTIONS::PANEL_EESCHEMA_DISPLAY_OPTIONS( wxWindow* aParent, + APP_SETTINGS_BASE* aAppSettings ) : + PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE( aParent ) { - m_galOptsPanel = new GAL_OPTIONS_PANEL( this, m_frame ); + m_galOptsPanel = new GAL_OPTIONS_PANEL( this, aAppSettings ); m_galOptionsSizer->Add( m_galOptsPanel, 1, wxEXPAND, 0 ); @@ -43,7 +43,8 @@ PANEL_EESCHEMA_DISPLAY_OPTIONS::PANEL_EESCHEMA_DISPLAY_OPTIONS( SCH_EDIT_FRAME* bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataToWindow() { - EESCHEMA_SETTINGS* cfg = m_frame->eeconfig(); + 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 ); @@ -66,7 +67,8 @@ bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataToWindow() bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow() { - EESCHEMA_SETTINGS* cfg = m_frame->eeconfig(); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings(); cfg->m_Appearance.show_hidden_pins = m_checkShowHiddenPins->GetValue(); cfg->m_Appearance.show_hidden_fields = m_checkShowHiddenFields->GetValue(); @@ -81,14 +83,6 @@ bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow() cfg->m_CrossProbing.zoom_to_fit = m_checkCrossProbeZoom->GetValue(); cfg->m_CrossProbing.auto_highlight = m_checkCrossProbeAutoHighlight->GetValue(); - // Update canvas - m_frame->GetRenderSettings()->m_ShowHiddenPins = m_checkShowHiddenPins->GetValue(); - m_frame->GetRenderSettings()->m_ShowHiddenText = m_checkShowHiddenFields->GetValue(); - m_frame->GetRenderSettings()->SetShowPageLimits( cfg->m_Appearance.show_page_limits ); - m_frame->GetCanvas()->GetView()->MarkDirty(); - m_frame->GetCanvas()->GetView()->UpdateAllItems( KIGFX::REPAINT ); - m_frame->GetCanvas()->Refresh(); - m_galOptsPanel->TransferDataFromWindow(); return true; diff --git a/eeschema/dialogs/panel_eeschema_display_options.h b/eeschema/dialogs/panel_eeschema_display_options.h index aee56256c0..c65c60f72b 100644 --- a/eeschema/dialogs/panel_eeschema_display_options.h +++ b/eeschema/dialogs/panel_eeschema_display_options.h @@ -17,28 +17,26 @@ * with this program. If not, see . */ -#ifndef KICAD_PANEL_EESCHEMA_DISPLAY_OPTIONS_H -#define KICAD_PANEL_EESCHEMA_DISPLAY_OPTIONS_H +#ifndef PANEL_EESCHEMA_DISPLAY_OPTIONS_H +#define PANEL_EESCHEMA_DISPLAY_OPTIONS_H -#include #include "panel_eeschema_display_options_base.h" -class SCH_EDIT_FRAME; +class APP_SETTINGS_BASE; class GAL_OPTIONS_PANEL; class PANEL_EESCHEMA_DISPLAY_OPTIONS : public PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE { public: - PANEL_EESCHEMA_DISPLAY_OPTIONS( SCH_EDIT_FRAME* aFrame, wxWindow* aWindow ); + PANEL_EESCHEMA_DISPLAY_OPTIONS( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ); private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; - SCH_EDIT_FRAME* m_frame; GAL_OPTIONS_PANEL* m_galOptsPanel; }; -#endif //KICAD_PANEL_EESCHEMA_DISPLAY_OPTIONS_H +#endif // PANEL_EESCHEMA_DISPLAY_OPTIONS_H diff --git a/eeschema/dialogs/panel_eeschema_editing_options.cpp b/eeschema/dialogs/panel_eeschema_editing_options.cpp index 1853ca7660..04e46bcca5 100644 --- a/eeschema/dialogs/panel_eeschema_editing_options.cpp +++ b/eeschema/dialogs/panel_eeschema_editing_options.cpp @@ -22,20 +22,18 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include #include -#include #include #include "panel_eeschema_editing_options.h" -PANEL_EESCHEMA_EDITING_OPTIONS::PANEL_EESCHEMA_EDITING_OPTIONS( SCH_EDIT_FRAME* aFrame, - wxWindow* aWindow ) : +PANEL_EESCHEMA_EDITING_OPTIONS::PANEL_EESCHEMA_EDITING_OPTIONS( wxWindow* aWindow, + EDA_BASE_FRAME* aUnitsProvider ) : PANEL_EESCHEMA_EDITING_OPTIONS_BASE( aWindow ), - m_frame( aFrame ), - m_hPitch( aFrame, m_hPitchLabel, m_hPitchCtrl, m_hPitchUnits ), - m_vPitch( aFrame, m_vPitchLabel, m_vPitchCtrl, m_vPitchUnits ) + m_hPitch( aUnitsProvider, m_hPitchLabel, m_hPitchCtrl, m_hPitchUnits ), + m_vPitch( aUnitsProvider, m_vPitchLabel, m_vPitchCtrl, m_vPitchUnits ) { // Make the color swatch show "Clear Color" instead m_borderColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); @@ -51,13 +49,14 @@ PANEL_EESCHEMA_EDITING_OPTIONS::PANEL_EESCHEMA_EDITING_OPTIONS( SCH_EDIT_FRAME* bool PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataToWindow() { - EESCHEMA_SETTINGS* cfg = m_frame->eeconfig(); + 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 = m_frame->GetColorSettings(); + COLOR_SETTINGS* settings = mgr.GetColorSettings(); COLOR4D schematicBackground = settings->GetColor( LAYER_SCHEMATIC_BACKGROUND ); m_borderColorSwatch->SetSwatchBackground( schematicBackground ); @@ -85,7 +84,8 @@ bool PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataToWindow() bool PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataFromWindow() { - EESCHEMA_SETTINGS* cfg = m_frame->eeconfig(); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings(); cfg->m_Drawing.default_sheet_border_color = m_borderColorSwatch->GetSwatchColor(); cfg->m_Drawing.default_sheet_background_color = m_backgroundColorSwatch->GetSwatchColor(); @@ -107,8 +107,6 @@ bool PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataFromWindow() cfg->m_Drawing.auto_start_wires = m_cbAutoStartWires->GetValue(); - m_frame->SaveProjectSettings(); - return true; } diff --git a/eeschema/dialogs/panel_eeschema_editing_options.h b/eeschema/dialogs/panel_eeschema_editing_options.h index 17b126d6fb..84acf646e9 100644 --- a/eeschema/dialogs/panel_eeschema_editing_options.h +++ b/eeschema/dialogs/panel_eeschema_editing_options.h @@ -23,19 +23,18 @@ #include #include "panel_eeschema_editing_options_base.h" -class SCH_EDIT_FRAME; +class EDA_BASE_FRAME; class PANEL_EESCHEMA_EDITING_OPTIONS : public PANEL_EESCHEMA_EDITING_OPTIONS_BASE { public: - PANEL_EESCHEMA_EDITING_OPTIONS( SCH_EDIT_FRAME* aFrame, wxWindow* aWindow ); + PANEL_EESCHEMA_EDITING_OPTIONS( wxWindow* aWindow, EDA_BASE_FRAME* aUnitsProvider ); private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; - SCH_EDIT_FRAME* m_frame; UNIT_BINDER m_hPitch; UNIT_BINDER m_vPitch; }; diff --git a/eeschema/dialogs/panel_sym_color_settings.cpp b/eeschema/dialogs/panel_sym_color_settings.cpp index 00acca04c8..a49e72bf29 100644 --- a/eeschema/dialogs/panel_sym_color_settings.cpp +++ b/eeschema/dialogs/panel_sym_color_settings.cpp @@ -21,31 +21,29 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include -#include -#include +#include #include +#include #include "panel_sym_color_settings.h" -PANEL_SYM_COLOR_SETTINGS::PANEL_SYM_COLOR_SETTINGS( SYMBOL_EDIT_FRAME* aFrame, - wxWindow* aWindow ) - : PANEL_SYM_COLOR_SETTINGS_BASE( aWindow ), m_frame( aFrame ) +PANEL_SYM_COLOR_SETTINGS::PANEL_SYM_COLOR_SETTINGS( wxWindow* aWindow ) : + PANEL_SYM_COLOR_SETTINGS_BASE( aWindow ) { } bool PANEL_SYM_COLOR_SETTINGS::TransferDataToWindow() { - SYMBOL_EDITOR_SETTINGS* cfg = m_frame->GetSettings(); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + SYMBOL_EDITOR_SETTINGS* cfg = mgr.GetAppSettings(); if( cfg->m_UseEeschemaColorSettings ) m_eeschemaRB->SetValue( true ); else m_themeRB->SetValue( true ); - COLOR_SETTINGS* current = m_frame->GetSettingsManager()->GetColorSettings( cfg->m_ColorTheme ); + COLOR_SETTINGS* current = mgr.GetColorSettings( cfg->m_ColorTheme ); int width = 0; int height = 0; @@ -53,7 +51,7 @@ bool PANEL_SYM_COLOR_SETTINGS::TransferDataToWindow() m_themes->Clear(); - for( COLOR_SETTINGS* settings : m_frame->GetSettingsManager()->GetColorSettingsList() ) + for( COLOR_SETTINGS* settings : mgr.GetColorSettingsList() ) { int pos = m_themes->Append( settings->GetName(), static_cast( settings ) ); @@ -74,26 +72,19 @@ bool PANEL_SYM_COLOR_SETTINGS::TransferDataToWindow() bool PANEL_SYM_COLOR_SETTINGS::TransferDataFromWindow() { - SETTINGS_MANAGER* mgr = m_frame->GetSettingsManager(); - int sel = m_themes->GetSelection(); - COLOR_SETTINGS* colors = static_cast( m_themes->GetClientData( sel ) ); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + SYMBOL_EDITOR_SETTINGS* cfg = mgr.GetAppSettings(); - SYMBOL_EDITOR_SETTINGS* cfg = mgr->GetAppSettings(); cfg->m_UseEeschemaColorSettings = m_eeschemaRB->GetValue(); - if( cfg->m_UseEeschemaColorSettings ) - { - EESCHEMA_SETTINGS* eecfg = mgr->GetAppSettings(); - colors = mgr->GetColorSettings( eecfg->m_ColorTheme ); - } - else + if( !cfg->m_UseEeschemaColorSettings ) { + int sel = m_themes->GetSelection(); + COLOR_SETTINGS* colors = static_cast( m_themes->GetClientData( sel ) ); + cfg->m_ColorTheme = colors->GetFilename(); } - RENDER_SETTINGS* settings = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings(); - settings->LoadColors( colors ); - return true; } diff --git a/eeschema/dialogs/panel_sym_color_settings.h b/eeschema/dialogs/panel_sym_color_settings.h index cf88d1d7d3..69e65bf66b 100644 --- a/eeschema/dialogs/panel_sym_color_settings.h +++ b/eeschema/dialogs/panel_sym_color_settings.h @@ -26,13 +26,11 @@ #include "panel_sym_color_settings_base.h" -class SYMBOL_EDIT_FRAME; - class PANEL_SYM_COLOR_SETTINGS : public PANEL_SYM_COLOR_SETTINGS_BASE { public: - PANEL_SYM_COLOR_SETTINGS( SYMBOL_EDIT_FRAME* aFrame, wxWindow* aWindow ); + PANEL_SYM_COLOR_SETTINGS( wxWindow* aWindow ); protected: void OnThemeChanged( wxCommandEvent& event ) override; @@ -41,8 +39,6 @@ private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; - - SYMBOL_EDIT_FRAME* m_frame; }; #endif diff --git a/eeschema/dialogs/panel_sym_editing_options.cpp b/eeschema/dialogs/panel_sym_editing_options.cpp index f07fb38550..27c2c511ec 100644 --- a/eeschema/dialogs/panel_sym_editing_options.cpp +++ b/eeschema/dialogs/panel_sym_editing_options.cpp @@ -22,29 +22,27 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include +#include #include #include - #include "panel_sym_editing_options.h" -PANEL_SYM_EDITING_OPTIONS::PANEL_SYM_EDITING_OPTIONS( SYMBOL_EDIT_FRAME* aFrame, - wxWindow* aWindow ) : +PANEL_SYM_EDITING_OPTIONS::PANEL_SYM_EDITING_OPTIONS( wxWindow* aWindow, + EDA_BASE_FRAME* aUnitsProvider ) : PANEL_SYM_EDITING_OPTIONS_BASE( aWindow ), - m_frame( aFrame ), - m_lineWidth( aFrame, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits ), - m_textSize( aFrame, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits ), - m_pinLength( aFrame, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits ), - m_pinNameSize( aFrame, m_pinNameSizeLabel, m_pinNameSizeCtrl, m_pinNameSizeUnits ), - m_pinNumberSize( aFrame, m_pinNumSizeLabel, m_pinNumSizeCtrl, m_pinNumSizeUnits ) + m_lineWidth( aUnitsProvider, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits ), + m_textSize( aUnitsProvider, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits ), + m_pinLength( aUnitsProvider, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits ), + m_pinNameSize( aUnitsProvider, m_pinNameSizeLabel, m_pinNameSizeCtrl, m_pinNameSizeUnits ), + m_pinNumberSize( aUnitsProvider, m_pinNumSizeLabel, m_pinNumSizeCtrl, m_pinNumSizeUnits ) {} bool PANEL_SYM_EDITING_OPTIONS::TransferDataToWindow() { - SYMBOL_EDITOR_SETTINGS* settings = m_frame->GetSettings(); + 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 ) ); @@ -53,8 +51,7 @@ bool PANEL_SYM_EDITING_OPTIONS::TransferDataToWindow() 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( m_frame->GetRenderSettings()->m_ShowPinsElectricalType ); + m_cbShowPinElectricalType->SetValue( settings->m_ShowPinElectricalType ); return true; } @@ -62,7 +59,8 @@ bool PANEL_SYM_EDITING_OPTIONS::TransferDataToWindow() bool PANEL_SYM_EDITING_OPTIONS::TransferDataFromWindow() { - SYMBOL_EDITOR_SETTINGS* settings = m_frame->GetSettings(); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + SYMBOL_EDITOR_SETTINGS* settings = mgr.GetAppSettings(); settings->m_Defaults.line_width = Iu2Mils( (int) m_lineWidth.GetValue() ); settings->m_Defaults.text_size = Iu2Mils( (int) m_textSize.GetValue() ); @@ -71,9 +69,7 @@ bool PANEL_SYM_EDITING_OPTIONS::TransferDataFromWindow() settings->m_Defaults.pin_name_size = Iu2Mils( (int) m_pinNameSize.GetValue() ); settings->m_Repeat.label_delta = m_spinRepeatLabel->GetValue(); settings->m_Repeat.pin_step = m_choicePinDisplacement->GetSelection() == 1 ? 50 : 100; - - m_frame->GetRenderSettings()->m_ShowPinsElectricalType = m_cbShowPinElectricalType->GetValue(); - m_frame->GetCanvas()->Refresh(); + settings->m_ShowPinElectricalType = m_cbShowPinElectricalType->GetValue(); return true; } diff --git a/eeschema/dialogs/panel_sym_editing_options.h b/eeschema/dialogs/panel_sym_editing_options.h index 4e73cd44fa..70c89c2568 100644 --- a/eeschema/dialogs/panel_sym_editing_options.h +++ b/eeschema/dialogs/panel_sym_editing_options.h @@ -23,20 +23,18 @@ #include #include "panel_sym_editing_options_base.h" -class SYMBOL_EDIT_FRAME; +class EDA_BASE_FRAME; class PANEL_SYM_EDITING_OPTIONS : public PANEL_SYM_EDITING_OPTIONS_BASE { public: - PANEL_SYM_EDITING_OPTIONS( SYMBOL_EDIT_FRAME* aFrame, wxWindow* aWindow ); + PANEL_SYM_EDITING_OPTIONS( wxWindow* aWindow, EDA_BASE_FRAME* aUnitsProvider ); private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; - SYMBOL_EDIT_FRAME* m_frame; - UNIT_BINDER m_lineWidth; UNIT_BINDER m_textSize; diff --git a/eeschema/dialogs/panel_eeschema_template_fieldnames.cpp b/eeschema/dialogs/panel_template_fieldnames.cpp similarity index 70% rename from eeschema/dialogs/panel_eeschema_template_fieldnames.cpp rename to eeschema/dialogs/panel_template_fieldnames.cpp index 78631c1c81..01e03a8781 100644 --- a/eeschema/dialogs/panel_eeschema_template_fieldnames.cpp +++ b/eeschema/dialogs/panel_template_fieldnames.cpp @@ -22,24 +22,53 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include +#include +#include #include #include #include -#include #include -#include -#include -#include +#include +#include -PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::PANEL_EESCHEMA_TEMPLATE_FIELDNAMES( SCH_EDIT_FRAME* aFrame, - wxWindow* aWindow, - bool aGlobal ) : - PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE( aWindow ), - m_frame( aFrame ), - m_global( aGlobal ) +PANEL_TEMPLATE_FIELDNAMES::PANEL_TEMPLATE_FIELDNAMES( wxWindow* aWindow, + TEMPLATES* aProjectTemplateMgr ) : + PANEL_TEMPLATE_FIELDNAMES_BASE( aWindow ) { - m_title->SetLabel( aGlobal ? _( "Global field name templates:" ) - : _( "Project field name templates:" ) ); + if( aProjectTemplateMgr ) + { + m_title->SetLabel( _( "Project field name templates:" ) ); + m_global = false; + m_templateMgr = aProjectTemplateMgr; + } + else + { + m_title->SetLabel( _( "Global field name templates:" ) ); + m_global = true; + m_templateMgr = &m_templateMgrInstance; + + EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); + + if( cfg ) + { + // Read global fieldname templates + wxString templateFieldNames = cfg->m_Drawing.field_names; + + if( !templateFieldNames.IsEmpty() ) + { + TEMPLATE_FIELDNAMES_LEXER field_lexer( TO_UTF8( templateFieldNames ) ); + + try + { + m_templateMgr->Parse( &field_lexer, true ); + } + catch( const IO_ERROR& ) + { + } + } + } + } m_addFieldButton->SetBitmap( KiBitmap( BITMAPS::small_plus ) ); m_deleteFieldButton->SetBitmap( KiBitmap( BITMAPS::small_trash ) ); @@ -51,23 +80,22 @@ PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::PANEL_EESCHEMA_TEMPLATE_FIELDNAMES( SCH_EDIT } -PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::~PANEL_EESCHEMA_TEMPLATE_FIELDNAMES() +PANEL_TEMPLATE_FIELDNAMES::~PANEL_TEMPLATE_FIELDNAMES() { // Delete the GRID_TRICKS. m_grid->PopEventHandler( true ); } -bool PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataToWindow() +bool PANEL_TEMPLATE_FIELDNAMES::TransferDataToWindow() { - SCHEMATIC& schematic = m_frame->Schematic(); + m_fields = m_templateMgr->GetTemplateFieldNames( true ); - m_fields = schematic.Settings().m_TemplateFieldNames.GetTemplateFieldNames( m_global ); return TransferDataToGrid(); } -void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnAddButtonClick( wxCommandEvent& event ) +void PANEL_TEMPLATE_FIELDNAMES::OnAddButtonClick( wxCommandEvent& event ) { if( !m_grid->CommitPendingChanges() ) return; @@ -86,7 +114,7 @@ void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnAddButtonClick( wxCommandEvent& event } -void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnDeleteButtonClick( wxCommandEvent& event ) +void PANEL_TEMPLATE_FIELDNAMES::OnDeleteButtonClick( wxCommandEvent& event ) { if( !m_grid->CommitPendingChanges() ) return; @@ -113,7 +141,7 @@ void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnDeleteButtonClick( wxCommandEvent& ev } -bool PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataToGrid() +bool PANEL_TEMPLATE_FIELDNAMES::TransferDataToGrid() { m_grid->Freeze(); @@ -145,7 +173,7 @@ bool PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataToGrid() } -bool PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataFromGrid() +bool PANEL_TEMPLATE_FIELDNAMES::TransferDataFromGrid() { if( !m_grid->CommitPendingChanges() ) return false; @@ -161,27 +189,25 @@ bool PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataFromGrid() } -bool PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataFromWindow() +bool PANEL_TEMPLATE_FIELDNAMES::TransferDataFromWindow() { if( !TransferDataFromGrid() ) return false; - SCHEMATIC& schematic = m_frame->Schematic(); - - schematic.Settings().m_TemplateFieldNames.DeleteAllFieldNameTemplates( m_global ); + m_templateMgr->DeleteAllFieldNameTemplates( m_global ); for( const TEMPLATE_FIELDNAME& field : m_fields ) - schematic.Settings().m_TemplateFieldNames.AddTemplateFieldName( field, m_global ); + m_templateMgr->AddTemplateFieldName( field, m_global ); if( m_global ) { - auto* cfg = dynamic_cast( Kiface().KifaceSettings() ); + EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); if( cfg ) { // Save global fieldname templates STRING_FORMATTER sf; - schematic.Settings().m_TemplateFieldNames.Format( &sf, 0, true ); + m_templateMgr->Format( &sf, 0, true ); wxString record = FROM_UTF8( sf.GetString().c_str() ); record.Replace( wxT("\n"), wxT(""), true ); // strip all newlines @@ -195,7 +221,7 @@ bool PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataFromWindow() } -void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::AdjustGridColumns( int aWidth ) +void PANEL_TEMPLATE_FIELDNAMES::AdjustGridColumns( int aWidth ) { if( aWidth <= 0 ) return; @@ -209,7 +235,7 @@ void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::AdjustGridColumns( int aWidth ) } -void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnSizeGrid( wxSizeEvent& event ) +void PANEL_TEMPLATE_FIELDNAMES::OnSizeGrid( wxSizeEvent& event ) { AdjustGridColumns( event.GetSize().GetX() ); @@ -217,7 +243,7 @@ void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::OnSizeGrid( wxSizeEvent& event ) } -void PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::ImportSettingsFrom( TEMPLATES* templateMgr ) +void PANEL_TEMPLATE_FIELDNAMES::ImportSettingsFrom( TEMPLATES* templateMgr ) { m_fields = templateMgr->GetTemplateFieldNames( m_global ); TransferDataToGrid(); diff --git a/eeschema/dialogs/panel_eeschema_template_fieldnames.h b/eeschema/dialogs/panel_template_fieldnames.h similarity index 83% rename from eeschema/dialogs/panel_eeschema_template_fieldnames.h rename to eeschema/dialogs/panel_template_fieldnames.h index 61ee7d5257..9443f34914 100644 --- a/eeschema/dialogs/panel_eeschema_template_fieldnames.h +++ b/eeschema/dialogs/panel_template_fieldnames.h @@ -21,16 +21,16 @@ #define PANEL_EESCHEMA_DEFUALT_FIELDS_H #include -#include "panel_eeschema_template_fieldnames_base.h" +#include "panel_template_fieldnames_base.h" class SCH_EDIT_FRAME; -class PANEL_EESCHEMA_TEMPLATE_FIELDNAMES : public PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE +class PANEL_TEMPLATE_FIELDNAMES : public PANEL_TEMPLATE_FIELDNAMES_BASE { public: - PANEL_EESCHEMA_TEMPLATE_FIELDNAMES( SCH_EDIT_FRAME* aFrame, wxWindow* aWindow, bool aGlobal ); - ~PANEL_EESCHEMA_TEMPLATE_FIELDNAMES() override; + PANEL_TEMPLATE_FIELDNAMES( wxWindow* aWindow, TEMPLATES* aProjectTemplateMgr ); + ~PANEL_TEMPLATE_FIELDNAMES() override; void ImportSettingsFrom( TEMPLATES* templateMgr ); @@ -67,11 +67,12 @@ private: bool TransferDataFromGrid(); protected: - SCH_EDIT_FRAME* m_frame; + TEMPLATES* m_templateMgr; TEMPLATE_FIELDNAMES m_fields; - bool m_global; // Editing global (vs. project) fieldname templates + bool m_global; // Editing global (vs. project) fieldname templates int m_checkboxColWidth; + TEMPLATES m_templateMgrInstance; }; diff --git a/eeschema/dialogs/panel_eeschema_template_fieldnames_base.cpp b/eeschema/dialogs/panel_template_fieldnames_base.cpp similarity index 74% rename from eeschema/dialogs/panel_eeschema_template_fieldnames_base.cpp rename to eeschema/dialogs/panel_template_fieldnames_base.cpp index 9fd8983cc2..460b9e4fed 100644 --- a/eeschema/dialogs/panel_eeschema_template_fieldnames_base.cpp +++ b/eeschema/dialogs/panel_template_fieldnames_base.cpp @@ -7,11 +7,11 @@ #include "widgets/wx_grid.h" -#include "panel_eeschema_template_fieldnames_base.h" +#include "panel_template_fieldnames_base.h" /////////////////////////////////////////////////////////////////////////// -PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE::PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_TEMPLATE_FIELDNAMES_BASE::PANEL_TEMPLATE_FIELDNAMES_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) { wxBoxSizer* bPanelSizer; bPanelSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -85,16 +85,16 @@ PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE::PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE bPanelSizer->Fit( this ); // Connect Events - m_grid->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE::OnSizeGrid ), NULL, this ); - m_addFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE::OnAddButtonClick ), NULL, this ); - m_deleteFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE::OnDeleteButtonClick ), NULL, this ); + m_grid->Connect( wxEVT_SIZE, wxSizeEventHandler( PANEL_TEMPLATE_FIELDNAMES_BASE::OnSizeGrid ), NULL, this ); + m_addFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_TEMPLATE_FIELDNAMES_BASE::OnAddButtonClick ), NULL, this ); + m_deleteFieldButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_TEMPLATE_FIELDNAMES_BASE::OnDeleteButtonClick ), NULL, this ); } -PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE::~PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE() +PANEL_TEMPLATE_FIELDNAMES_BASE::~PANEL_TEMPLATE_FIELDNAMES_BASE() { // Disconnect Events - m_grid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE::OnSizeGrid ), NULL, this ); - m_addFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE::OnAddButtonClick ), NULL, this ); - m_deleteFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE::OnDeleteButtonClick ), NULL, this ); + m_grid->Disconnect( wxEVT_SIZE, wxSizeEventHandler( PANEL_TEMPLATE_FIELDNAMES_BASE::OnSizeGrid ), NULL, this ); + m_addFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_TEMPLATE_FIELDNAMES_BASE::OnAddButtonClick ), NULL, this ); + m_deleteFieldButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_TEMPLATE_FIELDNAMES_BASE::OnDeleteButtonClick ), NULL, this ); } diff --git a/eeschema/dialogs/panel_eeschema_template_fieldnames_base.fbp b/eeschema/dialogs/panel_template_fieldnames_base.fbp similarity index 99% rename from eeschema/dialogs/panel_eeschema_template_fieldnames_base.fbp rename to eeschema/dialogs/panel_template_fieldnames_base.fbp index ef63091df4..16b098eff2 100644 --- a/eeschema/dialogs/panel_eeschema_template_fieldnames_base.fbp +++ b/eeschema/dialogs/panel_template_fieldnames_base.fbp @@ -11,12 +11,12 @@ res UTF-8 connect - panel_eeschema_template_fieldnames_base + panel_template_fieldnames_base 1000 none 1 - PanelEeschemaTemplateFieldnames + PanelTemplateFieldnames . @@ -41,7 +41,7 @@ wxID_ANY - PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE + PANEL_TEMPLATE_FIELDNAMES_BASE -1,-1 ; forward_declare diff --git a/eeschema/dialogs/panel_eeschema_template_fieldnames_base.h b/eeschema/dialogs/panel_template_fieldnames_base.h similarity index 78% rename from eeschema/dialogs/panel_eeschema_template_fieldnames_base.h rename to eeschema/dialogs/panel_template_fieldnames_base.h index 20653729cd..acbcce7863 100644 --- a/eeschema/dialogs/panel_eeschema_template_fieldnames_base.h +++ b/eeschema/dialogs/panel_template_fieldnames_base.h @@ -30,9 +30,9 @@ class WX_GRID; /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -/// Class PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE +/// Class PANEL_TEMPLATE_FIELDNAMES_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE : public wxPanel +class PANEL_TEMPLATE_FIELDNAMES_BASE : public wxPanel { private: @@ -52,8 +52,8 @@ class PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_BASE : public wxPanel public: - PANEL_EESCHEMA_TEMPLATE_FIELDNAMES_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_EESCHEMA_TEMPLATE_FIELDNAMES_BASE(); + PANEL_TEMPLATE_FIELDNAMES_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_TEMPLATE_FIELDNAMES_BASE(); }; diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 3ddc2671f4..9f304396ab 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,12 @@ #include #include +#include +#include +#include +#include +#include +#include // The main sheet of the project SCH_SHEET* g_RootSheet = nullptr; @@ -167,6 +174,85 @@ static struct IFACE : public KIFACE_BASE // Dialog has completed; nothing to return. return nullptr; + case PANEL_SYM_DISPLAY_OPTIONS: + { + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + APP_SETTINGS_BASE* cfg = mgr.GetAppSettings(); + + return new PANEL_GAL_DISPLAY_OPTIONS( aParent, cfg ); + } + + case PANEL_SYM_EDIT_OPTIONS: + { + EDA_BASE_FRAME* unitsProvider = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false ); + + if( !unitsProvider ) + unitsProvider = aKiway->Player( FRAME_SCH_VIEWER, false ); + + if( !unitsProvider ) + unitsProvider = aKiway->Player( FRAME_SCH, false ); + + if( !unitsProvider ) + { + // If we can't find an eeschema unitsProvider we'll have to make do with the units + // defined in whatever FRAME we _can_ find. + for( unsigned i = 0; !unitsProvider && i < KIWAY_PLAYER_COUNT; ++i ) + unitsProvider = aKiway->Player( (FRAME_T) i, false ); + } + + if( !unitsProvider ) + { + wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME ); + unitsProvider = static_cast( manager ); + } + + return new PANEL_SYM_EDITING_OPTIONS( aParent, unitsProvider ); + } + + case PANEL_SYM_COLORS: + return new PANEL_SYM_COLOR_SETTINGS( aParent ); + + case PANEL_SCH_DISPLAY_OPTIONS: + { + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + APP_SETTINGS_BASE* cfg = mgr.GetAppSettings(); + + return new PANEL_GAL_DISPLAY_OPTIONS( aParent, cfg ); + } + + case PANEL_SCH_EDIT_OPTIONS: + { + EDA_BASE_FRAME* unitsProvider = aKiway->Player( FRAME_SCH, false ); + + if( !unitsProvider ) + unitsProvider = aKiway->Player( FRAME_SCH_SYMBOL_EDITOR, false ); + + if( !unitsProvider ) + unitsProvider = aKiway->Player( FRAME_SCH_VIEWER, false ); + + if( !unitsProvider ) + { + // If we can't find an eeschema frame we'll have to make do with the units + // defined in whatever FRAME we _can_ find. + for( unsigned i = 0; !unitsProvider && i < KIWAY_PLAYER_COUNT; ++i ) + unitsProvider = aKiway->Player( (FRAME_T) i, false ); + } + + if( !unitsProvider ) + { + wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME ); + unitsProvider = static_cast( manager ); + } + + return new PANEL_EESCHEMA_EDITING_OPTIONS( aParent, unitsProvider ); + } + + case PANEL_SCH_COLORS: + return new PANEL_EESCHEMA_COLOR_SETTINGS( aParent ); + + case PANEL_SCH_FIELD_NAME_TEMPLATES: + return new PANEL_TEMPLATE_FIELDNAMES( aParent, nullptr ); + default: return nullptr; } diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 28f933e554..16b737ebd9 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -25,17 +25,10 @@ #include #include -#include -#include -#include -#include -#include -#include #include #include #include #include -#include #include #include #include @@ -45,11 +38,9 @@ #include #include #include -#include #include #include #include -#include /// Helper for all the old plotting/printing code while it still exists @@ -59,22 +50,6 @@ COLOR4D GetLayerColor( SCH_LAYER_ID aLayer ) } -void SCH_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, - PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) -{ - wxTreebook* book = aParent->GetTreebook(); - - book->AddPage( new wxPanel( book ), _( "Schematic Editor" ) ); - book->AddSubPage( new PANEL_EESCHEMA_DISPLAY_OPTIONS( this, book ), _( "Display Options" ) ); - book->AddSubPage( new PANEL_EESCHEMA_EDITING_OPTIONS( this, book ), _( "Editing Options" ) ); - book->AddSubPage( new PANEL_EESCHEMA_COLOR_SETTINGS( this, book ), _( "Colors" ) ); - book->AddSubPage( new PANEL_EESCHEMA_TEMPLATE_FIELDNAMES( this, book, true ), - _( "Field Name Templates" ) ); - - aHotkeysPanel->AddHotKeys( GetToolManager() ); -} - - bool SCH_EDIT_FRAME::LoadProjectSettings() { SCHEMATIC_SETTINGS& settings = Schematic().Settings(); @@ -242,20 +217,6 @@ void SCH_BASE_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) } -void SYMBOL_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, - PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) -{ - wxTreebook* book = aParent->GetTreebook(); - - book->AddPage( new wxPanel( book ), _( "Symbol Editor" ) ); - book->AddSubPage( new PANEL_GAL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); - book->AddSubPage( new PANEL_SYM_EDITING_OPTIONS( this, book ), _( "Editing Options" ) ); - book->AddSubPage( new PANEL_SYM_COLOR_SETTINGS( this, book ), _( "Colors" ) ); - - aHotkeysPanel->AddHotKeys( GetToolManager() ); -} - - static std::mutex s_symbolTableMutex; diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index c17dae875a..85a6c31c80 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -418,11 +418,15 @@ void SCH_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars { EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged ); - EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); - m_colorSettings = Pgm().GetSettingsManager().GetColorSettings( cfg->m_ColorTheme ); + COLOR_SETTINGS* colorSettings = GetColorSettings(); + + GetCanvas()->GetView()->GetPainter()->GetSettings()->LoadColors( colorSettings ); + GetCanvas()->GetGAL()->SetAxesColor( colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) ); + GetCanvas()->GetGAL()->DrawGrid(); GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL ); - GetCanvas()->Refresh(); + GetCanvas()->GetView()->RecacheAllItems(); + GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); } @@ -430,9 +434,19 @@ COLOR_SETTINGS* SCH_BASE_FRAME::GetColorSettings() const { if( !m_colorSettings ) { - SETTINGS_MANAGER& settingsManager = Pgm().GetSettingsManager(); - EESCHEMA_SETTINGS* cfg = settingsManager.GetAppSettings(); - COLOR_SETTINGS* colorSettings = settingsManager.GetColorSettings( cfg->m_ColorTheme ); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings(); + wxString colorTheme = cfg->m_ColorTheme; + + if( IsType( FRAME_SCH_SYMBOL_EDITOR ) ) + { + SYMBOL_EDITOR_SETTINGS* symCfg = mgr.GetAppSettings(); + + if( !symCfg->m_UseEeschemaColorSettings ) + colorTheme = symCfg->m_ColorTheme; + } + + COLOR_SETTINGS* colorSettings = mgr.GetColorSettings( colorTheme ); const_cast( this )->m_colorSettings = colorSettings; } diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 247183075a..ab0ed9edf1 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1475,6 +1475,15 @@ void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars ShowAllIntersheetRefs( settings.m_IntersheetRefsShow ); + auto cfg = Pgm().GetSettingsManager().GetAppSettings(); + GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window ); + + GetRenderSettings()->m_ShowHiddenPins = cfg->m_Appearance.show_hidden_pins; + GetRenderSettings()->m_ShowHiddenText = cfg->m_Appearance.show_hidden_fields; + GetRenderSettings()->SetShowPageLimits( cfg->m_Appearance.show_page_limits ); + + GetCanvas()->ForceRefresh(); + RecreateToolbars(); Layout(); SendSizeEvent(); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 77356debc1..37dee4b8b2 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -784,11 +784,6 @@ public: */ void RecalculateConnections( SCH_CLEANUP_FLAGS aCleanupFlags ); - /** - * Allow Eeschema to install its preferences panels into the preferences dialog. - */ - void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override; - /** * Called after the preferences dialog is run. */ diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 7a9ec65cc1..373f397893 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -1102,8 +1102,14 @@ void SYMBOL_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextV { SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged ); - GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) ); - GetCanvas()->GetGAL()->DrawGrid(); + SETTINGS_MANAGER* mgr = GetSettingsManager(); + SYMBOL_EDITOR_SETTINGS* cfg = mgr->GetAppSettings(); + + GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_ShowPinElectricalType; + + GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window ); + + GetCanvas()->ForceRefresh(); RecreateToolbars(); diff --git a/eeschema/symbol_editor/symbol_edit_frame.h b/eeschema/symbol_editor/symbol_edit_frame.h index 5f6d7f8bf9..4eafd3bd51 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.h +++ b/eeschema/symbol_editor/symbol_edit_frame.h @@ -310,11 +310,6 @@ public: */ void RefreshLibraryTree(); - /** - * Allow the symbol editor to install its preferences panel into the preferences dialog. - */ - void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override; - /** * Called after the preferences dialog is run. */ diff --git a/eeschema/symbol_viewer_frame.cpp b/eeschema/symbol_viewer_frame.cpp index 6496a25ba7..d95e793cce 100644 --- a/eeschema/symbol_viewer_frame.cpp +++ b/eeschema/symbol_viewer_frame.cpp @@ -740,8 +740,12 @@ void SYMBOL_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTex { SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged ); + auto cfg = Pgm().GetSettingsManager().GetAppSettings(); + GetGalDisplayOptions().ReadWindowSettings( cfg->m_LibViewPanel.window ); + GetCanvas()->GetGAL()->SetAxesColor( m_colorSettings->GetColor( LAYER_SCHEMATIC_GRID_AXES ) ); GetCanvas()->GetGAL()->DrawGrid(); + GetCanvas()->ForceRefresh(); if( aEnvVarsChanged ) ReCreateLibList(); diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index a1ebe19a5f..e1e0c987ab 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -21,8 +21,6 @@ set( DIALOGS_SRCS dialogs/panel_gerbview_display_options_base.cpp dialogs/panel_gerbview_excellon_settings.cpp dialogs/panel_gerbview_excellon_settings_base.cpp - dialogs/panel_gerbview_settings.cpp - dialogs/panel_gerbview_settings_base.cpp dialogs/dialog_layers_select_to_pcb.cpp dialogs/dialog_layers_select_to_pcb_base.cpp dialogs/dialog_print_gerbview.cpp diff --git a/gerbview/dialogs/panel_gerbview_display_options.cpp b/gerbview/dialogs/panel_gerbview_display_options.cpp index 24a25a5d3a..96e25d72c3 100644 --- a/gerbview/dialogs/panel_gerbview_display_options.cpp +++ b/gerbview/dialogs/panel_gerbview_display_options.cpp @@ -18,22 +18,34 @@ * with this program. If not, see . */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include "panel_gerbview_display_options.h" -PANEL_GERBVIEW_DISPLAY_OPTIONS::PANEL_GERBVIEW_DISPLAY_OPTIONS( GERBVIEW_FRAME *aFrame, - wxWindow* aWindow ) : - PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE( aWindow, wxID_ANY ), - m_Parent( aFrame ) +/// List of page sizes +static const wxChar* gerberPageSizeList[] = { - m_galOptsPanel = new GAL_OPTIONS_PANEL( this, m_Parent ); + wxT( "GERBER" ), // index 0: full size page selection + wxT( "A4" ), + wxT( "A3" ), + wxT( "A2" ), + wxT( "A" ), + wxT( "B" ), + wxT( "C" ), +}; + + +PANEL_GERBVIEW_DISPLAY_OPTIONS::PANEL_GERBVIEW_DISPLAY_OPTIONS( wxWindow* aParent ) : + PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE( aParent, wxID_ANY ) +{ + GERBVIEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); + + m_galOptsPanel = new GAL_OPTIONS_PANEL( this, cfg ); m_galOptionsSizer->Add( m_galOptsPanel, 0, wxEXPAND | wxLEFT, 5 ); } @@ -42,14 +54,26 @@ bool PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataToWindow( ) { m_galOptsPanel->TransferDataToWindow(); - // Show Option Draw Lines. We use DisplayPcbTrackFill as Lines draw option - m_OptDisplayLines->SetValue( !m_Parent->GetDisplayOptions().m_DisplayLinesFill ); - m_OptDisplayFlashedItems->SetValue( !m_Parent->GetDisplayOptions().m_DisplayFlashedItemsFill ); + GERBVIEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); // Show Option Draw polygons - m_OptDisplayPolygons->SetValue( !m_Parent->GetDisplayOptions().m_DisplayPolygonsFill ); + m_OptDisplayPolygons->SetValue( !cfg->m_Display.m_DisplayPolygonsFill ); - m_OptDisplayDCodes->SetValue( m_Parent->IsElementVisible( LAYER_DCODES ) ); + // 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_Display.m_DisplayDCodes ); + + for( unsigned i = 0; i < arrayDim( gerberPageSizeList ); ++i ) + { + if( gerberPageSizeList[i] == cfg->m_Appearance.page_type ) + { + m_PageSize->SetSelection( i ); + break; + } + } + + m_ShowPageLimitsOpt->SetValue( cfg->m_Display.m_DisplayPageLimits ); return true; } @@ -57,49 +81,17 @@ bool PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataToWindow( ) bool PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataFromWindow() { - GBR_DISPLAY_OPTIONS displayOptions = m_Parent->GetDisplayOptions(); - - bool needs_repaint = false, option; - - option = !m_OptDisplayLines->GetValue(); - - if( option != displayOptions.m_DisplayLinesFill ) - needs_repaint = true; - - displayOptions.m_DisplayLinesFill = option; - - option = !m_OptDisplayFlashedItems->GetValue(); - - if( option != m_Parent->GetDisplayOptions().m_DisplayFlashedItemsFill ) - needs_repaint = true; - - displayOptions.m_DisplayFlashedItemsFill = option; - - option = !m_OptDisplayPolygons->GetValue(); - - if( option != displayOptions.m_DisplayPolygonsFill ) - needs_repaint = true; - - displayOptions.m_DisplayPolygonsFill = option; - - m_Parent->SetElementVisibility( LAYER_DCODES, m_OptDisplayDCodes->GetValue() ); + GERBVIEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); m_galOptsPanel->TransferDataFromWindow(); - if( displayOptions.m_DiffMode ) - m_Parent->UpdateDiffLayers(); + cfg->m_Display.m_DisplayLinesFill = !m_OptDisplayLines->GetValue(); + cfg->m_Display.m_DisplayFlashedItemsFill = !m_OptDisplayFlashedItems->GetValue(); + cfg->m_Display.m_DisplayPolygonsFill = !m_OptDisplayPolygons->GetValue(); + cfg->m_Display.m_DisplayDCodes = m_OptDisplayDCodes->GetValue(); - // Apply changes to the GAL - auto view = m_Parent->GetCanvas()->GetView(); - auto painter = static_cast( view->GetPainter() ); - auto settings = painter->GetSettings(); - settings->LoadDisplayOptions( displayOptions ); - view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); - - if( needs_repaint ) - view->UpdateAllItems( KIGFX::REPAINT ); - - m_Parent->GetCanvas()->Refresh(); + cfg->m_Appearance.page_type = gerberPageSizeList[ m_PageSize->GetSelection() ]; + cfg->m_Display.m_DisplayPageLimits = m_ShowPageLimitsOpt->GetValue(); return true; } diff --git a/gerbview/dialogs/panel_gerbview_display_options.h b/gerbview/dialogs/panel_gerbview_display_options.h index fba822b04e..3da1e9cd21 100644 --- a/gerbview/dialogs/panel_gerbview_display_options.h +++ b/gerbview/dialogs/panel_gerbview_display_options.h @@ -21,30 +21,28 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef KICAD_PANEL_GERBVIEW_DISPLAY_OPTIONS_H -#define KICAD_PANEL_GERBVIEW_DISPLAY_OPTIONS_H +#ifndef PANEL_GERBVIEW_DISPLAY_OPTIONS_H +#define PANEL_GERBVIEW_DISPLAY_OPTIONS_H #include "panel_gerbview_display_options_base.h" -class GERBVIEW_FRAME; class GAL_OPTIONS_PANEL; class PANEL_GERBVIEW_DISPLAY_OPTIONS : public PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE { public: - PANEL_GERBVIEW_DISPLAY_OPTIONS( GERBVIEW_FRAME* aFrame, wxWindow* aWindow ); + PANEL_GERBVIEW_DISPLAY_OPTIONS( wxWindow* aParent ); ~PANEL_GERBVIEW_DISPLAY_OPTIONS() {}; private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; - GERBVIEW_FRAME* m_Parent; GAL_OPTIONS_PANEL* m_galOptsPanel; }; -#endif //KICAD_PANEL_GERBVIEW_DISPLAY_OPTIONS_H +#endif // PANEL_GERBVIEW_DISPLAY_OPTIONS_H diff --git a/gerbview/dialogs/panel_gerbview_display_options_base.cpp b/gerbview/dialogs/panel_gerbview_display_options_base.cpp index 69d330767b..3026daf7e4 100644 --- a/gerbview/dialogs/panel_gerbview_display_options_base.cpp +++ b/gerbview/dialogs/panel_gerbview_display_options_base.cpp @@ -24,30 +24,45 @@ PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE::PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE( wxWind wxBoxSizer* bRightSizer; bRightSizer = new wxBoxSizer( wxVERTICAL ); - wxStaticBoxSizer* sbSizer1; - sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Annotations") ), wxVERTICAL ); + wxStaticBoxSizer* sbAnnotations; + sbAnnotations = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Annotations") ), wxVERTICAL ); - m_OptDisplayDCodes = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Show D codes"), wxDefaultPosition, wxDefaultSize, 0 ); + m_OptDisplayDCodes = new wxCheckBox( sbAnnotations->GetStaticBox(), wxID_ANY, _("Show D codes"), wxDefaultPosition, wxDefaultSize, 0 ); m_OptDisplayDCodes->SetValue(true); - sbSizer1->Add( m_OptDisplayDCodes, 0, wxBOTTOM|wxLEFT, 5 ); + sbAnnotations->Add( m_OptDisplayDCodes, 0, wxBOTTOM|wxLEFT, 5 ); + + m_ShowPageLimitsOpt = new wxCheckBox( sbAnnotations->GetStaticBox(), wxID_ANY, _("Show page limits"), wxDefaultPosition, wxDefaultSize, 0 ); + sbAnnotations->Add( m_ShowPageLimitsOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - bRightSizer->Add( sbSizer1, 0, wxEXPAND|wxALL, 5 ); + bRightSizer->Add( sbAnnotations, 0, wxEXPAND|wxALL, 5 ); - wxStaticBoxSizer* sbSizer2; - sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Drawing Mode") ), wxVERTICAL ); + wxStaticBoxSizer* sbDrawingMode; + sbDrawingMode = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Drawing Mode") ), wxVERTICAL ); - m_OptDisplayFlashedItems = new wxCheckBox( sbSizer2->GetStaticBox(), wxID_ANY, _("Sketch flashed items"), wxDefaultPosition, wxDefaultSize, 0 ); - sbSizer2->Add( m_OptDisplayFlashedItems, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_OptDisplayFlashedItems = new wxCheckBox( sbDrawingMode->GetStaticBox(), wxID_ANY, _("Sketch flashed items"), wxDefaultPosition, wxDefaultSize, 0 ); + sbDrawingMode->Add( m_OptDisplayFlashedItems, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_OptDisplayLines = new wxCheckBox( sbSizer2->GetStaticBox(), wxID_ANY, _("Sketch lines"), wxDefaultPosition, wxDefaultSize, 0 ); - sbSizer2->Add( m_OptDisplayLines, 0, wxALL, 5 ); + m_OptDisplayLines = new wxCheckBox( sbDrawingMode->GetStaticBox(), wxID_ANY, _("Sketch lines"), wxDefaultPosition, wxDefaultSize, 0 ); + sbDrawingMode->Add( m_OptDisplayLines, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_OptDisplayPolygons = new wxCheckBox( sbSizer2->GetStaticBox(), wxID_ANY, _("Sketch polygons"), wxDefaultPosition, wxDefaultSize, 0 ); - sbSizer2->Add( m_OptDisplayPolygons, 0, wxALL, 5 ); + m_OptDisplayPolygons = new wxCheckBox( sbDrawingMode->GetStaticBox(), wxID_ANY, _("Sketch polygons"), wxDefaultPosition, wxDefaultSize, 0 ); + sbDrawingMode->Add( m_OptDisplayPolygons, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - bRightSizer->Add( sbSizer2, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + bRightSizer->Add( sbDrawingMode, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + + wxBoxSizer* bPageSize; + bPageSize = new wxBoxSizer( wxVERTICAL ); + + wxString m_PageSizeChoices[] = { _("Full size"), _("Size A4"), _("Size A3"), _("Size A2"), _("Size A"), _("Size B"), _("Size C") }; + int m_PageSizeNChoices = sizeof( m_PageSizeChoices ) / sizeof( wxString ); + m_PageSize = new wxRadioBox( this, wxID_ANY, _("Page Size"), wxDefaultPosition, wxDefaultSize, m_PageSizeNChoices, m_PageSizeChoices, 1, wxRA_SPECIFY_COLS ); + m_PageSize->SetSelection( 0 ); + bPageSize->Add( m_PageSize, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + + + bRightSizer->Add( bPageSize, 1, wxEXPAND, 5 ); m_UpperSizer->Add( bRightSizer, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); diff --git a/gerbview/dialogs/panel_gerbview_display_options_base.fbp b/gerbview/dialogs/panel_gerbview_display_options_base.fbp index 0290c324db..7fc84d1153 100644 --- a/gerbview/dialogs/panel_gerbview_display_options_base.fbp +++ b/gerbview/dialogs/panel_gerbview_display_options_base.fbp @@ -2,7 +2,7 @@ - + C++ 1 source_name @@ -14,11 +14,12 @@ panel_gerbview_display_options_base 1000 none + 1 PanelGerbviewDisplayOptions - + . - + 1 1 1 @@ -29,57 +30,27 @@ 0 wxAUI_MGR_DEFAULT - - + + 1 1 impl_virtual - - + + 0 wxID_ANY - - + + PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE - + -1,-1 ; forward_declare - - - + + + wxTAB_TRAVERSAL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + bDialogSizer wxVERTICAL none @@ -88,7 +59,7 @@ wxEXPAND 1 - + m_UpperSizer wxHORIZONTAL protected @@ -97,7 +68,7 @@ wxEXPAND 1 - + m_galOptionsSizer wxVERTICAL protected @@ -108,7 +79,7 @@ wxEXPAND|wxRIGHT|wxLEFT 1 - + bRightSizer wxVERTICAL none @@ -119,12 +90,11 @@ wxID_ANY Annotations - - sbSizer1 + + sbAnnotations wxVERTICAL 1 none - 5 wxBOTTOM|wxLEFT @@ -134,83 +104,123 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Show D codes - + 0 - - + + 0 - + 1 m_OptDisplayDCodes 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Show page limits + + 0 + + + 0 + + 1 + m_ShowPageLimitsOpt + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + @@ -222,12 +232,11 @@ wxID_ANY Drawing Mode - - sbSizer2 + + sbDrawingMode wxVERTICAL 1 none - 5 wxBOTTOM|wxRIGHT|wxLEFT @@ -237,259 +246,264 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Sketch flashed items - + 0 - - + + 0 - + 1 m_OptDisplayFlashedItems 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + 5 - wxALL + wxBOTTOM|wxRIGHT|wxLEFT 0 1 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Sketch lines - + 0 - - + + 0 - + 1 m_OptDisplayLines 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + 5 - wxALL + wxBOTTOM|wxRIGHT|wxLEFT 0 1 1 1 1 - - - - - - - + + + + + + + 1 0 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Sketch polygons - + 0 - - + + 0 - + 1 m_OptDisplayPolygons 1 - - + + protected 1 - + Resizable 1 - - + + ; forward_declare 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + 5 + wxEXPAND + 1 + + + bPageSize + wxVERTICAL + none + + 5 + wxEXPAND|wxTOP|wxBOTTOM|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Full size" "Size A4" "Size A3" "Size A2" "Size A" "Size B" "Size C" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Page Size + 1 + + 0 + + + 0 + + 1 + m_PageSize + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + diff --git a/gerbview/dialogs/panel_gerbview_display_options_base.h b/gerbview/dialogs/panel_gerbview_display_options_base.h index 0343b5be08..3010a79bf7 100644 --- a/gerbview/dialogs/panel_gerbview_display_options_base.h +++ b/gerbview/dialogs/panel_gerbview_display_options_base.h @@ -18,6 +18,7 @@ #include #include #include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -34,9 +35,11 @@ class PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE : public wxPanel wxBoxSizer* m_UpperSizer; wxBoxSizer* m_galOptionsSizer; wxCheckBox* m_OptDisplayDCodes; + wxCheckBox* m_ShowPageLimitsOpt; wxCheckBox* m_OptDisplayFlashedItems; wxCheckBox* m_OptDisplayLines; wxCheckBox* m_OptDisplayPolygons; + wxRadioBox* m_PageSize; public: diff --git a/gerbview/dialogs/panel_gerbview_excellon_settings.cpp b/gerbview/dialogs/panel_gerbview_excellon_settings.cpp index b5bd3ea887..d649f760f0 100644 --- a/gerbview/dialogs/panel_gerbview_excellon_settings.cpp +++ b/gerbview/dialogs/panel_gerbview_excellon_settings.cpp @@ -18,26 +18,23 @@ * with this program. If not, see . */ -#include -#include +#include +#include #include #include "panel_gerbview_excellon_settings.h" -#include -PANEL_GERBVIEW_EXCELLON_SETTINGS::PANEL_GERBVIEW_EXCELLON_SETTINGS( - GERBVIEW_FRAME *aFrame, wxWindow* aWindow ) : - PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE( aWindow, wxID_ANY ), - m_Parent( aFrame ) +PANEL_GERBVIEW_EXCELLON_SETTINGS::PANEL_GERBVIEW_EXCELLON_SETTINGS( wxWindow* aParent ) : + PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE( aParent, wxID_ANY ) { } bool PANEL_GERBVIEW_EXCELLON_SETTINGS::TransferDataToWindow( ) { - GERBVIEW_SETTINGS* config = static_cast( m_Parent->config() ); - EXCELLON_DEFAULTS curr_settings; + GERBVIEW_SETTINGS* config = Pgm().GetSettingsManager().GetAppSettings(); + EXCELLON_DEFAULTS curr_settings; config->GetExcellonDefaults( curr_settings ); applySettingsToPanel( curr_settings ); @@ -48,7 +45,7 @@ bool PANEL_GERBVIEW_EXCELLON_SETTINGS::TransferDataToWindow( ) bool PANEL_GERBVIEW_EXCELLON_SETTINGS::TransferDataFromWindow() { - GERBVIEW_SETTINGS* config = static_cast( m_Parent->config() ); + GERBVIEW_SETTINGS* config = Pgm().GetSettingsManager().GetAppSettings(); config->m_ExcellonDefaults.m_UnitsMM = m_rbUnits->GetSelection() != 0; config->m_ExcellonDefaults.m_LeadingZero = m_rbZeroFormat->GetSelection(); diff --git a/gerbview/dialogs/panel_gerbview_excellon_settings.h b/gerbview/dialogs/panel_gerbview_excellon_settings.h index e2c0956e34..ca690432fa 100644 --- a/gerbview/dialogs/panel_gerbview_excellon_settings.h +++ b/gerbview/dialogs/panel_gerbview_excellon_settings.h @@ -26,15 +26,13 @@ #include "panel_gerbview_excellon_settings_base.h" -class GERBVIEW_FRAME; -class GAL_OPTIONS_PANEL; struct EXCELLON_DEFAULTS; class PANEL_GERBVIEW_EXCELLON_SETTINGS : public PANEL_GERBVIEW_EXCELLON_SETTINGS_BASE { public: - PANEL_GERBVIEW_EXCELLON_SETTINGS( GERBVIEW_FRAME* aFrame, wxWindow* aWindow ); + PANEL_GERBVIEW_EXCELLON_SETTINGS( wxWindow* aParent ); ~PANEL_GERBVIEW_EXCELLON_SETTINGS() {}; private: @@ -43,7 +41,5 @@ private: void ResetPanel() override; void applySettingsToPanel( const EXCELLON_DEFAULTS& aSettings ); - - GERBVIEW_FRAME* m_Parent; }; diff --git a/gerbview/dialogs/panel_gerbview_settings.cpp b/gerbview/dialogs/panel_gerbview_settings.cpp deleted file mode 100644 index 32dbd25c76..0000000000 --- a/gerbview/dialogs/panel_gerbview_settings.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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. - * - * 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 . - */ - -#include -#include -#include - -#include "panel_gerbview_settings.h" - - -/// List of page sizes -static const wxChar* gerberPageSizeList[] = -{ - wxT( "GERBER" ), // index 0: full size page selection - wxT( "A4" ), - wxT( "A3" ), - wxT( "A2" ), - wxT( "A" ), - wxT( "B" ), - wxT( "C" ), -}; - - -PANEL_GERBVIEW_SETTINGS::PANEL_GERBVIEW_SETTINGS( GERBVIEW_FRAME *aFrame, wxWindow* aWindow ) : - PANEL_GERBVIEW_SETTINGS_BASE( aWindow, wxID_ANY ), - m_Parent( aFrame ) -{ -} - - -bool PANEL_GERBVIEW_SETTINGS::TransferDataToWindow( ) -{ - m_ShowPageLimitsOpt->SetValue( m_Parent->GetDisplayOptions().m_DisplayPageLimits ); - - for( unsigned i = 0; i < arrayDim( gerberPageSizeList ); ++i ) - { - if( gerberPageSizeList[i] == m_Parent->GetPageSettings().GetType() ) - { - m_PageSize->SetSelection( i ); - break; - } - } - - return true; -} - - -bool PANEL_GERBVIEW_SETTINGS::TransferDataFromWindow() -{ - auto opts = m_Parent->GetDisplayOptions(); - opts.m_DisplayPageLimits = m_ShowPageLimitsOpt->GetValue(); - - PAGE_INFO pageInfo( gerberPageSizeList[ m_PageSize->GetSelection() ] ); - m_Parent->SetPageSettings( pageInfo ); - - m_Parent->UpdateDisplayOptions( opts ); - - return true; -} - diff --git a/gerbview/dialogs/panel_gerbview_settings.h b/gerbview/dialogs/panel_gerbview_settings.h deleted file mode 100644 index 601b4add75..0000000000 --- a/gerbview/dialogs/panel_gerbview_settings.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2018-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 - */ - - -#ifndef KICAD_PANEL_GERBVIEW_SETTINGS_H -#define KICAD_PANEL_GERBVIEW_SETTINGS_H - -#include "panel_gerbview_settings_base.h" - -class GERBVIEW_FRAME; - -class PANEL_GERBVIEW_SETTINGS : public PANEL_GERBVIEW_SETTINGS_BASE -{ -public: - PANEL_GERBVIEW_SETTINGS( GERBVIEW_FRAME* aFrame, wxWindow* aWindow ); - ~PANEL_GERBVIEW_SETTINGS() {}; - -private: - bool TransferDataToWindow() override; - bool TransferDataFromWindow() override; - - GERBVIEW_FRAME* m_Parent; -}; - -#endif //KICAD_PANEL_GERBVIEW_SETTINGS_H diff --git a/gerbview/dialogs/panel_gerbview_settings_base.cpp b/gerbview/dialogs/panel_gerbview_settings_base.cpp deleted file mode 100644 index 81f98288d7..0000000000 --- a/gerbview/dialogs/panel_gerbview_settings_base.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#include "panel_gerbview_settings_base.h" - -/////////////////////////////////////////////////////////////////////////// - -PANEL_GERBVIEW_SETTINGS_BASE::PANEL_GERBVIEW_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) -{ - wxBoxSizer* bDialogSizer; - bDialogSizer = new wxBoxSizer( wxVERTICAL ); - - m_UpperSizer = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer* bLeftSizer; - bLeftSizer = new wxBoxSizer( wxVERTICAL ); - - wxString m_PageSizeChoices[] = { _("Full size"), _("Size A4"), _("Size A3"), _("Size A2"), _("Size A"), _("Size B"), _("Size C") }; - int m_PageSizeNChoices = sizeof( m_PageSizeChoices ) / sizeof( wxString ); - m_PageSize = new wxRadioBox( this, wxID_ANY, _("Page Size"), wxDefaultPosition, wxDefaultSize, m_PageSizeNChoices, m_PageSizeChoices, 1, wxRA_SPECIFY_COLS ); - m_PageSize->SetSelection( 0 ); - bLeftSizer->Add( m_PageSize, 0, wxEXPAND|wxTOP|wxLEFT, 5 ); - - m_ShowPageLimitsOpt = new wxCheckBox( this, wxID_ANY, _("Show page limits"), wxDefaultPosition, wxDefaultSize, 0 ); - bLeftSizer->Add( m_ShowPageLimitsOpt, 0, wxALL, 10 ); - - - m_UpperSizer->Add( bLeftSizer, 0, wxEXPAND|wxRIGHT, 5 ); - - - bDialogSizer->Add( m_UpperSizer, 0, wxEXPAND|wxRIGHT, 5 ); - - - this->SetSizer( bDialogSizer ); - this->Layout(); - bDialogSizer->Fit( this ); -} - -PANEL_GERBVIEW_SETTINGS_BASE::~PANEL_GERBVIEW_SETTINGS_BASE() -{ -} diff --git a/gerbview/dialogs/panel_gerbview_settings_base.fbp b/gerbview/dialogs/panel_gerbview_settings_base.fbp deleted file mode 100644 index 652288e278..0000000000 --- a/gerbview/dialogs/panel_gerbview_settings_base.fbp +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - panel_gerbview_settings_base - 1000 - none - - 1 - PanelGerbviewSettings - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - - 1 - 1 - impl_virtual - - - 0 - wxID_ANY - - - PANEL_GERBVIEW_SETTINGS_BASE - - -1,-1 - ; forward_declare - - - - wxTAB_TRAVERSAL - - - bDialogSizer - wxVERTICAL - none - - 5 - wxEXPAND|wxRIGHT - 0 - - - m_UpperSizer - wxVERTICAL - protected - - 5 - wxEXPAND|wxRIGHT - 0 - - - bLeftSizer - wxVERTICAL - none - - 5 - wxEXPAND|wxTOP|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Full size" "Size A4" "Size A3" "Size A2" "Size A" "Size B" "Size C" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Page Size - 1 - - 0 - - - 0 - - 1 - m_PageSize - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 10 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Show page limits - - 0 - - - 0 - - 1 - m_ShowPageLimitsOpt - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - diff --git a/gerbview/dialogs/panel_gerbview_settings_base.h b/gerbview/dialogs/panel_gerbview_settings_base.h deleted file mode 100644 index 391758aad9..0000000000 --- a/gerbview/dialogs/panel_gerbview_settings_base.h +++ /dev/null @@ -1,44 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) -// http://www.wxformbuilder.org/ -// -// PLEASE DO *NOT* EDIT THIS FILE! -/////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////////////////////////////// -/// Class PANEL_GERBVIEW_SETTINGS_BASE -/////////////////////////////////////////////////////////////////////////////// -class PANEL_GERBVIEW_SETTINGS_BASE : public wxPanel -{ - private: - - protected: - wxBoxSizer* m_UpperSizer; - wxRadioBox* m_PageSize; - wxCheckBox* m_ShowPageLimitsOpt; - - public: - - PANEL_GERBVIEW_SETTINGS_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_GERBVIEW_SETTINGS_BASE(); - -}; - diff --git a/gerbview/gbr_display_options.h b/gerbview/gbr_display_options.h index ec8f77cadb..4f3e1281df 100644 --- a/gerbview/gbr_display_options.h +++ b/gerbview/gbr_display_options.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012-2016 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see change_log.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 @@ -22,14 +22,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file gbr_display_options.h - * @brief Class GBR_DISPLAY_OPTIONS is a helper class to handle display options - * (filling modes and afew other options - */ +#ifndef GBR_DISPLAY_OPTIONS_H +#define GBR_DISPLAY_OPTIONS_H -#ifndef CLASS_GBR_DISPLAY_OPTIONS_H -#define CLASS_GBR_DISPLAY_OPTIONS_H +using KIGFX::COLOR4D; /** * @note Some of these parameters are used only for printing, some others only @@ -74,4 +70,4 @@ public: } }; -#endif // #ifndef CLASS_GBR_DISPLAY_OPTIONS_H +#endif // GBR_DISPLAY_OPTIONS_H diff --git a/gerbview/gerbview.cpp b/gerbview/gerbview.cpp index dc8c08afa0..1369e6542a 100644 --- a/gerbview/gerbview.cpp +++ b/gerbview/gerbview.cpp @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include #include @@ -61,11 +63,13 @@ static struct IFACE : public KIFACE_BASE switch( aClassId ) { case FRAME_GERBER: - { - GERBVIEW_FRAME* frame = new GERBVIEW_FRAME( aKiway, aParent ); - return frame; - } - break; + return new GERBVIEW_FRAME( aKiway, aParent ); + + case PANEL_GBR_DISPLAY_OPTIONS: + return new PANEL_GERBVIEW_DISPLAY_OPTIONS( aParent ); + + case PANEL_GBR_EXCELLON_OPTIONS: + return new PANEL_GERBVIEW_EXCELLON_SETTINGS( aParent ); default: ; diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 5eb27bd2df..47137fbca7 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -52,13 +51,7 @@ #include #include #include -#include -#include -#include -#include -#include #include -#include #include "widgets/gbr_layer_box_selector.h" #include "widgets/gerbview_layer_widget.h" @@ -1051,23 +1044,6 @@ void GERBVIEW_FRAME::ActivateGalCanvas() } -void GERBVIEW_FRAME::InstallPreferences( PAGED_DIALOG* aParent, - PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) -{ - wxTreebook* book = aParent->GetTreebook(); - - book->AddPage( new wxPanel( book ), _( "GerbView" ) ); - book->AddSubPage( new PANEL_GERBVIEW_DISPLAY_OPTIONS( this, book ), - _( "Display Options" ) ); - book->AddSubPage( new PANEL_GERBVIEW_SETTINGS( this, book ), _( "Editing Options" ) ); - book->AddSubPage( new PANEL_GERBVIEW_EXCELLON_SETTINGS( this, book ), - _( "Excellon Options" ) ); - - aHotkeysPanel->AddHotKeys( GetToolManager() ); -} - - - void GERBVIEW_FRAME::setupTools() { // Create the manager and dispatcher & route draw panel events to the dispatcher @@ -1196,6 +1172,23 @@ void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars { EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged ); + GERBVIEW_SETTINGS* cfg = static_cast( config() ); + SetPageSettings( PAGE_INFO( cfg->m_Appearance.page_type ) ); + + if( cfg->m_Display.m_DiffMode ) + UpdateDiffLayers(); + + // Apply changes to the GAL + auto painter = static_cast( GetCanvas()->GetView()->GetPainter() ); + auto settings = painter->GetSettings(); + settings->LoadDisplayOptions( GetDisplayOptions() ); + + SetElementVisibility( LAYER_DCODES, GetDisplayOptions().m_DisplayDCodes ); + + GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); + GetCanvas()->GetView()->UpdateAllItems( KIGFX::REPAINT ); + GetCanvas()->ForceRefresh(); + RecreateToolbars(); Layout(); SendSizeEvent(); diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 1e9f203b9b..f1e9d74fa6 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -382,11 +382,6 @@ public: ///< @copydoc EDA_DRAW_FRAME::ActivateGalCanvas void ActivateGalCanvas() override; - /** - * Allow Gerbview to install its preferences panels into the preferences dialog. - */ - void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override; - /** * Called after the preferences dialog is run. */ diff --git a/gerbview/gerbview_settings.h b/gerbview/gerbview_settings.h index 6804915190..31b0d5c9f8 100644 --- a/gerbview/gerbview_settings.h +++ b/gerbview/gerbview_settings.h @@ -26,7 +26,7 @@ #include #include - +#include class GERBVIEW_SETTINGS : public APP_SETTINGS_BASE { @@ -58,6 +58,8 @@ public: APPEARANCE m_Appearance; + GBR_DISPLAY_OPTIONS m_Display; + int m_BoardLayersCount; std::vector m_DrillFileHistory; diff --git a/include/dialogs/dialog_hotkey_list.h b/include/dialogs/dialog_hotkey_list.h index 607a83904f..c95e198de8 100644 --- a/include/dialogs/dialog_hotkey_list.h +++ b/include/dialogs/dialog_hotkey_list.h @@ -32,7 +32,6 @@ #include -class TOOL_MANAGER; class PANEL_HOTKEYS_EDITOR; @@ -48,7 +47,7 @@ public: * * @param aParent the parent frame */ - DIALOG_LIST_HOTKEYS( EDA_BASE_FRAME* aParent, TOOL_MANAGER* aToolManager ); + DIALOG_LIST_HOTKEYS( EDA_BASE_FRAME* aParent ); protected: diff --git a/include/dialogs/panel_color_settings.h b/include/dialogs/panel_color_settings.h index 24a4a117c9..93f47cbdd2 100644 --- a/include/dialogs/panel_color_settings.h +++ b/include/dialogs/panel_color_settings.h @@ -62,6 +62,7 @@ protected: void OnColorChanged( wxCommandEvent& aEvent ); + virtual void createSwatches() = 0; void updateSwatches(); /** diff --git a/include/dialogs/panel_gal_display_options.h b/include/dialogs/panel_gal_display_options.h index 3ac3a84e8e..67bbd99d70 100644 --- a/include/dialogs/panel_gal_display_options.h +++ b/include/dialogs/panel_gal_display_options.h @@ -24,19 +24,17 @@ #include class GAL_OPTIONS_PANEL; -class EDA_DRAW_FRAME; -class PAGED_DIALOG; + class PANEL_GAL_DISPLAY_OPTIONS : public wxPanel { public: - PANEL_GAL_DISPLAY_OPTIONS( EDA_DRAW_FRAME* aFrame, PAGED_DIALOG* aParent ); + PANEL_GAL_DISPLAY_OPTIONS( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ); private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; - EDA_DRAW_FRAME* m_frame; GAL_OPTIONS_PANEL* m_galOptsPanel; }; diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index 9936afb0dc..c0d03c77d1 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -44,6 +44,7 @@ #include #include #include +#include // Option for main frames #define KICAD_DEFAULT_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS @@ -137,6 +138,12 @@ public: virtual void ToggleUserUnits() { } + /** + * Return a reference to the default ORIGIN_TRANSFORMS object + */ + virtual ORIGIN_TRANSFORMS& GetOriginTransforms() { return m_originTransforms; } + + SETTINGS_MANAGER* GetSettingsManager() const { return m_settingsManager; } virtual SEVERITY GetSeverity( int aErrorCode ) const { return RPT_SEVERITY_UNDEFINED; } @@ -290,14 +297,6 @@ public: */ virtual APP_SETTINGS_BASE* config() const; - /** - * Allow a frame to load its preference panels (if any) into the preferences dialog. - * - * @param aParent a paged dialog into which the preference panels should be installed. - */ - virtual void InstallPreferences( PAGED_DIALOG* , PANEL_HOTKEYS_EDITOR* ) { } - - void LoadWindowState( const wxString& aFileName ); /** * Load window settings from the given settings object. @@ -720,14 +719,15 @@ private: int m_autoSaveInterval; // The auto save interval time in seconds. wxTimer* m_autoSaveTimer; - int m_undoRedoCountMax; // undo/Redo command Max depth + int m_undoRedoCountMax; // undo/Redo command Max depth UNDO_REDO_CONTAINER m_undoList; // Objects list for the undo command (old data) UNDO_REDO_CONTAINER m_redoList; // Objects list for the redo command (old data) - wxString m_mruPath; // Most recently used path. + wxString m_mruPath; // Most recently used path. - EDA_UNITS m_userUnits; + EDA_UNITS m_userUnits; + ORIGIN_TRANSFORMS m_originTransforms; // Default display origin transforms object. ///< Map containing the UI update handlers registered with wx for each action. std::map m_uiUpdateMap; @@ -738,7 +738,6 @@ private: ///< Set by #NonUserClose() to indicate that the user did not request the current close. bool m_isNonUserClose; - }; diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 79ab0cfe56..8e1b89d3cd 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include "hotkeys_basic.h" @@ -158,13 +157,6 @@ public: */ wxPoint GetNearestHalfGridPosition( const wxPoint& aPosition ) const; - /** - * Return a reference to the default ORIGIN_TRANSFORMS object - */ - virtual ORIGIN_TRANSFORMS& GetOriginTransforms() - { return m_originTransforms; } - - virtual const TITLE_BLOCK& GetTitleBlock() const = 0; virtual void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) = 0; @@ -531,9 +523,6 @@ private: ///< This the frame's interface to setting GAL display options. KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions; - - ///< Default display origin transforms object. - ORIGIN_TRANSFORMS m_originTransforms; }; #endif // DRAW_FRAME_H_ diff --git a/include/footprint_editor_settings.h b/include/footprint_editor_settings.h index 5ce07dc693..f335b6ed86 100644 --- a/include/footprint_editor_settings.h +++ b/include/footprint_editor_settings.h @@ -65,6 +65,8 @@ public: bool m_PolarCoords; + int m_RotationAngle; + bool m_Use45Limit; int m_LibWidth; diff --git a/include/frame_type.h b/include/frame_type.h index d89e74e58e..464c21b77d 100644 --- a/include/frame_type.h +++ b/include/frame_type.h @@ -65,8 +65,40 @@ enum FRAME_T FRAME_T_COUNT, + PANEL_SYM_DISPLAY_OPTIONS = FRAME_T_COUNT, + PANEL_SYM_EDIT_OPTIONS, + PANEL_SYM_COLORS, + + PANEL_SCH_DISPLAY_OPTIONS, + PANEL_SCH_EDIT_OPTIONS, + PANEL_SCH_COLORS, + PANEL_SCH_FIELD_NAME_TEMPLATES, + + PANEL_FP_DISPLAY_OPTIONS, + PANEL_FP_EDIT_OPTIONS, + PANEL_FP_COLORS, + PANEL_FP_DEFAULT_VALUES, + + PANEL_PCB_DISPLAY_OPTIONS, + PANEL_PCB_EDIT_OPTIONS, + PANEL_PCB_COLORS, + PANEL_PCB_ACTION_PLUGINS, + PANEL_PCB_ORIGINS_AXES, + + PANEL_3DV_DISPLAY_OPTIONS, + PANEL_3DV_OPENGL, + PANEL_3DV_RAYTRACING, + PANEL_3DV_COLORS, + + PANEL_GBR_DISPLAY_OPTIONS, + PANEL_GBR_EDIT_OPTIONS, + PANEL_GBR_EXCELLON_OPTIONS, + + PANEL_DS_DISPLAY_OPTIONS, + PANEL_DS_COLORS, + // Library table dialogs are transient and are never returned - DIALOG_CONFIGUREPATHS = FRAME_T_COUNT, + DIALOG_CONFIGUREPATHS, DIALOG_SCH_LIBRARY_TABLE, DIALOG_PCB_LIBRARY_TABLE }; diff --git a/include/hotkey_store.h b/include/hotkey_store.h index 315c5e7588..5789c21872 100644 --- a/include/hotkey_store.h +++ b/include/hotkey_store.h @@ -70,7 +70,7 @@ public: */ HOTKEY_STORE(); - void Init( std::vector aToolManagerList, bool aIncludeReadOnlyCmds ); + void Init( std::vector aActionsList, bool aIncludeReadOnlyCmds ); static wxString GetAppName( TOOL_ACTION* aAction ); static wxString GetSectionName( TOOL_ACTION* aAction ); diff --git a/include/hotkeys_basic.h b/include/hotkeys_basic.h index f0509b50ee..635ca3812c 100644 --- a/include/hotkeys_basic.h +++ b/include/hotkeys_basic.h @@ -93,7 +93,7 @@ wxString AddHotkeyName( const wxString& aText, int aHotKey, * @param aToolMgr the tool manager holding the registered actions from which the hotkeys * will be harvested. */ -void DisplayHotkeyList( EDA_BASE_FRAME* aFrame, TOOL_MANAGER* aToolMgr ); +void DisplayHotkeyList( EDA_BASE_FRAME* aFrame ); /** * Reads a hotkey config file into a map. @@ -105,7 +105,7 @@ void ReadHotKeyConfig( const wxString& aFileName, std::map& aH /** * Update the hotkeys config file with the hotkeys from the given actions map. */ -int WriteHotKeyConfig( const std::map& aActionMap ); +int WriteHotKeyConfig( const std::vector& aActions ); /** * Read hotkey configuration for a given app. diff --git a/include/kiface_base.h b/include/kiface_base.h index 547a21a3ab..a99fde8f9c 100644 --- a/include/kiface_base.h +++ b/include/kiface_base.h @@ -26,6 +26,7 @@ #include #include +#include /** @@ -112,6 +113,12 @@ public: /// (The library search path is in the PROJECT class.) SEARCH_STACK& KifaceSearch() { return m_bm.m_search; } + void GetActions( std::vector& aActions ) const override + { + for( TOOL_ACTION* action : ACTION_MANAGER::GetActionList() ) + aActions.push_back( action ); + } + private: KIWAY::FACE_T m_id; diff --git a/include/kiface_ids.h b/include/kiface_ids.h index 7b2b3de0b3..ade5a70f28 100644 --- a/include/kiface_ids.h +++ b/include/kiface_ids.h @@ -52,8 +52,6 @@ enum KIFACE_ADDR_ID : int */ KIFACE_GLOBAL_FOOTPRINT_TABLE, - KIFACE_NEW_DRC_ENGINE, - KIFACE_LOAD_PCB, KIFACE_LOAD_SCHEMATIC, KIFACE_NETLIST_SCHEMATIC, KIFACE_SCRIPTING_LEGACY, diff --git a/include/kiway.h b/include/kiway.h index 227b51ed2f..1abf012d8a 100644 --- a/include/kiway.h +++ b/include/kiway.h @@ -131,6 +131,7 @@ class PGM_BASE; class KIWAY; class KIWAY_PLAYER; class wxTopLevelWindow; +class TOOL_ACTION; /** @@ -227,6 +228,11 @@ struct KIFACE * @return the requested object which must be cast into the known type. */ virtual void* IfaceOrAddress( int aDataId ) = 0; + + /** + * Append this Kiface's registered actions to the given list. + */ + virtual void GetActions( std::vector& aActions ) const = 0; }; @@ -349,6 +355,11 @@ public: virtual void ExpressMail( FRAME_T aDestination, MAIL_T aCommand, std::string& aPayload, wxWindow* aSource = nullptr ); + /** + * Append all registered actions to the given list. + */ + virtual void GetActions( std::vector& aActions ) const; + /** * Return the #PROJECT associated with this KIWAY. * diff --git a/include/panel_hotkeys_editor.h b/include/panel_hotkeys_editor.h index 1f63b1f704..d10fd806ea 100644 --- a/include/panel_hotkeys_editor.h +++ b/include/panel_hotkeys_editor.h @@ -43,7 +43,7 @@ class PANEL_HOTKEYS_EDITOR : public RESETTABLE_PANEL public: PANEL_HOTKEYS_EDITOR( EDA_BASE_FRAME* aFrame, wxWindow* aWindow, bool aReadOnly ); - void AddHotKeys( TOOL_MANAGER* aToolMgr ); + std::vector& ActionsList() { return m_actions; } bool TransferDataToWindow() override; bool TransferDataFromWindow() override; @@ -55,6 +55,8 @@ public: return _( "Reset all hotkeys to the built-in KiCad defaults" ); } + bool Show( bool show ) override; + private: /** * Install the button panel (global reset/default, import/export) @@ -87,7 +89,7 @@ protected: EDA_BASE_FRAME* m_frame; bool m_readOnly; - std::vector m_toolManagers; + std::vector m_actions; HOTKEY_STORE m_hotkeyStore; WIDGET_HOTKEY_LIST* m_hotkeyListCtrl; }; diff --git a/include/tool/tool_manager.h b/include/tool/tool_manager.h index 40943fa97e..1ff1c6763b 100644 --- a/include/tool/tool_manager.h +++ b/include/tool/tool_manager.h @@ -178,8 +178,6 @@ public: return RunAction( aAction, aNow, (void*) NULL ); } - const std::map& GetActions() const; - /** * Send a cancel event to the tool currently at the top of the tool stack. */ diff --git a/include/widgets/gal_options_panel.h b/include/widgets/gal_options_panel.h index 5ae8e8c6c1..c111949d9c 100644 --- a/include/widgets/gal_options_panel.h +++ b/include/widgets/gal_options_panel.h @@ -31,14 +31,17 @@ class wxBoxSizer; class wxRadioBox; class wxSpinCtrlDouble; +class wxChoice; +class wxCheckBox; class wxStaticText; class EDA_DRAW_FRAME; +class APP_SETTINGS_BASE; class GAL_OPTIONS_PANEL: public wxPanel { public: - GAL_OPTIONS_PANEL( wxWindow* aParent, EDA_DRAW_FRAME* aDrawFrame ); + GAL_OPTIONS_PANEL( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ); /** * Load the panel controls from the given opt @@ -51,32 +54,29 @@ public: bool TransferDataFromWindow() override; private: - EDA_DRAW_FRAME* m_drawFrame; - - wxBoxSizer* m_mainSizer; + wxBoxSizer* m_mainSizer; #ifndef __WXMAC__ - wxRadioBox* m_renderingEngine; + wxRadioBox* m_renderingEngine; #endif - wxRadioBox* m_gridStyle; - wxStaticText* l_gridLineWidth; - wxSpinCtrlDouble* m_gridLineWidth; - wxStaticText* l_gridLineWidthUnits; + wxRadioBox* m_gridStyle; + wxStaticText* l_gridLineWidth; + wxSpinCtrlDouble* m_gridLineWidth; + wxStaticText* l_gridLineWidthUnits; - wxStaticText* l_gridMinSpacing; - wxSpinCtrlDouble* m_gridMinSpacing; - wxStaticText* l_gridMinSpacingUnits; + wxStaticText* l_gridMinSpacing; + wxSpinCtrlDouble* m_gridMinSpacing; + wxStaticText* l_gridMinSpacingUnits; - wxStaticText* l_gridSnapOptions; - wxChoice* m_gridSnapOptions; - wxStaticText* l_gridSnapSpace; + wxStaticText* l_gridSnapOptions; + wxChoice* m_gridSnapOptions; + wxStaticText* l_gridSnapSpace; - wxRadioBox* m_cursorShape; - wxCheckBox* m_forceCursorDisplay; + wxRadioBox* m_cursorShape; + wxCheckBox* m_forceCursorDisplay; - ///< The GAL options to read/write - KIGFX::GAL_DISPLAY_OPTIONS& m_galOptions; + APP_SETTINGS_BASE* m_cfg; }; diff --git a/include/widgets/unit_binder.h b/include/widgets/unit_binder.h index 8ad84bc5b4..644723f0b3 100644 --- a/include/widgets/unit_binder.h +++ b/include/widgets/unit_binder.h @@ -32,6 +32,7 @@ #include #include +class EDA_BASE_FRAME; class EDA_DRAW_FRAME; class wxTextEntry; class wxSpinButton; @@ -43,7 +44,7 @@ class UNIT_BINDER : public wxEvtHandler public: /** - * @param aParent is the parent EDA_DRAW_FRAME. + * @param aParent is the parent EDA_BASE_FRAME, used to fetch units and coordinate systems. * @param aLabel is the static text used to label the text input widget (note: the label * text, trimmed of its colon, will also be used in error messages) * @param aValueCtrl is the control used to edit or display the given value (wxTextCtrl, @@ -52,7 +53,7 @@ public: * Can be nullptr. * @param aAllowEval indicates \a aTextInput's content should be eval'ed before storing */ - UNIT_BINDER( EDA_DRAW_FRAME* aParent, + UNIT_BINDER( EDA_BASE_FRAME* aParent, wxStaticText* aLabel, wxWindow* aValueCtrl, wxStaticText* aUnitLabel, bool aAllowEval = true ); @@ -200,7 +201,7 @@ protected: */ double setPrecision( double aValue, bool aValueUsesUserUnits ); - EDA_DRAW_FRAME* m_frame; + EDA_BASE_FRAME* m_frame; ///< The bound widgets wxStaticText* m_label; diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index 246abed524..915e4fe06f 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -680,13 +679,6 @@ void KICAD_MANAGER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) } -void KICAD_MANAGER_FRAME::InstallPreferences( PAGED_DIALOG* aParent, - PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) -{ - aHotkeysPanel->AddHotKeys( GetToolManager() ); -} - - void KICAD_MANAGER_FRAME::PrintPrjInfo() { // wxStatusBar's wxELLIPSIZE_MIDDLE flag doesn't work (at least on Mac). diff --git a/kicad/kicad_manager_frame.h b/kicad/kicad_manager_frame.h index 2c32bd5d4d..0905e88d00 100644 --- a/kicad/kicad_manager_frame.h +++ b/kicad/kicad_manager_frame.h @@ -137,8 +137,6 @@ public: */ void OnChangeWatchedPaths( wxCommandEvent& aEvent ); - void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override; - const wxString GetProjectFileName() const; bool IsProjectActive(); diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp b/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp index 1fda574ba7..dedb0dabfb 100644 --- a/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings.cpp @@ -19,18 +19,12 @@ #include #include -#include -#include - +#include #include "panel_pl_editor_color_settings.h" -#include "pl_editor_frame.h" -#include "pl_editor_settings.h" -PANEL_PL_EDITOR_COLOR_SETTINGS::PANEL_PL_EDITOR_COLOR_SETTINGS( PL_EDITOR_FRAME* aFrame, - wxWindow* aWindow ) - : PANEL_PL_EDITOR_COLOR_SETTINGS_BASE( aWindow ), - m_frame( aFrame ) +PANEL_PL_EDITOR_COLOR_SETTINGS::PANEL_PL_EDITOR_COLOR_SETTINGS( wxWindow* aParent ) : + PANEL_PL_EDITOR_COLOR_SETTINGS_BASE( aParent ) { } @@ -68,15 +62,12 @@ bool PANEL_PL_EDITOR_COLOR_SETTINGS::TransferDataToWindow() bool PANEL_PL_EDITOR_COLOR_SETTINGS::TransferDataFromWindow() { - SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); - int sel = m_themes->GetSelection(); - COLOR_SETTINGS* colors = static_cast( m_themes->GetClientData( sel ) ); - + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); PL_EDITOR_SETTINGS* cfg = mgr.GetAppSettings(); - cfg->m_ColorTheme = colors->GetFilename(); + int sel = m_themes->GetSelection(); + COLOR_SETTINGS* colors = static_cast( m_themes->GetClientData( sel ) ); - RENDER_SETTINGS* settings = m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings(); - settings->LoadColors( colors ); + cfg->m_ColorTheme = colors->GetFilename(); return true; } \ No newline at end of file diff --git a/pagelayout_editor/dialogs/panel_pl_editor_color_settings.h b/pagelayout_editor/dialogs/panel_pl_editor_color_settings.h index 3a9d50e93a..cf21aa0be2 100644 --- a/pagelayout_editor/dialogs/panel_pl_editor_color_settings.h +++ b/pagelayout_editor/dialogs/panel_pl_editor_color_settings.h @@ -22,19 +22,16 @@ #include "panel_pl_editor_color_settings_base.h" -class PL_EDITOR_FRAME; class PANEL_PL_EDITOR_COLOR_SETTINGS : public PANEL_PL_EDITOR_COLOR_SETTINGS_BASE { public: - PANEL_PL_EDITOR_COLOR_SETTINGS( PL_EDITOR_FRAME* aFrame, wxWindow* aWindow ); + PANEL_PL_EDITOR_COLOR_SETTINGS( wxWindow* aParent ); private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; - - PL_EDITOR_FRAME* m_frame; }; diff --git a/pagelayout_editor/pl_editor.cpp b/pagelayout_editor/pl_editor.cpp index d736131bb9..6275208c0f 100644 --- a/pagelayout_editor/pl_editor.cpp +++ b/pagelayout_editor/pl_editor.cpp @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include "pl_editor_frame.h" #include "pl_editor_settings.h" @@ -56,12 +58,19 @@ static struct IFACE : public KIFACE_BASE switch( aClassId ) { case FRAME_PL_EDITOR: + return new PL_EDITOR_FRAME( aKiway, aParent ); + + case PANEL_DS_DISPLAY_OPTIONS: { - PL_EDITOR_FRAME* frame = new PL_EDITOR_FRAME( aKiway, aParent ); - return frame; - break; + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + APP_SETTINGS_BASE* cfg = mgr.GetAppSettings(); + + return new PANEL_GAL_DISPLAY_OPTIONS( aParent, cfg ); } + case PANEL_DS_COLORS: + return new PANEL_PL_EDITOR_COLOR_SETTINGS( aParent ); + default: ; } diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 127201fd91..cc73e3d28b 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -27,11 +27,8 @@ #include #include #include -#include #include #include -#include -#include #include #include #include @@ -45,10 +42,7 @@ #include #include #include -#include #include - -#include "dialogs/panel_pl_editor_color_settings.h" #include "pl_editor_frame.h" #include "pl_editor_id.h" #include "pl_editor_settings.h" @@ -478,20 +472,6 @@ const BOX2I PL_EDITOR_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const } -void PL_EDITOR_FRAME::InstallPreferences( PAGED_DIALOG* aParent, - PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) -{ - wxTreebook* book = aParent->GetTreebook(); - - book->AddPage( new wxPanel( book ), _( "Drawing Sheet Editor" ) ); - book->AddSubPage( new PANEL_GAL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); - book->AddSubPage( new PANEL_PL_EDITOR_COLOR_SETTINGS( this, aParent->GetTreebook() ), - _( "Colors" ) ); - - aHotkeysPanel->AddHotKeys( GetToolManager() ); -} - - void PL_EDITOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { EDA_DRAW_FRAME::LoadSettings( aCfg ); @@ -625,7 +605,7 @@ void PL_EDITOR_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVar GetCanvas()->GetView()->GetPainter()->GetSettings()->LoadColors( colors ); GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR ); - GetCanvas()->Refresh(); + GetCanvas()->ForceRefresh(); RecreateToolbars(); Layout(); diff --git a/pagelayout_editor/pl_editor_frame.h b/pagelayout_editor/pl_editor_frame.h index 634d30af08..9b2eecb37e 100644 --- a/pagelayout_editor/pl_editor_frame.h +++ b/pagelayout_editor/pl_editor_frame.h @@ -164,8 +164,6 @@ public: */ void UpdateTitleAndInfo(); - void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override; - void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 985b811a1f..a50c8de172 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -29,6 +29,7 @@ include_directories( ./dialogs ./autorouter ${CMAKE_SOURCE_DIR}/3d-viewer + ${CMAKE_SOURCE_DIR}/3d-viewer/dialogs ${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/common/dialogs ./exporters diff --git a/pcbnew/dialogs/dialog_board_setup.cpp b/pcbnew/dialogs/dialog_board_setup.cpp index 5c3086801b..33d25a9d5a 100644 --- a/pcbnew/dialogs/dialog_board_setup.cpp +++ b/pcbnew/dialogs/dialog_board_setup.cpp @@ -111,7 +111,10 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) : m_treebook->AddSubPage( m_severities, _( "Violation Severity" ) ); for( size_t i = 0; i < m_treebook->GetPageCount(); ++i ) + { + m_treebook->ExpandNode( i ); m_macHack.push_back( true ); + } m_treebook->SetMinSize( wxSize( -1, 480 ) ); diff --git a/pcbnew/dialogs/dialog_pad_properties_base.h b/pcbnew/dialogs/dialog_pad_properties_base.h index 716822cce5..2be017dafd 100644 --- a/pcbnew/dialogs/dialog_pad_properties_base.h +++ b/pcbnew/dialogs/dialog_pad_properties_base.h @@ -170,6 +170,8 @@ class DIALOG_PAD_PROPERTIES_BASE : public DIALOG_SHIM wxStaticText* m_staticTextFabProperty; wxChoice* m_choiceFabProperty; wxPanel* m_localSettingsPanel; + wxStaticText* m_staticTextInfoPosValue; + wxStaticText* m_staticTextInfoNegVal; wxStaticText* m_clearanceLabel; wxTextCtrl* m_clearanceCtrl; wxStaticText* m_clearanceUnits; diff --git a/pcbnew/dialogs/panel_display_options.cpp b/pcbnew/dialogs/panel_display_options.cpp index 2bf61f66e0..f2943bb4f5 100644 --- a/pcbnew/dialogs/panel_display_options.cpp +++ b/pcbnew/dialogs/panel_display_options.cpp @@ -18,16 +18,12 @@ * with this program. If not, see . */ -#include -#include +#include +#include #include #include #include -#include -#include -#include #include -#include static const UTIL::CFG_MAP traceClearanceSelectMap = @@ -40,40 +36,36 @@ static const UTIL::CFG_MAP }; -PANEL_DISPLAY_OPTIONS::PANEL_DISPLAY_OPTIONS( PCB_BASE_FRAME* aFrame, PAGED_DIALOG* aParent ) : - PANEL_DISPLAY_OPTIONS_BASE( aParent->GetTreebook() ), - m_frame( aFrame ) +PANEL_DISPLAY_OPTIONS::PANEL_DISPLAY_OPTIONS( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ) : + PANEL_DISPLAY_OPTIONS_BASE( aParent ), + m_isPCBEdit( dynamic_cast( aAppSettings ) != nullptr ) { - m_galOptsPanel = new GAL_OPTIONS_PANEL( this, m_frame ); + m_galOptsPanel = new GAL_OPTIONS_PANEL( this, aAppSettings ); m_galOptionsSizer->Add( m_galOptsPanel, 1, wxEXPAND, 0 ); - m_optionsBook->SetSelection( dynamic_cast( m_frame ) ? 1 : 0 ); + m_optionsBook->SetSelection( m_isPCBEdit ? 1 : 0 ); } bool PANEL_DISPLAY_OPTIONS::TransferDataToWindow() { - PCB_EDIT_FRAME* pcbEdit = dynamic_cast( m_frame ); - - if( pcbEdit ) + if( m_isPCBEdit ) { - const PCB_DISPLAY_OPTIONS& displ_opts = pcbEdit->GetDisplayOptions(); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + PCBNEW_SETTINGS* cfg = mgr.GetAppSettings(); m_OptDisplayTracksClearance->SetSelection( UTIL::GetConfigForVal( - traceClearanceSelectMap, displ_opts.m_ShowTrackClearanceMode ) ); + traceClearanceSelectMap, + cfg->m_Display.m_ShowTrackClearanceMode ) ); - m_OptDisplayPadClearence->SetValue( displ_opts.m_DisplayPadClearance ); - m_OptDisplayPadNumber->SetValue( displ_opts.m_DisplayPadNum ); - m_OptDisplayPadNoConn->SetValue( pcbEdit->IsElementVisible( LAYER_NO_CONNECTS ) ); - m_ShowNetNamesOption->SetSelection( displ_opts.m_DisplayNetNamesMode ); - - m_live3Drefresh->SetValue( displ_opts.m_Live3DRefresh ); - - CROSS_PROBING_SETTINGS& crossProbing = pcbEdit->GetPcbNewSettings()->m_CrossProbing; - - m_checkCrossProbeCenter->SetValue( crossProbing.center_on_items ); - m_checkCrossProbeZoom->SetValue( crossProbing.zoom_to_fit ); - m_checkCrossProbeAutoHighlight->SetValue( crossProbing.auto_highlight ); + 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 ); } m_galOptsPanel->TransferDataToWindow(); @@ -89,57 +81,25 @@ bool PANEL_DISPLAY_OPTIONS::TransferDataFromWindow() { m_galOptsPanel->TransferDataFromWindow(); - // Apply changes to the GAL - KIGFX::VIEW* view = m_frame->GetCanvas()->GetView(); - KIGFX::PCB_PAINTER* painter = static_cast( view->GetPainter() ); - KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings(); - - PCB_EDIT_FRAME* pcbEdit = dynamic_cast( m_frame ); - - if( pcbEdit ) + if( m_isPCBEdit ) { - PCB_DISPLAY_OPTIONS displ_opts = pcbEdit->GetDisplayOptions(); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + PCBNEW_SETTINGS* cfg = mgr.GetAppSettings(); - displ_opts.m_ShowTrackClearanceMode = UTIL::GetValFromConfig( - traceClearanceSelectMap, m_OptDisplayTracksClearance->GetSelection() ); + cfg->m_Display.m_ShowTrackClearanceMode = UTIL::GetValFromConfig( + traceClearanceSelectMap, + m_OptDisplayTracksClearance->GetSelection() ); - displ_opts.m_DisplayPadClearance = m_OptDisplayPadClearence->GetValue(); - displ_opts.m_DisplayPadNum = m_OptDisplayPadNumber->GetValue(); - - pcbEdit->SetElementVisibility( LAYER_NO_CONNECTS, m_OptDisplayPadNoConn->GetValue() ); - displ_opts.m_DisplayPadNoConnects = m_OptDisplayPadNoConn->GetValue(); - - displ_opts.m_DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection(); - displ_opts.m_Live3DRefresh = m_live3Drefresh->GetValue(); - - pcbEdit->SetDisplayOptions( displ_opts ); - settings->LoadDisplayOptions( displ_opts, pcbEdit->ShowPageLimits() ); - pcbEdit->SetElementVisibility( LAYER_RATSNEST, displ_opts.m_ShowGlobalRatsnest ); - - CROSS_PROBING_SETTINGS& crossProbing = pcbEdit->GetPcbNewSettings()->m_CrossProbing; - - crossProbing.center_on_items = m_checkCrossProbeCenter->GetValue(); - crossProbing.zoom_to_fit = m_checkCrossProbeZoom->GetValue(); - crossProbing.auto_highlight = m_checkCrossProbeAutoHighlight->GetValue(); - - // Mark items with clearance display for repaint - view->UpdateAllItemsConditionally( KIGFX::REPAINT, - []( KIGFX::VIEW_ITEM* aItem ) -> bool - { - if( EDA_ITEM* item = dynamic_cast( aItem ) ) - { - return( item->Type() == PCB_TRACE_T || - item->Type() == PCB_ARC_T || - item->Type() == PCB_VIA_T || - item->Type() == PCB_PAD_T ); - } - - return false; - } ); + cfg->m_Display.m_DisplayPadClearance = m_OptDisplayPadClearence->GetValue(); + cfg->m_Display.m_DisplayPadNum = m_OptDisplayPadNumber->GetValue(); + cfg->m_Display.m_DisplayPadNoConnects = m_OptDisplayPadNoConn->GetValue(); + cfg->m_Display.m_DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection(); + cfg->m_Display.m_Live3DRefresh = m_live3Drefresh->GetValue(); + cfg->m_CrossProbing.center_on_items = m_checkCrossProbeCenter->GetValue(); + cfg->m_CrossProbing.zoom_to_fit = m_checkCrossProbeZoom->GetValue(); + cfg->m_CrossProbing.auto_highlight = m_checkCrossProbeAutoHighlight->GetValue(); } - view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); - return true; } diff --git a/pcbnew/dialogs/panel_display_options.h b/pcbnew/dialogs/panel_display_options.h index 17023f4913..105294b7d2 100644 --- a/pcbnew/dialogs/panel_display_options.h +++ b/pcbnew/dialogs/panel_display_options.h @@ -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, jean-pierre.charras at wanadoo.fr - * Copyright (C) 1992-2020 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 @@ -20,19 +20,20 @@ #include "panel_display_options_base.h" +class APP_SETTINGS_BASE; class GAL_OPTIONS_PANEL; + class PANEL_DISPLAY_OPTIONS : public PANEL_DISPLAY_OPTIONS_BASE { public: - PANEL_DISPLAY_OPTIONS( PCB_BASE_FRAME* aFrame, PAGED_DIALOG* aWindow ); + PANEL_DISPLAY_OPTIONS( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ); - bool TransferDataFromWindow() override; - bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; + bool TransferDataToWindow() override; private: - PCB_BASE_FRAME* m_frame; - - GAL_OPTIONS_PANEL* m_galOptsPanel; + bool m_isPCBEdit; + GAL_OPTIONS_PANEL* m_galOptsPanel; }; diff --git a/pcbnew/dialogs/panel_edit_options.cpp b/pcbnew/dialogs/panel_edit_options.cpp index 9a83a55a24..f86939bbf7 100644 --- a/pcbnew/dialogs/panel_edit_options.cpp +++ b/pcbnew/dialogs/panel_edit_options.cpp @@ -22,25 +22,22 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include +#include +#include -PANEL_EDIT_OPTIONS::PANEL_EDIT_OPTIONS( PCB_BASE_EDIT_FRAME* aFrame, PAGED_DIALOG* aParent ) : - PANEL_EDIT_OPTIONS_BASE( aParent->GetTreebook() ), m_frame( aFrame ) +PANEL_EDIT_OPTIONS::PANEL_EDIT_OPTIONS( wxWindow* aParent, bool isFootprintEditor ) : + PANEL_EDIT_OPTIONS_BASE( aParent ), + m_isFootprintEditor( isFootprintEditor ) { - m_magneticPads->Show( dynamic_cast( m_frame ) != nullptr ); - m_magneticGraphics->Show( dynamic_cast( m_frame ) != nullptr ); - m_flipLeftRight->Show( dynamic_cast( m_frame ) != nullptr ); - m_allowFreePads->Show( dynamic_cast( m_frame ) != nullptr ); + m_magneticPads->Show( m_isFootprintEditor ); + m_magneticGraphics->Show( m_isFootprintEditor ); + m_flipLeftRight->Show( !m_isFootprintEditor ); + m_allowFreePads->Show( !m_isFootprintEditor ); #ifdef __WXOSX_MAC__ m_mouseCmdsOSX->Show( true ); @@ -50,53 +47,48 @@ PANEL_EDIT_OPTIONS::PANEL_EDIT_OPTIONS( PCB_BASE_EDIT_FRAME* aFrame, PAGED_DIALO m_mouseCmdsOSX->Show( false ); #endif - m_optionsBook->SetSelection( dynamic_cast( m_frame ) ? 1 : 0 ); + m_optionsBook->SetSelection( isFootprintEditor ? 0 : 1 ); } bool PANEL_EDIT_OPTIONS::TransferDataToWindow() { - const PCB_DISPLAY_OPTIONS& displ_opts = m_frame->GetDisplayOptions(); - const PCBNEW_SETTINGS& general_opts = m_frame->Settings(); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); - wxString rotationAngle; - rotationAngle = AngleToStringDegrees( (double) m_frame->GetRotationAngle() ); - m_rotationAngle->SetValue( rotationAngle ); - - if( dynamic_cast( m_frame ) ) + if( m_isFootprintEditor ) { - const MAGNETIC_SETTINGS& mag_opts = general_opts.m_MagneticItems; + 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 ); + } + 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( displ_opts.m_DisplayRatsnestLinesCurved ); - m_showSelectedRatsnest->SetValue( displ_opts.m_ShowModuleRatsnest ); + m_OptDisplayCurvedRatsnestLines->SetValue( cfg->m_Display.m_DisplayRatsnestLinesCurved ); + m_showSelectedRatsnest->SetValue( cfg->m_Display.m_ShowModuleRatsnest ); - m_magneticPadChoice->SetSelection( static_cast( mag_opts.pads ) ); - m_magneticTrackChoice->SetSelection( static_cast( mag_opts.tracks ) ); - m_magneticGraphicsChoice->SetSelection( !mag_opts.graphics ); - - m_flipLeftRight->SetValue( general_opts.m_FlipLeftRight ); - - switch( general_opts.m_TrackDragAction ) + 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( m_frame->ShowPageLimits() ); - m_autoRefillZones->SetValue( general_opts.m_AutoRefillZones ); - m_allowFreePads->SetValue( general_opts.m_AllowFreePads ); - - m_cbPcbGraphic45Mode->SetValue( general_opts.m_PcbUse45DegreeLimit ); - } - else if( dynamic_cast( m_frame ) ) - { - const MAGNETIC_SETTINGS* mag_opts = m_frame->GetMagneticItemsSettings(); - - m_magneticPads->SetValue( mag_opts->pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS ); - m_magneticGraphics->SetValue( mag_opts->graphics ); - m_cbFpGraphic45Mode->SetValue( general_opts.m_FpeditUse45DegreeLimit ); + m_showPageLimits->SetValue( cfg->m_ShowPageLimits ); + m_autoRefillZones->SetValue( cfg->m_AutoRefillZones ); + m_allowFreePads->SetValue( cfg->m_AllowFreePads ); } return true; @@ -105,65 +97,47 @@ bool PANEL_EDIT_OPTIONS::TransferDataToWindow() bool PANEL_EDIT_OPTIONS::TransferDataFromWindow() { - PCB_DISPLAY_OPTIONS displ_opts = m_frame->GetDisplayOptions(); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); - m_frame->SetRotationAngle( wxRound( 10.0 * wxAtof( m_rotationAngle->GetValue() ) ) ); - - if( dynamic_cast( m_frame ) ) + if( m_isFootprintEditor ) { - PCBNEW_SETTINGS& pcbnewSettings = m_frame->Settings(); - MAGNETIC_SETTINGS& mag_opts = pcbnewSettings.m_MagneticItems; + FOOTPRINT_EDITOR_SETTINGS* cfg = mgr.GetAppSettings(); - displ_opts.m_DisplayRatsnestLinesCurved = m_OptDisplayCurvedRatsnestLines->GetValue(); - displ_opts.m_ShowModuleRatsnest = m_showSelectedRatsnest->GetValue(); + cfg->m_RotationAngle = wxRound( 10.0 * wxAtof( m_rotationAngle->GetValue() ) ); - mag_opts.pads = static_cast( m_magneticPadChoice->GetSelection() ); - mag_opts.tracks = static_cast( m_magneticTrackChoice->GetSelection() ); - mag_opts.graphics = !m_magneticGraphicsChoice->GetSelection(); + cfg->m_MagneticItems.pads = m_magneticPads->GetValue() ? MAGNETIC_OPTIONS::CAPTURE_ALWAYS + : MAGNETIC_OPTIONS::NO_EFFECT; + cfg->m_MagneticItems.graphics = m_magneticGraphics->GetValue(); - pcbnewSettings.m_FlipLeftRight = m_flipLeftRight->GetValue(); - pcbnewSettings.m_AutoRefillZones = m_autoRefillZones->GetValue(); - pcbnewSettings.m_AllowFreePads = m_allowFreePads->GetValue(); + cfg->m_Use45Limit = m_cbFpGraphic45Mode->GetValue(); + } + else + { + PCBNEW_SETTINGS* cfg = mgr.GetAppSettings(); - m_frame->SetShowPageLimits( m_showPageLimits->GetValue() ); + cfg->m_Display.m_DisplayRatsnestLinesCurved = m_OptDisplayCurvedRatsnestLines->GetValue(); + cfg->m_Display.m_ShowModuleRatsnest = m_showSelectedRatsnest->GetValue(); + + cfg->m_RotationAngle = wxRound( 10.0 * wxAtof( m_rotationAngle->GetValue() ) ); + + cfg->m_MagneticItems.pads = static_cast( m_magneticPadChoice->GetSelection() ); + cfg->m_MagneticItems.tracks = static_cast( m_magneticTrackChoice->GetSelection() ); + cfg->m_MagneticItems.graphics = !m_magneticGraphicsChoice->GetSelection(); + + cfg->m_FlipLeftRight = m_flipLeftRight->GetValue(); + cfg->m_AutoRefillZones = m_autoRefillZones->GetValue(); + cfg->m_AllowFreePads = m_allowFreePads->GetValue(); + cfg->m_ShowPageLimits = m_showPageLimits->GetValue(); if( m_rbTrackDragMove->GetValue() ) - pcbnewSettings.m_TrackDragAction = TRACK_DRAG_ACTION::MOVE; + cfg->m_TrackDragAction = TRACK_DRAG_ACTION::MOVE; else if( m_rbTrackDrag45->GetValue() ) - pcbnewSettings.m_TrackDragAction = TRACK_DRAG_ACTION::DRAG; + cfg->m_TrackDragAction = TRACK_DRAG_ACTION::DRAG; else if( m_rbTrackDragFree->GetValue() ) - pcbnewSettings.m_TrackDragAction = TRACK_DRAG_ACTION::DRAG_FREE_ANGLE; + cfg->m_TrackDragAction = TRACK_DRAG_ACTION::DRAG_FREE_ANGLE; - pcbnewSettings.m_PcbUse45DegreeLimit = m_cbPcbGraphic45Mode->GetValue(); + cfg->m_Use45DegreeLimit = m_cbPcbGraphic45Mode->GetValue(); } - else if( dynamic_cast( m_frame ) ) - { - MAGNETIC_SETTINGS* mag_opts = m_frame->GetMagneticItemsSettings(); - - mag_opts->pads = m_magneticPads->GetValue() ? MAGNETIC_OPTIONS::CAPTURE_ALWAYS - : MAGNETIC_OPTIONS::NO_EFFECT; - mag_opts->graphics = m_magneticGraphics->GetValue(); - - m_frame->Settings().m_FpeditUse45DegreeLimit = m_cbFpGraphic45Mode->GetValue(); - } - - - // Apply changes to the GAL - KIGFX::VIEW* view = m_frame->GetCanvas()->GetView(); - KIGFX::PCB_PAINTER* painter = static_cast( view->GetPainter() ); - KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings(); - - m_frame->SetDisplayOptions( displ_opts, false ); - settings->LoadDisplayOptions( displ_opts, m_frame->ShowPageLimits() ); - - view->UpdateAllItemsConditionally( KIGFX::REPAINT, - []( KIGFX::VIEW_ITEM* aItem ) -> bool - { - return dynamic_cast( aItem ); - } ); - view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); - - m_frame->GetCanvas()->Refresh(); return true; } diff --git a/pcbnew/dialogs/panel_edit_options.h b/pcbnew/dialogs/panel_edit_options.h index 2d22e7a84c..f028263bb0 100644 --- a/pcbnew/dialogs/panel_edit_options.h +++ b/pcbnew/dialogs/panel_edit_options.h @@ -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, jean-pierre.charras at wanadoo.fr - * Copyright (C) 1992-2020 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 @@ -27,21 +27,18 @@ #include "panel_edit_options_base.h" -class PAGED_DIALOG; -class PCB_BASE_EDIT_FRAME; - class PANEL_EDIT_OPTIONS : public PANEL_EDIT_OPTIONS_BASE { public: - PANEL_EDIT_OPTIONS( PCB_BASE_EDIT_FRAME* aFrame, PAGED_DIALOG* aWindow ); + PANEL_EDIT_OPTIONS( wxWindow* aParent, bool isFootprintEditor ); protected: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; private: - PCB_BASE_EDIT_FRAME* m_frame; + bool m_isFootprintEditor; }; diff --git a/pcbnew/dialogs/panel_fp_editor_color_settings.cpp b/pcbnew/dialogs/panel_fp_editor_color_settings.cpp index 43d17bf80d..eb35c27aac 100644 --- a/pcbnew/dialogs/panel_fp_editor_color_settings.cpp +++ b/pcbnew/dialogs/panel_fp_editor_color_settings.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Jon Evans - * 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 @@ -20,41 +20,38 @@ #include -#include -#include -#include -#include -#include -#include +#include #include +#include +#include +#include +#include +#include -PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS( FOOTPRINT_EDIT_FRAME* aFrame, - wxWindow* aParent ) - : PANEL_COLOR_SETTINGS( aParent ), - m_frame( aFrame ), - m_page( nullptr ), - m_titleBlock( nullptr ) +PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS( wxWindow* aParent ) : + PANEL_COLOR_SETTINGS( aParent ), + m_page( nullptr ), + m_titleBlock( nullptr ) { // Currently this only applies to eeschema m_optOverrideColors->Hide(); m_colorNamespace = "board"; - SETTINGS_MANAGER* mgr = m_frame->GetSettingsManager(); - - FOOTPRINT_EDITOR_SETTINGS* settings = mgr->GetAppSettings(); - COLOR_SETTINGS* current = mgr->GetColorSettings( settings->m_ColorTheme ); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + FOOTPRINT_EDITOR_SETTINGS* settings = mgr.GetAppSettings(); + COLOR_SETTINGS* current = mgr.GetColorSettings( settings->m_ColorTheme ); // Store the current settings before reloading below current->Store(); - mgr->SaveColorSettings( current, "board" ); + mgr.SaveColorSettings( current, "board" ); m_optOverrideColors->SetValue( current->GetOverrideSchItemColors() ); m_currentSettings = new COLOR_SETTINGS( *current ); - mgr->ReloadColorSettings(); + mgr.ReloadColorSettings(); createThemeList( settings->m_ColorTheme ); m_validLayers.push_back( F_Cu ); @@ -78,8 +75,6 @@ PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS( FOOTPRINT_EDIT_F m_backgroundLayer = LAYER_PCB_BACKGROUND; m_colorsMainSizer->Insert( 0, 10, 0, 0, wxEXPAND, 5 ); - - createSwatches(); } @@ -93,8 +88,8 @@ PANEL_FP_EDITOR_COLOR_SETTINGS::~PANEL_FP_EDITOR_COLOR_SETTINGS() bool PANEL_FP_EDITOR_COLOR_SETTINGS::TransferDataFromWindow() { - SETTINGS_MANAGER* settingsMgr = m_frame->GetSettingsManager(); - FOOTPRINT_EDITOR_SETTINGS* settings = settingsMgr->GetAppSettings(); + SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager(); + FOOTPRINT_EDITOR_SETTINGS* settings = settingsMgr.GetAppSettings(); settings->m_ColorTheme = m_currentSettings->GetFilename(); return true; @@ -124,11 +119,9 @@ void PANEL_FP_EDITOR_COLOR_SETTINGS::createSwatches() return LayerName( a ) < LayerName( b ); } ); - BOARD* board = m_frame->GetBoard(); - - createSwatch( F_Cu, board ? board->GetLayerName( F_Cu ) : LayerName( F_Cu ) ); + createSwatch( F_Cu, LayerName( F_Cu ) ); createSwatch( In1_Cu, _( "Internal Layers" ) ); - createSwatch( B_Cu, board ? board->GetLayerName( B_Cu ) : LayerName( B_Cu ) ); + createSwatch( B_Cu, LayerName( B_Cu ) ); for( GAL_LAYER_ID layer : galLayers ) createSwatch( layer, LayerName( layer ) ); diff --git a/pcbnew/dialogs/panel_fp_editor_color_settings.h b/pcbnew/dialogs/panel_fp_editor_color_settings.h index ac2eb07712..35bbaa3e87 100644 --- a/pcbnew/dialogs/panel_fp_editor_color_settings.h +++ b/pcbnew/dialogs/panel_fp_editor_color_settings.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Jon Evans - * 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 @@ -21,21 +21,16 @@ #ifndef PANEL_FP_EDITOR_COLOR_SETTINGS_H #define PANEL_FP_EDITOR_COLOR_SETTINGS_H -#include -#include #include -class COLOR_SETTINGS; class PAGE_INFO; -class FOOTPRINT_EDIT_FRAME; class TITLE_BLOCK; -class DS_PROXY_VIEW_ITEM; class PANEL_FP_EDITOR_COLOR_SETTINGS : public PANEL_COLOR_SETTINGS { public: - PANEL_FP_EDITOR_COLOR_SETTINGS( FOOTPRINT_EDIT_FRAME* aFrame, wxWindow* aParent ); + PANEL_FP_EDITOR_COLOR_SETTINGS( wxWindow* aParent ); ~PANEL_FP_EDITOR_COLOR_SETTINGS() override; @@ -44,6 +39,8 @@ protected: bool TransferDataToWindow() override; + void createSwatches() override; + enum COLOR_CONTEXT_ID { ID_COPY = wxID_HIGHEST + 1, @@ -52,11 +49,8 @@ protected: }; private: - FOOTPRINT_EDIT_FRAME* m_frame; - PAGE_INFO* m_page; - TITLE_BLOCK* m_titleBlock; - - void createSwatches(); + PAGE_INFO* m_page; + TITLE_BLOCK* m_titleBlock; }; diff --git a/pcbnew/dialogs/panel_fp_editor_defaults.cpp b/pcbnew/dialogs/panel_fp_editor_defaults.cpp index 10ffed9c78..ca755ce63f 100644 --- a/pcbnew/dialogs/panel_fp_editor_defaults.cpp +++ b/pcbnew/dialogs/panel_fp_editor_defaults.cpp @@ -21,17 +21,16 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include +#include +#include #include #include +#include #include - +#include #include #include #include - -#include #include class TEXT_ITEMS_GRID_TABLE : public wxGridTableBase @@ -170,13 +169,15 @@ enum }; -PANEL_FP_EDITOR_DEFAULTS::PANEL_FP_EDITOR_DEFAULTS( FOOTPRINT_EDIT_FRAME* aFrame, - PAGED_DIALOG* aParent) : - PANEL_FP_EDITOR_DEFAULTS_BASE( aParent->GetTreebook() ), - m_brdSettings( aFrame->GetDesignSettings() ), - m_frame( aFrame ), - m_parent( aParent ) +PANEL_FP_EDITOR_DEFAULTS::PANEL_FP_EDITOR_DEFAULTS( wxWindow* aParent, + EDA_BASE_FRAME* aUnitsProvider ) : + PANEL_FP_EDITOR_DEFAULTS_BASE( aParent ) { + if( aUnitsProvider ) + m_units = aUnitsProvider->GetUserUnits(); + + m_parent = static_cast( aParent->GetParent() ); + m_textItemsGrid->SetDefaultRowSize( m_textItemsGrid->GetDefaultRowSize() + 4 ); m_graphicsGrid->SetDefaultRowSize( m_graphicsGrid->GetDefaultRowSize() + 4 ); @@ -191,8 +192,8 @@ PANEL_FP_EDITOR_DEFAULTS::PANEL_FP_EDITOR_DEFAULTS( FOOTPRINT_EDIT_FRAME* aFrame m_textItemsGrid->SetColAttr( 1, attr ); attr = new wxGridCellAttr; - attr->SetRenderer( new GRID_CELL_LAYER_RENDERER( m_frame ) ); - attr->SetEditor( new GRID_CELL_LAYER_SELECTOR( m_frame, {} ) ); + attr->SetRenderer( new GRID_CELL_LAYER_RENDERER( nullptr ) ); + attr->SetEditor( new GRID_CELL_LAYER_SELECTOR( nullptr, {} ) ); m_textItemsGrid->SetColAttr( 2, attr ); // Work around a bug in wxWidgets where it fails to recalculate the grid height @@ -219,15 +220,18 @@ bool PANEL_FP_EDITOR_DEFAULTS::TransferDataToWindow() wxColour disabledColour = wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ); #define SET_MILS_CELL( row, col, val ) \ - m_graphicsGrid->SetCellValue( row, col, StringFromValue( m_frame->GetUserUnits(), val, true ) ) + m_graphicsGrid->SetCellValue( row, col, StringFromValue( m_units, val, true ) ) #define DISABLE_CELL( row, col ) \ 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, m_brdSettings.m_LineThickness[ i ] ); + SET_MILS_CELL( i, COL_LINE_THICKNESS, cfg->m_DesignSettings.m_LineThickness[ i ] ); if( i == ROW_EDGES || i == ROW_COURTYARD ) { @@ -238,10 +242,10 @@ bool PANEL_FP_EDITOR_DEFAULTS::TransferDataToWindow() } else { - SET_MILS_CELL( i, COL_TEXT_WIDTH, m_brdSettings.m_TextSize[ i ].x ); - SET_MILS_CELL( i, COL_TEXT_HEIGHT, m_brdSettings.m_TextSize[ i ].y ); - SET_MILS_CELL( i, COL_TEXT_THICKNESS, m_brdSettings.m_TextThickness[ i ] ); - m_graphicsGrid->SetCellValue( i, COL_TEXT_ITALIC, m_brdSettings.m_TextItalic[ i ] ? "1" : "" ); + 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" : "" ); auto attr = new wxGridCellAttr; attr->SetRenderer( new wxGridCellBoolRenderer() ); @@ -252,11 +256,11 @@ bool PANEL_FP_EDITOR_DEFAULTS::TransferDataToWindow() } // Footprint defaults - m_textItemsGrid->GetTable()->AppendRows( m_brdSettings.m_DefaultFPTextItems.size() ); + m_textItemsGrid->GetTable()->AppendRows( cfg->m_DesignSettings.m_DefaultFPTextItems.size() ); - for( size_t i = 0; i < m_brdSettings.m_DefaultFPTextItems.size(); ++i ) + for( size_t i = 0; i < cfg->m_DesignSettings.m_DefaultFPTextItems.size(); ++i ) { - TEXT_ITEM_INFO item = m_brdSettings.m_DefaultFPTextItems[i]; + TEXT_ITEM_INFO item = cfg->m_DesignSettings.m_DefaultFPTextItems[i]; m_textItemsGrid->GetTable()->SetValue( i, 0, item.m_Text ); m_textItemsGrid->GetTable()->SetValueAsBool( i, 1, item.m_Visible ); @@ -306,8 +310,7 @@ bool PANEL_FP_EDITOR_DEFAULTS::Show( bool aShow ) int PANEL_FP_EDITOR_DEFAULTS::getGridValue( int aRow, int aCol ) { - return ValueFromString( m_frame->GetUserUnits(), - m_graphicsGrid->GetCellValue( aRow, aCol ) ); + return ValueFromString( m_units, m_graphicsGrid->GetCellValue( aRow, aCol ) ); } @@ -340,24 +343,27 @@ bool PANEL_FP_EDITOR_DEFAULTS::TransferDataFromWindow() if( !validateData() ) return false; + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + FOOTPRINT_EDITOR_SETTINGS* cfg = mgr.GetAppSettings(); + for( int i = 0; i < ROW_COUNT; ++i ) { - m_brdSettings.m_LineThickness[ i ] = getGridValue( i, COL_LINE_THICKNESS ); + cfg->m_DesignSettings.m_LineThickness[ i ] = getGridValue( i, COL_LINE_THICKNESS ); if( i == ROW_EDGES || i == ROW_COURTYARD ) continue; - m_brdSettings.m_TextSize[ i ] = wxSize( getGridValue( i, COL_TEXT_WIDTH ), - getGridValue( i, COL_TEXT_HEIGHT ) ); - m_brdSettings.m_TextThickness[ i ] = getGridValue( i, COL_TEXT_THICKNESS ); + cfg->m_DesignSettings.m_TextSize[ i ] = wxSize( getGridValue( i, COL_TEXT_WIDTH ), + getGridValue( i, COL_TEXT_HEIGHT ) ); + cfg->m_DesignSettings.m_TextThickness[ i ] = getGridValue( i, COL_TEXT_THICKNESS ); wxString msg = m_graphicsGrid->GetCellValue( i, COL_TEXT_ITALIC ); - m_brdSettings.m_TextItalic[ i ] = wxGridCellBoolEditor::IsTrueValue( msg ); + cfg->m_DesignSettings.m_TextItalic[ i ] = wxGridCellBoolEditor::IsTrueValue( msg ); } // Footprint defaults wxGridTableBase* table = m_textItemsGrid->GetTable(); - m_brdSettings.m_DefaultFPTextItems.clear(); + cfg->m_DesignSettings.m_DefaultFPTextItems.clear(); for( int i = 0; i < m_textItemsGrid->GetNumberRows(); ++i ) { @@ -365,14 +371,9 @@ bool PANEL_FP_EDITOR_DEFAULTS::TransferDataFromWindow() bool visible = table->GetValueAsBool( i, 1 ); int layer = (int) table->GetValueAsLong( i, 2 ); - m_brdSettings.m_DefaultFPTextItems.emplace_back( text, visible, layer ); + cfg->m_DesignSettings.m_DefaultFPTextItems.emplace_back( text, visible, layer ); } - m_frame->GetDesignSettings() = m_brdSettings; - - if( FOOTPRINT_EDITOR_SETTINGS* cfg = m_frame->GetSettings() ) - cfg->m_DesignSettings = m_brdSettings; - return true; } diff --git a/pcbnew/dialogs/panel_fp_editor_defaults.h b/pcbnew/dialogs/panel_fp_editor_defaults.h index 960ce627f4..5404295d0d 100644 --- a/pcbnew/dialogs/panel_fp_editor_defaults.h +++ b/pcbnew/dialogs/panel_fp_editor_defaults.h @@ -21,16 +21,14 @@ #define PANEL_FP_EDITOR_DEFAULTS_H #include -#include -#include -class FOOTPRINT_EDIT_FRAME; +class PAGED_DIALOG; class PANEL_FP_EDITOR_DEFAULTS : public PANEL_FP_EDITOR_DEFAULTS_BASE { public: - PANEL_FP_EDITOR_DEFAULTS( FOOTPRINT_EDIT_FRAME* aFrame, PAGED_DIALOG* aParent ); + PANEL_FP_EDITOR_DEFAULTS( wxWindow* aParent, EDA_BASE_FRAME* aUnitsProvider ); ~PANEL_FP_EDITOR_DEFAULTS() override; private: @@ -46,10 +44,10 @@ private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; - BOARD_DESIGN_SETTINGS m_brdSettings; - FOOTPRINT_EDIT_FRAME* m_frame; - PAGED_DIALOG* m_parent; - bool m_firstShow = true; +private: + EDA_UNITS m_units = EDA_UNITS::MILLIMETRES; + PAGED_DIALOG* m_parent; + bool m_firstShow = true; }; diff --git a/pcbnew/dialogs/panel_pcbnew_action_plugins.cpp b/pcbnew/dialogs/panel_pcbnew_action_plugins.cpp index 1057cb80d9..88156a7b94 100644 --- a/pcbnew/dialogs/panel_pcbnew_action_plugins.cpp +++ b/pcbnew/dialogs/panel_pcbnew_action_plugins.cpp @@ -26,22 +26,18 @@ #include #include #include +#include #include -#include -#include #include #include #include -#include #define GRID_CELL_MARGIN 4 -PANEL_PCBNEW_ACTION_PLUGINS::PANEL_PCBNEW_ACTION_PLUGINS( PCB_EDIT_FRAME* aFrame, - PAGED_DIALOG* aWindow ) : - PANEL_PCBNEW_ACTION_PLUGINS_BASE( aWindow->GetTreebook() ), - m_frame( aFrame ) +PANEL_PCBNEW_ACTION_PLUGINS::PANEL_PCBNEW_ACTION_PLUGINS( wxWindow* aParent ) : + PANEL_PCBNEW_ACTION_PLUGINS_BASE( aParent ) { m_genericIcon = KiBitmap( BITMAPS::puzzle_piece ); m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) ); @@ -142,7 +138,7 @@ void PANEL_PCBNEW_ACTION_PLUGINS::SwapRows( int aRowA, int aRowB ) void PANEL_PCBNEW_ACTION_PLUGINS::OnReloadButtonClick( wxCommandEvent& event ) { - m_frame->GetToolManager()->RunAction( PCB_ACTIONS::pluginsReload, true ); + SCRIPTING_TOOL::ReloadPlugins(); TransferDataToWindow(); } @@ -174,7 +170,7 @@ bool PANEL_PCBNEW_ACTION_PLUGINS::TransferDataToWindow() m_grid->ClearRows(); - const auto& orderedPlugins = m_frame->GetOrderedActionPlugins(); + const auto& orderedPlugins = PCB_EDIT_FRAME::GetOrderedActionPlugins(); m_grid->AppendRows( orderedPlugins.size() ); for( size_t row = 0; row < orderedPlugins.size(); row++ ) @@ -189,10 +185,10 @@ bool PANEL_PCBNEW_ACTION_PLUGINS::TransferDataToWindow() m_grid->SetCellRenderer( row, COLUMN_VISIBLE, new wxGridCellBoolRenderer() ); m_grid->SetCellAlignment( row, COLUMN_VISIBLE, wxALIGN_CENTER, wxALIGN_CENTER ); - bool showButton = m_frame->GetActionPluginButtonVisible( ap->GetPluginPath(), - ap->GetShowToolbarButton() ); + bool show = PCB_EDIT_FRAME::GetActionPluginButtonVisible( ap->GetPluginPath(), + ap->GetShowToolbarButton() ); - m_grid->SetCellValue( row, COLUMN_VISIBLE, showButton ? wxT( "1" ) : wxEmptyString ); + m_grid->SetCellValue( row, COLUMN_VISIBLE, show ? wxT( "1" ) : wxEmptyString ); m_grid->SetCellValue( row, COLUMN_NAME, ap->GetName() ); m_grid->SetCellValue( row, COLUMN_CATEGORY, ap->GetCategoryName() ); @@ -217,26 +213,33 @@ bool PANEL_PCBNEW_ACTION_PLUGINS::TransferDataToWindow() // Show errors button should be disabled if there are no errors. wxString trace; - pcbnewGetWizardsBackTrace( trace ); + + if( ACTION_PLUGINS::GetActionsCount() ) + pcbnewGetWizardsBackTrace( trace ); + if( trace.empty() ) { m_showErrorsButton->Disable(); m_showErrorsButton->Hide(); + m_reloadButton->Disable(); } else { m_showErrorsButton->Enable(); m_showErrorsButton->Show(); + m_reloadButton->Enable(); } return true; } + void PANEL_PCBNEW_ACTION_PLUGINS::OnOpenDirectoryButtonClick( wxCommandEvent& event ) { - m_frame->GetToolManager()->RunAction( PCB_ACTIONS::pluginsShowFolder, true ); + SCRIPTING_TOOL::ShowPluginFolder(); } + void PANEL_PCBNEW_ACTION_PLUGINS::OnShowErrorsButtonClick( wxCommandEvent& event ) { wxString trace; diff --git a/pcbnew/dialogs/panel_pcbnew_action_plugins.h b/pcbnew/dialogs/panel_pcbnew_action_plugins.h index ae243d4755..97712a4bf9 100644 --- a/pcbnew/dialogs/panel_pcbnew_action_plugins.h +++ b/pcbnew/dialogs/panel_pcbnew_action_plugins.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2018 Andrew Lutsenko, anlutsenko at gmail dot com - * 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 @@ -23,7 +23,7 @@ class PANEL_PCBNEW_ACTION_PLUGINS : public PANEL_PCBNEW_ACTION_PLUGINS_BASE { public: - PANEL_PCBNEW_ACTION_PLUGINS ( PCB_EDIT_FRAME* aFrame, PAGED_DIALOG* aWindow ); + PANEL_PCBNEW_ACTION_PLUGINS ( wxWindow* aParent ); bool TransferDataFromWindow() override; bool TransferDataToWindow() override; @@ -71,7 +71,6 @@ private: COLUMN_PATH }; - PCB_EDIT_FRAME* m_frame; wxBitmap m_genericIcon; void SwapRows( int aRowA, int aRowB ); diff --git a/pcbnew/dialogs/panel_pcbnew_color_settings.cpp b/pcbnew/dialogs/panel_pcbnew_color_settings.cpp index cc7c060b99..4041443120 100644 --- a/pcbnew/dialogs/panel_pcbnew_color_settings.cpp +++ b/pcbnew/dialogs/panel_pcbnew_color_settings.cpp @@ -20,15 +20,13 @@ #include +#include #include -#include #include #include #include -#include #include #include -#include #include #include #include @@ -371,19 +369,18 @@ std::set g_excludedLayers = }; -PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS( PCB_EDIT_FRAME* aFrame, - wxWindow* aParent ) +PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS( wxWindow* aParent, BOARD* aBoard ) : PANEL_COLOR_SETTINGS( aParent ), - m_frame( aFrame ), m_preview( nullptr ), m_page( nullptr ), - m_titleBlock( nullptr ) + m_titleBlock( nullptr ), + m_board( aBoard ) { m_colorNamespace = "board"; - SETTINGS_MANAGER* mgr = m_frame->GetSettingsManager(); - PCBNEW_SETTINGS* app_settings = mgr->GetAppSettings(); - COLOR_SETTINGS* current = mgr->GetColorSettings( app_settings->m_ColorTheme ); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + PCBNEW_SETTINGS* app_settings = mgr.GetAppSettings(); + COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme ); // Saved theme doesn't exist? Reset to default if( current->GetFilename() != app_settings->m_ColorTheme ) @@ -407,21 +404,6 @@ PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS( PCB_EDIT_FRAME* aFrame // NOTE: Main board layers are added by createSwatches() m_backgroundLayer = LAYER_PCB_BACKGROUND; - - m_colorsMainSizer->Insert( 0, 10, 0, 0, wxEXPAND, 5 ); - - createSwatches(); - - m_preview = FOOTPRINT_PREVIEW_PANEL::New( &m_frame->Kiway(), this ); - m_preview->GetGAL()->SetAxesEnabled( false ); - - m_colorsMainSizer->Add( 10, 0, 0, wxEXPAND, 5 ); - m_colorsMainSizer->Add( m_preview, 1, wxALL | wxEXPAND, 5 ); - m_colorsMainSizer->Add( 10, 0, 0, wxEXPAND, 5 ); - - createPreviewItems(); - updatePreview(); - zoomFitPreview(); } @@ -435,8 +417,8 @@ PANEL_PCBNEW_COLOR_SETTINGS::~PANEL_PCBNEW_COLOR_SETTINGS() bool PANEL_PCBNEW_COLOR_SETTINGS::TransferDataFromWindow() { - SETTINGS_MANAGER* settingsMgr = m_frame->GetSettingsManager(); - PCBNEW_SETTINGS* app_settings = settingsMgr->GetAppSettings(); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + PCBNEW_SETTINGS* app_settings = mgr.GetAppSettings(); app_settings->m_ColorTheme = m_currentSettings->GetFilename(); return true; @@ -458,18 +440,16 @@ void PANEL_PCBNEW_COLOR_SETTINGS::createSwatches() return LayerName( a ) < LayerName( b ); } ); - // Don't sort board layers by name + // Don't sort aBoard layers by name for( int i = PCBNEW_LAYER_ID_START; i <= User_9; ++i ) m_validLayers.insert( m_validLayers.begin() + i, i ); - BOARD* board = m_frame->GetBoard(); - for( int layer : m_validLayers ) { wxString name = LayerName( layer ); - if( board && layer >= PCBNEW_LAYER_ID_START && layer < PCB_LAYER_ID_COUNT ) - name = board->GetLayerName( static_cast( layer ) ); + if( m_board && layer >= PCBNEW_LAYER_ID_START && layer < PCB_LAYER_ID_COUNT ) + name = m_board->GetLayerName( static_cast( layer ) ); createSwatch( layer, name ); } @@ -479,6 +459,19 @@ void PANEL_PCBNEW_COLOR_SETTINGS::createSwatches() int min_width = m_colorsGridSizer->GetMinSize().x; const int margin = 20; // A margin around the sizer m_colorsListWindow->SetMinSize( wxSize( min_width + margin, -1 ) ); + + m_colorsMainSizer->Insert( 0, 10, 0, 0, wxEXPAND, 5 ); + + m_preview = FOOTPRINT_PREVIEW_PANEL::New( nullptr, this ); + m_preview->GetGAL()->SetAxesEnabled( false ); + + m_colorsMainSizer->Add( 10, 0, 0, wxEXPAND, 5 ); + m_colorsMainSizer->Add( m_preview, 1, wxALL | wxEXPAND, 5 ); + m_colorsMainSizer->Add( 10, 0, 0, wxEXPAND, 5 ); + + createPreviewItems(); + updatePreview(); + zoomFitPreview(); } @@ -554,23 +547,26 @@ void PANEL_PCBNEW_COLOR_SETTINGS::updatePreview() void PANEL_PCBNEW_COLOR_SETTINGS::zoomFitPreview() { - KIGFX::VIEW* view = m_preview->GetView(); - BOX2I bBox = m_preview->GetBoard()->GetBoundingBox(); - BOX2I defaultBox = m_preview->GetDefaultViewBBox(); + if( m_preview ) + { + KIGFX::VIEW* view = m_preview->GetView(); + BOX2I bBox = m_preview->GetBoard()->GetBoundingBox(); + BOX2I defaultBox = m_preview->GetDefaultViewBBox(); - view->SetScale( 1.0 ); - VECTOR2D screenSize = view->ToWorld( m_preview->GetClientSize(), false ); + view->SetScale( 1.0 ); + VECTOR2D screenSize = view->ToWorld( m_preview->GetClientSize(), false ); - if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 ) - bBox = defaultBox; + if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 ) + bBox = defaultBox; - VECTOR2D vsize = bBox.GetSize(); - double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ), - fabs( vsize.y / screenSize.y ) ); + VECTOR2D vsize = bBox.GetSize(); + double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ), + fabs( vsize.y / screenSize.y ) ); - view->SetScale( scale / 1.1 ); - view->SetCenter( bBox.Centre() ); - m_preview->ForceRefresh(); + view->SetScale( scale / 1.1 ); + view->SetCenter( bBox.Centre() ); + m_preview->ForceRefresh(); + } } diff --git a/pcbnew/dialogs/panel_pcbnew_color_settings.h b/pcbnew/dialogs/panel_pcbnew_color_settings.h index 565937b39a..fa3b157222 100644 --- a/pcbnew/dialogs/panel_pcbnew_color_settings.h +++ b/pcbnew/dialogs/panel_pcbnew_color_settings.h @@ -21,22 +21,17 @@ #ifndef PANEL_PCBNEW_COLOR_SETTINGS_H_ #define PANEL_PCBNEW_COLOR_SETTINGS_H_ -#include -#include #include -class COLOR_SETTINGS; class PAGE_INFO; -class PCB_EDIT_FRAME; class FOOTPRINT_PREVIEW_PANEL; class TITLE_BLOCK; -class DS_PROXY_VIEW_ITEM; class PANEL_PCBNEW_COLOR_SETTINGS : public PANEL_COLOR_SETTINGS { public: - PANEL_PCBNEW_COLOR_SETTINGS( PCB_EDIT_FRAME* aFrame, wxWindow* aParent ); + PANEL_PCBNEW_COLOR_SETTINGS( wxWindow* aParent, BOARD* aBoard ); ~PANEL_PCBNEW_COLOR_SETTINGS() override; @@ -51,6 +46,8 @@ protected: void onNewThemeSelected() override; void onColorChanged() override; + void createSwatches() override; + enum COLOR_CONTEXT_ID { ID_COPY = wxID_HIGHEST + 1, @@ -60,16 +57,14 @@ protected: private: void createPreviewItems(); - void createSwatches(); void updatePreview(); void zoomFitPreview(); - PCB_EDIT_FRAME* m_frame; - FOOTPRINT_PREVIEW_PANEL* m_preview; PAGE_INFO* m_page; TITLE_BLOCK* m_titleBlock; + BOARD* m_board; }; diff --git a/pcbnew/dialogs/panel_pcbnew_display_origin.cpp b/pcbnew/dialogs/panel_pcbnew_display_origin.cpp index 21af7b74f6..2e28d0179a 100644 --- a/pcbnew/dialogs/panel_pcbnew_display_origin.cpp +++ b/pcbnew/dialogs/panel_pcbnew_display_origin.cpp @@ -22,33 +22,24 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include +#include +#include +#include #include -#include -#include -#include -#include -#include - -#include -PANEL_PCBNEW_DISPLAY_ORIGIN::PANEL_PCBNEW_DISPLAY_ORIGIN( - PCB_EDIT_FRAME* aFrame, PAGED_DIALOG* aParent ) - : PANEL_PCBNEW_DISPLAY_ORIGIN_BASE( aParent->GetTreebook() ), - m_Frame( aFrame ) +PANEL_PCBNEW_DISPLAY_ORIGIN::PANEL_PCBNEW_DISPLAY_ORIGIN( wxWindow* aParent ) : + PANEL_PCBNEW_DISPLAY_ORIGIN_BASE( aParent ) { } bool PANEL_PCBNEW_DISPLAY_ORIGIN::TransferDataToWindow() { - const PCB_DISPLAY_OPTIONS& displ_opts = m_Frame->GetDisplayOptions(); + PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); + int origin = 0; - int origin = 0; - - switch( displ_opts.m_DisplayOrigin ) + switch( cfg->m_Display.m_DisplayOrigin ) { case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_PAGE: origin = 0; break; case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_AUX: origin = 1; break; @@ -56,8 +47,8 @@ bool PANEL_PCBNEW_DISPLAY_ORIGIN::TransferDataToWindow() } m_DisplayOrigin->SetSelection( origin ); - m_XAxisDirection->SetSelection( displ_opts.m_DisplayInvertXAxis ? 1 : 0 ); - m_YAxisDirection->SetSelection( displ_opts.m_DisplayInvertYAxis ? 0 : 1 ); + m_XAxisDirection->SetSelection( cfg->m_Display.m_DisplayInvertXAxis ? 1 : 0 ); + m_YAxisDirection->SetSelection( cfg->m_Display.m_DisplayInvertYAxis ? 0 : 1 ); return true; } @@ -65,19 +56,17 @@ bool PANEL_PCBNEW_DISPLAY_ORIGIN::TransferDataToWindow() bool PANEL_PCBNEW_DISPLAY_ORIGIN::TransferDataFromWindow() { - PCB_DISPLAY_OPTIONS displ_opts = m_Frame->GetDisplayOptions(); + PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); switch( m_DisplayOrigin->GetSelection() ) { - case 0: displ_opts.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_PAGE; break; - case 1: displ_opts.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_AUX; break; - case 2: displ_opts.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_GRID; break; + case 0: cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_PAGE; break; + case 1: cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_AUX; break; + case 2: cfg->m_Display.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_GRID; break; } - displ_opts.m_DisplayInvertXAxis = m_XAxisDirection->GetSelection() != 0; - displ_opts.m_DisplayInvertYAxis = m_YAxisDirection->GetSelection() == 0; - - m_Frame->SetDisplayOptions( displ_opts ); + cfg->m_Display.m_DisplayInvertXAxis = m_XAxisDirection->GetSelection() != 0; + cfg->m_Display.m_DisplayInvertYAxis = m_YAxisDirection->GetSelection() == 0; return true; } diff --git a/pcbnew/dialogs/panel_pcbnew_display_origin.h b/pcbnew/dialogs/panel_pcbnew_display_origin.h index e9b21ad0d2..76cb198fd3 100644 --- a/pcbnew/dialogs/panel_pcbnew_display_origin.h +++ b/pcbnew/dialogs/panel_pcbnew_display_origin.h @@ -27,20 +27,15 @@ #include "panel_pcbnew_display_origin_base.h" -class PAGED_DIALOG; - class PANEL_PCBNEW_DISPLAY_ORIGIN : public PANEL_PCBNEW_DISPLAY_ORIGIN_BASE { public: - PANEL_PCBNEW_DISPLAY_ORIGIN( PCB_EDIT_FRAME* aFrame, PAGED_DIALOG* aWindow ); + PANEL_PCBNEW_DISPLAY_ORIGIN( wxWindow* aParent ); protected: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; - -private: - PCB_EDIT_FRAME* m_Frame; }; diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 96973e84e8..c5510bd430 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -37,10 +37,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include @@ -51,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -71,14 +66,11 @@ #include #include #include -#include #include -#include #include #include #include #include -#include #include BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) @@ -988,21 +980,6 @@ void FOOTPRINT_EDIT_FRAME::OnDisplayOptionsChanged() } -void FOOTPRINT_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, - PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) -{ - wxTreebook* book = aParent->GetTreebook(); - - book->AddPage( new wxPanel( book ), _( "Footprint Editor" ) ); - book->AddSubPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); - book->AddSubPage( new PANEL_EDIT_OPTIONS( this, aParent ), _( "Editing Options" ) ); - book->AddSubPage( new PANEL_FP_EDITOR_COLOR_SETTINGS( this, book ), _( "Colors" ) ); - book->AddSubPage( new PANEL_FP_EDITOR_DEFAULTS( this, aParent ), _( "Default Values" ) ); - - aHotkeysPanel->AddHotKeys( GetToolManager() ); -} - - void FOOTPRINT_EDIT_FRAME::setupTools() { // Create the manager and dispatcher & route draw panel events to the dispatcher @@ -1201,7 +1178,11 @@ void FOOTPRINT_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTe { PCB_BASE_EDIT_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged ); + auto cfg = Pgm().GetSettingsManager().GetAppSettings(); + GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window ); + GetCanvas()->GetView()->UpdateAllLayersColor(); + GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); GetCanvas()->ForceRefresh(); UpdateUserInterface(); diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index 79eaf92840..1b908be33e 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -273,11 +273,6 @@ public: */ void AddFootprintToBoard( FOOTPRINT* aFootprint ) override; - /** - * Allow footprint editor to install its preferences panel into the preferences dialog. - */ - void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override; - /** * Update visible items after a language change. */ diff --git a/pcbnew/footprint_editor_settings.cpp b/pcbnew/footprint_editor_settings.cpp index afd3420d90..30f5eb05e1 100644 --- a/pcbnew/footprint_editor_settings.cpp +++ b/pcbnew/footprint_editor_settings.cpp @@ -82,9 +82,13 @@ FOOTPRINT_EDITOR_SETTINGS::FOOTPRINT_EDITOR_SETTINGS() : m_params.emplace_back( new PARAM( "editing.magnetic_graphics", &m_MagneticItems.graphics, true ) ); - m_params.emplace_back( new PARAM( "editing.polar_coords", &m_PolarCoords, false ) ); + m_params.emplace_back( new PARAM( "editing.polar_coords", + &m_PolarCoords, false ) ); - m_params.emplace_back( new PARAM( "editing.use_45_degree_limit", + m_params.emplace_back( new PARAM( "editing.rotation_angle", + &m_RotationAngle, 900, 1, 900 ) ); + + m_params.emplace_back( new PARAM( "editing.fp_use_45_degree_limit", &m_Use45Limit, false ) ); m_params.emplace_back( new PARAM( "pcb_display.text_fill", diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 2837b49bc8..470af6c83b 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -824,6 +824,8 @@ void FOOTPRINT_VIEWER_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool a { PCB_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged ); + GetCanvas()->ForceRefresh(); + if( aEnvVarsChanged ) ReCreateLibraryList(); } diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 9eaabbc5d1..41391c91d8 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -135,6 +135,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent PCB_DISPLAY_OPTIONS disp_opts = GetDisplayOptions(); disp_opts.m_DisplayPadClearance = true; + disp_opts.m_DisplayPadNoConnects = false; disp_opts.m_DisplayPadNum = true; SetDisplayOptions( disp_opts ); diff --git a/pcbnew/grid_layer_box_helpers.cpp b/pcbnew/grid_layer_box_helpers.cpp index e09f8807d9..51ffeeb87e 100644 --- a/pcbnew/grid_layer_box_helpers.cpp +++ b/pcbnew/grid_layer_box_helpers.cpp @@ -22,11 +22,15 @@ */ #include - +#include +#include +#include +#include #include #include #include #include +#include #include @@ -47,7 +51,8 @@ GRID_CELL_LAYER_RENDERER::~GRID_CELL_LAYER_RENDERER() void GRID_CELL_LAYER_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& aDC, const wxRect& aRect, int aRow, int aCol, bool isSelected ) { - int value = aGrid.GetTable()->GetValueAsLong( aRow, aCol ); + int value = aGrid.GetTable()->GetValueAsLong( aRow, aCol ); + COLOR_SETTINGS* cs = nullptr; wxRect rect = aRect; rect.Inflate( -1 ); @@ -55,19 +60,36 @@ void GRID_CELL_LAYER_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& // erase background wxGridCellRenderer::Draw( aGrid, aAttr, aDC, aRect, aRow, aCol, isSelected ); + if( m_frame ) + { + cs = m_frame->GetColorSettings(); + } + else + { + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + FOOTPRINT_EDITOR_SETTINGS* settings = mgr.GetAppSettings(); + cs = mgr.GetColorSettings( settings->m_ColorTheme ); + } + // draw the swatch wxBitmap bitmap( 14, 14 ); - COLOR_SETTINGS* cs = m_frame->GetColorSettings(); LAYER_SELECTOR::DrawColorSwatch( bitmap, cs->GetColor( ToLAYER_ID( LAYER_PCB_BACKGROUND ) ), cs->GetColor( ToLAYER_ID( value ) ) ); aDC.DrawBitmap( bitmap, rect.GetLeft() + 4, rect.GetTop() + 3, true ); // draw the text - wxString text = m_frame->GetBoard()->GetLayerName( ToLAYER_ID( value ) ); + PCB_LAYER_ID layer = ToLAYER_ID( value ); + wxString layerName; + + if( m_frame ) + layerName = m_frame->GetBoard()->GetLayerName( layer ); + else + layerName = BOARD::GetStandardLayerName( layer ); + rect.SetLeft( rect.GetLeft() + bitmap.GetWidth() + 8 ); SetTextColoursAndFont( aGrid, aAttr, aDC, isSelected ); - aGrid.DrawTextRectangle( aDC, text, rect, wxALIGN_LEFT, wxALIGN_CENTRE ); + aGrid.DrawTextRectangle( aDC, layerName, rect, wxALIGN_LEFT, wxALIGN_CENTRE ); } @@ -78,7 +100,9 @@ void GRID_CELL_LAYER_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, wxDC& GRID_CELL_LAYER_SELECTOR::GRID_CELL_LAYER_SELECTOR( PCB_BASE_FRAME* aFrame, LSET aMask ) : - m_frame( aFrame ), m_mask( aMask ), m_value( 0 ) + m_frame( aFrame ), + m_mask( aMask ), + m_value( 0 ) { } @@ -106,7 +130,14 @@ void GRID_CELL_LAYER_SELECTOR::Create( wxWindow* aParent, wxWindowID aId, wxString GRID_CELL_LAYER_SELECTOR::GetValue() const { if( LayerBox()->GetLayerSelection() != UNDEFINED_LAYER ) - return m_frame->GetBoard()->GetLayerName( ToLAYER_ID( LayerBox()->GetLayerSelection() ) ); + { + PCB_LAYER_ID layer = ToLAYER_ID( LayerBox()->GetLayerSelection() ); + + if( m_frame ) + return m_frame->GetBoard()->GetLayerName( layer ); + else + return BOARD::GetStandardLayerName( layer ); + } return wxEmptyString; } @@ -145,10 +176,10 @@ void GRID_CELL_LAYER_SELECTOR::BeginEdit( int aRow, int aCol, wxGrid* aGrid ) // Footprints are defined in a global context and may contain layers not enabled // on the current board. Check and display all layers if so. - bool currentLayerEnabled = m_frame->GetBoard()->IsLayerEnabled( ToLAYER_ID( m_value ) ); - LayerBox()->ShowNonActivatedLayers( !currentLayerEnabled ); - LayerBox()->Resync(); + if( m_frame && !m_frame->GetBoard()->IsLayerEnabled( ToLAYER_ID( m_value ) ) ) + LayerBox()->ShowNonActivatedLayers( true ); + LayerBox()->Resync(); LayerBox()->SetLayerSelection( m_value ); LayerBox()->SetFocus(); diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 44be182b80..c229392b02 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -59,6 +59,8 @@ #include "cleanup_item.h" #include +using KIGFX::RENDER_SETTINGS; +using KIGFX::PCB_RENDER_SETTINGS; wxDEFINE_EVENT( BOARD_CHANGED, wxCommandEvent ); @@ -842,7 +844,11 @@ void PCB_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars { EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged ); - GetCanvas()->GetView()->GetPainter()->GetSettings()->LoadColors( GetColorSettings() ); + RENDER_SETTINGS* settings = GetCanvas()->GetView()->GetPainter()->GetSettings(); + PCB_RENDER_SETTINGS* renderSettings = static_cast( settings ); + + renderSettings->LoadColors( GetColorSettings() ); + renderSettings->LoadDisplayOptions( GetDisplayOptions(), ShowPageLimits() ); GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR ); RecreateToolbars(); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index e3f4fad9be..8aae8a4db4 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1725,7 +1725,17 @@ void PCB_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars GetAppearancePanel()->OnColorThemeChanged(); - // Netclass definitions could have changed, either by us or by Eeschema + auto* painter = static_cast( GetCanvas()->GetView()->GetPainter() ); + auto* renderSettings = painter->GetSettings(); + renderSettings->LoadDisplayOptions( GetDisplayOptions(), ShowPageLimits() ); + SetElementVisibility( LAYER_NO_CONNECTS, GetDisplayOptions().m_DisplayPadNoConnects ); + SetElementVisibility( LAYER_RATSNEST, GetDisplayOptions().m_ShowGlobalRatsnest ); + + auto cfg = Pgm().GetSettingsManager().GetAppSettings(); + GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window ); + + // Netclass definitions could have changed, either by us or by Eeschema, so we need to + // recompile the implicit rules DRC_TOOL* drcTool = m_toolManager->GetTool(); WX_INFOBAR* infobar = GetInfoBar(); @@ -1754,6 +1764,15 @@ void PCB_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars WX_INFOBAR::MESSAGE_TYPE::DRC_RULES_ERROR ); } + GetCanvas()->GetView()->UpdateAllItemsConditionally( KIGFX::REPAINT, + []( KIGFX::VIEW_ITEM* aItem ) -> bool + { + return dynamic_cast( aItem ); + } ); + + GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); + GetCanvas()->ForceRefresh(); + // Update the environment variables in the Python interpreter if( aEnvVarsChanged ) PythonSyncEnvironmentVariables(); diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 3ac8e11e0c..c9b4ee29e3 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -163,20 +163,17 @@ public: */ void SetGridColor( const COLOR4D& aColor ) override; - // Configurations: - void Process_Config( wxCommandEvent& event ); - /** * Return true if button visibility action plugin setting was set to true * or it is unset and plugin defaults to true. */ - bool GetActionPluginButtonVisible( const wxString& aPluginPath, bool aPluginDefault ); + static bool GetActionPluginButtonVisible( const wxString& aPluginPath, bool aPluginDefault ); /** * Return ordered list of plugins in sequence in which they should appear on toolbar or * in settings */ - std::vector GetOrderedActionPlugins(); + static std::vector GetOrderedActionPlugins(); /** * Save changes to the project settings to the project (.pro) file. @@ -641,11 +638,6 @@ public: */ void UpdateTitle(); - /** - * Allow Pcbnew to install its preferences panel into the preferences dialog. - */ - void InstallPreferences( PAGED_DIALOG* aParent, PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) override; - /** * Called after the preferences dialog is run. */ diff --git a/pcbnew/pcb_layer_box_selector.cpp b/pcbnew/pcb_layer_box_selector.cpp index 321a2e52f3..77633c8375 100644 --- a/pcbnew/pcb_layer_box_selector.cpp +++ b/pcbnew/pcb_layer_box_selector.cpp @@ -22,14 +22,18 @@ * 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 - #include #include #include + // translate aLayer to its action static TOOL_ACTION* layer2action( PCB_LAYER_ID aLayer ) { @@ -136,33 +140,44 @@ void PCB_LAYER_BOX_SELECTOR::Resync() // Returns true if the layer id is enabled (i.e. is it should be displayed) bool PCB_LAYER_BOX_SELECTOR::isLayerEnabled( int aLayer ) const { - BOARD* board = m_boardFrame->GetBoard(); - - return board->IsLayerEnabled( ToLAYER_ID( aLayer ) ); + return getEnabledLayers().test( aLayer ); } LSET PCB_LAYER_BOX_SELECTOR::getEnabledLayers() const { - BOARD* board = m_boardFrame->GetBoard(); + static LSET footprintEditorLayers = LSET::AllLayersMask() & ~LSET::ForbiddenFootprintLayers(); - return board->GetEnabledLayers(); + if( m_boardFrame ) + return m_boardFrame->GetBoard()->GetEnabledLayers(); + else + return footprintEditorLayers; } // Returns a color index from the layer id COLOR4D PCB_LAYER_BOX_SELECTOR::getLayerColor( int aLayer ) const { - wxASSERT( m_boardFrame ); + if( m_boardFrame ) + { + return m_boardFrame->GetColorSettings()->GetColor( aLayer ); + } + else + { + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + FOOTPRINT_EDITOR_SETTINGS* settings = mgr.GetAppSettings(); + COLOR_SETTINGS* current = mgr.GetColorSettings( settings->m_ColorTheme ); - return m_boardFrame->GetColorSettings()->GetColor( aLayer ); + return current->GetColor( aLayer ); + } } // Returns the name of the layer id wxString PCB_LAYER_BOX_SELECTOR::getLayerName( int aLayer ) const { - BOARD* board = m_boardFrame->GetBoard(); - - return board->GetLayerName( ToLAYER_ID( aLayer ) ); + if( m_boardFrame ) + return m_boardFrame->GetBoard()->GetLayerName( ToLAYER_ID( aLayer ) ); + else + return BOARD::GetStandardLayerName( ToLAYER_ID( aLayer ) ); } diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 8a0daeb964..8270bafd3e 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -49,10 +50,21 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include "invoke_pcb_dialog.h" -#include "dialog_global_fp_lib_table_config.h" #include @@ -130,6 +142,87 @@ static struct IFACE : public KIFACE_BASE // Dialog has completed; nothing to return. return nullptr; + case PANEL_FP_DISPLAY_OPTIONS: + { + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + APP_SETTINGS_BASE* cfg = mgr.GetAppSettings(); + + return new PANEL_DISPLAY_OPTIONS( aParent, cfg ); + } + + case PANEL_FP_EDIT_OPTIONS: + return new PANEL_EDIT_OPTIONS( aParent, true ); + + case PANEL_FP_DEFAULT_VALUES: + { + EDA_BASE_FRAME* unitsProvider = aKiway->Player( FRAME_FOOTPRINT_EDITOR, false ); + + if( !unitsProvider ) + unitsProvider = aKiway->Player( FRAME_FOOTPRINT_VIEWER, false ); + + if( !unitsProvider ) + unitsProvider = aKiway->Player( FRAME_PCB_EDITOR, false ); + + if( !unitsProvider ) + { + // If we can't find an eeschema frame we'll have to make do with the units + // defined in whatever FRAME we _can_ find. + for( unsigned i = 0; !unitsProvider && i < KIWAY_PLAYER_COUNT; ++i ) + unitsProvider = aKiway->Player( (FRAME_T) i, false ); + } + + if( !unitsProvider ) + { + wxWindow* manager = wxFindWindowByName( KICAD_MANAGER_FRAME_NAME ); + unitsProvider = static_cast( manager ); + } + + return new PANEL_FP_EDITOR_DEFAULTS( aParent, unitsProvider ); + } + + case PANEL_FP_COLORS: + return new PANEL_FP_EDITOR_COLOR_SETTINGS( aParent ); + + case PANEL_PCB_DISPLAY_OPTIONS: + { + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + APP_SETTINGS_BASE* cfg = mgr.GetAppSettings(); + + return new PANEL_DISPLAY_OPTIONS( aParent, cfg ); + } + + case PANEL_PCB_EDIT_OPTIONS: + return new PANEL_EDIT_OPTIONS( aParent, false ); + + case PANEL_PCB_COLORS: + { + BOARD* board = nullptr; + EDA_BASE_FRAME* boardProvider = aKiway->Player( FRAME_PCB_EDITOR, false ); + + if( boardProvider ) + board = static_cast( boardProvider )->GetBoard(); + + return new PANEL_PCBNEW_COLOR_SETTINGS( aParent, board ); + } + + case PANEL_PCB_ACTION_PLUGINS: + return new PANEL_PCBNEW_ACTION_PLUGINS( aParent ); + + case PANEL_PCB_ORIGINS_AXES: + return new PANEL_PCBNEW_DISPLAY_ORIGIN( aParent ); + + case PANEL_3DV_DISPLAY_OPTIONS: + return new PANEL_3D_DISPLAY_OPTIONS( aParent ); + + case PANEL_3DV_OPENGL: + return new PANEL_3D_OPENGL_OPTIONS( aParent ); + + case PANEL_3DV_RAYTRACING: + return new PANEL_3D_RAYTRACING_OPTIONS( aParent ); + + case PANEL_3DV_COLORS: + return new PANEL_3D_COLORS( aParent ); + default: return nullptr; } diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index e31a38cd67..ceb5056f84 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -25,12 +25,6 @@ */ #include -#include -#include -#include -#include -#include -#include #include #include #include @@ -44,26 +38,9 @@ #include #include #include -#include -void PCB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent, - PANEL_HOTKEYS_EDITOR* aHotkeysPanel ) -{ - wxTreebook* book = aParent->GetTreebook(); - - book->AddPage( new wxPanel( book ), _( "PCB Editor" ) ); - book->AddSubPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) ); - book->AddSubPage( new PANEL_EDIT_OPTIONS( this, aParent ), _( "Editing Options" ) ); - book->AddSubPage( new PANEL_PCBNEW_COLOR_SETTINGS( this, book ), _( "Colors" ) ); - book->AddSubPage( new PANEL_PCBNEW_ACTION_PLUGINS( this, aParent ), _( "Action Plugins" ) ); - book->AddSubPage( new PANEL_PCBNEW_DISPLAY_ORIGIN( this, aParent ), _( "Origins & Axes" ) ); - - aHotkeysPanel->AddHotKeys( GetToolManager() ); -} - - bool PCB_EDIT_FRAME::LoadProjectSettings() { PROJECT_FILE& project = Prj().GetProjectFile(); diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index d093fd5c9e..6d931b4f84 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -67,8 +67,7 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_FootprintWizard(), m_Display(), m_TrackDragAction( TRACK_DRAG_ACTION::DRAG ), - m_PcbUse45DegreeLimit( false ), - m_FpeditUse45DegreeLimit( false ), + m_Use45DegreeLimit( false ), m_FlipLeftRight( false ), m_PolarCoords( false ), m_RotationAngle( 900 ), @@ -125,10 +124,7 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() static_cast( TRACK_DRAG_ACTION::DRAG ) ) ); m_params.emplace_back( new PARAM( "editing.pcb_use_45_degree_limit", - &m_PcbUse45DegreeLimit, false ) ); - - m_params.emplace_back( new PARAM( "editing.fp_use_45_degree_limit", - &m_FpeditUse45DegreeLimit, false ) ); + &m_Use45DegreeLimit, false ) ); m_params.emplace_back( new PARAM( "editing.auto_fill_zones", &m_AutoRefillZones, true ) ); diff --git a/pcbnew/pcbnew_settings.h b/pcbnew/pcbnew_settings.h index 159f619d61..2efbcd63dc 100644 --- a/pcbnew/pcbnew_settings.h +++ b/pcbnew/pcbnew_settings.h @@ -275,12 +275,9 @@ public: TRACK_DRAG_ACTION m_TrackDragAction; - bool m_PcbUse45DegreeLimit; // True to constrain tool actions to horizontal, - // vertical and 45deg in board editor - bool m_FpeditUse45DegreeLimit; // True to constrain tool actions to horizontal, - // vertical and 45deg in footprint editor + bool m_Use45DegreeLimit; // True to constrain tool actions to horizontal, + // vertical and 45deg bool m_FlipLeftRight; // True: Flip footprints across Y axis - // False: Flip footprints across X axis bool m_PolarCoords; diff --git a/pcbnew/python/scripting/pcb_scripting_tool.cpp b/pcbnew/python/scripting/pcb_scripting_tool.cpp index 5b47c5d371..3d422b97a9 100644 --- a/pcbnew/python/scripting/pcb_scripting_tool.cpp +++ b/pcbnew/python/scripting/pcb_scripting_tool.cpp @@ -24,7 +24,6 @@ #include "pcb_scripting_tool.h" #include -#include #include #include #include @@ -75,12 +74,22 @@ bool SCRIPTING_TOOL::Init() } +void SCRIPTING_TOOL::ReloadPlugins() +{ + // Reload Python plugins if they are newer than the already loaded, and load new plugins + // Remove all action plugins so that we don't keep references to old versions + ACTION_PLUGINS::UnloadAll(); + + PyLOCK lock; + callLoadPlugins(); +} + + int SCRIPTING_TOOL::reloadPlugins( const TOOL_EVENT& aEvent ) { - if( !m_isFootprintEditor ) - // Reload Python plugins if they are newer than the already loaded, and load new plugins - // Remove all action plugins so that we don't keep references to old versions - ACTION_PLUGINS::UnloadAll(); + // Reload Python plugins if they are newer than the already loaded, and load new plugins + // Remove all action plugins so that we don't keep references to old versions + ACTION_PLUGINS::UnloadAll(); { PyLOCK lock; @@ -121,18 +130,22 @@ pcbnew.LoadPlugins( sys_path, user_path, third_party_path ) } -int SCRIPTING_TOOL::showPluginFolder( const TOOL_EVENT& aEvent ) +void SCRIPTING_TOOL::ShowPluginFolder() { wxString pluginpath( SCRIPTING::PyPluginsPath( SCRIPTING::PATH_TYPE::USER ) ); LaunchExternal( pluginpath ); +} + +int SCRIPTING_TOOL::showPluginFolder( const TOOL_EVENT& aEvent ) +{ + ShowPluginFolder(); return 0; } void SCRIPTING_TOOL::setTransitions() { - Go( &SCRIPTING_TOOL::reloadPlugins, PCB_ACTIONS::pluginsReload.MakeEvent() ); Go( &SCRIPTING_TOOL::showPluginFolder, PCB_ACTIONS::pluginsShowFolder.MakeEvent() ); } diff --git a/pcbnew/python/scripting/pcb_scripting_tool.h b/pcbnew/python/scripting/pcb_scripting_tool.h index b97d01dc17..a5007f80e0 100644 --- a/pcbnew/python/scripting/pcb_scripting_tool.h +++ b/pcbnew/python/scripting/pcb_scripting_tool.h @@ -44,6 +44,9 @@ public: ///< Basic initialization bool Init() override; + static void ReloadPlugins(); + static void ShowPluginFolder(); + private: ///< Reload Python plugins and reset toolbar (if in pcbnew) @@ -51,7 +54,7 @@ private: ///< Call LoadPlugins method of the scripting module with apropriate paths ///< Must be called under PyLOCK - void callLoadPlugins(); + static void callLoadPlugins(); ///< Open the user's plugin folder in the system browser int showPluginFolder( const TOOL_EVENT& aEvent ); diff --git a/pcbnew/python/scripting/pcbnew_action_plugins.cpp b/pcbnew/python/scripting/pcbnew_action_plugins.cpp index 087fd266e0..f4c5bc9e8d 100644 --- a/pcbnew/python/scripting/pcbnew_action_plugins.cpp +++ b/pcbnew/python/scripting/pcbnew_action_plugins.cpp @@ -22,6 +22,9 @@ */ #include "pcbnew_action_plugins.h" +#include +#include +#include #include #include #include @@ -432,6 +435,8 @@ void PCB_EDIT_FRAME::AddActionPluginTools() std::vector PCB_EDIT_FRAME::GetOrderedActionPlugins() { + PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); + std::vector plugins; std::vector orderedPlugins; @@ -439,7 +444,7 @@ std::vector PCB_EDIT_FRAME::GetOrderedActionPlugins() plugins.push_back( ACTION_PLUGINS::GetAction( i ) ); // First add plugins that have entries in settings - for( const auto& pair : m_settings->m_VisibleActionPlugins ) + for( const auto& pair : cfg->m_VisibleActionPlugins ) { auto loc = std::find_if( plugins.begin(), plugins.end(), [pair] ( ACTION_PLUGIN* plugin ) @@ -465,9 +470,9 @@ std::vector PCB_EDIT_FRAME::GetOrderedActionPlugins() bool PCB_EDIT_FRAME::GetActionPluginButtonVisible( const wxString& aPluginPath, bool aPluginDefault ) { - auto& settings = m_settings->m_VisibleActionPlugins; + PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); - for( const auto& entry : settings ) + for( const auto& entry : cfg->m_VisibleActionPlugins ) { if( entry.first == aPluginPath ) return entry.second; diff --git a/pcbnew/python/scripting/pcbnew_scripting.cpp b/pcbnew/python/scripting/pcbnew_scripting.cpp index 99c0a0ceeb..31fed409fe 100644 --- a/pcbnew/python/scripting/pcbnew_scripting.cpp +++ b/pcbnew/python/scripting/pcbnew_scripting.cpp @@ -112,7 +112,12 @@ static void pcbnewRunPythonMethodWithReturnedString( const char* aMethodName, wx Py_DECREF( localDict ); if( PyErr_Occurred() ) - wxLogMessage( PyErrStringWithTraceback() ); + { + if( strcmp( aMethodName, "pcbnew.GetWizardsBackTrace" ) == 0 ) + aNames = PyErrStringWithTraceback(); + else + wxLogMessage( PyErrStringWithTraceback() ); + } } diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 9e965fd4f7..e45e34fd9f 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -27,6 +27,8 @@ #include #include +#include +#include #include #include #include @@ -255,12 +257,13 @@ void DRAWING_TOOL::updateStatusBar() const { if( m_frame ) { - bool constrained; + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + bool constrained; if( m_frame->IsType( FRAME_PCB_EDITOR ) ) - constrained = m_frame->Settings().m_PcbUse45DegreeLimit; + constrained = mgr.GetAppSettings()->m_Use45DegreeLimit; else - constrained = m_frame->Settings().m_FpeditUse45DegreeLimit; + constrained = mgr.GetAppSettings()->m_Use45Limit; m_frame->DisplayConstraintsMsg( constrained ? _( "Constrain to H, V, 45" ) : wxString( "" ) ); @@ -1396,14 +1399,20 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent ) int DRAWING_TOOL::ToggleLine45degMode( const TOOL_EVENT& toolEvent ) { - if( m_frame->IsType( FRAME_PCB_EDITOR ) ) - m_frame->Settings().m_PcbUse45DegreeLimit = !m_frame->Settings().m_PcbUse45DegreeLimit; +#define TOGGLE( a ) a = !a + + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + + if( frame()->IsType( FRAME_PCB_EDITOR ) ) + TOGGLE( mgr.GetAppSettings()->m_Use45DegreeLimit ); else - m_frame->Settings().m_FpeditUse45DegreeLimit = !m_frame->Settings().m_FpeditUse45DegreeLimit; + TOGGLE( mgr.GetAppSettings()->m_Use45Limit ); updateStatusBar(); return 0; + +#undef TOGGLE } diff --git a/pcbnew/tools/pcb_editor_conditions.cpp b/pcbnew/tools/pcb_editor_conditions.cpp index 38a539a862..d1a364cedf 100644 --- a/pcbnew/tools/pcb_editor_conditions.cpp +++ b/pcbnew/tools/pcb_editor_conditions.cpp @@ -23,7 +23,10 @@ */ -#include "pcbnew_settings.h" +#include +#include +#include +#include #include #include #include @@ -185,8 +188,10 @@ bool PCB_EDITOR_CONDITIONS::zoneDisplayModeFunc( const SELECTION& aSelection, PC bool PCB_EDITOR_CONDITIONS::get45degModeFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame ) { + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + if( aFrame->IsType( FRAME_PCB_EDITOR ) ) - return aFrame->Settings().m_PcbUse45DegreeLimit; + return mgr.GetAppSettings()->m_Use45DegreeLimit; else - return aFrame->Settings().m_FpeditUse45DegreeLimit; + return mgr.GetAppSettings()->m_Use45Limit; } diff --git a/pcbnew/tools/pcb_tool_base.cpp b/pcbnew/tools/pcb_tool_base.cpp index 05bba6da47..eb6e10035d 100644 --- a/pcbnew/tools/pcb_tool_base.cpp +++ b/pcbnew/tools/pcb_tool_base.cpp @@ -27,8 +27,10 @@ #include #include #include +#include +#include #include - +#include #include #include #include @@ -322,10 +324,12 @@ PCB_SELECTION& PCB_TOOL_BASE::selection() bool PCB_TOOL_BASE::Is45Limited() const { + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + if( frame()->IsType( FRAME_PCB_EDITOR ) ) - return frame()->Settings().m_PcbUse45DegreeLimit; + return mgr.GetAppSettings()->m_Use45DegreeLimit; else - return frame()->Settings().m_FpeditUse45DegreeLimit; + return mgr.GetAppSettings()->m_Use45Limit; } diff --git a/pcbnew/tools/pcb_viewer_tools.cpp b/pcbnew/tools/pcb_viewer_tools.cpp index a04a46d989..7bb0bb6d2a 100644 --- a/pcbnew/tools/pcb_viewer_tools.cpp +++ b/pcbnew/tools/pcb_viewer_tools.cpp @@ -21,10 +21,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include +#include +#include +#include #include <3d_viewer/eda_3d_viewer_frame.h> #include #include -#include #include #include #include @@ -295,10 +298,13 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent ) // move or drag when origin set updates rules else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) ) { - bool force45Deg = frame()->Settings().m_PcbUse45DegreeLimit; + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + bool force45Deg; - if( !frame()->IsType( FRAME_PCB_EDITOR ) ) - force45Deg = frame()->Settings().m_FpeditUse45DegreeLimit; + if( frame()->IsType( FRAME_PCB_EDITOR ) ) + force45Deg = mgr.GetAppSettings()->m_Use45DegreeLimit; + else + force45Deg = mgr.GetAppSettings()->m_Use45Limit; twoPtMgr.SetAngleSnap( force45Deg ); twoPtMgr.SetEnd( cursorPos );