From 49a4699d5a0a96b166a187fb74c1a938298017f4 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 26 Feb 2025 18:13:36 -0800 Subject: [PATCH] ADDED: Local power symbol option Local power symbols work like regular power symbols except that they are scoped only the the sheet in which they are instantiated Fixes https://gitlab.com/kicad/code/kicad/-/issues/2075 --- eeschema/connection_graph.cpp | 62 +++-- eeschema/connection_graph.h | 4 +- eeschema/dialogs/dialog_label_properties.cpp | 18 ++ .../dialogs/dialog_lib_symbol_properties.cpp | 16 +- .../dialog_lib_symbol_properties_base.cpp | 30 ++- .../dialog_lib_symbol_properties_base.fbp | 113 ++++++++-- .../dialog_lib_symbol_properties_base.h | 3 +- .../panel_eeschema_editing_options.cpp | 4 + .../panel_eeschema_editing_options_base.cpp | 42 +++- .../panel_eeschema_editing_options_base.fbp | 212 ++++++++++++++++-- .../panel_eeschema_editing_options_base.h | 5 +- eeschema/eeschema_settings.cpp | 4 + eeschema/eeschema_settings.h | 48 ++-- eeschema/erc/erc.cpp | 2 +- eeschema/lib_symbol.cpp | 52 ++++- eeschema/lib_symbol.h | 10 +- eeschema/sch_connection.cpp | 13 +- eeschema/sch_file_versions.h | 3 +- eeschema/sch_io/altium/sch_io_altium.cpp | 2 +- .../cadstar/cadstar_sch_archive_loader.cpp | 2 +- eeschema/sch_io/eagle/sch_io_eagle.cpp | 6 +- .../sch_io/easyeda/sch_easyeda_parser.cpp | 2 +- .../easyedapro/sch_easyedapro_parser.cpp | 2 +- .../kicad_legacy/sch_io_kicad_legacy.cpp | 4 +- .../sch_io_kicad_legacy_lib_cache.cpp | 4 +- .../sch_io_kicad_sexpr_lib_cache.cpp | 6 +- .../kicad_sexpr/sch_io_kicad_sexpr_parser.cpp | 12 +- .../sch_io/ltspice/sch_io_ltspice_parser.cpp | 2 +- eeschema/sch_painter.cpp | 69 ++++++ eeschema/sch_pin.cpp | 21 +- eeschema/sch_pin.h | 12 + eeschema/sch_screen.cpp | 2 +- eeschema/sch_symbol.cpp | 42 +++- eeschema/sch_symbol.h | 3 + eeschema/schematic.keywords | 2 + eeschema/symbol.h | 2 + eeschema/symbol_checker.cpp | 2 +- eeschema/symbol_editor/symbol_editor.cpp | 6 +- eeschema/tools/backannotate.cpp | 2 +- eeschema/tools/sch_drawing_tools.cpp | 30 +++ .../eeschema/test_legacy_power_symbols.cpp | 2 +- qa/tests/eeschema/test_lib_part.cpp | 6 +- qa/tests/eeschema/test_sch_pin.cpp | 3 +- 43 files changed, 739 insertions(+), 148 deletions(-) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index a3dee0eb49..888dda344e 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -151,8 +152,17 @@ bool CONNECTION_SUBGRAPH::ResolveDrivers( bool aCheckMultipleDrivers ) SCH_PIN* pa = static_cast( a ); SCH_PIN* pb = static_cast( b ); - bool aPower = pa->GetLibPin()->GetParentSymbol()->IsPower(); - bool bPower = pb->GetLibPin()->GetParentSymbol()->IsPower(); + bool aPower = pa->GetLibPin()->GetParentSymbol()->IsGlobalPower(); + bool bPower = pb->GetLibPin()->GetParentSymbol()->IsGlobalPower(); + + if( aPower && !bPower ) + return true; + else if( bPower && !aPower ) + return false; + + // Secondary check for local power pin + aPower = pa->GetLibPin()->GetParentSymbol()->IsLocalPower(); + bPower = pb->GetLibPin()->GetParentSymbol()->IsLocalPower(); if( aPower && !bPower ) return true; @@ -217,7 +227,7 @@ bool CONNECTION_SUBGRAPH::ResolveDrivers( bool aCheckMultipleDrivers ) m_strong_driver = true; // Power pins are 5, global labels are 6 - m_local_driver = ( highest_priority < PRIORITY::POWER_PIN ); + m_local_driver = ( highest_priority < PRIORITY::GLOBAL_POWER_PIN ); if( !candidates.empty() ) { @@ -422,6 +432,7 @@ const wxString& CONNECTION_SUBGRAPH::GetNameForDriver( SCH_ITEM* aItem ) const if( aItem->HasCachedDriverName() ) return aItem->GetCachedDriverName(); + std::lock_guard lock( m_driver_name_cache_mutex ); auto it = m_driver_name_cache.find( aItem ); if( it != m_driver_name_cache.end() ) @@ -575,7 +586,9 @@ CONNECTION_SUBGRAPH::PRIORITY CONNECTION_SUBGRAPH::GetDriverPriority( SCH_ITEM* const SCH_SYMBOL* sym = static_cast( sch_pin->GetParentSymbol() ); if( sch_pin->IsGlobalPower() ) - return PRIORITY::POWER_PIN; + return PRIORITY::GLOBAL_POWER_PIN; + else if( sch_pin->IsLocalPower() ) + return PRIORITY::LOCAL_POWER_PIN; else if( !sym || sym->GetExcludedFromBoard() || sym->GetLibSymbolRef()->GetReferenceField().GetText().StartsWith( '#' ) ) return PRIORITY::NONE; @@ -1569,8 +1582,21 @@ void CONNECTION_GRAPH::collectAllDriverValues() case SCH_PIN_T: { SCH_PIN* pin = static_cast( driver ); - wxASSERT( pin->IsGlobalPower() ); - m_global_label_cache[name].push_back( subgraph ); + if( pin->IsGlobalPower() ) + { + m_global_label_cache[name].push_back( subgraph ); + } + else if( pin->IsLocalPower() ) + { + m_local_label_cache[std::make_pair( sheet, name )].push_back( subgraph ); + } + else + { + UNITS_PROVIDER unitsProvider( schIUScale, EDA_UNITS::MILLIMETRES ); + wxLogTrace( ConnTrace, wxS( "Unexpected normal pin %s" ), + driver->GetItemDescription( &unitsProvider, true ) ); + } + break; } default: @@ -1662,7 +1688,7 @@ void CONNECTION_GRAPH::generateGlobalPowerPinSubGraphs() SCH_PIN* pin = it.second; if( !pin->ConnectedItems( sheet ).empty() - && !pin->GetLibPin()->GetParentSymbol()->IsPower() ) + && !pin->GetLibPin()->GetParentSymbol()->IsGlobalPower() ) { // ERC will warn about this: user has wired up an invisible pin continue; @@ -1677,7 +1703,7 @@ void CONNECTION_GRAPH::generateGlobalPowerPinSubGraphs() // Proper modern power symbols get their net name from the value field // in the symbol, but we support legacy non-power symbols with global // power connections based on invisible, power-in, pin's names. - if( pin->GetLibPin()->GetParentSymbol()->IsPower() ) + if( pin->GetLibPin()->GetParentSymbol()->IsGlobalPower() ) connection->SetName( pin->GetParentSymbol()->GetValue( true, &sheet, false ) ); else connection->SetName( pin->GetShownName() ); @@ -2000,7 +2026,7 @@ void CONNECTION_GRAPH::processSubGraphs() { auto pin = static_cast( driver ); - if( pin->IsGlobalPower() + if( pin->IsPower() && pin->GetDefaultNetName( sheet ) == test_name ) { match = true; @@ -2183,7 +2209,7 @@ void CONNECTION_GRAPH::buildConnectionGraph( std::function* a continue; bool secondary_is_global = CONNECTION_SUBGRAPH::GetDriverPriority( driver ) - >= CONNECTION_SUBGRAPH::PRIORITY::POWER_PIN; + >= CONNECTION_SUBGRAPH::PRIORITY::GLOBAL_POWER_PIN; for( CONNECTION_SUBGRAPH* candidate : global_subgraphs ) { @@ -2722,7 +2748,7 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph, boo // Take whichever name is higher priority if( CONNECTION_SUBGRAPH::GetDriverPriority( neighbor->m_driver ) - >= CONNECTION_SUBGRAPH::PRIORITY::POWER_PIN ) + >= CONNECTION_SUBGRAPH::PRIORITY::GLOBAL_POWER_PIN ) { member->Clone( *neighbor_conn ); stale_bus_members.insert( member ); @@ -2788,7 +2814,7 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph, boo wxString bestName = aSubgraph->m_driver_connection->Name(); // Check if a subsheet has a higher-priority connection to the same net - if( highest < CONNECTION_SUBGRAPH::PRIORITY::POWER_PIN ) + if( highest < CONNECTION_SUBGRAPH::PRIORITY::GLOBAL_POWER_PIN ) { for( CONNECTION_SUBGRAPH* subgraph : visited ) { @@ -2810,7 +2836,7 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph, boo // d) matches our priority, is a strong driver, and has a shorter path // e) matches our strength and is at least as short, and is alphabetically lower - if( ( priority >= CONNECTION_SUBGRAPH::PRIORITY::POWER_PIN ) || + if( ( priority >= CONNECTION_SUBGRAPH::PRIORITY::GLOBAL_POWER_PIN ) || ( !bestIsStrong && candidateStrong ) || ( priority > highest && candidateStrong ) || ( priority == highest && candidateStrong && shorterPath ) || @@ -2894,7 +2920,7 @@ std::shared_ptr CONNECTION_GRAPH::getDefaultConnection( SCH_ITEM { SCH_PIN* pin = static_cast( aItem ); - if( pin->IsGlobalPower() ) + if( pin->IsPower() ) c = std::make_shared( aItem, aSubgraph->m_sheet ); break; @@ -3264,7 +3290,7 @@ bool CONNECTION_GRAPH::ercCheckMultipleDrivers( const CONNECTION_SUBGRAPH* aSubg || driver->Type() == SCH_HIER_LABEL_T || driver->Type() == SCH_LABEL_T || ( driver->Type() == SCH_PIN_T - && static_cast( driver )->IsGlobalPower() ) ) + && static_cast( driver )->IsPower() ) ) { const wxString& primaryName = aSubgraph->GetNameForDriver( aSubgraph->m_driver ); const wxString& secondaryName = aSubgraph->GetNameForDriver( driver ); @@ -3501,7 +3527,7 @@ bool CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts( const CONNECTION_SUBGRAPH // Don't report warnings if this bus member has been overridden by a higher priority power pin // or global label if( conflict && CONNECTION_SUBGRAPH::GetDriverPriority( aSubgraph->m_driver ) - >= CONNECTION_SUBGRAPH::PRIORITY::POWER_PIN ) + >= CONNECTION_SUBGRAPH::PRIORITY::GLOBAL_POWER_PIN ) { conflict = false; } @@ -3706,7 +3732,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph // Or else we may fail walking connected components to a power symbol pin since we // reject starting at a power symbol if( test_pin->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN - && !test_pin->IsGlobalPower() ) + && !test_pin->IsPower() ) { pin = test_pin; break; @@ -3718,7 +3744,7 @@ bool CONNECTION_GRAPH::ercCheckNoConnects( const CONNECTION_SUBGRAPH* aSubgraph // We want to throw unconnected errors for power symbols even if they are connected to other // net items by name, because usually failing to connect them graphically is a mistake if( pin && !has_other_connections - && !pin->IsGlobalPower() + && !pin->IsPower() && !pin->GetLibPin()->GetParentSymbol()->IsPower() ) { wxString name = pin->Connection( &sheet )->Name(); diff --git a/eeschema/connection_graph.h b/eeschema/connection_graph.h index a8dd7e7ebb..cd88ffb269 100644 --- a/eeschema/connection_graph.h +++ b/eeschema/connection_graph.h @@ -70,7 +70,8 @@ public: SHEET_PIN, HIER_LABEL, LOCAL_LABEL, - POWER_PIN, + LOCAL_POWER_PIN, + GLOBAL_POWER_PIN, GLOBAL }; @@ -297,6 +298,7 @@ private: std::unordered_set m_hier_children; /// A cache of escaped netnames from schematic items. + mutable std::mutex m_driver_name_cache_mutex; mutable std::unordered_map m_driver_name_cache; /// Fully-resolved driver for the subgraph (might not exist in this subgraph). diff --git a/eeschema/dialogs/dialog_label_properties.cpp b/eeschema/dialogs/dialog_label_properties.cpp index def516d48a..a8134b754b 100644 --- a/eeschema/dialogs/dialog_label_properties.cpp +++ b/eeschema/dialogs/dialog_label_properties.cpp @@ -339,6 +339,24 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataToWindow() } } + // Add local power labels from power symbols + if( m_currentLabel->Type() == SCH_LABEL_T ) + { + for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_LOCATE_POWER_T ) ) + { + const SCH_SYMBOL* power = static_cast( item ); + + // Ensure the symbol has the Power (i.e. equivalent to a local label + // before adding its value in list + if( power->IsSymbolLikePowerLocalLabel() ) + { + const SCH_FIELD* valueField = power->GetField( FIELD_T::VALUE ); + existingLabels.insert( UnescapeString( valueField->GetText() ) ); + } + } + } + // Add bus aliases from the current screen + auto& sheetAliases = screen->GetBusAliases(); busAliases.insert( busAliases.end(), sheetAliases.begin(), sheetAliases.end() ); } diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.cpp b/eeschema/dialogs/dialog_lib_symbol_properties.cpp index a1c9bfb3c9..bb5bf7b567 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties.cpp @@ -235,9 +235,17 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow() m_hasAlternateBodyStyles->SetValue( m_Parent->GetShowDeMorgan() ); m_OptionPower->SetValue( m_libEntry->IsPower() ); + m_OptionLocalPower->SetValue( m_libEntry->IsLocalPower() ); if( m_libEntry->IsPower() ) + { m_spiceFieldsButton->Hide(); + m_OptionLocalPower->Enable(); + } + else + { + m_OptionLocalPower->Enable( false ); + } m_excludeFromSimCheckBox->SetValue( m_libEntry->GetExcludedFromSim() ); m_excludeFromBomCheckBox->SetValue( m_libEntry->GetExcludedFromBOM() ); @@ -483,7 +491,11 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow() if( m_OptionPower->GetValue() ) { - m_libEntry->SetPower(); + if( m_OptionLocalPower->GetValue() ) + m_libEntry->SetLocalPower(); + else + m_libEntry->SetGlobalPower(); + // Power symbols must have value matching name for now m_libEntry->GetValueField().SetText( newName ); } @@ -979,6 +991,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::onPowerCheckBox( wxCommandEvent& aEvent ) m_excludeFromBoardCheckBox->Enable( false ); m_excludeFromSimCheckBox->Enable( false ); m_spiceFieldsButton->Show( false ); + m_OptionLocalPower->Enable( true ); } else { @@ -986,6 +999,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::onPowerCheckBox( wxCommandEvent& aEvent ) m_excludeFromBoardCheckBox->Enable( true ); m_excludeFromSimCheckBox->Enable( true ); m_spiceFieldsButton->Show( true ); + m_OptionLocalPower->Enable( false ); } OnModify(); diff --git a/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp b/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp index b901c39633..9ede1237ee 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6) +// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6a-dirty) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -184,22 +184,30 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow* sbSizerSymbol->Add( m_OptionPartsInterchangeable, 0, wxALL, 4 ); - - sbSizerSymbol->Add( 0, 8, 0, wxEXPAND, 5 ); - m_hasAlternateBodyStyles = new wxCheckBox( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("Has alternate body style (De Morgan)"), wxDefaultPosition, wxDefaultSize, 0 ); m_hasAlternateBodyStyles->SetToolTip( _("Check this option if the symbol has an alternate body style for a De Morgan logic equivalence.\nFor instance, this should be checked for a NAND gate to provide an alternate representation as an OR gate with inverted inputs.") ); sbSizerSymbol->Add( m_hasAlternateBodyStyles, 0, wxBOTTOM|wxRIGHT|wxLEFT, 4 ); - - sbSizerSymbol->Add( 0, 7, 0, wxEXPAND, 5 ); - m_OptionPower = new wxCheckBox( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("Define as power symbol"), wxDefaultPosition, wxDefaultSize, 0 ); - m_OptionPower->SetToolTip( _("Setting this option makes the symbol in question appear in the\n\"add power symbol\" dialog. It will lock the value text to protect it\nfrom editing in the schematic. The symbol will not be included in\nthe BOM and cannot be assigned a footprint.") ); + m_OptionPower->SetToolTip( _("Power symbols define a global net with the value as a netname.\nThey will not be included in the BOM and cannot be assigned a footprint.") ); sbSizerSymbol->Add( m_OptionPower, 0, wxBOTTOM|wxRIGHT|wxLEFT, 4 ); + wxBoxSizer* bSizer16; + bSizer16 = new wxBoxSizer( wxHORIZONTAL ); + + + bSizer16->Add( 0, 0, 0, wxEXPAND|wxLEFT|wxRIGHT, 10 ); + + m_OptionLocalPower = new wxCheckBox( sbSizerSymbol->GetStaticBox(), wxID_ANY, _("Define as local power symbol"), wxDefaultPosition, wxDefaultSize, 0 ); + m_OptionLocalPower->SetToolTip( _("Local power symbols create labels that are limited to the sheet in which they are used") ); + + bSizer16->Add( m_OptionLocalPower, 0, wxBOTTOM|wxLEFT|wxRIGHT, 4 ); + + + sbSizerSymbol->Add( bSizer16, 1, wxEXPAND, 5 ); + bSizerLeftCol->Add( sbSizerSymbol, 0, wxEXPAND|wxALL, 5 ); @@ -292,7 +300,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow* m_PanelBasic->SetSizer( bSizerBasicPanel ); m_PanelBasic->Layout(); bSizerBasicPanel->Fit( m_PanelBasic ); - m_NoteBook->AddPage( m_PanelBasic, _("General"), false ); + m_NoteBook->AddPage( m_PanelBasic, _("General"), true ); m_PanelFootprintFilter = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bPanelFpFilterBoxSizer; bPanelFpFilterBoxSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -340,7 +348,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow* m_PanelFootprintFilter->SetSizer( bPanelFpFilterBoxSizer ); m_PanelFootprintFilter->Layout(); bPanelFpFilterBoxSizer->Fit( m_PanelFootprintFilter ); - m_NoteBook->AddPage( m_PanelFootprintFilter, _("Footprint Filters"), true ); + m_NoteBook->AddPage( m_PanelFootprintFilter, _("Footprint Filters"), false ); bUpperSizer->Add( m_NoteBook, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); @@ -394,6 +402,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow* m_OptionPartsInterchangeable->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_hasAlternateBodyStyles->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_OptionPower->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::onPowerCheckBox ), NULL, this ); + m_OptionLocalPower->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::onPowerCheckBox ), NULL, this ); m_ShowPinNumButt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_ShowPinNameButt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_PinsNameInsideButt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); @@ -429,6 +438,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::~DIALOG_LIB_SYMBOL_PROPERTIES_BASE() m_OptionPartsInterchangeable->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_hasAlternateBodyStyles->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_OptionPower->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::onPowerCheckBox ), NULL, this ); + m_OptionLocalPower->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::onPowerCheckBox ), NULL, this ); m_ShowPinNumButt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_ShowPinNameButt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); m_PinsNameInsideButt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LIB_SYMBOL_PROPERTIES_BASE::OnCheckBox ), NULL, this ); diff --git a/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp b/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp index f787a61005..4ebbe362e3 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp +++ b/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp @@ -136,7 +136,7 @@ General - 0 + 1 1 1 @@ -1269,16 +1269,6 @@ OnCheckBox - - 5 - wxEXPAND - 0 - - 8 - protected - 0 - - 4 wxBOTTOM|wxRIGHT|wxLEFT @@ -1345,16 +1335,6 @@ OnCheckBox - - 5 - wxEXPAND - 0 - - 7 - protected - 0 - - 4 wxBOTTOM|wxRIGHT|wxLEFT @@ -1410,7 +1390,7 @@ 0 - Setting this option makes the symbol in question appear in the "add power symbol" dialog. It will lock the value text to protect it from editing in the schematic. The symbol will not be included in the BOM and cannot be assigned a footprint. + Power symbols define a global net with the value as a netname. They will not be included in the BOM and cannot be assigned a footprint. wxFILTER_NONE wxDefaultValidator @@ -1421,6 +1401,93 @@ onPowerCheckBox + + 5 + wxEXPAND + 1 + + + bSizer16 + wxHORIZONTAL + none + + 10 + wxEXPAND|wxLEFT|wxRIGHT + 0 + + 0 + protected + 0 + + + + 4 + wxBOTTOM|wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Define as local power symbol + + 0 + + + 0 + + 1 + m_OptionLocalPower + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Local power symbols create labels that are limited to the sheet in which they are used + + wxFILTER_NONE + wxDefaultValidator + + + + + onPowerCheckBox + + + + @@ -2110,7 +2177,7 @@ Footprint Filters - 1 + 0 1 1 diff --git a/eeschema/dialogs/dialog_lib_symbol_properties_base.h b/eeschema/dialogs/dialog_lib_symbol_properties_base.h index 91f510f426..7950f2f590 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties_base.h +++ b/eeschema/dialogs/dialog_lib_symbol_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6) +// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6a-dirty) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -68,6 +68,7 @@ class DIALOG_LIB_SYMBOL_PROPERTIES_BASE : public DIALOG_SHIM wxCheckBox* m_OptionPartsInterchangeable; wxCheckBox* m_hasAlternateBodyStyles; wxCheckBox* m_OptionPower; + wxCheckBox* m_OptionLocalPower; wxCheckBox* m_ShowPinNumButt; wxCheckBox* m_ShowPinNameButt; wxCheckBox* m_PinsNameInsideButt; diff --git a/eeschema/dialogs/panel_eeschema_editing_options.cpp b/eeschema/dialogs/panel_eeschema_editing_options.cpp index 3f4008d078..986aeff1cc 100644 --- a/eeschema/dialogs/panel_eeschema_editing_options.cpp +++ b/eeschema/dialogs/panel_eeschema_editing_options.cpp @@ -88,6 +88,8 @@ void PANEL_EESCHEMA_EDITING_OPTIONS::loadEEschemaSettings( EESCHEMA_SETTINGS* aC m_cbAutoStartWires->SetValue( aCfg->m_Drawing.auto_start_wires ); m_escClearsNetHighlight->SetValue( aCfg->m_Input.esc_clears_net_highlight ); + + m_choicePower->SetSelection( static_cast( aCfg->m_Drawing.new_power_symbols ) ); } @@ -107,6 +109,8 @@ bool PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataFromWindow() SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings( "eeschema" ); + cfg->m_Drawing.new_power_symbols = static_cast( m_choicePower->GetSelection() ); + cfg->m_Drawing.default_sheet_border_color = m_borderColorSwatch->GetSwatchColor(); cfg->m_Drawing.default_sheet_background_color = m_backgroundColorSwatch->GetSwatchColor(); diff --git a/eeschema/dialogs/panel_eeschema_editing_options_base.cpp b/eeschema/dialogs/panel_eeschema_editing_options_base.cpp index a021ac1105..b7434d6708 100644 --- a/eeschema/dialogs/panel_eeschema_editing_options_base.cpp +++ b/eeschema/dialogs/panel_eeschema_editing_options_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6) +// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6a-dirty) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -71,26 +71,54 @@ PANEL_EESCHEMA_EDITING_OPTIONS_BASE::PANEL_EESCHEMA_EDITING_OPTIONS_BASE( wxWind m_staticline4 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bLeftColumn->Add( m_staticline4, 0, wxEXPAND|wxBOTTOM, 5 ); - wxBoxSizer* bSizer6; - bSizer6 = new wxBoxSizer( wxHORIZONTAL ); + wxGridBagSizer* gbSizer1; + gbSizer1 = new wxGridBagSizer( 0, 0 ); + gbSizer1->SetFlexibleDirection( wxBOTH ); + gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); m_borderColorLabel = new wxStaticText( this, wxID_ANY, _("Sheet border:"), wxDefaultPosition, wxDefaultSize, 0 ); m_borderColorLabel->Wrap( -1 ); - bSizer6->Add( m_borderColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); + gbSizer1->Add( m_borderColorLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); m_borderColorSwatch = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_borderColorSwatch->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); - bSizer6->Add( m_borderColorSwatch, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + gbSizer1->Add( m_borderColorSwatch, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 ); m_backgroundColorLabel = new wxStaticText( this, wxID_ANY, _("Sheet background:"), wxDefaultPosition, wxDefaultSize, 0 ); m_backgroundColorLabel->Wrap( -1 ); - bSizer6->Add( m_backgroundColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + gbSizer1->Add( m_backgroundColorLabel, wxGBPosition( 0, 2 ), wxGBSpan( 1, 1 ), wxALL, 5 ); m_backgroundColorSwatch = new COLOR_SWATCH( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_backgroundColorSwatch->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); - bSizer6->Add( m_backgroundColorSwatch, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + gbSizer1->Add( m_backgroundColorSwatch, wxGBPosition( 0, 3 ), wxGBSpan( 1, 1 ), wxALL, 5 ); + + m_powerSymbolLabel = new wxStaticText( this, wxID_ANY, _("Power Symbols:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_powerSymbolLabel->Wrap( -1 ); + gbSizer1->Add( m_powerSymbolLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + wxString m_choicePowerChoices[] = { _("Default"), _("Global"), _("Local") }; + int m_choicePowerNChoices = sizeof( m_choicePowerChoices ) / sizeof( wxString ); + m_choicePower = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choicePowerNChoices, m_choicePowerChoices, 0 ); + m_choicePower->SetSelection( 0 ); + m_choicePower->SetToolTip( _("Select the assigned type of new power symbol.\nDefault will follow the symbol definition.\nGlobal will convert new power symbols to global power symbols.\nLocal will convert new power symbols to a local power symbols.") ); + + gbSizer1->Add( m_choicePower, wxGBPosition( 1, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); + + + bLeftColumn->Add( gbSizer1, 0, wxEXPAND|wxLEFT|wxTOP, 10 ); + + wxFlexGridSizer* fgSizer4; + fgSizer4 = new wxFlexGridSizer( 2, 4, 0, 0 ); + fgSizer4->SetFlexibleDirection( wxBOTH ); + fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + + bLeftColumn->Add( fgSizer4, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizer6; + bSizer6 = new wxBoxSizer( wxHORIZONTAL ); bLeftColumn->Add( bSizer6, 0, wxEXPAND|wxTOP|wxLEFT, 10 ); diff --git a/eeschema/dialogs/panel_eeschema_editing_options_base.fbp b/eeschema/dialogs/panel_eeschema_editing_options_base.fbp index 93cde8e56b..46f3d0cdef 100644 --- a/eeschema/dialogs/panel_eeschema_editing_options_base.fbp +++ b/eeschema/dialogs/panel_eeschema_editing_options_base.fbp @@ -667,17 +667,26 @@ 10 - wxEXPAND|wxTOP|wxLEFT + wxEXPAND|wxLEFT|wxTOP 0 - + + + wxBOTH + + + 0 - bSizer6 - wxHORIZONTAL + gbSizer1 + wxFLEX_GROWMODE_SPECIFIED none - + 0 + 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT - 0 + 1 + 0 + wxALL + 0 + 1 1 1 @@ -736,10 +745,13 @@ -1 - + 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL - 1 + 1 + 1 + wxALL + 0 + 1 1 1 @@ -799,10 +811,13 @@ - + 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT - 0 + 1 + 2 + wxALL + 0 + 1 1 1 @@ -861,10 +876,13 @@ -1 - + 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL - 1 + 1 + 3 + wxALL + 0 + 1 1 1 @@ -924,6 +942,168 @@ + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL|wxALL + 1 + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Power Symbols: + 0 + + 0 + + + 0 + + 1 + m_powerSymbolLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 2 + 1 + wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND + 1 + 1 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + "Default" "Global" "Local" + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_choicePower + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + ; ; forward_declare + 0 + Select the assigned type of new power symbol. Default will follow the symbol definition. Global will convert new power symbols to global power symbols. Local will convert new power symbols to a local power symbols. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 5 + wxEXPAND + 1 + + 4 + wxBOTH + + + 0 + + fgSizer4 + wxFLEX_GROWMODE_SPECIFIED + none + 2 + 0 + + + + 10 + wxEXPAND|wxTOP|wxLEFT + 0 + + + bSizer6 + wxHORIZONTAL + none diff --git a/eeschema/dialogs/panel_eeschema_editing_options_base.h b/eeschema/dialogs/panel_eeschema_editing_options_base.h index fe389e4602..252210379c 100644 --- a/eeschema/dialogs/panel_eeschema_editing_options_base.h +++ b/eeschema/dialogs/panel_eeschema_editing_options_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6) +// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6a-dirty) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,8 @@ class PANEL_EESCHEMA_EDITING_OPTIONS_BASE : public RESETTABLE_PANEL COLOR_SWATCH* m_borderColorSwatch; wxStaticText* m_backgroundColorLabel; COLOR_SWATCH* m_backgroundColorSwatch; + wxStaticText* m_powerSymbolLabel; + wxChoice* m_choicePower; wxSimplebook* m_leftClickCmdsBook; wxPanel* m_pageWinLin; wxStaticText* m_leftClickLabel; diff --git a/eeschema/eeschema_settings.cpp b/eeschema/eeschema_settings.cpp index 986fafda28..0472c79eee 100644 --- a/eeschema/eeschema_settings.cpp +++ b/eeschema/eeschema_settings.cpp @@ -371,6 +371,10 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() : m_params.emplace_back( new PARAM( "drawing.default_sheet_background_color", &m_Drawing.default_sheet_background_color, COLOR4D::UNSPECIFIED ) ); + m_params.emplace_back( new PARAM_ENUM( + "drawing.new_power_symbols", &m_Drawing.new_power_symbols, POWER_SYMBOLS::DEFAULT, + POWER_SYMBOLS::DEFAULT, POWER_SYMBOLS::LOCAL ) ); + m_params.emplace_back( new PARAM_LIST( "drawing.junction_size_mult_list", &m_Drawing.junction_size_mult_list, { 0.0, 1.7, 4.0, 6.0, 9.0, 12.0 } ) ); diff --git a/eeschema/eeschema_settings.h b/eeschema/eeschema_settings.h index 5d06c28dc7..a44278f315 100644 --- a/eeschema/eeschema_settings.h +++ b/eeschema/eeschema_settings.h @@ -49,6 +49,13 @@ enum LINE_MODE }; +enum class POWER_SYMBOLS +{ + DEFAULT = 0, + GLOBAL, + LOCAL +}; + class EESCHEMA_SETTINGS : public APP_SETTINGS_BASE { public: @@ -147,26 +154,27 @@ public: struct DRAWING { - int default_bus_thickness; - int default_junction_size; - int default_line_thickness; - int default_repeat_offset_x; - int default_repeat_offset_y; - int default_wire_thickness; - int default_text_size; - int pin_symbol_size; - double text_offset_ratio; - COLOR4D default_sheet_border_color; - COLOR4D default_sheet_background_color; - wxString field_names; - int line_mode; - int repeat_label_increment; - bool intersheets_ref_show; - bool intersheets_ref_own_page; - bool intersheets_ref_short; - wxString intersheets_ref_prefix; - wxString intersheets_ref_suffix; - bool auto_start_wires; + int default_bus_thickness; + int default_junction_size; + int default_line_thickness; + int default_repeat_offset_x; + int default_repeat_offset_y; + int default_wire_thickness; + int default_text_size; + int pin_symbol_size; + double text_offset_ratio; + COLOR4D default_sheet_border_color; + COLOR4D default_sheet_background_color; + POWER_SYMBOLS new_power_symbols; + wxString field_names; + int line_mode; + int repeat_label_increment; + bool intersheets_ref_show; + bool intersheets_ref_own_page; + bool intersheets_ref_short; + wxString intersheets_ref_prefix; + wxString intersheets_ref_suffix; + bool auto_start_wires; std::vector junction_size_mult_list; // Pulldown index for user default junction dot size (e.g. smallest = 0, small = 1, etc) diff --git a/eeschema/erc/erc.cpp b/eeschema/erc/erc.cpp index 77fb1adbbc..f25a700671 100644 --- a/eeschema/erc/erc.cpp +++ b/eeschema/erc/erc.cpp @@ -1333,7 +1333,7 @@ int ERC_TESTER::TestSimilarLabels() { SCH_PIN* pin = static_cast( item ); - if( !pin->IsGlobalPower() ) + if( !pin->IsPower() ) { continue; } diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index bcae105ba6..46cf584974 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -411,33 +411,69 @@ const wxString LIB_SYMBOL::GetLibraryName() const } -bool LIB_SYMBOL::IsPower() const +bool LIB_SYMBOL::IsLocalPower() const +{ + std::shared_ptr parent; + + if( !m_parent.expired() && ( parent = m_parent.lock() ) ) + { + if( parent->IsRoot() ) + return parent->m_options == ENTRY_LOCAL_POWER; + else + return parent->IsLocalPower(); + } + + return m_options == ENTRY_LOCAL_POWER; +} + + +void LIB_SYMBOL::SetLocalPower() +{ + if( LIB_SYMBOL_SPTR parent = m_parent.lock() ) + { + if( parent->IsRoot() ) + parent->m_options = ENTRY_LOCAL_POWER; + else + parent->SetLocalPower(); + } + + m_options = ENTRY_LOCAL_POWER; +} + + +bool LIB_SYMBOL::IsGlobalPower() const { std::shared_ptr parent; if( !m_parent.expired() && ( parent = m_parent.lock() ) ) { if( parent->IsRoot() ) - return parent->m_options == ENTRY_POWER; + return parent->m_options == ENTRY_GLOBAL_POWER; else - return parent->IsPower(); + return parent->IsGlobalPower(); } - return m_options == ENTRY_POWER; + return m_options == ENTRY_GLOBAL_POWER; +} + + +bool LIB_SYMBOL::IsPower() const +{ + return IsLocalPower() || IsGlobalPower(); } -void LIB_SYMBOL::SetPower() +void LIB_SYMBOL::SetGlobalPower() { if( LIB_SYMBOL_SPTR parent = m_parent.lock() ) { if( parent->IsRoot() ) - parent->m_options = ENTRY_POWER; + parent->m_options = ENTRY_GLOBAL_POWER; else - parent->SetPower(); + parent->SetGlobalPower(); } - m_options = ENTRY_POWER; + m_options = ENTRY_GLOBAL_POWER; } diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index f66353976f..6540088a67 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -58,8 +58,9 @@ typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS; /* values for member .m_options */ enum LIBRENTRYOPTIONS { - ENTRY_NORMAL, // Libentry is a standard symbol (real or alias) - ENTRY_POWER // Libentry is a power symbol + ENTRY_NORMAL, // Libentry is a standard symbol (real or alias) + ENTRY_GLOBAL_POWER, // Libentry is a power symbol + ENTRY_LOCAL_POWER // Libentry is a local power symbol }; @@ -266,10 +267,13 @@ public: return GetBodyBoundingBox( m_previewUnit, m_previewBodyStyle, true, false ); } + bool IsGlobalPower() const override; + bool IsLocalPower() const override; bool IsPower() const override; bool IsNormal() const override; - void SetPower(); + void SetGlobalPower(); + void SetLocalPower(); void SetNormal(); /** diff --git a/eeschema/sch_connection.cpp b/eeschema/sch_connection.cpp index 4d1e542b8c..dba95de600 100644 --- a/eeschema/sch_connection.cpp +++ b/eeschema/sch_connection.cpp @@ -336,7 +336,7 @@ bool SCH_CONNECTION::IsDriver() const if( const SCH_SYMBOL* symbol = dynamic_cast( pin->GetParentSymbol() ) ) { // Only annotated symbols should drive nets. - return pin->IsGlobalPower() || symbol->IsAnnotated( &m_sheet ); + return pin->IsPower() || symbol->IsAnnotated( &m_sheet ); } return true; @@ -399,12 +399,17 @@ void SCH_CONNECTION::recacheName() switch( m_driver->Type() ) { case SCH_GLOBAL_LABEL_T: - case SCH_PIN_T: - // Pins are either power connections or belong to a uniquely-annotated - // symbol, so they don't need a path if they are driving the subgraph. prepend_path = false; break; + case SCH_PIN_T: + { // Normal pins and global power pins do not need a path. But local power pins do + SCH_PIN* pin = static_cast( m_driver ); + + prepend_path = pin->IsLocalPower(); + break; + } + default: break; } diff --git a/eeschema/sch_file_versions.h b/eeschema/sch_file_versions.h index 528b745c36..29d02039e8 100644 --- a/eeschema/sch_file_versions.h +++ b/eeschema/sch_file_versions.h @@ -115,4 +115,5 @@ //#define SEXPR_SCHEMATIC_FILE_VERSION 20241004 // Use booleans for 'hide' in symbols //#define SEXPR_SCHEMATIC_FILE_VERSION 20241209 // Private flags for SCH_FIELDs //#define SEXPR_SCHEMATIC_FILE_VERSION 20250114 // Full paths for text variable cross references -#define SEXPR_SCHEMATIC_FILE_VERSION 20250222 // Hatched fills for shapes +//#define SEXPR_SCHEMATIC_FILE_VERSION 20250222 // Hatched fills for shapes +#define SEXPR_SCHEMATIC_FILE_VERSION 20250227 // Support for local power symbols diff --git a/eeschema/sch_io/altium/sch_io_altium.cpp b/eeschema/sch_io/altium/sch_io_altium.cpp index 5ae7463e6b..bf713fed74 100644 --- a/eeschema/sch_io/altium/sch_io_altium.cpp +++ b/eeschema/sch_io/altium/sch_io_altium.cpp @@ -3673,7 +3673,7 @@ void SCH_IO_ALTIUM::ParsePowerPort( const std::map& aPropert else { libSymbol = new LIB_SYMBOL( wxEmptyString ); - libSymbol->SetPower(); + libSymbol->SetGlobalPower(); libSymbol->SetName( elem.text ); libSymbol->GetReferenceField().SetText( "#PWR" ); libSymbol->GetReferenceField().SetVisible( false ); diff --git a/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp index 9165b3ffda..b337641cbd 100644 --- a/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp @@ -893,7 +893,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances() wxCHECK( templatePart, /*void*/ ); kiPart = new LIB_SYMBOL( *templatePart ); - kiPart->SetPower(); + kiPart->SetGlobalPower(); kiPart->SetName( libPartName ); kiPart->GetValueField().SetText( symbolInstanceNetName ); kiPart->SetShowPinNames( false ); diff --git a/eeschema/sch_io/eagle/sch_io_eagle.cpp b/eeschema/sch_io/eagle/sch_io_eagle.cpp index 9970281cf4..a3a54d018f 100644 --- a/eeschema/sch_io/eagle/sch_io_eagle.cpp +++ b/eeschema/sch_io/eagle/sch_io_eagle.cpp @@ -1999,7 +1999,7 @@ void SCH_IO_EAGLE::loadInstance( const std::unique_ptr& aInstance, for( const SCH_PIN* pin : symbol->GetLibPins() ) m_connPoints[symbol->GetPinPhysicalPosition( pin )].emplace( pin ); - if( part->IsPower() ) + if( part->IsGlobalPower() ) m_powerPorts[ reference ] = symbol->GetField( FIELD_T::VALUE )->GetText(); symbol->ClearFlags(); @@ -2082,7 +2082,7 @@ EAGLE_LIBRARY* SCH_IO_EAGLE::loadLibrary( const ELIBRARY* aLibrary, EAGLE_LIBRAR libSymbol->SetUnitCount( gate_count ); if( gate_count == 1 && ispower ) - libSymbol->SetPower(); + libSymbol->SetGlobalPower(); // Don't set the footprint field if no package is defined in the Eagle schematic. if( edevice->package ) @@ -3346,7 +3346,7 @@ void SCH_IO_EAGLE::addImplicitConnections( SCH_SYMBOL* aSymbol, SCH_SCREEN* aScr // Normally power parts also have power input pins, // but they already force net names on the attached wires - if( aSymbol->GetLibSymbolRef()->IsPower() ) + if( aSymbol->GetLibSymbolRef()->IsGlobalPower() ) return; int unit = aSymbol->GetUnit(); diff --git a/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp b/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp index 817792ae1a..b1f459872d 100644 --- a/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp +++ b/eeschema/sch_io/easyeda/sch_easyeda_parser.cpp @@ -990,7 +990,7 @@ std::pair SCH_EASYEDA_PARSER::MakePowerSymbol( const wxString LIB_ID libId = EasyEdaToKiCadLibID( wxEmptyString, aNetname ); - ksymbol->SetPower(); + ksymbol->SetGlobalPower(); ksymbol->SetLibId( libId ); ksymbol->SetName( aNetname ); ksymbol->GetReferenceField().SetText( wxS( "#PWR" ) ); diff --git a/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp b/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp index 75ac16147a..5332f41b1b 100644 --- a/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp +++ b/eeschema/sch_io/easyedapro/sch_easyedapro_parser.cpp @@ -678,7 +678,7 @@ SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector& aLines, if( symInfo.head.symbolType == EASYEDAPRO::SYMBOL_TYPE::POWER_PORT || symInfo.head.symbolType == EASYEDAPRO::SYMBOL_TYPE::NETPORT ) { - ksymbol->SetPower(); + ksymbol->SetGlobalPower(); ksymbol->GetReferenceField().SetText( wxS( "#PWR" ) ); ksymbol->GetReferenceField().SetVisible( false ); ksymbol->SetKeyWords( wxS( "power-flag" ) ); diff --git a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp index 4187b5c517..291d85e19b 100644 --- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp +++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy.cpp @@ -2135,7 +2135,7 @@ void SCH_IO_KICAD_LEGACY::EnumerateSymbolLib( wxArrayString& aSymbolNameList, for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it ) { - if( !powerSymbolsOnly || it->second->IsPower() ) + if( !powerSymbolsOnly || it->second->IsGlobalPower() ) aSymbolNameList.Add( it->first ); } } @@ -2156,7 +2156,7 @@ void SCH_IO_KICAD_LEGACY::EnumerateSymbolLib( std::vector& aSymbolL for( LIB_SYMBOL_MAP::const_iterator it = symbols.begin(); it != symbols.end(); ++it ) { - if( !powerSymbolsOnly || it->second->IsPower() ) + if( !powerSymbolsOnly || it->second->IsGlobalPower() ) aSymbolList.push_back( it->second ); } } diff --git a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp index ede0e2574a..faf107d615 100644 --- a/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp +++ b/eeschema/sch_io/kicad_legacy/sch_io_kicad_legacy_lib_cache.cpp @@ -447,7 +447,7 @@ LIB_SYMBOL* SCH_IO_KICAD_LEGACY_LIB_CACHE::LoadPart( LINE_READER& aReader, int a tmp = tokens.GetNextToken(); if( tmp == "P" ) - symbol->SetPower(); + symbol->SetGlobalPower(); else if( tmp == "N" ) symbol->SetNormal(); else @@ -1520,7 +1520,7 @@ void SCH_IO_KICAD_LEGACY_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMA aSymbol->GetShowPinNumbers() ? 'Y' : 'N', aSymbol->GetShowPinNames() ? 'Y' : 'N', aSymbol->GetUnitCount(), aSymbol->UnitsLocked() ? 'L' : 'F', - aSymbol->IsPower() ? 'P' : 'N' ); + aSymbol->IsGlobalPower() ? 'P' : 'N' ); timestamp_t dateModified = aSymbol->GetLastModDate(); diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp index b0615ec040..ed6ae5c25a 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_lib_cache.cpp @@ -168,8 +168,10 @@ void SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMAT { aFormatter.Print( "(symbol %s", name.c_str() ); - if( aSymbol->IsPower() ) - aFormatter.Print( "(power)" ); + if( aSymbol->IsGlobalPower() ) + aFormatter.Print( "(power global)" ); + else if( aSymbol->IsLocalPower() ) + aFormatter.Print( "(power local)" ); // TODO: add uuid token here. diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp index 6e2196219a..dc1f8b37de 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp @@ -357,7 +357,17 @@ LIB_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseLibSymbol( LIB_SYMBOL_MAP& aSymbolLi switch( token ) { case T_power: - symbol->SetPower(); + symbol->SetGlobalPower(); + token = NextTok(); + + if( token == T_RIGHT ) + break; + + if( token == T_local ) + symbol->SetLocalPower(); + else if( token != T_global ) + Expecting( "global or local" ); + NeedRIGHT(); break; diff --git a/eeschema/sch_io/ltspice/sch_io_ltspice_parser.cpp b/eeschema/sch_io/ltspice/sch_io_ltspice_parser.cpp index e10481f8c4..7859e8593f 100644 --- a/eeschema/sch_io/ltspice/sch_io_ltspice_parser.cpp +++ b/eeschema/sch_io/ltspice/sch_io_ltspice_parser.cpp @@ -825,7 +825,7 @@ SCH_SYMBOL* SCH_IO_LTSPICE_PARSER::CreatePowerSymbol( const VECTOR2I& aOffset, LINE_STYLE::SOLID ) ); lib_symbol->AddDrawItem( shape ); - lib_symbol->SetPower(); + lib_symbol->SetGlobalPower(); SCH_PIN* pin = new SCH_PIN( lib_symbol ); diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index cf8370790d..c764d7a018 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -775,6 +775,51 @@ void SCH_PAINTER::drawPinDanglingIndicator( const SCH_PIN& aPin, const COLOR4D& } +/** + * Draw an local power pin indicator icon. + */ +static void drawLocalPowerIcon( GAL& aGal, const VECTOR2D& aPos, double aSize, bool aRotate, + const COLOR4D& aColor ) +{ + aGal.Save(); + + aGal.Translate( aPos ); + + if( aRotate ) + { + aGal.Rotate( ANGLE_270.AsRadians() ); + } + + aGal.SetIsFill( false ); + aGal.SetIsStroke( true ); + aGal.SetLineWidth( KiROUND( aSize / 10.0 ) ); + aGal.SetStrokeColor( aColor ); + + double x_right = aSize / 1.6180339887; + double x_middle = x_right / 2.0; + + VECTOR2D bottomPt = VECTOR2D{ x_middle, 0 }; + VECTOR2D leftPt = VECTOR2D{ 0, 2.0 * -aSize / 3.0 }; + VECTOR2D rightPt = VECTOR2D{ x_right, 2.0 * -aSize / 3.0 }; + + VECTOR2D bottomAnchorPt = VECTOR2D{ x_middle, -aSize / 4.0 }; + VECTOR2D leftSideAnchorPt1 = VECTOR2D{ 0, -aSize / 2.5 }; + VECTOR2D leftSideAnchorPt2 = VECTOR2D{ 0, -aSize * 1.15 }; + VECTOR2D rightSideAnchorPt1 = VECTOR2D{ x_right, -aSize / 2.5 }; + VECTOR2D rightSideAnchorPt2 = VECTOR2D{ x_right, -aSize * 1.15 }; + + aGal.DrawCurve( bottomPt, bottomAnchorPt, leftSideAnchorPt1, leftPt ); + aGal.DrawCurve( leftPt, leftSideAnchorPt2, rightSideAnchorPt2, rightPt ); + aGal.DrawCurve( rightPt, rightSideAnchorPt1, bottomAnchorPt, bottomPt ); + + aGal.SetIsFill( true ); + aGal.SetFillColor( aColor ); + aGal.DrawCircle( ( leftPt + rightPt ) / 2.0, aSize / 15.0 ); + + aGal.Restore(); +}; + + /** * Draw an alternate pin mode indicator icon. */ @@ -2488,6 +2533,30 @@ void SCH_PAINTER::draw( const SCH_FIELD* aField, int aLayer, bool aDimmed ) const_cast( aField )->ClearFlags( IS_SHOWN_AS_BITMAP ); } + + if( aField->GetParent() && aField->GetParent()->Type() == SCH_SYMBOL_T ) + { + SCH_SYMBOL* parent = static_cast( aField->GetParent() ); + bool rotated = !orient.IsHorizontal() && !aField->CanAutoplace(); + + VECTOR2D pos; + double size = bbox.GetHeight() / 1.5; + + if( rotated ) + { + pos = VECTOR2D( bbox.GetRight() - bbox.GetWidth() / 6.0, + bbox.GetBottom() + bbox.GetWidth() / 2.0 ); + size = bbox.GetWidth() / 1.5; + } + else + { + pos = VECTOR2D( bbox.GetLeft() - bbox.GetHeight() / 2.0, + bbox.GetBottom() - bbox.GetHeight() / 6.0 ); + } + + if( parent->IsSymbolLikePowerLocalLabel() ) + drawLocalPowerIcon( *m_gal, pos, size, rotated, m_gal->GetStrokeColor() ); + } } // Draw anchor or umbilical line diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index 9eabda564b..87de8f0bc7 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -363,7 +363,20 @@ wxString SCH_PIN::GetElectricalTypeName() const bool SCH_PIN::IsGlobalPower() const { return GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN - && ( !IsVisible() || GetParentSymbol()->IsPower() ); + && ( !IsVisible() || GetParentSymbol()->IsGlobalPower() ); +} + + +bool SCH_PIN::IsLocalPower() const +{ + return GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN + && GetParentSymbol()->IsLocalPower(); +} + + +bool SCH_PIN::IsPower() const +{ + return IsLocalPower() || IsGlobalPower(); } @@ -1220,9 +1233,11 @@ wxString SCH_PIN::GetDefaultNetName( const SCH_SHEET_PATH& aPath, bool aForceNoC // Need to check for parent as power symbol to make sure we aren't dealing // with legacy global power pins on non-power symbols - if( IsGlobalPower() ) + if( IsGlobalPower() || IsLocalPower() ) { - if( GetLibPin()->GetParentSymbol()->IsPower() ) + SYMBOL* parent = GetLibPin()->GetParentSymbol(); + + if( parent->IsGlobalPower() || parent->IsLocalPower() ) { return EscapeString( symbol->GetValue( true, &aPath, false ), CTX_NETNAME ); } diff --git a/eeschema/sch_pin.h b/eeschema/sch_pin.h index f8617f9073..2f1af13e53 100644 --- a/eeschema/sch_pin.h +++ b/eeschema/sch_pin.h @@ -193,6 +193,18 @@ public: */ bool IsGlobalPower() const; + /** + * Local power pin is the same except that it is sheet-local and it does not support the legacy + * hidden pin mode + */ + bool IsLocalPower() const; + + /** + * Check if the pin is _either_ a global or local power pin. + * @see IsGlobalPower() and IsLocalPower() + */ + bool IsPower() const; + int GetPenWidth() const override { return 0; } void Move( const VECTOR2I& aOffset ) override; diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index e6eebc66fd..2c2af04e87 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -1424,7 +1424,7 @@ void SCH_SCREEN::FixLegacyPowerSymbolMismatches() // Fix pre-8.0 legacy power symbols with invisible pins // that have mismatched pin names and value fields if( symbol->GetLibSymbolRef() - && symbol->GetLibSymbolRef()->IsPower() + && symbol->GetLibSymbolRef()->IsGlobalPower() && symbol->GetAllLibPins().size() > 0 && symbol->GetAllLibPins()[0]->IsGlobalPower() && !symbol->GetAllLibPins()[0]->IsVisible() ) diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index dc469028d2..4598d8c7d7 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -2277,8 +2277,7 @@ INSPECT_RESULT SCH_SYMBOL::Visit( INSPECTOR aInspector, void* aTestData, { for( KICAD_T scanType : aScanTypes ) { - if( scanType == SCH_LOCATE_ANY_T - || ( scanType == SCH_SYMBOL_T ) + if( scanType == SCH_LOCATE_ANY_T || ( scanType == SCH_SYMBOL_T ) || ( scanType == SCH_SYMBOL_LOCATE_POWER_T && m_part && m_part->IsPower() ) ) { if( INSPECT_RESULT::QUIT == aInspector( this, aTestData ) ) @@ -2726,7 +2725,7 @@ bool SCH_SYMBOL::IsSymbolLikePowerGlobalLabel() const // It is a Power symbol // It has only one pin type Power input - if( !GetLibSymbolRef() || !GetLibSymbolRef()->IsPower() ) + if( !GetLibSymbolRef() || !GetLibSymbolRef()->IsGlobalPower() ) return false; std::vector pin_list = GetAllLibPins(); @@ -2738,12 +2737,45 @@ bool SCH_SYMBOL::IsSymbolLikePowerGlobalLabel() const } -bool SCH_SYMBOL::IsPower() const +bool SCH_SYMBOL::IsSymbolLikePowerLocalLabel() const +{ + // return true if the symbol is equivalent to a local label: + // It is a Power symbol + // It has only one pin type Power input + + if( !GetLibSymbolRef() || !GetLibSymbolRef()->IsLocalPower() ) + return false; + + std::vector pin_list = GetAllLibPins(); + + if( pin_list.size() != 1 ) + return false; + + return pin_list[0]->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN; +} + + +bool SCH_SYMBOL::IsLocalPower() const +{ + if( !m_part ) + return false; + + return m_part->IsLocalPower(); +} + + +bool SCH_SYMBOL::IsGlobalPower() const { if( !m_part ) return false; - return m_part->IsPower(); + return m_part->IsGlobalPower(); +} + + +bool SCH_SYMBOL::IsPower() const +{ + return IsLocalPower() || IsGlobalPower(); } diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 31fa643af5..8705b7f722 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -822,7 +822,10 @@ public: * It has only one pin type Power input */ bool IsSymbolLikePowerGlobalLabel() const; + bool IsSymbolLikePowerLocalLabel() const; + bool IsGlobalPower() const override; + bool IsLocalPower() const override; bool IsPower() const override; bool IsNormal() const override; diff --git a/eeschema/schematic.keywords b/eeschema/schematic.keywords index 7fc44eb0e9..fd194f7b4c 100644 --- a/eeschema/schematic.keywords +++ b/eeschema/schematic.keywords @@ -55,6 +55,7 @@ footprint free generator generator_version +global global_label hatch header @@ -86,6 +87,7 @@ lib_name lib_symbols line line_spacing +local margins members mid diff --git a/eeschema/symbol.h b/eeschema/symbol.h index 189318e267..810dd09e13 100644 --- a/eeschema/symbol.h +++ b/eeschema/symbol.h @@ -110,6 +110,8 @@ public: virtual wxString GetDescription() const = 0; virtual wxString GetKeyWords() const = 0; + virtual bool IsGlobalPower() const = 0; + virtual bool IsLocalPower() const = 0; virtual bool IsPower() const = 0; virtual bool IsNormal() const = 0; diff --git a/eeschema/symbol_checker.cpp b/eeschema/symbol_checker.cpp index 66bc61a515..c1ac9de1a6 100644 --- a/eeschema/symbol_checker.cpp +++ b/eeschema/symbol_checker.cpp @@ -249,7 +249,7 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, else pinName = "'" + pinName + "'"; - if( !aSymbol->IsPower() + if( !aSymbol->IsGlobalPower() && pin->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN && !pin->IsVisible() ) { diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index 8fe1c2b174..d210e63cac 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -420,7 +420,7 @@ void SYMBOL_EDIT_FRAME::CreateNewSymbol( const wxString& aInheritFrom ) new_symbol.SetPinNameOffset( 0 ); } - ( dlg.GetPowerSymbol() ) ? new_symbol.SetPower() : new_symbol.SetNormal(); + ( dlg.GetPowerSymbol() ) ? new_symbol.SetGlobalPower() : new_symbol.SetNormal(); new_symbol.SetShowPinNumbers( dlg.GetShowPinNumber() ); new_symbol.SetShowPinNames( dlg.GetShowPinName() ); new_symbol.LockUnits( !dlg.GetUnitsInterchangeable() ); @@ -1757,8 +1757,10 @@ void SYMBOL_EDIT_FRAME::UpdateSymbolMsgPanelInfo() AppendMsgPanel( _( "Body" ), msg, 8 ); - if( m_symbol->IsPower() ) + if( m_symbol->IsGlobalPower() ) msg = _( "Power Symbol" ); + else if( m_symbol->IsLocalPower() ) + msg = _( "Power Symbol (Local)" ); else msg = _( "Symbol" ); diff --git a/eeschema/tools/backannotate.cpp b/eeschema/tools/backannotate.cpp index 5b498c35d6..3f4af1f458 100644 --- a/eeschema/tools/backannotate.cpp +++ b/eeschema/tools/backannotate.cpp @@ -710,7 +710,7 @@ void BACK_ANNOTATE::processNetNameChange( SCH_COMMIT* aCommit, const wxString& a SCH_PIN* schPin = static_cast( driver ); SPIN_STYLE spin = orientLabel( schPin ); - if( schPin->IsGlobalPower() ) + if( schPin->IsPower() ) { msg.Printf( _( "Net %s cannot be changed to %s because it is driven by a power pin." ), EscapeHTML( aOldName ), diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 903f2a8874..634db8a5eb 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -392,6 +392,36 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent ) GRID_HELPER_GRIDS::GRID_CONNECTABLE ); } + EESCHEMA_SETTINGS* cfg = m_frame->eeconfig(); + + if( !libSymbol->IsLocalPower() && cfg->m_Drawing.new_power_symbols == POWER_SYMBOLS::LOCAL ) + { + libSymbol->SetLocalPower(); + wxString keywords = libSymbol->GetKeyWords(); + + // Adjust the KiCad library default fields to match the new power symbol type + if( keywords.Contains( wxT( "global power" ) ) ) + { + keywords.Replace( wxT( "global power" ), wxT( "local power" ) ); + libSymbol->SetKeyWords( keywords ); + } + + wxString desc = libSymbol->GetDescription(); + + if( desc.Contains( wxT( "global label" ) ) ) + { + desc.Replace( wxT( "global label" ), wxT( "local label" ) ); + libSymbol->SetDescription( desc ); + } + } + else if( !libSymbol->IsGlobalPower() + && cfg->m_Drawing.new_power_symbols == POWER_SYMBOLS::GLOBAL ) + { + // We do not currently have local power symbols in the KiCad library, so + // don't update any fields + libSymbol->SetGlobalPower(); + } + symbol = new SCH_SYMBOL( *libSymbol, &m_frame->GetCurrentSheet(), sel, cursorPos, &m_frame->Schematic() ); addSymbol( symbol ); diff --git a/qa/tests/eeschema/test_legacy_power_symbols.cpp b/qa/tests/eeschema/test_legacy_power_symbols.cpp index 8ce69aa061..91f64dc27a 100644 --- a/qa/tests/eeschema/test_legacy_power_symbols.cpp +++ b/qa/tests/eeschema/test_legacy_power_symbols.cpp @@ -42,7 +42,7 @@ struct LEGACY_POWER_SYMBOLS_TEST_FIXTURE // Fix pre-8.0 legacy power symbols with invisible pins // that have mismatched pin names and value fields if( symbol->GetLibSymbolRef() - && symbol->GetLibSymbolRef()->IsPower() + && symbol->GetLibSymbolRef()->IsGlobalPower() && symbol->GetAllLibPins().size() > 0 && symbol->GetAllLibPins()[0]->IsGlobalPower() && !symbol->GetAllLibPins()[0]->IsVisible() ) diff --git a/qa/tests/eeschema/test_lib_part.cpp b/qa/tests/eeschema/test_lib_part.cpp index e0a842d4e5..ee7b173aa4 100644 --- a/qa/tests/eeschema/test_lib_part.cpp +++ b/qa/tests/eeschema/test_lib_part.cpp @@ -391,10 +391,10 @@ BOOST_AUTO_TEST_CASE( Compare ) m_part_no_data.SetUnitCount( 1 ); // Options flag comparison tests. - testPart.SetPower(); + testPart.SetGlobalPower(); BOOST_CHECK( m_part_no_data.Compare( testPart ) < 0 ); testPart.SetNormal(); - m_part_no_data.SetPower(); + m_part_no_data.SetGlobalPower(); BOOST_CHECK( m_part_no_data.Compare( testPart ) > 0 ); m_part_no_data.SetNormal(); @@ -678,7 +678,7 @@ BOOST_AUTO_TEST_CASE( IsPowerTest ) BOOST_CHECK( !symbol->IsPower() ); BOOST_CHECK( symbol->IsNormal() ); - symbol->SetPower(); + symbol->SetGlobalPower(); BOOST_CHECK( symbol->IsPower() ); BOOST_CHECK( !symbol->IsNormal() ); diff --git a/qa/tests/eeschema/test_sch_pin.cpp b/qa/tests/eeschema/test_sch_pin.cpp index 3349fe3320..3d2f640161 100644 --- a/qa/tests/eeschema/test_sch_pin.cpp +++ b/qa/tests/eeschema/test_sch_pin.cpp @@ -91,6 +91,7 @@ BOOST_AUTO_TEST_CASE( DefaultProperties ) BOOST_CHECK( ( m_sch_pin->GetType() == m_lib_pin->GetType() ) ); BOOST_CHECK_EQUAL( m_sch_pin->IsGlobalPower(), m_lib_pin->IsGlobalPower() ); + BOOST_CHECK_EQUAL( m_sch_pin->IsLocalPower(), m_lib_pin->IsLocalPower() ); } /** @@ -162,7 +163,7 @@ BOOST_AUTO_TEST_CASE( PinNumberingPower ) { // but if we set isPower... m_lib_pin->SetType( ELECTRICAL_PINTYPE::PT_POWER_IN ); - m_parent_part->SetPower(); + m_parent_part->SetGlobalPower(); BOOST_CHECK_EQUAL( m_lib_pin->IsGlobalPower(), true ); // and update symbol from library...