Symbol editor: add option (view menu+toolbar) to show/hide invisible pins and fields

Fixes #8020
https://gitlab.com/kicad/code/kicad/-/issues/8020
This commit is contained in:
jean-pierre charras 2024-01-21 11:22:27 +01:00
parent be81bce637
commit f7721f385a
11 changed files with 104 additions and 8 deletions

View File

@ -105,6 +105,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 ),
@ -1071,7 +1073,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;
@ -1398,7 +1403,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 );
}
@ -2204,7 +2211,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;

View File

@ -115,6 +115,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;

View File

@ -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 -----------------------------------------------

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* 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<SYMBOL_EDITOR_SETTINGS>();
GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_ShowPinElectricalType;
GetRenderSettings()->m_ShowHiddenLibPins = cfg->m_ShowHiddenLibPins;
GetRenderSettings()->m_ShowHiddenLibFields = cfg->m_ShowHiddenLibFields;
GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );

View File

@ -101,6 +101,12 @@ SYMBOL_EDITOR_SETTINGS::SYMBOL_EDITOR_SETTINGS() :
m_params.emplace_back( new PARAM<bool>( "show_pin_electrical_type",
&m_ShowPinElectricalType, true ) );
m_params.emplace_back( new PARAM<bool>( "show_hidden_lib_fields",
&m_ShowHiddenLibFields, true ) );
m_params.emplace_back( new PARAM<bool>( "show_hidden_lib_pins",
&m_ShowHiddenLibPins, true ) );
m_params.emplace_back( new PARAM<int>( "lib_table_width",
&m_LibWidth, 250 ) );

View File

@ -80,6 +80,8 @@ public:
DIALOG_IMPORT_GRAPHICS m_ImportGraphics;
bool m_ShowPinElectricalType;
bool m_ShowHiddenLibPins;
bool m_ShowHiddenLibFields;
int m_LibWidth;

View File

@ -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 );

View File

@ -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
@ -312,6 +312,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
//

View File

@ -229,6 +229,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;

View File

@ -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<SYMBOL_EDIT_FRAME>();
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<SYMBOL_EDIT_FRAME>();
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() );
}

View File

@ -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: