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)
This commit is contained in:
Jeff Young 2018-07-01 16:22:33 +01:00
parent 34857d06c4
commit 7d71861015
2 changed files with 30 additions and 55 deletions

View File

@ -530,6 +530,8 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, component, m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, component,
m_currentSearchPattern, m_filteringOptions); m_currentSearchPattern, m_filteringOptions);
m_footprintListBox->SetSelection( m_footprintListBox->GetSelection(), false );
refreshAfterComponentSearch (component); refreshAfterComponentSearch (component);
} }
@ -556,7 +558,7 @@ void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component )
{ {
wxString module = FROM_UTF8( component->GetFPID().Format().c_str() ); 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++ ) for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ )
{ {
@ -569,23 +571,12 @@ void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component )
if( module.Cmp( footprintName ) == 0 ) if( module.Cmp( footprintName ) == 0 )
{ {
m_footprintListBox->SetSelection( ii, true ); m_footprintListBox->SetSelection( ii, true );
found = true;
break; break;
} }
} }
if( !found ) if( GetFootprintViewerFrame() )
{ CreateScreenCmp();
int ii = m_footprintListBox->GetSelection();
if ( ii >= 0 )
m_footprintListBox->SetSelection( ii, false );
if( GetFootprintViewerFrame() )
{
CreateScreenCmp();
}
}
} }
SendMessageToEESCHEMA(); SendMessageToEESCHEMA();

View File

@ -466,59 +466,43 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
void DISPLAY_FOOTPRINTS_FRAME::InitDisplay() 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(); wxString footprintName = parentframe->GetSelectedFootprint();
if( footprintName.IsEmpty() )
{
COMPONENT* comp = parentframe->GetSelectedComponent();
if( comp )
footprintName = comp->GetFPID().GetUniStringLibId();
}
if( !footprintName.IsEmpty() ) if( !footprintName.IsEmpty() )
{ {
msg.Printf( _( "Footprint: %s" ), GetChars( footprintName ) ); SetTitle( wxString::Format( _( "Footprint: %s" ), footprintName ) );
SetTitle( msg ); module = Get_Module( footprintName );
const FOOTPRINT_INFO* module_info =
parentframe->m_FootprintsList->GetModuleInfo( footprintName );
const wxChar* libname; module_info = parentframe->m_FootprintsList->GetModuleInfo( footprintName );
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 );
}
} }
// 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(); UpdateStatusBar();
Zoom_Automatique( false );
GetCanvas()->Refresh(); GetCanvas()->Refresh();
Update3DView(); Update3DView();
} }