From 70fb5cac9618b9c76fcccd6c044c1290fcd2cf9f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 23 May 2020 00:11:04 +0100 Subject: [PATCH] Flatten one level of showElectricalTypes settings. --- eeschema/dialogs/panel_libedit_settings.cpp | 6 ++---- eeschema/dialogs/panel_libedit_settings_base.cpp | 4 ++-- eeschema/dialogs/panel_libedit_settings_base.fbp | 2 +- eeschema/dialogs/panel_libedit_settings_base.h | 2 +- eeschema/lib_view_frame.cpp | 12 ++++-------- eeschema/libedit/lib_edit_frame.cpp | 6 ++---- eeschema/libedit/toolbars_libedit.cpp | 8 +++++--- eeschema/sch_base_frame.cpp | 1 - eeschema/sch_base_frame.h | 8 -------- eeschema/toolbars_lib_view.cpp | 4 ++-- eeschema/tools/lib_control.cpp | 5 ++--- 11 files changed, 21 insertions(+), 37 deletions(-) diff --git a/eeschema/dialogs/panel_libedit_settings.cpp b/eeschema/dialogs/panel_libedit_settings.cpp index 0f0d7a51cc..2e771c8a85 100644 --- a/eeschema/dialogs/panel_libedit_settings.cpp +++ b/eeschema/dialogs/panel_libedit_settings.cpp @@ -59,7 +59,7 @@ bool PANEL_LIBEDIT_SETTINGS::TransferDataToWindow() m_choicePinDisplacement->SetSelection( settings->m_Repeat.pin_step == 50 ? 1 : 0 ); m_spinRepeatLabel->SetValue( settings->m_Repeat.label_delta ); - m_checkShowPinElectricalType->SetValue( m_frame->GetShowElectricalType() ); + m_cbShowPinElectricalType->SetValue( m_frame->GetRenderSettings()->m_ShowPinsElectricalType ); return true; } @@ -79,9 +79,7 @@ bool PANEL_LIBEDIT_SETTINGS::TransferDataFromWindow() settings->m_Repeat.label_delta = m_spinRepeatLabel->GetValue(); settings->m_Repeat.pin_step = m_choicePinDisplacement->GetSelection() == 1 ? 50 : 100; - m_frame->SetShowElectricalType( m_checkShowPinElectricalType->GetValue() ); - - m_frame->GetRenderSettings()->m_ShowPinsElectricalType = m_frame->GetShowElectricalType(); + m_frame->GetRenderSettings()->m_ShowPinsElectricalType = m_cbShowPinElectricalType->GetValue(); m_frame->GetCanvas()->Refresh(); return true; diff --git a/eeschema/dialogs/panel_libedit_settings_base.cpp b/eeschema/dialogs/panel_libedit_settings_base.cpp index 7c11153dbc..f2726e80a8 100644 --- a/eeschema/dialogs/panel_libedit_settings_base.cpp +++ b/eeschema/dialogs/panel_libedit_settings_base.cpp @@ -93,8 +93,8 @@ PANEL_LIBEDIT_SETTINGS_BASE::PANEL_LIBEDIT_SETTINGS_BASE( wxWindow* parent, wxWi defaults->Add( fgSizer, 0, wxBOTTOM|wxEXPAND, 5 ); - m_checkShowPinElectricalType = new wxCheckBox( defaults->GetStaticBox(), wxID_ANY, _("Show pin &electrical type"), wxDefaultPosition, wxDefaultSize, 0 ); - defaults->Add( m_checkShowPinElectricalType, 0, wxBOTTOM, 5 ); + m_cbShowPinElectricalType = new wxCheckBox( defaults->GetStaticBox(), wxID_ANY, _( "Show pin &electrical type"), wxDefaultPosition, wxDefaultSize, 0 ); + defaults->Add( m_cbShowPinElectricalType, 0, wxBOTTOM, 5 ); leftColumn->Add( defaults, 0, wxEXPAND|wxALL, 5 ); diff --git a/eeschema/dialogs/panel_libedit_settings_base.fbp b/eeschema/dialogs/panel_libedit_settings_base.fbp index 28281e763d..950669b2fd 100644 --- a/eeschema/dialogs/panel_libedit_settings_base.fbp +++ b/eeschema/dialogs/panel_libedit_settings_base.fbp @@ -1094,7 +1094,7 @@ 0 1 - m_checkShowPinElectricalType + m_cbShowPinElectricalType 1 diff --git a/eeschema/dialogs/panel_libedit_settings_base.h b/eeschema/dialogs/panel_libedit_settings_base.h index ddaf36ee17..a0e4d4d003 100644 --- a/eeschema/dialogs/panel_libedit_settings_base.h +++ b/eeschema/dialogs/panel_libedit_settings_base.h @@ -50,7 +50,7 @@ class PANEL_LIBEDIT_SETTINGS_BASE : public wxPanel wxStaticText* m_pinNameSizeLabel; wxTextCtrl* m_pinNameSizeCtrl; wxStaticText* m_pinNameSizeUnits; - wxCheckBox* m_checkShowPinElectricalType; + wxCheckBox* m_cbShowPinElectricalType; wxStaticText* m_hPitchLabel; wxTextCtrl* m_hPitchCtrl; wxStaticText* m_hPitchUnits; diff --git a/eeschema/lib_view_frame.cpp b/eeschema/lib_view_frame.cpp index 5ae87c9c3a..ffa42033b3 100644 --- a/eeschema/lib_view_frame.cpp +++ b/eeschema/lib_view_frame.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -37,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -134,15 +132,12 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame GetScreen()->m_Center = true; // Axis origin centered on screen. LoadSettings( config() ); - // Synchronize some draw options - SetShowElectricalType( true ); // Ensure axis are always drawn (initial default display was not drawn) KIGFX::GAL_DISPLAY_OPTIONS& gal_opts = GetGalDisplayOptions(); gal_opts.m_axesEnabled = true; GetCanvas()->GetGAL()->SetAxesEnabled( true ); GetCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() ); - GetRenderSettings()->m_ShowPinsElectricalType = GetShowElectricalType(); GetRenderSettings()->m_ShowHiddenText = true; GetRenderSettings()->m_ShowHiddenPins = true; GetRenderSettings()->SetDefaultPenWidth( DEFAULT_LINE_THICKNESS * IU_PER_MILS ); @@ -629,7 +624,8 @@ void LIB_VIEW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) m_libListWidth = cfg->m_LibViewPanel.lib_list_width; m_cmpListWidth = cfg->m_LibViewPanel.cmp_list_width; - m_showPinElectricalTypeName = cfg->m_LibViewPanel.show_pin_electrical_type; + + GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_LibViewPanel.show_pin_electrical_type; // Set parameters to a reasonable value. if( m_libListWidth > m_FrameSize.x/2 ) @@ -642,7 +638,7 @@ void LIB_VIEW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) void LIB_VIEW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg) { - auto cfg = Pgm().GetSettingsManager().GetAppSettings(); + EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); EDA_DRAW_FRAME::SaveSettings( cfg ); @@ -653,7 +649,7 @@ void LIB_VIEW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg) cfg->m_LibViewPanel.lib_list_width = m_libListWidth; cfg->m_LibViewPanel.cmp_list_width = m_cmpListWidth; - cfg->m_LibViewPanel.show_pin_electrical_type = m_showPinElectricalTypeName; + cfg->m_LibViewPanel.show_pin_electrical_type = GetRenderSettings()->m_ShowPinsElectricalType; } diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index bdc055bfa1..e0fcf86042 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -101,7 +101,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_DrawSpecificConvert = true; m_DrawSpecificUnit = false; m_SyncPinEdit = false; - SetShowElectricalType( true ); m_my_part = nullptr; m_treePane = nullptr; @@ -228,9 +227,8 @@ void LIB_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) SetDefaultLineWidth( Mils2iu( m_settings->m_Defaults.line_width ) ); SetDefaultTextSize( Mils2iu( m_settings->m_Defaults.text_size ) ); - m_showPinElectricalTypeName = m_settings->m_ShowPinElectricalType; - GetRenderSettings()->m_ShowPinsElectricalType = GetShowElectricalType(); + GetRenderSettings()->m_ShowPinsElectricalType = m_settings->m_ShowPinElectricalType; // Hidden elements must be editable GetRenderSettings()->m_ShowHiddenText = true; @@ -247,7 +245,7 @@ void LIB_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) m_settings->m_Defaults.line_width = Iu2Mils( GetDefaultLineWidth() ); m_settings->m_Defaults.text_size = Iu2Mils( GetDefaultTextSize() ); - m_settings->m_ShowPinElectricalType = GetShowElectricalType(); + m_settings->m_ShowPinElectricalType = GetRenderSettings()->m_ShowPinsElectricalType; m_settings->m_LibWidth = m_treePane->GetSize().x; } diff --git a/eeschema/libedit/toolbars_libedit.cpp b/eeschema/libedit/toolbars_libedit.cpp index 199b542dce..59520a8ece 100644 --- a/eeschema/libedit/toolbars_libedit.cpp +++ b/eeschema/libedit/toolbars_libedit.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -151,6 +152,7 @@ void LIB_EDIT_FRAME::ReCreateOptToolbar() void LIB_EDIT_FRAME::SyncToolbars() { + KIGFX::SCH_RENDER_SETTINGS* settings = GetRenderSettings(); KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions(); bool isEditable = m_my_part && m_my_part->IsRoot(); @@ -173,10 +175,10 @@ void LIB_EDIT_FRAME::SyncToolbars() m_mainToolBar->Refresh(); m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() ); - m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != EDA_UNITS::INCHES ); - m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == EDA_UNITS::INCHES ); + m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != EDA_UNITS::INCHES ); + m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == EDA_UNITS::INCHES ); m_optionsToolBar->Toggle( ACTIONS::toggleCursorStyle, galOpts.m_fullscreenCursor ); - m_optionsToolBar->Toggle( EE_ACTIONS::showElectricalTypes, GetShowElectricalType() ); + m_optionsToolBar->Toggle( EE_ACTIONS::showElectricalTypes, settings->m_ShowPinsElectricalType ); m_optionsToolBar->Toggle( EE_ACTIONS::showComponentTree, IsSearchTreeShown() ); m_optionsToolBar->Refresh(); diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 75fe20b78e..e0639652d5 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -84,7 +84,6 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aWindo const wxString& aTitle, const wxPoint& aPosition, const wxSize& aSize, long aStyle, const wxString& aFrameName ) : EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition, aSize, aStyle, aFrameName ), - m_showPinElectricalTypeName( false ), m_defaults( &m_base_frame_defaults ) { createCanvas(); diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h index 8617a6382d..a1ae3f2b4f 100644 --- a/eeschema/sch_base_frame.h +++ b/eeschema/sch_base_frame.h @@ -92,8 +92,6 @@ class SCH_BASE_FRAME : public EDA_DRAW_FRAME protected: TEMPLATES m_templateFieldNames; - bool m_showPinElectricalTypeName; - /// These are only used by libedit. Eeschema should be using the one inside the SCHEMATIC. SCHEMATIC_SETTINGS m_base_frame_defaults; @@ -133,12 +131,6 @@ public: */ virtual bool GetShowAllPins() const { return true; } - /** - * Allow some frames to show/hide pin electrical type names. - */ - bool GetShowElectricalType() { return m_showPinElectricalTypeName; } - void SetShowElectricalType( bool aShow ) { m_showPinElectricalTypeName = aShow; } - virtual int GetDefaultLineWidth() const { return m_defaults->m_DefaultLineWidth; } virtual void SetDefaultLineWidth( int aWidth ); diff --git a/eeschema/toolbars_lib_view.cpp b/eeschema/toolbars_lib_view.cpp index 60c9e020e6..817ce24b76 100644 --- a/eeschema/toolbars_lib_view.cpp +++ b/eeschema/toolbars_lib_view.cpp @@ -24,8 +24,8 @@ #include #include "class_library.h" #include "eeschema_id.h" -#include "general.h" #include "lib_view_frame.h" +#include "sch_painter.h" #include #include #include @@ -116,7 +116,7 @@ void LIB_VIEW_FRAME::ReCreateMenuBar() return IsGridVisible(); }; auto electricalTypesShownCondition = [ this ] ( const SELECTION& aSel ) { - return GetShowElectricalType(); + return GetRenderSettings()->m_ShowPinsElectricalType; }; viewMenu->AddItem( ACTIONS::zoomInCenter, EE_CONDITIONS::ShowAlways ); diff --git a/eeschema/tools/lib_control.cpp b/eeschema/tools/lib_control.cpp index da14841db5..9421091224 100644 --- a/eeschema/tools/lib_control.cpp +++ b/eeschema/tools/lib_control.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include @@ -283,10 +282,10 @@ int LIB_CONTROL::ShowComponentTree( const TOOL_EVENT& aEvent ) int LIB_CONTROL::ShowElectricalTypes( const TOOL_EVENT& aEvent ) { - m_frame->SetShowElectricalType( !m_frame->GetShowElectricalType() ); + KIGFX::SCH_RENDER_SETTINGS* renderSettings = m_frame->GetRenderSettings(); + renderSettings->m_ShowPinsElectricalType = !renderSettings->m_ShowPinsElectricalType; // Update canvas - m_frame->GetRenderSettings()->m_ShowPinsElectricalType = m_frame->GetShowElectricalType(); m_frame->GetCanvas()->GetView()->UpdateAllItems( KIGFX::REPAINT ); m_frame->GetCanvas()->Refresh();