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.

123 lines
4.2 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2014-2016 CERN
  5. * @author Maciej Suminski <maciej.suminski@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. #ifndef PCBNEW_CONTROL_H
  25. #define PCBNEW_CONTROL_H
  26. #include <io_mgr.h>
  27. #include <memory>
  28. #include <tools/pcb_tool_base.h>
  29. namespace KIGFX {
  30. class ORIGIN_VIEWITEM;
  31. }
  32. class PCB_BASE_FRAME;
  33. class BOARD_ITEM;
  34. /**
  35. * Class PCBNEW_CONTROL
  36. *
  37. * Handles actions that are shared between different frames in pcbnew.
  38. */
  39. class PCBNEW_CONTROL : public PCB_TOOL_BASE
  40. {
  41. public:
  42. PCBNEW_CONTROL();
  43. ~PCBNEW_CONTROL();
  44. /// @copydoc TOOL_INTERACTIVE::Reset()
  45. void Reset( RESET_REASON aReason ) override;
  46. int AddLibrary( const TOOL_EVENT& aEvent );
  47. int Print( const TOOL_EVENT& aEvent );
  48. int Quit( const TOOL_EVENT& aEvent );
  49. // Display modes
  50. int ToggleRatsnest( const TOOL_EVENT& aEvent );
  51. int ZoneDisplayMode( const TOOL_EVENT& aEvent );
  52. int TrackDisplayMode( const TOOL_EVENT& aEvent );
  53. int PadDisplayMode( const TOOL_EVENT& aEvent );
  54. int ViaDisplayMode( const TOOL_EVENT& aEvent );
  55. int GraphicDisplayMode( const TOOL_EVENT& aEvent );
  56. int ModuleEdgeOutlines( const TOOL_EVENT& aEvent );
  57. int HighContrastMode( const TOOL_EVENT& aEvent );
  58. // Layer control
  59. int LayerSwitch( const TOOL_EVENT& aEvent );
  60. int LayerNext( const TOOL_EVENT& aEvent );
  61. int LayerPrev( const TOOL_EVENT& aEvent );
  62. int LayerToggle( const TOOL_EVENT& aEvent );
  63. int LayerAlphaInc( const TOOL_EVENT& aEvent );
  64. int LayerAlphaDec( const TOOL_EVENT& aEvent );
  65. // Grid control
  66. int GridFast1( const TOOL_EVENT& aEvent );
  67. int GridFast2( const TOOL_EVENT& aEvent );
  68. int GridSetOrigin( const TOOL_EVENT& aEvent );
  69. int GridResetOrigin( const TOOL_EVENT& aEvent );
  70. // UI-level access (including undo) to setting the grid origin
  71. static bool SetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
  72. BOARD_ITEM* originViewItem, const VECTOR2D& aPoint );
  73. // Low-level access (below undo) to setting the grid origin
  74. static void DoSetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
  75. BOARD_ITEM* originViewItem, const VECTOR2D& aPoint );
  76. int Undo( const TOOL_EVENT& aEvent );
  77. int Redo( const TOOL_EVENT& aEvent );
  78. // Miscellaneous
  79. int DeleteItemCursor( const TOOL_EVENT& aEvent );
  80. int Paste( const TOOL_EVENT& aEvent );
  81. int AppendBoardFromFile( const TOOL_EVENT& aEvent );
  82. int AppendBoard( PLUGIN& pi, wxString& fileName );
  83. int Show3DViewer( const TOOL_EVENT& aEvent );
  84. int UpdateMessagePanel( const TOOL_EVENT& aEvent );
  85. ///> Sets up handlers for various events.
  86. void setTransitions() override;
  87. private:
  88. int placeBoardItems( BOARD* aBoard );
  89. /** add and selec or just select for move/place command a list of board items.
  90. * @param aItems is the list of items
  91. * @param aIsNew = true to add items to the current board, false to just select if
  92. * items are already managed by the current board
  93. */
  94. int placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew );
  95. ///> Pointer to the currently used edit frame.
  96. PCB_BASE_FRAME* m_frame;
  97. ///> Grid origin marker.
  98. std::unique_ptr<KIGFX::ORIGIN_VIEWITEM> m_gridOrigin;
  99. ///> Applies the legacy canvas grid settings for GAL.
  100. void updateGrid();
  101. };
  102. #endif