MeVisLab Toolbox Reference
SoInteractionCoordinator.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2008, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef SO_INTERACTION_COORDINATOR_H
14 #define SO_INTERACTION_COORDINATOR_H
15 
17 
19 
20 #include <ThirdPartyWarningsDisable.h>
21 #include <list>
22 
23 #include <Inventor/events/SoKeyboardEvent.h>
24 #include <ThirdPartyWarningsRestore.h>
25 
26 #include "SoCommandAction.h"
27 #include "SoPointingAction.h"
28 #include "SoOffsetAction.h"
29 
32 
35 {
36 public:
37  // Constructor
39  // Destructor
41 
43  size_t getNumMappers();
44 
49 
51  void clearMappers();
52 
55  void truncateMappers(size_t n = 0);
56 
57 
61  const SoPointerPosition& location, bool allowed = true);
62 
64  SoPointingAction* getCurrentPointingAction() const { return _currentPointingAction; }
65 
67  SoInteractionHandler* getCurrentPointingActionHandler() const { return _currentPActionHandler; }
68 
70  bool getCurrentPointingActionAllowed() const { return _currentPointingActionAllowed; }
71 
74  void affirmSelectedPointingAction() { _pointingActionSelected = true; }
75 
78  bool isPointingActionSelected() const { return _pointingActionSelected; }
79 
81  bool maySelectPointingAction() const { return _maySelectPointingAction; }
82 
86 
88  SoPointingAction* getLockedPointingAction() { return _lockedPointingAction; }
89 
91  SoInteractionHandler* getLockedPointingActionHandler() { return _lockedPActionHandler; }
92 
95 
97  virtual bool isPointingActionActive (SoPointingAction* action, int currentMask);
98 
102  virtual int getModeModifierMask(int numModes);
103 
106  virtual int getModeFromModifiers(int numModes, int modifierMask);
107 
109  virtual bool startPress(const SoPointerPosition& position, int modifierMask);
110 
112  virtual void endPress(int clickCount);
113 
115  virtual bool isDragging() { return _isDragging; }
116 
118  bool isCancelled() const { return _cancelled; }
119 
122  void cancelDrag();
123 
126  bool wheelModifiersFitOffsetAction(SoOffsetAction* action, int modifiers,
127  double& sensitivityX, double& sensitivityY, bool& swapAxes);
128 
130  void setWheelActionExecuted() { _mayExecuteWheelAction = false; }
131 
133  bool mayExecuteWheelAction() const { return _mayExecuteWheelAction; }
134 
135 
137  bool keyFitsCommandAction (SoCommandAction* action, int modifiers, SoKeyboardEvent::Key nKey);
138 
140  bool keyFitsOffsetAction (SoOffsetAction* action, int modifiers, SoKeyboardEvent::Key nKey,
141  double& sensitivityX, double& sensitivityY, bool& swapAxes);
142 
144  void setKeyboardActionExecuted() { _mayExecuteKeyboardAction = false; }
145 
147  bool mayExecuteKeyboardAction() const { return _mayExecuteKeyboardAction; }
148 
150  virtual bool isDragThresholdExceeded() const { return true; }
151 
152 
155 
158 
161 
162 protected:
164  virtual void setDragging(bool dragging);
165 
167  void unsetPointingActionSelected() { _pointingActionSelected = false; }
168 
169  // only allow to select (new) pointing action if this is true
171 
172  // only allow to execute keyboard actions if this is true
174 
175  // only allow to execute wheel actions if this is true
177 
178 private:
179  static void _grabReleasedByActionCB (SoPointingAction* action, void* data);
180 
182  std::list<SoInteractionMapper*> _mappers;
183 
184  // selected pointing action
185  SoPointingAction* _currentPointingAction;
186  SoInteractionHandler* _currentPActionHandler;
187 
188  // locked pointing action
189  SoPointingAction* _lockedPointingAction;
190  SoInteractionHandler* _lockedPActionHandler;
191 
192  // is the controller enabled
193  bool _enabled;
194 
195  // this might be set to true during traversal
196  bool _pointingActionSelected;
197 
198  // this may be false for locked actions
199  bool _currentPointingActionAllowed;
200 
201  // this is set to true when dragging with an PointingAction
202  bool _isDragging;
203 
204  // this is set if the current dragging action has been cancelled
205  bool _cancelled;
206 };
207 
208 #endif // __SoInteractionCoordinator_H
#define SOMANAGEDINTERACTION_API
File to resolve system dependencies in View2D library.
SoCommandAction is the base class for instantaneous actions.
std::list< Shortcut > ShortcutList
A list of shortcuts.
Provides coordinating interface to the SoInteractionHandlers in the scene.
bool isCancelled() const
This returns true if the current drag action has been cancelled.
void addMapper(SoInteractionMapper *mapper)
Add an instance to override pointing and command action mappings.
void cancelDrag()
Cancel the current drag action (if this wasn't done already).
SoCommandAction::ShortcutList getShortcuts(SoCommandAction *action)
get current shortcuts for a command action
virtual int getModeFromModifiers(int numModes, int modifierMask)
Get mode number to set for a total number of modes and the current modifier mask.
virtual void setSelectedPointingAction(SoPointingAction *action, SoInteractionHandler *handler, const SoPointerPosition &location, bool allowed=true)
This method sets the new selected pointing action.
SoPointingAction::TriggerList getTriggers(SoPointingAction *action)
get current triggers for a pointing action
bool wheelModifiersFitOffsetAction(SoOffsetAction *action, int modifiers, double &sensitivityX, double &sensitivityY, bool &swapAxes)
Check if the current modifiers allow to execute a wheel action; also returns the sensitivity settings...
SoOffsetAction::TriggerList getTriggers(SoOffsetAction *action)
get current triggers for an offset action
void affirmSelectedPointingAction()
Affirm currently selected pointing action (this prevents other nodes from changing the action without...
virtual bool startPress(const SoPointerPosition &position, int modifierMask)
Start mouse button press for current action.
void setKeyboardActionExecuted()
Prevent further keyboard actions from being executed.
bool mayExecuteKeyboardAction() const
Check if it is allowed to execute keyboard actions.
bool keyFitsCommandAction(SoCommandAction *action, int modifiers, SoKeyboardEvent::Key nKey)
Check if a keyboard event fits a certain command action.
void clearMappers()
Clear list of mappers.
bool getCurrentPointingActionAllowed() const
Get if the current pointing action may be applied at the current location.
virtual bool isDragging()
Query flag indicating drag action.
void setWheelActionExecuted()
Prevent further wheel actions from being executed.
size_t getNumMappers()
Return number of added mappers, to be used with truncateMappers.
virtual bool isPointingActionActive(SoPointingAction *action, int currentMask)
This method will be used to override the default action selection mechanism.
SoPointingAction * getCurrentPointingAction() const
Get currently selected pointing action.
virtual void endPress(int clickCount)
Stop mouse button press for current action.
SoInteractionHandler * getLockedPointingActionHandler()
Get handler for locked pointing action.
bool keyFitsOffsetAction(SoOffsetAction *action, int modifiers, SoKeyboardEvent::Key nKey, double &sensitivityX, double &sensitivityY, bool &swapAxes)
Check if a keyboard event fits a certain offset action.
SoInteractionHandler * getCurrentPointingActionHandler() const
Get handler for currently selected pointing action.
virtual int getModeModifierMask(int numModes)
Return a mask that covers all modifier flags that are needed for the given number of drag modes.
void truncateMappers(size_t n=0)
Truncate list of mappers to the given number, used for push/pop semantics.
bool maySelectPointingAction() const
Return whether one is even allowed to select a (new) pointing action.
bool mayExecuteWheelAction() const
Check if it is allowed to execute wheel actions.
virtual void setLockedPointingAction(SoPointingAction *action, SoInteractionHandler *handler)
Setting the locked pointing action with this method ensures that a callback is set to be informed of ...
virtual void setDragging(bool dragging)
Set flag indicating drag action.
void unsetPointingActionSelected()
reset _pointingActionSelected flag (before traversing the scene)
void grabReleasedByAction(SoPointingAction *action)
This method is called from a PointingAction if a grab should be released.
SoPointingAction * getLockedPointingAction()
Get locked pointing action.
virtual bool isDragThresholdExceeded() const
Must be overridden to implement click detection.
bool isPointingActionSelected() const
Find out whether the pointing action has been set during the current scene graph traversal.
virtual ~SoInteractionCoordinator()
SoInteractionHandler is a mix-in class for instances of SoNode to handle the interactions it provides...
SoInteractionMapper is the base class for instances that map SoPointingActions or SoCommandActions to...
SoOffsetAction is the base class for any interaction that only provides (numeric) offsets in one or t...
std::list< Trigger > TriggerList
List of triggers.
SoPointerPosition manages the current position of the mouse cursor.
SoPointingAction is the base class for any mouse based interaction.
std::list< Trigger > TriggerList
List of triggers.