Move SwitchCanvas() implementation to EDA_DRAW_FRAME

Share more code between pcbnew and gerbview. Fix warnings regarding
shadowing EDA_DRAW_FRAME::SwitchCanvas().
This commit is contained in:
Maciej Suminski 2018-01-21 12:04:04 +01:00
parent b3cb6be48e
commit da305e7750
6 changed files with 29 additions and 46 deletions

View File

@ -1191,6 +1191,20 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
}
bool EDA_DRAW_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
{
auto galCanvas = GetGalCanvas();
wxCHECK( galCanvas, false );
bool use_gal = galCanvas->SwitchBackend( aCanvasType );
use_gal &= aCanvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
UseGalCanvas( use_gal );
m_canvasType = use_gal ? aCanvasType : EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
m_canvasTypeDirty = true;
return use_gal;
}
EDA_DRAW_PANEL_GAL::GAL_TYPE EDA_DRAW_FRAME::loadCanvasTypeSetting() const
{
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;

View File

@ -90,9 +90,9 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
EVT_UPDATE_UI( ID_MENU_CANVAS_LEGACY, GERBVIEW_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, GERBVIEW_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, GERBVIEW_FRAME::OnUpdateSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_LEGACY, GERBVIEW_FRAME::SwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_CAIRO, GERBVIEW_FRAME::SwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_OPENGL, GERBVIEW_FRAME::SwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_LEGACY, GERBVIEW_FRAME::OnSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_CAIRO, GERBVIEW_FRAME::OnSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_OPENGL, GERBVIEW_FRAME::OnSwitchCanvas )
// menu Postprocess
EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, GERBVIEW_FRAME::Process_Special_Functions )
@ -538,37 +538,22 @@ void GERBVIEW_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
}
void GERBVIEW_FRAME::SwitchCanvas( wxCommandEvent& aEvent )
void GERBVIEW_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
{
bool use_gal = false;
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
switch( aEvent.GetId() )
{
case ID_MENU_CANVAS_LEGACY:
SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
break;
case ID_MENU_CANVAS_CAIRO:
use_gal = GetGalCanvas()->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
if( use_gal )
canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
break;
case ID_MENU_CANVAS_OPENGL:
use_gal = GetGalCanvas()->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
if( use_gal )
canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
break;
}
UseGalCanvas( use_gal );
wxUpdateUIEvent e;
OnUpdateSwitchCanvas( e );
m_canvasType = canvasType;
m_canvasTypeDirty = true;
}

View File

@ -734,7 +734,7 @@ public:
/**
* switches currently used canvas (default / Cairo / OpenGL).
*/
void SwitchCanvas( wxCommandEvent& aEvent );
void OnSwitchCanvas( wxCommandEvent& aEvent );
/**
* Update UI called when switches currently used canvas (default / Cairo / OpenGL).

View File

@ -337,12 +337,6 @@ public:
bool ShowPageLimits() const { return m_showPageLimits; }
void SetShowPageLimits( bool aShow ) { m_showPageLimits = aShow; }
virtual bool SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
{
wxFAIL_MSG( "SwitchCanvas not implemented" );
return false;
}
EDA_DRAW_PANEL* GetCanvas() { return m_canvas; }
virtual wxString GetScreenDesc() const;
@ -862,6 +856,13 @@ public:
*/
virtual void UseGalCanvas( bool aEnable );
/**
* Changes the current rendering backend.
* aCanvasType is the new rendering backend type.
* @return true if any kind of GAL canvas is used.
*/
virtual bool SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType );
/**
* Function IsGalCanvasActive
* is used to check which canvas (GAL-based or standard) is currently in use.

View File

@ -686,11 +686,6 @@ public:
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas
virtual void UseGalCanvas( bool aEnable ) override;
/**
* switches currently used canvas (default / Cairo / OpenGL).
*/
bool SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) override;
/**
* Update UI called when switches currently used canvas (default / Cairo / OpenGL).
*/

View File

@ -1006,18 +1006,6 @@ void PCB_BASE_FRAME::UseGalCanvas( bool aEnable )
}
bool PCB_BASE_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
{
bool use_gal = GetGalCanvas()->SwitchBackend( aCanvasType );
use_gal &= aCanvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
UseGalCanvas( use_gal );
m_canvasType = use_gal ? aCanvasType : EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
m_canvasTypeDirty = true;
return use_gal;
}
void PCB_BASE_FRAME::OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent )
{
wxMenuBar* menuBar = GetMenuBar();