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.

106 lines
3.4 KiB

7 years ago
  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 _COMMON_TOOLS_H
  25. #define _COMMON_TOOLS_H
  26. #include <tool/tool_interactive.h>
  27. class EDA_DRAW_FRAME;
  28. /**
  29. * COMMON_TOOLS
  30. *
  31. * Handles actions that are shared between different applications
  32. */
  33. class COMMON_TOOLS : public TOOL_INTERACTIVE
  34. {
  35. public:
  36. COMMON_TOOLS() :
  37. TOOL_INTERACTIVE( "common.Control" ),
  38. m_frame( nullptr )
  39. { }
  40. ~COMMON_TOOLS() override { }
  41. /// @copydoc TOOL_BASE::Reset()
  42. void Reset( RESET_REASON aReason ) override;
  43. int SelectionTool( const TOOL_EVENT& aEvent );
  44. // View controls
  45. int ZoomRedraw( const TOOL_EVENT& aEvent );
  46. int ZoomInOut( const TOOL_EVENT& aEvent );
  47. int ZoomInOutCenter( const TOOL_EVENT& aEvent );
  48. int ZoomCenter( const TOOL_EVENT& aEvent );
  49. int ZoomFitScreen( const TOOL_EVENT& aEvent );
  50. int ZoomPreset( const TOOL_EVENT& aEvent );
  51. int CenterContents( const TOOL_EVENT& aEvent );
  52. int PanControl( const TOOL_EVENT& aEvent );
  53. // Cursor control
  54. int CursorControl( const TOOL_EVENT& aEvent );
  55. int ToggleCursor( const TOOL_EVENT& aEvent );
  56. int ToggleCursorStyle( const TOOL_EVENT& aEvent );
  57. // Units control
  58. int ImperialUnits( const TOOL_EVENT& aEvent );
  59. int MetricUnits( const TOOL_EVENT& aEvent );
  60. int ToggleUnits( const TOOL_EVENT& aEvent );
  61. int TogglePolarCoords( const TOOL_EVENT& aEvent );
  62. int ResetLocalCoords( const TOOL_EVENT& aEvent );
  63. // Grid control
  64. int GridNext( const TOOL_EVENT& aEvent );
  65. int GridPrev( const TOOL_EVENT& aEvent );
  66. int GridPreset( const TOOL_EVENT& aEvent );
  67. int GridFast1( const TOOL_EVENT& aEvent );
  68. int GridFast2( const TOOL_EVENT& aEvent );
  69. int ToggleGrid( const TOOL_EVENT& aEvent );
  70. int GridProperties( const TOOL_EVENT& aEvent );
  71. int GridPreset( int idx );
  72. int OnGridChanged();
  73. int SwitchCanvas( const TOOL_EVENT& aEvent );
  74. private:
  75. ///> Sets up handlers for various events.
  76. void setTransitions() override;
  77. ///> Pointer to the currently used edit frame.
  78. EDA_DRAW_FRAME* m_frame;
  79. int doZoomInOut( bool aDirection, bool aCenterOnCursor );
  80. ///> Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
  81. int doZoomToPreset( int idx, bool aCenterOnCursor );
  82. std::vector<VECTOR2I> m_grids; // grids from APP_SETTINGS converted to internal units
  83. // and with the user grid appended
  84. };
  85. #endif