KiCad PCB EDA Suite
TOOL_MANAGER::TOOL_STATE Struct Reference

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

Public Member Functions

 TOOL_STATE (TOOL_BASE *aTool)
 
 TOOL_STATE (const TOOL_STATE &aState)
 
 ~TOOL_STATE ()
 
void operator= (const TOOL_STATE &aState)
 
bool operator== (const TOOL_MANAGER::TOOL_STATE &aRhs) const
 
bool operator!= (const TOOL_MANAGER::TOOL_STATE &aRhs) const
 
void Push ()
 Function Push() Stores the current state of the tool on stack. More...
 
bool Pop ()
 Function Pop() Restores state of the tool from stack. More...
 

Public Attributes

TOOL_BASEtheTool
 The tool itself. More...
 
bool idle
 Is the tool active (pending execution) or disabled at the moment. More...
 
bool pendingWait
 Flag defining if the tool is waiting for any event (i.e. More...
 
bool pendingContextMenu
 Is there a context menu being displayed. More...
 
CONTEXT_MENUcontextMenu
 Context menu currently used by the tool. More...
 
CONTEXT_MENU_TRIGGER contextMenuTrigger
 Defines when the context menu is opened. More...
 
COROUTINE< int, const TOOL_EVENT & > * cofunc
 Tool execution context. More...
 
TOOL_EVENT wakeupEvent
 The event that triggered the execution/wakeup of the tool after Wait() call. More...
 
TOOL_EVENT_LIST waitEvents
 List of events the tool is currently waiting for. More...
 
std::vector< TRANSITIONtransitions
 List of possible transitions (ie. More...
 
KIGFX::VC_SETTINGS vcSettings
 VIEW_CONTROLS settings to preserve settings when the tools are switched. More...
 

Private Member Functions

void clear ()
 

Restores the initial state.

More...
 

Private Attributes

std::stack< std::unique_ptr< TOOL_STATE > > stateStack
 

Stack preserving previous states of a TOOL.

More...
 

Detailed Description

Struct describing the current execution state of a TOOL.

Definition at line 50 of file tool_manager.cpp.

Constructor & Destructor Documentation

TOOL_MANAGER::TOOL_STATE::TOOL_STATE ( TOOL_BASE aTool)
inline

Definition at line 52 of file tool_manager.cpp.

References clear().

52  :
53  theTool( aTool )
54  {
55  clear();
56  }
TOOL_BASE * theTool
The tool itself.
void clear()
Restores the initial state.
TOOL_MANAGER::TOOL_STATE::TOOL_STATE ( const TOOL_STATE aState)
inline

Definition at line 58 of file tool_manager.cpp.

References cofunc, contextMenu, contextMenuTrigger, idle, pendingContextMenu, pendingWait, theTool, transitions, vcSettings, waitEvents, and wakeupEvent.

59  {
60  theTool = aState.theTool;
61  idle = aState.idle;
62  pendingWait = aState.pendingWait;
63  pendingContextMenu = aState.pendingContextMenu;
64  contextMenu = aState.contextMenu;
65  contextMenuTrigger = aState.contextMenuTrigger;
66  cofunc = aState.cofunc;
67  wakeupEvent = aState.wakeupEvent;
68  waitEvents = aState.waitEvents;
69  transitions = aState.transitions;
70  vcSettings = aState.vcSettings;
71  // do not copy stateStack
72  }
TOOL_BASE * theTool
The tool itself.
std::vector< TRANSITION > transitions
List of possible transitions (ie.
KIGFX::VC_SETTINGS vcSettings
VIEW_CONTROLS settings to preserve settings when the tools are switched.
bool pendingWait
Flag defining if the tool is waiting for any event (i.e.
bool pendingContextMenu
Is there a context menu being displayed.
bool idle
Is the tool active (pending execution) or disabled at the moment.
CONTEXT_MENU * contextMenu
Context menu currently used by the tool.
TOOL_EVENT wakeupEvent
The event that triggered the execution/wakeup of the tool after Wait() call.
COROUTINE< int, const TOOL_EVENT & > * cofunc
Tool execution context.
CONTEXT_MENU_TRIGGER contextMenuTrigger
Defines when the context menu is opened.
TOOL_EVENT_LIST waitEvents
List of events the tool is currently waiting for.
TOOL_MANAGER::TOOL_STATE::~TOOL_STATE ( )
inline

Definition at line 74 of file tool_manager.cpp.

References stateStack.

75  {
76  assert( stateStack.empty() );
77  }
std::stack< std::unique_ptr< TOOL_STATE > > stateStack
Stack preserving previous states of a TOOL.

Member Function Documentation

void TOOL_MANAGER::TOOL_STATE::clear ( )
inlineprivate

Restores the initial state.

Definition at line 180 of file tool_manager.cpp.

References CMENU_OFF, and KIGFX::VC_SETTINGS::Reset().

Referenced by Push(), and TOOL_STATE().

181  {
182  idle = true;
183  pendingWait = false;
184  pendingContextMenu = false;
185  cofunc = NULL;
186  contextMenu = NULL;
188  vcSettings.Reset();
189  transitions.clear();
190  }
void Reset()
Restores the default settings
std::vector< TRANSITION > transitions
List of possible transitions (ie.
KIGFX::VC_SETTINGS vcSettings
VIEW_CONTROLS settings to preserve settings when the tools are switched.
bool pendingWait
Flag defining if the tool is waiting for any event (i.e.
bool pendingContextMenu
Is there a context menu being displayed.
bool idle
Is the tool active (pending execution) or disabled at the moment.
CONTEXT_MENU * contextMenu
Context menu currently used by the tool.
COROUTINE< int, const TOOL_EVENT & > * cofunc
Tool execution context.
CONTEXT_MENU_TRIGGER contextMenuTrigger
Defines when the context menu is opened.
bool TOOL_MANAGER::TOOL_STATE::operator!= ( const TOOL_MANAGER::TOOL_STATE aRhs) const
inline

Definition at line 135 of file tool_manager.cpp.

References theTool.

136  {
137  return aRhs.theTool != this->theTool;
138  }
TOOL_BASE * theTool
The tool itself.
void TOOL_MANAGER::TOOL_STATE::operator= ( const TOOL_STATE aState)
inline

Definition at line 114 of file tool_manager.cpp.

References cofunc, contextMenu, contextMenuTrigger, idle, pendingContextMenu, pendingWait, theTool, transitions, vcSettings, waitEvents, and wakeupEvent.

115  {
116  theTool = aState.theTool;
117  idle = aState.idle;
118  pendingWait = aState.pendingWait;
119  pendingContextMenu = aState.pendingContextMenu;
120  contextMenu = aState.contextMenu;
121  contextMenuTrigger = aState.contextMenuTrigger;
122  cofunc = aState.cofunc;
123  wakeupEvent = aState.wakeupEvent;
124  waitEvents = aState.waitEvents;
125  transitions = aState.transitions;
126  vcSettings = aState.vcSettings;
127  // do not copy stateStack
128  }
TOOL_BASE * theTool
The tool itself.
std::vector< TRANSITION > transitions
List of possible transitions (ie.
KIGFX::VC_SETTINGS vcSettings
VIEW_CONTROLS settings to preserve settings when the tools are switched.
bool pendingWait
Flag defining if the tool is waiting for any event (i.e.
bool pendingContextMenu
Is there a context menu being displayed.
bool idle
Is the tool active (pending execution) or disabled at the moment.
CONTEXT_MENU * contextMenu
Context menu currently used by the tool.
TOOL_EVENT wakeupEvent
The event that triggered the execution/wakeup of the tool after Wait() call.
COROUTINE< int, const TOOL_EVENT & > * cofunc
Tool execution context.
CONTEXT_MENU_TRIGGER contextMenuTrigger
Defines when the context menu is opened.
TOOL_EVENT_LIST waitEvents
List of events the tool is currently waiting for.
bool TOOL_MANAGER::TOOL_STATE::operator== ( const TOOL_MANAGER::TOOL_STATE aRhs) const
inline

Definition at line 130 of file tool_manager.cpp.

References theTool.

131  {
132  return aRhs.theTool == this->theTool;
133  }
TOOL_BASE * theTool
The tool itself.
bool TOOL_MANAGER::TOOL_STATE::Pop ( )
inline

Function Pop() Restores state of the tool from stack.

Stacks are stored internally and are not shared between different TOOL_STATE objects.

Returns
True if state was restored, false if the stack was empty.

Definition at line 158 of file tool_manager.cpp.

References cofunc, and stateStack.

Referenced by TOOL_MANAGER::finishTool().

159  {
160  delete cofunc;
161 
162  if( !stateStack.empty() )
163  {
164  *this = *stateStack.top().get();
165  stateStack.pop();
166  return true;
167  }
168  else
169  {
170  cofunc = NULL;
171  return false;
172  }
173  }
std::stack< std::unique_ptr< TOOL_STATE > > stateStack
Stack preserving previous states of a TOOL.
COROUTINE< int, const TOOL_EVENT & > * cofunc
Tool execution context.
void TOOL_MANAGER::TOOL_STATE::Push ( )
inline

Function Push() Stores the current state of the tool on stack.

Stacks are stored internally and are not shared between different TOOL_STATE objects.

Definition at line 145 of file tool_manager.cpp.

References clear(), and stateStack.

Referenced by TOOL_MANAGER::dispatchInternal().

146  {
147  auto state = std::make_unique<TOOL_STATE>( *this );
148  stateStack.push( std::move( state ) );
149  clear();
150  }
std::stack< std::unique_ptr< TOOL_STATE > > stateStack
Stack preserving previous states of a TOOL.
void clear()
Restores the initial state.

Member Data Documentation

COROUTINE<int, const TOOL_EVENT&>* TOOL_MANAGER::TOOL_STATE::cofunc
CONTEXT_MENU* TOOL_MANAGER::TOOL_STATE::contextMenu

Context menu currently used by the tool.

Definition at line 93 of file tool_manager.cpp.

Referenced by TOOL_MANAGER::dispatchContextMenu(), operator=(), TOOL_MANAGER::ScheduleContextMenu(), and TOOL_STATE().

CONTEXT_MENU_TRIGGER TOOL_MANAGER::TOOL_STATE::contextMenuTrigger

Defines when the context menu is opened.

Definition at line 96 of file tool_manager.cpp.

Referenced by TOOL_MANAGER::dispatchContextMenu(), operator=(), TOOL_MANAGER::ScheduleContextMenu(), and TOOL_STATE().

bool TOOL_MANAGER::TOOL_STATE::idle

Is the tool active (pending execution) or disabled at the moment.

Definition at line 83 of file tool_manager.cpp.

Referenced by TOOL_MANAGER::dispatchInternal(), TOOL_MANAGER::finishTool(), operator=(), and TOOL_STATE().

bool TOOL_MANAGER::TOOL_STATE::pendingContextMenu

Is there a context menu being displayed.

Definition at line 90 of file tool_manager.cpp.

Referenced by operator=(), and TOOL_STATE().

bool TOOL_MANAGER::TOOL_STATE::pendingWait

Flag defining if the tool is waiting for any event (i.e.

if it issued a Wait() call).

Definition at line 87 of file tool_manager.cpp.

Referenced by TOOL_MANAGER::dispatchContextMenu(), TOOL_MANAGER::dispatchInternal(), operator=(), TOOL_MANAGER::ScheduleWait(), and TOOL_STATE().

std::stack<std::unique_ptr<TOOL_STATE> > TOOL_MANAGER::TOOL_STATE::stateStack
private

Stack preserving previous states of a TOOL.

Definition at line 177 of file tool_manager.cpp.

Referenced by Pop(), Push(), and ~TOOL_STATE().

TOOL_BASE* TOOL_MANAGER::TOOL_STATE::theTool

The tool itself.

Definition at line 80 of file tool_manager.cpp.

Referenced by TOOL_MANAGER::finishTool(), operator!=(), operator=(), operator==(), and TOOL_STATE().

std::vector<TRANSITION> TOOL_MANAGER::TOOL_STATE::transitions

List of possible transitions (ie.

association of events and state handlers that are executed upon the event reception

Definition at line 109 of file tool_manager.cpp.

Referenced by TOOL_MANAGER::dispatchInternal(), operator=(), TOOL_MANAGER::ScheduleNextState(), and TOOL_STATE().

KIGFX::VC_SETTINGS TOOL_MANAGER::TOOL_STATE::vcSettings

VIEW_CONTROLS settings to preserve settings when the tools are switched.

Definition at line 112 of file tool_manager.cpp.

Referenced by TOOL_MANAGER::applyViewControls(), operator=(), TOOL_MANAGER::saveViewControls(), and TOOL_STATE().

TOOL_EVENT_LIST TOOL_MANAGER::TOOL_STATE::waitEvents

List of events the tool is currently waiting for.

Definition at line 105 of file tool_manager.cpp.

Referenced by TOOL_MANAGER::dispatchContextMenu(), TOOL_MANAGER::dispatchInternal(), operator=(), TOOL_MANAGER::ScheduleWait(), and TOOL_STATE().

TOOL_EVENT TOOL_MANAGER::TOOL_STATE::wakeupEvent

The event that triggered the execution/wakeup of the tool after Wait() call.

Definition at line 102 of file tool_manager.cpp.

Referenced by TOOL_MANAGER::dispatchInternal(), operator=(), TOOL_MANAGER::ScheduleWait(), and TOOL_STATE().


The documentation for this struct was generated from the following file: