From c1755835eb036158973d1b82f1dda0807696a829 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 21 Jan 2024 11:22:27 +0100 Subject: [PATCH] Symbol editor: add option (view menu+toolbar) to show/hide invisible pins and fields From master branch Fixes #8020 https://gitlab.com/kicad/code/kicad/-/issues/8020 --- eeschema/sch_painter.cpp | 17 ++++++++-- eeschema/sch_painter.h | 2 ++ .../symbol_editor/menubar_symbol_editor.cpp | 4 ++- eeschema/symbol_editor/symbol_edit_frame.cpp | 23 +++++++++++++- .../symbol_editor/symbol_editor_settings.cpp | 6 ++++ .../symbol_editor/symbol_editor_settings.h | 2 ++ .../symbol_editor/toolbars_symbol_editor.cpp | 6 +++- eeschema/tools/ee_actions.cpp | 16 +++++++++- eeschema/tools/ee_actions.h | 2 ++ eeschema/tools/symbol_editor_control.cpp | 31 ++++++++++++++++++- eeschema/tools/symbol_editor_control.h | 3 ++ 11 files changed, 104 insertions(+), 8 deletions(-) diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index ef911e047b..08db61bcb0 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -104,6 +104,8 @@ SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() : m_ShowUnit( 0 ), m_ShowBodyStyle( 0 ), m_ShowPinsElectricalType( true ), + m_ShowHiddenLibPins( true ), // Force showing of hidden pin ( symbol editor specific) + m_ShowHiddenLibFields( true ), // Force showing of hidden fields ( symbol editor specific) m_ShowPinNumbers( false ), m_ShowDisabled( false ), m_ShowGraphicsDisabled( false ), @@ -1064,7 +1066,10 @@ void SCH_PAINTER::draw( const LIB_FIELD* aField, int aLayer, bool aDimmed ) if( !( aField->IsVisible() || aField->IsForceVisible() ) ) { - if( m_schSettings.m_IsSymbolEditor || eeconfig()->m_Appearance.show_hidden_fields ) + bool force_show = m_schematic ? eeconfig()->m_Appearance.show_hidden_fields + : m_schSettings.m_ShowHiddenLibFields; + + if( force_show ) color = getRenderColor( aField, LAYER_HIDDEN, drawingShadows, aDimmed ); else return; @@ -1373,7 +1378,9 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed ) if( m_schSettings.IsPrinting() ) return; - if( !m_schematic || eeconfig()->m_Appearance.show_hidden_pins ) + bool force_show = m_schematic ? eeconfig()->m_Appearance.show_hidden_pins + : m_schSettings.m_ShowHiddenLibPins; + if( force_show ) { color = getRenderColor( aPin, LAYER_HIDDEN, drawingShadows, aDimmed ); } @@ -2179,7 +2186,11 @@ void SCH_PAINTER::draw( const SCH_TEXT* aText, int aLayer ) if( !( aText->IsVisible() || aText->IsForceVisible() ) ) { - if( !m_schematic || eeconfig()->m_Appearance.show_hidden_fields ) + // Currently invisible texts are always shown in symbol editor + bool force_show = m_schematic ? eeconfig()->m_Appearance.show_hidden_fields + : true; + + if( force_show ) color = getRenderColor( aText, LAYER_HIDDEN, drawingShadows ); else return; diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index 34582a816d..23a2827a35 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -114,6 +114,8 @@ public: int m_ShowBodyStyle; // Show all body styles if 0 bool m_ShowPinsElectricalType; + bool m_ShowHiddenLibPins; // Force showing of hidden pin ( symbol editor specific) + bool m_ShowHiddenLibFields; // Force showing of hidden fields ( symbol editor specific) bool m_ShowPinNumbers; // Force showing of pin numbers (normally symbol-specific) bool m_ShowDisabled; bool m_ShowGraphicsDisabled; diff --git a/eeschema/symbol_editor/menubar_symbol_editor.cpp b/eeschema/symbol_editor/menubar_symbol_editor.cpp index 800f061e85..569568d08d 100644 --- a/eeschema/symbol_editor/menubar_symbol_editor.cpp +++ b/eeschema/symbol_editor/menubar_symbol_editor.cpp @@ -125,7 +125,9 @@ void SYMBOL_EDIT_FRAME::doReCreateMenuBar() viewMenu->Add( ACTIONS::zoomRedraw ); viewMenu->AppendSeparator(); - viewMenu->Add( EE_ACTIONS::showSymbolTree, ACTION_MENU::CHECK ); + viewMenu->Add( EE_ACTIONS::showSymbolTree, ACTION_MENU::CHECK ); + viewMenu->Add( EE_ACTIONS::showHiddenLibPins, ACTION_MENU::CHECK ); + viewMenu->Add( EE_ACTIONS::showHiddenLibFields, ACTION_MENU::CHECK ); //-- Place menu ----------------------------------------------- diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 661a6ad65f..c551a11181 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2024 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 @@ -308,6 +308,8 @@ void SYMBOL_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) SCH_BASE_FRAME::LoadSettings( GetSettings() ); GetRenderSettings()->m_ShowPinsElectricalType = m_settings->m_ShowPinElectricalType; + GetRenderSettings()->m_ShowHiddenLibPins = m_settings->m_ShowHiddenLibPins; + GetRenderSettings()->m_ShowHiddenLibFields = m_settings->m_ShowHiddenLibFields; GetRenderSettings()->SetDefaultFont( wxEmptyString ); } @@ -321,6 +323,9 @@ void SYMBOL_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) SCH_BASE_FRAME::SaveSettings( GetSettings() ); m_settings->m_ShowPinElectricalType = GetRenderSettings()->m_ShowPinsElectricalType; + m_settings->m_ShowHiddenLibPins = GetRenderSettings()->m_ShowHiddenLibPins; + m_settings->m_ShowHiddenLibFields = GetRenderSettings()->m_ShowHiddenLibFields; + m_settings->m_LibWidth = m_treePane->GetSize().x; m_settings->m_LibrarySortMode = m_treePane->GetLibTree()->GetSortMode(); @@ -471,6 +476,18 @@ void SYMBOL_EDIT_FRAME::setupUIConditions() return GetRenderSettings() && GetRenderSettings()->m_ShowPinsElectricalType; }; + auto hiddenPinCond = + [this]( const SELECTION& ) + { + return GetRenderSettings() && GetRenderSettings()->m_ShowHiddenLibPins; + }; + + auto hiddenFieldCond = + [this]( const SELECTION& ) + { + return GetRenderSettings() && GetRenderSettings()->m_ShowHiddenLibFields; + }; + auto showCompTreeCond = [this]( const SELECTION& ) { @@ -487,6 +504,8 @@ void SYMBOL_EDIT_FRAME::setupUIConditions() mgr->SetConditions( ACTIONS::toggleBoundingBoxes, CHECK( cond.BoundingBoxes() ) ); mgr->SetConditions( EE_ACTIONS::showSymbolTree, CHECK( showCompTreeCond ) ); mgr->SetConditions( ACTIONS::showProperties, CHECK( propertiesCond ) ); + mgr->SetConditions( EE_ACTIONS::showHiddenLibPins, CHECK( hiddenPinCond ) ); + mgr->SetConditions( EE_ACTIONS::showHiddenLibFields, CHECK( hiddenFieldCond ) ); auto demorganCond = [this]( const SELECTION& ) @@ -1215,6 +1234,8 @@ void SYMBOL_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextV SYMBOL_EDITOR_SETTINGS* cfg = mgr->GetAppSettings(); GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_ShowPinElectricalType; + GetRenderSettings()->m_ShowHiddenLibPins = cfg->m_ShowHiddenLibPins; + GetRenderSettings()->m_ShowHiddenLibFields = cfg->m_ShowHiddenLibFields; GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window ); diff --git a/eeschema/symbol_editor/symbol_editor_settings.cpp b/eeschema/symbol_editor/symbol_editor_settings.cpp index 469204376c..c7b7af86ca 100644 --- a/eeschema/symbol_editor/symbol_editor_settings.cpp +++ b/eeschema/symbol_editor/symbol_editor_settings.cpp @@ -101,6 +101,12 @@ SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_SETTINGS() : m_params.emplace_back( new PARAM( "show_pin_electrical_type", &m_ShowPinElectricalType, true ) ); + m_params.emplace_back( new PARAM( "show_hidden_lib_fields", + &m_ShowHiddenLibFields, true ) ); + + m_params.emplace_back( new PARAM( "show_hidden_lib_pins", + &m_ShowHiddenLibPins, true ) ); + m_params.emplace_back( new PARAM( "lib_table_width", &m_LibWidth, 250 ) ); diff --git a/eeschema/symbol_editor/symbol_editor_settings.h b/eeschema/symbol_editor/symbol_editor_settings.h index b83a794d7c..c4b9434576 100644 --- a/eeschema/symbol_editor/symbol_editor_settings.h +++ b/eeschema/symbol_editor/symbol_editor_settings.h @@ -80,6 +80,8 @@ public: DIALOG_IMPORT_GRAPHICS m_ImportGraphics; bool m_ShowPinElectricalType; + bool m_ShowHiddenLibPins; + bool m_ShowHiddenLibFields; int m_LibWidth; diff --git a/eeschema/symbol_editor/toolbars_symbol_editor.cpp b/eeschema/symbol_editor/toolbars_symbol_editor.cpp index a4fdbf76d5..da8f45a568 100644 --- a/eeschema/symbol_editor/toolbars_symbol_editor.cpp +++ b/eeschema/symbol_editor/toolbars_symbol_editor.cpp @@ -165,10 +165,14 @@ void SYMBOL_EDIT_FRAME::ReCreateOptToolbar() m_optionsToolBar->Add( ACTIONS::milsUnits, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( ACTIONS::millimetersUnits, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->Add( ACTIONS::toggleCursorStyle, ACTION_TOOLBAR::TOGGLE ); + + m_optionsToolBar->AddScaledSeparator( this ); m_optionsToolBar->Add( EE_ACTIONS::showElectricalTypes, ACTION_TOOLBAR::TOGGLE ); + m_optionsToolBar->Add( EE_ACTIONS::showHiddenLibPins, ACTION_TOOLBAR::TOGGLE ); + m_optionsToolBar->Add( EE_ACTIONS::showHiddenLibFields, ACTION_TOOLBAR::TOGGLE ); if( ADVANCED_CFG::GetCfg().m_DrawBoundingBoxes ) - m_optionsToolBar->Add( ACTIONS::toggleBoundingBoxes, ACTION_TOOLBAR::TOGGLE ); + m_optionsToolBar->Add( ACTIONS::toggleBoundingBoxes, ACTION_TOOLBAR::TOGGLE ); m_optionsToolBar->AddScaledSeparator( this ); m_optionsToolBar->Add( EE_ACTIONS::showSymbolTree, ACTION_TOOLBAR::TOGGLE ); diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index 5794c21c68..3e514d98df 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019-2023 CERN - * Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2024 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 @@ -307,6 +307,20 @@ TOOL_ACTION EE_ACTIONS::toggleSyncedPinsMode( TOOL_ACTION_ARGS() "Enabled by default for multiunit parts with interchangeable units." ) ) .Icon( BITMAPS::pin2pin ) ); +TOOL_ACTION EE_ACTIONS::showHiddenLibPins( TOOL_ACTION_ARGS() + .Name( "eeschema.SymbolLibraryControl.showHiddenLibPins" ) + .Scope( AS_GLOBAL ) + .FriendlyName( _( "Show Hidden Pins" ) ) + .Tooltip( _( "Toggle display of hidden pins" ) ) + .Icon( BITMAPS::hidden_pin ) ); + +TOOL_ACTION EE_ACTIONS::showHiddenLibFields( TOOL_ACTION_ARGS() + .Name( "eeschema.SymbolLibraryControl.showHiddenLibFields" ) + .Scope( AS_GLOBAL ) + .FriendlyName( _( "Show Hidden Fields" ) ) + .Tooltip( _( "Toggle display of hidden text fields" ) ) + .Icon( BITMAPS::spreadsheet ) ); + // SYMBOL_EDITOR_DRAWING_TOOLS // diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index c3bceeef5d..4e78b5f869 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -223,6 +223,8 @@ public: // Miscellaneous static TOOL_ACTION toggleHiddenPins; static TOOL_ACTION toggleHiddenFields; + static TOOL_ACTION showHiddenLibPins; + static TOOL_ACTION showHiddenLibFields; static TOOL_ACTION toggleDirectiveLabels; static TOOL_ACTION toggleERCWarnings; static TOOL_ACTION toggleERCErrors; diff --git a/eeschema/tools/symbol_editor_control.cpp b/eeschema/tools/symbol_editor_control.cpp index efd77d2d00..078cddc9b6 100644 --- a/eeschema/tools/symbol_editor_control.cpp +++ b/eeschema/tools/symbol_editor_control.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 CERN - * Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2024 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 @@ -556,6 +556,32 @@ int SYMBOL_EDITOR_CONTROL::ToggleSyncedPinsMode( const TOOL_EVENT& aEvent ) } +int SYMBOL_EDITOR_CONTROL::ToggleHiddenLibPins( const TOOL_EVENT& aEvent ) +{ + SYMBOL_EDIT_FRAME* editFrame = getEditFrame(); + editFrame->GetRenderSettings()->m_ShowHiddenLibPins = + !editFrame->GetRenderSettings()->m_ShowHiddenLibPins; + + getView()->UpdateAllItems( KIGFX::REPAINT ); + editFrame->GetCanvas()->Refresh(); + + return 0; +} + + +int SYMBOL_EDITOR_CONTROL::ToggleHiddenLibFields( const TOOL_EVENT& aEvent ) +{ + SYMBOL_EDIT_FRAME* editFrame = getEditFrame(); + editFrame->GetRenderSettings()->m_ShowHiddenLibFields = + !editFrame->GetRenderSettings()->m_ShowHiddenLibFields; + + getView()->UpdateAllItems( KIGFX::REPAINT ); + editFrame->GetCanvas()->Refresh(); + + return 0; +} + + int SYMBOL_EDITOR_CONTROL::ExportView( const TOOL_EVENT& aEvent ) { if( !m_isSymbolEditor ) @@ -748,5 +774,8 @@ void SYMBOL_EDITOR_CONTROL::setTransitions() Go( &SYMBOL_EDITOR_CONTROL::ToggleSymbolTree, EE_ACTIONS::showSymbolTree.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ToggleSymbolTree, EE_ACTIONS::hideSymbolTree.MakeEvent() ); Go( &SYMBOL_EDITOR_CONTROL::ToggleSyncedPinsMode, EE_ACTIONS::toggleSyncedPinsMode.MakeEvent() ); + Go( &SYMBOL_EDITOR_CONTROL::ToggleProperties, ACTIONS::showProperties.MakeEvent() ); + Go( &SYMBOL_EDITOR_CONTROL::ToggleHiddenLibPins, EE_ACTIONS::showHiddenLibPins.MakeEvent() ); + Go( &SYMBOL_EDITOR_CONTROL::ToggleHiddenLibFields, EE_ACTIONS::showHiddenLibFields.MakeEvent() ); } diff --git a/eeschema/tools/symbol_editor_control.h b/eeschema/tools/symbol_editor_control.h index 1000a89a98..fda7d7e098 100644 --- a/eeschema/tools/symbol_editor_control.h +++ b/eeschema/tools/symbol_editor_control.h @@ -71,6 +71,9 @@ public: int ToggleProperties( const TOOL_EVENT& aEvent ); int ToggleSyncedPinsMode( const TOOL_EVENT& aEvent ); + int ToggleHiddenLibPins( const TOOL_EVENT& aEvent ); + int ToggleHiddenLibFields( const TOOL_EVENT& aEvent ); + int DdAddLibrary( const TOOL_EVENT& aEvent ); private: