KiCad PCB EDA Suite
TOOL_EVT_UTILS Namespace Reference

Namespace TOOL_EVT_UTILS. More...


bool IsCancelInteractive (const TOOL_EVENT &aEvt)
 Function IsCancelInteractive() More...
bool IsRotateToolEvt (const TOOL_EVENT &aEvt)
 Function isRotateToolEvt() More...
int GetEventRotationAngle (const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
 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

int TOOL_EVT_UTILS::GetEventRotationAngle ( const PCB_BASE_EDIT_FRAME aFrame,
const TOOL_EVENT aEvt 

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 rotation angle in clockwise internal units

Definition at line 44 of file tool_event_utils.cpp.

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

Referenced by PCB_TOOL::doInteractiveItemPlacement(), MODULE_EDITOR_TOOLS::PasteItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), DRAWING_TOOL::PlaceText(), and EDIT_TOOL::Rotate().

46 {
47  wxASSERT_MSG( IsRotateToolEvt( aEvt ), "Expected rotation event" );
49  const int rotAngle = aFrame.GetRotationAngle();
50  const int angleMultiplier = aEvt.Parameter<intptr_t>();
52  return rotAngle * angleMultiplier;
53 }
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
int GetRotationAngle() const
Function GetRotationAngle() Returns the angle used for rotate operations.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:373
bool TOOL_EVT_UTILS::IsCancelInteractive ( const TOOL_EVENT aEvt)

Function IsCancelInteractive()

true if this event should restart/end an ongoing interactive tool's event loop (eg esc key, click cancel, start different tool)

Definition at line 30 of file tool_event_utils.cpp.

References ACTIONS::cancelInteractive, TOOL_EVENT::IsAction(), TOOL_EVENT::IsActivate(), and TOOL_EVENT::IsCancel().

Referenced by PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), ROUTER_TOOL::mainLoop(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), DRAWING_TOOL::PlaceDXF(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::runPolygonEventLoop(), and DRAWING_TOOL::SetAnchor().

31 {
32  return aEvt.IsAction( &ACTIONS::cancelInteractive )
33  || aEvt.IsActivate()
34  || aEvt.IsCancel();
35 }
static TOOL_ACTION cancelInteractive
Definition: actions.h:45
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:54
bool IsActivate() const
Definition: tool_event.h:300
bool IsCancel() const
Definition: tool_event.h:295
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 37 of file tool_event_utils.cpp.

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

Referenced by PCB_TOOL::doInteractiveItemPlacement(), GetEventRotationAngle(), MODULE_EDITOR_TOOLS::PasteItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), and DRAWING_TOOL::PlaceText().

38 {
39  return aEvt.IsAction( &PCB_ACTIONS::rotateCw )
40  || aEvt.IsAction( &PCB_ACTIONS::rotateCcw );
41 }
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:54
static TOOL_ACTION rotateCw
Rotation of selected objects clockwise.
Definition: pcb_actions.h:84
static TOOL_ACTION rotateCcw
Rotation of selected objects counter-clockwise.
Definition: pcb_actions.h:87