MeVisLab Resolution Independence API
SoMouseGrabber.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, 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_MOUSE_GRABBER_H
14#define SO_MOUSE_GRABBER_H
15
16
19
20#include <Inventor/fields/SoSFBool.h>
21#include <Inventor/fields/SoSFFloat.h>
22#include <Inventor/fields/SoSFTrigger.h>
23#include <Inventor/nodes/SoSeparator.h>
24#include <Inventor/nodes/SoSubNode.h>
25#include <Inventor/events/SoMouseButtonEvent.h>
26#include <Inventor/sensors/SoFieldSensor.h>
27
28#include <SoInteractionNode.h>
29
30class SoMouseGrabberPointingAction;
31
32//=============================================================
35
70//=============================================================
71class SoMouseGrabber : public SoInteractionNode
72{
73
74 SO_NODE_HEADER(SoMouseGrabber);
75
76 public:
79
81 static void initClass();
82
84
86 SoSFBool on;
87
90
92 SoSFBool normalized;
94 SoSFBool clamp;
95
97 SoSFFloat x;
99 SoSFFloat y;
100
101 SoSFFloat absX;
102 SoSFFloat absY;
103
106
108 SoSFFloat xmin;
110 SoSFFloat xmax;
112 SoSFFloat ymin;
114 SoSFFloat ymax;
115
117 SoSFBool flipX;
119 SoSFBool flipY;
121 SoSFBool swapXY;
124 SoSFFloat sensitivity;
125
127 SoSFEnum button1;
129 SoSFEnum button2;
131 SoSFEnum button3;
133 SoSFEnum shift;
135 SoSFEnum ctrl;
138 SoSFEnum alt;
139
141 SoSFEnum cursorShape;
142
144
146
147 SoSFBool shiftPressed;
148 SoSFBool ctrlPressed;
149 SoSFBool altPressed;
153
157
159 SoSFTrigger released;
160
163 SoSFBool maskValid;
164
167
170
172
175 SoSFFloat wheel;
177 SoSFFloat wheelMin;
179 SoSFFloat wheelMax;
181 SoSFFloat wheelStep;
182
184 SoSFTrigger wheelUp;
186 SoSFTrigger wheelDown;
187
190
192
194 void onChanged(SoField* field);
195
198 void handleEvent(SoHandleEventAction *action) override;
199
201 void GLRender(SoGLRenderAction * /* action */) override {};
202
204 bool affectsState() const override { return false; }
205
206 protected:
207 ~SoMouseGrabber() override;
208
209 private:
211
213 void trackMouse(SbVec2s pos, SbVec2f localPos, const SbViewportRegion& vp, bool initial);
214
216 void updatePointingAction(SoField*);
217
219
228 bool testState(int state, SbBool flag);
229
231 SoMouseGrabberPointingAction* _pointingAction;
232
234 SbBool _maskValid;
236 SbVec2s _lastPos;
239 SbBool _buttonState[3];
240
242 int _lastButtonPressed;
243
245 unsigned _prevWheelCode;
247 int _sumWheel;
248};
249
250#endif
SoMouseGrabber is a general facility to grab mouse events and to map mouse movement to x/y values.
SoSFEnum alt
mask for shift alt, the alt key will not work in SoFullViewer derived classes because those viewers h...
SoSFBool normalized
if true x and y are set to [xmin,xmax] relative to the viewport
SoSFBool button3Pressed
SoSFBool setEventHandled
Set events that depend on the button mask handled if they are indeed handled by this extension.
SoSFBool button2Pressed
SoSFEnum ctrl
mask for shift ctrl
SoSFBool flipY
flip the mouse movement to y mapping
SoSFEnum button2
button mask for button2
void handleEvent(SoHandleEventAction *action) override
handle event is reimplemented to handle the mouse events (The events are not consumed,...
SoMouseGrabber()
Constructor.
static void initClass()
inventor type system
SoSFBool wheelOverflow
if it to true, the wheel value is wrapped around when reaching min/max values
SoSFFloat wheelMax
max value for wheel
SoSFBool useManagedInteraction
If this is on, use managed interaction actions to modify x/y values.
SoSFTrigger wheelDown
tells when the wheel was turned down
SoSFBool shiftPressed
Output Fields that are changed when the state changes.
SoSFFloat xmax
max value for the x field
void GLRender(SoGLRenderAction *) override
GLRender dummy implementation.
SoSFBool swapXY
flip the mouse movement to xy mapping (mouse x -> field y, mouse y -> field x)
SoSFTrigger button2DoubleClicked
void onChanged(SoField *field)
Called when field on changed.
SoSFBool cursorPresent
this is set to true if the cursor is inside the viewing area
SoSFTrigger wheelUp
tells when the wheel was turned up
SoSFTrigger button1DoubleClicked
SoSFTrigger button3DoubleClicked
SoSFFloat y
y value that is changed by mouse movements
SoSFTrigger released
emitted when the mask was valid and switches to invalid again
SoSFBool on
Fields.
SoSFFloat ymax
max value for the y field
SoSFFloat wheelMin
min value for wheel
SoSFBool maskValid
gives the state of the mask, which calculated by the current mousebuttons and modifier key compared t...
SoSFFloat sensitivity
set the sensitivity of the mouse movement to x/y mapping, a value of 1 means that 400 pixel mouse mov...
SoSFFloat x
x value that is changed by mouse movements
SoSFBool flipX
flip the mouse movement to x mapping
SoSFEnum button3
button mask for button3
friend class SoMouseGrabberPointingAction
SoSFFloat xmin
min value for the x field
SoSFFloat wheelStep
step value that is added/subtracted onto wheel on wheel events
SoSFEnum cursorShape
shape of mouse cursor when this grabber is active
~SoMouseGrabber() override
SoSFFloat ymin
min value for the y field
SoSFBool setWheelEventHandled
Set wheel events handled.
SoSFBool button1Pressed
bool affectsState() const override
this node does not affect the state, so return false!
SoSFEnum shift
mask for shift key
SoSFEnum button1
button mask for button1
SoSFBool clamp
clamps the output to [min,max] in noramlized mode