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...
 
bool IsToolActive (TOOL_ID aId) const
 Function IsToolActive() Returns true if a tool with given id is active (executing) 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...
 
bool 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, EDA_DRAW_FRAME *aFrame)
 Sets the work environment (model, view, view controls and the parent window). More...
 
KIGFX::VIEWGetView () const
 
KIGFX::VIEW_CONTROLSGetViewControls () const
 
EDA_ITEMGetModel () const
 
EDA_DRAW_FRAMEGetEditFrame () 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 ClearTransitions (TOOL_BASE *aTool)
 Clears the state transition map for a tool. More...
 
void RunMainStack (TOOL_BASE *aTool, std::function< void()> aFunc)
 
void UpdateUI ()
 Synchronizes toolbars. More...
 
OPT< 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, ACTION_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...
 
const KIGFX::VC_SETTINGSGetCurrentToolVC () const
 Returns the view controls settings for the current tool or the general settings if there is no active tool. More...
 
void VetoContextMenuMouseWarp ()
 Disables mouse warping after the current context menu is closed. 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...
 
bool processEvent (const TOOL_EVENT &aEvent)
 

Main function for event processing.

More...
 
void setActiveState (TOOL_STATE *aState)
 Saves the previous active state and sets a new one. 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...
 
std::map< TOOL_ID, OPT< VECTOR2D > > m_cursorSettings
 Original cursor position, if overridden by the context menu handler. More...
 
EDA_ITEMm_model
 
KIGFX::VIEWm_view
 
KIGFX::VIEW_CONTROLSm_viewControls
 
EDA_DRAW_FRAMEm_editFrame
 
std::list< TOOL_EVENTm_eventQueue
 Queue that stores events to be processed at the end of the event processing cycle. More...
 
bool m_passEvent
 Flag saying if the currently processed event should be passed to other tools. More...
 
VECTOR2D m_menuCursor
 Right click context menu position. More...
 
bool m_warpMouseAfterContextMenu
 
bool m_menuActive
 Flag indicating whether a context menu is currently displayed. More...
 
TOOL_ID m_menuOwner
 Tool currently displaying a popup menu. It is negative when there is no menu displayed. More...
 
TOOL_STATEm_activeState
 Pointer to the state object corresponding to the currently executed tool. 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

◆ ID_LIST

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

Definition at line 63 of file tool_manager.h.

◆ ID_STATE_MAP

Definition at line 62 of file tool_manager.h.

◆ NAME_STATE_MAP

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

Definition at line 61 of file tool_manager.h.

◆ TOOL_STATE_MAP

Definition at line 60 of file tool_manager.h.

◆ TRANSITION

Definition at line 392 of file tool_manager.h.

Constructor & Destructor Documentation

◆ TOOL_MANAGER()

TOOL_MANAGER::TOOL_MANAGER ( )

Definition at line 194 of file tool_manager.cpp.

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  m_menuOwner( -1 ),
202  m_activeState( nullptr )
203 {
204  m_actionMgr = new ACTION_MANAGER( this );
205 }
bool m_menuActive
Flag indicating whether a context menu is currently displayed.
Definition: tool_manager.h:553
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:531
EDA_DRAW_FRAME * m_editFrame
Definition: tool_manager.h:539
Class ACTION_MANAGER.
bool m_passEvent
Flag saying if the currently processed event should be passed to other tools.
Definition: tool_manager.h:545
EDA_ITEM * m_model
Definition: tool_manager.h:536
TOOL_ID m_menuOwner
Tool currently displaying a popup menu. It is negative when there is no menu displayed.
Definition: tool_manager.h:556
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:538
KIGFX::VIEW * m_view
Definition: tool_manager.h:537
TOOL_STATE * m_activeState
Pointer to the state object corresponding to the currently executed tool.
Definition: tool_manager.h:559

References m_actionMgr.

◆ ~TOOL_MANAGER()

TOOL_MANAGER::~TOOL_MANAGER ( )

Definition at line 208 of file tool_manager.cpp.

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

References m_actionMgr, and m_toolState.

Member Function Documentation

◆ applyViewControls()

void TOOL_MANAGER::applyViewControls ( TOOL_STATE aState)
private

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

Definition at line 924 of file tool_manager.cpp.

925 {
926  m_viewControls->ApplySettings( aState->vcSettings );
927 }
void ApplySettings(const VC_SETTINGS &aSettings)
Applies VIEW_CONTROLS settings from an object
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:538

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

Referenced by setActiveState().

◆ ClearTransitions()

void TOOL_MANAGER::ClearTransitions ( TOOL_BASE aTool)

Clears the state transition map for a tool.

Parameters
aToolis the tool that should have the transition map cleared.

Definition at line 497 of file tool_manager.cpp.

498 {
499  m_toolState[aTool]->transitions.clear();
500 }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:516

References m_toolState.

Referenced by TOOL_INTERACTIVE::resetTransitions().

◆ DeactivateTool()

void TOOL_MANAGER::DeactivateTool ( )

Function DeactivateTool() Deactivates the currently active tool.

Definition at line 418 of file tool_manager.cpp.

419 {
420  // Deactivate the active tool, but do not run anything new
422  processEvent( evt );
423 }
bool processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
Class TOOL_EVENT.
Definition: tool_event.h:167

References processEvent(), TA_CANCEL_TOOL, and TC_COMMAND.

Referenced by LIB_DRAWING_TOOLS::DrawShape(), GERBVIEW_FRAME::OnCloseWindow(), LIB_EDIT_FRAME::OnExportBody(), LIB_EDIT_FRAME::OnImportBody(), ResetTools(), DRC::ShowDRCDialog(), DISPLAY_FOOTPRINTS_FRAME::~DISPLAY_FOOTPRINTS_FRAME(), and FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME().

◆ dispatchActivation()

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 638 of file tool_manager.cpp.

639 {
640  if( aEvent.IsActivate() )
641  {
642  wxString cmdStr( *aEvent.GetCommandStr() );
643 
644  std::map<std::string, TOOL_STATE*>::iterator tool = m_toolNameIndex.find( *aEvent.GetCommandStr() );
645 
646  if( tool != m_toolNameIndex.end() )
647  {
648  runTool( tool->second->theTool );
649  return true;
650  }
651  }
652 
653  return false;
654 }
bool runTool(TOOL_ID aToolId)
Function runTool() Makes a tool active, so it can receive events and react to them.
NAME_STATE_MAP m_toolNameIndex
Index of the registered tools current states, associated by tools' names.
Definition: tool_manager.h:519
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:400
bool IsActivate() const
Definition: tool_event.h:300

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

Referenced by processEvent().

◆ dispatchContextMenu()

void TOOL_MANAGER::dispatchContextMenu ( const TOOL_EVENT aEvent)
private

Function dispatchContextMenu() Handles context menu related events.

Definition at line 656 of file tool_manager.cpp.

657 {
658  for( TOOL_ID toolId : m_activeTools )
659  {
660  TOOL_STATE* st = m_toolIdIndex[toolId];
661 
662  // the tool requested a context menu. The menu is activated on RMB click (CMENU_BUTTON mode)
663  // or immediately (CMENU_NOW) mode. The latter is used for clarification lists.
664  if( st->contextMenuTrigger == CMENU_OFF )
665  continue;
666 
667  if( st->contextMenuTrigger == CMENU_BUTTON && !aEvent.IsClick( BUT_RIGHT ) )
668  break;
669 
670  st->pendingWait = true;
671  st->waitEvents = TOOL_EVENT( TC_ANY, TA_ANY );
672 
673  // Store the menu pointer in case it is changed by the TOOL when handling menu events
674  ACTION_MENU* m = st->contextMenu;
675 
676  if( st->contextMenuTrigger == CMENU_NOW )
677  st->contextMenuTrigger = CMENU_OFF;
678 
679  // Store the cursor position, so the tools could execute actions
680  // using the point where the user has invoked a context menu
682 
683  // Save all tools cursor settings, as they will be overridden
684  for( auto idState : m_toolIdIndex )
685  {
686  TOOL_STATE* s = idState.second;
687  const auto& vc = s->vcSettings;
688 
689  if( vc.m_forceCursorPosition )
690  m_cursorSettings[idState.first] = vc.m_forcedPosition;
691  else
692  m_cursorSettings[idState.first] = NULLOPT;
693  }
694 
696 
697  // Display a copy of menu
698  std::unique_ptr<ACTION_MENU> menu( m->Clone() );
699 
700  m_menuOwner = toolId;
701  m_menuActive = true;
702 
703  auto frame = dynamic_cast<wxFrame*>( m_editFrame );
704 
705  if( frame )
706  frame->PopupMenu( menu.get() );
707 
708  // Warp the cursor if a menu item was selected
709  if( menu->GetSelected() >= 0 && m_warpMouseAfterContextMenu )
710  m_viewControls->WarpCursor( m_menuCursor, true, false );
711  // Otherwise notify the tool of a cancelled menu
712  else
713  {
715  evt.SetParameter( m );
716  dispatchInternal( evt );
717  }
718 
719  // Restore setting in case it was vetoed
721 
722  // Notify the tools that menu has been closed
724  evt.SetParameter( m );
725  dispatchInternal( evt );
726 
727  m_menuActive = false;
728  m_menuOwner = -1;
729 
730  // Restore cursor settings
731  for( auto cursorSetting : m_cursorSettings )
732  {
733  auto it = m_toolIdIndex.find( cursorSetting.first );
734  wxASSERT( it != m_toolIdIndex.end() );
735 
736  if( it == m_toolIdIndex.end() )
737  continue;
738 
739  KIGFX::VC_SETTINGS& vc = it->second->vcSettings;
740  vc.m_forceCursorPosition = (bool) cursorSetting.second;
741  vc.m_forcedPosition = cursorSetting.second ? *cursorSetting.second : VECTOR2D( 0, 0 );
742  }
743 
744  m_cursorSettings.clear();
745  break;
746  }
747 }
bool m_menuActive
Flag indicating whether a context menu is currently displayed.
Definition: tool_manager.h:553
VECTOR2D m_menuCursor
Right click context menu position.
Definition: tool_manager.h:548
Class ACTION_MENU.
Definition: action_menu.h:43
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:522
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:165
std::map< TOOL_ID, OPT< VECTOR2D > > m_cursorSettings
Original cursor position, if overridden by the context menu handler.
Definition: tool_manager.h:534
VECTOR2D m_forcedPosition
Forced cursor position (world coordinates)
Definition: view_controls.h:58
EDA_DRAW_FRAME * m_editFrame
Definition: tool_manager.h:539
int TOOL_ID
Unique identifier for tools.
Definition: tool_base.h:57
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
Function WarpCursor() If enabled (.
const auto NULLOPT
Definition: optional.h:9
bool m_forceCursorPosition
Is the forced cursor position enabled
Definition: view_controls.h:61
TOOL_ID m_menuOwner
Tool currently displaying a popup menu. It is negative when there is no menu displayed.
Definition: tool_manager.h:556
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:167
Structure to keep VIEW_CONTROLS settings for easy store/restore operations
Definition: view_controls.h:44
ACTION_MENU * Clone() const
Creates a deep, recursive copy of this ACTION_MENU.
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:538
bool m_warpMouseAfterContextMenu
Definition: tool_manager.h:550
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:528
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.

References BUT_RIGHT, ACTION_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::GetCursorPosition(), TOOL_EVENT::IsClick(), m_activeTools, m_cursorSettings, m_editFrame, KIGFX::VC_SETTINGS::m_forceCursorPosition, KIGFX::VC_SETTINGS::m_forcedPosition, m_menuActive, m_menuCursor, m_menuOwner, m_toolIdIndex, m_viewControls, m_warpMouseAfterContextMenu, NULLOPT, TOOL_MANAGER::TOOL_STATE::pendingWait, TOOL_EVENT::SetParameter(), TA_ANY, TA_CONTEXT_MENU_CHOICE, TA_CONTEXT_MENU_CLOSED, TC_ANY, TC_COMMAND, TOOL_MANAGER::TOOL_STATE::vcSettings, TOOL_MANAGER::TOOL_STATE::waitEvents, and KIGFX::VIEW_CONTROLS::WarpCursor().

Referenced by processEvent().

◆ dispatchInternal()

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 529 of file tool_manager.cpp.

530 {
531  // iterate over all registered tools
532  for( auto it = m_activeTools.begin(); it != m_activeTools.end(); ++it )
533  {
534  TOOL_STATE* st = m_toolIdIndex[*it];
535 
536  // forward context menu events to the tool that created the menu
537  if( aEvent.IsMenu() )
538  {
539  if( *it != m_menuOwner )
540  continue;
541  }
542 
543  // the tool state handler is waiting for events (i.e. called Wait() method)
544  if( st->pendingWait )
545  {
546  if( st->waitEvents.Matches( aEvent ) )
547  {
548  // By default only messages are passed further
549  m_passEvent = ( aEvent.Category() == TC_MESSAGE );
550 
551  // got matching event? clear wait list and wake up the coroutine
552  st->wakeupEvent = aEvent;
553  st->pendingWait = false;
554  st->waitEvents.clear();
555 
556  if( st->cofunc )
557  {
558  setActiveState( st );
559  bool end = !st->cofunc->Resume();
560 
561  if( end )
562  it = finishTool( st );
563  }
564 
565  // If the tool did not request to propagate
566  // the event to other tools, we should stop it now
567  if( !m_passEvent )
568  break;
569  }
570  }
571  }
572 
573  for( auto& state : m_toolState )
574  {
575  TOOL_STATE* st = state.second;
576  bool finished = false;
577 
578  // no state handler in progress - check if there are any transitions (defined by
579  // Go() method that match the event.
580  if( !st->transitions.empty() )
581  {
582  for( TRANSITION& tr : st->transitions )
583  {
584  if( tr.first.Matches( aEvent ) )
585  {
586  auto func_copy = tr.second;
587 
588  // if there is already a context, then push it on the stack
589  // and transfer the previous view control settings to the new context
590  if( st->cofunc )
591  {
592  auto vc = st->vcSettings;
593  st->Push();
594  st->vcSettings = vc;
595  }
596 
597  st->cofunc = new COROUTINE<int, const TOOL_EVENT&>( std::move( func_copy ) );
598 
599  // as the state changes, the transition table has to be set up again
600  st->transitions.clear();
601 
602  // got match? Run the handler.
603  setActiveState( st );
604  st->idle = false;
605  st->cofunc->Call( aEvent );
606 
607  if( !st->cofunc->Running() )
608  finishTool( st ); // The couroutine has finished immediately?
609 
610  // if it is a message, continue processing
611  finished = !( aEvent.Category() == TC_MESSAGE );
612 
613  // there is no point in further checking, as transitions got cleared
614  break;
615  }
616  }
617  }
618 
619  if( finished )
620  break; // only the first tool gets the event
621  }
622 }
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:522
ID_LIST::iterator finishTool(TOOL_STATE *aState)
Function finishTool() Deactivates a tool and does the necessary clean up.
TOOL_EVENT_CATEGORY Category() const
Returns the category (eg. mouse/keyboard/action) of an event..
Definition: tool_event.h:233
bool m_passEvent
Flag saying if the currently processed event should be passed to other tools.
Definition: tool_manager.h:545
TOOL_ID m_menuOwner
Tool currently displaying a popup menu. It is negative when there is no menu displayed.
Definition: tool_manager.h:556
void setActiveState(TOOL_STATE *aState)
Saves the previous active state and sets a new one.
bool IsMenu() const
Definition: tool_event.h:310
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:528
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:516
std::pair< TOOL_EVENT_LIST, TOOL_STATE_FUNC > TRANSITION
Definition: tool_manager.h:392

References COROUTINE< ReturnType, ArgType >::Call(), TOOL_EVENT::Category(), TOOL_EVENT_LIST::clear(), TOOL_MANAGER::TOOL_STATE::cofunc, finishTool(), TOOL_MANAGER::TOOL_STATE::idle, TOOL_EVENT::IsMenu(), m_activeTools, m_menuOwner, m_passEvent, m_toolIdIndex, m_toolState, TOOL_EVENT_LIST::Matches(), TOOL_MANAGER::TOOL_STATE::pendingWait, TOOL_MANAGER::TOOL_STATE::Push(), COROUTINE< ReturnType, ArgType >::Resume(), COROUTINE< ReturnType, ArgType >::Running(), setActiveState(), TC_MESSAGE, TOOL_MANAGER::TOOL_STATE::transitions, TOOL_MANAGER::TOOL_STATE::vcSettings, TOOL_MANAGER::TOOL_STATE::waitEvents, and TOOL_MANAGER::TOOL_STATE::wakeupEvent.

Referenced by dispatchContextMenu(), and processEvent().

◆ dispatchStandardEvents()

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 625 of file tool_manager.cpp.

626 {
627  if( aEvent.Action() == TA_KEY_PRESSED )
628  {
629  // Check if there is a hotkey associated
630  if( m_actionMgr->RunHotKey( aEvent.Modifier() | aEvent.KeyCode() ) )
631  return false; // hotkey event was handled so it does not go any further
632  }
633 
634  return true;
635 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:531
TOOL_ACTIONS Action() const
Returns more specific information about the type of an event.
Definition: tool_event.h:239
bool RunHotKey(int aHotKey) const
Function RunHotKey() Runs an action associated with a hotkey (if there is one available).
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:316
int KeyCode() const
Definition: tool_event.h:321

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

Referenced by processEvent().

◆ FindTool() [1/2]

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 396 of file tool_manager.cpp.

397 {
398  std::map<TOOL_ID, TOOL_STATE*>::const_iterator it = m_toolIdIndex.find( aId );
399 
400  if( it != m_toolIdIndex.end() )
401  return it->second->theTool;
402 
403  return NULL;
404 }
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:522

References m_toolIdIndex.

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

◆ FindTool() [2/2]

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 407 of file tool_manager.cpp.

408 {
409  std::map<std::string, TOOL_STATE*>::const_iterator it = m_toolNameIndex.find( aName );
410 
411  if( it != m_toolNameIndex.end() )
412  return it->second->theTool;
413 
414  return NULL;
415 }
NAME_STATE_MAP m_toolNameIndex
Index of the registered tools current states, associated by tools' names.
Definition: tool_manager.h:519

References m_toolNameIndex.

◆ finishTool()

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 750 of file tool_manager.cpp.

751 {
752  auto it = std::find( m_activeTools.begin(), m_activeTools.end(), aState->theTool->GetId() );
753 
754  if( !aState->Pop() )
755  {
756  // Deactivate the tool if there are no other contexts saved on the stack
757  if( it != m_activeTools.end() )
758  it = m_activeTools.erase( it );
759 
760  aState->idle = true;
761  }
762 
763  if( aState == m_activeState )
764  setActiveState( nullptr );
765 
766  // Set transitions to be ready for future TOOL_EVENTs
767  TOOL_BASE* tool = aState->theTool;
768 
769  if( tool->GetType() == INTERACTIVE )
770  static_cast<TOOL_INTERACTIVE*>( tool )->resetTransitions();
771 
772  return it;
773 }
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:111
Tool that interacts with the user
Definition: tool_base.h:50
void setActiveState(TOOL_STATE *aState)
Saves the previous active state and sets a new one.
TOOL_STATE * m_activeState
Pointer to the state object corresponding to the currently executed tool.
Definition: tool_manager.h:559
Class TOOL_BASE.
Definition: tool_base.h:68
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:528

References TOOL_BASE::GetId(), TOOL_BASE::GetType(), TOOL_MANAGER::TOOL_STATE::idle, INTERACTIVE, m_activeState, m_activeTools, TOOL_MANAGER::TOOL_STATE::Pop(), setActiveState(), and TOOL_MANAGER::TOOL_STATE::theTool.

Referenced by dispatchInternal().

◆ GetClipboard()

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 825 of file tool_manager.cpp.

826 {
827  std::string result;
828 
829  if( wxTheClipboard->Open() )
830  {
831  if( wxTheClipboard->IsSupported( wxDF_TEXT ) )
832  {
833  wxTextDataObject data;
834  wxTheClipboard->GetData( data );
835 
836  result = data.GetText().mb_str();
837  }
838 
839  wxTheClipboard->Close();
840  }
841 
842  return result;
843 }

Referenced by LIB_EDIT_TOOL::Paste(), and SCH_EDITOR_CONTROL::Paste().

◆ GetCurrentTool()

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 287 of file tool_manager.h.

288  {
289  return FindTool( GetCurrentToolId() );
290  }
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:277

References FindTool(), and GetCurrentToolId().

◆ GetCurrentToolId()

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 277 of file tool_manager.h.

278  {
279  return m_activeTools.empty() ? -1 : m_activeTools.front();
280  }
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:528

References m_activeTools.

Referenced by GetCurrentTool(), and GetCurrentToolState().

◆ GetCurrentToolState()

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 296 of file tool_manager.h.

297  {
298  auto it = m_toolIdIndex.find( GetCurrentToolId() );
299  return ( it != m_toolIdIndex.end() ) ? it->second : nullptr;
300  }
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:522
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:277

References GetCurrentToolId(), and m_toolIdIndex.

Referenced by GetCurrentToolVC(), invokeTool(), and ProcessEvent().

◆ GetCurrentToolVC()

const KIGFX::VC_SETTINGS & TOOL_MANAGER::GetCurrentToolVC ( ) const

Returns the view controls settings for the current tool or the general settings if there is no active tool.

Definition at line 846 of file tool_manager.cpp.

847 {
848  if( TOOL_STATE* active = GetCurrentToolState() )
849  return active->vcSettings;
850 
851  return m_viewControls->GetSettings();
852 }
const VC_SETTINGS & GetSettings() const
Returns the current VIEW_CONTROLS settings
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:538
TOOL_STATE * GetCurrentToolState() const
Returns the TOOL_STATE object representing the state of the active tool.
Definition: tool_manager.h:296

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

Referenced by CVPCB_CONTROL::ResetCoords(), and PCBNEW_CONTROL::ResetCoords().

◆ GetEditFrame()

◆ GetHotKey()

int TOOL_MANAGER::GetHotKey ( const TOOL_ACTION aAction)

Definition at line 315 of file tool_manager.cpp.

316 {
317  return m_actionMgr->GetHotKey( aAction );
318 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:531
int GetHotKey(const TOOL_ACTION &aAction) const
Function GetHotKey() Returns the hot key associated with a given action or 0 if there is none.

References ACTION_MANAGER::GetHotKey(), and m_actionMgr.

Referenced by ACTION_MENU::updateHotKeys().

◆ GetModel()

EDA_ITEM* TOOL_MANAGER::GetModel ( ) const
inline

Definition at line 262 of file tool_manager.h.

263  {
264  return m_model;
265  }
EDA_ITEM * m_model
Definition: tool_manager.h:536

References m_model.

Referenced by PCB_EDITOR_CONTROL::ClearHighlight(), TOOL_BASE::getModelInt(), highlightNet(), and DIALOG_POSITION_RELATIVE::OnUseGridOriginClick().

◆ GetPriority()

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 472 of file tool_manager.cpp.

473 {
474  int priority = 0;
475 
476  for( auto it = m_activeTools.begin(), itEnd = m_activeTools.end(); it != itEnd; ++it )
477  {
478  if( *it == aToolId )
479  return priority;
480 
481  ++priority;
482  }
483 
484  return -1;
485 }
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:528

References m_activeTools.

Referenced by ACTION_MANAGER::RunHotKey().

◆ GetTool()

template<typename T >
T* TOOL_MANAGER::GetTool ( )
inline

Definition at line 189 of file tool_manager.h.

190  {
191  std::map<const char*, TOOL_BASE*>::iterator tool = m_toolTypes.find( typeid( T ).name() );
192 
193  if( tool != m_toolTypes.end() )
194  return static_cast<T*>( tool->second );
195 
196  return NULL;
197  }
const char * name
Definition: DXF_plotter.cpp:61
std::map< const char *, TOOL_BASE * > m_toolTypes
Index of the registered tools to easily lookup by their type.
Definition: tool_manager.h:525

References m_toolTypes, and name.

Referenced by PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), deleteItem(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), LIB_DRAWING_TOOLS::doTwoClickPlace(), PCB_EDITOR_CONTROL::DrillOrigin(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), SCH_EDITOR_CONTROL::EnterSheet(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), DRAWING_TOOL::getSourceZoneForAction(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), LIB_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PAD_TOOL::Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), LIB_EDIT_FRAME::LoadOneSymbol(), LIB_MOVE_TOOL::Main(), PCB_EDITOR_CONTROL::modifyLockSelected(), SCH_EDIT_FRAME::OnHotKey(), LIB_EDIT_FRAME::OnHotKey(), PCB_EDIT_FRAME::OnNetlistChanged(), DIALOG_POSITION_RELATIVE::OnOkClick(), DIALOG_POSITION_RELATIVE::OnSelectItemClick(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), DRAWING_TOOL::PlaceText(), LIB_EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), SCH_EDIT_FRAME::PutDataInPreviousState(), LIB_VIEW_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), LIB_EDIT_FRAME::ReCreateMenuBar(), SCH_EDIT_FRAME::ReCreateMenuBar(), PCB_EDIT_FRAME::ReCreateMenuBar(), LIB_DRAWING_TOOLS::RepeatDrawItem(), LIB_EDIT_FRAME::RollbackPartFromUndo(), PCB_TOOL_BASE::selection(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), FOOTPRINT_EDIT_FRAME::setupTools(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), showLocalRatsnest(), BUS_UNFOLD_MENU::update(), PAD_CONTEXT_MENU::update(), SYMBOL_UNIT_MENU::update(), EE_INSPECTION_TOOL::UpdateMessagePanel(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ GetView()

◆ GetViewControls()

KIGFX::VIEW_CONTROLS* TOOL_MANAGER::GetViewControls ( ) const
inline

Definition at line 257 of file tool_manager.h.

258  {
259  return m_viewControls;
260  }
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:538

References m_viewControls.

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

◆ InitTools()

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 442 of file tool_manager.cpp.

443 {
444  for( auto it = m_toolState.begin(); it != m_toolState.end(); /* iteration in the loop */ )
445  {
446  TOOL_BASE* tool = it->first;
447  TOOL_STATE* state = it->second;
448  setActiveState( state );
449  ++it; // keep the iterator valid if the element is going to be erased
450 
451  if( !tool->Init() )
452  {
453  wxMessageBox(
454  wxString::Format( "Initialization of tool \"%s\" failed", tool->GetName() ) );
455 
456  // Unregister the tool
457  setActiveState( nullptr );
458  m_toolState.erase( tool );
459  m_toolNameIndex.erase( tool->GetName() );
460  m_toolIdIndex.erase( tool->GetId() );
461  m_toolTypes.erase( typeid( *tool ).name() );
462 
463  delete state;
464  delete tool;
465  }
466  }
467 
469 }
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:522
TOOL_ID GetId() const
Function GetId() Returns the unique identifier of the tool.
Definition: tool_base.h:122
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:519
void setActiveState(TOOL_STATE *aState)
Saves the previous active state and sets a new one.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
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:516
std::map< const char *, TOOL_BASE * > m_toolTypes
Index of the registered tools to easily lookup by their type.
Definition: tool_manager.h:525

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

Referenced by FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), FOOTPRINT_EDIT_FRAME::setupTools(), LIB_VIEW_FRAME::setupTools(), GERBVIEW_FRAME::setupTools(), LIB_EDIT_FRAME::setupTools(), and SCH_EDIT_FRAME::setupTools().

◆ InvokeTool() [1/2]

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 243 of file tool_manager.cpp.

244 {
245  TOOL_BASE* tool = FindTool( aToolId );
246 
247  if( tool && tool->GetType() == INTERACTIVE )
248  return invokeTool( tool );
249 
250  return false; // there is no tool with the given id
251 }
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:111
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
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,...

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

Referenced by TOOL_INTERACTIVE::Activate(), SELECTION_TOOL::findMove(), FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), FOOTPRINT_EDIT_FRAME::setupTools(), GERBVIEW_FRAME::setupTools(), LIB_EDIT_FRAME::setupTools(), SCH_EDIT_FRAME::setupTools(), DIALOG_NETLIST::~DIALOG_NETLIST(), and DIALOG_UPDATE_PCB::~DIALOG_UPDATE_PCB().

◆ InvokeTool() [2/2]

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 254 of file tool_manager.cpp.

255 {
256  TOOL_BASE* tool = FindTool( aToolName );
257 
258  if( tool && tool->GetType() == INTERACTIVE )
259  return invokeTool( tool );
260 
261  return false; // there is no tool with the given name
262 }
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:111
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
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,...

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

◆ invokeTool() [1/2]

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 327 of file tool_manager.cpp.

328 {
329  wxASSERT( aTool != NULL );
330 
331  TOOL_EVENT evt( TC_COMMAND, TA_ACTIVATE, aTool->GetName() );
332  processEvent( evt );
333 
334  if( TOOL_STATE* active = GetCurrentToolState() )
335  setActiveState( active );
336 
337  return true;
338 }
bool processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
void setActiveState(TOOL_STATE *aState)
Saves the previous active state and sets a new one.
Class TOOL_EVENT.
Definition: tool_event.h:167
TOOL_STATE * GetCurrentToolState() const
Returns the TOOL_STATE object representing the state of the active tool.
Definition: tool_manager.h:296
const std::string & GetName() const
Function GetName() Returns the name of the tool.
Definition: tool_base.h:133

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

Referenced by InvokeTool().

◆ invokeTool() [2/2]

template<class Parameters >
void TOOL_MANAGER::invokeTool ( const std::string &  aName,
const Parameters &  aToolParams 
)
private

◆ isActive()

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 874 of file tool_manager.cpp.

875 {
876  if( !isRegistered( aTool ) )
877  return false;
878 
879  // Just check if the tool is on the active tools stack
880  return std::find( m_activeTools.begin(), m_activeTools.end(), aTool->GetId() ) != m_activeTools.end();
881 }
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:477
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:528

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

Referenced by runTool().

◆ isRegistered()

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 477 of file tool_manager.h.

478  {
479  return m_toolState.count( aTool ) > 0;
480  }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:516

References m_toolState.

Referenced by isActive(), and runTool().

◆ IsToolActive()

bool TOOL_MANAGER::IsToolActive ( TOOL_ID  aId) const

Function IsToolActive() Returns true if a tool with given id is active (executing)

Definition at line 964 of file tool_manager.cpp.

965 {
966  auto it = m_toolIdIndex.find( aId );
967  return !it->second->idle;
968 }
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:522

References m_toolIdIndex.

Referenced by TOOL_BASE::IsToolActive().

◆ MakeToolId()

TOOL_ID TOOL_MANAGER::MakeToolId ( const std::string &  aToolName)
static

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

Definition at line 855 of file tool_manager.cpp.

856 {
857  static int currentId;
858 
859  return currentId++;
860 }

◆ PassEvent()

void TOOL_MANAGER::PassEvent ( )
inline

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

Definition at line 356 of file tool_manager.h.

357  {
358  m_passEvent = true;
359  }
bool m_passEvent
Flag saying if the currently processed event should be passed to other tools.
Definition: tool_manager.h:545

References m_passEvent.

Referenced by ZOOM_TOOL::Main(), EE_POINT_EDITOR::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), and POINT_EDITOR::OnSelectionChange().

◆ PostEvent()

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 238 of file tool_manager.h.

239  {
240  m_eventQueue.push_back( aEvent );
241  }
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:542

References m_eventQueue.

Referenced by SCH_EDIT_FRAME::AddJunction(), SCH_WIRE_BUS_TOOL::finishSegments(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), EDIT_TOOL::Main(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), and RunAction().

◆ ProcessEvent()

bool 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.
Returns
true if the event is a managed hotkey

Definition at line 776 of file tool_manager.cpp.

777 {
778  bool hotkey_handled = processEvent( aEvent );
779 
780  if( TOOL_STATE* active = GetCurrentToolState() )
781  setActiveState( active );
782 
783  if( m_view->IsDirty() )
784  {
785  auto f = dynamic_cast<EDA_DRAW_FRAME*>( GetEditFrame() );
786 
787  if( f )
788  f->GetGalCanvas()->Refresh(); // fixme: ugly hack, provide a method in TOOL_DISPATCHER.
789 
790 #if defined( __WXMAC__ ) || defined( __WINDOWS__ )
791  wxTheApp->ProcessPendingEvents(); // required for updating brightening behind a popup menu
792 #endif
793  }
794 
795  UpdateUI();
796 
797  return hotkey_handled;
798 }
bool processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
void UpdateUI()
Synchronizes toolbars.
EDA_DRAW_FRAME * GetEditFrame() const
Definition: tool_manager.h:267
void setActiveState(TOOL_STATE *aState)
Saves the previous active state and sets a new one.
TOOL_STATE * GetCurrentToolState() const
Returns the TOOL_STATE object representing the state of the active tool.
Definition: tool_manager.h:296
KIGFX::VIEW * m_view
Definition: tool_manager.h:537
bool IsDirty() const
Function IsDirty() Returns true if any of the VIEW layers needs to be refreshened.
Definition: view.h:568

References GetCurrentToolState(), GetEditFrame(), KIGFX::VIEW::IsDirty(), m_view, processEvent(), setActiveState(), and UpdateUI().

Referenced by EE_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemToSel(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), COMMON_TOOLS::CursorControl(), TOOL_DISPATCHER::DispatchWxCommand(), TOOL_DISPATCHER::DispatchWxEvent(), SELECTION_TOOL::expandConnection(), SELECTION_TOOL::findCallback(), EDIT_TOOL::Flip(), TOOL_DISPATCHER::handleMouseButton(), EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), ACTION_MENU::onMenuEvent(), ACTION_TOOLBAR::onToolEvent(), PAD_TOOL::pastePadProperties(), PCBNEW_CONTROL::placeBoardItems(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EE_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), EDIT_TOOL::Rotate(), EE_SELECTION_TOOL::SelectConnection(), SELECTION_TOOL::selectCopper(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), GERBVIEW_SELECTION_TOOL::toggleSelection(), EE_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), DIALOG_SET_GRID::TransferDataFromWindow(), SCH_EDITOR_CONTROL::Undo(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), and SELECTION_TOOL::UnselectItems().

◆ processEvent()

bool TOOL_MANAGER::processEvent ( const TOOL_EVENT aEvent)
private

Main function for event processing.

Returns
true if a hotkey was handled

Definition at line 930 of file tool_manager.cpp.

931 {
932  // Early dispatch of events destined for the TOOL_MANAGER
933  if( !dispatchStandardEvents( aEvent ) )
934  return true;
935 
936  dispatchInternal( aEvent );
937  dispatchActivation( aEvent );
938  dispatchContextMenu( aEvent );
939 
940  // Dispatch queue
941  while( !m_eventQueue.empty() )
942  {
943  TOOL_EVENT event = m_eventQueue.front();
944  m_eventQueue.pop_front();
945  processEvent( event );
946  }
947 
948  return false;
949 }
bool processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
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:167
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:542

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

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

◆ RegisterAction()

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 265 of file tool_manager.cpp.

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

References m_actionMgr, and ACTION_MANAGER::RegisterAction().

◆ RegisterTool()

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 223 of file tool_manager.cpp.

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

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

Referenced by FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), FOOTPRINT_EDIT_FRAME::setupTools(), LIB_VIEW_FRAME::setupTools(), GERBVIEW_FRAME::setupTools(), LIB_EDIT_FRAME::setupTools(), and SCH_EDIT_FRAME::setupTools().

◆ ResetTools()

void TOOL_MANAGER::ResetTools ( TOOL_BASE::RESET_REASON  aReason)

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

calls their Reset() method).

Definition at line 426 of file tool_manager.cpp.

427 {
428  DeactivateTool();
429 
430  for( auto& state : m_toolState )
431  {
432  TOOL_BASE* tool = state.first;
433  setActiveState( state.second );
434  tool->Reset( aReason );
435 
436  if( tool->GetType() == INTERACTIVE )
437  static_cast<TOOL_INTERACTIVE*>( tool )->resetTransitions();
438  }
439 }
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:111
void DeactivateTool()
Function DeactivateTool() Deactivates the currently active tool.
virtual void Reset(RESET_REASON aReason)=0
Function Reset() Brings the tool to a known, initial state.
Tool that interacts with the user
Definition: tool_base.h:50
void setActiveState(TOOL_STATE *aState)
Saves the previous active state and sets a new one.
Class TOOL_BASE.
Definition: tool_base.h:68
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:516

References DeactivateTool(), TOOL_BASE::GetType(), INTERACTIVE, m_toolState, TOOL_BASE::Reset(), and setActiveState().

Referenced by GERBVIEW_FRAME::Clear_DrawLayers(), FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList(), GERBVIEW_FRAME::Erase_Current_DrawLayer(), InitTools(), LIB_EDIT_FRAME::OnSelectBodyStyle(), LIB_EDIT_FRAME::OnSelectUnit(), FOOTPRINT_WIZARD_FRAME::ReloadFootprint(), PCB_BASE_EDIT_FRAME::SetBoard(), LIB_EDIT_FRAME::SetCurPart(), DISPLAY_FOOTPRINTS_FRAME::updateView(), FOOTPRINT_WIZARD_FRAME::updateView(), FOOTPRINT_VIEWER_FRAME::updateView(), FOOTPRINT_EDIT_FRAME::updateView(), PCB_BASE_FRAME::UseGalCanvas(), and GERBVIEW_FRAME::UseGalCanvas().

◆ RunAction() [1/6]

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.

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

Referenced by DIALOG_GLOBAL_DELETION::AcceptPcbDelete(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), SCH_DRAWING_TOOLS::AddJunction(), SCH_DRAWING_TOOLS::AddLabel(), SCH_EDIT_FRAME::AppendSchematic(), ROUTER_TOOL::CanInlineDrag(), SELECTION_TOOL::clearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), SCH_EDIT_FRAME::ConvertPart(), SCH_EDIT_FRAME::ConvertTextType(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), ROUTER_TOOL::CustomTrackWidthDialog(), SCH_EDITOR_CONTROL::Cut(), DIALOG_DRC_CONTROL::DelDRCMarkers(), deleteItem(), DIALOG_MIGRATE_BUSES::DIALOG_MIGRATE_BUSES(), SCH_EDIT_FRAME::DisplayCurrentSheet(), DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup(), LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_DRAWING_TOOLS::doPlaceComponent(), DIALOG_DRC_CONTROL::doSelectionMenu(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), DRAWING_TOOL::drawArc(), SCH_WIRE_BUS_TOOL::DrawBusses(), DRAWING_TOOL::DrawDimension(), SCH_WIRE_BUS_TOOL::DrawLines(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_WIRE_BUS_TOOL::DrawWires(), DRAWING_TOOL::drawZone(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), LIB_EDIT_TOOL::editSymbolProperties(), LIB_EDIT_FRAME::emptyScreen(), MODULE_EDITOR_TOOLS::EnumeratePads(), TRACK_WIDTH_MENU::eventHandler(), DIFF_PAIR_MENU::eventHandler(), EDIT_TOOL::ExchangeFootprints(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), SCH_EDIT_FRAME::ExecuteRemoteCommand(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SCH_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), DRAWING_TOOL::getSourceZoneForAction(), SCH_EDIT_FRAME::importFile(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), LIB_EDIT_FRAME::LoadComponentFromCurrentLib(), LIB_EDIT_FRAME::LoadOneLibraryPartAux(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), LIB_VIEW_FRAME::OnAddPartToSchematic(), LIB_EDIT_FRAME::OnAddPartToSchematic(), LIB_EDIT_FRAME::OnCreateNewPart(), DIALOG_DRC_CONTROL::OnDeleteOneClick(), ACTION_MENU::onMenuEvent(), PCB_EDIT_FRAME::OnNetlistChanged(), DIALOG_CLEANUP_TRACKS_AND_VIAS::OnRightUpItem(), LIB_EDIT_FRAME::OnSelectBodyStyle(), DIALOG_POSITION_RELATIVE::OnSelectItemClick(), LIB_EDIT_FRAME::OnSelectUnit(), SCH_EDIT_FRAME::OpenProjectFiles(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), ZONE_CREATE_HELPER::performZoneCutout(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Properties(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), SELECTION_TOOL::RequestSelection(), LIB_EDIT_FRAME::RollbackPartFromUndo(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), RunAction(), ACTION_MANAGER::RunHotKey(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), LIB_EDIT_FRAME::saveLibrary(), EE_SELECTION_TOOL::SelectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), GERBVIEW_FRAME::SetActiveLayer(), LIB_EDIT_FRAME::SetCurPart(), PCB_BASE_FRAME::SetFastGrid1(), PCB_BASE_FRAME::SetFastGrid2(), LIB_VIEW_FRAME::SetSelectedComponent(), DRC::ShowDRCDialog(), showLocalRatsnest(), SCH_WIRE_BUS_TOOL::StartBus(), SCH_WIRE_BUS_TOOL::StartLine(), SCH_WIRE_BUS_TOOL::StartWire(), FOOTPRINT_EDIT_FRAME::ToPrinter(), PCB_EDIT_FRAME::ToPrinter(), GERBVIEW_FRAME::ToPrinter(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), DIALOG_SET_GRID::TransferDataFromWindow(), SCH_WIRE_BUS_TOOL::UnfoldBus(), PCB_BASE_EDIT_FRAME::unitsChangeRefresh(), DISPLAY_FOOTPRINTS_FRAME::updateView(), FOOTPRINT_WIZARD_FRAME::updateView(), FOOTPRINT_VIEWER_FRAME::updateView(), FOOTPRINT_EDIT_FRAME::updateView(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ RunAction() [2/6]

bool TOOL_MANAGER::RunAction ( const std::string &  aActionName,
bool  aNow,
void *  aParam 
)

Definition at line 277 of file tool_manager.cpp.

278 {
279  TOOL_ACTION* action = m_actionMgr->FindAction( aActionName );
280 
281  if( !action )
282  {
283  wxASSERT_MSG( false, wxString::Format( wxT( "Could not find action %s." ), aActionName ) );
284  return false;
285  }
286 
287  RunAction( *action, aNow, aParam );
288 
289  return false;
290 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:531
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

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

◆ RunAction() [3/6]

bool TOOL_MANAGER::RunAction ( const std::string &  aActionName,
bool  aNow = false 
)
inline

Definition at line 132 of file tool_manager.h.

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

References RunAction().

◆ RunAction() [4/6]

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.

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

References RunAction().

◆ RunAction() [5/6]

void TOOL_MANAGER::RunAction ( const TOOL_ACTION aAction,
bool  aNow,
void *  aParam 
)

Definition at line 293 of file tool_manager.cpp.

294 {
295  TOOL_EVENT event = aAction.MakeEvent();
296 
297  // Allow to override the action parameter
298  if( aParam )
299  event.SetParameter( aParam );
300 
301  if( aNow )
302  {
303  TOOL_STATE* current = m_activeState;
304  processEvent( event );
305  setActiveState( current );
306  UpdateUI();
307  }
308  else
309  {
310  PostEvent( event );
311  }
312 }
bool processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
void UpdateUI()
Synchronizes toolbars.
void SetParameter(T aParam)
Function SetParameter() Sets a non-standard parameter assigned to the event.
Definition: tool_event.h:390
void setActiveState(TOOL_STATE *aState)
Saves the previous active state and sets a new one.
Class TOOL_EVENT.
Definition: tool_event.h:167
TOOL_STATE * m_activeState
Pointer to the state object corresponding to the currently executed tool.
Definition: tool_manager.h:559
TOOL_EVENT MakeEvent() const
Function MakeEvent() Returns the event associated with the action (i.e.
Definition: tool_action.h:95
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:238

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

◆ RunAction() [6/6]

void TOOL_MANAGER::RunAction ( const TOOL_ACTION aAction,
bool  aNow = false 
)
inline

Definition at line 155 of file tool_manager.h.

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

References RunAction().

◆ RunMainStack()

void TOOL_MANAGER::RunMainStack ( TOOL_BASE aTool,
std::function< void()>  aFunc 
)

Definition at line 503 of file tool_manager.cpp.

504 {
505  TOOL_STATE* st = m_toolState[aTool];
506  setActiveState( st );
507  st->cofunc->RunMainStack( std::move( aFunc ) );
508 }
void setActiveState(TOOL_STATE *aState)
Saves the previous active state and sets a new one.
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:516

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

Referenced by TOOL_INTERACTIVE::RunMainStack().

◆ runTool() [1/3]

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 341 of file tool_manager.cpp.

342 {
343  TOOL_BASE* tool = FindTool( aToolId );
344 
345  if( tool && tool->GetType() == INTERACTIVE )
346  return runTool( tool );
347 
348  return false; // there is no tool with the given id
349 }
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:111
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
Class TOOL_BASE.
Definition: tool_base.h:68

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

Referenced by dispatchActivation(), and runTool().

◆ runTool() [2/3]

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 352 of file tool_manager.cpp.

353 {
354  TOOL_BASE* tool = FindTool( aToolName );
355 
356  if( tool && tool->GetType() == INTERACTIVE )
357  return runTool( tool );
358 
359  return false; // there is no tool with the given name
360 }
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:111
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
Class TOOL_BASE.
Definition: tool_base.h:68

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

◆ runTool() [3/3]

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 363 of file tool_manager.cpp.

364 {
365  wxASSERT( aTool != NULL );
366 
367  if( !isRegistered( aTool ) )
368  {
369  wxASSERT_MSG( false, wxT( "You cannot run unregistered tools" ) );
370  return false;
371  }
372 
373  TOOL_ID id = aTool->GetId();
374 
375  if( aTool->GetType() == INTERACTIVE )
376  static_cast<TOOL_INTERACTIVE*>( aTool )->resetTransitions();
377 
378  // If the tool is already active, bring it to the top of the active tools stack
379  if( isActive( aTool ) )
380  {
381  m_activeTools.erase( std::find( m_activeTools.begin(), m_activeTools.end(), id ) );
382  m_activeTools.push_front( id );
383  return false;
384  }
385 
387  aTool->Reset( TOOL_INTERACTIVE::RUN );
388 
389  // Add the tool on the front of the processing queue (it gets events first)
390  m_activeTools.push_front( id );
391 
392  return true;
393 }
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:111
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:522
TOOL_ID GetId() const
Function GetId() Returns the unique identifier of the tool.
Definition: tool_base.h:122
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 that interacts with the user
Definition: tool_base.h:50
void setActiveState(TOOL_STATE *aState)
Saves the previous active state and sets a new one.
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:477
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:528

References TOOL_BASE::GetId(), TOOL_BASE::GetType(), INTERACTIVE, isActive(), isRegistered(), m_activeTools, m_toolIdIndex, TOOL_BASE::Reset(), TOOL_BASE::RUN, and setActiveState().

◆ SaveClipboard()

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

Definition at line 811 of file tool_manager.cpp.

812 {
813  if( wxTheClipboard->Open() )
814  {
815  wxTheClipboard->SetData( new wxTextDataObject( wxString( aText.c_str(), wxConvUTF8 ) ) );
816  wxTheClipboard->Close();
817 
818  return true;
819  }
820 
821  return false;
822 }

Referenced by LIB_EDIT_TOOL::Copy(), and SCH_EDITOR_CONTROL::doCopy().

◆ saveViewControls()

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 884 of file tool_manager.cpp.

885 {
886  aState->vcSettings = m_viewControls->GetSettings();
887 
888  if( m_menuActive )
889  {
890  // Context menu is active, so the cursor settings are overridden (see dispatchContextMenu())
891  auto it = m_cursorSettings.find( aState->theTool->GetId() );
892 
893  if( it != m_cursorSettings.end() )
894  {
896 
897  // Tool has overridden the cursor position, so store the new settings
899  {
900  if( !curr.m_forceCursorPosition )
901  it->second = NULLOPT;
902  else
903  it->second = curr.m_forcedPosition;
904  }
905  else
906  {
907  OPT<VECTOR2D> cursor = it->second;
908 
909  if( cursor )
910  {
911  aState->vcSettings.m_forceCursorPosition = true;
912  aState->vcSettings.m_forcedPosition = *cursor;
913  }
914  else
915  {
916  aState->vcSettings.m_forceCursorPosition = false;
917  }
918  }
919  }
920  }
921 }
bool m_menuActive
Flag indicating whether a context menu is currently displayed.
Definition: tool_manager.h:553
VECTOR2D m_menuCursor
Right click context menu position.
Definition: tool_manager.h:548
std::map< TOOL_ID, OPT< VECTOR2D > > m_cursorSettings
Original cursor position, if overridden by the context menu handler.
Definition: tool_manager.h:534
VECTOR2D m_forcedPosition
Forced cursor position (world coordinates)
Definition: view_controls.h:58
const VC_SETTINGS & GetSettings() const
Returns the current VIEW_CONTROLS settings
const auto NULLOPT
Definition: optional.h:9
bool m_forceCursorPosition
Is the forced cursor position enabled
Definition: view_controls.h:61
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:538
boost::optional< T > OPT
Definition: optional.h:7

References TOOL_BASE::GetId(), KIGFX::VIEW_CONTROLS::GetSettings(), m_cursorSettings, KIGFX::VC_SETTINGS::m_forceCursorPosition, KIGFX::VC_SETTINGS::m_forcedPosition, m_menuActive, m_menuCursor, m_viewControls, NULLOPT, TOOL_MANAGER::TOOL_STATE::theTool, and TOOL_MANAGER::TOOL_STATE::vcSettings.

Referenced by setActiveState().

◆ ScheduleContextMenu()

void TOOL_MANAGER::ScheduleContextMenu ( TOOL_BASE aTool,
ACTION_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 801 of file tool_manager.cpp.

803 {
804  TOOL_STATE* st = m_toolState[aTool];
805 
806  st->contextMenu = aMenu;
807  st->contextMenuTrigger = aTrigger;
808 }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:516

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

Referenced by TOOL_INTERACTIVE::SetContextMenu().

◆ ScheduleNextState()

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 488 of file tool_manager.cpp.

490 {
491  TOOL_STATE* st = m_toolState[aTool];
492 
493  st->transitions.push_back( TRANSITION( aConditions, aHandler ) );
494 }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:516
std::pair< TOOL_EVENT_LIST, TOOL_STATE_FUNC > TRANSITION
Definition: tool_manager.h:392

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

Referenced by TOOL_INTERACTIVE::goInternal().

◆ ScheduleWait()

OPT< 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 511 of file tool_manager.cpp.

512 {
513  TOOL_STATE* st = m_toolState[aTool];
514 
515  wxASSERT( !st->pendingWait ); // everything collapses on two KiYield() in a row
516 
517  // indicate to the manager that we are going to sleep and we shall be
518  // woken up when an event matching aConditions arrive
519  st->pendingWait = true;
520  st->waitEvents = aConditions;
521 
522  // switch context back to event dispatcher loop
523  st->cofunc->KiYield();
524 
525  return st->wakeupEvent;
526 }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:516

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().

◆ setActiveState()

void TOOL_MANAGER::setActiveState ( TOOL_STATE aState)
private

Saves the previous active state and sets a new one.

Parameters
aStateis the new active state. Might be null to indicate there is no new active state.

Definition at line 952 of file tool_manager.cpp.

953 {
954  if( m_activeState )
956 
957  m_activeState = aState;
958 
959  if( m_activeState )
960  applyViewControls( aState );
961 }
void applyViewControls(TOOL_STATE *aState)
Function applyViewControls() Applies VIEW_CONTROLS settings stored in a TOOL_STATE object.
TOOL_STATE * m_activeState
Pointer to the state object corresponding to the currently executed tool.
Definition: tool_manager.h:559
void saveViewControls(TOOL_STATE *aState)
Function saveViewControls() Saves the VIEW_CONTROLS settings to the tool state object.

References applyViewControls(), m_activeState, and saveViewControls().

Referenced by dispatchInternal(), finishTool(), InitTools(), invokeTool(), ProcessEvent(), ResetTools(), RunAction(), RunMainStack(), and runTool().

◆ SetEnvironment()

void TOOL_MANAGER::SetEnvironment ( EDA_ITEM aModel,
KIGFX::VIEW aView,
KIGFX::VIEW_CONTROLS aViewControls,
EDA_DRAW_FRAME 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 863 of file tool_manager.cpp.

865 {
866  m_model = aModel;
867  m_view = aView;
868  m_viewControls = aViewControls;
869  m_editFrame = aFrame;
871 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:531
void UpdateHotKeys()
Function UpdateHotKeys() Updates TOOL_ACTIONs hot key assignment according to the current frame's Hot...
EDA_DRAW_FRAME * m_editFrame
Definition: tool_manager.h:539
EDA_ITEM * m_model
Definition: tool_manager.h:536
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:538
KIGFX::VIEW * m_view
Definition: tool_manager.h:537

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

Referenced by DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME(), EVT_GRID_CMD_CELL_CHANGED(), FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), PCB_BASE_EDIT_FRAME::SetBoard(), SCH_BASE_FRAME::SetScreen(), PCB_EDIT_FRAME::setupTools(), FOOTPRINT_EDIT_FRAME::setupTools(), LIB_VIEW_FRAME::setupTools(), GERBVIEW_FRAME::setupTools(), LIB_EDIT_FRAME::setupTools(), SCH_EDIT_FRAME::setupTools(), PCB_BASE_FRAME::UseGalCanvas(), and GERBVIEW_FRAME::UseGalCanvas().

◆ UnregisterAction()

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 271 of file tool_manager.cpp.

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

References m_actionMgr, and ACTION_MANAGER::UnregisterAction().

◆ UpdateHotKeys()

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 321 of file tool_manager.cpp.

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

References m_actionMgr, and ACTION_MANAGER::UpdateHotKeys().

Referenced by EDA_DRAW_FRAME::WriteHotkeyConfig().

◆ UpdateUI()

void TOOL_MANAGER::UpdateUI ( )

Synchronizes toolbars.

Definition at line 971 of file tool_manager.cpp.

972 {
973  EDA_DRAW_FRAME* frame = GetEditFrame();
974 
975  if( frame )
976  {
977  frame->UpdateStatusBar();
978  frame->SyncMenusAndToolbars();
979  }
980 }
EDA_DRAW_FRAME * GetEditFrame() const
Definition: tool_manager.h:267
The base class for create windows for drawing purpose.
Definition: draw_frame.h:82
virtual void SyncMenusAndToolbars()
Update the toolbars and menus (mostly settings/check buttons/checkboxes) with the current controller ...
Definition: draw_frame.h:955
virtual void UpdateStatusBar()
Update the status bar information.

References GetEditFrame(), EDA_DRAW_FRAME::SyncMenusAndToolbars(), and EDA_DRAW_FRAME::UpdateStatusBar().

Referenced by ProcessEvent(), and RunAction().

◆ VetoContextMenuMouseWarp()

void TOOL_MANAGER::VetoContextMenuMouseWarp ( )
inline

Disables mouse warping after the current context menu is closed.

Must be called before invoking each context menu. It's a good idea to call this from non-modal dialogs (e.g. DRC window).

Definition at line 385 of file tool_manager.h.

386  {
388  }
bool m_warpMouseAfterContextMenu
Definition: tool_manager.h:550

References m_warpMouseAfterContextMenu.

Referenced by DIALOG_SHIM::DIALOG_SHIM(), SCH_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::doPlaceComponent(), DIALOG_DRC_CONTROL::doSelectionMenu(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), and SCH_DRAWING_TOOLS::PlaceImage().

Member Data Documentation

◆ m_actionMgr

ACTION_MANAGER* TOOL_MANAGER::m_actionMgr
private

◆ m_activeState

TOOL_STATE* TOOL_MANAGER::m_activeState
private

Pointer to the state object corresponding to the currently executed tool.

Definition at line 559 of file tool_manager.h.

Referenced by finishTool(), RunAction(), and setActiveState().

◆ m_activeTools

ID_LIST TOOL_MANAGER::m_activeTools
private

Stack of the active tools.

Definition at line 528 of file tool_manager.h.

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

◆ m_cursorSettings

std::map<TOOL_ID, OPT<VECTOR2D> > TOOL_MANAGER::m_cursorSettings
private

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

Definition at line 534 of file tool_manager.h.

Referenced by dispatchContextMenu(), and saveViewControls().

◆ m_editFrame

EDA_DRAW_FRAME* TOOL_MANAGER::m_editFrame
private

Definition at line 539 of file tool_manager.h.

Referenced by dispatchContextMenu(), GetEditFrame(), and SetEnvironment().

◆ m_eventQueue

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 542 of file tool_manager.h.

Referenced by PostEvent(), and processEvent().

◆ m_menuActive

bool TOOL_MANAGER::m_menuActive
private

Flag indicating whether a context menu is currently displayed.

Definition at line 553 of file tool_manager.h.

Referenced by dispatchContextMenu(), and saveViewControls().

◆ m_menuCursor

VECTOR2D TOOL_MANAGER::m_menuCursor
private

Right click context menu position.

Definition at line 548 of file tool_manager.h.

Referenced by dispatchContextMenu(), and saveViewControls().

◆ m_menuOwner

TOOL_ID TOOL_MANAGER::m_menuOwner
private

Tool currently displaying a popup menu. It is negative when there is no menu displayed.

Definition at line 556 of file tool_manager.h.

Referenced by dispatchContextMenu(), and dispatchInternal().

◆ m_model

EDA_ITEM* TOOL_MANAGER::m_model
private

Definition at line 536 of file tool_manager.h.

Referenced by GetModel(), and SetEnvironment().

◆ m_passEvent

bool TOOL_MANAGER::m_passEvent
private

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

Definition at line 545 of file tool_manager.h.

Referenced by dispatchInternal(), and PassEvent().

◆ m_toolIdIndex

ID_STATE_MAP TOOL_MANAGER::m_toolIdIndex
private

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

Definition at line 522 of file tool_manager.h.

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

◆ m_toolNameIndex

NAME_STATE_MAP TOOL_MANAGER::m_toolNameIndex
private

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

Definition at line 519 of file tool_manager.h.

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

◆ m_toolState

TOOL_STATE_MAP TOOL_MANAGER::m_toolState
private

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

Definition at line 516 of file tool_manager.h.

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

◆ m_toolTypes

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 525 of file tool_manager.h.

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

◆ m_view

KIGFX::VIEW* TOOL_MANAGER::m_view
private

Definition at line 537 of file tool_manager.h.

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

◆ m_viewControls

KIGFX::VIEW_CONTROLS* TOOL_MANAGER::m_viewControls
private

◆ m_warpMouseAfterContextMenu

bool TOOL_MANAGER::m_warpMouseAfterContextMenu
private

Definition at line 550 of file tool_manager.h.

Referenced by dispatchContextMenu(), and VetoContextMenuMouseWarp().


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