From 84ba36fa72e975f8d95a21e616a860d2d857936e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 19 May 2015 18:39:05 +0200 Subject: [PATCH] Allows switching GAL or legacy mode in footprint editor (previously, the mode was inherited from the board editor, and was not modifiable without closing the footprint editor) by menu or F9, F11 and F12 keys) --- common/draw_frame.cpp | 2 +- common/zoom.cpp | 10 +- eeschema/libeditframe.cpp | 2 +- eeschema/schframe.cpp | 2 +- eeschema/viewlib_frame.cpp | 2 +- gerbview/gerbview_frame.cpp | 4 +- include/draw_frame.h | 2 +- include/wxPcbStruct.h | 4 +- pagelayout_editor/pl_editor_frame.cpp | 2 +- pcbnew/footprint_wizard_frame.cpp | 2 +- pcbnew/hotkeys.cpp | 1 + pcbnew/menubar_modedit.cpp | 40 ++++++-- pcbnew/menubar_pcbframe.cpp | 8 +- pcbnew/modedit.cpp | 12 --- pcbnew/module_editor_frame.h | 9 ++ pcbnew/moduleframe.cpp | 135 ++++++++++++++++++-------- pcbnew/modview_frame.cpp | 2 +- pcbnew/pcbframe.cpp | 2 +- 18 files changed, 157 insertions(+), 84 deletions(-) diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp index fe422ee03c..74806935d0 100644 --- a/common/draw_frame.cpp +++ b/common/draw_frame.cpp @@ -107,7 +107,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, m_optionsToolBar = NULL; m_gridSelectBox = NULL; m_zoomSelectBox = NULL; - m_HotkeysZoomAndGridList = NULL; + m_hotkeysDescrList = NULL; m_canvas = NULL; m_galCanvas = NULL; diff --git a/common/zoom.cpp b/common/zoom.cpp index eb81413360..5107ab88dc 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -243,15 +243,15 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu ) wxString msg; BASE_SCREEN* screen = m_canvas->GetScreen(); - msg = AddHotkeyName( _( "Center" ), m_HotkeysZoomAndGridList, HK_ZOOM_CENTER ); + msg = AddHotkeyName( _( "Center" ), m_hotkeysDescrList, HK_ZOOM_CENTER ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_CENTER, msg, KiBitmap( zoom_center_on_screen_xpm ) ); - msg = AddHotkeyName( _( "Zoom in" ), m_HotkeysZoomAndGridList, HK_ZOOM_IN ); + msg = AddHotkeyName( _( "Zoom in" ), m_hotkeysDescrList, HK_ZOOM_IN ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_IN, msg, KiBitmap( zoom_in_xpm ) ); - msg = AddHotkeyName( _( "Zoom out" ), m_HotkeysZoomAndGridList, HK_ZOOM_OUT ); + msg = AddHotkeyName( _( "Zoom out" ), m_hotkeysDescrList, HK_ZOOM_OUT ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_OUT, msg, KiBitmap( zoom_out_xpm ) ); - msg = AddHotkeyName( _( "Redraw view" ), m_HotkeysZoomAndGridList, HK_ZOOM_REDRAW ); + msg = AddHotkeyName( _( "Redraw view" ), m_hotkeysDescrList, HK_ZOOM_REDRAW ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_REDRAW, msg, KiBitmap( zoom_redraw_xpm ) ); - msg = AddHotkeyName( _( "Zoom auto" ), m_HotkeysZoomAndGridList, HK_ZOOM_AUTO ); + msg = AddHotkeyName( _( "Zoom auto" ), m_hotkeysDescrList, HK_ZOOM_AUTO ); AddMenuItem( MasterMenu, ID_POPUP_ZOOM_PAGE, msg, KiBitmap( zoom_fit_in_page_xpm ) ); diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index fa7a8d863b..c7ab53290a 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -190,7 +190,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SetShowDeMorgan( false ); m_drawSpecificConvert = true; m_drawSpecificUnit = false; - m_HotkeysZoomAndGridList = g_Libedit_Hokeys_Descr; + m_hotkeysDescrList = g_Libedit_Hokeys_Descr; m_editPinsPerPartOrConvert = false; m_repeatPinStep = DEFAULT_REPEAT_OFFSET_PIN; diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 636350fc5d..a9c3290de4 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -319,7 +319,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): m_printMonochrome = true; m_printSheetReference = true; SetShowPageLimits( true ); - m_HotkeysZoomAndGridList = g_Schematic_Hokeys_Descr; + m_hotkeysDescrList = g_Schematic_Hokeys_Descr; m_dlgFindReplace = NULL; m_findReplaceData = new wxFindReplaceData( wxFR_DOWN ); m_undoItem = NULL; diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index c46ea4cc9e..c3088c0885 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -99,7 +99,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame icon.CopyFromBitmap( KiBitmap( library_browse_xpm ) ); SetIcon( icon ); - m_HotkeysZoomAndGridList = g_Viewlib_Hokeys_Descr; + m_hotkeysDescrList = g_Viewlib_Hokeys_Descr; m_cmpList = NULL; m_libList = NULL; m_listPowerCmpOnly = false; diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index c576e8c204..28fc6e3d68 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -79,8 +79,8 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): m_show_layer_manager_tools = true; m_showAxis = true; // true to show X and Y axis on screen - m_showBorderAndTitleBlock = false; // true for reference drawings. - m_HotkeysZoomAndGridList = GerbviewHokeysDescr; + m_showBorderAndTitleBlock = false; // true for reference drawings. + m_hotkeysDescrList = GerbviewHokeysDescr; m_SelLayerBox = NULL; m_DCodeSelector = NULL; m_displayMode = 0; diff --git a/include/draw_frame.h b/include/draw_frame.h index 5d346e7068..0c108b21c5 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -56,7 +56,7 @@ protected: wxSingleInstanceChecker* m_file_checker; ///< prevents opening same file multiple times. - EDA_HOTKEY_CONFIG* m_HotkeysZoomAndGridList; + EDA_HOTKEY_CONFIG* m_hotkeysDescrList; int m_LastGridSizeId; // the command id offset (>= 0) of the last selected grid // 0 is for the grid corresponding to // a wxCommand ID = ID_POPUP_GRID_LEVEL_1000. diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index c94f9a1ada..d32d13acf5 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -625,14 +625,14 @@ public: void Show3D_Frame( wxCommandEvent& event ); /** - * Function UseGalCanvas + * Virtual function UseGalCanvas * Enables/disables GAL canvas. * @param aEnable determines if GAL should be active or not. */ void UseGalCanvas( bool aEnable ); /** - * Function ChangeCanvas + * Function SwitchCanvas * switches currently used canvas (default / Cairo / OpenGL). */ void SwitchCanvas( wxCommandEvent& aEvent ); diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 29b746b5cf..8f1ac4fba5 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -62,7 +62,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_showAxis = false; // true to show X and Y axis on screen m_showGridAxis = true; m_showBorderAndTitleBlock = true; // true for reference drawings. - m_HotkeysZoomAndGridList = PlEditorHokeysDescr; + m_hotkeysDescrList = PlEditorHokeysDescr; m_originSelectChoice = 0; SetDrawBgColor( WHITE ); // default value, user option (WHITE/BLACK) SetShowPageLimits( true ); diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index f76d29f772..a30244e54c 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -114,7 +114,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) ); SetIcon( icon ); - m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr; + m_hotkeysDescrList = g_Module_Viewer_Hokeys_Descr; m_wizardName.Empty(); SetBoard( new BOARD() ); diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index 783b57f256..46cf644d4a 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -319,6 +319,7 @@ EDA_HOTKEY* module_edit_Hotkey_List[] = { &HkMoveItem, &HkRotateItem, &HkEditBoardItem, &HkMoveItemExact, &HkDuplicateItem, &HkDuplicateItemAndIncrement, &HkCreateArray, &HkDelete, &HkSaveModule, + &HkCanvasDefault, &HkCanvasCairo, &HkCanvasOpenGL, NULL }; diff --git a/pcbnew/menubar_modedit.cpp b/pcbnew/menubar_modedit.cpp index a3c1ad0ae7..4140b9f895 100644 --- a/pcbnew/menubar_modedit.cpp +++ b/pcbnew/menubar_modedit.cpp @@ -110,7 +110,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() // Save module text = AddHotkeyName( _( "&Save Footprint in Active Library" ), - g_Module_Editor_Hokeys_Descr, HK_SAVE_MODULE ); + m_hotkeysDescrList, HK_SAVE_MODULE ); AddMenuItem( fileMenu, ID_MODEDIT_SAVE_LIBMODULE, text, _( "Save footprint in active library" ), @@ -155,13 +155,13 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() wxMenu* editMenu = new wxMenu; // Undo - text = AddHotkeyName( _( "&Undo" ), g_Module_Editor_Hokeys_Descr, HK_UNDO ); + text = AddHotkeyName( _( "&Undo" ), m_hotkeysDescrList, HK_UNDO ); AddMenuItem( editMenu, wxID_UNDO, text, _( "Undo last action" ), KiBitmap( undo_xpm ) ); // Redo - text = AddHotkeyName( _( "&Redo" ), g_Module_Editor_Hokeys_Descr, HK_REDO ); + text = AddHotkeyName( _( "&Redo" ), m_hotkeysDescrList, HK_REDO ); AddMenuItem( editMenu, wxID_REDO, text, _( "Redo last action" ), KiBitmap( redo_xpm ) ); @@ -213,30 +213,54 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() * in other words HK_ZOOM_IN and HK_ZOOM_OUT *are NOT* accelerators * for Zoom in and Zoom out sub menus */ - text = AddHotkeyName( _( "Zoom &In" ), g_Module_Editor_Hokeys_Descr, + text = AddHotkeyName( _( "Zoom &In" ), m_hotkeysDescrList, HK_ZOOM_IN, IS_ACCELERATOR ); AddMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) ); - text = AddHotkeyName( _( "Zoom &Out" ), g_Module_Editor_Hokeys_Descr, + text = AddHotkeyName( _( "Zoom &Out" ), m_hotkeysDescrList, HK_ZOOM_OUT, IS_ACCELERATOR ); AddMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) ); - text = AddHotkeyName( _( "&Fit on Screen" ), g_Module_Editor_Hokeys_Descr, + text = AddHotkeyName( _( "&Fit on Screen" ), m_hotkeysDescrList, HK_ZOOM_AUTO ); AddMenuItem( viewMenu, ID_ZOOM_PAGE, text, HELP_ZOOM_FIT, KiBitmap( zoom_fit_in_page_xpm ) ); - text = AddHotkeyName( _( "&Redraw" ), g_Module_Editor_Hokeys_Descr, HK_ZOOM_REDRAW ); + text = AddHotkeyName( _( "&Redraw" ), m_hotkeysDescrList, HK_ZOOM_REDRAW ); AddMenuItem( viewMenu, ID_ZOOM_REDRAW, text, HELP_ZOOM_REDRAW, KiBitmap( zoom_redraw_xpm ) ); viewMenu->AppendSeparator(); // 3D view - text = AddHotkeyName( _( "&3D Viewer" ), g_Module_Editor_Hokeys_Descr, HK_3D_VIEWER ); + text = AddHotkeyName( _( "&3D Viewer" ), m_hotkeysDescrList, HK_3D_VIEWER ); AddMenuItem( viewMenu, ID_MENU_PCB_SHOW_3D_FRAME, text, _( "Show footprint in 3D viewer" ), KiBitmap( three_d_xpm ) ); + // Add canvas selection + viewMenu->AppendSeparator(); + + text = AddHotkeyName( _( "&Switch canvas to default" ), m_hotkeysDescrList, + HK_CANVAS_DEFAULT ); + + AddMenuItem( viewMenu, ID_MENU_CANVAS_DEFAULT, + text, _( "Switch the canvas implementation to default" ), + KiBitmap( tools_xpm ) ); + + text = AddHotkeyName( _( "Switch canvas to Open&GL" ), m_hotkeysDescrList, + HK_CANVAS_OPENGL ); + + AddMenuItem( viewMenu, ID_MENU_CANVAS_OPENGL, + text, _( "Switch the canvas implementation to OpenGL" ), + KiBitmap( tools_xpm ) ); + + text = AddHotkeyName( _( "Switch canvas to &Cairo" ), m_hotkeysDescrList, + HK_CANVAS_CAIRO ); + + AddMenuItem( viewMenu, ID_MENU_CANVAS_CAIRO, + text, _( "Switch the canvas implementation to Cairo" ), + KiBitmap( tools_xpm ) ); + //-------- Place menu -------------------- wxMenu* placeMenu = new wxMenu; diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index d4bf039706..9527d6d17f 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -69,7 +69,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() _( "Clear current board and initialize a new one" ), KiBitmap( new_pcb_xpm ) ); - text = AddHotkeyName( _( "&Open" ), g_Board_Editor_Hokeys_Descr, HK_LOAD_BOARD ); + text = AddHotkeyName( _( "&Open" ), m_hotkeysDescrList, HK_LOAD_BOARD ); AddMenuItem( filesMenu, ID_LOAD_FILE, text, _( "Delete current board and load new board" ), KiBitmap( open_brd_file_xpm ) ); @@ -106,7 +106,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() filesMenu->AppendSeparator(); - text = AddHotkeyName( _( "&Save" ), g_Board_Editor_Hokeys_Descr, HK_SAVE_BOARD ); + text = AddHotkeyName( _( "&Save" ), m_hotkeysDescrList, HK_SAVE_BOARD ); AddMenuItem( filesMenu, ID_SAVE_BOARD, text, _( "Save current board" ), KiBitmap( save_xpm ) ); @@ -118,7 +118,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() // when not under a project mgr, we are free to change filenames, cwd ... if( Kiface().IsSingle() ) // not when under a project mgr (pcbnew is run as stand alone) { - text = AddHotkeyName( _( "Sa&ve As..." ), g_Board_Editor_Hokeys_Descr, HK_SAVE_BOARD_AS ); + text = AddHotkeyName( _( "Sa&ve As..." ), m_hotkeysDescrList, HK_SAVE_BOARD_AS ); AddMenuItem( filesMenu, ID_SAVE_BOARD_AS, text, _( "Save the current board as..." ), KiBitmap( save_as_xpm ) ); @@ -127,7 +127,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() // but do not change the current board file name else { - text = AddHotkeyName( _( "Sa&ve Copy As..." ), g_Board_Editor_Hokeys_Descr, HK_SAVE_BOARD_AS ); + text = AddHotkeyName( _( "Sa&ve Copy As..." ), m_hotkeysDescrList, HK_SAVE_BOARD_AS ); AddMenuItem( filesMenu, ID_COPY_BOARD_AS, text, _( "Save a copy of the current board as..." ), KiBitmap( save_as_xpm ) ); diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 0012efdfa9..a8041c0f1f 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -993,15 +993,3 @@ void FOOTPRINT_EDIT_FRAME::SetActiveLayer( LAYER_ID aLayer ) GetGalCanvas()->Refresh(); } - -void FOOTPRINT_EDIT_FRAME::UseGalCanvas( bool aEnable ) -{ - EDA_DRAW_FRAME::UseGalCanvas( aEnable ); - - if( aEnable ) - { - SetBoard( m_Pcb ); - updateView(); - GetGalCanvas()->StartDrawing(); - } -} diff --git a/pcbnew/module_editor_frame.h b/pcbnew/module_editor_frame.h index cce0b90619..402dc98f8c 100644 --- a/pcbnew/module_editor_frame.h +++ b/pcbnew/module_editor_frame.h @@ -123,6 +123,9 @@ public: */ void ReCreateMenuBar(); + // The Tool Framework initalization, for GAL mode + void setupTools(); + void ToolOnRightClick( wxCommandEvent& event ); void OnSelectOptionToolbar( wxCommandEvent& event ); void OnConfigurePaths( wxCommandEvent& aEvent ); @@ -164,6 +167,12 @@ public: */ void Show3D_Frame( wxCommandEvent& event ); + /** + * Function SwitchCanvas + * switches currently used canvas (default / Cairo / OpenGL). + */ + void SwitchCanvas( wxCommandEvent& aEvent ); + bool GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); void OnVerticalToolbar( wxCommandEvent& aEvent ); diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 3cf9a7dd44..91459db108 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -165,6 +165,11 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME ) // Menu 3D Frame EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, FOOTPRINT_EDIT_FRAME::Show3D_Frame ) + // Switching canvases + EVT_MENU( ID_MENU_CANVAS_DEFAULT, FOOTPRINT_EDIT_FRAME::SwitchCanvas ) + EVT_MENU( ID_MENU_CANVAS_CAIRO, FOOTPRINT_EDIT_FRAME::SwitchCanvas ) + EVT_MENU( ID_MENU_CANVAS_OPENGL, FOOTPRINT_EDIT_FRAME::SwitchCanvas ) + EVT_UPDATE_UI( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::OnUpdateLibSelected ) EVT_UPDATE_UI( ID_MODEDIT_SELECT_CURRENT_LIB, FOOTPRINT_EDIT_FRAME::OnUpdateSelectCurrentLib ) EVT_UPDATE_UI( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected ) @@ -197,6 +202,9 @@ END_EVENT_TABLE() #define FOOTPRINT_EDIT_FRAME_NAME wxT( "ModEditFrame" ) +// Store the canvas mode during a session: +static enum PCB_DRAW_PANEL_GAL::GalType galmode = PCB_DRAW_PANEL_GAL::GAL_TYPE_NONE; + FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_MODULE_EDITOR, wxEmptyString, wxDefaultPosition, wxDefaultSize, @@ -205,7 +213,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_showBorderAndTitleBlock = false; // true to show the frame references m_showAxis = true; // true to show X and Y axis on screen m_showGridAxis = true; // show the grid origin axis - m_HotkeysZoomAndGridList = g_Module_Editor_Hokeys_Descr; + m_hotkeysDescrList = g_Module_Editor_Hokeys_Descr; // Give an icon wxIcon icon; @@ -216,9 +224,9 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : updateTitle(); // Create GAL canvas - PCB_BASE_FRAME* parentFrame = static_cast( Kiway().Player( FRAME_PCB, true ) ); PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, - parentFrame->GetGalCanvas()->GetBackend() ); + galmode != PCB_DRAW_PANEL_GAL::GAL_TYPE_NONE ? + galmode : PCB_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ); SetGalCanvas( drawPanel ); SetBoard( new BOARD() ); @@ -293,8 +301,8 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // Add the layer manager ( most right side of pcbframe ) m_auimgr.AddPane( m_Layers, lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 2 ) ); - // Layers manager is visible and served only in GAL canvas mode. - m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( true ); // parentFrame->IsGalCanvasActive() ); + // Layers manager is visible + m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( true ); // The left vertical toolbar (fast acces to display options) m_auimgr.AddPane( m_optionsToolBar, @@ -309,31 +317,8 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : wxAuiPaneInfo( mesg_pane ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) ); // Create the manager and dispatcher & route draw panel events to the dispatcher - m_toolManager = new TOOL_MANAGER; - m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(), - drawPanel->GetViewControls(), this ); - m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager ); - - if( parentFrame->IsGalCanvasActive() ) - { - drawPanel->SetEventDispatcher( m_toolDispatcher ); - - m_toolManager->RegisterTool( new SELECTION_TOOL ); - m_toolManager->RegisterTool( new EDIT_TOOL ); - m_toolManager->RegisterTool( new DRAWING_TOOL ); - m_toolManager->RegisterTool( new POINT_EDITOR ); - m_toolManager->RegisterTool( new PCBNEW_CONTROL ); - m_toolManager->RegisterTool( new MODULE_TOOLS ); - m_toolManager->RegisterTool( new PLACEMENT_TOOL ); - - m_toolManager->GetTool()->EditModules( true ); - m_toolManager->GetTool()->EditModules( true ); - m_toolManager->GetTool()->EditModules( true ); - - m_toolManager->ResetTools( TOOL_BASE::RUN ); - m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" ); - UseGalCanvas( true ); - } + setupTools(); + UseGalCanvas( galmode != PCB_DRAW_PANEL_GAL::GAL_TYPE_NONE ); if( m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).IsShown() ) { @@ -448,24 +433,12 @@ const wxChar* FOOTPRINT_EDIT_FRAME::GetFootprintEditorFrameName() BOARD_DESIGN_SETTINGS& FOOTPRINT_EDIT_FRAME::GetDesignSettings() const { - // get the BOARD_DESIGN_SETTINGS from the parent editor, not our BOARD. - - // @todo(DICK) change the routing to some default or the board directly, parent may not exist -// PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) Kiway().Player( FRAME_PCB, true ); -// wxASSERT( parentFrame ); - return GetBoard()->GetDesignSettings(); } void FOOTPRINT_EDIT_FRAME::SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings ) { - // set the BOARD_DESIGN_SETTINGS into parent editor, not our BOARD. - - // @todo(DICK) change the routing to some default or the board directly, parent may not exist -// PCB_BASE_FRAME* parentFrame = (PCB_BASE_FRAME*) Kiway().Player( FRAME_PCB, true ); -// wxASSERT( parentFrame ); - GetBoard()->SetDesignSettings( aSettings ); } @@ -926,3 +899,81 @@ void FOOTPRINT_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent ) { Pgm().ConfigurePaths( this ); } + + +void FOOTPRINT_EDIT_FRAME::SwitchCanvas( wxCommandEvent& aEvent ) +{ + int id = aEvent.GetId(); + bool use_gal = false; + + switch( id ) + { + case ID_MENU_CANVAS_DEFAULT: + galmode = PCB_DRAW_PANEL_GAL::GAL_TYPE_NONE; + break; + + case ID_MENU_CANVAS_CAIRO: + galmode = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; + use_gal = GetGalCanvas()->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ); + break; + + case ID_MENU_CANVAS_OPENGL: + galmode = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; + use_gal = GetGalCanvas()->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ); + break; + } + + UseGalCanvas( use_gal ); +} + + +void FOOTPRINT_EDIT_FRAME::setupTools() +{ + PCB_DRAW_PANEL_GAL* drawPanel = static_cast( GetGalCanvas() ); + + // Create the manager and dispatcher & route draw panel events to the dispatcher + m_toolManager = new TOOL_MANAGER; + m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(), + drawPanel->GetViewControls(), this ); + m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager ); + + drawPanel->SetEventDispatcher( m_toolDispatcher ); + + m_toolManager->RegisterTool( new SELECTION_TOOL ); + m_toolManager->RegisterTool( new EDIT_TOOL ); + m_toolManager->RegisterTool( new DRAWING_TOOL ); + m_toolManager->RegisterTool( new POINT_EDITOR ); + m_toolManager->RegisterTool( new PCBNEW_CONTROL ); + m_toolManager->RegisterTool( new MODULE_TOOLS ); + m_toolManager->RegisterTool( new PLACEMENT_TOOL ); + + m_toolManager->GetTool()->EditModules( true ); + m_toolManager->GetTool()->EditModules( true ); + m_toolManager->GetTool()->EditModules( true ); + + m_toolManager->ResetTools( TOOL_BASE::RUN ); + m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" ); + +} + + +void FOOTPRINT_EDIT_FRAME::UseGalCanvas( bool aEnable ) +{ + EDA_DRAW_FRAME::UseGalCanvas( aEnable ); + + if( aEnable ) + { + SetBoard( m_Pcb ); + m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH ); + updateView(); + GetGalCanvas()->SetEventDispatcher( m_toolDispatcher ); + GetGalCanvas()->StartDrawing(); + } + else + { + m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH ); + + // Redirect all events to the legacy canvas + GetGalCanvas()->SetEventDispatcher( NULL ); + } +} diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index b348c23d75..78640c721f 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -121,7 +121,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) ); SetIcon( icon ); - m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr; + m_hotkeysDescrList = g_Module_Viewer_Hokeys_Descr; m_libList = new wxListBox( this, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL ); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 5a1cc5851d..132a5c3479 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -316,7 +316,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_SelLayerBox = NULL; m_show_microwave_tools = false; m_show_layer_manager_tools = true; - m_HotkeysZoomAndGridList = g_Board_Editor_Hokeys_Descr; + m_hotkeysDescrList = g_Board_Editor_Hokeys_Descr; m_hasAutoSave = true; m_RecordingMacros = -1; m_microWaveToolBar = NULL;