diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp index 7236fd74d1..215e5ea981 100644 --- a/common/draw_frame.cpp +++ b/common/draw_frame.cpp @@ -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; wxConfigBase* cfg = Kiface().KifaceSettings(); diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index e3f490d8e0..61a1e69a9f 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -201,7 +201,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): SetActiveLayer( 0, true ); 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 if( m_firstRunDialogSetting < 1 ) diff --git a/gerbview/gerbview_layer_widget.cpp b/gerbview/gerbview_layer_widget.cpp index 1d4dbd1618..78ebe98516 100644 --- a/gerbview/gerbview_layer_widget.cpp +++ b/gerbview/gerbview_layer_widget.cpp @@ -257,6 +257,7 @@ void GERBER_LAYER_WIDGET::ReFill() wxEmptyString, visible, true ) ); } + UpdateLayouts(); Thaw(); } diff --git a/include/draw_frame.h b/include/draw_frame.h index 745553421e..0e029c9b3e 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -211,11 +211,6 @@ protected: */ 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. */ @@ -872,6 +867,11 @@ public: */ 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 * used to switch between standard and GAL-based canvas. diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 3288697f41..ac36bc41ca 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -202,7 +202,8 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) 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, wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() ) @@ -218,11 +219,8 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SetIcon( icon ); // Create GAL canvas - bool boardEditorWasRunning = Kiway().Player( FRAME_PCB, false ) != nullptr; - PCB_BASE_FRAME* pcbFrame = static_cast( Kiway().Player( FRAME_PCB, true ) ); PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, - GetGalDisplayOptions(), - pcbFrame->GetGalCanvas()->GetBackend() ); + GetGalDisplayOptions(), aBackend ); SetGalCanvas( drawPanel ); 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 setupTools(); GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); - UseGalCanvas( pcbFrame->IsGalCanvasActive() ); + UseGalCanvas( aBackend != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ); if( m_auimgr.GetPane( "m_LayersManagerToolBar" ).IsShown() ) { @@ -345,9 +343,6 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_Layers->OnLayerSelected(); } - if( !boardEditorWasRunning ) - pcbFrame->Destroy(); - m_auimgr.Update(); updateTitle(); diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index 28cac3a612..5b8d867845 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -487,7 +487,7 @@ public: protected: /// 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 diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 5a1b3edaa5..bc426c4dd5 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -120,7 +120,9 @@ END_EVENT_TABLE() #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" ), wxDefaultPosition, wxDefaultSize, aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ? @@ -185,22 +187,10 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent ReCreateLibraryList(); 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( Kiway().Player( FRAME_PCB, true ) ); - // Create GAL canvas PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, - pcbEditorFrame->GetGalDisplayOptions(), - pcbEditorFrame->GetGalCanvas()->GetBackend() ); + GetGalDisplayOptions(), aBackend ); 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 m_toolManager = new TOOL_MANAGER; @@ -295,7 +285,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent #endif GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); - UseGalCanvas( switchToGalCanvas ); + UseGalCanvas( aBackend != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ); updateView(); if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame diff --git a/pcbnew/footprint_viewer_frame.h b/pcbnew/footprint_viewer_frame.h index 832935135e..99290c5176 100644 --- a/pcbnew/footprint_viewer_frame.h +++ b/pcbnew/footprint_viewer_frame.h @@ -48,7 +48,8 @@ class FOOTPRINT_VIEWER_FRAME : public PCB_BASE_FRAME friend struct PCB::IFACE; // constructor called from here only 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: diff --git a/pcbnew/layer_widget.cpp b/pcbnew/layer_widget.cpp index cf803f3bbc..4e4986409e 100644 --- a/pcbnew/layer_widget.cpp +++ b/pcbnew/layer_widget.cpp @@ -610,7 +610,6 @@ void LAYER_WIDGET::AppendLayerRow( const ROW& aRow ) { int nextRow = GetLayerRowCount(); insertLayerRow( nextRow, aRow ); - UpdateLayouts(); } @@ -624,7 +623,6 @@ void LAYER_WIDGET::AppendRenderRow( const ROW& aRow ) { int nextRow = GetRenderRowCount(); insertRenderRow( nextRow, aRow ); - UpdateLayouts(); } diff --git a/pcbnew/layer_widget.h b/pcbnew/layer_widget.h index 4112a7341a..3f1cc1a2ad 100644 --- a/pcbnew/layer_widget.h +++ b/pcbnew/layer_widget.h @@ -307,6 +307,8 @@ public: { for( int row=0; row( 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: return new FOOTPRINT_WIZARD_FRAME( aKiway, aParent, FRAME_T( aClassId ) );