KiCad PCB EDA Suite
TOOL_MANAGER Class Reference

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 ShutdownAllTools ()
 Shutdown all tools with a currently registered event loop in this tool manager by waking them up with a null event. More...
 
void ShutdownTool (TOOL_BASE *aTool)
 Shutdown the specified tool by waking it up with a null event to terminate the processing loop. More...
 
void ShutdownTool (TOOL_ID aToolId)
 Shutdown the specified tool by waking it up with a null event to terminate the processing loop. More...
 
void ShutdownTool (const std::string &aToolName)
 Shutdown the specified tool by waking it up with a null event to terminate the processing loop. 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 >
bool RunAction (const TOOL_ACTION &aAction, bool aNow=false, T aParam=NULL)
 Function RunAction() Runs the specified action. More...
 
bool RunAction (const TOOL_ACTION &aAction, bool aNow, void *aParam)
 
bool RunAction (const TOOL_ACTION &aAction, bool aNow=false)
 
const std::map< std::string, TOOL_ACTION * > & GetActions ()
 
void CancelTool ()
 Send a cancel event to the tool currently at the top of the tool stack. More...
 
void PrimeTool (const VECTOR2D &aPosition)
 Function PrimeTool() "Primes" a tool by sending a cursor left-click event with the mouse position set to the passed in position. More...
 
int GetHotKey (const TOOL_ACTION &aAction)
 

More...
 
ACTION_MANAGERGetActionManager ()
 
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, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
 Sets the work environment (model, view, view controls and the parent window). More...
 
KIGFX::VIEWGetView () const
 
KIGFX::VIEW_CONTROLSGetViewControls () const
 
VECTOR2D GetMousePosition ()
 
VECTOR2D GetCursorPosition ()
 
EDA_ITEMGetModel () const
 
APP_SETTINGS_BASEGetSettings () const
 
TOOLS_HOLDERGetToolHolder () 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 (const TOOL_EVENT &aEvent)
 Updates the status bar and synchronizes toolbars. More...
 
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...
 
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...
 
bool IsContextMenuActive ()
 True while processing a context menu. More...
 
void VetoContextMenuMouseWarp ()
 Disables mouse warping after the current context menu is closed. More...
 
void DispatchContextMenu (const TOOL_EVENT &aEvent)
 Function DispatchContextMenu() Handles context menu related events. More...
 
bool DispatchHotKey (const TOOL_EVENT &aEvent)
 Function dispatchHotKey() Handles specific events, that are intended for TOOL_MANAGER rather than tools. 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

bool dispatchInternal (const TOOL_EVENT &aEvent)
 Function dispatchInternal Passes an event at first to the active tools, then to all others. More...
 
bool dispatchActivation (const TOOL_EVENT &aEvent)
 Function dispatchActivation() Checks if it is a valid activation event and invokes a proper tool. 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_BASE *aTool)
 Function runTool() Makes a tool active, so it can receive events and react to them. More...
 
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
 
TOOLS_HOLDERm_frame
 
APP_SETTINGS_BASEm_settings
 
std::list< TOOL_EVENTm_eventQueue
 Queue that stores events to be processed at the end of the event processing cycle. 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

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

Member Typedef Documentation

◆ ID_LIST

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

Definition at line 65 of file tool_manager.h.

◆ ID_STATE_MAP

Definition at line 64 of file tool_manager.h.

◆ NAME_STATE_MAP

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

Definition at line 63 of file tool_manager.h.

◆ TOOL_STATE_MAP

Definition at line 62 of file tool_manager.h.

◆ TRANSITION

Definition at line 433 of file tool_manager.h.

Constructor & Destructor Documentation

◆ TOOL_MANAGER()

TOOL_MANAGER::TOOL_MANAGER ( )

Definition at line 200 of file tool_manager.cpp.

200  :
201  m_model( nullptr ),
202  m_view( nullptr ),
203  m_viewControls( nullptr ),
204  m_frame( nullptr ),
205  m_settings( nullptr ),
207  m_menuActive( false ),
208  m_menuOwner( -1 ),
209  m_activeState( nullptr )
210 {
211  m_actionMgr = new ACTION_MANAGER( this );
212 }
bool m_menuActive
Flag indicating whether a context menu is currently displayed.
Definition: tool_manager.h:559
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:539
ACTION_MANAGER.
TOOLS_HOLDER * m_frame
Definition: tool_manager.h:547
EDA_ITEM * m_model
Definition: tool_manager.h:544
TOOL_ID m_menuOwner
Tool currently displaying a popup menu. It is negative when there is no menu displayed.
Definition: tool_manager.h:562
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:546
KIGFX::VIEW * m_view
Definition: tool_manager.h:545
bool m_warpMouseAfterContextMenu
Definition: tool_manager.h:556
TOOL_STATE * m_activeState
Pointer to the state object corresponding to the currently executed tool.
Definition: tool_manager.h:565
APP_SETTINGS_BASE * m_settings
Definition: tool_manager.h:548

References m_actionMgr.

◆ ~TOOL_MANAGER()

TOOL_MANAGER::~TOOL_MANAGER ( )

Definition at line 215 of file tool_manager.cpp.

216 {
217  std::map<TOOL_BASE*, TOOL_STATE*>::iterator it, it_end;
218 
219  for( it = m_toolState.begin(), it_end = m_toolState.end(); it != it_end; ++it )
220  {
221  delete it->second->cofunc; // delete cofunction
222  delete it->second; // delete TOOL_STATE
223  delete it->first; // delete the tool itself
224  }
225 
226  delete m_actionMgr;
227 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:539
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:524

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

1085 {
1086  m_viewControls->ApplySettings( aState->vcSettings );
1087 }
void ApplySettings(const VC_SETTINGS &aSettings)
Applies VIEW_CONTROLS settings from an object
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:546

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

Referenced by setActiveState().

◆ CancelTool()

void TOOL_MANAGER::CancelTool ( )

Send a cancel event to the tool currently at the top of the tool stack.

Definition at line 340 of file tool_manager.cpp.

341 {
343 
344  processEvent( evt );
345 }
bool processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
TOOL_EVENT.
Definition: tool_event.h:171

References processEvent(), TA_CANCEL_TOOL, and TC_COMMAND.

Referenced by ACTION_TOOLBAR::onToolEvent().

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

609 {
610  m_toolState[aTool]->transitions.clear();
611 }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:524

References m_toolState.

Referenced by TOOL_INTERACTIVE::resetTransitions().

◆ DeactivateTool()

void TOOL_MANAGER::DeactivateTool ( )

Function DeactivateTool() Deactivates the currently active tool.

Definition at line 527 of file tool_manager.cpp.

528 {
529  // Deactivate the active tool, but do not run anything new
531  processEvent( evt );
532 }
bool processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
TOOL_EVENT.
Definition: tool_event.h:171

References processEvent(), TA_CANCEL_TOOL, and TC_COMMAND.

Referenced by GERBVIEW_FRAME::doCloseWindow(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), LIB_EDIT_FRAME::OnExportBody(), LIB_EDIT_FRAME::OnImportBody(), ResetTools(), 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 784 of file tool_manager.cpp.

785 {
786  wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::dispatchActivation - %s", aEvent.Format() );
787  if( aEvent.IsActivate() )
788  {
789  wxString cmdStr( *aEvent.GetCommandStr() );
790 
791  auto tool = m_toolNameIndex.find( *aEvent.GetCommandStr() );
792 
793  if( tool != m_toolNameIndex.end() )
794  {
795  wxLogTrace( kicadTraceToolStack,
796  "TOOL_MANAGER::dispatchActivation - Running tool %s for event: %s",
797  tool->second->theTool->GetName(), aEvent.Format() );
798 
799  runTool( tool->second->theTool );
800  return true;
801  }
802  }
803 
804  return false;
805 }
const std::string Format() const
Function Format() Returns information about event in form of a human-readable string.
Definition: tool_event.cpp:73
NAME_STATE_MAP m_toolNameIndex
Index of the registered tools current states, associated by tools' names.
Definition: tool_manager.h:527
bool runTool(TOOL_BASE *aTool)
Function runTool() Makes a tool active, so it can receive events and react to them.
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
bool IsActivate() const
Definition: tool_event.h:321
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.

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

Referenced by processEvent().

◆ DispatchContextMenu()

void TOOL_MANAGER::DispatchContextMenu ( const TOOL_EVENT aEvent)

Function DispatchContextMenu() Handles context menu related events.

Definition at line 807 of file tool_manager.cpp.

808 {
809  for( TOOL_ID toolId : m_activeTools )
810  {
811  TOOL_STATE* st = m_toolIdIndex[toolId];
812 
813  // the tool requested a context menu. The menu is activated on RMB click (CMENU_BUTTON mode)
814  // or immediately (CMENU_NOW) mode. The latter is used for clarification lists.
815  if( st->contextMenuTrigger == CMENU_OFF )
816  continue;
817 
818  if( st->contextMenuTrigger == CMENU_BUTTON && !aEvent.IsClick( BUT_RIGHT ) )
819  break;
820 
821  if( st->cofunc )
822  {
823  st->pendingWait = true;
824  st->waitEvents = TOOL_EVENT( TC_ANY, TA_ANY );
825  }
826 
827  // Store the menu pointer in case it is changed by the TOOL when handling menu events
828  ACTION_MENU* m = st->contextMenu;
829 
830  if( st->contextMenuTrigger == CMENU_NOW )
831  st->contextMenuTrigger = CMENU_OFF;
832 
833  // Store the cursor position, so the tools could execute actions
834  // using the point where the user has invoked a context menu
835  if( m_viewControls )
837 
838  // Save all tools cursor settings, as they will be overridden
839  for( auto idState : m_toolIdIndex )
840  {
841  TOOL_STATE* s = idState.second;
842  const auto& vc = s->vcSettings;
843 
844  if( vc.m_forceCursorPosition )
845  m_cursorSettings[idState.first] = vc.m_forcedPosition;
846  else
847  m_cursorSettings[idState.first] = NULLOPT;
848  }
849 
850  if( m_viewControls )
852 
853  // Display a copy of menu
854  std::unique_ptr<ACTION_MENU> menu( m->Clone() );
855 
856  m_menuOwner = toolId;
857  m_menuActive = true;
858 
859  if( wxWindow* frame = dynamic_cast<wxWindow*>( m_frame ) )
860  frame->PopupMenu( menu.get() );
861 
862  // Warp the cursor if a menu item was selected
863  if( menu->GetSelected() >= 0 )
864  {
866  m_viewControls->WarpCursor( m_menuCursor, true, false );
867  }
868  // Otherwise notify the tool of a cancelled menu
869  else
870  {
872  evt.SetHasPosition( false );
873  evt.SetParameter( m );
874  dispatchInternal( evt );
875  }
876 
877  // Restore setting in case it was vetoed
879 
880  // Notify the tools that menu has been closed
882  evt.SetHasPosition( false );
883  evt.SetParameter( m );
884  dispatchInternal( evt );
885 
886  m_menuActive = false;
887  m_menuOwner = -1;
888 
889  // Restore cursor settings
890  for( auto cursorSetting : m_cursorSettings )
891  {
892  auto it = m_toolIdIndex.find( cursorSetting.first );
893  wxASSERT( it != m_toolIdIndex.end() );
894 
895  if( it == m_toolIdIndex.end() )
896  continue;
897 
898  KIGFX::VC_SETTINGS& vc = it->second->vcSettings;
899  vc.m_forceCursorPosition = (bool) cursorSetting.second;
900  vc.m_forcedPosition = cursorSetting.second ? *cursorSetting.second : VECTOR2D( 0, 0 );
901  }
902 
903  m_cursorSettings.clear();
904  break;
905  }
906 }
bool m_menuActive
Flag indicating whether a context menu is currently displayed.
Definition: tool_manager.h:559
VECTOR2D m_menuCursor
Right click context menu position.
Definition: tool_manager.h:554
Defines the structure of a menu based on ACTIONs.
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:530
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:178
std::map< TOOL_ID, OPT< VECTOR2D > > m_cursorSettings
Original cursor position, if overridden by the context menu handler.
Definition: tool_manager.h:542
VECTOR2D m_forcedPosition
Forced cursor position (world coordinates)
Definition: view_controls.h:69
TOOLS_HOLDER * m_frame
Definition: tool_manager.h:547
int TOOL_ID
Unique identifier for tools.
Definition: tool_base.h:56
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:72
TOOL_ID m_menuOwner
Tool currently displaying a popup menu. It is negative when there is no menu displayed.
Definition: tool_manager.h:562
TOOL_EVENT.
Definition: tool_event.h:171
Structure to keep VIEW_CONTROLS settings for easy store/restore operations
Definition: view_controls.h:55
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:546
bool m_warpMouseAfterContextMenu
Definition: tool_manager.h:556
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:536
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
bool dispatchInternal(const TOOL_EVENT &aEvent)
Function dispatchInternal Passes an event at first to the active tools, then to all others.

References BUT_RIGHT, ACTION_MENU::Clone(), CMENU_BUTTON, CMENU_NOW, CMENU_OFF, TOOL_MANAGER::TOOL_STATE::cofunc, 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, KIGFX::VC_SETTINGS::m_forceCursorPosition, KIGFX::VC_SETTINGS::m_forcedPosition, m_frame, m_menuActive, m_menuCursor, m_menuOwner, m_toolIdIndex, m_viewControls, m_warpMouseAfterContextMenu, NULLOPT, TOOL_MANAGER::TOOL_STATE::pendingWait, TOOL_EVENT::SetHasPosition(), TOOL_EVENT::SetParameter(), TA_ANY, TA_CHOICE_MENU_CHOICE, TA_CHOICE_MENU_CLOSED, TC_ANY, TC_COMMAND, TOOL_MANAGER::TOOL_STATE::vcSettings, TOOL_MANAGER::TOOL_STATE::waitEvents, and KIGFX::VIEW_CONTROLS::WarpCursor().

Referenced by LIB_TREE::onContextMenu(), and processEvent().

◆ DispatchHotKey()

bool TOOL_MANAGER::DispatchHotKey ( const TOOL_EVENT aEvent)

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

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

Definition at line 775 of file tool_manager.cpp.

776 {
777  if( aEvent.Action() == TA_KEY_PRESSED )
778  return m_actionMgr->RunHotKey( aEvent.Modifier() | aEvent.KeyCode() );
779 
780  return false;
781 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:539
TOOL_ACTIONS Action() const
Returns more specific information about the type of an event.
Definition: tool_event.h:250
bool RunHotKey(int aHotKey) const
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:342
int KeyCode() const
Definition: tool_event.h:347

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

Referenced by processEvent().

◆ dispatchInternal()

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

645 {
646  bool handled = false;
647 
648  wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::dispatchInternal - %s", aEvent.Format() );
649 
650  auto it = m_activeTools.begin();
651 
652  // iterate over active tool stack
653  while( it != m_activeTools.end() )
654  {
655  TOOL_STATE* st = m_toolIdIndex[*it];
656  bool increment = true;
657 
658  // forward context menu events to the tool that created the menu
659  if( aEvent.IsChoiceMenu() )
660  {
661  if( *it != m_menuOwner )
662  {
663  ++it;
664  continue;
665  }
666  }
667 
668  // If we're pendingWait then we had better have a cofunc to process the wait.
669  wxASSERT( !st || !st->pendingWait || st->cofunc );
670 
671  // the tool state handler is waiting for events (i.e. called Wait() method)
672  if( st && st->cofunc && st->pendingWait && st->waitEvents.Matches( aEvent ) )
673  {
674  if( !aEvent.FirstResponder() )
675  const_cast<TOOL_EVENT*>( &aEvent )->SetFirstResponder( st->theTool );
676 
677  // got matching event? clear wait list and wake up the coroutine
678  st->wakeupEvent = aEvent;
679  st->pendingWait = false;
680  st->waitEvents.clear();
681 
682  wxLogTrace( kicadTraceToolStack,
683  "TOOL_MANAGER::dispatchInternal - Waking tool %s for event: %s",
684  st->theTool->GetName(), aEvent.Format() );
685 
686  setActiveState( st );
687  bool end = !st->cofunc->Resume();
688 
689  if( end )
690  {
691  it = finishTool( st );
692  increment = false;
693  }
694 
695  // If the tool did not request the event be passed to other tools, we're done
696  if( !st->wakeupEvent.PassEvent() )
697  {
698  wxLogTrace( kicadTraceToolStack,
699  "TOOL_MANAGER::dispatchInternal - %s stopped passing event: %s",
700  st->theTool->GetName(), aEvent.Format() );
701 
702  return true;
703  }
704  }
705 
706  if( increment )
707  ++it;
708  }
709 
710  for( auto& state : m_toolState )
711  {
712  TOOL_STATE* st = state.second;
713  bool finished = false;
714 
715  // no state handler in progress - check if there are any transitions (defined by
716  // Go() method that match the event.
717  if( !st->transitions.empty() )
718  {
719  for( TRANSITION& tr : st->transitions )
720  {
721  if( tr.first.Matches( aEvent ) )
722  {
723  auto func_copy = tr.second;
724 
725  if( !aEvent.FirstResponder() )
726  const_cast<TOOL_EVENT*>( &aEvent )->SetFirstResponder( st->theTool );
727 
728  // if there is already a context, then push it on the stack
729  // and transfer the previous view control settings to the new context
730  if( st->cofunc )
731  {
732  auto vc = st->vcSettings;
733  st->Push();
734  st->vcSettings = vc;
735  }
736 
737  st->cofunc = new COROUTINE<int, const TOOL_EVENT&>( std::move( func_copy ) );
738 
739  // as the state changes, the transition table has to be set up again
740  st->transitions.clear();
741 
742  wxLogTrace( kicadTraceToolStack,
743  "TOOL_MANAGER::dispatchInternal - Running tool %s for event: %s",
744  st->theTool->GetName(), aEvent.Format() );
745 
746  // got match? Run the handler.
747  setActiveState( st );
748  st->idle = false;
749  st->cofunc->Call( aEvent );
750  handled = true;
751 
752  if( !st->cofunc->Running() )
753  finishTool( st ); // The couroutine has finished immediately?
754 
755  // if it is a message, continue processing
756  finished = !( aEvent.Category() == TC_MESSAGE );
757 
758  // there is no point in further checking, as transitions got cleared
759  break;
760  }
761  }
762  }
763 
764  if( finished )
765  break; // only the first tool gets the event
766  }
767 
768  wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::dispatchInternal - Handled: %s %s",
769  ( handled ? "true" : "false" ), aEvent.Format() );
770 
771  return handled;
772 }
const std::string Format() const
Function Format() Returns information about event in form of a human-readable string.
Definition: tool_event.cpp:73
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:530
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:247
TOOL_ID m_menuOwner
Tool currently displaying a popup menu. It is negative when there is no menu displayed.
Definition: tool_manager.h:562
void setActiveState(TOOL_STATE *aState)
Saves the previous active state and sets a new one.
bool IsChoiceMenu() const
Definition: tool_event.h:331
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.
TOOL_BASE * FirstResponder() const
Definition: tool_event.h:263
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:536
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:524
std::pair< TOOL_EVENT_LIST, TOOL_STATE_FUNC > TRANSITION
Definition: tool_manager.h:433

References COROUTINE< ReturnType, ArgType >::Call(), TOOL_EVENT::Category(), TOOL_EVENT_LIST::clear(), TOOL_MANAGER::TOOL_STATE::cofunc, finishTool(), TOOL_EVENT::FirstResponder(), TOOL_EVENT::Format(), TOOL_BASE::GetName(), TOOL_MANAGER::TOOL_STATE::idle, TOOL_EVENT::IsChoiceMenu(), kicadTraceToolStack, m_activeTools, m_menuOwner, m_toolIdIndex, m_toolState, TOOL_EVENT_LIST::Matches(), TOOL_EVENT::PassEvent(), 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::theTool, 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().

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

506 {
507  std::map<TOOL_ID, TOOL_STATE*>::const_iterator it = m_toolIdIndex.find( aId );
508 
509  if( it != m_toolIdIndex.end() )
510  return it->second->theTool;
511 
512  return NULL;
513 }
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:530
#define NULL

References m_toolIdIndex, and NULL.

Referenced by GetCurrentTool(), GLOBAL_EDIT_TOOL::Init(), EDIT_TOOL::Init(), InvokeTool(), ACTION_MANAGER::RunHotKey(), and ShutdownTool().

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

517 {
518  std::map<std::string, TOOL_STATE*>::const_iterator it = m_toolNameIndex.find( aName );
519 
520  if( it != m_toolNameIndex.end() )
521  return it->second->theTool;
522 
523  return NULL;
524 }
NAME_STATE_MAP m_toolNameIndex
Index of the registered tools current states, associated by tools' names.
Definition: tool_manager.h:527
#define NULL

References m_toolNameIndex, and NULL.

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

910 {
911  auto it = std::find( m_activeTools.begin(), m_activeTools.end(), aState->theTool->GetId() );
912 
913  if( !aState->Pop() )
914  {
915  // Deactivate the tool if there are no other contexts saved on the stack
916  if( it != m_activeTools.end() )
917  it = m_activeTools.erase( it );
918 
919  aState->idle = true;
920  }
921 
922  if( aState == m_activeState )
923  setActiveState( nullptr );
924 
925  // Set transitions to be ready for future TOOL_EVENTs
926  TOOL_BASE* tool = aState->theTool;
927 
928  if( tool->GetType() == INTERACTIVE )
929  static_cast<TOOL_INTERACTIVE*>( tool )->resetTransitions();
930 
931  return it;
932 }
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:110
Tool that interacts with the user
Definition: tool_base.h:49
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:565
TOOL_BASE.
Definition: tool_base.h:67
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:536

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(), and ShutdownTool().

◆ GetActionManager()

◆ GetActions()

const std::map< std::string, TOOL_ACTION * > & TOOL_MANAGER::GetActions ( )

Definition at line 362 of file tool_manager.cpp.

363 {
364  return m_actionMgr->GetActions();
365 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:539
const std::map< std::string, TOOL_ACTION * > & GetActions()
Get a list of currently-registered actions mapped by their name.

References ACTION_MANAGER::GetActions(), and m_actionMgr.

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

985 {
986  std::string result;
987 
988  if( wxTheClipboard->Open() )
989  {
990  if( wxTheClipboard->IsSupported( wxDF_TEXT ) )
991  {
992  wxTextDataObject data;
993  wxTheClipboard->GetData( data );
994 
995  result = data.GetText().mb_str();
996  }
997 
998  wxTheClipboard->Close();
999  }
1000 
1001  return result;
1002 }

Referenced by LIB_EDIT_TOOL::Paste(), PL_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 317 of file tool_manager.h.

318  {
319  return FindTool( GetCurrentToolId() );
320  }
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:307

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

308  {
309  return m_activeTools.empty() ? -1 : m_activeTools.front();
310  }
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:536

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

327  {
328  auto it = m_toolIdIndex.find( GetCurrentToolId() );
329  return ( it != m_toolIdIndex.end() ) ? it->second : nullptr;
330  }
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:530
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:307

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

1006 {
1007  if( TOOL_STATE* active = GetCurrentToolState() )
1008  return active->vcSettings;
1009 
1010  return m_viewControls->GetSettings();
1011 }
const VC_SETTINGS & GetSettings() const
Returns the current VIEW_CONTROLS settings
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:546
TOOL_STATE * GetCurrentToolState() const
Returns the TOOL_STATE object representing the state of the active tool.
Definition: tool_manager.h:326

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

Referenced by COMMON_TOOLS::ResetLocalCoords().

◆ GetCursorPosition()

VECTOR2D TOOL_MANAGER::GetCursorPosition ( )

Definition at line 303 of file tool_manager.cpp.

304 {
305  if( m_viewControls )
307  else
308  return wxGetMousePosition();
309 }
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:546
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.

References KIGFX::VIEW_CONTROLS::GetCursorPosition(), and m_viewControls.

Referenced by invokeTool(), and RunAction().

◆ GetHotKey()

int TOOL_MANAGER::GetHotKey ( const TOOL_ACTION aAction)

Definition at line 368 of file tool_manager.cpp.

369 {
370  return m_actionMgr->GetHotKey( aAction );
371 }
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:539
int GetHotKey(const TOOL_ACTION &aAction) const
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

◆ GetMousePosition()

VECTOR2D TOOL_MANAGER::GetMousePosition ( )

Definition at line 294 of file tool_manager.cpp.

295 {
296  if( m_viewControls )
298  else
299  return wxGetMousePosition();
300 }
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:546

References KIGFX::VIEW_CONTROLS::GetMousePosition(), and m_viewControls.

Referenced by ACTION_MENU::OnMenuEvent().

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

584 {
585  int priority = 0;
586 
587  for( TOOL_ID tool : m_activeTools )
588  {
589  if( tool == aToolId )
590  return priority;
591 
592  ++priority;
593  }
594 
595  return -1;
596 }
int TOOL_ID
Unique identifier for tools.
Definition: tool_base.h:56
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:536

References m_activeTools.

Referenced by ACTION_MANAGER::RunHotKey().

◆ GetSettings()

◆ GetTool()

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

Definition at line 224 of file tool_manager.h.

225  {
226  std::map<const char*, TOOL_BASE*>::iterator tool = m_toolTypes.find( typeid( T ).name() );
227 
228  if( tool != m_toolTypes.end() )
229  return static_cast<T*>( tool->second );
230 
231  return NULL;
232  }
#define NULL
const char * name
Definition: DXF_plotter.cpp:60
std::map< const char *, TOOL_BASE * > m_toolTypes
Index of the registered tools to easily lookup by their type.
Definition: tool_manager.h:533

References m_toolTypes, name, and NULL.

Referenced by EDA_BASE_FRAME::AddStandardHelpMenu(), EDA_DRAW_FRAME::AddStandardSubMenus(), SCH_EDITOR_CONTROL::AssignNetclass(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), PAD_TOOL::copyPadSettings(), EDA_3D_VIEWER::CreateMenuBar(), ZONE_CREATE_HELPER::createNewZone(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDIT_FRAME::DeleteJunction(), DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE(), SCH_EDIT_FRAME::DisplayCurrentSheet(), PL_DRAW_PANEL_GAL::DisplayWorksheet(), DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_INSPECTION_TOOL::doHideNet(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), PCB_EDITOR_CONTROL::DrillOrigin(), EDIT_TOOL::Duplicate(), PCB_EDITOR_CONTROL::EditFpInFpEditor(), LIB_EDIT_TOOL::editGraphicProperties(), PAD_TOOL::EditPad(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), SCH_EDITOR_CONTROL::EnterSheet(), SCH_EDIT_FRAME::ExecuteRemoteCommand(), FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), EDIT_TOOL::GetAndPlace(), FP_TREE_SYNCHRONIZING_ADAPTER::GetContextMenuTool(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetContextMenuTool(), FOOTPRINT_VIEWER_FRAME::GetCurrentSelection(), FOOTPRINT_EDIT_FRAME::GetCurrentSelection(), PL_EDITOR_FRAME::GetCurrentSelection(), DISPLAY_FOOTPRINTS_FRAME::GetCurrentSelection(), LIB_VIEW_FRAME::GetCurrentSelection(), LIB_EDIT_FRAME::GetCurrentSelection(), SCH_EDIT_FRAME::GetCurrentSelection(), GERBVIEW_FRAME::GetCurrentSelection(), PL_EDITOR_FRAME::GetLayoutFromRedoList(), PL_EDITOR_FRAME::GetLayoutFromUndoList(), DRAWING_TOOL::getSourceZoneForAction(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::GroupEnterSelected(), PCB_EDITOR_CONTROL::GroupFlattenSelected(), PCB_EDITOR_CONTROL::GroupLeave(), PCB_EDITOR_CONTROL::GroupMergeSelected(), PCB_EDITOR_CONTROL::GroupRemoveItemsSelected(), PCB_EDITOR_CONTROL::GroupSelected(), PL_EDITOR_FRAME::HardRedraw(), LIB_EDIT_FRAME::HardRedraw(), GERBVIEW_CONTROL::HighlightControl(), PCB_INSPECTION_TOOL::highlightNet(), highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), LIB_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), CONVERT_TOOL::Init(), PAD_TOOL::Init(), PCB_INSPECTION_TOOL::Init(), LIB_CONTROL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PL_POINT_EDITOR::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::InspectClearance(), PCB_BASE_FRAME::InstallPadOptionsFrame(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), EDIT_TOOL::isRouterActive(), SCH_EDIT_FRAME::KiwayMailIn(), LIB_EDIT_FRAME::LoadOneSymbol(), LIB_EDIT_FRAME::LoadPart(), PCB_EDIT_FRAME::LoadProjectSettings(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), LIB_MOVE_TOOL::Main(), PCB_EDITOR_CONTROL::modifyLockSelected(), PROPERTIES_FRAME::OnAcceptPrms(), DIALOG_DRC::OnActivateDlg(), DIALOG_DRC::OnCancelClick(), DIALOG_INSPECTOR::onCellClicked(), DIALOG_POSITION_RELATIVE::OnClear(), DIALOG_POSITION_RELATIVE::OnOkClick(), DIALOG_PLOT::onRunDRC(), DIALOG_DRC::OnRunDRCClick(), DIALOG_POSITION_RELATIVE::OnSelectItemClick(), DIALOG_FIELDS_EDITOR_GLOBAL::OnTableCellClick(), SCH_EDIT_FRAME::OpenProjectFiles(), PANEL_SELECTION_FILTER::PANEL_SELECTION_FILTER(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickReferencePoint(), PCBNEW_CONTROL::placeBoardItems(), DIALOG_PLOT::Plot(), LIB_EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), SCH_EDIT_FRAME::PutDataInPreviousState(), LIB_VIEW_FRAME::ReCreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar(), LIB_EDIT_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), CVPCB_MAINFRAME::ReCreateMenuBar(), SCH_EDIT_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), PCB_EDIT_FRAME::ReCreateMenuBar(), PCB_EDIT_FRAME::ReCreateVToolbar(), LIB_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), SCH_BASE_FRAME::RefreshSelection(), LIB_DRAWING_TOOLS::RepeatDrawItem(), PL_EDITOR_FRAME::RollbackFromUndo(), LIB_EDIT_FRAME::RollbackPartFromUndo(), DRC_TOOL::RunTests(), PCB_EDIT_FRAME::SaveProjectSettings(), FOOTPRINT_EDIT_FRAME::SaveSettings(), SCH_EDIT_FRAME::SchematicCleanUp(), PCB_TOOL_BASE::selection(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), FOOTPRINT_EDIT_FRAME::setupTools(), CVPCB_MAINFRAME::setupTools(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), DIALOG_LIB_EDIT_TEXT::TransferDataFromWindow(), DIALOG_3D_VIEW_OPTIONS::TransferDataFromWindow(), DIALOG_FIELDS_EDITOR_GLOBAL::TransferDataToWindow(), DIALOG_LIB_EDIT_TEXT::TransferDataToWindow(), DIALOG_3D_VIEW_OPTIONS::TransferDataToWindow(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow(), LIB_DRAWING_TOOLS::TwoClickPlace(), LIB_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), PCB_EDITOR_CONTROL::UngroupSelected(), SYMBOL_UNIT_MENU::update(), BUS_UNFOLD_MENU::update(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), SCH_EDIT_FRAME::UpdateSymbolFromEditor(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ GetToolHolder()

◆ GetView()

◆ GetViewControls()

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

Definition at line 291 of file tool_manager.h.

291 { return m_viewControls; }
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:546

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

552 {
553  for( auto it = m_toolState.begin(); it != m_toolState.end(); /* iteration in the loop */ )
554  {
555  TOOL_BASE* tool = it->first;
556  TOOL_STATE* state = it->second;
557  setActiveState( state );
558  ++it; // keep the iterator valid if the element is going to be erased
559 
560  if( !tool->Init() )
561  {
562  wxMessageBox( wxString::Format( "Initialization of tool \"%s\" failed",
563  tool->GetName() ) );
564 
565  // Unregister the tool
566  setActiveState( nullptr );
567  m_toolState.erase( tool );
568  m_toolNameIndex.erase( tool->GetName() );
569  m_toolIdIndex.erase( tool->GetId() );
570  m_toolTypes.erase( typeid( *tool ).name() );
571 
572  delete state;
573  delete tool;
574  }
575  }
576 
577  m_actionMgr->UpdateHotKeys( true );
578 
580 }
virtual bool Init()
Function Init() Init() is called once upon a registration of the tool.
Definition: tool_base.h:92
ACTION_MANAGER * m_actionMgr
Instance of ACTION_MANAGER that handles TOOL_ACTIONs.
Definition: tool_manager.h:539
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:530
TOOL_ID GetId() const
Function GetId() Returns the unique identifier of the tool.
Definition: tool_base.h:121
Tool is invoked after being inactive.
Definition: tool_base.h:81
void UpdateHotKeys(bool aFullUpdate)
Optionally reads the hotkey config files and then rebuilds the internal hotkey maps.
NAME_STATE_MAP m_toolNameIndex
Index of the registered tools current states, associated by tools' names.
Definition: tool_manager.h:527
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:201
TOOL_BASE.
Definition: tool_base.h:67
const std::string & GetName() const
Function GetName() Returns the name of the tool.
Definition: tool_base.h:132
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:524
std::map< const char *, TOOL_BASE * > m_toolTypes
Index of the registered tools to easily lookup by their type.
Definition: tool_manager.h:533

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

Referenced by FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), PANEL_PREV_3D::PANEL_PREV_3D(), PL_EDITOR_FRAME::setupTools(), FOOTPRINT_EDIT_FRAME::setupTools(), LIB_VIEW_FRAME::setupTools(), KICAD_MANAGER_FRAME::setupTools(), GERBVIEW_FRAME::setupTools(), LIB_EDIT_FRAME::setupTools(), CVPCB_MAINFRAME::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 250 of file tool_manager.cpp.

251 {
252  TOOL_BASE* tool = FindTool( aToolId );
253 
254  if( tool && tool->GetType() == INTERACTIVE )
255  return invokeTool( tool );
256 
257  wxLogTrace( kicadTraceToolStack,
258  "TOOL_MANAGER::InvokeTool - No interactive tool with ID %d", aToolId );
259 
260  return false; // there is no tool with the given id
261 }
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:110
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:49
TOOL_BASE.
Definition: tool_base.h:67
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.
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, invokeTool(), and kicadTraceToolStack.

Referenced by TOOL_INTERACTIVE::Activate(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PANEL_PREV_3D::PANEL_PREV_3D(), PL_EDITOR_FRAME::setupTools(), FOOTPRINT_EDIT_FRAME::setupTools(), LIB_VIEW_FRAME::setupTools(), GERBVIEW_FRAME::setupTools(), and LIB_EDIT_FRAME::setupTools().

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

265 {
266  TOOL_BASE* tool = FindTool( aToolName );
267 
268  if( tool && tool->GetType() == INTERACTIVE )
269  return invokeTool( tool );
270 
271  wxLogTrace( kicadTraceToolStack,
272  "TOOL_MANAGER::InvokeTool - No interactive tool with name %s", aToolName );
273 
274  return false; // there is no tool with the given name
275 }
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:110
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:49
TOOL_BASE.
Definition: tool_base.h:67
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.
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, invokeTool(), and kicadTraceToolStack.

◆ invokeTool()

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

375 {
376  wxASSERT( aTool != NULL );
377 
378  TOOL_EVENT evt( TC_COMMAND, TA_ACTIVATE, aTool->GetName() );
380  processEvent( evt );
381 
382  if( TOOL_STATE* active = GetCurrentToolState() )
383  setActiveState( active );
384 
385  return true;
386 }
VECTOR2D GetCursorPosition()
bool processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
void SetMousePosition(const VECTOR2D &aP)
Definition: tool_event.h:468
#define NULL
void setActiveState(TOOL_STATE *aState)
Saves the previous active state and sets a new one.
TOOL_EVENT.
Definition: tool_event.h:171
TOOL_STATE * GetCurrentToolState() const
Returns the TOOL_STATE object representing the state of the active tool.
Definition: tool_manager.h:326
const std::string & GetName() const
Function GetName() Returns the name of the tool.
Definition: tool_base.h:132

References GetCurrentToolState(), GetCursorPosition(), TOOL_BASE::GetName(), NULL, processEvent(), setActiveState(), TOOL_EVENT::SetMousePosition(), TA_ACTIVATE, and TC_COMMAND.

Referenced by InvokeTool().

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

1035 {
1036  if( !isRegistered( aTool ) )
1037  return false;
1038 
1039  // Just check if the tool is on the active tools stack
1040  return std::find( m_activeTools.begin(), m_activeTools.end(), aTool->GetId() ) != m_activeTools.end();
1041 }
TOOL_ID GetId() const
Function GetId() Returns the unique identifier of the tool.
Definition: tool_base.h:121
bool isRegistered(TOOL_BASE *aTool) const
Function isRegistered() Returns information about a tool registration status.
Definition: tool_manager.h:483
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:536

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

Referenced by runTool(), and ShutdownTool().

◆ IsContextMenuActive()

bool TOOL_MANAGER::IsContextMenuActive ( )
inline

True while processing a context menu.

Definition at line 403 of file tool_manager.h.

404  {
405  return m_menuActive;
406  }
bool m_menuActive
Flag indicating whether a context menu is currently displayed.
Definition: tool_manager.h:559

References m_menuActive.

Referenced by DIALOG_SHIM::DIALOG_SHIM().

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

484  {
485  return m_toolState.count( aTool ) > 0;
486  }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:524

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

1149 {
1150  auto it = m_toolIdIndex.find( aId );
1151  return !it->second->idle;
1152 }
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:530

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

1015 {
1016  static int currentId;
1017 
1018  return currentId++;
1019 }

◆ PostEvent()

◆ PrimeTool()

void TOOL_MANAGER::PrimeTool ( const VECTOR2D aPosition)

Function PrimeTool() "Primes" a tool by sending a cursor left-click event with the mouse position set to the passed in position.

Parameters
aPositionis the mouse position to use in the event

Definition at line 348 of file tool_manager.cpp.

349 {
350  int modifiers = 0;
351  modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0;
352  modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0;
353  modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0;
354 
355  TOOL_EVENT evt( TC_MOUSE, TA_PRIME, BUT_LEFT | modifiers );
356  evt.SetMousePosition( aPosition );
357 
358  PostEvent( evt );
359 }
TOOL_EVENT.
Definition: tool_event.h:171
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:273

References BUT_LEFT, MD_ALT, MD_CTRL, MD_SHIFT, PostEvent(), TOOL_EVENT::SetMousePosition(), TA_PRIME, and TC_MOUSE.

Referenced by DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawZone(), and ROUTER_TOOL::MainLoop().

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

936 {
937  bool handled = processEvent( aEvent );
938 
939  TOOL_STATE* activeTool = GetCurrentToolState();
940 
941  if( activeTool )
942  setActiveState( activeTool );
943 
944  if( m_view && m_view->IsDirty() )
945  {
946  if( GetToolHolder() )
948 
949 #if defined( __WXMAC__ ) || defined( __WINDOWS__ )
950  wxTheApp->ProcessPendingEvents(); // required for updating brightening behind a popup menu
951 #endif
952  }
953 
954  UpdateUI( aEvent );
955 
956  return handled;
957 }
void UpdateUI(const TOOL_EVENT &aEvent)
Updates the status bar and synchronizes toolbars.
bool processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
virtual void RefreshCanvas()
Definition: tools_holder.h:152
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:326
KIGFX::VIEW * m_view
Definition: tool_manager.h:545
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:300
bool IsDirty() const
Function IsDirty() Returns true if any of the VIEW layers needs to be refreshened.
Definition: view.h:546

References GetCurrentToolState(), GetToolHolder(), KIGFX::VIEW::IsDirty(), m_view, processEvent(), TOOLS_HOLDER::RefreshCanvas(), setActiveState(), and UpdateUI().

Referenced by PL_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::AddItemToSel(), SELECTION_TOOL::AddItemToSel(), EDIT_TOOL::ChangeTrackWidth(), SELECTION_TOOL::ClearSelection(), PL_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), COMMON_TOOLS::CursorControl(), TOOL_DISPATCHER::DispatchWxCommand(), TOOL_DISPATCHER::DispatchWxEvent(), SELECTION_TOOL::expandConnection(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::findCallback(), EDIT_TOOL::Flip(), TOOL_DISPATCHER::handleMouseButton(), LIB_MOVE_TOOL::Main(), EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), ACTION_MENU::OnMenuEvent(), ACTION_TOOLBAR::onToolEvent(), PAD_TOOL::pastePadProperties(), PCBNEW_CONTROL::placeBoardItems(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RequestSelection(), EDIT_TOOL::Rotate(), EE_SELECTION_TOOL::SelectConnection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::SelectPoint(), SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), SCH_EDITOR_CONTROL::Undo(), GERBVIEW_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 1090 of file tool_manager.cpp.

1091 {
1092  wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::processEvent - %s", aEvent.Format() );
1093 
1094  // First try to dispatch the action associated with the event if it is a key press event
1095  bool handled = DispatchHotKey( aEvent );
1096 
1097  if( !handled )
1098  {
1099  TOOL_EVENT mod_event( aEvent );
1100 
1101  // Only immediate actions get the position. Otherwise clear for tool activation
1102  if( GetToolHolder() && !GetToolHolder()->GetDoImmediateActions() )
1103  {
1104  // An tool-selection-event has no position
1105  if( mod_event.GetCommandStr().is_initialized()
1106  && mod_event.GetCommandStr().get() != GetToolHolder()->CurrentToolName() )
1107  {
1108  mod_event.SetHasPosition( false );
1109  }
1110  }
1111 
1112  // If the event is not handled through a hotkey activation, pass it to the currently
1113  // running tool loops
1114  handled |= dispatchInternal( mod_event );
1115  handled |= dispatchActivation( mod_event );
1116 
1117  // Open the context menu if requested by a tool
1118  DispatchContextMenu( mod_event );
1119 
1120  // Dispatch any remaining events in the event queue
1121  while( !m_eventQueue.empty() )
1122  {
1123  TOOL_EVENT event = m_eventQueue.front();
1124  m_eventQueue.pop_front();
1125  processEvent( event );
1126  }
1127  }
1128 
1129  wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::processEvent - Handled: %s %s",
1130  ( handled ? "true" : "false" ), aEvent.Format() );
1131 
1132  return handled;
1133 }
void DispatchContextMenu(const TOOL_EVENT &aEvent)
Function DispatchContextMenu() Handles context menu related events.
const std::string Format() const
Function Format() Returns information about event in form of a human-readable string.
Definition: tool_event.cpp:73
bool processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
bool dispatchActivation(const TOOL_EVENT &aEvent)
Function dispatchActivation() Checks if it is a valid activation event and invokes a proper tool.
bool DispatchHotKey(const TOOL_EVENT &aEvent)
Function dispatchHotKey() Handles specific events, that are intended for TOOL_MANAGER rather than too...
TOOL_EVENT.
Definition: tool_event.h:171
std::string CurrentToolName() const
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:300
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:551
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.
bool dispatchInternal(const TOOL_EVENT &aEvent)
Function dispatchInternal Passes an event at first to the active tools, then to all others.

References TOOLS_HOLDER::CurrentToolName(), dispatchActivation(), DispatchContextMenu(), DispatchHotKey(), dispatchInternal(), TOOL_EVENT::Format(), TOOL_EVENT::GetCommandStr(), GetToolHolder(), kicadTraceToolStack, m_eventQueue, and TOOL_EVENT::SetHasPosition().

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

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

231 {
232  wxASSERT_MSG( m_toolNameIndex.find( aTool->GetName() ) == m_toolNameIndex.end(),
233  wxT( "Adding two tools with the same name may result in unexpected behaviour.") );
234  wxASSERT_MSG( m_toolIdIndex.find( aTool->GetId() ) == m_toolIdIndex.end(),
235  wxT( "Adding two tools with the same ID may result in unexpected behaviour.") );
236  wxASSERT_MSG( m_toolTypes.find( typeid( *aTool ).name() ) == m_toolTypes.end(),
237  wxT( "Adding two tools of the same type may result in unexpected behaviour.") );
238 
239  TOOL_STATE* st = new TOOL_STATE( aTool );
240 
241  m_toolState[aTool] = st;
242  m_toolNameIndex[aTool->GetName()] = st;
243  m_toolIdIndex[aTool->GetId()] = st;
244  m_toolTypes[typeid( *aTool ).name()] = st->theTool;
245 
246  aTool->attachManager( this );
247 }
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:530
TOOL_ID GetId() const
Function GetId() Returns the unique identifier of the tool.
Definition: tool_base.h:121
void attachManager(TOOL_MANAGER *aManager)
Function attachManager()
Definition: tool_base.cpp:60
NAME_STATE_MAP m_toolNameIndex
Index of the registered tools current states, associated by tools' names.
Definition: tool_manager.h:527
const std::string & GetName() const
Function GetName() Returns the name of the tool.
Definition: tool_base.h:132
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:524
std::map< const char *, TOOL_BASE * > m_toolTypes
Index of the registered tools to easily lookup by their type.
Definition: tool_manager.h:533

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(), PANEL_PREV_3D::PANEL_PREV_3D(), PL_EDITOR_FRAME::setupTools(), FOOTPRINT_EDIT_FRAME::setupTools(), LIB_VIEW_FRAME::setupTools(), KICAD_MANAGER_FRAME::setupTools(), GERBVIEW_FRAME::setupTools(), LIB_EDIT_FRAME::setupTools(), CVPCB_MAINFRAME::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 535 of file tool_manager.cpp.

536 {
537  DeactivateTool();
538 
539  for( auto& state : m_toolState )
540  {
541  TOOL_BASE* tool = state.first;
542  setActiveState( state.second );
543  tool->Reset( aReason );
544 
545  if( tool->GetType() == INTERACTIVE )
546  static_cast<TOOL_INTERACTIVE*>( tool )->resetTransitions();
547  }
548 }
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:110
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:49
void setActiveState(TOOL_STATE *aState)
Saves the previous active state and sets a new one.
TOOL_BASE.
Definition: tool_base.h:67
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:524

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

Referenced by PCB_BASE_FRAME::ActivateGalCanvas(), GERBVIEW_FRAME::ActivateGalCanvas(), GERBVIEW_FRAME::Clear_DrawLayers(), FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList(), GERBVIEW_FRAME::Erase_Current_DrawLayer(), InitTools(), LIB_CONTROL::OnDeMorgan(), LIB_EDIT_FRAME::OnSelectUnit(), FOOTPRINT_WIZARD_FRAME::ReloadFootprint(), PCB_BASE_EDIT_FRAME::SetBoard(), LIB_EDIT_FRAME::SetCurPart(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), DISPLAY_FOOTPRINTS_FRAME::updateView(), FOOTPRINT_WIZARD_FRAME::updateView(), FOOTPRINT_VIEWER_FRAME::updateView(), and FOOTPRINT_EDIT_FRAME::updateView().

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

141  {
142  return RunAction( aActionName, aNow, reinterpret_cast<void*>( aParam ) );
143  }
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140

Referenced by DIALOG_GLOBAL_DELETION::AcceptPcbDelete(), TREEPROJECT_ITEM::Activate(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), LIB_CONTROL::AddSymbolToSchematic(), SCH_MOVE_TOOL::AlignElements(), APPEARANCE_CONTROLS::APPEARANCE_CONTROLS(), SCH_EDIT_FRAME::AppendSchematic(), CVPCB_ASSOCIATION_TOOL::Associate(), SCH_EDIT_TOOL::AutoplaceFields(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), SELECTION_TOOL::ClearSelection(), ZONE_CREATE_HELPER::commitZone(), SCH_EDIT_TOOL::ConvertDeMorgan(), SCH_EDIT_FRAME::ConvertPart(), MICROWAVE_TOOL::createInductorBetween(), LIB_EDIT_FRAME::CreateNewPart(), COMMON_TOOLS::CursorControl(), SCH_EDITOR_CONTROL::Cut(), LIB_VIEW_FRAME::DClickOnCmpList(), DIALOG_ERC::deleteAllMarkers(), DIALOG_DRC::deleteAllMarkers(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), DIALOG_MIGRATE_BUSES::DIALOG_MIGRATE_BUSES(), SCH_EDIT_FRAME::DisplayCurrentSheet(), DIALOG_CLEANUP_GRAPHICS::doCleanup(), DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup(), SIM_PLOT_FRAME::doCloseWindow(), LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), PCB_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), LIB_EDIT_FRAME::emptyScreen(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), TRACK_WIDTH_MENU::eventHandler(), DIFF_PAIR_MENU::eventHandler(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SCH_EDIT_FRAME::ExecuteRemoteCommand(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), PAD_TOOL::explodePad(), SCH_EDITOR_CONTROL::FindComponentAndItem(), POINT_EDITOR::finishItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), GERBVIEW_FRAME::GERBVIEW_FRAME(), EDIT_TOOL::GetAndPlace(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), DRAWING_TOOL::getSourceZoneForAction(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::GroupFlattenSelected(), PCB_EDITOR_CONTROL::GroupMergeSelected(), PCB_EDITOR_CONTROL::GroupRemoveItemsSelected(), PCB_EDITOR_CONTROL::GroupSelected(), PCB_INSPECTION_TOOL::HighlightItem(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), SCH_EDIT_FRAME::importFile(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::ImportWorksheetContent(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), SCH_EDIT_FRAME::KiwayMailIn(), PCB_EDIT_FRAME::KiwayMailIn(), SCH_EDITOR_CONTROL::LeaveSheet(), LIB_VIEW_FRAME::LIB_VIEW_FRAME(), LIB_EDIT_FRAME::LoadComponentFromCurrentLib(), LIB_EDIT_FRAME::LoadOneLibraryPartAux(), LIB_EDIT_FRAME::LoadSymbolFromSchematic(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), SYMBOL_TREE_PANE::onComponentSelected(), DIALOG_DRC::OnDeleteOneClick(), LIB_CONTROL::OnDeMorgan(), DIALOG_ERC::OnERCItemSelected(), ZONE_CREATE_HELPER::OnFirstPoint(), KICAD_MANAGER_FRAME::OnIdle(), FOOTPRINTS_LISTBOX::OnLeftDClick(), ACTION_MENU::OnMenuEvent(), APPEARANCE_CONTROLS::onNetclassContextMenu(), APPEARANCE_CONTROLS::onNetContextMenu(), PL_EDITOR_FRAME::OnNewPageLayout(), KICAD_MANAGER_FRAME::OnOpenFileInTextEditor(), SIM_PLOT_FRAME::onProbe(), EDA_DRAW_FRAME::OnSelectGrid(), DIALOG_POSITION_RELATIVE::OnSelectItemClick(), HIERARCHY_NAVIG_DLG::onSelectSheetPath(), LIB_EDIT_FRAME::OnSelectUnit(), EDA_DRAW_FRAME::OnSelectZoom(), SCH_EDIT_FRAME::onSize(), SIM_PLOT_FRAME::onTune(), SCH_EDIT_FRAME::OpenProjectFiles(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), ZONE_CREATE_HELPER::performZoneCutout(), EDIT_TOOL::pickReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCBNEW_CONTROL::Print(), GERBVIEW_CONTROL::Print(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), SCH_EDIT_FRAME::PutDataInPreviousState(), CVPCB_MAINFRAME::refreshAfterComponentSearch(), SCH_EDIT_TOOL::RefreshSymbolFromLibrary(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), SELECTION_TOOL::RequestSelection(), PL_EDITOR_FRAME::RollbackFromUndo(), 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(), DIALOG_FIND::search(), PL_SELECTION_TOOL::SelectPoint(), EE_SELECTION_TOOL::SelectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), GERBVIEW_FRAME::SetActiveLayer(), DRAWING_TOOL::SetAnchor(), LIB_EDIT_FRAME::SetCurPart(), LIB_VIEW_FRAME::SetSelectedComponent(), CVPCB_MAINFRAME::setupEventHandlers(), SCH_EDIT_FRAME::setupTools(), DRC_TOOL::ShowDRCDialog(), APPEARANCE_CONTROLS::showNetclass(), SCH_DRAWING_TOOLS::SingleClickPlace(), PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), PCB_EDITOR_CONTROL::UngroupSelected(), PCB_BASE_FRAME::unitsChangeRefresh(), NET_GRID_TABLE::updateNetVisibility(), SCH_EDIT_FRAME::UpdateSymbolFromEditor(), DISPLAY_FOOTPRINTS_FRAME::updateView(), FOOTPRINT_WIZARD_FRAME::updateView(), FOOTPRINT_VIEWER_FRAME::updateView(), FOOTPRINT_EDIT_FRAME::updateView(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCB_EDITOR_CONTROL::ZoneMerge(), EDA_DRAW_FRAME::Zoom_Automatique(), DIALOG_NETLIST::~DIALOG_NETLIST(), and DIALOG_UPDATE_PCB::~DIALOG_UPDATE_PCB().

◆ RunAction() [2/6]

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

Definition at line 278 of file tool_manager.cpp.

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:539
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
TOOL_ACTION * FindAction(const std::string &aActionName) const
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:201
Represents a single user action.
Definition: tool_action.h:44

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

148  {
149  return RunAction( aActionName, aNow, (void*) NULL );
150  }
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
#define NULL

References NULL, and RunAction().

◆ RunAction() [4/6]

template<typename T >
bool TOOL_MANAGER::RunAction ( const TOOL_ACTION aAction,
bool  aNow = false,
aParam = NULL 
)
inline

Function RunAction() Runs the specified action.

This function will only return if the action has been handled when the action is run immediately (aNow = true), otherwise it will always return false.

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.
Returns
True if the action was handled immediately

Definition at line 168 of file tool_manager.h.

169  {
170  return RunAction( aAction, aNow, reinterpret_cast<void*>( aParam ) );
171  }
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140

References RunAction().

◆ RunAction() [5/6]

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

Definition at line 312 of file tool_manager.cpp.

313 {
314  bool handled = false;
315  TOOL_EVENT event = aAction.MakeEvent();
316 
317  if( event.Category() == TC_COMMAND )
319 
320  // Allow to override the action parameter
321  if( aParam )
322  event.SetParameter( aParam );
323 
324  if( aNow )
325  {
326  TOOL_STATE* current = m_activeState;
327  handled = processEvent( event );
328  setActiveState( current );
329  UpdateUI( event );
330  }
331  else
332  {
333  PostEvent( event );
334  }
335 
336  return handled;
337 }
VECTOR2D GetCursorPosition()
void UpdateUI(const TOOL_EVENT &aEvent)
Updates the status bar and synchronizes toolbars.
bool processEvent(const TOOL_EVENT &aEvent)
Main function for event processing.
void SetMousePosition(const VECTOR2D &aP)
Definition: tool_event.h:468
void setActiveState(TOOL_STATE *aState)
Saves the previous active state and sets a new one.
TOOL_EVENT.
Definition: tool_event.h:171
TOOL_STATE * m_activeState
Pointer to the state object corresponding to the currently executed tool.
Definition: tool_manager.h:565
TOOL_EVENT MakeEvent() const
Returns the event associated with the action (i.e.
Definition: tool_action.h:113
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:273

References GetCursorPosition(), m_activeState, TOOL_ACTION::MakeEvent(), PostEvent(), processEvent(), setActiveState(), TOOL_EVENT::SetMousePosition(), TC_COMMAND, and UpdateUI().

◆ RunAction() [6/6]

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

Definition at line 175 of file tool_manager.h.

176  {
177  return RunAction( aAction, aNow, (void*) NULL );
178  }
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
#define NULL

References NULL, and RunAction().

◆ RunMainStack()

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

Definition at line 614 of file tool_manager.cpp.

615 {
616  TOOL_STATE* st = m_toolState[aTool];
617  setActiveState( st );
618  st->cofunc->RunMainStack( std::move( aFunc ) );
619 }
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:524

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

Referenced by TOOL_INTERACTIVE::RunMainStack().

◆ runTool()

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

390 {
391  wxASSERT( aTool != NULL );
392 
393  if( !isRegistered( aTool ) )
394  {
395  wxASSERT_MSG( false, wxT( "You cannot run unregistered tools" ) );
396  return false;
397  }
398 
399  TOOL_ID id = aTool->GetId();
400 
401  if( aTool->GetType() == INTERACTIVE )
402  static_cast<TOOL_INTERACTIVE*>( aTool )->resetTransitions();
403 
404  // If the tool is already active, bring it to the top of the active tools stack
405  if( isActive( aTool ) && m_activeTools.size() > 1 )
406  {
407  auto it = std::find( m_activeTools.begin(), m_activeTools.end(), id );
408 
409  if( it != m_activeTools.end() )
410  {
411  if( it != m_activeTools.begin() )
412  {
413  m_activeTools.erase( it );
414  m_activeTools.push_front( id );
415  }
416 
417  return false;
418  }
419  }
420 
422  aTool->Reset( TOOL_INTERACTIVE::RUN );
423 
424  // Add the tool on the front of the processing queue (it gets events first)
425  m_activeTools.push_front( id );
426 
427  return true;
428 }
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:110
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:530
TOOL_ID GetId() const
Function GetId() Returns the unique identifier of the tool.
Definition: tool_base.h:121
Tool is invoked after being inactive.
Definition: tool_base.h:81
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:56
Tool that interacts with the user
Definition: tool_base.h:49
#define NULL
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:483
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:536

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

Referenced by dispatchActivation().

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

971 {
972  if( wxTheClipboard->Open() )
973  {
974  wxTheClipboard->SetData( new wxTextDataObject( wxString( aText.c_str(), wxConvUTF8 ) ) );
975  wxTheClipboard->Close();
976 
977  return true;
978  }
979 
980  return false;
981 }

Referenced by LIB_EDIT_TOOL::Copy(), PL_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 1044 of file tool_manager.cpp.

1045 {
1046  aState->vcSettings = m_viewControls->GetSettings();
1047 
1048  if( m_menuActive )
1049  {
1050  // Context menu is active, so the cursor settings are overridden (see DispatchContextMenu())
1051  auto it = m_cursorSettings.find( aState->theTool->GetId() );
1052 
1053  if( it != m_cursorSettings.end() )
1054  {
1056 
1057  // Tool has overridden the cursor position, so store the new settings
1058  if( !curr.m_forceCursorPosition || curr.m_forcedPosition != m_menuCursor )
1059  {
1060  if( !curr.m_forceCursorPosition )
1061  it->second = NULLOPT;
1062  else
1063  it->second = curr.m_forcedPosition;
1064  }
1065  else
1066  {
1067  OPT<VECTOR2D> cursor = it->second;
1068 
1069  if( cursor )
1070  {
1071  aState->vcSettings.m_forceCursorPosition = true;
1072  aState->vcSettings.m_forcedPosition = *cursor;
1073  }
1074  else
1075  {
1076  aState->vcSettings.m_forceCursorPosition = false;
1077  }
1078  }
1079  }
1080  }
1081 }
bool m_menuActive
Flag indicating whether a context menu is currently displayed.
Definition: tool_manager.h:559
VECTOR2D m_menuCursor
Right click context menu position.
Definition: tool_manager.h:554
std::map< TOOL_ID, OPT< VECTOR2D > > m_cursorSettings
Original cursor position, if overridden by the context menu handler.
Definition: tool_manager.h:542
VECTOR2D m_forcedPosition
Forced cursor position (world coordinates)
Definition: view_controls.h:69
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:72
Structure to keep VIEW_CONTROLS settings for easy store/restore operations
Definition: view_controls.h:55
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:546
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 960 of file tool_manager.cpp.

962 {
963  TOOL_STATE* st = m_toolState[aTool];
964 
965  st->contextMenu = aMenu;
966  st->contextMenuTrigger = aTrigger;
967 }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:524

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

601 {
602  TOOL_STATE* st = m_toolState[aTool];
603 
604  st->transitions.emplace_back( TRANSITION( aConditions, aHandler ) );
605 }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:524
std::pair< TOOL_EVENT_LIST, TOOL_STATE_FUNC > TRANSITION
Definition: tool_manager.h:433

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

Referenced by TOOL_INTERACTIVE::goInternal().

◆ ScheduleWait()

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

623 {
624  TOOL_STATE* st = m_toolState[aTool];
625 
626  wxASSERT( !st->pendingWait ); // everything collapses on two KiYield() in a row
627 
628  // indicate to the manager that we are going to sleep and we shall be
629  // woken up when an event matching aConditions arrive
630  st->pendingWait = true;
631  st->waitEvents = aConditions;
632 
633  // switch context back to event dispatcher loop
634  st->cofunc->KiYield();
635 
636  // If the tool should shutdown, it gets a null event to break the loop
637  if( st->shutdown )
638  return nullptr;
639  else
640  return &st->wakeupEvent;
641 }
TOOL_STATE_MAP m_toolState
Index of registered tools current states, associated by tools' objects.
Definition: tool_manager.h:524

References TOOL_MANAGER::TOOL_STATE::cofunc, COROUTINE< ReturnType, ArgType >::KiYield(), m_toolState, TOOL_MANAGER::TOOL_STATE::pendingWait, TOOL_MANAGER::TOOL_STATE::shutdown, 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 1136 of file tool_manager.cpp.

1137 {
1138  if( m_activeState && m_viewControls )
1140 
1141  m_activeState = aState;
1142 
1143  if( m_activeState && m_viewControls )
1144  applyViewControls( aState );
1145 }
void applyViewControls(TOOL_STATE *aState)
Function applyViewControls() Applies VIEW_CONTROLS settings stored in a TOOL_STATE object.
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:546
TOOL_STATE * m_activeState
Pointer to the state object corresponding to the currently executed tool.
Definition: tool_manager.h:565
void saveViewControls(TOOL_STATE *aState)
Function saveViewControls() Saves the VIEW_CONTROLS settings to the tool state object.

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

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

◆ SetEnvironment()

void TOOL_MANAGER::SetEnvironment ( EDA_ITEM aModel,
KIGFX::VIEW aView,
KIGFX::VIEW_CONTROLS aViewControls,
APP_SETTINGS_BASE aSettings,
TOOLS_HOLDER 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 when it is set up.

Definition at line 1022 of file tool_manager.cpp.

1025 {
1026  m_model = aModel;
1027  m_view = aView;
1028  m_viewControls = aViewControls;
1029  m_frame = aFrame;
1030  m_settings = aSettings;
1031 }
TOOLS_HOLDER * m_frame
Definition: tool_manager.h:547
EDA_ITEM * m_model
Definition: tool_manager.h:544
KIGFX::VIEW_CONTROLS * m_viewControls
Definition: tool_manager.h:546
KIGFX::VIEW * m_view
Definition: tool_manager.h:545
APP_SETTINGS_BASE * m_settings
Definition: tool_manager.h:548

References m_frame, m_model, m_settings, m_view, and m_viewControls.

Referenced by PCB_BASE_FRAME::ActivateGalCanvas(), GERBVIEW_FRAME::ActivateGalCanvas(), DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME(), EVT_GRID_CMD_CELL_CHANGED(), EVT_TOOL_RANGE(), FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), PANEL_PREV_3D::PANEL_PREV_3D(), PCB_BASE_EDIT_FRAME::SetBoard(), PL_EDITOR_FRAME::setupTools(), PCB_EDIT_FRAME::setupTools(), FOOTPRINT_EDIT_FRAME::setupTools(), LIB_VIEW_FRAME::setupTools(), KICAD_MANAGER_FRAME::setupTools(), GERBVIEW_FRAME::setupTools(), LIB_EDIT_FRAME::setupTools(), CVPCB_MAINFRAME::setupTools(), and SCH_EDIT_FRAME::setupTools().

◆ ShutdownAllTools()

void TOOL_MANAGER::ShutdownAllTools ( )

Shutdown all tools with a currently registered event loop in this tool manager by waking them up with a null event.

Definition at line 431 of file tool_manager.cpp.

432 {
433  // Create a temporary list of tools to iterate over since when the tools shutdown
434  // they remove themselves from the list automatically (invalidating the iterator)
435  ID_LIST tmpList = m_activeTools;
436 
437  for( auto id : tmpList )
438  {
439  ShutdownTool( id );
440  }
441 }
void ShutdownTool(TOOL_BASE *aTool)
Shutdown the specified tool by waking it up with a null event to terminate the processing loop.
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:536
std::list< TOOL_ID > ID_LIST
Definition: tool_manager.h:65

References m_activeTools, and ShutdownTool().

Referenced by SCH_EDIT_FRAME::doCloseWindow(), CVPCB_MAINFRAME::~CVPCB_MAINFRAME(), DISPLAY_FOOTPRINTS_FRAME::~DISPLAY_FOOTPRINTS_FRAME(), FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME(), FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME(), GERBVIEW_FRAME::~GERBVIEW_FRAME(), KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME(), LIB_EDIT_FRAME::~LIB_EDIT_FRAME(), LIB_VIEW_FRAME::~LIB_VIEW_FRAME(), PL_EDITOR_FRAME::~PL_EDITOR_FRAME(), and SCH_EDIT_FRAME::~SCH_EDIT_FRAME().

◆ ShutdownTool() [1/3]

void TOOL_MANAGER::ShutdownTool ( TOOL_BASE aTool)

Shutdown the specified tool by waking it up with a null event to terminate the processing loop.

Parameters
aToolis the tool to shutdown

Definition at line 468 of file tool_manager.cpp.

469 {
470  wxASSERT( aTool != NULL );
471 
472  TOOL_ID id = aTool->GetId();
473 
474  if( isActive( aTool ) )
475  {
476  auto it = std::find( m_activeTools.begin(), m_activeTools.end(), id );
477 
478  TOOL_STATE* st = m_toolIdIndex[*it];
479 
480  // the tool state handler is waiting for events (i.e. called Wait() method)
481  if( st && st->pendingWait )
482  {
483  // Wake up the tool and tell it to shutdown
484  st->shutdown = true;
485  st->pendingWait = false;
486  st->waitEvents.clear();
487 
488  if( st->cofunc )
489  {
490  wxLogTrace( kicadTraceToolStack,
491  "TOOL_MANAGER::ShutdownTool - Shutting down tool %s",
492  st->theTool->GetName() );
493 
494  setActiveState( st );
495  bool end = !st->cofunc->Resume();
496 
497  if( end )
498  finishTool( st );
499  }
500  }
501  }
502 }
ID_STATE_MAP m_toolIdIndex
Index of the registered tools current states, associated by tools' ID numbers.
Definition: tool_manager.h:530
TOOL_ID GetId() const
Function GetId() Returns the unique identifier of the tool.
Definition: tool_base.h:121
ID_LIST::iterator finishTool(TOOL_STATE *aState)
Function finishTool() Deactivates a tool and does the necessary clean up.
int TOOL_ID
Unique identifier for tools.
Definition: tool_base.h:56
#define NULL
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.
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.
ID_LIST m_activeTools
Stack of the active tools.
Definition: tool_manager.h:536

References finishTool(), TOOL_BASE::GetId(), isActive(), kicadTraceToolStack, m_activeTools, m_toolIdIndex, NULL, and setActiveState().

Referenced by ShutdownAllTools(), and ShutdownTool().

◆ ShutdownTool() [2/3]

void TOOL_MANAGER::ShutdownTool ( TOOL_ID  aToolId)

Shutdown the specified tool by waking it up with a null event to terminate the processing loop.

Parameters
aToolIdis the ID of the tool to shutdown

Definition at line 444 of file tool_manager.cpp.

445 {
446  TOOL_BASE* tool = FindTool( aToolId );
447 
448  if( tool && tool->GetType() == INTERACTIVE )
449  ShutdownTool( tool );
450 
451  wxLogTrace( kicadTraceToolStack,
452  "TOOL_MANAGER::ShutdownTool - No interactive tool with ID %d", aToolId );
453 }
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:110
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
void ShutdownTool(TOOL_BASE *aTool)
Shutdown the specified tool by waking it up with a null event to terminate the processing loop.
Tool that interacts with the user
Definition: tool_base.h:49
TOOL_BASE.
Definition: tool_base.h:67
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.

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

◆ ShutdownTool() [3/3]

void TOOL_MANAGER::ShutdownTool ( const std::string &  aToolName)

Shutdown the specified tool by waking it up with a null event to terminate the processing loop.

Parameters
aToolNameis name of the tool to shutdown

Definition at line 456 of file tool_manager.cpp.

457 {
458  TOOL_BASE* tool = FindTool( aToolName );
459 
460  if( tool && tool->GetType() == INTERACTIVE )
461  ShutdownTool( tool );
462 
463  wxLogTrace( kicadTraceToolStack,
464  "TOOL_MANAGER::ShutdownTool - No interactive tool with name %s", aToolName );
465 }
TOOL_TYPE GetType() const
Function GetType() Returns the type of the tool.
Definition: tool_base.h:110
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
void ShutdownTool(TOOL_BASE *aTool)
Shutdown the specified tool by waking it up with a null event to terminate the processing loop.
Tool that interacts with the user
Definition: tool_base.h:49
TOOL_BASE.
Definition: tool_base.h:67
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.

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

◆ UpdateUI()

void TOOL_MANAGER::UpdateUI ( const TOOL_EVENT aEvent)

Updates the status bar and synchronizes toolbars.

Definition at line 1155 of file tool_manager.cpp.

1156 {
1157  EDA_BASE_FRAME* frame = dynamic_cast<EDA_BASE_FRAME*>( GetToolHolder() );
1158 
1159  if( frame )
1160  frame->UpdateStatusBar();
1161 }
virtual void UpdateStatusBar()
Update the status bar information.
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:300
The base frame for deriving all KiCad main window classes.

References GetToolHolder(), and EDA_BASE_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 413 of file tool_manager.h.

414  {
416  }
bool m_warpMouseAfterContextMenu
Definition: tool_manager.h:556

References m_warpMouseAfterContextMenu.

Referenced by DIALOG_SHIM::DIALOG_SHIM(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), LIB_TREE::onContextMenu(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

Member Data Documentation

◆ m_actionMgr

ACTION_MANAGER* TOOL_MANAGER::m_actionMgr
private

Instance of ACTION_MANAGER that handles TOOL_ACTIONs.

Definition at line 539 of file tool_manager.h.

Referenced by DispatchHotKey(), GetActionManager(), GetActions(), GetHotKey(), InitTools(), RunAction(), TOOL_MANAGER(), and ~TOOL_MANAGER().

◆ m_activeState

TOOL_STATE* TOOL_MANAGER::m_activeState
private

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

Definition at line 565 of file tool_manager.h.

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

◆ m_activeTools

ID_LIST TOOL_MANAGER::m_activeTools
private

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

Referenced by DispatchContextMenu(), and saveViewControls().

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

Referenced by PostEvent(), and processEvent().

◆ m_frame

TOOLS_HOLDER* TOOL_MANAGER::m_frame
private

Definition at line 547 of file tool_manager.h.

Referenced by DispatchContextMenu(), GetToolHolder(), and SetEnvironment().

◆ m_menuActive

bool TOOL_MANAGER::m_menuActive
private

Flag indicating whether a context menu is currently displayed.

Definition at line 559 of file tool_manager.h.

Referenced by DispatchContextMenu(), IsContextMenuActive(), and saveViewControls().

◆ m_menuCursor

VECTOR2D TOOL_MANAGER::m_menuCursor
private

Right click context menu position.

Definition at line 554 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 562 of file tool_manager.h.

Referenced by DispatchContextMenu(), and dispatchInternal().

◆ m_model

EDA_ITEM* TOOL_MANAGER::m_model
private

Definition at line 544 of file tool_manager.h.

Referenced by GetModel(), and SetEnvironment().

◆ m_settings

APP_SETTINGS_BASE* TOOL_MANAGER::m_settings
private

Definition at line 548 of file tool_manager.h.

Referenced by GetSettings(), and SetEnvironment().

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

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

◆ m_toolNameIndex

NAME_STATE_MAP TOOL_MANAGER::m_toolNameIndex
private

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

Definition at line 527 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 524 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 533 of file tool_manager.h.

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

◆ m_view

KIGFX::VIEW* TOOL_MANAGER::m_view
private

Definition at line 545 of file tool_manager.h.

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

◆ m_viewControls

◆ m_warpMouseAfterContextMenu

bool TOOL_MANAGER::m_warpMouseAfterContextMenu
private

Definition at line 556 of file tool_manager.h.

Referenced by DispatchContextMenu(), and VetoContextMenuMouseWarp().


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