From b0ca7d5140e0cbf7f69b9fbdb6ed2fbf8aadf0e9 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 4 Jul 2020 00:28:24 +0100 Subject: [PATCH] Netclass setup for Eeschema. ADDED netclass panel in Schematic Setup dialog. Fixes https://gitlab.com/kicad/code/kicad/issues/2132 --- common/dialogs/panel_setup_netclasses.cpp | 5 ++++- common/project/net_settings.cpp | 6 ++++++ eeschema/dialogs/dialog_schematic_setup.cpp | 7 +++++++ eeschema/dialogs/dialog_schematic_setup.h | 2 ++ pcbnew/dialogs/dialog_board_setup.cpp | 2 +- 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/common/dialogs/panel_setup_netclasses.cpp b/common/dialogs/panel_setup_netclasses.cpp index dd6dcfd2db..0259788425 100644 --- a/common/dialogs/panel_setup_netclasses.cpp +++ b/common/dialogs/panel_setup_netclasses.cpp @@ -185,7 +185,10 @@ bool PANEL_SETUP_NETCLASSES::TransferDataToWindow() // add all the nets discovered in the netclass membership lists for( const std::pair& ii : netToNetclassMap ) - addNet( UnescapeString( ii.first ), ii.second ); + { + if( !ii.first.IsEmpty() ) + addNet( UnescapeString( ii.first ), ii.second ); + } return true; } diff --git a/common/project/net_settings.cpp b/common/project/net_settings.cpp index 30b87f72ec..209e281dfa 100644 --- a/common/project/net_settings.cpp +++ b/common/project/net_settings.cpp @@ -124,6 +124,12 @@ NET_SETTINGS::NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) : netclass->SetDiffPairViaGap( get( entry, "diff_pair_via_gap", netclass->GetDiffPairViaGap() ) ); + if( entry.contains( "nets" ) && entry["nets"].is_array() ) + { + for( const auto& net : entry["nets"].items() ) + netclass->Add( net.value().get() ); + } + if( netclass != defaultClass ) m_NetClasses.Add( netclass ); } diff --git a/eeschema/dialogs/dialog_schematic_setup.cpp b/eeschema/dialogs/dialog_schematic_setup.cpp index d3b3ab63e0..5cbf04aec4 100644 --- a/eeschema/dialogs/dialog_schematic_setup.cpp +++ b/eeschema/dialogs/dialog_schematic_setup.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,7 @@ #include #include #include +#include #include #include "dialog_schematic_setup.h" #include "panel_eeschema_template_fieldnames.h" @@ -50,6 +52,9 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) : m_textVars = new PANEL_TEXT_VARIABLES( m_treebook, &Prj() ); + PROJECT_FILE& project = aFrame->Prj().GetProjectFile(); + m_netclasses = new PANEL_SETUP_NETCLASSES( this, &project.NetSettings().m_NetClasses ); + /* * WARNING: If you change page names you MUST update calls to ShowSchematicSetupDialog(). */ @@ -63,6 +68,7 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) : m_treebook->AddSubPage( m_pinMap, _( "Pin Conflicts Map" ) ); m_treebook->AddPage( new wxPanel( this ), _( "Project" ) ); + m_treebook->AddSubPage( m_netclasses, _( "Net Classes" ) ); m_treebook->AddSubPage( m_textVars, _( "Text Variables" ) ); for( size_t i = 0; i < m_treebook->GetPageCount(); ++i ) @@ -96,6 +102,7 @@ void DIALOG_SCHEMATIC_SETUP::OnPageChange( wxBookCtrlEvent& event ) { wxSize pageSize = m_treebook->GetPage( page )->GetSize(); pageSize.x -= 1; + pageSize.y += 2; m_treebook->GetPage( page )->SetSize( pageSize ); m_macHack[ page ] = false; diff --git a/eeschema/dialogs/dialog_schematic_setup.h b/eeschema/dialogs/dialog_schematic_setup.h index f60d2fda39..2835ae99df 100644 --- a/eeschema/dialogs/dialog_schematic_setup.h +++ b/eeschema/dialogs/dialog_schematic_setup.h @@ -29,6 +29,7 @@ class PANEL_EESCHEMA_TEMPLATE_FIELDNAMES; class PANEL_SETUP_FORMATTING; class PANEL_SETUP_PINMAP; class PANEL_TEXT_VARIABLES; +class PANEL_SETUP_NETCLASSES; class DIALOG_SCHEMATIC_SETUP : public PAGED_DIALOG @@ -46,6 +47,7 @@ protected: PANEL_EESCHEMA_TEMPLATE_FIELDNAMES* m_fieldNameTemplates; PANEL_SETUP_PINMAP* m_pinMap; PANEL_SETUP_SEVERITIES* m_severities; + PANEL_SETUP_NETCLASSES* m_netclasses; PANEL_TEXT_VARIABLES* m_textVars; ERC_ITEM* m_pinToPinError; diff --git a/pcbnew/dialogs/dialog_board_setup.cpp b/pcbnew/dialogs/dialog_board_setup.cpp index 42728a097e..3d85f211e7 100644 --- a/pcbnew/dialogs/dialog_board_setup.cpp +++ b/pcbnew/dialogs/dialog_board_setup.cpp @@ -76,11 +76,11 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) : m_treebook->AddPage( new wxPanel( this ), _( "Design Rules" ) ); m_treebook->AddSubPage( m_constraints, _( "Constraints" ) ); - m_treebook->AddSubPage( m_netclasses, _( "Net Classes" ) ); m_treebook->AddSubPage( m_rules, _( "Rules" ) ); m_treebook->AddSubPage( m_severities, _( "Violation Severity" ) ); m_treebook->AddPage( new wxPanel( this ), _( "Project" ) ); + m_treebook->AddSubPage( m_netclasses, _( "Net Classes" ) ); m_treebook->AddSubPage( m_textVars, _( "Text Variables" ) ); for( size_t i = 0; i < m_treebook->GetPageCount(); ++i )