KiCad PCB EDA Suite
TOOL_MANAGER Class Reference

Class TOOL_MANAGER. More...

#include <tool_manager.h>

Classes

struct  TOOL_STATE
 Struct describing the current execution state of a TOOL. More...
 

Public Types

typedef std::map< TOOL_BASE *, TOOL_STATE * > TOOL_STATE_MAP
 
typedef std::map< std::string, TOOL_STATE * > NAME_STATE_MAP
 
typedef std::map< TOOL_ID, TOOL_STATE * > ID_STATE_MAP
 
typedef std::list< TOOL_IDID_LIST
 

Public Member Functions

 TOOL_MANAGER ()
 
 ~TOOL_MANAGER ()
 
void RegisterTool (TOOL_BASE *aTool)
 Function RegisterTool() Adds a tool to the manager set and sets it up. More...
 
bool InvokeTool (TOOL_ID aToolId)
 Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID. More...
 
bool InvokeTool (const std::string &aToolName)
 Function InvokeTool() Calls a tool by sending a tool activation event to tool of given name. More...
 
void RegisterAction (TOOL_ACTION *aAction)
 Function RegisterAction() Registers an action that can be used to control tools (eg. More...
 
void UnregisterAction (TOOL_ACTION *aAction)
 Function UnregisterAction() Unregisters an action, so it is no longer active. More...
 
template<typename T >
bool RunAction (const std::string &aActionName, bool aNow=false, T aParam=NULL)
 Function RunAction() Runs the specified action. More...
 
bool RunAction (const std::string &aActionName, bool aNow, void *aParam)
 
bool RunAction (const std::string &aActionName, bool aNow=false)
 
template<typename T >
void RunAction (const TOOL_ACTION &aAction, bool aNow=false, T aParam=NULL)
 Function RunAction() Runs the specified action. More...
 
void RunAction (const TOOL_ACTION &aAction, bool aNow, void *aParam)
 
void RunAction (const TOOL_ACTION &aAction, bool aNow=false)
 
int GetHotKey (const TOOL_ACTION &aAction)
 > More...
 
void UpdateHotKeys ()
 > More...
 
TOOL_BASEFindTool (int aId) const
 Function FindTool() Searches for a tool with given ID. More...
 
TOOL_BASEFindTool (const std::string &aName) const
 Function FindTool() Searches for a tool with given name. More...
 
template<typename T >
T * GetTool ()
 
void DeactivateTool ()
 Function DeactivateTool() Deactivates the currently active tool. More...
 
void ResetTools (TOOL_BASE::RESET_REASON aReason)
 Function ResetTools() Resets all tools (i.e. More...
 
void InitTools ()
 Function InitTools() Initializes all registered tools. More...
 
void ProcessEvent (const TOOL_EVENT &aEvent)
 Propagates an event to tools that requested events of matching type(s). More...
 
void PostEvent (const TOOL_EVENT &aEvent)
 Puts an event to the event queue to be processed at the end of event processing cycle. More...
 
void SetEnvironment (EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, wxWindow *aFrame)
 Sets the work environment (model, view, view controls and the parent window). More...
 
KIGFX::VIEWGetView () const
 
KIGFX::VIEW_CONTROLSGetViewControls () const
 
EDA_ITEMGetModel () const
 
wxWindow * GetEditFrame () const
 
int GetCurrentToolId () const
 Returns id of the tool that is on the top of the active tools stack (was invoked the most recently). More...
 
TOOL_BASEGetCurrentTool () const
 Returns the tool that is on the top of the active tools stack (was invoked the most recently). More...
 
TOOL_STATEGetCurrentToolState () const
 Returns the TOOL_STATE object representing the state of the active tool. More...
 
int GetPriority (int aToolId) const
 Returns priority of a given tool. More...
 
void ScheduleNextState (TOOL_BASE *aTool, TOOL_STATE_FUNC &aHandler, const TOOL_EVENT_LIST &aConditions)
 Defines a state transition - the events that cause a given handler method in the tool to be called. More...
 
void RunMainStack (TOOL_BASE *aTool, std::function< void()> aFunc)
 
boost::optional< TOOL_EVENTScheduleWait (TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
 Pauses execution of a given tool until one or more events matching aConditions arrives. More...
 
void ScheduleContextMenu (TOOL_BASE *aTool, CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
 Sets behaviour of the tool's context popup menu. More...
 
void PassEvent ()
 Allows a tool to pass the already handled event to the next tool on the stack. More...
 
bool SaveClipboard (const std::string &aText)
 Stores an information to the system clipboard. More...
 
std::string GetClipboard () const
 Returns the information currently stored in the system clipboard. More...
 

Static Public Member Functions

static TOOL_ID MakeToolId (const std::string &aToolName)
 Generates a unique ID from for a tool with given name. More...
 

Private Types

typedef std::pair< TOOL_EVENT_LIST, TOOL_STATE_FUNCTRANSITION
 

Private Member Functions

void dispatchInternal (const TOOL_EVENT &aEvent)
 Function dispatchInternal Passes an event at first to the active tools, then to all others. More...
 
bool dispatchStandardEvents (const TOOL_EVENT &aEvent)
 Function dispatchStandardEvents() Handles specific events, that are intended for TOOL_MANAGER rather than tools. More...
 
bool dispatchActivation (const TOOL_EVENT &aEvent)
 Function dispatchActivation() Checks if it is a valid activation event and invokes a proper tool. More...
 
void dispatchContextMenu (const TOOL_EVENT &aEvent)
 Function dispatchContextMenu() Handles context menu related events. More...
 
bool invokeTool (TOOL_BASE *aTool)
 Function invokeTool() Invokes a tool by sending a proper event (in contrary to runTool, which makes the tool run for real). More...
 
bool runTool (TOOL_ID aToolId)
 Function runTool() Makes a tool active, so it can receive events and react to them. More...
 
bool runTool (const std::string &aName)
 Function runTool() Makes a tool active, so it can receive events and react to them. More...
 
bool runTool (TOOL_BASE *aTool)
 Function runTool() Makes a tool active, so it can receive events and react to them. More...
 
template<class Parameters >
void invokeTool (const std::string &aName, const Parameters &aToolParams)
 
ID_LIST::iterator finishTool (TOOL_STATE *aState)
 Function finishTool() Deactivates a tool and does the necessary clean up. More...
 
bool isRegistered (TOOL_BASE *aTool) const
 Function isRegistered() Returns information about a tool registration status. More...
 
bool isActive (TOOL_BASE *aTool)
 Function isActive() Returns information about a tool activation status. More...
 
void saveViewControls (TOOL_STATE *aState)
 Function saveViewControls() Saves the VIEW_CONTROLS settings to the tool state object. More...
 
void applyViewControls (TOOL_STATE *aState)
 Function applyViewControls() Applies VIEW_CONTROLS settings stored in a TOOL_STATE object. More...
 
void pushViewControls ()
 Function pushViewControls() Stores the current VIEW_CONTROLS settings on the stack. More...
 
void popViewControls ()
 Function pushViewControls() Restores VIEW_CONTROLS settings from the stack. More...
 
void processEvent (const TOOL_EVENT &aEvent)
 

Main function for event processing.

More...
 

Private Attributes

TOOL_STATE_MAP m_toolState
 Index of registered tools current states, associated by tools' objects. More...
 
NAME_STATE_MAP m_toolNameIndex
 Index of the registered tools current states, associated by tools' names. More...
 
ID_STATE_MAP m_toolIdIndex
 Index of the registered tools current states, associated by tools' ID numbers. More...
 
std::map< const char *, TOOL_BASE * > m_toolTypes
 Index of the registered tools to easily lookup by their type. More...
 
ID_LIST m_activeTools
 Stack of the active tools. More...
 
ACTION_MANAGERm_actionMgr
 Instance of ACTION_MANAGER that handles TOOL_ACTIONs. More...
 
boost::optional< VECTOR2Dm_origCursor
 Original cursor position, if overridden by the context menu handler. More...
 
EDA_ITEMm_model
 
KIGFX::VIEWm_view
 
KIGFX::VIEW_CONTROLSm_viewControls
 
wxWindow * m_editFrame
 
std::list< TOOL_EVENTm_eventQueue
 Queue that stores events to be processed at the end of the event processing cycle. More...
 
std::stack< KIGFX::VC_SETTINGSm_vcStack
 

VIEW_CONTROLS settings stack

More...
 
bool m_passEvent
 Flag saying if the currently processed event should be passed to other tools. More...
 
bool m_menuActive
 Flag indicating whether a context menu is currently displayed. More...
 

Detailed Description

Class TOOL_MANAGER.

Master controller class:

  • registers editing tools
  • pumps UI events to tools requesting them
  • manages tool state machines (transitions and wait requests)

Definition at line 49 of file tool_manager.h.

Member Typedef Documentation

typedef std::list<TOOL_ID> TOOL_MANAGER::ID_LIST

Definition at line 63 of file tool_manager.h.

Definition at line 62 of file tool_manager.h.

typedef std::map<std::string, TOOL_STATE*> TOOL_MANAGER::NAME_STATE_MAP

Definition at line 61 of file tool_manager.h.

Definition at line 60 of file tool_manager.h.

Definition at line 355 of file tool_manager.h.

Constructor & Destructor Documentation

TOOL_MANAGER::TOOL_MANAGER ( )

Definition at line 194 of file tool_manager.cpp.

References m_actionMgr, and m_vcStack.

194  :
195  m_model( NULL ),
196  m_view( NULL ),
197  m_viewControls( NULL ),
198  m_editFrame( NULL ),
199  m_passEvent( false ),
200  m_menuActive( false )
201 {
202  m_actionMgr = new ACTION_MANAGER( this );
203 
204  // Keep default VIEW_CONTROLS settings at the bottom of the stack
205  m_vcStack.push( KIGFX::VC_SETTINGS() );
206 }
bool m_menuActive
Flag indicating whether a context menu is currently displayed.
Definition: tool_manager.h:518
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:498
Class ACTION_MANAGER.
bool m_passEvent
Flag saying if the currently processed event should be passed to other tools.
Definition: tool_manager.h:515
EDA_ITEM * m_model
Definition: tool_manager.h:503
wxWindow * m_editFrame
Definition: tool_manager.h:506
Structure to keep VIEW_CONTROLS settings for easy store/restore operations
Definition: view_controls.h:44
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:505
KIGFX::VIEW * m_view
Definition: tool_manager.h:504
std::stack< KIGFX::VC_SETTINGS > m_vcStack
VIEW_CONTROLS settings stack
Definition: tool_manager.h:512
TOOL_MANAGER::~TOOL_MANAGER ( )

Definition at line 209 of file tool_manager.cpp.

References m_actionMgr, and m_toolState.

210 {
211  std::map<TOOL_BASE*, TOOL_STATE*>::iterator it, it_end;
212 
213  for( it = m_toolState.begin(), it_end = m_toolState.end(); it != it_end; ++it )
214  {
215  delete it->second->cofunc; // delete cofunction
216  delete it->second; // delete TOOL_STATE
217  delete it->first; // delete the tool itself
218  }
219 
220  delete m_actionMgr;
221 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:498
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:483

Member Function Documentation

void TOOL_MANAGER::applyViewControls ( TOOL_STATE aState)
private

Function applyViewControls() Applies VIEW_CONTROLS settings stored in a TOOL_STATE object.

Definition at line 824 of file tool_manager.cpp.

References KIGFX::VIEW_CONTROLS::ApplySettings(), m_viewControls, and TOOL_MANAGER::TOOL_STATE::vcSettings.

Referenced by dispatchInternal(), and ProcessEvent().

825 {
826  m_viewControls->ApplySettings( aState->vcSettings );
827 }
void ApplySettings(const VC_SETTINGS &aSettings)
Applies VIEW_CONTROLS settings from an object
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:505
void TOOL_MANAGER::DeactivateTool ( )

Function DeactivateTool() Deactivates the currently active tool.

Definition at line 406 of file tool_manager.cpp.

References processEvent(), TA_CANCEL_TOOL, and TC_COMMAND.

Referenced by ResetTools(), and PCB_BASE_EDIT_FRAME::SetBoard().

407 {
408  // Deactivate the active tool, but do not run anything new
410  processEvent( evt );
411 }
Class TOOL_EVENT.
Definition: tool_event.h:162
void processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
bool TOOL_MANAGER::dispatchActivation ( const TOOL_EVENT aEvent)
private

Function dispatchActivation() Checks if it is a valid activation event and invokes a proper tool.

Parameters
aEventis an event to be tested.
Returns
True if a tool was invoked, false otherwise.

Definition at line 607 of file tool_manager.cpp.

References TOOL_EVENT::GetCommandStr(), TOOL_EVENT::IsActivate(), m_toolNameIndex, and runTool().

Referenced by processEvent().

608 {
609  if( aEvent.IsActivate() )
610  {
611  std::map<std::string, TOOL_STATE*>::iterator tool = m_toolNameIndex.find( *aEvent.GetCommandStr() );
612 
613  if( tool != m_toolNameIndex.end() )
614  {
615  runTool( tool->second->theTool );
616  return true;
617  }
618  }
619 
620  return false;
621 }
bool runTool(TOOL_ID aToolId)
Function runTool() Makes a tool active, so it can receive events and react to them.
boost::optional< std::string > GetCommandStr() const
Definition: tool_event.h:395
NAME_STATE_MAP m_toolNameIndex
Index of the registered tools current states, associated by tools' names.
Definition: tool_manager.h:486
bool IsActivate() const
Definition: tool_event.h:300
void TOOL_MANAGER::dispatchContextMenu ( const TOOL_EVENT aEvent)
private

Function dispatchContextMenu() Handles context menu related events.

Definition at line 624 of file tool_manager.cpp.

References BUT_RIGHT, CONTEXT_MENU::Clone(), CMENU_BUTTON, CMENU_NOW, CMENU_OFF, TOOL_MANAGER::TOOL_STATE::contextMenu, TOOL_MANAGER::TOOL_STATE::contextMenuTrigger, dispatchInternal(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), KIGFX::VIEW_CONTROLS::ForcedCursorPosition(), GetCurrentToolId(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), GetEditFrame(), TOOL_EVENT::IsClick(), m_activeTools, m_menuActive, m_origCursor, m_toolIdIndex, m_viewControls, TOOL_MANAGER::TOOL_STATE::pendingWait, TOOL_EVENT::SetParameter(), TA_ANY, TA_CONTEXT_MENU_CHOICE, TA_CONTEXT_MENU_CLOSED, TC_ANY, TC_COMMAND, and TOOL_MANAGER::TOOL_STATE::waitEvents.

Referenced by processEvent().

625 {
626  // Store the current tool ID to decide whether to restore the cursor position
627  TOOL_ID activeTool = GetCurrentToolId();
628 
629  for( TOOL_ID toolId : m_activeTools )
630  {
631  TOOL_STATE* st = m_toolIdIndex[toolId];
632 
633  // the tool requested a context menu. The menu is activated on RMB click (CMENU_BUTTON mode)
634  // or immediately (CMENU_NOW) mode. The latter is used for clarification lists.
635  if( st->contextMenuTrigger == CMENU_OFF )
636  continue;
637 
638  if( st->contextMenuTrigger == CMENU_BUTTON && !aEvent.IsClick( BUT_RIGHT ) )
639  break;
640 
641  st->pendingWait = true;
642  st->waitEvents = TOOL_EVENT( TC_ANY, TA_ANY );
643 
644  // Store the menu pointer in case it is changed by the TOOL when handling menu events
645  CONTEXT_MENU* m = st->contextMenu;
646 
647  if( st->contextMenuTrigger == CMENU_NOW )
648  st->contextMenuTrigger = CMENU_OFF;
649 
651 
652  // Temporarily store the cursor position, so the tools could execute actions
653  // using the point where the user has invoked a context menu
655  m_origCursor = cursor;
656 
657  m_viewControls->ForceCursorPosition( true, cursor );
658 
659  // Display a copy of menu
660  std::unique_ptr<CONTEXT_MENU> menu( m->Clone() );
661 
662  // Run update handlers on the created copy
663  menu->UpdateAll();
664  m_menuActive = true;
665  GetEditFrame()->PopupMenu( menu.get() );
666  m_menuActive = false;
667 
668  // If nothing was chosen from the context menu, we must notify the tool as well
669  if( menu->GetSelected() < 0 )
670  {
672  evt.SetParameter( m );
673  dispatchInternal( evt );
674  }
675 
676  // Notify the tools that menu has been closed
678  evt.SetParameter( m );
679  dispatchInternal( evt );
680 
681  // Restore the cursor settings if the tool is still active
682  if( activeTool == GetCurrentToolId() )
683  {
685  m_origCursor.get_value_or( VECTOR2D( 0, 0 ) ) );
686  }
687 
688  m_origCursor = boost::none;
689  break;
690  }
691 }
bool m_menuActive
Flag indicating whether a context menu is currently displayed.
Definition: tool_manager.h:518
int GetCurrentToolId() const
Returns id of the tool that is on the top of the active tools stack (was invoked the most recently)...
Definition: tool_manager.h:268
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:489
Class CONTEXT_MENU.
Definition: context_menu.h:44
wxWindow * GetEditFrame() const
Definition: tool_manager.h:258
int TOOL_ID
Unique identifier for tools.
Definition: tool_base.h:57
CONTEXT_MENU * Clone() const
Creates a deep, recursive copy of this CONTEXT_MENU.
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
void dispatchInternal(const TOOL_EVENT &aEvent)
Function dispatchInternal Passes an event at first to the active tools, then to all others...
Class TOOL_EVENT.
Definition: tool_event.h:162
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:505
boost::optional< VECTOR2D > m_origCursor
Original cursor position, if overridden by the context menu handler.
Definition: tool_manager.h:501
bool ForcedCursorPosition() const
Function ForcedCursorPosition() Returns true if the current cursor position is forced to a specific l...
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:495
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:268
void TOOL_MANAGER::dispatchInternal ( const TOOL_EVENT aEvent)
private

Function dispatchInternal Passes an event at first to the active tools, then to all others.

Definition at line 505 of file tool_manager.cpp.

References applyViewControls(), COROUTINE< ReturnType, ArgType >::Call(), TOOL_EVENT::Category(), TOOL_EVENT_LIST::clear(), TOOL_MANAGER::TOOL_STATE::cofunc, finishTool(), m_activeTools, m_passEvent, m_toolIdIndex, m_toolState, TOOL_EVENT_LIST::Matches(), TOOL_MANAGER::TOOL_STATE::pendingWait, popViewControls(), TOOL_MANAGER::TOOL_STATE::Push(), pushViewControls(), COROUTINE< ReturnType, ArgType >::Resume(), COROUTINE< ReturnType, ArgType >::Running(), saveViewControls(), TC_MESSAGE, TOOL_MANAGER::TOOL_STATE::transitions, TOOL_MANAGER::TOOL_STATE::waitEvents, and TOOL_MANAGER::TOOL_STATE::wakeupEvent.

Referenced by dispatchContextMenu(), and processEvent().

506 {
507  // iterate over all registered tools
508  for( auto it = m_activeTools.begin(); it != m_activeTools.end(); ++it )
509  {
510  TOOL_STATE* st = m_toolIdIndex[*it];
511 
512  // the tool state handler is waiting for events (i.e. called Wait() method)
513  if( st->pendingWait )
514  {
515  if( st->waitEvents.Matches( aEvent ) )
516  {
517  // By default, only messages are passed further
518  m_passEvent = ( aEvent.Category() == TC_MESSAGE );
519 
520  // got matching event? clear wait list and wake up the coroutine
521  st->wakeupEvent = aEvent;
522  st->pendingWait = false;
523  st->waitEvents.clear();
524 
525  if( st->cofunc )
526  {
528  applyViewControls( st );
529  bool end = !st->cofunc->Resume();
530  saveViewControls( st );
531  popViewControls();
532 
533  if( end )
534  it = finishTool( st );
535  }
536 
537  // If the tool did not request to propagate
538  // the event to other tools, we should stop it now
539  if( !m_passEvent )
540  break;
541  }
542  }
543  }
544 
545  for( auto& state : m_toolState )
546  {
547  TOOL_STATE* st = state.second;
548  bool finished = false;
549 
550  // no state handler in progress - check if there are any transitions (defined by
551  // Go() method that match the event.
552  if( !st->transitions.empty() )
553  {
554  for( TRANSITION& tr : st->transitions )
555  {
556  if( tr.first.Matches( aEvent ) )
557  {
558  auto func_copy = tr.second;
559 
560  // if there is already a context, then store it
561  if( st->cofunc )
562  st->Push();
563 
564  st->cofunc = new COROUTINE<int, const TOOL_EVENT&>( std::move( func_copy ) );
565 
566  // as the state changes, the transition table has to be set up again
567  st->transitions.clear();
568 
569  // got match? Run the handler.
571  applyViewControls( st );
572  st->cofunc->Call( aEvent );
573  saveViewControls( st );
574  popViewControls();
575 
576  if( !st->cofunc->Running() )
577  finishTool( st ); // The couroutine has finished immediately?
578 
579  // if it is a message, continue processing
580  finished = !( aEvent.Category() == TC_MESSAGE );
581 
582  // there is no point in further checking, as transitions got cleared
583  break;
584  }
585  }
586  }
587 
588  if( finished )
589  break; // only the first tool gets the event
590  }
591 }
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:489
ID_LIST::iterator finishTool(TOOL_STATE *aState)
Function finishTool() Deactivates a tool and does the necessary clean up.
void applyViewControls(TOOL_STATE *aState)
Function applyViewControls() Applies VIEW_CONTROLS settings stored in a TOOL_STATE object...
bool m_passEvent
Flag saying if the currently processed event should be passed to other tools.
Definition: tool_manager.h:515
void pushViewControls()
Function pushViewControls() Stores the current VIEW_CONTROLS settings on the stack.
TOOL_EVENT_CATEGORY Category() const
Returns the category (eg. mouse/keyboard/action) of an event..
Definition: tool_event.h:228
void popViewControls()
Function pushViewControls() Restores VIEW_CONTROLS settings from the stack.
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:495
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:483
void saveViewControls(TOOL_STATE *aState)
Function saveViewControls() Saves the VIEW_CONTROLS settings to the tool state object.
std::pair< TOOL_EVENT_LIST, TOOL_STATE_FUNC > TRANSITION
Definition: tool_manager.h:355
bool TOOL_MANAGER::dispatchStandardEvents ( const TOOL_EVENT aEvent)
private

Function dispatchStandardEvents() Handles specific events, that are intended for TOOL_MANAGER rather than tools.

Parameters
aEventis the event to be processed.
Returns
False if the event was processed and should not go any further.

Definition at line 594 of file tool_manager.cpp.

References TOOL_EVENT::Action(), TOOL_EVENT::KeyCode(), m_actionMgr, TOOL_EVENT::Modifier(), ACTION_MANAGER::RunHotKey(), and TA_KEY_PRESSED.

Referenced by processEvent().

595 {
596  if( aEvent.Action() == TA_KEY_PRESSED )
597  {
598  // Check if there is a hotkey associated
599  if( m_actionMgr->RunHotKey( aEvent.Modifier() | aEvent.KeyCode() ) )
600  return false; // hotkey event was handled so it does not go any further
601  }
602 
603  return true;
604 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:498
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:311
int KeyCode() const
Definition: tool_event.h:316
bool RunHotKey(int aHotKey) const
Function RunHotKey() Runs an action associated with a hotkey (if there is one available).
TOOL_ACTIONS Action() const
Returns more specific information about the type of an event.
Definition: tool_event.h:234
TOOL_BASE * TOOL_MANAGER::FindTool ( int  aId) const

Function FindTool() Searches for a tool with given ID.

Parameters
aIdis the ID number of the requested tool.
Returns
Pointer to the requested tool or NULL in case of failure.

Definition at line 384 of file tool_manager.cpp.

References m_toolIdIndex.

Referenced by GetCurrentTool(), PLACEMENT_TOOL::Init(), POINT_EDITOR::Init(), EDIT_TOOL::Init(), EDIT_TOOL::invokeInlineRouter(), InvokeTool(), ACTION_MANAGER::RunHotKey(), and runTool().

385 {
386  std::map<TOOL_ID, TOOL_STATE*>::const_iterator it = m_toolIdIndex.find( aId );
387 
388  if( it != m_toolIdIndex.end() )
389  return it->second->theTool;
390 
391  return NULL;
392 }
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:489
TOOL_BASE * TOOL_MANAGER::FindTool ( const std::string &  aName) const

Function FindTool() Searches for a tool with given name.

Parameters
aNameis the name of the requested tool.
Returns
Pointer to the requested tool or NULL in case of failure.

Definition at line 395 of file tool_manager.cpp.

References m_toolNameIndex.

396 {
397  std::map<std::string, TOOL_STATE*>::const_iterator it = m_toolNameIndex.find( aName );
398 
399  if( it != m_toolNameIndex.end() )
400  return it->second->theTool;
401 
402  return NULL;
403 }
NAME_STATE_MAP m_toolNameIndex
Index of the registered tools current states, associated by tools' names.
Definition: tool_manager.h:486
TOOL_MANAGER::ID_LIST::iterator TOOL_MANAGER::finishTool ( TOOL_STATE aState)
private

Function finishTool() Deactivates a tool and does the necessary clean up.

Parameters
aStateis the state variable of the tool to be stopped.
Returns
m_activeTools iterator. If the tool has been completely deactivated, it points to the next active tool on the list. Otherwise it is an iterator pointing to aState.

Definition at line 694 of file tool_manager.cpp.

References TOOL_BASE::GetId(), m_activeTools, TOOL_MANAGER::TOOL_STATE::Pop(), TOOL_BASE::SetTransitions(), and TOOL_MANAGER::TOOL_STATE::theTool.

Referenced by dispatchInternal().

695 {
696  auto it = std::find( m_activeTools.begin(), m_activeTools.end(), aState->theTool->GetId() );
697 
698  if( !aState->Pop() )
699  {
700  // Deactivate the tool if there are no other contexts saved on the stack
701  if( it != m_activeTools.end() )
702  it = m_activeTools.erase( it );
703  }
704 
705  // Set transitions to be ready for future TOOL_EVENTs
706  aState->theTool->SetTransitions();
707 
708  return it;
709 }
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:495
std::string TOOL_MANAGER::GetClipboard ( ) const

Returns the information currently stored in the system clipboard.

If data stored in the clipboard is in non-text format, empty string is returned.

Definition at line 753 of file tool_manager.cpp.

Referenced by MODULE_EDITOR_TOOLS::PasteItems().

754 {
755  std::string result;
756 
757  if( wxTheClipboard->Open() )
758  {
759  if( wxTheClipboard->IsSupported( wxDF_TEXT ) )
760  {
761  wxTextDataObject data;
762  wxTheClipboard->GetData( data );
763 
764  result = data.GetText().mb_str();
765  }
766 
767  wxTheClipboard->Close();
768  }
769 
770  return result;
771 }
TOOL_BASE* TOOL_MANAGER::GetCurrentTool ( ) const
inline

Returns the tool that is on the top of the active tools stack (was invoked the most recently).

Returns
Pointer to the currently used tool.

Definition at line 278 of file tool_manager.h.

References FindTool(), and GetCurrentToolId().

279  {
280  return FindTool( GetCurrentToolId() );
281  }
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
int GetCurrentToolId() const
Returns id of the tool that is on the top of the active tools stack (was invoked the most recently)...
Definition: tool_manager.h:268
int TOOL_MANAGER::GetCurrentToolId ( ) const
inline

Returns id of the tool that is on the top of the active tools stack (was invoked the most recently).

Returns
Id of the currently used tool.

Definition at line 268 of file tool_manager.h.

References m_activeTools.

Referenced by dispatchContextMenu(), GetCurrentTool(), GetCurrentToolState(), and EDIT_TOOL::getModificationPoint().

269  {
270  return m_activeTools.empty() ? -1 : m_activeTools.front();
271  }
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:495
TOOL_STATE* TOOL_MANAGER::GetCurrentToolState ( ) const
inline

Returns the TOOL_STATE object representing the state of the active tool.

If there are no tools active, it returns nullptr.

Definition at line 287 of file tool_manager.h.

References GetCurrentToolId(), and m_toolIdIndex.

Referenced by ProcessEvent().

288  {
289  auto it = m_toolIdIndex.find( GetCurrentToolId() );
290  return ( it != m_toolIdIndex.end() ) ? it->second : nullptr;
291  }
int GetCurrentToolId() const
Returns id of the tool that is on the top of the active tools stack (was invoked the most recently)...
Definition: tool_manager.h:268
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:489
wxWindow* TOOL_MANAGER::GetEditFrame ( ) const
inline
int TOOL_MANAGER::GetHotKey ( const TOOL_ACTION aAction)

>

Function GetHotKey() Returns the hot key associated with a given action or 0 if there is none.

Parameters
aActionis the queried action.

Definition at line 309 of file tool_manager.cpp.

References ACTION_MANAGER::GetHotKey(), and m_actionMgr.

Referenced by CONTEXT_MENU::updateHotKeys().

310 {
311  return m_actionMgr->GetHotKey( aAction );
312 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:498
int GetHotKey(const TOOL_ACTION &aAction) const
Function GetHotKey() Returns the hot key associated with a given action or 0 if there is none...
EDA_ITEM* TOOL_MANAGER::GetModel ( ) const
inline

Definition at line 253 of file tool_manager.h.

References m_model.

Referenced by TOOL_BASE::getModelInt(), and highlightNet().

254  {
255  return m_model;
256  }
EDA_ITEM * m_model
Definition: tool_manager.h:503
int TOOL_MANAGER::GetPriority ( int  aToolId) const

Returns priority of a given tool.

Higher number means that the tool is closer to the beginning of the active tools queue (i.e. receives events earlier, tools with lower priority receive events later).

Parameters
aToolIdis the id of queried tool.
Returns
The priority of a given tool. If returned number is negative, then it means that the tool id is invalid or the tool is not active.

Definition at line 454 of file tool_manager.cpp.

References m_activeTools.

Referenced by ACTION_MANAGER::RunHotKey().

455 {
456  int priority = 0;
457 
458  for( auto it = m_activeTools.begin(), itEnd = m_activeTools.end(); it != itEnd; ++it )
459  {
460  if( *it == aToolId )
461  return priority;
462 
463  ++priority;
464  }
465 
466  return -1;
467 }
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:495
template<typename T >
T* TOOL_MANAGER::GetTool ( )
inline
KIGFX::VIEW* TOOL_MANAGER::GetView ( ) const
inline

Definition at line 243 of file tool_manager.h.

References m_view.

Referenced by MODULE_EDITOR_TOOLS::EnumeratePads(), TOOL_BASE::getView(), PCB_EDITOR_CONTROL::HighlightNet(), and highlightNet().

244  {
245  return m_view;
246  }
KIGFX::VIEW * m_view
Definition: tool_manager.h:504
KIGFX::VIEW_CONTROLS* TOOL_MANAGER::GetViewControls ( ) const
inline

Definition at line 248 of file tool_manager.h.

References m_viewControls.

Referenced by TOOL_DISPATCHER::DispatchWxEvent(), and TOOL_BASE::getViewControls().

249  {
250  return m_viewControls;
251  }
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:505
void TOOL_MANAGER::InitTools ( )

Function InitTools() Initializes all registered tools.

If a tool fails during the initialization, it is deactivated and becomes unavailable for further use. Initialization should be done only once.

Definition at line 426 of file tool_manager.cpp.

References Format(), TOOL_BASE::GetId(), TOOL_BASE::GetName(), TOOL_BASE::Init(), m_toolIdIndex, m_toolNameIndex, m_toolState, m_toolTypes, ResetTools(), and TOOL_BASE::RUN.

Referenced by FOOTPRINT_EDIT_FRAME::setupTools().

427 {
428  for( auto it = m_toolState.begin(); it != m_toolState.end(); /* iteration in the loop */ )
429  {
430  TOOL_BASE* tool = it->first;
431  TOOL_STATE* state = it->second;
432  ++it; // keep the iterator valid if the element is going to be erased
433 
434  if( !tool->Init() )
435  {
436  wxMessageBox(
437  wxString::Format( "Initialization of tool '%s' failed", tool->GetName() ) );
438 
439  // Unregister the tool
440  m_toolState.erase( tool );
441  m_toolNameIndex.erase( tool->GetName() );
442  m_toolIdIndex.erase( tool->GetId() );
443  m_toolTypes.erase( typeid( *tool ).name() );
444 
445  delete state;
446  delete tool;
447  }
448  }
449 
451 }
virtual bool Init()
Function Init() Init() is called once upon a registration of the tool.
Definition: tool_base.h:93
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:489
Tool is invoked after being inactive.
Definition: tool_base.h:82
NAME_STATE_MAP m_toolNameIndex
Index of the registered tools current states, associated by tools' names.
Definition: tool_manager.h:486
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
TOOL_ID GetId() const
Function GetId() Returns the unique identifier of the tool.
Definition: tool_base.h:122
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
Class TOOL_BASE.
Definition: tool_base.h:68
const std::string & GetName() const
Function GetName() Returns the name of the tool.
Definition: tool_base.h:133
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:483
std::map< const char *, TOOL_BASE * > m_toolTypes
Index of the registered tools to easily lookup by their type.
Definition: tool_manager.h:492
bool TOOL_MANAGER::InvokeTool ( TOOL_ID  aToolId)

Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.

Parameters
aToolIdis the ID number of the requested tool.
Returns
True if the requested tool was invoked successfully.

Definition at line 244 of file tool_manager.cpp.

References FindTool(), TOOL_BASE::GetType(), INTERACTIVE, and invokeTool().

Referenced by TOOL_INTERACTIVE::Activate(), PCBNEW_CONTROL::AppendBoard(), SELECTION_TOOL::findMove(), SELECTION_TOOL::Main(), DIALOG_UPDATE_PCB::PerformUpdate(), and FOOTPRINT_EDIT_FRAME::setupTools().

245 {
246  TOOL_BASE* tool = FindTool( aToolId );
247 
248  if( tool && tool->GetType() == INTERACTIVE )
249  return invokeTool( tool );
250 
251  return false; // there is no tool with the given id
252 }
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
Tool that interacts with the user
Definition: tool_base.h:50
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:111
Class TOOL_BASE.
Definition: tool_base.h:68
bool invokeTool(TOOL_BASE *aTool)
Function invokeTool() Invokes a tool by sending a proper event (in contrary to runTool, which makes the tool run for real).
bool TOOL_MANAGER::InvokeTool ( const std::string &  aToolName)

Function InvokeTool() Calls a tool by sending a tool activation event to tool of given name.

Parameters
aToolNameis the name of the requested tool.
Returns
True if the requested tool was invoked successfully.

Definition at line 255 of file tool_manager.cpp.

References FindTool(), TOOL_BASE::GetType(), INTERACTIVE, and invokeTool().

256 {
257  TOOL_BASE* tool = FindTool( aToolName );
258 
259  if( tool && tool->GetType() == INTERACTIVE )
260  return invokeTool( tool );
261 
262  return false; // there is no tool with the given name
263 }
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
Tool that interacts with the user
Definition: tool_base.h:50
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:111
Class TOOL_BASE.
Definition: tool_base.h:68
bool invokeTool(TOOL_BASE *aTool)
Function invokeTool() Invokes a tool by sending a proper event (in contrary to runTool, which makes the tool run for real).
bool TOOL_MANAGER::invokeTool ( TOOL_BASE aTool)
private

Function invokeTool() Invokes a tool by sending a proper event (in contrary to runTool, which makes the tool run for real).

Parameters
aToolis the tool to be invoked.

Definition at line 321 of file tool_manager.cpp.

References TOOL_BASE::GetName(), processEvent(), TA_ACTIVATE, and TC_COMMAND.

Referenced by InvokeTool().

322 {
323  wxASSERT( aTool != NULL );
324 
325  TOOL_EVENT evt( TC_COMMAND, TA_ACTIVATE, aTool->GetName() );
326  processEvent( evt );
327 
328  return true;
329 }
Class TOOL_EVENT.
Definition: tool_event.h:162
void processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
const std::string & GetName() const
Function GetName() Returns the name of the tool.
Definition: tool_base.h:133
template<class Parameters >
void TOOL_MANAGER::invokeTool ( const std::string &  aName,
const Parameters &  aToolParams 
)
private
bool TOOL_MANAGER::isActive ( TOOL_BASE aTool)
private

Function isActive() Returns information about a tool activation status.

Parameters
aToolis the tool to be checked.
Returns
True if the tool is on the active tools stack, false otherwise.

Definition at line 793 of file tool_manager.cpp.

References TOOL_BASE::GetId(), isRegistered(), and m_activeTools.

Referenced by runTool().

794 {
795  if( !isRegistered( aTool ) )
796  return false;
797 
798  // Just check if the tool is on the active tools stack
799  return std::find( m_activeTools.begin(), m_activeTools.end(), aTool->GetId() ) != m_activeTools.end();
800 }
TOOL_ID GetId() const
Function GetId() Returns the unique identifier of the tool.
Definition: tool_base.h:122
bool isRegistered(TOOL_BASE *aTool) const
Function isRegistered() Returns information about a tool registration status.
Definition: tool_manager.h:440
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:495
bool TOOL_MANAGER::isRegistered ( TOOL_BASE aTool) const
inlineprivate

Function isRegistered() Returns information about a tool registration status.

Parameters
aToolis the tool to be checked.
Returns
true if the tool is in the registered tools list, false otherwise.

Definition at line 440 of file tool_manager.h.

References m_toolState.

Referenced by isActive(), and runTool().

441  {
442  return m_toolState.count( aTool ) > 0;
443  }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:483
TOOL_ID TOOL_MANAGER::MakeToolId ( const std::string &  aToolName)
static

Generates a unique ID from for a tool with given name.

Definition at line 774 of file tool_manager.cpp.

775 {
776  static int currentId;
777 
778  return currentId++;
779 }
void TOOL_MANAGER::PassEvent ( )
inline

Allows a tool to pass the already handled event to the next tool on the stack.

Definition at line 336 of file tool_manager.h.

References m_passEvent.

Referenced by ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::MeasureTool(), and POINT_EDITOR::OnSelectionChange().

337  {
338  m_passEvent = true;
339  }
bool m_passEvent
Flag saying if the currently processed event should be passed to other tools.
Definition: tool_manager.h:515
void TOOL_MANAGER::popViewControls ( )
private

Function pushViewControls() Restores VIEW_CONTROLS settings from the stack.

Definition at line 836 of file tool_manager.cpp.

References KIGFX::VIEW_CONTROLS::ApplySettings(), m_vcStack, and m_viewControls.

Referenced by dispatchInternal().

837 {
839  m_vcStack.pop();
840 }
void ApplySettings(const VC_SETTINGS &aSettings)
Applies VIEW_CONTROLS settings from an object
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:505
std::stack< KIGFX::VC_SETTINGS > m_vcStack
VIEW_CONTROLS settings stack
Definition: tool_manager.h:512
void TOOL_MANAGER::PostEvent ( const TOOL_EVENT aEvent)
inline

Puts an event to the event queue to be processed at the end of event processing cycle.

Parameters
aEventis the event to be put into the queue.

Definition at line 229 of file tool_manager.h.

References m_eventQueue.

Referenced by RunAction().

230  {
231  m_eventQueue.push_back( aEvent );
232  }
std::list< TOOL_EVENT > m_eventQueue
Queue that stores events to be processed at the end of the event processing cycle.
Definition: tool_manager.h:509
void TOOL_MANAGER::ProcessEvent ( const TOOL_EVENT aEvent)

Propagates an event to tools that requested events of matching type(s).

Parameters
aEventis the event to be processed.

Definition at line 712 of file tool_manager.cpp.

References applyViewControls(), GetCurrentToolState(), GetEditFrame(), EDA_DRAW_FRAME::GetGalCanvas(), KIGFX::VIEW::IsDirty(), m_view, processEvent(), and EDA_DRAW_PANEL_GAL::Refresh().

Referenced by SELECTION_TOOL::clearSelection(), PCBNEW_CONTROL::CursorControl(), TOOL_DISPATCHER::DispatchWxCommand(), TOOL_DISPATCHER::DispatchWxEvent(), SELECTION_TOOL::findCallback(), TOOL_DISPATCHER::handleMouseButton(), CONTEXT_MENU::onMenuEvent(), SELECTION_TOOL::SanitizeSelection(), SELECTION_TOOL::selectConnection(), SELECTION_TOOL::selectCopper(), SELECTION_TOOL::SelectItem(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::toggleSelection(), DIALOG_SET_GRID::TransferDataFromWindow(), and SELECTION_TOOL::UnselectItem().

713 {
714  processEvent( aEvent );
715 
716  if( TOOL_STATE* active = GetCurrentToolState() )
717  {
718  applyViewControls( active );
719  }
720 
721  if( m_view->IsDirty() )
722  {
723  EDA_DRAW_FRAME* f = static_cast<EDA_DRAW_FRAME*>( GetEditFrame() );
724  f->GetGalCanvas()->Refresh(); // fixme: ugly hack, provide a method in TOOL_DISPATCHER.
725  }
726 }
wxWindow * GetEditFrame() const
Definition: tool_manager.h:258
void applyViewControls(TOOL_STATE *aState)
Function applyViewControls() Applies VIEW_CONTROLS settings stored in a TOOL_STATE object...
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:53
bool IsDirty() const
Function IsDirty() Returns true if any of the VIEW layers needs to be refreshened.
Definition: view.h:546
TOOL_STATE * GetCurrentToolState() const
Returns the TOOL_STATE object representing the state of the active tool.
Definition: tool_manager.h:287
KIGFX::VIEW * m_view
Definition: tool_manager.h:504
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
void processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:803
void TOOL_MANAGER::processEvent ( const TOOL_EVENT aEvent)
private

Main function for event processing.

Definition at line 843 of file tool_manager.cpp.

References dispatchActivation(), dispatchContextMenu(), dispatchInternal(), dispatchStandardEvents(), and m_eventQueue.

Referenced by DeactivateTool(), invokeTool(), ProcessEvent(), and RunAction().

844 {
845  // Early dispatch of events destined for the TOOL_MANAGER
846  if( !dispatchStandardEvents( aEvent ) )
847  return;
848 
849  dispatchInternal( aEvent );
850  dispatchActivation( aEvent );
851  dispatchContextMenu( aEvent );
852 
853  // Dispatch queue
854  while( !m_eventQueue.empty() )
855  {
856  TOOL_EVENT event = m_eventQueue.front();
857  m_eventQueue.pop_front();
858  processEvent( event );
859  }
860 }
bool dispatchStandardEvents(const TOOL_EVENT &aEvent)
Function dispatchStandardEvents() Handles specific events, that are intended for TOOL_MANAGER rather ...
bool dispatchActivation(const TOOL_EVENT &aEvent)
Function dispatchActivation() Checks if it is a valid activation event and invokes a proper tool...
void dispatchContextMenu(const TOOL_EVENT &aEvent)
Function dispatchContextMenu() Handles context menu related events.
void dispatchInternal(const TOOL_EVENT &aEvent)
Function dispatchInternal Passes an event at first to the active tools, then to all others...
Class TOOL_EVENT.
Definition: tool_event.h:162
std::list< TOOL_EVENT > m_eventQueue
Queue that stores events to be processed at the end of the event processing cycle.
Definition: tool_manager.h:509
void processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
void TOOL_MANAGER::pushViewControls ( )
private

Function pushViewControls() Stores the current VIEW_CONTROLS settings on the stack.

Definition at line 830 of file tool_manager.cpp.

References KIGFX::VIEW_CONTROLS::GetSettings(), m_vcStack, and m_viewControls.

Referenced by dispatchInternal().

831 {
833 }
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:505
const VC_SETTINGS & GetSettings() const
Returns the current VIEW_CONTROLS settings
std::stack< KIGFX::VC_SETTINGS > m_vcStack
VIEW_CONTROLS settings stack
Definition: tool_manager.h:512
void TOOL_MANAGER::RegisterAction ( TOOL_ACTION aAction)

Function RegisterAction() Registers an action that can be used to control tools (eg.

invoke, trigger specific behaviours).

Parameters
aActionis the action to be registered.

Definition at line 266 of file tool_manager.cpp.

References m_actionMgr, and ACTION_MANAGER::RegisterAction().

267 {
268  m_actionMgr->RegisterAction( aAction );
269 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:498
void RegisterAction(TOOL_ACTION *aAction)
Function RegisterAction() Adds a tool action to the manager and sets it up.
void TOOL_MANAGER::RegisterTool ( TOOL_BASE aTool)

Function RegisterTool() Adds a tool to the manager set and sets it up.

Called once for each tool during application initialization.

Parameters
aTooltool to be added. Ownership is transferred.

Definition at line 224 of file tool_manager.cpp.

References TOOL_BASE::attachManager(), TOOL_BASE::GetId(), TOOL_BASE::GetName(), m_toolIdIndex, m_toolNameIndex, m_toolState, and m_toolTypes.

Referenced by PCB_ACTIONS::RegisterAllTools(), and FOOTPRINT_EDIT_FRAME::setupTools().

225 {
226  wxASSERT_MSG( m_toolNameIndex.find( aTool->GetName() ) == m_toolNameIndex.end(),
227  wxT( "Adding two tools with the same name may result in unexpected behaviour.") );
228  wxASSERT_MSG( m_toolIdIndex.find( aTool->GetId() ) == m_toolIdIndex.end(),
229  wxT( "Adding two tools with the same ID may result in unexpected behaviour.") );
230  wxASSERT_MSG( m_toolTypes.find( typeid( *aTool ).name() ) == m_toolTypes.end(),
231  wxT( "Adding two tools of the same type may result in unexpected behaviour.") );
232 
233  TOOL_STATE* st = new TOOL_STATE( aTool );
234 
235  m_toolState[aTool] = st;
236  m_toolNameIndex[aTool->GetName()] = st;
237  m_toolIdIndex[aTool->GetId()] = st;
238  m_toolTypes[typeid( *aTool ).name()] = st->theTool;
239 
240  aTool->attachManager( this );
241 }
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:489
void attachManager(TOOL_MANAGER *aManager)
Function attachManager()
Definition: tool_base.cpp:54
NAME_STATE_MAP m_toolNameIndex
Index of the registered tools current states, associated by tools' names.
Definition: tool_manager.h:486
TOOL_ID GetId() const
Function GetId() Returns the unique identifier of the tool.
Definition: tool_base.h:122
const std::string & GetName() const
Function GetName() Returns the name of the tool.
Definition: tool_base.h:133
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:483
std::map< const char *, TOOL_BASE * > m_toolTypes
Index of the registered tools to easily lookup by their type.
Definition: tool_manager.h:492
void TOOL_MANAGER::ResetTools ( TOOL_BASE::RESET_REASON  aReason)

Function ResetTools() Resets all tools (i.e.

calls their Reset() method).

Definition at line 414 of file tool_manager.cpp.

References DeactivateTool(), and m_toolState.

Referenced by InitTools(), PCB_BASE_EDIT_FRAME::SetBoard(), FOOTPRINT_VIEWER_FRAME::updateView(), FOOTPRINT_EDIT_FRAME::updateView(), and PCB_BASE_FRAME::UseGalCanvas().

415 {
416  DeactivateTool();
417 
418  for( auto& state : m_toolState )
419  {
420  state.first->Reset( aReason );
421  state.first->SetTransitions();
422  }
423 }
void DeactivateTool()
Function DeactivateTool() Deactivates the currently active tool.
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:483
template<typename T >
bool TOOL_MANAGER::RunAction ( const std::string &  aActionName,
bool  aNow = false,
aParam = NULL 
)
inline

Function RunAction() Runs the specified action.

The common format for action names is "application.ToolName.Action".

Parameters
aActionNameis the name of action to be invoked.
aNowdecides if the action has to be run immediately or after the current coroutine is preemptied.
aParamis an optional parameter that might be used by the invoked action. Its meaning depends on the action.
Returns
False if the action was not found.

Definition at line 125 of file tool_manager.h.

Referenced by PCBNEW_CONTROL::AppendBoard(), PAD_TOOL::applyPadSettings(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), ROUTER_TOOL::CustomTrackWidthDialog(), deleteItem(), PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), EDA_DRAW_FRAME::OnSelectGrid(), EDA_DRAW_FRAME::OnSelectZoom(), MODULE_EDITOR_TOOLS::PasteItems(), DIALOG_UPDATE_PCB::PerformUpdate(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), GAL_ARRAY_CREATOR::prePushAction(), FOOTPRINT_EDIT_FRAME::Process_Special_Functions(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::Remove(), SELECTION_TOOL::RequestSelection(), EDIT_TOOL::Rotate(), RunAction(), ACTION_MANAGER::RunHotKey(), DRC::ShowDRCDialog(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), DIALOG_SET_GRID::TransferDataFromWindow(), FOOTPRINT_VIEWER_FRAME::updateView(), FOOTPRINT_EDIT_FRAME::updateView(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCB_EDITOR_CONTROL::ZoneMerge(), and EDA_DRAW_FRAME::Zoom_Automatique().

126  {
127  return RunAction( aActionName, aNow, reinterpret_cast<void*>( aParam ) );
128  }
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
bool TOOL_MANAGER::RunAction ( const std::string &  aActionName,
bool  aNow,
void *  aParam 
)

Definition at line 278 of file tool_manager.cpp.

References ACTION_MANAGER::FindAction(), Format(), m_actionMgr, and RunAction().

279 {
280  TOOL_ACTION* action = m_actionMgr->FindAction( aActionName );
281 
282  if( !action )
283  {
284  wxASSERT_MSG( false, wxString::Format( wxT( "Could not find action %s." ), aActionName ) );
285  return false;
286  }
287 
288  RunAction( *action, aNow, aParam );
289 
290  return false;
291 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:498
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
TOOL_ACTION * FindAction(const std::string &aActionName) const
Function FindAction() Finds an action with a given name (if there is one available).
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
Class TOOL_ACTION.
Definition: tool_action.h:46
bool TOOL_MANAGER::RunAction ( const std::string &  aActionName,
bool  aNow = false 
)
inline

Definition at line 132 of file tool_manager.h.

References RunAction().

133  {
134  return RunAction( aActionName, aNow, (void*) NULL );
135  }
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
template<typename T >
void TOOL_MANAGER::RunAction ( const TOOL_ACTION aAction,
bool  aNow = false,
aParam = NULL 
)
inline

Function RunAction() Runs the specified action.

Parameters
aActionis the action to be invoked.
aNowdecides if the action has to be run immediately or after the current coroutine is preemptied.
aParamis an optional parameter that might be used by the invoked action. Its meaning depends on the action.

Definition at line 148 of file tool_manager.h.

References RunAction().

149  {
150  RunAction( aAction, aNow, reinterpret_cast<void*>( aParam ) );
151  }
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void TOOL_MANAGER::RunAction ( const TOOL_ACTION aAction,
bool  aNow,
void *  aParam 
)

Definition at line 294 of file tool_manager.cpp.

References TOOL_ACTION::MakeEvent(), PostEvent(), processEvent(), and TOOL_EVENT::SetParameter().

295 {
296  TOOL_EVENT event = aAction.MakeEvent();
297 
298  // Allow to override the action parameter
299  if( aParam )
300  event.SetParameter( aParam );
301 
302  if( aNow )
303  processEvent( event );
304  else
305  PostEvent( event );
306 }
void SetParameter(T aParam)
Function SetParameter() Sets a non-standard parameter assigned to the event.
Definition: tool_event.h:385
Class TOOL_EVENT.
Definition: tool_event.h:162
TOOL_EVENT MakeEvent() const
Function HasHotKey() Checks if the action has a hot key assigned.
Definition: tool_action.h:104
void processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:229
void TOOL_MANAGER::RunAction ( const TOOL_ACTION aAction,
bool  aNow = false 
)
inline

Definition at line 155 of file tool_manager.h.

References RunAction().

156  {
157  RunAction( aAction, aNow, (void*) NULL );
158  }
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void TOOL_MANAGER::RunMainStack ( TOOL_BASE aTool,
std::function< void()>  aFunc 
)

Definition at line 479 of file tool_manager.cpp.

References TOOL_MANAGER::TOOL_STATE::cofunc, m_toolState, and COROUTINE< ReturnType, ArgType >::RunMainStack().

Referenced by TOOL_INTERACTIVE::RunMainStack().

480 {
481  TOOL_STATE* st = m_toolState[aTool];
482  st->cofunc->RunMainStack( std::move( aFunc ) );
483 }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:483
bool TOOL_MANAGER::runTool ( TOOL_ID  aToolId)
private

Function runTool() Makes a tool active, so it can receive events and react to them.

Activated tool is pushed on the active tools stack, so the last activated tool receives events first.

Parameters
aToolIdis the ID number of tool to be run.

Definition at line 332 of file tool_manager.cpp.

References FindTool(), TOOL_BASE::GetType(), and INTERACTIVE.

Referenced by dispatchActivation(), and runTool().

333 {
334  TOOL_BASE* tool = FindTool( aToolId );
335 
336  if( tool && tool->GetType() == INTERACTIVE )
337  return runTool( tool );
338 
339  return false; // there is no tool with the given id
340 }
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
bool runTool(TOOL_ID aToolId)
Function runTool() Makes a tool active, so it can receive events and react to them.
Tool that interacts with the user
Definition: tool_base.h:50
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:111
Class TOOL_BASE.
Definition: tool_base.h:68
bool TOOL_MANAGER::runTool ( const std::string &  aName)
private

Function runTool() Makes a tool active, so it can receive events and react to them.

Activated tool is pushed on the active tools stack, so the last activated tool receives events first.

Parameters
aNameis the name of tool to be run.

Definition at line 343 of file tool_manager.cpp.

References FindTool(), TOOL_BASE::GetType(), INTERACTIVE, and runTool().

344 {
345  TOOL_BASE* tool = FindTool( aToolName );
346 
347  if( tool && tool->GetType() == INTERACTIVE )
348  return runTool( tool );
349 
350  return false; // there is no tool with the given name
351 }
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
bool runTool(TOOL_ID aToolId)
Function runTool() Makes a tool active, so it can receive events and react to them.
Tool that interacts with the user
Definition: tool_base.h:50
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:111
Class TOOL_BASE.
Definition: tool_base.h:68
bool TOOL_MANAGER::runTool ( TOOL_BASE aTool)
private

Function runTool() Makes a tool active, so it can receive events and react to them.

Activated tool is pushed on the active tools stack, so the last activated tool receives events first.

Parameters
aToolis the tool to be run.

Definition at line 354 of file tool_manager.cpp.

References TOOL_BASE::GetId(), isActive(), isRegistered(), m_activeTools, TOOL_BASE::Reset(), TOOL_BASE::RUN, and TOOL_BASE::SetTransitions().

355 {
356  wxASSERT( aTool != NULL );
357 
358  if( !isRegistered( aTool ) )
359  {
360  wxASSERT_MSG( false, wxT( "You cannot run unregistered tools" ) );
361  return false;
362  }
363 
364  TOOL_ID id = aTool->GetId();
365 
366  // If the tool is already active, bring it to the top of the active tools stack
367  if( isActive( aTool ) )
368  {
369  m_activeTools.erase( std::find( m_activeTools.begin(), m_activeTools.end(), id ) );
370  m_activeTools.push_front( id );
371  return false;
372  }
373 
374  aTool->Reset( TOOL_INTERACTIVE::RUN );
375  aTool->SetTransitions();
376 
377  // Add the tool on the front of the processing queue (it gets events first)
378  m_activeTools.push_front( id );
379 
380  return true;
381 }
Tool is invoked after being inactive.
Definition: tool_base.h:82
virtual void Reset(RESET_REASON aReason)=0
Function Reset() Brings the tool to a known, initial state.
int TOOL_ID
Unique identifier for tools.
Definition: tool_base.h:57
TOOL_ID GetId() const
Function GetId() Returns the unique identifier of the tool.
Definition: tool_base.h:122
bool isActive(TOOL_BASE *aTool)
Function isActive() Returns information about a tool activation status.
bool isRegistered(TOOL_BASE *aTool) const
Function isRegistered() Returns information about a tool registration status.
Definition: tool_manager.h:440
virtual void SetTransitions()
Function SetTransitions() This method is meant to be overridden in order to specify handlers for even...
Definition: tool_base.h:154
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:495
bool TOOL_MANAGER::SaveClipboard ( const std::string &  aText)

Stores an information to the system clipboard.

Parameters
aTextis the information to be stored.
Returns
False if error occured.

Definition at line 739 of file tool_manager.cpp.

Referenced by MODULE_EDITOR_TOOLS::CopyItems().

740 {
741  if( wxTheClipboard->Open() )
742  {
743  wxTheClipboard->SetData( new wxTextDataObject( wxString( aText.c_str(), wxConvUTF8 ) ) );
744  wxTheClipboard->Close();
745 
746  return true;
747  }
748 
749  return false;
750 }
void TOOL_MANAGER::saveViewControls ( TOOL_STATE aState)
private

Function saveViewControls() Saves the VIEW_CONTROLS settings to the tool state object.

If VIEW_CONTROLS settings are affected by TOOL_MANAGER, the original settings are saved.

Definition at line 803 of file tool_manager.cpp.

References KIGFX::VIEW_CONTROLS::GetSettings(), KIGFX::VC_SETTINGS::m_forceCursorPosition, KIGFX::VC_SETTINGS::m_forcedPosition, m_menuActive, m_origCursor, m_viewControls, and TOOL_MANAGER::TOOL_STATE::vcSettings.

Referenced by dispatchInternal().

804 {
805  aState->vcSettings = m_viewControls->GetSettings();
806 
807  // If context menu has overridden the cursor position, restore the original position
808  // (see dispatchContextMenu())
809  if( m_menuActive )
810  {
811  if( m_origCursor )
812  {
813  aState->vcSettings.m_forceCursorPosition = true;
814  aState->vcSettings.m_forcedPosition = *m_origCursor;
815  }
816  else
817  {
818  aState->vcSettings.m_forceCursorPosition = false;
819  }
820  }
821 }
bool m_menuActive
Flag indicating whether a context menu is currently displayed.
Definition: tool_manager.h:518
bool m_forceCursorPosition
Is the forced cursor position enabled
Definition: view_controls.h:61
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:505
const VC_SETTINGS & GetSettings() const
Returns the current VIEW_CONTROLS settings
boost::optional< VECTOR2D > m_origCursor
Original cursor position, if overridden by the context menu handler.
Definition: tool_manager.h:501
void TOOL_MANAGER::ScheduleContextMenu ( TOOL_BASE aTool,
CONTEXT_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger 
)

Sets behaviour of the tool's context popup menu.

Parameters
aTool- the parent tool
aMenu- the menu structure, defined by the tool
aTrigger- when the menu is activated: CMENU_NOW: opens the menu right now CMENU_BUTTON: opens the menu when RMB is pressed CMENU_OFF: menu is disabled. May be called from a coroutine context.

Definition at line 729 of file tool_manager.cpp.

References TOOL_MANAGER::TOOL_STATE::contextMenu, TOOL_MANAGER::TOOL_STATE::contextMenuTrigger, and m_toolState.

Referenced by TOOL_INTERACTIVE::SetContextMenu().

731 {
732  TOOL_STATE* st = m_toolState[aTool];
733 
734  st->contextMenu = aMenu;
735  st->contextMenuTrigger = aTrigger;
736 }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:483
void TOOL_MANAGER::ScheduleNextState ( TOOL_BASE aTool,
TOOL_STATE_FUNC aHandler,
const TOOL_EVENT_LIST aConditions 
)

Defines a state transition - the events that cause a given handler method in the tool to be called.

Called by TOOL_INTERACTIVE::Go(). May be called from a coroutine context.

Definition at line 470 of file tool_manager.cpp.

References m_toolState, and TOOL_MANAGER::TOOL_STATE::transitions.

Referenced by TOOL_INTERACTIVE::goInternal().

472 {
473  TOOL_STATE* st = m_toolState[aTool];
474 
475  st->transitions.push_back( TRANSITION( aConditions, aHandler ) );
476 }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:483
std::pair< TOOL_EVENT_LIST, TOOL_STATE_FUNC > TRANSITION
Definition: tool_manager.h:355
optional< TOOL_EVENT > TOOL_MANAGER::ScheduleWait ( TOOL_BASE aTool,
const TOOL_EVENT_LIST aConditions 
)

Pauses execution of a given tool until one or more events matching aConditions arrives.

The pause/resume operation is done through COROUTINE object. Called only from coroutines.

Definition at line 486 of file tool_manager.cpp.

References TOOL_MANAGER::TOOL_STATE::cofunc, COROUTINE< ReturnType, ArgType >::KiYield(), m_toolState, TOOL_MANAGER::TOOL_STATE::pendingWait, TOOL_MANAGER::TOOL_STATE::waitEvents, and TOOL_MANAGER::TOOL_STATE::wakeupEvent.

Referenced by TOOL_INTERACTIVE::Wait().

488 {
489  TOOL_STATE* st = m_toolState[aTool];
490 
491  assert( !st->pendingWait ); // everything collapses on two KiYield() in a row
492 
493  // indicate to the manager that we are going to sleep and we shall be
494  // woken up when an event matching aConditions arrive
495  st->pendingWait = true;
496  st->waitEvents = aConditions;
497 
498  // switch context back to event dispatcher loop
499  st->cofunc->KiYield();
500 
501  return st->wakeupEvent;
502 }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:483
void TOOL_MANAGER::SetEnvironment ( EDA_ITEM aModel,
KIGFX::VIEW aView,
KIGFX::VIEW_CONTROLS aViewControls,
wxWindow *  aFrame 
)

Sets the work environment (model, view, view controls and the parent window).

These are made available to the tool. Called by the parent frame (PCB_EDIT_FRAME) when the board is set up.

Definition at line 782 of file tool_manager.cpp.

References m_actionMgr, m_editFrame, m_model, m_view, m_viewControls, and ACTION_MANAGER::UpdateHotKeys().

Referenced by EVT_TOOL(), PCB_BASE_EDIT_FRAME::SetBoard(), PCB_EDIT_FRAME::setupTools(), FOOTPRINT_EDIT_FRAME::setupTools(), and PCB_BASE_FRAME::UseGalCanvas().

784 {
785  m_model = aModel;
786  m_view = aView;
787  m_viewControls = aViewControls;
788  m_editFrame = aFrame;
790 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:498
void UpdateHotKeys()
Function UpdateHotKeys() Updates TOOL_ACTIONs hot key assignment according to the current frame's Hot...
EDA_ITEM * m_model
Definition: tool_manager.h:503
wxWindow * m_editFrame
Definition: tool_manager.h:506
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:505
KIGFX::VIEW * m_view
Definition: tool_manager.h:504
void TOOL_MANAGER::UnregisterAction ( TOOL_ACTION aAction)

Function UnregisterAction() Unregisters an action, so it is no longer active.

Parameters
aActionis the action to be unregistered.

Definition at line 272 of file tool_manager.cpp.

References m_actionMgr, and ACTION_MANAGER::UnregisterAction().

273 {
274  m_actionMgr->UnregisterAction( aAction );
275 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:498
void UnregisterAction(TOOL_ACTION *aAction)
Function UnregisterAction() Removes a tool action from the manager and makes it unavailable for furth...
void TOOL_MANAGER::UpdateHotKeys ( )

>

Function UpdateHotKeys() Updates TOOL_ACTIONs hot key assignment according to the current frame's Hot Key Editor settings.

Definition at line 315 of file tool_manager.cpp.

References m_actionMgr, and ACTION_MANAGER::UpdateHotKeys().

Referenced by EDA_DRAW_FRAME::WriteHotkeyConfig().

316 {
318 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:498
void UpdateHotKeys()
Function UpdateHotKeys() Updates TOOL_ACTIONs hot key assignment according to the current frame's Hot...

Member Data Documentation

ACTION_MANAGER* TOOL_MANAGER::m_actionMgr
private
ID_LIST TOOL_MANAGER::m_activeTools
private

Stack of the active tools.

Definition at line 495 of file tool_manager.h.

Referenced by dispatchContextMenu(), dispatchInternal(), finishTool(), GetCurrentToolId(), GetPriority(), isActive(), and runTool().

wxWindow* TOOL_MANAGER::m_editFrame
private

Definition at line 506 of file tool_manager.h.

Referenced by GetEditFrame(), and SetEnvironment().

std::list<TOOL_EVENT> TOOL_MANAGER::m_eventQueue
private

Queue that stores events to be processed at the end of the event processing cycle.

Definition at line 509 of file tool_manager.h.

Referenced by PostEvent(), and processEvent().

bool TOOL_MANAGER::m_menuActive
private

Flag indicating whether a context menu is currently displayed.

Definition at line 518 of file tool_manager.h.

Referenced by dispatchContextMenu(), and saveViewControls().

EDA_ITEM* TOOL_MANAGER::m_model
private

Definition at line 503 of file tool_manager.h.

Referenced by GetModel(), and SetEnvironment().

boost::optional<VECTOR2D> TOOL_MANAGER::m_origCursor
private

Original cursor position, if overridden by the context menu handler.

Definition at line 501 of file tool_manager.h.

Referenced by dispatchContextMenu(), and saveViewControls().

bool TOOL_MANAGER::m_passEvent
private

Flag saying if the currently processed event should be passed to other tools.

Definition at line 515 of file tool_manager.h.

Referenced by dispatchInternal(), and PassEvent().

ID_STATE_MAP TOOL_MANAGER::m_toolIdIndex
private

Index of the registered tools current states, associated by tools' ID numbers.

Definition at line 489 of file tool_manager.h.

Referenced by dispatchContextMenu(), dispatchInternal(), FindTool(), GetCurrentToolState(), InitTools(), and RegisterTool().

NAME_STATE_MAP TOOL_MANAGER::m_toolNameIndex
private

Index of the registered tools current states, associated by tools' names.

Definition at line 486 of file tool_manager.h.

Referenced by dispatchActivation(), FindTool(), InitTools(), and RegisterTool().

TOOL_STATE_MAP TOOL_MANAGER::m_toolState
private

Index of registered tools current states, associated by tools' objects.

Definition at line 483 of file tool_manager.h.

Referenced by dispatchInternal(), InitTools(), isRegistered(), RegisterTool(), ResetTools(), RunMainStack(), ScheduleContextMenu(), ScheduleNextState(), ScheduleWait(), and ~TOOL_MANAGER().

std::map<const char*, TOOL_BASE*> TOOL_MANAGER::m_toolTypes
private

Index of the registered tools to easily lookup by their type.

Definition at line 492 of file tool_manager.h.

Referenced by GetTool(), InitTools(), and RegisterTool().

std::stack<KIGFX::VC_SETTINGS> TOOL_MANAGER::m_vcStack
private

VIEW_CONTROLS settings stack

Definition at line 512 of file tool_manager.h.

Referenced by popViewControls(), pushViewControls(), and TOOL_MANAGER().

KIGFX::VIEW* TOOL_MANAGER::m_view
private

Definition at line 504 of file tool_manager.h.

Referenced by GetView(), ProcessEvent(), and SetEnvironment().


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