From 7d71861015ab552980f8c0e568f111aba364581f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 1 Jul 2018 16:22:33 +0100 Subject: [PATCH] If the user has a selection then show the footprint. Don't be pedantic about it having to come from the footprint list, the component list also has footprints assigned. (cherry picked from commit 759fba1) --- cvpcb/cvpcb_mainframe.cpp | 19 +++------ cvpcb/display_footprints_frame.cpp | 66 +++++++++++------------------- 2 files changed, 30 insertions(+), 55 deletions(-) diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index 72c4594af5..918218293f 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -530,6 +530,8 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event ) m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, component, m_currentSearchPattern, m_filteringOptions); + m_footprintListBox->SetSelection( m_footprintListBox->GetSelection(), false ); + refreshAfterComponentSearch (component); } @@ -556,7 +558,7 @@ void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component ) { wxString module = FROM_UTF8( component->GetFPID().Format().c_str() ); - bool found = false; + m_footprintListBox->SetSelection( m_footprintListBox->GetSelection(), false ); for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ ) { @@ -569,23 +571,12 @@ void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component ) if( module.Cmp( footprintName ) == 0 ) { m_footprintListBox->SetSelection( ii, true ); - found = true; break; } } - if( !found ) - { - int ii = m_footprintListBox->GetSelection(); - - if ( ii >= 0 ) - m_footprintListBox->SetSelection( ii, false ); - - if( GetFootprintViewerFrame() ) - { - CreateScreenCmp(); - } - } + if( GetFootprintViewerFrame() ) + CreateScreenCmp(); } SendMessageToEESCHEMA(); diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index 6f4483e8c1..7f55615a7f 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -466,59 +466,43 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName ) void DISPLAY_FOOTPRINTS_FRAME::InitDisplay() { - wxString msg; + CVPCB_MAINFRAME* parentframe = (CVPCB_MAINFRAME *) GetParent(); + MODULE* module = nullptr; + const FOOTPRINT_INFO* module_info = nullptr; - CVPCB_MAINFRAME* parentframe = (CVPCB_MAINFRAME *) GetParent(); + if( GetBoard()->m_Modules.GetCount() ) + GetBoard()->m_Modules.DeleteAll(); wxString footprintName = parentframe->GetSelectedFootprint(); + if( footprintName.IsEmpty() ) + { + COMPONENT* comp = parentframe->GetSelectedComponent(); + + if( comp ) + footprintName = comp->GetFPID().GetUniStringLibId(); + } + if( !footprintName.IsEmpty() ) { - msg.Printf( _( "Footprint: %s" ), GetChars( footprintName ) ); + SetTitle( wxString::Format( _( "Footprint: %s" ), footprintName ) ); - SetTitle( msg ); - const FOOTPRINT_INFO* module_info = - parentframe->m_FootprintsList->GetModuleInfo( footprintName ); + module = Get_Module( footprintName ); - const wxChar* libname; - - if( module_info ) - libname = GetChars( module_info->GetNickname() ); - else - libname = GetChars( wxT( "???" ) ); - - msg.Printf( _( "Lib: %s" ), libname ); - - SetStatusText( msg, 0 ); - - if( GetBoard()->m_Modules.GetCount() ) - { - // there is only one module in the list - GetBoard()->m_Modules.DeleteAll(); - } - - MODULE* module = Get_Module( footprintName ); - - if( module ) - GetBoard()->m_Modules.PushBack( module ); - - Zoom_Automatique( false ); - } - else // No footprint to display. Erase old footprint, if any - { - if( GetBoard()->m_Modules.GetCount() ) - { - GetBoard()->m_Modules.DeleteAll(); - Zoom_Automatique( false ); - SetStatusText( wxEmptyString, 0 ); - } + module_info = parentframe->m_FootprintsList->GetModuleInfo( footprintName ); } - // Display new cursor coordinates and zoom value: + if( module ) + GetBoard()->m_Modules.PushBack( module ); + + if( module_info ) + SetStatusText( wxString::Format( _( "Lib: %s" ), module_info->GetNickname() ), 0 ); + else + SetStatusText( wxEmptyString, 0 ); + UpdateStatusBar(); - + Zoom_Automatique( false ); GetCanvas()->Refresh(); - Update3DView(); }