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 d3e2345f94
commit faace3090c
2 changed files with 14 additions and 2 deletions

View File

@ -493,6 +493,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;
@ -520,6 +522,7 @@ void DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel( wxCommandEvent& )
if( !S3D::Select3DModel( this, Prj().Get3DCacheManager(), initialpath, filter, &model )
|| model.m_Filename.empty() )
{
select3DModel( selected );
return;
}
@ -547,6 +550,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();
}
@ -565,6 +569,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

@ -404,7 +404,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();
}
}
@ -415,12 +415,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.
@ -442,6 +444,7 @@ void DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel( wxCommandEvent& )
if( !S3D::Select3DModel( this, Prj().Get3DCacheManager(), initialpath, filter, &model )
|| model.m_Filename.empty() )
{
select3DModel( selected );
return;
}
@ -469,6 +472,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();
}
@ -487,6 +491,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 );