diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index ab3b530361..1974c73256 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -169,7 +169,6 @@ set( COMMON_DLG_SRCS dialogs/dialog_hotkey_list.cpp dialogs/dialog_image_editor.cpp dialogs/dialog_image_editor_base.cpp - dialogs/dialog_list_selector_base.cpp dialogs/dialog_migrate_settings.cpp dialogs/dialog_migrate_settings_base.cpp dialogs/dialog_page_settings_base.cpp @@ -177,6 +176,8 @@ set( COMMON_DLG_SRCS dialogs/dialog_print_generic.cpp dialogs/dialog_print_generic_base.cpp dialogs/dialog_text_entry.cpp + dialogs/eda_list_dialog.cpp + dialogs/eda_list_dialog_base.cpp dialogs/panel_color_settings_base.cpp dialogs/panel_color_settings.cpp dialogs/panel_common_settings.cpp @@ -283,7 +284,6 @@ set( COMMON_SRCS confirm.cpp cursor_store.cpp dialog_shim.cpp - displlst.cpp gr_text.cpp dsnlexer.cpp eagle_parser.cpp diff --git a/common/dialogs/dialog_list_selector_base.fbp b/common/dialogs/dialog_list_selector_base.fbp deleted file mode 100644 index d7b201114f..0000000000 --- a/common/dialogs/dialog_list_selector_base.fbp +++ /dev/null @@ -1,640 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_list_selector_base - 1000 - none - - 1 - dialog_list_selector_base - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - wxBOTH - - 1 - 1 - decl_pure_virtual - - - - 0 - wxID_ANY - - - EDA_LIST_DIALOG_BASE - - - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bSizerMain - wxVERTICAL - none - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 1 - - - bMargins - wxVERTICAL - none - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Items: - 0 - - 0 - - - 0 - - 1 - m_listLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND - 3 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - -1,200 - 1 - m_listBox - 1 - - - protected - 1 - - Resizable - 1 - - wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - wxALWAYS_SHOW_SB|wxBORDER_SIMPLE|wxVSCROLL - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - onListItemActivated - - - - - onListItemSelected - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - m_filterBox - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - textChangeInFilterBox - - - - - - - - 5 - wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Messages: - 0 - - 0 - - - 0 - - 1 - m_staticTextMsg - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - -1,80 - 1 - m_messages - 1 - - - protected - 1 - - Resizable - 1 - - wxTE_MULTILINE|wxTE_READONLY - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer - protected - - - - - - - - - - - - - - diff --git a/common/displlst.cpp b/common/dialogs/eda_list_dialog.cpp similarity index 79% rename from common/displlst.cpp rename to common/dialogs/eda_list_dialog.cpp index 021ef4bc0c..50c3eaa54a 100644 --- a/common/displlst.cpp +++ b/common/dialogs/eda_list_dialog.cpp @@ -40,14 +40,10 @@ static int DEFAULT_COL_WIDTHS[] = { 200, 600 }; EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle, const wxArrayString& aItemHeaders, const std::vector& aItemList, - const wxString& aSelection, - void( *aCallBackFunction )( wxString&, void* ), - void* aCallBackFunctionData ) : + const wxString& aSelection ) : EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle ) { - m_cb_func = aCallBackFunction; - m_cb_data = aCallBackFunctionData; - m_itemsListCp = &aItemList; + m_itemsList = &aItemList; m_filterBox->SetHint( _( "Filter" ) ); @@ -68,35 +64,28 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl } -void EDA_LIST_DIALOG::initDialog( const wxArrayString& aItemHeaders, const wxString& aSelection) +void EDA_LIST_DIALOG::initDialog( const wxArrayString& aItemHeaders, const wxString& aSelection ) { for( unsigned i = 0; i < aItemHeaders.Count(); i++ ) + { m_listBox->InsertColumn( i, aItemHeaders.Item( i ), wxLIST_FORMAT_LEFT, DEFAULT_COL_WIDTHS[ i ] ); - - InsertItems( *m_itemsListCp, 0 ); - - if( m_cb_func == NULL ) - { - m_messages->Show( false ); - m_staticTextMsg->Show( false ); } + InsertItems( *m_itemsList, 0 ); + if( !aSelection.IsEmpty() ) { - for( unsigned row = 0; row < m_itemsListCp->size(); ++row ) + long sel = m_listBox->FindItem( -1, aSelection ); + + if( sel != wxNOT_FOUND ) { - if( (*m_itemsListCp)[row][0] == aSelection ) - { - m_listBox->SetItemState( row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); + m_listBox->SetItemState( sel, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); - // Set to a small size so EnsureVisible() won't be foiled by later additions. - // ListBox will expand to fit later. - m_listBox->SetSize( m_listBox->GetSize().GetX(), 100 ); - m_listBox->EnsureVisible( row ); - - break; - } + // Set to a small size so EnsureVisible() won't be foiled by later additions. + // ListBox will expand to fit later. + m_listBox->SetSize( m_listBox->GetSize().GetX(), 100 ); + m_listBox->EnsureVisible( sel ); } } } @@ -124,14 +113,12 @@ void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event ) m_listBox->DeleteAllItems(); - for( unsigned i = 0; i < m_itemsListCp->size(); i++ ) + for( const wxArrayString& row : *m_itemsList ) { - itemName = (*m_itemsListCp)[i].Item( 0 ); + itemName = row.Item( 0 ); if( itemName.MakeLower().Matches( filter ) ) - { - Append( (*m_itemsListCp)[i] ); - } + Append( row ); } sortList(); @@ -169,9 +156,7 @@ void EDA_LIST_DIALOG::Append( const wxArrayString& itemList ) // Adding the next columns content for( unsigned i = 1; i < itemList.size(); i++ ) - { m_listBox->SetItem( itemIndex, i, itemList[i] ); - } } @@ -208,18 +193,6 @@ void EDA_LIST_DIALOG::InsertItems( const std::vector< wxArrayString >& itemList, } -void EDA_LIST_DIALOG::onListItemSelected( wxListEvent& event ) -{ - if( m_cb_func ) - { - m_messages->Clear(); - wxString text = GetTextSelection(); - m_cb_func( text, m_cb_data ); - m_messages->WriteText( text ); - } -} - - void EDA_LIST_DIALOG::onListItemActivated( wxListEvent& event ) { EndModal( wxID_OK ); diff --git a/common/dialogs/dialog_list_selector_base.cpp b/common/dialogs/eda_list_dialog_base.cpp similarity index 74% rename from common/dialogs/dialog_list_selector_base.cpp rename to common/dialogs/eda_list_dialog_base.cpp index 568db90666..25631f7b08 100644 --- a/common/dialogs/dialog_list_selector_base.cpp +++ b/common/dialogs/eda_list_dialog_base.cpp @@ -1,67 +1,57 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 2 2018) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "dialog_list_selector_base.h" +#include "eda_list_dialog_base.h" /////////////////////////////////////////////////////////////////////////// EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - + wxBoxSizer* bSizerMain; bSizerMain = new wxBoxSizer( wxVERTICAL ); - + wxBoxSizer* bMargins; bMargins = new wxBoxSizer( wxVERTICAL ); - + m_listLabel = new wxStaticText( this, wxID_ANY, _("Items:"), wxDefaultPosition, wxDefaultSize, 0 ); m_listLabel->Wrap( -1 ); bMargins->Add( m_listLabel, 0, wxALL, 5 ); - + m_listBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES|wxALWAYS_SHOW_SB|wxBORDER_SIMPLE|wxVSCROLL ); m_listBox->SetMinSize( wxSize( -1,200 ) ); - + bMargins->Add( m_listBox, 3, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - + m_filterBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bMargins->Add( m_filterBox, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_staticTextMsg = new wxStaticText( this, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextMsg->Wrap( -1 ); - bMargins->Add( m_staticTextMsg, 0, wxRIGHT|wxLEFT, 5 ); - - m_messages = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); - m_messages->SetMinSize( wxSize( -1,80 ) ); - - bMargins->Add( m_messages, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - + + bSizerMain->Add( bMargins, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - + m_sdbSizer = new wxStdDialogButtonSizer(); m_sdbSizerOK = new wxButton( this, wxID_OK ); m_sdbSizer->AddButton( m_sdbSizerOK ); m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); m_sdbSizer->AddButton( m_sdbSizerCancel ); m_sdbSizer->Realize(); - + bSizerMain->Add( m_sdbSizer, 0, wxALL|wxEXPAND, 5 ); - - + + this->SetSizer( bSizerMain ); this->Layout(); bSizerMain->Fit( this ); - + this->Centre( wxBOTH ); - + // Connect Events m_listBox->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemActivated ), NULL, this ); - m_listBox->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemSelected ), NULL, this ); m_filterBox->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this ); } @@ -69,7 +59,6 @@ EDA_LIST_DIALOG_BASE::~EDA_LIST_DIALOG_BASE() { // Disconnect Events m_listBox->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemActivated ), NULL, this ); - m_listBox->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemSelected ), NULL, this ); m_filterBox->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this ); - + } diff --git a/common/dialogs/eda_list_dialog_base.fbp b/common/dialogs/eda_list_dialog_base.fbp new file mode 100644 index 0000000000..58a6f2037f --- /dev/null +++ b/common/dialogs/eda_list_dialog_base.fbp @@ -0,0 +1,282 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + eda_list_dialog_base + 1000 + none + + 1 + eda_list_dialog_base + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + decl_pure_virtual + + + + 0 + wxID_ANY + + + EDA_LIST_DIALOG_BASE + + + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + + + + + + + + bSizerMain + wxVERTICAL + none + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 1 + + + bMargins + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Items: + 0 + + 0 + + + 0 + + 1 + m_listLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 3 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + -1,200 + 1 + m_listBox + 1 + + + protected + 1 + + Resizable + 1 + + wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + wxALWAYS_SHOW_SB|wxBORDER_SIMPLE|wxVSCROLL + onListItemActivated + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_filterBox + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + textChangeInFilterBox + + + + + + 5 + wxALL|wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer + protected + + + + + + diff --git a/common/dialogs/dialog_list_selector_base.h b/common/dialogs/eda_list_dialog_base.h similarity index 80% rename from common/dialogs/dialog_list_selector_base.h rename to common/dialogs/eda_list_dialog_base.h index 593778d45e..7cdb4d8307 100644 --- a/common/dialogs/dialog_list_selector_base.h +++ b/common/dialogs/eda_list_dialog_base.h @@ -1,12 +1,11 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 2 2018) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __DIALOG_LIST_SELECTOR_BASE_H__ -#define __DIALOG_LIST_SELECTOR_BASE_H__ +#pragma once #include #include @@ -33,28 +32,24 @@ class EDA_LIST_DIALOG_BASE : public DIALOG_SHIM { private: - + protected: wxStaticText* m_listLabel; wxListCtrl* m_listBox; wxTextCtrl* m_filterBox; - wxStaticText* m_staticTextMsg; - wxTextCtrl* m_messages; wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; wxButton* m_sdbSizerCancel; - + // Virtual event handlers, overide them in your derived class virtual void onListItemActivated( wxListEvent& event ) = 0; - virtual void onListItemSelected( wxListEvent& event ) = 0; virtual void textChangeInFilterBox( wxCommandEvent& event ) = 0; - - + + public: - - EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + + EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~EDA_LIST_DIALOG_BASE(); - + }; -#endif //__DIALOG_LIST_SELECTOR_BASE_H__ diff --git a/common/dialogs/panel_setup_netclasses.cpp b/common/dialogs/panel_setup_netclasses.cpp index 2f4a6e6ba0..f487af2635 100644 --- a/common/dialogs/panel_setup_netclasses.cpp +++ b/common/dialogs/panel_setup_netclasses.cpp @@ -47,6 +47,7 @@ enum { GRID_DIFF_PAIR_VIA_GAP }; +#define NO_NETCLASS_ASSIGNMENT _( "" ) PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, NETCLASSES* aNetclasses, const std::vector& aCandidateNetNames ) : @@ -153,7 +154,7 @@ bool PANEL_SETUP_NETCLASSES::TransferDataToWindow() std::map staleNetMap; for( const wxString& candidate : m_candidateNetNames ) - netToNetclassMap[ candidate ] = "Default"; + netToNetclassMap[ candidate ] = wxEmptyString; if( m_netclassGrid->GetNumberRows() ) m_netclassGrid->DeleteRows( 0, m_netclassGrid->GetNumberRows() ); @@ -232,6 +233,8 @@ void PANEL_SETUP_NETCLASSES::rebuildNetclassDropdowns() wxArrayString netclassNames; + netclassNames.emplace_back( NO_NETCLASS_ASSIGNMENT ); + for( int ii = 0; ii < m_netclassGrid->GetNumberRows(); ii++ ) { wxString netclassName = m_netclassGrid->GetCellValue( ii, GRID_NAME ); @@ -294,7 +297,7 @@ bool PANEL_SETUP_NETCLASSES::TransferDataFromWindow() const wxString& netname = m_membershipGrid->GetCellValue( row, 0 ); const wxString& classname = m_membershipGrid->GetCellValue( row, 1 ); - if( classname != "Default" ) + if( classname != NO_NETCLASS_ASSIGNMENT ) { const NETCLASSPTR& nc = m_netclasses->Find( classname ); diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 43adcabe06..c83d173b2b 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -31,14 +31,12 @@ #include #include #include -#include -#include -#include #include #include #include #include #include +#include #include #include #include @@ -47,13 +45,10 @@ #include #include #include -#include #include #include -#include #include #include "erc.h" -#include // For some default values #define FieldNameTemplatesKey wxT( "FieldNameTemplates" ) @@ -274,6 +269,7 @@ void SCH_EDIT_FRAME::ShowSchematicSetupDialog( const wxString& aInitialPage ) if( dlg.ShowQuasiModal() == wxID_OK ) { + Prj().GetProjectFile().NetSettings().ResolveNetClassAssignments(); SaveProjectSettings(); GetCanvas()->Refresh(); diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index dac616eb3a..e73a352898 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1491,7 +1491,7 @@ void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetConnectionForPin( this, frame->GetCurrentSheet() ); if( conn ) - conn->AppendDebugInfoToMsgPanel( aList ); + conn->AppendInfoToMsgPanel( aList ); #endif } diff --git a/eeschema/libedit/libedit.cpp b/eeschema/libedit/libedit.cpp index 061f251090..8d1eef3a11 100644 --- a/eeschema/libedit/libedit.cpp +++ b/eeschema/libedit/libedit.cpp @@ -90,7 +90,7 @@ wxString LIB_EDIT_FRAME::SelectLibraryFromList() std::vector< wxString > libNicknames = prj.SchSymbolLibTable()->GetLogicalLibs(); // Conversion from wxArrayString to vector of ArrayString - for( const auto& name : libNicknames ) + for( const wxString& name : libNicknames ) { wxArrayString item; diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 3e8ccb5aae..a30e3b3ff6 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -23,15 +23,8 @@ */ #include -#include -#include #include -#include -#include -#include #include -#include -#include #include #include #include @@ -39,7 +32,6 @@ #include #include #include "sch_painter.h" -#include // For some default values SCH_BUS_ENTRY_BASE::SCH_BUS_ENTRY_BASE( KICAD_T aType, const wxPoint& pos, bool aFlipY ) : @@ -398,13 +390,7 @@ void SCH_BUS_ENTRY_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEM return; if( auto conn = Connection( frame->GetCurrentSheet() ) ) - { -#if defined(DEBUG) - conn->AppendDebugInfoToMsgPanel( aList ); -#else conn->AppendInfoToMsgPanel( aList ); -#endif - } } diff --git a/eeschema/sch_connection.cpp b/eeschema/sch_connection.cpp index 613c9edab3..2af98db3ad 100644 --- a/eeschema/sch_connection.cpp +++ b/eeschema/sch_connection.cpp @@ -327,9 +327,6 @@ void SCH_CONNECTION::SetSuffix( const wxString& aSuffix ) void SCH_CONNECTION::AppendInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const { - if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime ) - return; - wxString msg, group_name; std::vector group_members; @@ -374,19 +371,13 @@ void SCH_CONNECTION::AppendInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const } } } -} +#if defined(DEBUG) + // These messages are not flagged as translatable, because they are only debug messages -void SCH_CONNECTION::AppendDebugInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const -{ if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime ) return; - // These messages are not flagged as translatable, because they are only debug messages - wxString msg; - - AppendInfoToMsgPanel( aList ); - if( IsBus() ) { msg.Printf( "%d", m_bus_code ); @@ -401,6 +392,7 @@ void SCH_CONNECTION::AppendDebugInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const msg.Printf( "%s at %p", driver->GetSelectMenuText( EDA_UNITS::MILLIMETRES ), driver ); aList.push_back( MSG_PANEL_ITEM( "Connection Source", msg, RED ) ); } +#endif } diff --git a/eeschema/sch_connection.h b/eeschema/sch_connection.h index c9ab585c8d..6ff75bb938 100644 --- a/eeschema/sch_connection.h +++ b/eeschema/sch_connection.h @@ -280,11 +280,6 @@ public: */ void AppendInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const; - /** - * Adds extended debug information about the connection object to aList - */ - void AppendDebugInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const; - /** * Test if \a aLabel has a bus notation. * diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 7540e4d1b0..bc9bafd87a 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -22,26 +22,21 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file sch_line.cpp - * @brief Class SCH_LINE implementation - */ - #include -#include -#include -#include +//#include +//#include +//#include #include #include -#include -#include -#include +//#include +//#include #include #include #include #include -#include #include +#include +#include SCH_LINE::SCH_LINE( const wxPoint& pos, int layer ) : @@ -778,19 +773,21 @@ void SCH_LINE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList ) SCH_EDIT_FRAME* frame = dynamic_cast( aFrame ); - if( !frame ) - return; - - if( auto conn = Connection( frame->GetCurrentSheet() ) ) + if( frame ) { -#if defined(DEBUG) - conn->AppendDebugInfoToMsgPanel( aList ); + if( SCH_CONNECTION* conn = Connection( frame->GetCurrentSheet() ) ) + { + conn->AppendInfoToMsgPanel( aList ); - msg.Printf( "%zu", m_connected_items.size() ); - aList.push_back( MSG_PANEL_ITEM( _( "Connections" ), msg, BROWN ) ); -#else - conn->AppendInfoToMsgPanel( aList ); -#endif + NET_SETTINGS& netSettings = Schematic()->Prj().GetProjectFile().NetSettings(); + const wxString& netname = conn->Name( true ); + + if( netSettings.m_NetClassAssignments.count( netname ) ) + { + const wxString& netclassName = netSettings.m_NetClassAssignments[ netname ]; + aList.push_back( MSG_PANEL_ITEM( _( "Assigned Netclass" ), netclassName, DARKRED ) ); + } + } } } diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 5722327b9d..7cab5c13c7 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -29,17 +29,12 @@ */ #include -#include -#include -#include #include #include #include #include #include #include -#include // for KiROUND -#include #include #include #include @@ -48,6 +43,8 @@ #include #include #include +#include +#include using KIGFX::SCH_RENDER_SETTINGS; @@ -716,19 +713,24 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList ) msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextWidth(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) ); -#if defined(DEBUG) - SCH_EDIT_FRAME* schframe = dynamic_cast( aFrame ); + SCH_EDIT_FRAME* frame = dynamic_cast( aFrame ); - if( schframe ) + if( frame ) { - if( auto conn = Connection( schframe->GetCurrentSheet() ) ) - conn->AppendDebugInfoToMsgPanel( aList ); + if( SCH_CONNECTION* conn = Connection( frame->GetCurrentSheet() ) ) + { + conn->AppendInfoToMsgPanel( aList ); + + NET_SETTINGS& netSettings = Schematic()->Prj().GetProjectFile().NetSettings(); + const wxString& netname = conn->Name( true ); + + if( netSettings.m_NetClassAssignments.count( netname ) ) + { + const wxString& netclassName = netSettings.m_NetClassAssignments[ netname ]; + aList.push_back( MSG_PANEL_ITEM( _( "Assigned Netclass" ), netclassName, DARKRED ) ); + } + } } - - msg.Printf( "%p", this ); - aList.push_back( MSG_PANEL_ITEM( "Object Address", msg, RED ) ); - -#endif } #if defined(DEBUG) diff --git a/eeschema/schematic.cpp b/eeschema/schematic.cpp index 31ce069691..e2dbcbd38f 100644 --- a/eeschema/schematic.cpp +++ b/eeschema/schematic.cpp @@ -198,10 +198,13 @@ std::vector SCHEMATIC::GetNetClassAssignmentCandidates() if( NET_SETTINGS::ParseBusVector( unescaped, nullptr, nullptr ) ) { // Allow netclass assignment to an entire vector. - names.emplace_back( unescaped ); + names.emplace_back( EscapeString( unescaped, CTX_NETNAME ) ); } else if( NET_SETTINGS::ParseBusGroup( unescaped, &busPrefix, &busMembers ) ) { + // Allow netclass assignment to an entire group. + names.emplace_back( EscapeString( unescaped, CTX_NETNAME ) ); + // Named bus groups generate a net prefix, unnamed ones don't if( !busPrefix.IsEmpty() ) busPrefix += wxT( "." ); diff --git a/eeschema/toolbars_sch_editor.cpp b/eeschema/toolbars_sch_editor.cpp index fba557b25c..12f4093173 100644 --- a/eeschema/toolbars_sch_editor.cpp +++ b/eeschema/toolbars_sch_editor.cpp @@ -116,7 +116,7 @@ void SCH_EDIT_FRAME::ReCreateVToolbar() // Set up toolbar m_drawToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( EE_ACTIONS::highlightNetTool, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( EE_ACTIONS::highlightNetTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->AddScaledSeparator( this ); m_drawToolBar->Add( EE_ACTIONS::placeSymbol, ACTION_TOOLBAR::TOGGLE ); diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index db5d9e98e0..a1fac5af46 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -396,6 +396,11 @@ TOOL_ACTION EE_ACTIONS::updateFieldsFromLibrary( "eeschema.InteractiveEdit.updat _( "Update Fields from Library..." ), _( "Sets symbol fields to original library values" ), update_fields_xpm ); +TOOL_ACTION EE_ACTIONS::assignNetclass( "eeschema.InteractiveEdit.assignNetclass", + AS_GLOBAL, 0, "", + _( "Assign Netclass..." ), _( "Assign a netclass to the net of the selected wire" ), + list_nets_xpm ); + TOOL_ACTION EE_ACTIONS::toggleDeMorgan( "eeschema.InteractiveEdit.toggleDeMorgan", AS_GLOBAL, 0, "", _( "DeMorgan Conversion" ), _( "Switch between DeMorgan representations" ), diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index aea27232e8..786f83bfe8 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -145,6 +145,7 @@ public: static TOOL_ACTION pinTable; static TOOL_ACTION updateFieldsFromLibrary; static TOOL_ACTION assignFootprints; + static TOOL_ACTION assignNetclass; static TOOL_ACTION showBusManager; static TOOL_ACTION schematicSetup; @@ -157,7 +158,6 @@ public: static TOOL_ACTION importFPAssignments; static TOOL_ACTION exportNetlist; static TOOL_ACTION generateBOM; - static TOOL_ACTION runSimulation; static TOOL_ACTION addSymbolToSchematic; // Library management @@ -176,9 +176,11 @@ public: static TOOL_ACTION leaveSheet; static TOOL_ACTION navigateHierarchy; - // Miscellaneous + // Global edit tools static TOOL_ACTION cleanupSheetPins; static TOOL_ACTION editTextAndGraphics; + + // Miscellaneous static TOOL_ACTION toggleHiddenPins; static TOOL_ACTION toggleHiddenFields; static TOOL_ACTION toggleSyncedPinsMode; @@ -195,6 +197,7 @@ public: static TOOL_ACTION exportSymbolAsSVG; // SPICE + static TOOL_ACTION runSimulation; static TOOL_ACTION simProbe; static TOOL_ACTION simTune; diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index ab34ee8021..2739efa817 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -156,14 +156,23 @@ bool EE_SELECTION_TOOL::Init() static KICAD_T wireOrBusTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT }; + static KICAD_T connectedTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, + SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, + SCH_SHEET_PIN_T, SCH_PIN_T, EOT }; auto wireSelection = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_WIRE_T ); auto busSelection = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_BUS_T ); auto wireOrBusSelection = E_C::MoreThan( 0 ) && E_C::OnlyTypes( wireOrBusTypes ); + auto connectedSelection = E_C::MoreThan( 0 ) && E_C::OnlyTypes( connectedTypes ); auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T ); - auto schEditCondition = [this] ( const SELECTION& aSel ) { - return !m_isLibEdit && !m_isLibView; - }; + + auto schEditCondition = + [this] ( const SELECTION& aSel ) + { + + return !m_isLibEdit && !m_isLibView; + }; + auto belowRootSheetCondition = [&]( const SELECTION& aSel ) { @@ -191,10 +200,10 @@ bool EE_SELECTION_TOOL::Init() menu.AddItem( EE_ACTIONS::drawBus, schEditCondition && EE_CONDITIONS::Empty, 100 ); menu.AddSeparator( 100 ); - menu.AddItem( EE_ACTIONS::finishWire, SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire, 100 ); + menu.AddItem( EE_ACTIONS::finishWire, SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire, 100 ); menu.AddSeparator( 100 ); - menu.AddItem( EE_ACTIONS::finishBus, SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus, 100 ); + menu.AddItem( EE_ACTIONS::finishBus, SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus, 100 ); menu.AddSeparator( 200 ); menu.AddItem( EE_ACTIONS::selectConnection, wireOrBusSelection && EE_CONDITIONS::Idle, 250 ); @@ -205,6 +214,7 @@ bool EE_SELECTION_TOOL::Init() menu.AddItem( EE_ACTIONS::breakWire, wireSelection && EE_CONDITIONS::Idle, 250 ); menu.AddItem( EE_ACTIONS::breakBus, busSelection && EE_CONDITIONS::Idle, 250 ); menu.AddItem( EE_ACTIONS::importSheetPin, sheetSelection && EE_CONDITIONS::Idle, 250 ); + menu.AddItem( EE_ACTIONS::assignNetclass, connectedSelection && EE_CONDITIONS::Idle, 250 ); menu.AddSeparator( 400 ); menu.AddItem( EE_ACTIONS::symbolProperties, havePartCondition && EE_CONDITIONS::Empty, 400 ); diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 2671908081..67302ac691 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -36,6 +36,8 @@ #include #include #include +#include +#include #include #include #include @@ -56,9 +58,8 @@ #include #include #include -#include // for KiROUND #include - +#include int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent ) { @@ -900,6 +901,83 @@ int SCH_EDITOR_CONTROL::ClearHighlight( const TOOL_EVENT& aEvent ) } +int SCH_EDITOR_CONTROL::AssignNetclass( const TOOL_EVENT& aEvent ) +{ + EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool(); + KIGFX::VIEW_CONTROLS* controls = getViewControls(); + VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) ); + + // Remove selection in favour of highlighting so the whole net is highlighted + selectionTool->ClearSelection(); + highlightNet( m_toolMgr, cursorPos ); + + const SCH_CONNECTION* conn = m_frame->GetHighlightedConnection(); + + if( conn ) + { + wxString netName = conn->Name( true ); + + if( conn->Name( true ).IsEmpty() ) + { + DisplayError( m_frame, _( "Net must be labelled to assign a netclass." ) ); + highlightNet( m_toolMgr, CLEAR ); + return 0; + } + + NET_SETTINGS& netSettings = m_frame->Schematic().Prj().GetProjectFile().NetSettings(); + wxString netclassName = netSettings.m_NetClassAssignments[ netName ]; + + wxArrayString headers; + std::vector items; + + headers.Add( _( "Netclasses" ) ); + + wxArrayString defaultItem; + defaultItem.Add( _( "Default" ) ); + items.emplace_back( defaultItem ); + + for( const auto& ii : netSettings.m_NetClasses ) + { + wxArrayString item; + item.Add( ii.first ); + items.emplace_back( item ); + } + + EDA_LIST_DIALOG dlg( m_frame, _( "Assign Netclass" ), headers, items, netclassName ); + dlg.SetListLabel( _( "Select netclass:" ) ); + + if( dlg.ShowModal() == wxID_OK ) + { + netclassName = dlg.GetTextSelection(); + + // Remove from old netclass membership list + if( netSettings.m_NetClassAssignments.count( netName ) ) + { + const wxString oldNetclassName = netSettings.m_NetClassAssignments[ netName ]; + NETCLASSPTR oldNetclass = netSettings.m_NetClasses.Find( oldNetclassName ); + + if( oldNetclass ) + oldNetclass->Remove( netName ); + } + + // Add to new netclass membership list + NETCLASSPTR newNetclass = netSettings.m_NetClasses.Find( netclassName ); + + if( newNetclass ) + { + newNetclass->Add( netName ); + } + + netSettings.m_NetClassAssignments[ netName ] = netclassName; + netSettings.ResolveNetClassAssignments(); + } + } + + highlightNet( m_toolMgr, CLEAR ); + return 0; +} + + int SCH_EDITOR_CONTROL::UpdateNetHighlighting( const TOOL_EVENT& aEvent ) { SCH_SCREEN* screen = m_frame->GetCurrentSheet().LastScreen(); @@ -1676,6 +1754,8 @@ void SCH_EDITOR_CONTROL::setTransitions() Go( &SCH_EDITOR_CONTROL::UpdateNetHighlighting, EE_ACTIONS::updateNetHighlighting.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::ClearHighlight, ACTIONS::cancelInteractive.MakeEvent() ); + Go( &SCH_EDITOR_CONTROL::AssignNetclass, EE_ACTIONS::assignNetclass.MakeEvent() ); + Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() ); diff --git a/eeschema/tools/sch_editor_control.h b/eeschema/tools/sch_editor_control.h index f15ef1f691..2002ed1dec 100644 --- a/eeschema/tools/sch_editor_control.h +++ b/eeschema/tools/sch_editor_control.h @@ -104,6 +104,8 @@ public: ///> Launches a tool to highlight nets. int HighlightNetCursor( const TOOL_EVENT& aEvent ); + int AssignNetclass( const TOOL_EVENT& aEvent ); + int Undo( const TOOL_EVENT& aEvent ); int Redo( const TOOL_EVENT& aEvent ); diff --git a/include/dialog_helpers.h b/include/dialog_helpers.h index 29af96ab25..5a175a80fb 100644 --- a/include/dialog_helpers.h +++ b/include/dialog_helpers.h @@ -32,7 +32,7 @@ #define DIALOG_HELPERS_H_ -#include <../common/dialogs/dialog_list_selector_base.h> +#include <../common/dialogs/eda_list_dialog_base.h> #include // EDA_UNITS void ConvertMarkdown2Html( const wxString& aMarkdownInput, wxString& aHtmlOutput ); @@ -59,23 +59,19 @@ public: * @param aItemHeaders an optional array containing the column header names for the dialog. * @param aItemList = A wxArrayString of the list of elements. * @param aRefText = An item name if an item must be preselected. - * @param aCallBackFunction = callback function to display comments - * @param aCallBackFunctionData = a pointer to pass to @a aCallBackFunction */ EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle, const wxArrayString& aItemHeaders, const std::vector& aItemList, - const wxString& aRefText, - void (* aCallBackFunction)( wxString& text, void* data ) = NULL, - void* aCallBackFunctionData = NULL ); + const wxString& aRefText ); // ~EDA_LIST_DIALOG() {} - void SetListLabel( const wxString& aLabel ); - void SetOKLabel( const wxString& aLabel ); + void SetListLabel( const wxString& aLabel ); + void SetOKLabel( const wxString& aLabel ); - void Append( const wxArrayString& aItemStr ); - void InsertItems( const std::vector& aItemList, int aPosition = 0 ); + void Append( const wxArrayString& aItemStr ); + void InsertItems( const std::vector& aItemList, int aPosition = 0 ); /** * Function GetTextSelection @@ -87,16 +83,14 @@ public: wxString GetTextSelection( int aColumn = 0 ); private: - void onListItemSelected( wxListEvent& event ) override; - void onListItemActivated( wxListEvent& event ) override; - void textChangeInFilterBox(wxCommandEvent& event) override; + void onListItemActivated( wxListEvent& event ) override; + void textChangeInFilterBox(wxCommandEvent& event) override; - void initDialog( const wxArrayString& aItemHeaders, - const wxString& aSelection); - void sortList(); - void (* m_cb_func)( wxString& text, void* data ); - void* m_cb_data; - const std::vector* m_itemsListCp; + void initDialog( const wxArrayString& aItemHeaders, const wxString& aSelection); + void sortList(); + +private: + const std::vector* m_itemsList; }; @@ -117,7 +111,7 @@ private: public: EDA_POSITION_CTRL( wxWindow* parent, const wxString& title, const wxPoint& pos_to_edit, - EDA_UNITS user_unit, wxBoxSizer* BoxSizer ); + EDA_UNITS user_unit, wxBoxSizer* BoxSizer ); ~EDA_POSITION_CTRL(); @@ -135,7 +129,7 @@ class EDA_SIZE_CTRL : public EDA_POSITION_CTRL { public: EDA_SIZE_CTRL( wxWindow* parent, const wxString& title, const wxSize& size_to_edit, - EDA_UNITS user_unit, wxBoxSizer* BoxSizer ); + EDA_UNITS user_unit, wxBoxSizer* BoxSizer ); ~EDA_SIZE_CTRL() { } wxSize GetValue(); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index a0c7081a00..f168dbe308 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -23,13 +23,11 @@ #include #include #include -#include #include #include <3d_viewer/eda_3d_viewer.h> #include #include #include -#include #include #include #include @@ -49,10 +47,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -650,6 +648,8 @@ void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage, const w if( dlg.ShowQuasiModal() == wxID_OK ) { + Prj().GetProjectFile().NetSettings().ResolveNetClassAssignments(); + GetBoard()->SynchronizeNetsAndNetClasses(); GetBoard()->GetDesignSettings().SetCurrentNetClass( NETCLASS::Default ); SaveProjectSettings();