MeVisLab Toolbox Reference
SoInteractionHandler.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_HANDLER_H
14#define SO_INTERACTION_HANDLER_H
15
18
20#include "SoPointerPosition.h"
21
22#include <ThirdPartyWarningsDisable.h>
23#include <Inventor/events/SoKeyboardEvent.h>
24#include <Inventor/events/SoMouseWheelEvent.h>
25
26#include <list>
27#include <ThirdPartyWarningsRestore.h>
28
29class SoState;
30class SoHandleEventAction;
32
36{
37public:
40
42 virtual void handleEventForInteraction(SoHandleEventAction *action);
43
44protected:
47 bool handleKeyPress(SoState* state, const SoPointerPosition& location, int modifiers, SoKeyboardEvent::Key nKey,
48 bool positionValid);
49
56 virtual bool augmentLocation (SoPointerPosition& /*position*/, bool /*dragging*/) { return true; }
57
59 void buttonMaskChanged (SoState* state, const SoPointerPosition& location, int buttonMask);
60
62 void modifierMaskChanged (SoState* state, const SoPointerPosition& location, int modifierMask);
63
68 void locationChanged (SoState* state, const SoPointerPosition& location, bool force = false, bool renderRefresh = false);
69
72 bool wheelRotated(SoState* state, const SoPointerPosition& location, int modifierMask,
73 SoMouseWheelEvent::Orientation orientation, short rotation);
74
76 void handlePointerLeftWindow(SoState* state);
77
81 int getCurrentButtonMask() { return _currentButtonMask; }
83 int getCurrentModifierMask() { return _currentModifierMask; }
85 SoPointerPosition getCurrentPointerLocation() { return _currentPointerLocation; }
87 bool isCurrentPointerLocationValid() { return _currentPointerLocationValid; }
89
91 SoInteractionCoordinator* getCoordinator() { return _coordinator; }
92
93 // Convenience method, returns the selected pointing action it belongs to this
94 // interaction provider; otherwise, it returns NULL. Must be called during event handling.
96
100 virtual bool isEnabled (SoPointingAction* action, int currentMask);
101
106 virtual bool isValidStartingLocation(const SoPointerPosition& location);
107
108 // Returns whether the pointing action may be selected by this handler, i.e., it has been
109 // not been selected by another node during the current event traversal.
110 // Must be called during event handling.
112
113 // Selects the appropriate pointing action for the given location and
114 // button/modifier mask. The action is set in the SoInteractionCoordinator.
115 void selectTargetPointingAction(SoState* state, const SoPointerPosition& location, int mask);
116
120 bool trySwitchGlobalPointingAction (SoState* state, const SoPointerPosition& location, int buttonMask, int modifierMask);
121
122private:
125 std::list<SoPointingAction*> getPointingActions(SoState* state);
126
128 SoInteractionProvider* _provider;
129
131 SoInteractionCoordinator* _coordinator;
132
134 SoState* _inventorState;
135
136 // Remember current state of pointer:
137 int _currentButtonMask;
138 int _currentModifierMask;
139 SoPointerPosition _currentPointerLocation;
140 bool _currentPointerLocationValid;
141
142 // This flag remembers if we did find a pointing action last time we searched.
143 bool _pointingActionFound;
144
145 // Set to \c true if pointerPosition() had been called on pointing actions (and
146 // when pointerLeftWindow() needs to be called if the cursor leaves the window).
147 bool _hadPointerUpdate;
148};
149
150#endif // __SoInteractionHandler_H
#define SOMANAGEDINTERACTION_API
File to resolve system dependencies in View2D library.
Provides a coordinating interface to the SoInteractionHandlers in the scene.
void handlePointerLeftWindow(SoState *state)
Called if the pointer left the scene widget.
virtual bool isValidStartingLocation(const SoPointerPosition &location)
SoPointerPosition getCurrentPointerLocation()
Returns the current position of the mouse cursor.
bool isCurrentPointerLocationValid()
Returns whether the current mouse cursor position is valid.
SoInteractionHandler(SoInteractionProvider *provider)
void selectTargetPointingAction(SoState *state, const SoPointerPosition &location, int mask)
void modifierMaskChanged(SoState *state, const SoPointerPosition &location, int modifierMask)
Called if the modifier mask changed since the last input event.
bool wheelRotated(SoState *state, const SoPointerPosition &location, int modifierMask, SoMouseWheelEvent::Orientation orientation, short rotation)
bool trySwitchGlobalPointingAction(SoState *state, const SoPointerPosition &location, int buttonMask, int modifierMask)
virtual ~SoInteractionHandler()
virtual void handleEventForInteraction(SoHandleEventAction *action)
Handles the mouse and keyboard events and send them to interaction nodes.
void buttonMaskChanged(SoState *state, const SoPointerPosition &location, int buttonMask)
Called if the button mask changed since the last input event.
bool handleKeyPress(SoState *state, const SoPointerPosition &location, int modifiers, SoKeyboardEvent::Key nKey, bool positionValid)
SoPointingAction * getLocalCurrentPointingAction()
bool canSelectPointingAction()
virtual bool isEnabled(SoPointingAction *action, int currentMask)
int getCurrentModifierMask()
Returns the currently active button modifier.
void locationChanged(SoState *state, const SoPointerPosition &location, bool force=false, bool renderRefresh=false)
virtual bool augmentLocation(SoPointerPosition &, bool)
SoInteractionCoordinator * getCoordinator()
Access method, returns the interaction coordinator during event handling.
SoPointerPosition manages the current position of the mouse cursor.