KiCad PCB EDA Suite
PICKER_TOOL Class Reference

Generic tool for picking a point. More...

#include <picker_tool.h>

Inheritance diagram for PICKER_TOOL:
TOOL_INTERACTIVE TOOL_BASE

Public Types

typedef boost::function< bool(const VECTOR2D &)> CLICK_HANDLER
 

Mouse event click handler type.

More...
 
enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 PICKER_TOOL ()
 
 ~PICKER_TOOL ()
 
void Reset (RESET_REASON aReason) override
 > More...
 
int Main (const TOOL_EVENT &aEvent)
 

Main event loop.

More...
 
void SetSnapping (bool aEnable)
 Function SetSnapping() Sets cursor snapping to grid for the period when the tool is active. More...
 
void SetCursorVisible (bool aEnable)
 Function SetCursorVisible() Sets cursor visibility for the period when the tool is active. More...
 
void SetAutoPanning (bool aEnable)
 Function SetAutoPanning() Sets autopanning mode for the period when the tool is active. More...
 
void SetCursorCapture (bool aEnable)
 Function SetAutoPanning() Toggles cursor capture mode for the period when the tool is active. More...
 
boost::optional< VECTOR2DGetPoint () const
 Function GetPoint() Returns picked point. More...
 
bool IsPicking () const
 Function IsPicking() Returns information whether the tool is still active. More...
 
void SetClickHandler (CLICK_HANDLER aHandler)
 Function SetClickHandler() Sets a handler for mouse click event. More...
 
void SetTransitions () override
 > More...
 
void Activate ()
 Function Activate() Runs the tool. More...
 
void SetContextMenu (CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
OPT_TOOL_EVENT Wait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
virtual bool Init ()
 Function Init() Init() is called once upon a registration of the tool. More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
TOOL_SETTINGSGetSettings ()
 

Protected Member Functions

const TOOL_EVENT evActivate (std::string aToolName="")
 functions below are not yet implemented - their interface may change More...
 
const TOOL_EVENT evCommand (int aCommandId=-1)
 
const TOOL_EVENT evCommand (std::string aCommandStr="")
 
const TOOL_EVENT evMotion ()
 
const TOOL_EVENT evClick (int aButton=BUT_ANY)
 
const TOOL_EVENT evDrag (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonUp (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonDown (int aButton=BUT_ANY)
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

void reset ()
 

Reinitializes tool to its initial state.

More...
 
void setControls ()
 

Applies the requested VIEW_CONTROLS settings.

More...
 

Private Attributes

bool m_cursorSnapping
 
bool m_cursorVisible
 
bool m_cursorCapture
 
bool m_autoPanning
 
boost::optional< CLICK_HANDLERm_clickHandler
 

Optional mouse click event handler.

More...
 
boost::optional< VECTOR2Dm_picked
 

Picked point (if any).

More...
 
bool m_picking
 

Activity status.

More...
 

Detailed Description

Generic tool for picking a point.

Definition at line 35 of file picker_tool.h.

Member Typedef Documentation

typedef boost::function<bool(const VECTOR2D&)> PICKER_TOOL::CLICK_HANDLER

Mouse event click handler type.

Definition at line 42 of file picker_tool.h.

Member Enumeration Documentation

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 80 of file tool_base.h.

81  {
82  RUN,
83  MODEL_RELOAD,
84  GAL_SWITCH
85  };
Model changes (required full reload)
Definition: tool_base.h:83
Tool is invoked after being inactive.
Definition: tool_base.h:82
Rendering engine changes.
Definition: tool_base.h:84

Constructor & Destructor Documentation

PICKER_TOOL::PICKER_TOOL ( )

Definition at line 35 of file picker_tool.cpp.

References reset().

36  : TOOL_INTERACTIVE( "pcbnew.Picker" )
37 {
38  reset();
39 }
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Constructor.
void reset()
Reinitializes tool to its initial state.
Definition: picker_tool.cpp:98
PICKER_TOOL::~PICKER_TOOL ( )
inline

Definition at line 39 of file picker_tool.h.

39 {}

Member Function Documentation

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

After activation, the tool starts receiving events until it is finished.

Definition at line 49 of file tool_interactive.cpp.

References TOOL_MANAGER::InvokeTool(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by MODULE_EDITOR_TOOLS::CopyItems(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), ROUTER_TOOL::SettingsDialog(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:215
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

Sets the TOOL_MANAGER the tool will belong to. Called by TOOL_MANAGER::RegisterTool()

Definition at line 54 of file tool_base.cpp.

References TOOL_BASE::m_toolMgr, TOOL_BASE::m_toolSettings, and TOOL_BASE::TOOL_SETTINGS.

Referenced by TOOL_MANAGER::RegisterTool().

55 {
56  m_toolMgr = aManager;
57  m_toolSettings = TOOL_SETTINGS( this );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:221
friend class TOOL_SETTINGS
Definition: tool_base.h:160
const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited
template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

Returns the application window object, casted to requested user type.

Definition at line 193 of file tool_base.h.

References TOOL_BASE::getEditFrameInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), TOOL_SETTINGS::getConfigBase(), and ZONE_CREATE_HELPER::performZoneCutout().

194  {
195  return static_cast<T*>( getEditFrameInt() );
196  }
T
enum T contains all this lexer's tokens.
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:42
TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Function GetId() Returns the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 122 of file tool_base.h.

References TOOL_BASE::m_toolId.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::isActive(), TOOL_MANAGER::RegisterTool(), ACTION_MANAGER::RunHotKey(), and TOOL_MANAGER::runTool().

123  {
124  return m_toolId;
125  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:215
TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER. If there is no TOOL_MANAGER associated, it returns NULL.

Definition at line 144 of file tool_base.h.

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), PCB_TOOL::doInteractiveItemPlacement(), CONTEXT_MENU::getToolManager(), EDIT_TOOL::MeasureTool(), and CONTEXT_MENU::onMenuEvent().

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 204 of file tool_base.h.

References TOOL_BASE::getModelInt().

Referenced by ZONE_CREATE_HELPER::createNewZone(), ZONE_CREATE_HELPER::createZoneFromExisting(), and ZONE_CREATE_HELPER::performZoneCutout().

205  {
206  EDA_ITEM* m = getModelInt();
207 
208  return static_cast<T*>( m );
209  }
T
enum T contains all this lexer's tokens.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:48
const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Function GetName() Returns the name of the tool.

Tool names are expected to obey the format: application.ToolName (eg. pcbnew.InteractiveSelection).

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

References TOOL_BASE::m_toolName.

Referenced by TOOL_SETTINGS::getKeyName(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), and TOOL_MANAGER::RegisterTool().

134  {
135  return m_toolName;
136  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:219
boost::optional<VECTOR2D> PICKER_TOOL::GetPoint ( ) const
inline

Function GetPoint() Returns picked point.

Definition at line 78 of file picker_tool.h.

References m_picked, and m_picking.

79  {
80  assert( !m_picking );
81  return m_picked;
82  }
bool m_picking
Activity status.
Definition: picker_tool.h:118
boost::optional< VECTOR2D > m_picked
Picked point (if any).
Definition: picker_tool.h:115
TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 72 of file tool_base.cpp.

References TOOL_BASE::m_toolSettings.

Referenced by ROUTER_TOOL::Init(), SELECTION_TOOL::selectable(), and ROUTER_TOOL::~ROUTER_TOOL().

73 {
74  return m_toolSettings;
75 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:221
TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

References TOOL_BASE::m_type.

Referenced by TOOL_MANAGER::InvokeTool(), and TOOL_MANAGER::runTool().

112  {
113  return m_type;
114  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:212
KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Function getView()

Returns the instance of VIEW object used in the application. It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 30 of file tool_base.cpp.

References TOOL_MANAGER::GetView(), and TOOL_BASE::m_toolMgr.

Referenced by PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), SELECTION_TOOL::disambiguationMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridSetOrigin(), PCBNEW_CONTROL::HighContrastMode(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), EDIT_TOOL::Main(), EDIT_TOOL::MeasureTool(), MODULE_EDITOR_TOOLS::ModuleEdgeOutlines(), MODULE_EDITOR_TOOLS::ModuleTextOutlines(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PanControl(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PCB_EDITOR_CONTROL::Reset(), PCBNEW_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), DRAWING_TOOL::Reset(), SELECTION_TOOL::Reset(), SELECTION_TOOL::selectable(), SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), PCBNEW_CONTROL::TrackDisplayMode(), POINT_EDITOR::updateEditedPoint(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_TOOL::view(), PCBNEW_CONTROL::ZoneDisplayMode(), COMMON_TOOLS::ZoomFitScreen(), SELECTION_TOOL::zoomFitSelection(), COMMON_TOOLS::ZoomInOutCenter(), and SELECTION_TOOL::~SELECTION_TOOL().

31 {
32  return m_toolMgr->GetView();
33 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:243
KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited

Function getViewControls()

Returns the instance of VIEW_CONTROLS object used in the application. It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.)

Returns
The instance of VIEW_CONTROLS.

Definition at line 36 of file tool_base.cpp.

References TOOL_MANAGER::GetViewControls(), and TOOL_BASE::m_toolMgr.

Referenced by POINT_EDITOR::addCorner(), PCBNEW_CONTROL::AppendBoard(), PCB_TOOL::controls(), MODULE_EDITOR_TOOLS::CopyItems(), PCBNEW_CONTROL::CursorControl(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawZone(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), EDIT_TOOL::getModificationPoint(), PCB_EDITOR_CONTROL::HighlightNet(), Main(), EDIT_TOOL::Main(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), ROUTER_TOOL::performDragging(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PNS::TOOL_BASE::Reset(), DRAWING_TOOL::Reset(), PCBNEW_CONTROL::ResetCoords(), DRAWING_TOOL::runPolygonEventLoop(), SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), setControls(), POINT_EDITOR::setEditedPoint(), COMMON_TOOLS::ZoomCenter(), and COMMON_TOOLS::ZoomInOut().

37 {
38  return m_toolMgr->GetViewControls();
39 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:248
template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Function Go()

Defines which state (aStateFunc) to go when a certain event arrives (aConditions). No conditions means any event.

Definition at line 122 of file tool_interactive.h.

References TOOL_INTERACTIVE::goInternal().

Referenced by LENGTH_TUNER_TOOL::Reset(), ZOOM_TOOL::SetTransitions(), LENGTH_TUNER_TOOL::SetTransitions(), ROUTER_TOOL::SetTransitions(), PAD_TOOL::SetTransitions(), MICROWAVE_TOOL::SetTransitions(), POINT_EDITOR::SetTransitions(), COMMON_TOOLS::SetTransitions(), ALIGN_DISTRIBUTE_TOOL::SetTransitions(), PCBNEW_CONTROL::SetTransitions(), POSITION_RELATIVE_TOOL::SetTransitions(), MODULE_EDITOR_TOOLS::SetTransitions(), SetTransitions(), PCB_EDITOR_CONTROL::SetTransitions(), EDIT_TOOL::SetTransitions(), SELECTION_TOOL::SetTransitions(), and DRAWING_TOOL::SetTransitions().

124 {
125  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
126 
127  goInternal( sptr, aConditions );
128 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:59
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
virtual bool TOOL_BASE::Init ( )
inlinevirtualinherited

Function Init() Init() is called once upon a registration of the tool.

Returns
True if the initialization went fine, false - otherwise.

Reimplemented in SELECTION_TOOL, DRAWING_TOOL, EDIT_TOOL, POSITION_RELATIVE_TOOL, PCB_EDITOR_CONTROL, POINT_EDITOR, MICROWAVE_TOOL, PAD_TOOL, ALIGN_DISTRIBUTE_TOOL, and ROUTER_TOOL.

Definition at line 93 of file tool_base.h.

Referenced by TOOL_MANAGER::InitTools().

94  {
95  return true;
96  }
bool PICKER_TOOL::IsPicking ( ) const
inline

Function IsPicking() Returns information whether the tool is still active.

Definition at line 88 of file picker_tool.h.

References m_picking.

88 { return m_picking; }
bool m_picking
Activity status.
Definition: picker_tool.h:118
int PICKER_TOOL::Main ( const TOOL_EVENT aEvent)

Main event loop.

Definition at line 42 of file picker_tool.cpp.

References BUT_LEFT, KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_BASE::getViewControls(), m_clickHandler, m_picked, m_picking, TOOL_BASE::m_toolMgr, TOOL_MANAGER::PassEvent(), reset(), setControls(), and TOOL_INTERACTIVE::Wait().

Referenced by SetTransitions().

43 {
45 
46  assert( !m_picking );
47  m_picking = true;
48  m_picked = boost::none;
49 
50  setControls();
51 
52  while( OPT_TOOL_EVENT evt = Wait() )
53  {
54  if( evt->IsClick( BUT_LEFT ) )
55  {
56  bool getNext = false;
57  m_picked = controls->GetCursorPosition();
58 
59  if( m_clickHandler )
60  {
61  try
62  {
63  getNext = (*m_clickHandler)( *m_picked );
64  }
65  catch( std::exception& e )
66  {
67  std::cerr << "PICKER_TOOL click handler error: " << e.what() << std::endl;
68  break;
69  }
70  }
71 
72  if( !getNext )
73  break;
74  else
75  setControls();
76  }
77 
78  else if( evt->IsCancel() || evt->IsActivate() )
79  break;
80 
81  else
83  }
84 
85  reset();
86  getEditFrame<PCB_BASE_FRAME>()->SetNoToolSelected();
87 
88  return 0;
89 }
boost::optional< CLICK_HANDLER > m_clickHandler
Optional mouse click event handler.
Definition: picker_tool.h:112
bool m_picking
Activity status.
Definition: picker_tool.h:118
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void PassEvent()
Allows a tool to pass the already handled event to the next tool on the stack.
Definition: tool_manager.h:336
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
void reset()
Reinitializes tool to its initial state.
Definition: picker_tool.cpp:98
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
Definition: view_controls.h:94
boost::optional< VECTOR2D > m_picked
Picked point (if any).
Definition: picker_tool.h:115
void setControls()
Applies the requested VIEW_CONTROLS settings.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:36
void PICKER_TOOL::Reset ( RESET_REASON  aReason)
inlineoverridevirtual

>

Function Reset() Brings the tool to a known, initial state. If the tool claimed anything from the model or the view, it must release it when its reset.

Parameters
aReasoncontains information about the reason of tool reset.

Implements TOOL_BASE.

Definition at line 45 of file picker_tool.h.

45 {}
void PICKER_TOOL::reset ( )
private

Reinitializes tool to its initial state.

Definition at line 98 of file picker_tool.cpp.

References m_autoPanning, m_clickHandler, m_cursorCapture, m_cursorSnapping, m_cursorVisible, and m_picking.

Referenced by Main(), and PICKER_TOOL().

99 {
100  m_cursorSnapping = true;
101  m_cursorVisible = true;
102  m_cursorCapture = false;
103  m_autoPanning = false;
104 
105  m_picking = false;
106  m_clickHandler = boost::none;
107 }
boost::optional< CLICK_HANDLER > m_clickHandler
Optional mouse click event handler.
Definition: picker_tool.h:112
bool m_picking
Activity status.
Definition: picker_tool.h:118
bool m_autoPanning
Definition: picker_tool.h:109
bool m_cursorSnapping
Definition: picker_tool.h:106
bool m_cursorVisible
Definition: picker_tool.h:107
bool m_cursorCapture
Definition: picker_tool.h:108
void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 78 of file tool_interactive.cpp.

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::RunMainStack().

Referenced by DRAWING_TOOL::PlaceText().

79 {
80  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
81 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)
void PICKER_TOOL::SetAutoPanning ( bool  aEnable)
inline

Function SetAutoPanning() Sets autopanning mode for the period when the tool is active.

Definition at line 66 of file picker_tool.h.

References m_autoPanning.

66 { m_autoPanning = aEnable; }
bool m_autoPanning
Definition: picker_tool.h:109
void PICKER_TOOL::SetClickHandler ( CLICK_HANDLER  aHandler)
inline

Function SetClickHandler() Sets a handler for mouse click event.

Handler may decide to receive further click by returning true.

Definition at line 95 of file picker_tool.h.

References m_clickHandler.

Referenced by PCBNEW_CONTROL::DeleteItemCursor(), PCB_EDITOR_CONTROL::DrillOrigin(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), and POSITION_RELATIVE_TOOL::SelectPositionRelativeItem().

96  {
97  assert( !m_clickHandler );
98  m_clickHandler = aHandler;
99  }
boost::optional< CLICK_HANDLER > m_clickHandler
Optional mouse click event handler.
Definition: picker_tool.h:112
void TOOL_INTERACTIVE::SetContextMenu ( CONTEXT_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Function SetContextMenu()

Assigns a context menu and tells when it should be activated.

Parameters
aMenuis the menu to be assigned.
aTriggerdetermines conditions upon which the context menu is activated.

Definition at line 67 of file tool_interactive.cpp.

References CMENU_OFF, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ScheduleContextMenu(), and CONTEXT_MENU::SetTool().

Referenced by SELECTION_TOOL::disambiguationMenu(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), and TOOL_MENU::ShowContextMenu().

68 {
69  if( aMenu )
70  aMenu->SetTool( this );
71  else
72  aTrigger = CMENU_OFF;
73 
74  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
75 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void ScheduleContextMenu(TOOL_BASE *aTool, CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool's context popup menu.
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
void PICKER_TOOL::setControls ( )
private

Applies the requested VIEW_CONTROLS settings.

Definition at line 110 of file picker_tool.cpp.

References KIGFX::VIEW_CONTROLS::CaptureCursor(), TOOL_BASE::getViewControls(), m_autoPanning, m_cursorCapture, m_cursorSnapping, m_cursorVisible, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetSnapping(), and KIGFX::VIEW_CONTROLS::ShowCursor().

Referenced by Main().

111 {
113 
114  controls->ShowCursor( m_cursorVisible );
115  controls->SetSnapping( m_cursorSnapping );
116  controls->CaptureCursor( m_cursorCapture );
117  controls->SetAutoPan( m_autoPanning );
118 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
bool m_autoPanning
Definition: picker_tool.h:109
bool m_cursorSnapping
Definition: picker_tool.h:106
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool m_cursorVisible
Definition: picker_tool.h:107
bool m_cursorCapture
Definition: picker_tool.h:108
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
Definition: view_controls.h:94
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:36
void PICKER_TOOL::SetCursorCapture ( bool  aEnable)
inline

Function SetAutoPanning() Toggles cursor capture mode for the period when the tool is active.

Definition at line 72 of file picker_tool.h.

References m_cursorCapture.

72 { m_cursorCapture = aEnable; }
bool m_cursorCapture
Definition: picker_tool.h:108
void PICKER_TOOL::SetCursorVisible ( bool  aEnable)
inline

Function SetCursorVisible() Sets cursor visibility for the period when the tool is active.

Definition at line 60 of file picker_tool.h.

References m_cursorVisible.

60 { m_cursorVisible = aEnable; }
bool m_cursorVisible
Definition: picker_tool.h:107
void PICKER_TOOL::SetSnapping ( bool  aEnable)
inline

Function SetSnapping() Sets cursor snapping to grid for the period when the tool is active.

Definition at line 54 of file picker_tool.h.

References m_cursorSnapping.

Referenced by PCBNEW_CONTROL::DeleteItemCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), and POSITION_RELATIVE_TOOL::SelectPositionRelativeItem().

54 { m_cursorSnapping = aEnable; }
bool m_cursorSnapping
Definition: picker_tool.h:106
void PICKER_TOOL::SetTransitions ( )
overridevirtual

>

Function SetTransitions() This method is meant to be overridden in order to specify handlers for events. It is called every time tool is reset or finished.

Reimplemented from TOOL_BASE.

Definition at line 92 of file picker_tool.cpp.

References TOOL_INTERACTIVE::Go(), Main(), and PCB_ACTIONS::pickerTool.

93 {
95 }
int Main(const TOOL_EVENT &aEvent)
Main event loop.
Definition: picker_tool.cpp:42
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION pickerTool
Definition: pcb_actions.h:350
OPT_TOOL_EVENT TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Function Wait()

Suspends execution of the tool until an event specified in aEventList arrives. No parameters means waiting for any event.

Definition at line 55 of file tool_interactive.cpp.

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::ScheduleWait().

Referenced by MODULE_EDITOR_TOOLS::CopyItems(), PCBNEW_CONTROL::DeleteItemCursor(), SELECTION_TOOL::disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::runPolygonEventLoop(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

56 {
57  return m_toolMgr->ScheduleWait( this, aEventList );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
boost::optional< TOOL_EVENT > ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pauses execution of a given tool until one or more events matching aConditions arrives.

Member Data Documentation

bool PICKER_TOOL::m_autoPanning
private

Definition at line 109 of file picker_tool.h.

Referenced by reset(), SetAutoPanning(), and setControls().

boost::optional<CLICK_HANDLER> PICKER_TOOL::m_clickHandler
private

Optional mouse click event handler.

Definition at line 112 of file picker_tool.h.

Referenced by Main(), reset(), and SetClickHandler().

bool PICKER_TOOL::m_cursorCapture
private

Definition at line 108 of file picker_tool.h.

Referenced by reset(), setControls(), and SetCursorCapture().

bool PICKER_TOOL::m_cursorSnapping
private

Definition at line 106 of file picker_tool.h.

Referenced by reset(), setControls(), and SetSnapping().

bool PICKER_TOOL::m_cursorVisible
private

Definition at line 107 of file picker_tool.h.

Referenced by reset(), setControls(), and SetCursorVisible().

boost::optional<VECTOR2D> PICKER_TOOL::m_picked
private

Picked point (if any).

Definition at line 115 of file picker_tool.h.

Referenced by GetPoint(), and Main().

bool PICKER_TOOL::m_picking
private

Activity status.

Definition at line 118 of file picker_tool.h.

Referenced by GetPoint(), IsPicking(), Main(), and reset().

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

Definition at line 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), TOOL_BASE::GetId(), and EDIT_TOOL::getModificationPoint().

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 220 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PCBNEW_CONTROL::AppendBoard(), PAD_TOOL::applyPadSettings(), TOOL_BASE::attachManager(), SELECTION_TOOL::clearSelection(), MODULE_EDITOR_TOOLS::CopyItems(), PAD_TOOL::copyPadSettings(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), EDIT_TOOL::getModificationPoint(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PAD_TOOL::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), EDIT_TOOL::Init(), POSITION_RELATIVE_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), ZOOM_TOOL::Main(), Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), SELECTION_TOOL::RequestSelection(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), SELECTION_TOOL::SanitizeSelection(), SELECTION_TOOL::selectConnection(), SELECTION_TOOL::selectCopper(), SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItems(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItems(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), PCB_EDITOR_CONTROL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and PCB_EDITOR_CONTROL::ZoneUnfill().

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName

(eg. pcbnew.InteractiveSelection).

Definition at line 219 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 221 of file tool_base.h.

Referenced by TOOL_BASE::attachManager(), and TOOL_BASE::GetSettings().

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 212 of file tool_base.h.

Referenced by TOOL_BASE::GetType().


The documentation for this class was generated from the following files: