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;
32
36{
37public:
40
43
44protected:
47 bool handleKeyPress (SoState* state, const SoPointerPosition& location, int modifiers, SoKeyboardEvent::Key nKey);
48
55 virtual bool augmentLocation (SoPointerPosition& /*position*/, bool /*dragging*/) { return true; }
56
58 void buttonMaskChanged (SoState* state, const SoPointerPosition& location, int buttonMask);
59
61 void modifierMaskChanged (SoState* state, const SoPointerPosition& location, int modifierMask);
62
67 void locationChanged (SoState* state, const SoPointerPosition& location, bool force = false, bool renderRefresh = false);
68
71 bool wheelRotated(SoState* state, const SoPointerPosition& location, int modifierMask,
72 SoMouseWheelEvent::Orientation orientation, short rotation);
73
76
80 int getCurrentButtonMask() { return _currentButtonMask; }
82 int getCurrentModifierMask() { return _currentModifierMask; }
84 SoPointerPosition getCurrentPointerLocation() { return _currentPointerLocation; }
86 bool isCurrentPointerLocationValid() { return _currentPointerLocationValid; }
88
90 SoInteractionCoordinator* getCoordinator() { return _coordinator; }
91
92 // Convenience method, returns the selected pointing action it belongs to this
93 // interaction provider, otherwise NULL. Must be called during event handling.
95
100
105 virtual bool isValidStartingLocation(const SoPointerPosition& location);
106
107 // Returns whether the pointing action may be selected by this handler, i.e. it has been
108 // not been selected by another node during the current event traversal.
109 // Must be called during event handling.
111
112 // Selects the appropriate pointing action for the given location and
113 // button/modifier mask. The action is set in the SoInteractionCoordinator.
114 void selectTargetPointingAction(SoState* state, const SoPointerPosition& location, int mask);
115
120
121private:
124 std::list<SoPointingAction*> getPointingActions(SoState* state);
125
127 SoInteractionProvider* _provider;
128
130 SoInteractionCoordinator* _coordinator;
131
133 SoState* _inventorState;
134
135 // Remember current state of pointer:
136 int _currentButtonMask;
137 int _currentModifierMask;
138 SoPointerPosition _currentPointerLocation;
139 bool _currentPointerLocationValid;
140
141 // This flag remembers if we did find a pointing action last time we searched:
142 bool _pointingActionFound;
143
144 // Set to true if pointerPosition() had been called on pointing actions (and
145 // when pointerLeftWindow() needs to be called if the cursor leaves the window)
146 bool _hadPointerUpdate;
147};
148
149#endif // __SoInteractionHandler_H
#define SOMANAGEDINTERACTION_API
File to resolve system dependencies in View2D library.
Provides coordinating interface to the SoInteractionHandlers in the scene.
SoInteractionHandler is a mix-in class for instances of SoNode to handle the interactions it provides...
bool handleKeyPress(SoState *state, const SoPointerPosition &location, int modifiers, SoKeyboardEvent::Key nKey)
Handles key press by checking for commands actions with matching key shortcuts and executing (one of)...
void handlePointerLeftWindow(SoState *state)
Called if the pointer left the scene widget.
virtual bool isValidStartingLocation(const SoPointerPosition &location)
This method returns whether the current location is valid for starting a pointing action.
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)
Called when the mouse wheel is rotated.
bool trySwitchGlobalPointingAction(SoState *state, const SoPointerPosition &location, int buttonMask, int modifierMask)
Tries to switch from one global pointing action to another during a drag.
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.
SoPointingAction * getLocalCurrentPointingAction()
bool canSelectPointingAction()
virtual bool isEnabled(SoPointingAction *action, int currentMask)
This method returns true if the pointing action should be enabled for the given modifier/button mask.
int getCurrentModifierMask()
Returns the currently active button modifier.
void locationChanged(SoState *state, const SoPointerPosition &location, bool force=false, bool renderRefresh=false)
Called if the pointer location changed since the last input event.
virtual bool augmentLocation(SoPointerPosition &, bool)
This method can be overridden to provide further position information to SoPointingActions - e....
SoInteractionCoordinator * getCoordinator()
Access method, returns the interaction coordinator during event handling.
SoInteractionProvider is an abstract interface class that provides interactions to the SoInteractionC...
SoPointerPosition manages the current position of the mouse cursor.
SoPointingAction is the base class for any mouse based interaction.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.