Add specific selection updating when adding 3D models.

This keeps us from being at the receiving end of wxWidgets' vagaries.

Fixes https://gitlab.com/kicad/code/kicad/issues/3760
This commit is contained in:
Jeff Young 2020-04-19 22:41:37 +01:00
parent c977addfa2
commit b2cd66f0a3
2 changed files with 14 additions and 2 deletions

View File

@ -518,6 +518,8 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel( wxCommandEvent& )
if( !m_modelsGrid->CommitPendingChanges() )
return;
int selected = m_modelsGrid->GetGridCursorRow();
PROJECT& prj = Prj();
MODULE_3D_SETTINGS model;
@ -545,6 +547,7 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel( wxCommandEvent& )
if( !S3D::Select3DModel( this, Prj().Get3DCacheManager(), initialpath, filter, &model )
|| model.m_Filename.empty() )
{
select3DModel( selected );
return;
}
@ -572,6 +575,7 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel( wxCommandEvent& )
m_modelsGrid->SetCellValue( idx, 0, filename );
m_modelsGrid->SetCellValue( idx, 1, wxT( "1" ) );
select3DModel( idx );
m_PreviewPane->UpdateDummyModule();
}
@ -590,6 +594,8 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DRow( wxCommandEvent& )
m_modelsGrid->AppendRows( 1 );
m_modelsGrid->SetCellValue( row, 1, wxT( "1" ) );
select3DModel( row );
m_modelsGrid->SetFocus();
m_modelsGrid->MakeCellVisible( row, 0 );
m_modelsGrid->SetGridCursor( row, 0 );

View File

@ -413,7 +413,7 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnRemove3DModel( wxCommandEvent& )
m_shapes3D_list.erase( m_shapes3D_list.begin() + idx );
m_modelsGrid->DeleteRows( idx );
select3DModel( idx-1 ); // will clamp idx within bounds
select3DModel( idx ); // will clamp idx within bounds
m_PreviewPane->UpdateDummyModule();
}
}
@ -424,12 +424,14 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel( wxCommandEvent& )
if( !m_modelsGrid->CommitPendingChanges() )
return;
int selected = m_modelsGrid->GetGridCursorRow();
PROJECT& prj = Prj();
MODULE_3D_SETTINGS model;
wxString initialpath = prj.GetRString( PROJECT::VIEWER_3D_PATH );
wxString sidx = prj.GetRString( PROJECT::VIEWER_3D_FILTER_INDEX );
int filter = 0;
int filter = 0;
// If the PROJECT::VIEWER_3D_PATH hasn't been set yet, use the KISYS3DMOD environment
// varaible and fall back to the project path if necessary.
@ -451,6 +453,7 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel( wxCommandEvent& )
if( !S3D::Select3DModel( this, Prj().Get3DCacheManager(), initialpath, filter, &model )
|| model.m_Filename.empty() )
{
select3DModel( selected );
return;
}
@ -478,6 +481,7 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel( wxCommandEvent& )
m_modelsGrid->SetCellValue( idx, 0, filename );
m_modelsGrid->SetCellValue( idx, 1, wxT( "1" ) );
select3DModel( idx );
m_PreviewPane->UpdateDummyModule();
}
@ -496,6 +500,8 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DRow( wxCommandEvent& )
m_modelsGrid->AppendRows( 1 );
m_modelsGrid->SetCellValue( row, 1, wxT( "1" ) );
select3DModel( row );
m_modelsGrid->SetFocus();
m_modelsGrid->MakeCellVisible( row, 0 );
m_modelsGrid->SetGridCursor( row, 0 );