KiCad PCB EDA Suite
TOOL_EVT_UTILS Namespace Reference

Namespace TOOL_EVT_UTILS. More...


bool IsRotateToolEvt (const TOOL_EVENT &aEvt)
 Function isRotateToolEvt() More...
EDA_ANGLE GetEventRotationAngle (const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvent)
 Function getEventRotationAngle() More...

Detailed Description


Utility functions for dealing with various tool events. These are free functions, so they interface with any classes exclusively via the public interfaces, so they don't need to be subsumed into the "helped" classes.

Function Documentation

◆ GetEventRotationAngle()

EDA_ANGLE TOOL_EVT_UTILS::GetEventRotationAngle ( const PCB_BASE_EDIT_FRAME aFrame,
const TOOL_EVENT aEvent 

Function getEventRotationAngle()

Helper function to get a rotation angle based on a frame's configured angle and the direction indicated by a rotation action event

aFramethe PCB edit frame to use to get the base rotation step value from
aEvtthe tool event - should be a rotation action event and should have a rotation multiplier parameter
the clockwise rotation angle

Definition at line 36 of file tool_event_utils.cpp.

39 wxASSERT_MSG( IsRotateToolEvt( aEvent ), wxT( "Expected rotation event" ) );
41 EDA_ANGLE rotAngle = aFrame.GetRotationAngle();
42 const int angleMultiplier = aEvent.Parameter<intptr_t>();
44 wxASSERT_MSG( angleMultiplier == 1 || angleMultiplier == -1, "Expected 1 or -1" );
46 return angleMultiplier > 0 ? rotAngle : -rotAngle;
virtual EDA_ANGLE GetRotationAngle() const
Return the angle used for rotate operations.
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:442
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()

References PCB_BASE_EDIT_FRAME::GetRotationAngle(), IsRotateToolEvt(), and TOOL_EVENT::Parameter().

Referenced by PCB_TOOL_BASE::doInteractiveItemPlacement(), and EDIT_TOOL::Rotate().

◆ IsRotateToolEvt()

bool TOOL_EVT_UTILS::IsRotateToolEvt ( const TOOL_EVENT aEvt)

Function isRotateToolEvt()

aEvtevent to check
true if the event is a rotation action tool event

Definition at line 29 of file tool_event_utils.cpp.

31 return aEvt.IsAction( &PCB_ACTIONS::rotateCw )
static TOOL_ACTION rotateCw
Rotation of selected objects.
Definition: pcb_actions.h:122
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:123
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:88

References TOOL_EVENT::IsAction(), PCB_ACTIONS::rotateCcw, and PCB_ACTIONS::rotateCw.

Referenced by PCB_TOOL_BASE::doInteractiveItemPlacement(), and GetEventRotationAngle().