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.

77 lines
2.6 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, you may find one here:
  17. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  18. * or you may search the http://www.gnu.org website for the version 2 license,
  19. * or you may write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  21. */
  22. #ifndef TOOL_EVENT_UTILS_H
  23. #define TOOL_EVENT_UTILS_H
  24. #include <tool/tool_interactive.h>
  25. class PCB_BASE_EDIT_FRAME;
  26. /**
  27. * Namespace TOOL_EVT_UTILS
  28. *
  29. * Utility functions for dealing with various tool events. These are
  30. * free functions, so they interface with any classes exclusively via
  31. * the public interfaces, so they don't need to be subsumed into the
  32. * "helped" classes.
  33. */
  34. namespace TOOL_EVT_UTILS
  35. {
  36. /**
  37. * Function IsCancelInteractive()
  38. *
  39. * @return true if this event should restart/end an ongoing interactive
  40. * tool's event loop (eg esc key, click cancel, start different
  41. * tool)
  42. */
  43. bool IsCancelInteractive( const TOOL_EVENT& aEvt );
  44. /**
  45. * Function isRotateToolEvt()
  46. *
  47. * @param aEvt event to check
  48. * @return true if the event is a rotation action tool event
  49. */
  50. bool IsRotateToolEvt( const TOOL_EVENT& aEvt );
  51. /**
  52. * Function getEventRotationAngle()
  53. *
  54. * Helper function to get a rotation angle based on a frame's
  55. * configured angle and the direction indicated by a rotation action event
  56. *
  57. * @param aFrame the PCB edit frame to use to get the base rotation
  58. * step value from
  59. * @param aEvt the tool event - should be a rotation action event
  60. * and should have a rotation multiplier parameter
  61. *
  62. * @return the rotation angle in clockwise internal units
  63. */
  64. int GetEventRotationAngle( const PCB_BASE_EDIT_FRAME& aFrame,
  65. const TOOL_EVENT& aEvt );
  66. }
  67. #endif // TOOL_EVENT_UTILS_H