From bfd8a628525ca454ad9040b55a63b0d986b6970d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 7 Nov 2020 14:31:50 +0000 Subject: [PATCH] Formatting and naming conventions. --- common/footprint_info.cpp | 27 ++---- common/lib_tree_model_adapter.h | 6 -- common/widgets/lib_tree.cpp | 3 +- common/widgets/lib_tree.h | 14 +-- cvpcb/auto_associate.cpp | 77 +++++++-------- cvpcb/cvpcb_mainframe.cpp | 91 +++++++++--------- cvpcb/display_footprints_frame.cpp | 45 +++++---- cvpcb/display_footprints_frame.h | 2 +- eeschema/dialogs/dialog_choose_component.cpp | 2 +- eeschema/dialogs/dialog_choose_component.h | 5 +- .../dialogs/dialog_edit_components_libid.cpp | 8 +- eeschema/getpart.cpp | 48 +++++----- eeschema/lib_view_frame.cpp | 7 +- eeschema/sch_base_frame.h | 29 +++--- eeschema/sch_component.cpp | 2 +- eeschema/sch_component.h | 4 +- eeschema/sch_screen.h | 4 +- .../symbol_editor/symbol_library_manager.h | 34 ++++--- eeschema/symbol_tree_model_adapter.cpp | 7 +- eeschema/symbol_tree_model_adapter.h | 3 +- .../symbol_tree_synchronizing_adapter.cpp | 8 +- eeschema/symbol_tree_synchronizing_adapter.h | 3 +- eeschema/tools/sch_drawing_tools.cpp | 11 +-- eeschema/tools/sch_drawing_tools.h | 14 +-- include/footprint_info.h | 23 ++--- pcbnew/dialogs/dialog_choose_footprint.cpp | 2 +- pcbnew/dialogs/dialog_choose_footprint.h | 2 +- pcbnew/footprint_edit_frame.h | 9 +- pcbnew/footprint_editor_utils.cpp | 2 +- pcbnew/fp_tree_model_adapter.cpp | 18 ++-- pcbnew/fp_tree_model_adapter.h | 3 +- pcbnew/fp_tree_synchronizing_adapter.cpp | 7 +- pcbnew/fp_tree_synchronizing_adapter.h | 3 +- pcbnew/load_select_footprint.cpp | 94 +++++++++---------- pcbnew/pcb_edit_frame.cpp | 2 +- pcbnew/tools/pcb_editor_control.cpp | 2 +- 36 files changed, 317 insertions(+), 304 deletions(-) diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp index 795371ef30..bfb27d8f35 100644 --- a/common/footprint_info.cpp +++ b/common/footprint_info.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2011 Jean-Pierre Charras, * Copyright (C) 2013-2016 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -31,35 +31,31 @@ #include #include #include -#include #include #include #include #include -#include #include #include -#include -#include -FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aLibNickname, - const wxString& aFootprintName ) +FOOTPRINT_INFO* FOOTPRINT_LIST::GetFootprintInfo( const wxString& aLibNickname, + const wxString& aFootprintName ) { if( aFootprintName.IsEmpty() ) return NULL; - for( auto& fp : m_list ) + for( std::unique_ptr& fp : m_list ) { if( aLibNickname == fp->GetLibNickname() && aFootprintName == fp->GetFootprintName() ) - return &*fp; + return fp.get(); } return NULL; } -FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aFootprintName ) +FOOTPRINT_INFO* FOOTPRINT_LIST::GetFootprintInfo( const wxString& aFootprintName ) { if( aFootprintName.IsEmpty() ) return NULL; @@ -69,7 +65,7 @@ FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aFootprintName ) wxCHECK_MSG( fpid.Parse( aFootprintName, LIB_ID::ID_PCB ) < 0, NULL, wxString::Format( wxT( "\"%s\" is not a valid LIB_ID." ), aFootprintName ) ); - return GetModuleInfo( fpid.GetLibNickname(), fpid.GetLibItemName() ); + return GetFootprintInfo( fpid.GetLibNickname(), fpid.GetLibItemName()); } @@ -79,9 +75,6 @@ bool FOOTPRINT_INFO::InLibrary( const wxString& aLibrary ) const } -/** - * Less than operator implementation for FOOTPRINT_INFO - */ bool operator<( const FOOTPRINT_INFO& lhs, const FOOTPRINT_INFO& rhs ) { int retv = StrNumCmp( lhs.m_nickname, rhs.m_nickname, false ); @@ -110,7 +103,7 @@ void FOOTPRINT_LIST::DisplayErrors( wxTopLevelWindow* aWindow ) wxString msg; - while( auto error = PopError() ) + while( const std::unique_ptr& error = PopError() ) { wxString tmp = error->Problem(); @@ -180,8 +173,8 @@ void FOOTPRINT_ASYNC_LOADER::SetList( FOOTPRINT_LIST* aList ) } -void FOOTPRINT_ASYNC_LOADER::Start( - FP_LIB_TABLE* aTable, wxString const* aNickname, unsigned aNThreads ) +void FOOTPRINT_ASYNC_LOADER::Start( FP_LIB_TABLE* aTable, wxString const* aNickname, + unsigned aNThreads ) { // Capture the FP_LIB_TABLE into m_last_table. Formatting it as a string instead of storing the // raw data avoids having to pull in the FP-specific parts. diff --git a/common/lib_tree_model_adapter.h b/common/lib_tree_model_adapter.h index eb841b2b47..25d8096404 100644 --- a/common/lib_tree_model_adapter.h +++ b/common/lib_tree_model_adapter.h @@ -97,12 +97,6 @@ class EDA_BASE_FRAME; class LIB_TREE_MODEL_ADAPTER: public wxDataViewModel { public: - - /** - * Reference-counting container for a pointer to CMP_TREE_MODEL_ADAPTER_BASE. - */ - typedef wxObjectDataPtr PTR; - /** * Destructor. Do NOT delete this class manually; it is reference-counted * by wxObject. diff --git a/common/widgets/lib_tree.cpp b/common/widgets/lib_tree.cpp index 031897f672..1efd2e176d 100644 --- a/common/widgets/lib_tree.cpp +++ b/common/widgets/lib_tree.cpp @@ -32,7 +32,8 @@ #include -LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable, LIB_TREE_MODEL_ADAPTER::PTR& aAdapter, +LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable, + wxObjectDataPtr& aAdapter, WIDGETS aWidgets, wxHtmlWindow* aDetails ) : wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS | wxTAB_TRAVERSAL | wxNO_BORDER ), diff --git a/common/widgets/lib_tree.h b/common/widgets/lib_tree.h index 1eabbf7a95..f29f0d1f81 100644 --- a/common/widgets/lib_tree.h +++ b/common/widgets/lib_tree.h @@ -55,7 +55,8 @@ public: * @param aDetails if not null, a custom wxHtmlWindow to hold symbol details. If null this * will be created inside the LIB_TREE. */ - LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable, LIB_TREE_MODEL_ADAPTER::PTR& aAdapter, + LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable, + wxObjectDataPtr& aAdapter, WIDGETS aWidgets = ALL, wxHtmlWindow *aDetails = nullptr ); ~LIB_TREE() override; @@ -166,12 +167,13 @@ protected: void onContextMenu( wxDataViewEvent& aEvent ); protected: - LIB_TABLE* m_lib_table; - LIB_TREE_MODEL_ADAPTER::PTR m_adapter; + LIB_TABLE* m_lib_table; - wxTextCtrl* m_query_ctrl; - wxDataViewCtrl* m_tree_ctrl; - wxHtmlWindow* m_details_ctrl; + wxObjectDataPtr m_adapter; + + wxTextCtrl* m_query_ctrl; + wxDataViewCtrl* m_tree_ctrl; + wxHtmlWindow* m_details_ctrl; }; ///> Custom event sent when a new component is preselected diff --git a/cvpcb/auto_associate.cpp b/cvpcb/auto_associate.cpp index 5892c0db85..5cc3b642ed 100644 --- a/cvpcb/auto_associate.cpp +++ b/cvpcb/auto_associate.cpp @@ -76,7 +76,8 @@ bool sortListbyCmpValue( const FOOTPRINT_EQUIVALENCE& ref, const FOOTPRINT_EQUIV // read the .equ files and populate the list of equivalents -int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wxString * aErrorMessages ) +int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, + wxString* aErrorMessages ) { char line[1024]; int error_count = 0; @@ -89,7 +90,7 @@ int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wx // Find equivalences in all available files, and populates the // equiv_List with all equivalences found in .equ files - for( const auto& equfile : project.m_EquivalenceFiles ) + for( const wxString& equfile : project.m_EquivalenceFiles ) { fn = wxExpandEnvVars( equfile ); @@ -103,7 +104,7 @@ int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wx { error_msg.Printf( _( "Equivalence file \"%s\" could not be found in the " "default search paths." ), - fn.GetFullName() ); + fn.GetFullName() ); if( ! aErrorMessages->IsEmpty() ) *aErrorMessages << wxT("\n\n"); @@ -166,26 +167,25 @@ int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wx void CVPCB_MAINFRAME::AutomaticFootprintMatching() { - FOOTPRINT_EQUIVALENCE_LIST equiv_List; - wxString msg, error_msg; + FOOTPRINT_EQUIVALENCE_LIST equivList; + wxString msg; + wxString error_msg; if( m_netlist.IsEmpty() ) return; - if( buildEquivalenceList( equiv_List, &error_msg ) ) - wxMessageBox( error_msg, _( "Equivalence File Load Error" ), wxOK | wxICON_WARNING, this ); + if( buildEquivalenceList( equivList, &error_msg ) ) + wxMessageBox( error_msg, _( "Equivalence File Load Error" ), wxOK | wxICON_WARNING, this ); - // Sort the association list by component value. - // When sorted, find duplicate definitions (i.e. 2 or more items - // having the same component value) is more easy. - std::sort( equiv_List.begin(), equiv_List.end(), sortListbyCmpValue ); + // Sort the association list by symbol value. When sorted, finding duplicate definitions + // (i.e. 2 or more items having the same symbol value) is easier. + std::sort( equivList.begin(), equivList.end(), sortListbyCmpValue ); - // Display the number of footprint/component equivalences. - msg.Printf( _( "%lu footprint/cmp equivalences found." ), (unsigned long)equiv_List.size() ); + // Display the number of footprint/symbol equivalences. + msg.Printf( _( "%lu footprint/symbol equivalences found." ), (unsigned long)equivList.size() ); SetStatusText( msg, 0 ); - // Now, associate each free component with a footprint, when the association - // is found in list + // Now, associate each free component with a footprint m_skipComponentSelect = true; error_msg.Empty(); @@ -201,36 +201,40 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching() // Here a first attempt is made. We can have multiple equivItem of the same value. // When happens, using the footprint filter of components can remove the ambiguity by - // filtering equivItem so one can use multiple equiv_List (for polar and - // non-polar caps for example) + // filtering equivItem so one can use multiple equivList (for polar and non-polar caps + // for example) wxString fpid_candidate; - for( unsigned idx = 0; idx < equiv_List.size(); idx++ ) + for( unsigned idx = 0; idx < equivList.size(); idx++ ) { - FOOTPRINT_EQUIVALENCE& equivItem = equiv_List[idx]; + FOOTPRINT_EQUIVALENCE& equivItem = equivList[idx]; if( equivItem.m_ComponentValue.CmpNoCase( component->GetValue() ) != 0 ) continue; - const FOOTPRINT_INFO *module = m_FootprintsList->GetModuleInfo( equivItem.m_FootprintFPID ); + const FOOTPRINT_INFO *fp = m_FootprintsList->GetFootprintInfo( equivItem.m_FootprintFPID ); bool equ_is_unique = true; unsigned next = idx+1; int previous = idx-1; - if( next < equiv_List.size() && - equivItem.m_ComponentValue == equiv_List[next].m_ComponentValue ) + if( next < equivList.size() + && equivItem.m_ComponentValue == equivList[next].m_ComponentValue ) + { equ_is_unique = false; + } - if( previous >= 0 && - equivItem.m_ComponentValue == equiv_List[previous].m_ComponentValue ) + if( previous >= 0 + && equivItem.m_ComponentValue == equivList[previous].m_ComponentValue ) + { equ_is_unique = false; + } // If the equivalence is unique, no ambiguity: use the association - if( module && equ_is_unique ) + if( fp && equ_is_unique ) { AssociateFootprint( CVPCB_ASSOCIATION( kk, equivItem.m_FootprintFPID ), - firstAssoc ); + firstAssoc ); firstAssoc = false; found = true; break; @@ -238,27 +242,25 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching() // Store the first candidate found in list, when equivalence is not unique // We use it later. - if( module && fpid_candidate.IsEmpty() ) + if( fp && fpid_candidate.IsEmpty() ) fpid_candidate = equivItem.m_FootprintFPID; // The equivalence is not unique: use the footprint filter to try to remove // ambiguity // if the footprint filter does not remove ambiguity, we will use fpid_candidate - if( module ) + if( fp ) { size_t filtercount = component->GetFootprintFilters().GetCount(); found = ( 0 == filtercount ); // if no entries, do not filter for( size_t jj = 0; jj < filtercount && !found; jj++ ) - { - found = module->GetFootprintName().Matches( component->GetFootprintFilters()[jj] ); - } + found = fp->GetFootprintName().Matches( component->GetFootprintFilters()[jj] ); } else { msg.Printf( _( "Component %s: footprint %s not found in any of the project " "footprint libraries." ), - component->GetReference(), equivItem.m_FootprintFPID ); + component->GetReference(), equivItem.m_FootprintFPID ); if( ! error_msg.IsEmpty() ) error_msg << wxT("\n\n"); @@ -268,14 +270,17 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching() if( found ) { - AssociateFootprint( CVPCB_ASSOCIATION( kk, equivItem.m_FootprintFPID ), firstAssoc ); + AssociateFootprint( CVPCB_ASSOCIATION( kk, equivItem.m_FootprintFPID ), + firstAssoc ); firstAssoc = false; break; } } if( found ) + { continue; + } else if( !fpid_candidate.IsEmpty() ) { AssociateFootprint( CVPCB_ASSOCIATION( kk, fpid_candidate ), firstAssoc ); @@ -288,12 +293,10 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching() { // we do not need to analyze wildcards: single footprint do not // contain them and if there are wildcards it just will not match any - const FOOTPRINT_INFO* module = m_FootprintsList->GetModuleInfo( component->GetFootprintFilters()[0] ); - - if( module ) + if( m_FootprintsList->GetFootprintInfo( component->GetFootprintFilters()[0] ) ) { AssociateFootprint( CVPCB_ASSOCIATION( kk, component->GetFootprintFilters()[0] ), - firstAssoc ); + firstAssoc ); firstAssoc = false; } } diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index 0adf9af638..a96d22021d 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -280,25 +280,23 @@ void CVPCB_MAINFRAME::setupUIConditions() mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) ); mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) ); - #define filterActive( filter ) ( m_filteringOptions & filter ) - auto compFilter = - [this] ( const SELECTION& ) - { - return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_FP_FILTERS; - }; + [this] ( const SELECTION& ) + { + return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_FP_FILTERS; + }; auto libFilter = - [this] ( const SELECTION& ) - { - return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY; - }; + [this] ( const SELECTION& ) + { + return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY; + }; auto pinFilter = - [this] ( const SELECTION& ) - { - return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT; - }; + [this] ( const SELECTION& ) + { + return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT; + }; mgr->SetConditions( CVPCB_ACTIONS::FilterFPbyFPFilters, CHECK( compFilter ) ); mgr->SetConditions( CVPCB_ACTIONS::FilterFPbyLibrary, CHECK( libFilter ) ); @@ -363,10 +361,10 @@ void CVPCB_MAINFRAME::setupEventHandlers() // Just skip the resize events Bind( wxEVT_SIZE, - []( wxSizeEvent& aEvent ) - { - aEvent.Skip(); - } ); + []( wxSizeEvent& aEvent ) + { + aEvent.Skip(); + } ); // Attach the events to the tool dispatcher Bind( wxEVT_TOOL, &TOOL_DISPATCHER::DispatchWxCommand, m_toolDispatcher ); @@ -388,7 +386,10 @@ bool CVPCB_MAINFRAME::canCloseWindow( wxCloseEvent& aEvent ) if( !HandleUnsavedChanges( this, _( "Symbol to Footprint links have been modified. " "Save changes?" ), - [&]()->bool { return SaveFootprintAssociation( false ); } ) ) + [&]() -> bool + { + return SaveFootprintAssociation( false ); + } ) ) { return false; } @@ -400,7 +401,6 @@ bool CVPCB_MAINFRAME::canCloseWindow( wxCloseEvent& aEvent ) void CVPCB_MAINFRAME::doCloseWindow() { - // Close module display frame if( GetFootprintViewerFrame() ) GetFootprintViewerFrame()->Close( true ); @@ -447,7 +447,7 @@ void CVPCB_MAINFRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { EDA_BASE_FRAME::LoadSettings( aCfg ); - auto cfg = static_cast( aCfg ); + CVPCB_SETTINGS* cfg = static_cast( aCfg ); m_filteringOptions = cfg->m_FilterFootprint; } @@ -457,7 +457,7 @@ void CVPCB_MAINFRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) { EDA_BASE_FRAME::SaveSettings( aCfg ); - auto cfg = static_cast( aCfg ); + CVPCB_SETTINGS* cfg = static_cast( aCfg ); cfg->m_FilterFootprint = m_filteringOptions; cfg->m_LibrariesWidth = m_libListBox->GetSize().x; @@ -496,6 +496,7 @@ void CVPCB_MAINFRAME::RedoAssociation() // Iterate over the entries to undo bool firstAssoc = true; + for( const auto& assoc : curEntry ) { AssociateFootprint( assoc, firstAssoc ); @@ -564,16 +565,19 @@ void CVPCB_MAINFRAME::AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation, { // Create a new entry for this association CVPCB_UNDO_REDO_ENTRIES newEntry; - newEntry.emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(), oldFpid, - aAssociation.GetNewFootprint() ) ); + newEntry.emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(), oldFpid, + aAssociation.GetNewFootprint() ) ); m_undoList.emplace_back( newEntry ); // Clear the redo list m_redoList.clear(); } else + { m_undoList.back().emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(), - oldFpid, aAssociation.GetNewFootprint() ) ); + oldFpid, + aAssociation.GetNewFootprint() ) ); + } } @@ -588,8 +592,7 @@ void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component ) { // Tell AuiMgr that objects are changed ! if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized - // (could be not the case when starting CvPcb - m_auimgr.Update(); + m_auimgr.Update(); // (could be not the case when starting CvPcb) if( component == NULL ) { @@ -604,19 +607,19 @@ void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component ) // selected footprint. if( FindFocus() == m_compListBox || FindFocus() == m_libListBox ) { - wxString module = FROM_UTF8( component->GetFPID().Format().c_str() ); + wxString footprintName = FROM_UTF8( component->GetFPID().Format().c_str() ); m_footprintListBox->SetSelection( m_footprintListBox->GetSelection(), false ); for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ ) { - wxString footprintName; + wxString candidateName; wxString msg = m_footprintListBox->OnGetItemText( ii, 0 ); msg.Trim( true ); msg.Trim( false ); - footprintName = msg.AfterFirst( wxChar( ' ' ) ); + candidateName = msg.AfterFirst( wxChar( ' ' ) ); - if( module.Cmp( footprintName ) == 0 ) + if( footprintName.Cmp( candidateName ) == 0 ) { m_footprintListBox->SetSelection( ii, true ); break; @@ -731,13 +734,13 @@ void CVPCB_MAINFRAME::DisplayStatus() msg.Empty(); wxString footprintName = GetSelectedFootprint(); - FOOTPRINT_INFO* module = m_FootprintsList->GetModuleInfo( footprintName ); + FOOTPRINT_INFO* fp = m_FootprintsList->GetFootprintInfo( footprintName ); - if( module ) // can be NULL if no netlist loaded + if( fp ) // can be NULL if no netlist loaded { msg = wxString::Format( _( "Description: %s; Keywords: %s" ), - module->GetDescription(), - module->GetKeywords() ); + fp->GetDescription(), + fp->GetKeywords() ); } SetStatusText( msg, 1 ); @@ -746,10 +749,10 @@ void CVPCB_MAINFRAME::DisplayStatus() wxString lib; // Choose the footprint to get the information on - if( module ) + if( fp ) { // Use the footprint in the footprint viewer - lib = module->GetLibNickname(); + lib = fp->GetLibNickname(); } else if( GetFocusedControl() == CVPCB_MAINFRAME::CONTROL_COMPONENT ) { @@ -882,8 +885,8 @@ void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX() wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ) ); } - m_footprintListBox->SetFootprints( *m_FootprintsList, wxEmptyString, NULL, - wxEmptyString, FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST ); + m_footprintListBox->SetFootprints( *m_FootprintsList, wxEmptyString, NULL, wxEmptyString, + FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST ); DisplayStatus(); } @@ -986,6 +989,7 @@ std::vector CVPCB_MAINFRAME::GetComponentIndices( CVPCB_MAINFRAME::CRITERIA aCriteria ) { std::vector idx; + int lastIdx; // Make sure a netlist has been loaded and the box has contents if( m_netlist.IsEmpty() || m_compListBox->GetCount() == 0 ) @@ -999,13 +1003,12 @@ std::vector CVPCB_MAINFRAME::GetComponentIndices( break; case CVPCB_MAINFRAME::SEL_COMPONENTS: - { // Check to see if anything is selected if( m_compListBox->GetSelectedItemCount() < 1 ) break; // Get the components - int lastIdx = m_compListBox->GetFirstSelected(); + lastIdx = m_compListBox->GetFirstSelected(); idx.emplace_back( lastIdx ); lastIdx = m_compListBox->GetNextSelected( lastIdx ); @@ -1015,7 +1018,7 @@ std::vector CVPCB_MAINFRAME::GetComponentIndices( lastIdx = m_compListBox->GetNextSelected( lastIdx ); } break; - } + case CVPCB_MAINFRAME::NA_COMPONENTS: for( unsigned int i = 0; i < m_netlist.GetCount(); i++ ) { @@ -1043,8 +1046,8 @@ std::vector CVPCB_MAINFRAME::GetComponentIndices( DISPLAY_FOOTPRINTS_FRAME* CVPCB_MAINFRAME::GetFootprintViewerFrame() const { // returns the Footprint Viewer frame, if exists, or NULL - return dynamic_cast - ( wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME ) ); + wxWindow* window = wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME ); + return dynamic_cast( window ); } diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index 2fae56218f..a8560aa41a 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -206,10 +206,10 @@ void DISPLAY_FOOTPRINTS_FRAME::setupUIConditions() auto autoZoomCond = - [this] ( const SELECTION& aSel ) - { - return GetAutoZoom(); - }; + [this] ( const SELECTION& aSel ) + { + return GetAutoZoom(); + }; mgr->SetConditions( PCB_ACTIONS::zoomFootprintAutomatically, CHECK( autoZoomCond ) ); mgr->SetConditions( PCB_ACTIONS::showPadNumbers, CHECK( cond.PadNumbersDisplay() ) ); @@ -241,7 +241,8 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateOptToolbar() } else { - m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize, + m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition, + wxDefaultSize, KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL ); m_optionsToolBar->SetAuiManager( &m_auimgr ); } @@ -301,8 +302,7 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar() // Grid selection choice box. if( !m_gridSelectBox ) - m_gridSelectBox = new wxChoice( m_mainToolBar, ID_ON_GRID_SELECT, - wxDefaultPosition, wxDefaultSize, 0, NULL ); + m_gridSelectBox = new wxChoice( m_mainToolBar, ID_ON_GRID_SELECT ); UpdateGridSelectBox(); m_mainToolBar->AddControl( m_gridSelectBox ); @@ -311,8 +311,7 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar() // Zoom selection choice box. if( !m_zoomSelectBox ) - m_zoomSelectBox = new wxChoice( m_mainToolBar, ID_ON_ZOOM_SELECT, - wxDefaultPosition, wxDefaultSize, 0, NULL ); + m_zoomSelectBox = new wxChoice( m_mainToolBar, ID_ON_ZOOM_SELECT ); UpdateZoomSelectBox(); m_mainToolBar->AddControl( m_zoomSelectBox ); @@ -339,7 +338,7 @@ void DISPLAY_FOOTPRINTS_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) void DISPLAY_FOOTPRINTS_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) { - auto cfg = dynamic_cast( aCfg ); + CVPCB_SETTINGS* cfg = dynamic_cast( aCfg ); wxCHECK( cfg, /* void */ ); PCB_BASE_FRAME::SaveSettings( cfg ); @@ -352,7 +351,7 @@ void DISPLAY_FOOTPRINTS_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) WINDOW_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg ) { - auto cfg = dynamic_cast( aCfg ); + CVPCB_SETTINGS* cfg = dynamic_cast( aCfg ); wxCHECK( cfg, nullptr ); return &cfg->m_FootprintViewer; } @@ -360,7 +359,7 @@ WINDOW_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetWindowSettings( APP_SETTINGS_BASE* MAGNETIC_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetMagneticItemsSettings() { - auto cfg = dynamic_cast( Kiface().KifaceSettings() ); + CVPCB_SETTINGS* cfg = dynamic_cast( Kiface().KifaceSettings() ); wxCHECK( cfg, nullptr ); return &cfg->m_FootprintViewerMagneticSettings; } @@ -372,11 +371,11 @@ COLOR4D DISPLAY_FOOTPRINTS_FRAME::GetGridColor() } -MODULE* DISPLAY_FOOTPRINTS_FRAME::GetModule( const wxString& aFootprintName, REPORTER& aReporter ) +MODULE* DISPLAY_FOOTPRINTS_FRAME::GetFootprint( const wxString& aFootprintName, + REPORTER& aReporter ) { MODULE* footprint = NULL; - - LIB_ID fpid; + LIB_ID fpid; if( fpid.Parse( aFootprintName, LIB_ID::ID_PCB ) >= 0 ) { @@ -435,8 +434,8 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::GetModule( const wxString& aFootprintName, REP void DISPLAY_FOOTPRINTS_FRAME::InitDisplay() { CVPCB_MAINFRAME* parentframe = (CVPCB_MAINFRAME *) GetParent(); - MODULE* module = nullptr; - const FOOTPRINT_INFO* module_info = nullptr; + MODULE* footprint = nullptr; + const FOOTPRINT_INFO* fpInfo = nullptr; GetBoard()->DeleteAllModules(); GetCanvas()->GetView()->Clear(); @@ -458,16 +457,16 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay() { SetTitle( wxString::Format( _( "Footprint: %s" ), footprintName ) ); - module = GetModule( footprintName, infoReporter ); + footprint = GetFootprint( footprintName, infoReporter ); - module_info = parentframe->m_FootprintsList->GetModuleInfo( footprintName ); + fpInfo = parentframe->m_FootprintsList->GetFootprintInfo( footprintName ); } - if( module ) - GetBoard()->Add( module ); + if( footprint ) + GetBoard()->Add( footprint ); - if( module_info ) - SetStatusText( wxString::Format( _( "Lib: %s" ), module_info->GetLibNickname() ), 0 ); + if( fpInfo ) + SetStatusText( wxString::Format( _( "Lib: %s" ), fpInfo->GetLibNickname() ), 0 ); else SetStatusText( wxEmptyString, 0 ); diff --git a/cvpcb/display_footprints_frame.h b/cvpcb/display_footprints_frame.h index ae6f711b35..bcc0ab09b1 100644 --- a/cvpcb/display_footprints_frame.h +++ b/cvpcb/display_footprints_frame.h @@ -87,7 +87,7 @@ public: */ COLOR4D GetGridColor() override; - MODULE* GetModule( const wxString& CmpName, REPORTER& aReporter ); + MODULE* GetFootprint( const wxString& aFootprintName, REPORTER& aReporter ); /* SaveCopyInUndoList() virtual * currently: do nothing in CvPcb. diff --git a/eeschema/dialogs/dialog_choose_component.cpp b/eeschema/dialogs/dialog_choose_component.cpp index b05ca053f8..9959cf58ef 100644 --- a/eeschema/dialogs/dialog_choose_component.cpp +++ b/eeschema/dialogs/dialog_choose_component.cpp @@ -48,7 +48,7 @@ std::mutex DIALOG_CHOOSE_COMPONENT::g_Mutex; DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxString& aTitle, - SYMBOL_TREE_MODEL_ADAPTER::PTR& aAdapter, + wxObjectDataPtr& aAdapter, int aDeMorganConvert, bool aAllowFieldEdits, bool aShowFootprints, bool aAllowBrowser ) : DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize, diff --git a/eeschema/dialogs/dialog_choose_component.h b/eeschema/dialogs/dialog_choose_component.h index 8a1f48e7a0..146ffbc109 100644 --- a/eeschema/dialogs/dialog_choose_component.h +++ b/eeschema/dialogs/dialog_choose_component.h @@ -104,8 +104,9 @@ public: * @param aAllowBrowser show a Select with Browser button */ DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxString& aTitle, - SYMBOL_TREE_MODEL_ADAPTER::PTR& aAdapter, int aDeMorganConvert, - bool aAllowFieldEdits, bool aShowFootprints, bool aAllowBrowser ); + wxObjectDataPtr& aAdapter, + int aDeMorganConvert, bool aAllowFieldEdits, bool aShowFootprints, + bool aAllowBrowser ); ~DIALOG_CHOOSE_COMPONENT(); diff --git a/eeschema/dialogs/dialog_edit_components_libid.cpp b/eeschema/dialogs/dialog_edit_components_libid.cpp index 3a03780240..5bd132b726 100644 --- a/eeschema/dialogs/dialog_edit_components_libid.cpp +++ b/eeschema/dialogs/dialog_edit_components_libid.cpp @@ -669,8 +669,8 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::setLibIdByBrowser( int aRow ) #if 0 // Use dialog symbol selector to choose a symbol SCH_BASE_FRAME::HISTORY_LIST dummy; - SCH_BASE_FRAME::COMPONENT_SELECTION sel = - m_frame->SelectComponentFromLibrary( NULL, dummy, true, 0, 0, false ); + SCH_BASE_FRAME::PICKED_SYMBOL sel = m_frame->SelectComponentFromLibrary( NULL, dummy, true, + 0, 0, false ); #else // Use library viewer to choose a symbol LIB_ID aPreselectedLibid; @@ -682,8 +682,8 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::setLibIdByBrowser( int aRow ) if( !current.IsEmpty() ) aPreselectedLibid.Parse( current, LIB_ID::ID_SCH, true ); - COMPONENT_SELECTION sel = - GetParent()->SelectComponentFromLibBrowser( this, NULL, aPreselectedLibid, 0, 0 ); + PICKED_SYMBOL sel = GetParent()->PickSymbolFromLibBrowser( this, NULL, aPreselectedLibid, + 0, 0 ); #endif if( sel.LibId.empty() ) // command aborted diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 2aa9dce844..5fbea8f2bd 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -40,8 +40,10 @@ #include #include -COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibBrowser( wxTopLevelWindow* aParent, - const SCHLIB_FILTER* aFilter, const LIB_ID& aPreselectedLibId, int aUnit, int aConvert ) +PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibBrowser( wxTopLevelWindow* aParent, + const SCHLIB_FILTER* aFilter, + const LIB_ID& aPreselectedLibId, + int aUnit, int aConvert ) { // Close any open non-modal Lib browser, and open a new one, in "modal" mode: LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false ); @@ -64,8 +66,8 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibBrowser( wxTopLevelWin viewlibFrame->Refresh(); - COMPONENT_SELECTION sel; - wxString symbol; + PICKED_SYMBOL sel; + wxString symbol; if( viewlibFrame->ShowModal( &symbol, aParent ) ) { @@ -84,9 +86,13 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibBrowser( wxTopLevelWin } -COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER* aFilter, - std::vector& aHistoryList, bool aUseLibBrowser, int aUnit, - int aConvert, bool aShowFootprints, const LIB_ID* aHighlight, bool aAllowFields ) +PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibTree( const SCHLIB_FILTER* aFilter, + std::vector& aHistoryList, + bool aUseLibBrowser, + int aUnit, int aConvert, + bool aShowFootprints, + const LIB_ID* aHighlight, + bool aAllowFields ) { std::unique_lock dialogLock( DIALOG_CHOOSE_COMPONENT::g_Mutex, std::defer_lock ); wxString dialogTitle; @@ -94,10 +100,9 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER* // One CHOOSE_COMPONENT dialog at a time. User probaby can't handle more anyway. if( !dialogLock.try_lock() ) - return COMPONENT_SELECTION(); + return PICKED_SYMBOL(); - auto adapterPtr( SYMBOL_TREE_MODEL_ADAPTER::Create( this, libs ) ); - auto adapter = static_cast( adapterPtr.get() ); + wxObjectDataPtr adapter = SYMBOL_TREE_MODEL_ADAPTER::Create( this, libs ); bool loaded = false; if( aFilter ) @@ -109,7 +114,7 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER* if( libs->HasLibrary( liblist[ii], true ) ) { loaded = true; - adapter->AddLibrary( liblist[ii] ); + static_cast( adapter.get() )->AddLibrary( liblist[ii] ); } } @@ -121,7 +126,7 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER* std::vector< LIB_TREE_ITEM* > history_list; - for( auto const& i : aHistoryList ) + for( const PICKED_SYMBOL& i : aHistoryList ) { LIB_PART* symbol = GetLibPart( i.LibId ); @@ -130,8 +135,7 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER* history_list.push_back( symbol ); } - adapter->DoAddLibrary( "-- " + _( "Recently Used" ) + " --", wxEmptyString, history_list, - true ); + adapter->DoAddLibrary( "-- " + _( "Recently Used" ) + " --", wxEmptyString, history_list, true ); if( !aHistoryList.empty() ) adapter->SetPreselectNode( aHistoryList[0].LibId, aHistoryList[0].Unit ); @@ -139,7 +143,7 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER* const std::vector< wxString > libNicknames = libs->GetLogicalLibs(); if( !loaded ) - adapter->AddLibraries( libNicknames, this ); + static_cast( adapter.get() )->AddLibraries( libNicknames, this ); if( aHighlight && aHighlight->IsValid() ) adapter->SetPreselectNode( *aHighlight, /* aUnit */ 0 ); @@ -149,25 +153,25 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER* else dialogTitle.Printf( _( "Choose Symbol (%d items loaded)" ), adapter->GetItemCount() ); - DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapterPtr, aConvert, - aAllowFields, aShowFootprints, aUseLibBrowser ); + DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapter, aConvert, aAllowFields, + aShowFootprints, aUseLibBrowser ); if( dlg.ShowModal() == wxID_CANCEL ) - return COMPONENT_SELECTION(); + return PICKED_SYMBOL(); - COMPONENT_SELECTION sel; + PICKED_SYMBOL sel; LIB_ID id = dlg.GetSelectedLibId( &sel.Unit ); if( dlg.IsExternalBrowserSelected() ) // User requested component browser. { - sel = SelectComponentFromLibBrowser( this, aFilter, id, sel.Unit, sel.Convert ); + sel = PickSymbolFromLibBrowser( this, aFilter, id, sel.Unit, sel.Convert ); id = sel.LibId; } if( !id.IsValid() ) // Dialog closed by OK button, // or the selection by lib browser was requested, // but no symbol selected - return COMPONENT_SELECTION(); + return PICKED_SYMBOL(); if( sel.Unit == 0 ) sel.Unit = 1; @@ -178,7 +182,7 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER* if( sel.LibId.IsValid() ) { aHistoryList.erase( std::remove_if( aHistoryList.begin(), aHistoryList.end(), - [ &sel ]( COMPONENT_SELECTION const& i ) + [ &sel ]( PICKED_SYMBOL const& i ) { return i.LibId == sel.LibId; } ), diff --git a/eeschema/lib_view_frame.cpp b/eeschema/lib_view_frame.cpp index 78d1212f00..47fdd0db0e 100644 --- a/eeschema/lib_view_frame.cpp +++ b/eeschema/lib_view_frame.cpp @@ -812,11 +812,10 @@ void LIB_VIEW_FRAME::OnSelectSymbol( wxCommandEvent& aEvent ) // Container doing search-as-you-type. SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable(); - auto adapterPtr( SYMBOL_TREE_MODEL_ADAPTER::Create( this, libs ) ); - auto adapter = static_cast( adapterPtr.get() ); + wxObjectDataPtr adapter = SYMBOL_TREE_MODEL_ADAPTER::Create( this, libs ); const auto libNicknames = libs->GetLogicalLibs(); - adapter->AddLibraries( libNicknames, this ); + static_cast( adapter.get() )->AddLibraries( libNicknames, this ); LIB_PART* current = GetSelectedSymbol(); LIB_ID id; @@ -831,7 +830,7 @@ void LIB_VIEW_FRAME::OnSelectSymbol( wxCommandEvent& aEvent ) wxString dialogTitle; dialogTitle.Printf( _( "Choose Symbol (%d items loaded)" ), adapter->GetItemCount() ); - DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapterPtr, m_convert, false, false, false ); + DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapter, m_convert, false, false, false ); if( dlg.ShowQuasiModal() == wxID_CANCEL ) return; diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h index 8c10129090..04e6ead472 100644 --- a/eeschema/sch_base_frame.h +++ b/eeschema/sch_base_frame.h @@ -145,7 +145,7 @@ public: void UpdateStatusBar() override; /** - * Function SelectComponentFromLib + * Function PickSymbolFromLibTree * Calls the library viewer to select component to import into schematic. * if the library viewer is currently running, it is closed and reopened * in modal mode. @@ -168,15 +168,14 @@ public: * * @return the selected component */ - COMPONENT_SELECTION SelectCompFromLibTree( - const SCHLIB_FILTER* aFilter, - std::vector& aHistoryList, - bool aUseLibBrowser, - int aUnit, - int aConvert, - bool aShowFootprints, - const LIB_ID* aHighlight = nullptr, - bool aAllowFields = true ); + PICKED_SYMBOL PickSymbolFromLibTree( const SCHLIB_FILTER* aFilter, + std::vector& aHistoryList, + bool aUseLibBrowser, + int aUnit, + int aConvert, + bool aShowFootprints, + const LIB_ID* aHighlight = nullptr, + bool aAllowFields = true ); /** * Load symbol from symbol library table. @@ -193,7 +192,7 @@ public: LIB_PART* GetFlattenedLibPart( const LIB_ID& aLibId, bool aShowErrorMsg = false ); /** - * Function SelectComponentFromLibBrowser + * Function PickSymbolFromLibBrowser * Calls the library viewer to select component to import into schematic. * if the library viewer is currently running, it is closed and reopened * in modal mode. @@ -205,10 +204,10 @@ public: * @param aConvert preselected deMorgan conversion * @return the selected component */ - COMPONENT_SELECTION SelectComponentFromLibBrowser( wxTopLevelWindow* aParent, - const SCHLIB_FILTER* aFilter, - const LIB_ID& aPreselectedLibid, - int aUnit, int aConvert ); + PICKED_SYMBOL PickSymbolFromLibBrowser( wxTopLevelWindow* aParent, + const SCHLIB_FILTER* aFilter, + const LIB_ID& aPreselectedLibId, + int aUnit, int aConvert ); virtual void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ); diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 9b8c6daebf..db0273e1a8 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -129,7 +129,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, LIB_ID aLibId, SCH_SHEET_PATH* sh } -SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* aSheet, COMPONENT_SELECTION& aSel, +SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* aSheet, PICKED_SYMBOL& aSel, const wxPoint& pos ) : SCH_COMPONENT( aPart, aSel.LibId, aSheet, aSel.Unit, aSel.Convert, pos ) { diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 1a1d885d9f..1ee0e17f71 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -51,7 +51,7 @@ #include #include -struct COMPONENT_SELECTION; +struct PICKED_SYMBOL; class SCH_SCREEN; class LIB_ITEM; class LIB_PIN; @@ -137,7 +137,7 @@ public: int unit = 0, int convert = 0, const wxPoint& pos = wxPoint( 0, 0 ) ); - SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* aSheet, COMPONENT_SELECTION& aSel, + SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* aSheet, PICKED_SYMBOL& aSel, const wxPoint& pos = wxPoint( 0, 0 ) ); /** * Clones \a aComponent into a new schematic symbol object. diff --git a/eeschema/sch_screen.h b/eeschema/sch_screen.h index ef68f82663..0f7ea55478 100644 --- a/eeschema/sch_screen.h +++ b/eeschema/sch_screen.h @@ -77,7 +77,7 @@ enum SCH_LINE_TEST_T /// Max number of sheets in a hierarchy project #define NB_MAX_SHEET 500 -struct COMPONENT_SELECTION +struct PICKED_SYMBOL { LIB_ID LibId; int Unit; @@ -85,7 +85,7 @@ struct COMPONENT_SELECTION std::vector> Fields; - COMPONENT_SELECTION() : Unit( 1 ), Convert( 1 ) + PICKED_SYMBOL() : Unit( 1 ), Convert( 1 ) { } }; diff --git a/eeschema/symbol_editor/symbol_library_manager.h b/eeschema/symbol_editor/symbol_library_manager.h index 5a68ed54c2..38020c05bc 100644 --- a/eeschema/symbol_editor/symbol_library_manager.h +++ b/eeschema/symbol_editor/symbol_library_manager.h @@ -273,7 +273,7 @@ public: /** * Returns the adapter object that provides the stored data. */ - LIB_TREE_MODEL_ADAPTER::PTR& GetAdapter() { return m_adapter; } + wxObjectDataPtr& GetAdapter() { return m_adapter; } /** * Returns the currently modified library name. @@ -315,6 +315,11 @@ private: ///> Returns the current Symbol Library Table SYMBOL_LIB_TABLE* symTable() const; + SYMBOL_TREE_SYNCHRONIZING_ADAPTER* getAdapter() + { + return static_cast( m_adapter.get() ); + } + ///> Class to store a working copy of a LIB_PART object and editor context. class PART_BUFFER { @@ -454,28 +459,29 @@ private: int m_hash; }; - ///> Returns a set of LIB_PART objects belonging to the original library + /** + * Returns a set of LIB_PART objects belonging to the original library + */ std::set getOriginalParts( const wxString& aLibrary ); - ///> Returns an existing library buffer or creates one to using - ///> Symbol Library Table to get the original data. + /** + * Returns an existing library buffer or creates one to using Symbol Library Table to get + * the original data. + */ LIB_BUFFER& getLibraryBuffer( const wxString& aLibrary ); ///> The library buffers std::map m_libs; - SYMBOL_EDIT_FRAME& m_frame; // Parent frame - LIB_LOGGER m_logger; - int m_syncHash; // Symbol Lib Table hash value from the last synchronization + SYMBOL_EDIT_FRAME& m_frame; ///< Parent frame + LIB_LOGGER m_logger; + int m_syncHash; ///< Symbol lib table hash value from last synchronization - wxString m_currentLib; // Currently modified part - wxString m_currentPart; // Currently modified library + wxString m_currentLib; ///< Currently modified part + wxString m_currentPart; ///< Currently modified library + + wxObjectDataPtr m_adapter; - SYMBOL_TREE_SYNCHRONIZING_ADAPTER::PTR m_adapter; - SYMBOL_TREE_SYNCHRONIZING_ADAPTER* getAdapter() - { - return static_cast( m_adapter.get() ); - } }; #endif /* SYMBOL_LIBRARY_MANAGER_H */ diff --git a/eeschema/symbol_tree_model_adapter.cpp b/eeschema/symbol_tree_model_adapter.cpp index 261841b09d..4d72befb2a 100644 --- a/eeschema/symbol_tree_model_adapter.cpp +++ b/eeschema/symbol_tree_model_adapter.cpp @@ -36,10 +36,11 @@ bool SYMBOL_TREE_MODEL_ADAPTER::m_show_progress = true; #define PROGRESS_INTERVAL_MILLIS 66 -SYMBOL_TREE_MODEL_ADAPTER::PTR SYMBOL_TREE_MODEL_ADAPTER::Create( EDA_BASE_FRAME* aParent, - LIB_TABLE* aLibs ) +wxObjectDataPtr +SYMBOL_TREE_MODEL_ADAPTER::Create( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs ) { - return PTR( new SYMBOL_TREE_MODEL_ADAPTER( aParent, aLibs ) ); + auto* adapter = new SYMBOL_TREE_MODEL_ADAPTER( aParent, aLibs ); + return wxObjectDataPtr( adapter ); } diff --git a/eeschema/symbol_tree_model_adapter.h b/eeschema/symbol_tree_model_adapter.h index 68a1b69027..a101d2aa25 100644 --- a/eeschema/symbol_tree_model_adapter.h +++ b/eeschema/symbol_tree_model_adapter.h @@ -40,7 +40,8 @@ public: * * @param aLibs library set from which parts will be loaded */ - static PTR Create( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs ); + static wxObjectDataPtr Create( EDA_BASE_FRAME* aParent, + LIB_TABLE* aLibs ); /** * Add all the libraries in a SYMBOL_LIB_TABLE to the model. diff --git a/eeschema/symbol_tree_synchronizing_adapter.cpp b/eeschema/symbol_tree_synchronizing_adapter.cpp index 1a0e7a8e6d..931466163c 100644 --- a/eeschema/symbol_tree_synchronizing_adapter.cpp +++ b/eeschema/symbol_tree_synchronizing_adapter.cpp @@ -30,10 +30,12 @@ #include -LIB_TREE_MODEL_ADAPTER::PTR SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( SYMBOL_EDIT_FRAME* aParent, - SYMBOL_LIBRARY_MANAGER* aLibMgr ) +wxObjectDataPtr +SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( SYMBOL_EDIT_FRAME* aParent, + SYMBOL_LIBRARY_MANAGER* aLibMgr ) { - return PTR( new SYMBOL_TREE_SYNCHRONIZING_ADAPTER( aParent, aLibMgr ) ); + auto* adapter = new SYMBOL_TREE_SYNCHRONIZING_ADAPTER( aParent, aLibMgr ); + return wxObjectDataPtr( adapter ); } diff --git a/eeschema/symbol_tree_synchronizing_adapter.h b/eeschema/symbol_tree_synchronizing_adapter.h index 576e423140..43cf32828e 100644 --- a/eeschema/symbol_tree_synchronizing_adapter.h +++ b/eeschema/symbol_tree_synchronizing_adapter.h @@ -34,7 +34,8 @@ class SYMBOL_LIBRARY_MANAGER; class SYMBOL_TREE_SYNCHRONIZING_ADAPTER : public LIB_TREE_MODEL_ADAPTER { public: - static PTR Create( SYMBOL_EDIT_FRAME* aParent, SYMBOL_LIBRARY_MANAGER* aLibs ); + static wxObjectDataPtr Create( SYMBOL_EDIT_FRAME* aParent, + SYMBOL_LIBRARY_MANAGER* aLibs ); bool IsContainer( const wxDataViewItem& aItem ) const override; diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 1b45917512..3e67e279ef 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -79,9 +79,9 @@ bool SCH_DRAWING_TOOLS::Init() int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent ) { - SCH_COMPONENT* component = aEvent.Parameter(); - SCHLIB_FILTER filter; - std::vector* historyList = nullptr; + SCH_COMPONENT* component = aEvent.Parameter(); + SCHLIB_FILTER filter; + std::vector* historyList = nullptr; if( aEvent.IsAction( &EE_ACTIONS::placeSymbol ) ) historyList = &m_symbolHistoryList; @@ -173,9 +173,8 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent ) // Pick the module to be placed bool footprintPreviews = m_frame->eeconfig()->m_Appearance.footprint_preview; - COMPONENT_SELECTION sel = m_frame->SelectCompFromLibTree( &filter, *historyList, - true, 1, 1, - footprintPreviews ); + PICKED_SYMBOL sel = m_frame->PickSymbolFromLibTree( &filter, *historyList, true, + 1, 1, footprintPreviews ); // Restore cursor after dialog getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true ); diff --git a/eeschema/tools/sch_drawing_tools.h b/eeschema/tools/sch_drawing_tools.h index d51797fe13..94e88e1abb 100644 --- a/eeschema/tools/sch_drawing_tools.h +++ b/eeschema/tools/sch_drawing_tools.h @@ -76,14 +76,14 @@ private: private: // History lists for PlaceComponent() - std::vector m_symbolHistoryList; - std::vector m_powerHistoryList; + std::vector m_symbolHistoryList; + std::vector m_powerHistoryList; - PINSHEETLABEL_SHAPE m_lastSheetPinType; - PINSHEETLABEL_SHAPE m_lastGlobalLabelShape; - LABEL_SPIN_STYLE m_lastTextOrientation; - bool m_lastTextBold; - bool m_lastTextItalic; + PINSHEETLABEL_SHAPE m_lastSheetPinType; + PINSHEETLABEL_SHAPE m_lastGlobalLabelShape; + LABEL_SPIN_STYLE m_lastTextOrientation; + bool m_lastTextBold; + bool m_lastTextItalic; std::unique_ptr m_statusPopup; }; diff --git a/include/footprint_info.h b/include/footprint_info.h index f0240bf5de..ed16bef98f 100644 --- a/include/footprint_info.h +++ b/include/footprint_info.h @@ -155,15 +155,15 @@ protected: FOOTPRINT_LIST* m_owner; ///< provides access to FP_LIB_TABLE - bool m_loaded; + bool m_loaded; - wxString m_nickname; ///< library as known in FP_LIB_TABLE - wxString m_fpname; ///< Module name. - int m_num; ///< Order number in the display list. - unsigned m_pad_count; ///< Number of pads - unsigned m_unique_pad_count; ///< Number of unique pads - wxString m_doc; ///< Footprint description. - wxString m_keywords; ///< Footprint keywords. + wxString m_nickname; ///< library as known in FP_LIB_TABLE + wxString m_fpname; ///< Module name. + int m_num; ///< Order number in the display list. + unsigned m_pad_count; ///< Number of pads + unsigned m_unique_pad_count; ///< Number of unique pads + wxString m_doc; ///< Footprint description. + wxString m_keywords; ///< Footprint keywords. }; @@ -216,12 +216,13 @@ public: /** * Get info for a module by id. */ - FOOTPRINT_INFO* GetModuleInfo( const wxString& aFootprintId ); + FOOTPRINT_INFO* GetFootprintInfo( const wxString& aFootprintName ); /** * Get info for a module by libNickname/footprintName */ - FOOTPRINT_INFO* GetModuleInfo( const wxString& aLibNickname, const wxString& aFootprintName ); + FOOTPRINT_INFO* GetFootprintInfo( const wxString& aLibNickname, + const wxString& aFootprintName ); /** * Get info for a module by index. @@ -333,7 +334,7 @@ public: * @param aNThreads is the number of worker threads. */ void Start( FP_LIB_TABLE* aTable, wxString const* aNickname = nullptr, - unsigned aNThreads = DEFAULT_THREADS ); + unsigned aNThreads = DEFAULT_THREADS ); /** * Wait until the worker threads are finished, and then perform any required diff --git a/pcbnew/dialogs/dialog_choose_footprint.cpp b/pcbnew/dialogs/dialog_choose_footprint.cpp index 14161990ac..b3bfcbfbec 100644 --- a/pcbnew/dialogs/dialog_choose_footprint.cpp +++ b/pcbnew/dialogs/dialog_choose_footprint.cpp @@ -43,7 +43,7 @@ DIALOG_CHOOSE_FOOTPRINT::DIALOG_CHOOSE_FOOTPRINT( PCB_BASE_FRAME* aParent, const wxString& aTitle, - FP_TREE_MODEL_ADAPTER::PTR& aAdapter ) + wxObjectDataPtr& aAdapter ) : DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ), m_browser_button( nullptr ), diff --git a/pcbnew/dialogs/dialog_choose_footprint.h b/pcbnew/dialogs/dialog_choose_footprint.h index a926d1853c..a3e628b65f 100644 --- a/pcbnew/dialogs/dialog_choose_footprint.h +++ b/pcbnew/dialogs/dialog_choose_footprint.h @@ -94,7 +94,7 @@ public: * for documentation. */ DIALOG_CHOOSE_FOOTPRINT( PCB_BASE_FRAME* aParent, const wxString& aTitle, - FP_TREE_MODEL_ADAPTER::PTR& aAdapter ); + wxObjectDataPtr& aAdapter ); ~DIALOG_CHOOSE_FOOTPRINT(); diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index 53a5dc3b3e..985e8813fe 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -41,7 +41,8 @@ class FOOTPRINT_EDIT_FRAME : public PCB_BASE_EDIT_FRAME friend struct PCB::IFACE; FOOTPRINT_TREE_PANE* m_treePane; - LIB_TREE_MODEL_ADAPTER::PTR m_adapter; + + wxObjectDataPtr m_adapter; std::unique_ptr m_revertModule; wxString m_footprintNameWhenLoaded; @@ -169,7 +170,7 @@ public: /** * Returns the adapter object that provides the stored data. */ - LIB_TREE_MODEL_ADAPTER::PTR& GetLibTreeAdapter() { return m_adapter; } + wxObjectDataPtr& GetLibTreeAdapter() { return m_adapter; } /** * Save in an existing library a given footprint. @@ -239,10 +240,10 @@ public: /** * Load in Modedit a footprint from the main board. * - * @param Module = the module to load. If NULL, a module reference will we asked to user + * @param aFootprint = the module to load. If NULL, a module reference will we asked to user * @return true if a module isloaded, false otherwise. */ - bool Load_Module_From_BOARD( MODULE* Module ); + bool LoadFootprintFromBoard( MODULE* aFootprint ); /** * Display the list of footprints currently existing on the BOARD. diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index 6c115bbfd5..ca73bee2f7 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -54,7 +54,7 @@ using namespace std::placeholders; void FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard( wxCommandEvent& event ) { - Load_Module_From_BOARD( NULL ); + LoadFootprintFromBoard( NULL ); } diff --git a/pcbnew/fp_tree_model_adapter.cpp b/pcbnew/fp_tree_model_adapter.cpp index ce2c765c3f..98d4a9241d 100644 --- a/pcbnew/fp_tree_model_adapter.cpp +++ b/pcbnew/fp_tree_model_adapter.cpp @@ -27,10 +27,11 @@ #include "fp_tree_model_adapter.h" -FP_TREE_MODEL_ADAPTER::PTR FP_TREE_MODEL_ADAPTER::Create( EDA_BASE_FRAME* aParent, - LIB_TABLE* aLibs ) +wxObjectDataPtr +FP_TREE_MODEL_ADAPTER::Create( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs ) { - return PTR( new FP_TREE_MODEL_ADAPTER( aParent, aLibs ) ); + auto* adapter = new FP_TREE_MODEL_ADAPTER( aParent, aLibs ); + return wxObjectDataPtr( adapter ); } @@ -42,7 +43,7 @@ FP_TREE_MODEL_ADAPTER::FP_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent, LIB_TABLE void FP_TREE_MODEL_ADAPTER::AddLibraries() { - for( const auto& libName : m_libs->GetLogicalLibs() ) + for( const wxString& libName : m_libs->GetLogicalLibs() ) { const FP_LIB_TABLE_ROW* library = m_libs->FindRow( libName ); @@ -63,10 +64,11 @@ std::vector FP_TREE_MODEL_ADAPTER::getFootprints( const wxString // List is sorted, so use a binary search to find the range of footnotes for our library auto libBounds = std::equal_range( fullListStart, fullListEnd, dummy, - []( const std::unique_ptr& a, const std::unique_ptr& b ) - { - return StrNumCmp( a->GetLibNickname(), b->GetLibNickname(), false ) < 0; - } ); + []( const std::unique_ptr& a, + const std::unique_ptr& b ) + { + return StrNumCmp( a->GetLibNickname(), b->GetLibNickname(), false ) < 0; + } ); for( auto i = libBounds.first; i != libBounds.second; ++i ) libList.push_back( i->get() ); diff --git a/pcbnew/fp_tree_model_adapter.h b/pcbnew/fp_tree_model_adapter.h index f82250f32b..fae06b830e 100644 --- a/pcbnew/fp_tree_model_adapter.h +++ b/pcbnew/fp_tree_model_adapter.h @@ -36,7 +36,8 @@ public: * * @param aLibs library set from which parts will be loaded */ - static PTR Create( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs ); + static wxObjectDataPtr Create( EDA_BASE_FRAME* aParent, + LIB_TABLE* aLibs ); void AddLibraries(); diff --git a/pcbnew/fp_tree_synchronizing_adapter.cpp b/pcbnew/fp_tree_synchronizing_adapter.cpp index 054799cc10..2fd79a70bd 100644 --- a/pcbnew/fp_tree_synchronizing_adapter.cpp +++ b/pcbnew/fp_tree_synchronizing_adapter.cpp @@ -34,10 +34,11 @@ #include -LIB_TREE_MODEL_ADAPTER::PTR FP_TREE_SYNCHRONIZING_ADAPTER::Create( FOOTPRINT_EDIT_FRAME* aFrame, - FP_LIB_TABLE* aLibs ) +wxObjectDataPtr +FP_TREE_SYNCHRONIZING_ADAPTER::Create( FOOTPRINT_EDIT_FRAME* aFrame, FP_LIB_TABLE* aLibs ) { - return PTR( new FP_TREE_SYNCHRONIZING_ADAPTER( aFrame, aLibs ) ); + auto* adapter = new FP_TREE_SYNCHRONIZING_ADAPTER( aFrame, aLibs ); + return wxObjectDataPtr( adapter ); } diff --git a/pcbnew/fp_tree_synchronizing_adapter.h b/pcbnew/fp_tree_synchronizing_adapter.h index 016e8d2ef6..4562d01bc6 100644 --- a/pcbnew/fp_tree_synchronizing_adapter.h +++ b/pcbnew/fp_tree_synchronizing_adapter.h @@ -33,7 +33,8 @@ class FOOTPRINT_EDIT_FRAME; class FP_TREE_SYNCHRONIZING_ADAPTER : public FP_TREE_MODEL_ADAPTER { public: - static PTR Create( FOOTPRINT_EDIT_FRAME* aFrame, FP_LIB_TABLE* aLibs ); + static wxObjectDataPtr Create( FOOTPRINT_EDIT_FRAME* aFrame, + FP_LIB_TABLE* aLibs ); bool IsContainer( const wxDataViewItem& aItem ) const override; diff --git a/pcbnew/load_select_footprint.cpp b/pcbnew/load_select_footprint.cpp index a56da9b2a8..851d19ba73 100644 --- a/pcbnew/load_select_footprint.cpp +++ b/pcbnew/load_select_footprint.cpp @@ -55,89 +55,87 @@ using namespace std::placeholders; #include "fp_tree_model_adapter.h" -static wxArrayString s_ModuleHistoryList; -static unsigned s_ModuleHistoryMaxCount = 8; +static wxArrayString s_FootprintHistoryList; +static unsigned s_FootprintHistoryMaxCount = 8; -static void AddModuleToHistory( const wxString& aName ) +static void AddFootprintToHistory( const wxString& aName ) { // Remove duplicates - for( int ii = s_ModuleHistoryList.GetCount() - 1; ii >= 0; --ii ) + for( int ii = s_FootprintHistoryList.GetCount() - 1; ii >= 0; --ii ) { - if( s_ModuleHistoryList[ ii ] == aName ) - s_ModuleHistoryList.RemoveAt( (size_t) ii ); + if( s_FootprintHistoryList[ ii ] == aName ) + s_FootprintHistoryList.RemoveAt((size_t) ii ); } // Add the new name at the beginning of the history list - s_ModuleHistoryList.Insert( aName, 0 ); + s_FootprintHistoryList.Insert( aName, 0 ); // Remove extra names - while( s_ModuleHistoryList.GetCount() >= s_ModuleHistoryMaxCount ) - s_ModuleHistoryList.RemoveAt( s_ModuleHistoryList.GetCount() - 1 ); + while( s_FootprintHistoryList.GetCount() >= s_FootprintHistoryMaxCount ) + s_FootprintHistoryList.RemoveAt( s_FootprintHistoryList.GetCount() - 1 ); } -static void clearModuleItemFlags( BOARD_ITEM* aItem ) -{ - aItem->ClearFlags(); -} - #include -bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule ) +bool FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( MODULE* aFootprint ) { bool is_last_fp_from_brd = IsCurrentFPFromBoard(); - MODULE* newModule; + MODULE* newFootprint = nullptr; PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false ); if( frame == NULL ) // happens if no board editor opened return false; - if( aModule == NULL ) + if( aFootprint == NULL ) { if( !frame->GetBoard() || !frame->GetBoard()->GetFirstModule() ) return false; - aModule = SelectFootprintFromBoard( frame->GetBoard() ); + aFootprint = SelectFootprintFromBoard( frame->GetBoard() ); } - if( aModule == NULL ) + if( aFootprint == NULL ) return false; if( !Clear_Pcb( true ) ) return false; - newModule = (MODULE*) aModule->Duplicate(); - newModule->SetParent( GetBoard() ); - newModule->SetLink( aModule->m_Uuid ); + newFootprint = (MODULE*) aFootprint->Duplicate(); + newFootprint->SetParent( GetBoard() ); + newFootprint->SetLink( aFootprint->m_Uuid ); - newModule->ClearFlags(); - newModule->RunOnChildren( std::bind( &clearModuleItemFlags, _1 ) ); + newFootprint->ClearFlags(); + newFootprint->RunOnChildren( []( BOARD_ITEM* aItem ) + { + aItem->ClearFlags(); + } ); - AddModuleToBoard( newModule ); + AddModuleToBoard( newFootprint ); // Clear references to any net info, because the footprint editor // does know any thing about nets handled by the current edited board. // Morever we do not want to save any reference to an unknown net when // saving the footprint in lib cache // so we force the ORPHANED dummy net info for all pads - newModule->ClearAllNets(); + newFootprint->ClearAllNets(); GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false ); - PlaceModule( newModule ); - newModule->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment + PlaceModule( newFootprint ); + newFootprint->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment // Put it on FRONT layer, // because this is the default in ModEdit, and in libs - if( newModule->GetLayer() != F_Cu ) - newModule->Flip( newModule->GetPosition(), frame->Settings().m_FlipLeftRight ); + if( newFootprint->GetLayer() != F_Cu ) + newFootprint->Flip( newFootprint->GetPosition(), frame->Settings().m_FlipLeftRight ); // Put it in orientation 0, // because this is the default orientation in ModEdit, and in libs - newModule->SetOrientation( 0 ); + newFootprint->SetOrientation( 0 ); Zoom_Automatique( false ); - m_adapter->SetPreselectNode( newModule->GetFPID(), 0 ); + m_adapter->SetPreselectNode( newFootprint->GetFPID(), 0 ); ClearUndoRedoList(); GetScreen()->ClrModify(); @@ -196,9 +194,9 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser() MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect ) { FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs(); - wxString moduleName; + wxString footprintName; LIB_ID fpid; - MODULE* module = NULL; + MODULE* footprint = nullptr; static wxString lastComponentName; @@ -215,14 +213,14 @@ MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect ) if( GFootprintList.GetErrorCount() ) GFootprintList.DisplayErrors( this ); - auto adapterPtr( FP_TREE_MODEL_ADAPTER::Create( this, fpTable ) ); - auto adapter = static_cast( adapterPtr.get() ); + wxObjectDataPtr ptr = FP_TREE_MODEL_ADAPTER::Create( this, fpTable ); + FP_TREE_MODEL_ADAPTER* adapter = static_cast( ptr.get() ); std::vector historyInfos; - for( auto const& item : s_ModuleHistoryList ) + for( const wxString& item : s_FootprintHistoryList ) { - LIB_TREE_ITEM* fp_info = GFootprintList.GetModuleInfo( item ); + LIB_TREE_ITEM* fp_info = GFootprintList.GetFootprintInfo( item ); // this can be null, for example, if the footprint has been deleted from a library. if( fp_info != nullptr ) @@ -241,7 +239,7 @@ MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect ) wxString title; title.Printf( _( "Choose Footprint (%d items loaded)" ), adapter->GetItemCount() ); - DIALOG_CHOOSE_FOOTPRINT dialog( this, title, adapterPtr ); + DIALOG_CHOOSE_FOOTPRINT dialog( this, title, ptr ); if( dialog.ShowQuasiModal() == wxID_CANCEL ) return NULL; @@ -250,12 +248,12 @@ MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect ) { // SelectFootprintFromLibBrowser() returns the "full" footprint name, i.e. // / or LIB_ID format "lib_name:fp_name:rev#" - moduleName = SelectFootprintFromLibBrowser(); + footprintName = SelectFootprintFromLibBrowser(); - if( moduleName.IsEmpty() ) // Cancel command + if( footprintName.IsEmpty() ) // Cancel command return NULL; else - fpid.Parse( moduleName, LIB_ID::ID_PCB ); + fpid.Parse( footprintName, LIB_ID::ID_PCB ); } else { @@ -264,24 +262,24 @@ MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect ) if( !fpid.IsValid() ) return NULL; else - moduleName = fpid.Format(); + footprintName = fpid.Format(); } try { - module = loadFootprint( fpid ); + footprint = loadFootprint( fpid ); } catch( const IO_ERROR& ) { } - if( module ) + if( footprint ) { - lastComponentName = moduleName; - AddModuleToHistory( moduleName ); + lastComponentName = footprintName; + AddFootprintToHistory( footprintName ); } - return module; + return footprint; } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 26c0d37247..c763407f90 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1532,7 +1532,7 @@ void PCB_EDIT_FRAME::ShowFootprintPropertiesDialog( MODULE* aFootprint ) { auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, true ); - editor->Load_Module_From_BOARD( aFootprint ); + editor->LoadFootprintFromBoard( aFootprint ); editor->Show( true ); editor->Raise(); // Iconize( false ); diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 1580468adb..9d3305c6ce 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -1264,7 +1264,7 @@ int PCB_EDITOR_CONTROL::EditFpInFpEditor( const TOOL_EVENT& aEvent ) auto editor = (FOOTPRINT_EDIT_FRAME*) editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true ); - editor->Load_Module_From_BOARD( fp ); + editor->LoadFootprintFromBoard( fp ); editor->Show( true ); editor->Raise(); // Iconize( false );