Refactor post-load actions in PcbNew and apply them consistently

Fixes: lp:1751589
* https://bugs.launchpad.net/kicad/+bug/1751589
This commit is contained in:
Jon Evans 2018-02-25 12:52:52 -05:00 committed by Wayne Stambaugh
parent b90528a7ae
commit cfd67163a1
4 changed files with 40 additions and 36 deletions

View File

@ -197,8 +197,8 @@ bool PCB_EDIT_FRAME::AppendBoardFile( const wxString& aFullFileName, int aCtl )
enabledLayers |= initialEnabledLayers; enabledLayers |= initialEnabledLayers;
GetBoard()->SetEnabledLayers( enabledLayers ); GetBoard()->SetEnabledLayers( enabledLayers );
GetBoard()->SetVisibleLayers( enabledLayers ); GetBoard()->SetVisibleLayers( enabledLayers );
ReCreateLayerBox();
ReFillLayerWidget(); onBoardLoaded();
if( IsGalCanvasActive() ) if( IsGalCanvasActive() )
static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( GetBoard() ); static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( GetBoard() );
@ -206,9 +206,6 @@ bool PCB_EDIT_FRAME::AppendBoardFile( const wxString& aFullFileName, int aCtl )
GetBoard()->BuildListOfNets(); GetBoard()->BuildListOfNets();
GetBoard()->SynchronizeNetsAndNetClasses(); GetBoard()->SynchronizeNetsAndNetClasses();
SetStatusText( wxEmptyString );
Zoom_Automatique( false );
// Finish block move command: // Finish block move command:
wxPoint cpos = GetNearestGridPosition( bbox.Centre() ); wxPoint cpos = GetNearestGridPosition( bbox.Centre() );
blockmove.SetOrigin( bbox.GetOrigin() ); blockmove.SetOrigin( bbox.GetOrigin() );

View File

@ -329,8 +329,9 @@ void PCB_EDIT_FRAME::Files_io_from_id( int id )
fn.SetExt( PcbFileExtension ); fn.SetExt( PcbFileExtension );
GetBoard()->SetFileName( fn.GetFullPath() ); GetBoard()->SetFileName( fn.GetFullPath() );
UpdateTitle();
ReCreateLayerBox(); onBoardLoaded();
OnModify(); OnModify();
break; break;
} }
@ -532,12 +533,6 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
loadedBoard->BuildListOfNets(); loadedBoard->BuildListOfNets();
loadedBoard->SynchronizeNetsAndNetClasses(); loadedBoard->SynchronizeNetsAndNetClasses();
SetStatusText( wxEmptyString );
Zoom_Automatique( false );
// update the layer names in the listbox
ReCreateLayerBox( false );
GetScreen()->ClrModify(); GetScreen()->ClrModify();
{ {
@ -567,8 +562,6 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
GetBoard()->SetFileName( fname ); GetBoard()->SetFileName( fname );
} }
UpdateTitle();
if( !converted ) if( !converted )
UpdateFileHistory( GetBoard()->GetFileName() ); UpdateFileHistory( GetBoard()->GetFileName() );
@ -582,27 +575,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
Compile_Ratsnest( NULL, true ); Compile_Ratsnest( NULL, true );
GetBoard()->BuildConnectivity(); GetBoard()->BuildConnectivity();
// Update info shown by the horizontal toolbars onBoardLoaded();
ReFillLayerWidget();
ReCreateLayerBox();
// upate the layer widget to match board visibility states, both layers and render columns.
syncLayerVisibilities();
syncLayerWidgetLayer();
syncRenderStates();
// Update the tracks / vias available sizes list:
ReCreateAuxiliaryToolbar();
// Update the RATSNEST items, which were not loaded at the time
// BOARD::SetVisibleElements() was called from within any PLUGIN.
// See case LAYER_RATSNEST: in BOARD::SetElementVisibility()
GetBoard()->SetVisibleElements( GetBoard()->GetVisibleElements() );
// Display the loaded board:
Zoom_Automatique( false );
SetMsgPanel( GetBoard() );
// Refresh the 3D view, if any // Refresh the 3D view, if any
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame(); EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();

View File

@ -946,6 +946,35 @@ void PCB_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer )
} }
void PCB_EDIT_FRAME::onBoardLoaded()
{
UpdateTitle();
// Re-create layers manager based on layer info in board
ReFillLayerWidget();
ReCreateLayerBox();
// Sync layer and item visibility
syncLayerVisibilities();
syncLayerWidgetLayer();
syncRenderStates();
// Update the tracks / vias available sizes list:
ReCreateAuxiliaryToolbar();
// Update the RATSNEST items, which were not loaded at the time
// BOARD::SetVisibleElements() was called from within any PLUGIN.
// See case LAYER_RATSNEST: in BOARD::SetElementVisibility()
GetBoard()->SetVisibleElements( GetBoard()->GetVisibleElements() );
// Display the loaded board:
Zoom_Automatique( false );
SetMsgPanel( GetBoard() );
SetStatusText( wxEmptyString );
}
void PCB_EDIT_FRAME::syncLayerWidgetLayer() void PCB_EDIT_FRAME::syncLayerWidgetLayer()
{ {
m_Layers->SelectLayer( GetActiveLayer() ); m_Layers->SelectLayer( GetActiveLayer() );

View File

@ -163,6 +163,11 @@ protected:
return FindWindowByName( pythonConsoleNameId() ); return FindWindowByName( pythonConsoleNameId() );
} }
/**
* Updates the state of the GUI after a new board is loaded or created
*/
void onBoardLoaded();
/** /**
* Function syncLayerWidgetLayer * Function syncLayerWidgetLayer
* updates the currently layer "selection" within the PCB_LAYER_WIDGET. * updates the currently layer "selection" within the PCB_LAYER_WIDGET.