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.

53 lines
1.9 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. #include <tools/tool_event_utils.h>
  23. #include <tools/pcb_actions.h>
  24. #include <pcb_base_edit_frame.h>
  25. bool TOOL_EVT_UTILS::IsCancelInteractive( const TOOL_EVENT& aEvt )
  26. {
  27. return aEvt.IsAction( &ACTIONS::cancelInteractive )
  28. || aEvt.IsActivate()
  29. || aEvt.IsCancel();
  30. }
  31. bool TOOL_EVT_UTILS::IsRotateToolEvt( const TOOL_EVENT& aEvt )
  32. {
  33. return aEvt.IsAction( &PCB_ACTIONS::rotateCw )
  34. || aEvt.IsAction( &PCB_ACTIONS::rotateCcw );
  35. }
  36. int TOOL_EVT_UTILS::GetEventRotationAngle( const PCB_BASE_EDIT_FRAME& aFrame,
  37. const TOOL_EVENT& aEvt )
  38. {
  39. wxASSERT_MSG( IsRotateToolEvt( aEvt ), "Expected rotation event" );
  40. const int rotAngle = aFrame.GetRotationAngle();
  41. const int angleMultiplier = aEvt.Parameter<intptr_t>();
  42. return rotAngle * angleMultiplier;
  43. }