KiCad PCB EDA Suite
TOOL_EVT_UTILS Namespace Reference

Namespace TOOL_EVT_UTILS. 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...
bool IsCancelInteractive (const TOOL_EVENT &aEvt)
 Function IsCancelInteractive() More...
bool IsSelectionEvent (const TOOL_EVENT &aEvt)
 Function IsSelectionEvent() 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()

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 36 of file tool_event_utils.cpp.

38 {
39  wxASSERT_MSG( IsRotateToolEvt( aEvt ), "Expected rotation event" );
41  const int rotAngle = aFrame.GetRotationAngle();
42  const int angleMultiplier = aEvt.Parameter<intptr_t>();
44  return rotAngle * angleMultiplier;
45 }
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
int GetRotationAngle() const
Function GetRotationAngle() Returns the angle used for rotate operations.

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

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

◆ IsCancelInteractive()

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 177 of file tool_event.cpp.

178 {
179  return aEvt.IsAction( &ACTIONS::cancelInteractive )
180  || aEvt.IsActivate()
181  || aEvt.IsCancel();
182 }
bool IsCancel() const
Definition: tool_event.h:295
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

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

Referenced by SCH_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::drawZone(), MODULE_EDITOR_TOOLS::EnumeratePads(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::MeasureTool(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), SELECTION_TOOL::selectMultiple(), and DRAWING_TOOL::SetAnchor().

◆ 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.

30 {
31  return aEvt.IsAction( &PCB_ACTIONS::rotateCw )
32  || aEvt.IsAction( &PCB_ACTIONS::rotateCcw );
33 }
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.
Definition: pcb_actions.h:95
static TOOL_ACTION rotateCcw
Definition: pcb_actions.h:96

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

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

◆ IsSelectionEvent()

bool TOOL_EVT_UTILS::IsSelectionEvent ( const TOOL_EVENT aEvt)

Function IsSelectionEvent()

Indicates an selection-changed notification event.

Definition at line 185 of file tool_event.cpp.

186 {
187  return aEvt.Matches( EVENTS::ClearedEvent )
189  || aEvt.Matches( EVENTS::SelectedEvent );
190 }
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
Definition: actions.h:132
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
Definition: actions.h:133
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
Definition: actions.h:134
bool Matches(const TOOL_EVENT &aEvent) const
Function Matches() Tests whether two events match in terms of category & action or command.
Definition: tool_event.h:338

References EVENTS::ClearedEvent, TOOL_EVENT::Matches(), EVENTS::SelectedEvent, and EVENTS::UnselectedEvent.

Referenced by SCH_DRAWING_TOOLS::doTwoClickPlace().