You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.8 KiB

12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2013 CERN
  5. * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #include <wx/wx.h>
  25. #include <wx/event.h>
  26. #include <wxPcbStruct.h>
  27. #include <wxBasePcbFrame.h>
  28. #include <tool/tool_manager.h>
  29. #include <tool/tool_dispatcher.h>
  30. #include <class_drawpanel_gal.h>
  31. #include <pcbnew_id.h>
  32. #include "selection_tool.h"
  33. #include "edit_tool.h"
  34. #include "common_actions.h"
  35. #include <router/router_tool.h>
  36. void PCB_EDIT_FRAME::setupTools()
  37. {
  38. // Create the manager and dispatcher & route draw panel events to the dispatcher
  39. m_toolManager = new TOOL_MANAGER;
  40. m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, this );
  41. GetGalCanvas()->SetEventDispatcher( m_toolDispatcher );
  42. // Register tool actions
  43. m_toolManager->RegisterAction( &COMMON_ACTIONS::selectionSingle );
  44. m_toolManager->RegisterAction( &COMMON_ACTIONS::selectionClear );
  45. m_toolManager->RegisterAction( &COMMON_ACTIONS::editActivate );
  46. m_toolManager->RegisterAction( &COMMON_ACTIONS::rotate );
  47. m_toolManager->RegisterAction( &COMMON_ACTIONS::flip );
  48. m_toolManager->RegisterAction( &COMMON_ACTIONS::remove );
  49. m_toolManager->RegisterAction( &COMMON_ACTIONS::properties );
  50. // Register tools
  51. m_toolManager->RegisterTool( new SELECTION_TOOL );
  52. m_toolManager->RegisterTool( new ROUTER_TOOL );
  53. m_toolManager->RegisterTool( new EDIT_TOOL );
  54. m_toolManager->SetEnvironment( NULL, GetGalCanvas()->GetView(),
  55. GetGalCanvas()->GetViewControls(), this );
  56. m_toolManager->ResetTools( TOOL_BASE::RUN );
  57. // Run the selection tool, it is supposed to be always active
  58. m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
  59. }
  60. void PCB_EDIT_FRAME::destroyTools()
  61. {
  62. delete m_toolManager;
  63. delete m_toolDispatcher;
  64. }
  65. void PCB_EDIT_FRAME::onGenericCommand( wxCommandEvent& aEvent )
  66. {
  67. m_toolDispatcher->DispatchWxCommand( aEvent );
  68. }