Performance enhancements for Footprint Editor construction.

This commit is contained in:
Jeff Young 2018-08-03 20:41:57 +01:00
parent 92b3aca0ef
commit 33fc74a04d
13 changed files with 47 additions and 39 deletions

View File

@ -1262,7 +1262,7 @@ bool EDA_DRAW_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
} }
EDA_DRAW_PANEL_GAL::GAL_TYPE EDA_DRAW_FRAME::loadCanvasTypeSetting() const EDA_DRAW_PANEL_GAL::GAL_TYPE EDA_DRAW_FRAME::LoadCanvasTypeSetting()
{ {
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE; EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
wxConfigBase* cfg = Kiface().KifaceSettings(); wxConfigBase* cfg = Kiface().KifaceSettings();

View File

@ -201,7 +201,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
SetActiveLayer( 0, true ); SetActiveLayer( 0, true );
Zoom_Automatique( false ); // Gives a default zoom value Zoom_Automatique( false ); // Gives a default zoom value
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = loadCanvasTypeSetting(); EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = LoadCanvasTypeSetting();
// Nudge user to switch to OpenGL if they are on legacy or Cairo // Nudge user to switch to OpenGL if they are on legacy or Cairo
if( m_firstRunDialogSetting < 1 ) if( m_firstRunDialogSetting < 1 )

View File

@ -257,6 +257,7 @@ void GERBER_LAYER_WIDGET::ReFill()
wxEmptyString, visible, true ) ); wxEmptyString, visible, true ) );
} }
UpdateLayouts();
Thaw(); Thaw();
} }

View File

@ -211,11 +211,6 @@ protected:
*/ */
bool isBusy() const; bool isBusy() const;
/**
* Returns the canvas type stored in the application settings.
*/
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting() const;
/** /**
* Stores the canvas type in the application settings. * Stores the canvas type in the application settings.
*/ */
@ -872,6 +867,11 @@ public:
*/ */
virtual void PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData = NULL ); virtual void PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData = NULL );
/**
* Returns the canvas type stored in the application settings.
*/
static EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting();
/** /**
* Function UseGalCanvas * Function UseGalCanvas
* used to switch between standard and GAL-based canvas. * used to switch between standard and GAL-based canvas.

View File

@ -202,7 +202,8 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
END_EVENT_TABLE() END_EVENT_TABLE()
FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend ) :
PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_MODULE_EDITOR, wxEmptyString, PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_MODULE_EDITOR, wxEmptyString,
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() ) KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() )
@ -218,11 +219,8 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SetIcon( icon ); SetIcon( icon );
// Create GAL canvas // Create GAL canvas
bool boardEditorWasRunning = Kiway().Player( FRAME_PCB, false ) != nullptr;
PCB_BASE_FRAME* pcbFrame = static_cast<PCB_BASE_FRAME*>( Kiway().Player( FRAME_PCB, true ) );
PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
GetGalDisplayOptions(), GetGalDisplayOptions(), aBackend );
pcbFrame->GetGalCanvas()->GetBackend() );
SetGalCanvas( drawPanel ); SetGalCanvas( drawPanel );
SetBoard( new BOARD() ); SetBoard( new BOARD() );
@ -333,7 +331,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
// Create the manager and dispatcher & route draw panel events to the dispatcher // Create the manager and dispatcher & route draw panel events to the dispatcher
setupTools(); setupTools();
GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
UseGalCanvas( pcbFrame->IsGalCanvasActive() ); UseGalCanvas( aBackend != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
if( m_auimgr.GetPane( "m_LayersManagerToolBar" ).IsShown() ) if( m_auimgr.GetPane( "m_LayersManagerToolBar" ).IsShown() )
{ {
@ -345,9 +343,6 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_Layers->OnLayerSelected(); m_Layers->OnLayerSelected();
} }
if( !boardEditorWasRunning )
pcbFrame->Destroy();
m_auimgr.Update(); m_auimgr.Update();
updateTitle(); updateTitle();

View File

@ -487,7 +487,7 @@ public:
protected: protected:
/// protected so only friend PCB::IFACE::CreateWindow() can act as sole factory. /// protected so only friend PCB::IFACE::CreateWindow() can act as sole factory.
FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ); FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend );
PCB_LAYER_WIDGET* m_Layers; ///< the layer manager PCB_LAYER_WIDGET* m_Layers; ///< the layer manager

View File

@ -120,7 +120,9 @@ END_EVENT_TABLE()
#endif #endif
FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType ) : FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent,
FRAME_T aFrameType,
EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend ) :
PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ), PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ),
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ? aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ?
@ -185,22 +187,10 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
ReCreateLibraryList(); ReCreateLibraryList();
UpdateTitle(); UpdateTitle();
// See for an existing board editor frame opened
// (we need it just to know some settings )
// TODO: find a better way to retrieve these settings)
bool isBordEditorRunning = Kiway().Player( FRAME_PCB, false ) != nullptr;
PCB_BASE_FRAME* pcbEditorFrame = static_cast<PCB_BASE_FRAME*>( Kiway().Player( FRAME_PCB, true ) );
// Create GAL canvas // Create GAL canvas
PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
pcbEditorFrame->GetGalDisplayOptions(), GetGalDisplayOptions(), aBackend );
pcbEditorFrame->GetGalCanvas()->GetBackend() );
SetGalCanvas( drawPanel ); SetGalCanvas( drawPanel );
bool switchToGalCanvas = pcbEditorFrame->IsGalCanvasActive();
// delete pcbEditorFrame if it was not yet in use:
if( !isBordEditorRunning )
pcbEditorFrame->Destroy();
// Create the manager and dispatcher & route draw panel events to the dispatcher // Create the manager and dispatcher & route draw panel events to the dispatcher
m_toolManager = new TOOL_MANAGER; m_toolManager = new TOOL_MANAGER;
@ -295,7 +285,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
#endif #endif
GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
UseGalCanvas( switchToGalCanvas ); UseGalCanvas( aBackend != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
updateView(); updateView();
if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame

View File

@ -48,7 +48,8 @@ class FOOTPRINT_VIEWER_FRAME : public PCB_BASE_FRAME
friend struct PCB::IFACE; // constructor called from here only friend struct PCB::IFACE; // constructor called from here only
protected: protected:
FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType ); FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
EDA_DRAW_PANEL_GAL::GAL_TYPE aBackend );
public: public:

View File

@ -610,7 +610,6 @@ void LAYER_WIDGET::AppendLayerRow( const ROW& aRow )
{ {
int nextRow = GetLayerRowCount(); int nextRow = GetLayerRowCount();
insertLayerRow( nextRow, aRow ); insertLayerRow( nextRow, aRow );
UpdateLayouts();
} }
@ -624,7 +623,6 @@ void LAYER_WIDGET::AppendRenderRow( const ROW& aRow )
{ {
int nextRow = GetRenderRowCount(); int nextRow = GetRenderRowCount();
insertRenderRow( nextRow, aRow ); insertRenderRow( nextRow, aRow );
UpdateLayouts();
} }

View File

@ -307,6 +307,8 @@ public:
{ {
for( int row=0; row<aRowCount; ++row ) for( int row=0; row<aRowCount; ++row )
AppendLayerRow( aRowsArray[row] ); AppendLayerRow( aRowsArray[row] );
UpdateLayouts();
} }
/** /**
@ -331,6 +333,8 @@ public:
{ {
for( int row=0; row<aRowCount; ++row ) for( int row=0; row<aRowCount; ++row )
AppendRenderRow( aRowsArray[row] ); AppendRenderRow( aRowsArray[row] );
UpdateLayouts();
} }
/** /**

View File

@ -437,7 +437,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
Zoom_Automatique( false ); Zoom_Automatique( false );
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = loadCanvasTypeSetting(); EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = LoadCanvasTypeSetting();
// Nudge user to switch to OpenGL if they are on legacy or Cairo // Nudge user to switch to OpenGL if they are on legacy or Cairo
if( m_firstRunDialogSetting < 1 ) if( m_firstRunDialogSetting < 1 )

View File

@ -426,6 +426,8 @@ void PCB_LAYER_WIDGET::ReFillRender()
AppendRenderRow( renderRow ); AppendRenderRow( renderRow );
} }
UpdateLayouts();
} }
@ -526,6 +528,8 @@ void PCB_LAYER_WIDGET::ReFill()
} }
} }
UpdateLayouts();
// technical layers are shown in this order: // technical layers are shown in this order:
// Because they are static, wxGetTranslation must be explicitly // Because they are static, wxGetTranslation must be explicitly

View File

@ -127,11 +127,26 @@ static struct IFACE : public KIFACE_I
} }
case FRAME_PCB_MODULE_EDITOR: case FRAME_PCB_MODULE_EDITOR:
return new FOOTPRINT_EDIT_FRAME( aKiway, aParent );
case FRAME_PCB_MODULE_VIEWER: case FRAME_PCB_MODULE_VIEWER:
case FRAME_PCB_MODULE_VIEWER_MODAL: case FRAME_PCB_MODULE_VIEWER_MODAL:
return new FOOTPRINT_VIEWER_FRAME( aKiway, aParent, FRAME_T( aClassId ) ); {
EDA_DRAW_PANEL_GAL::GAL_TYPE backend;
auto pcbFrame = static_cast<PCB_EDIT_FRAME*>( wxWindow::FindWindowByName( wxT( "Pcbnew" ) ) );
if( pcbFrame )
backend = pcbFrame->GetGalCanvas()->GetBackend();
else
backend = EDA_DRAW_FRAME::LoadCanvasTypeSetting();
switch( aClassId )
{
case FRAME_PCB_MODULE_EDITOR:
return new FOOTPRINT_EDIT_FRAME( aKiway, aParent, backend );
case FRAME_PCB_MODULE_VIEWER:
case FRAME_PCB_MODULE_VIEWER_MODAL:
return new FOOTPRINT_VIEWER_FRAME( aKiway, aParent, FRAME_T( aClassId ), backend );
}
}
case FRAME_PCB_FOOTPRINT_WIZARD_MODAL: case FRAME_PCB_FOOTPRINT_WIZARD_MODAL:
return new FOOTPRINT_WIZARD_FRAME( aKiway, aParent, FRAME_T( aClassId ) ); return new FOOTPRINT_WIZARD_FRAME( aKiway, aParent, FRAME_T( aClassId ) );