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{
36public:
37 // Constructor
39 // Destructor
41
43 size_t getNumMappers();
44
49
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
98
103
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
123
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
162protected:
164 virtual void setDragging(bool dragging);
165
167 void unsetPointingActionSelected() { _pointingActionSelected = false; }
168
169 // Only allow to select (new) pointing action if this is \c true.
171
172 // Only allow to execute keyboard actions if this is \c true.
174
175 // Only allow to execute wheel actions if this is \c true.
177
178private:
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 \c true during traversal.
196 bool _pointingActionSelected;
197
198 // This may be \c false for locked actions.
199 bool _currentPointingActionAllowed;
200
201 // This is set to \c true when dragging with an PointingAction.
202 bool _isDragging;
203
204 // This is set if the current dragging action has been canceled.
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 a coordinating interface to the SoInteractionHandlers in the scene.
bool isCancelled() const
This returns true if the current drag action has been canceled.
void addMapper(SoInteractionMapper *mapper)
Adds an instance to override pointing and command action mappings.
void cancelDrag()
Cancels the current drag action if this was not done already.
SoCommandAction::ShortcutList getShortcuts(SoCommandAction *action)
Returns the current shortcuts for a command action.
virtual int getModeFromModifiers(int numModes, int modifierMask)
Returns the 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)
Returns the current triggers for a pointing action.
bool wheelModifiersFitOffsetAction(SoOffsetAction *action, int modifiers, double &sensitivityX, double &sensitivityY, bool &swapAxes)
Checks whether the current modifiers allow to execute a wheel action; also returns the sensitivity se...
SoOffsetAction::TriggerList getTriggers(SoOffsetAction *action)
Returns current triggers for an offset action.
void affirmSelectedPointingAction()
Affirms currently selected pointing action.
virtual bool startPress(const SoPointerPosition &position, int modifierMask)
Starts a mouse button press for current action.
void setKeyboardActionExecuted()
Prevents further keyboard actions from being executed.
SoInteractionHandler * getCurrentPointingActionHandler() const
Returns the handler for currently selected pointing action.
bool mayExecuteKeyboardAction() const
Checks whether it is allowed to execute keyboard actions.
bool keyFitsCommandAction(SoCommandAction *action, int modifiers, SoKeyboardEvent::Key nKey)
Checks whether a keyboard event fits a certain command action.
void clearMappers()
Clears the list of mappers.
bool getCurrentPointingActionAllowed() const
Returns whether the current pointing action may be applied at the current location.
virtual bool isDragging()
Queries the flag indicating drag action.
void setWheelActionExecuted()
Prevents further wheel actions from being executed.
SoPointingAction * getCurrentPointingAction() const
Returns the currently selected pointing action.
size_t getNumMappers()
Returns the 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.
SoInteractionHandler * getLockedPointingActionHandler()
Returns the handler for locked pointing action.
virtual void endPress(int clickCount)
Stops a mouse button press for current action.
bool keyFitsOffsetAction(SoOffsetAction *action, int modifiers, SoKeyboardEvent::Key nKey, double &sensitivityX, double &sensitivityY, bool &swapAxes)
Checks whether a keyboard event fits a certain offset action.
virtual int getModeModifierMask(int numModes)
Returns a mask that covers all modifier flags that are needed for the given number of drag modes.
void truncateMappers(size_t n=0)
Truncates the list of mappers to the given number, used for push/pop semantics.
bool maySelectPointingAction() const
Returns whether one is even allowed to select a (new) pointing action.
SoPointingAction * getLockedPointingAction()
Returns the locked pointing action.
bool mayExecuteWheelAction() const
Checks whether 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)
Sets the flag indicating drag action.
void unsetPointingActionSelected()
Resets the _pointingActionSelected flag (before traversing the scene).
void grabReleasedByAction(SoPointingAction *action)
This method is called from a PointingAction if a grab should be released.
virtual bool isDragThresholdExceeded() const
Must be overridden to implement click detection.
bool isPointingActionSelected() const
Finds 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.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.