Pcbnew saves the type of used canvas.
This commit is contained in:
parent
1d6fc920e6
commit
6018bb6625
|
@ -291,6 +291,10 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
|
|||
|
||||
case GAL_TYPE_NONE:
|
||||
return false;
|
||||
|
||||
default:
|
||||
assert( false );
|
||||
return false;
|
||||
}
|
||||
|
||||
delete m_gal;
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
GAL_TYPE_NONE, ///< Not used
|
||||
GAL_TYPE_OPENGL, ///< OpenGL implementation
|
||||
GAL_TYPE_CAIRO, ///< Cairo implementation
|
||||
GAL_TYPE_LAST ///< Sentinel, do not use as a parameter
|
||||
};
|
||||
|
||||
EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId, const wxPoint& aPosition,
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <richio.h>
|
||||
#include <class_pcb_screen.h>
|
||||
#include <pcbstruct.h>
|
||||
#include <class_draw_panel_gal.h>
|
||||
|
||||
|
||||
/* Forward declarations of classes. */
|
||||
|
@ -681,6 +682,21 @@ public:
|
|||
*/
|
||||
void SwitchCanvas( wxCommandEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Function LoadCanvasTypeSetting()
|
||||
* Returns the canvas type stored in the application settings.
|
||||
*/
|
||||
EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting() const;
|
||||
|
||||
/**
|
||||
* Function SaveCanvasTypeSetting()
|
||||
* Stores the canvas type in the application settings.
|
||||
*/
|
||||
bool SaveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType );
|
||||
|
||||
///> Key in KifaceSettings to store the canvas type.
|
||||
static const wxString CANVAS_TYPE_KEY;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
|
|
@ -920,23 +920,30 @@ void PCB_BASE_FRAME::SetPrevGrid()
|
|||
|
||||
void PCB_BASE_FRAME::SwitchCanvas( wxCommandEvent& aEvent )
|
||||
{
|
||||
int id = aEvent.GetId();
|
||||
bool use_gal = false;
|
||||
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
|
||||
|
||||
switch( id )
|
||||
switch( aEvent.GetId() )
|
||||
{
|
||||
case ID_MENU_CANVAS_DEFAULT:
|
||||
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;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
||||
SaveCanvasTypeSetting( canvasType );
|
||||
UseGalCanvas( use_gal );
|
||||
}
|
||||
|
||||
|
@ -971,3 +978,44 @@ void PCB_BASE_FRAME::UseGalCanvas( bool aEnable )
|
|||
galCanvas->SetEventDispatcher( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EDA_DRAW_PANEL_GAL::GAL_TYPE PCB_BASE_FRAME::LoadCanvasTypeSetting() const
|
||||
{
|
||||
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
|
||||
|
||||
wxConfigBase* cfg = Kiface().KifaceSettings();
|
||||
|
||||
if( cfg )
|
||||
cfg->Read( CANVAS_TYPE_KEY, (long*) &canvasType );
|
||||
|
||||
if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
|
||||
|| canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
|
||||
{
|
||||
assert( false );
|
||||
canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
|
||||
}
|
||||
|
||||
return canvasType;
|
||||
}
|
||||
|
||||
|
||||
bool PCB_BASE_FRAME::SaveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
|
||||
{
|
||||
if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
|
||||
|| aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
|
||||
{
|
||||
assert( false );
|
||||
return false;
|
||||
}
|
||||
|
||||
wxConfigBase* cfg = Kiface().KifaceSettings();
|
||||
|
||||
if( cfg )
|
||||
return cfg->Write( CANVAS_TYPE_KEY, (long) aCanvasType );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const wxString PCB_BASE_FRAME::CANVAS_TYPE_KEY = wxT( "canvas_type" );
|
||||
|
|
|
@ -321,6 +321,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
m_hasAutoSave = true;
|
||||
m_RecordingMacros = -1;
|
||||
m_microWaveToolBar = NULL;
|
||||
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = LoadCanvasTypeSetting();
|
||||
|
||||
m_rotationAngle = 900;
|
||||
|
||||
|
@ -329,7 +330,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
|
||||
// Create GAL canvas
|
||||
SetGalCanvas( new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
|
||||
PCB_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) );
|
||||
canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ? EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO : canvasType ) );
|
||||
|
||||
SetBoard( new BOARD() );
|
||||
|
||||
|
@ -453,6 +454,13 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
enableGALSpecificMenus();
|
||||
|
||||
Zoom_Automatique( false );
|
||||
|
||||
if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
|
||||
{
|
||||
GetGalCanvas()->SwitchBackend( canvasType );
|
||||
UseGalCanvas( true );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue