Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoQtSpaceball.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24
25#ifndef _SO_QT_SPACEBALL_
26#define _SO_QT_SPACEBALL_
27#include <Inventor/Qt/OivQtCompat.h>
28#include <Inventor/Qt/SoQt.h>
29#include <Inventor/Qt/devices/SoQtDevice.h>
30#include <Inventor/events/SoMotion3Event.h>
31#include <Inventor/events/SoSpaceballButtonEvent.h>
32
33#include <Inventor/Gui/devices/SoGuiSpaceball.h>
34
52class SoQtSpaceball : public SoQtDevice {
53
54 Q_OBJECT
55
56#ifdef __APPLE__
57public:
58 SoQtSpaceball(SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL) { };
59 SoQtSpaceball(Display *d, SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL) { };
60 ~SoQtSpaceball() { };
61 virtual void enable(QWidget *w, XtEventHandler f, XtPointer data, void *unused=NULL) { };
62 virtual void disable(QWidget *w, XtEventHandler f, XtPointer data) { };
63 virtual const SoEvent * translateEvent(QEvent *xevent) { return NULL;};
64 void setRotationScaleFactor(float f) { };
65 float getRotationScaleFactor() const { return 0.0; };
66 void setTranslationScaleFactor(float f) { };
67 float getTranslationScaleFactor() const { return 0.0; };
68 static SbBool exists() { return FALSE;};
69 static SbBool exists(Display);
71 SbBool isFocusToWindow() const { return FALSE;};
72
73#else
74public:
75
76 //
77 // valid event mask values:
78 // SoXtSpaceball::MOTION - spaceball translation and rotation
79 // SoXtSpaceball::PRESS - spaceball button press
80 // SoXtSpaceball::RELEASE - spaceball button release
81 // SoXtSpaceball::ALL - all spaceball events
82 // Bitwise OR these to specify whichEvents this device should queue.
83 //
84 // The second constructor allows the spaceball to be attached
85 // to a different display than the one used by SoXt::init().
86
90 SoQtSpaceball(SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL);
94 SoQtSpaceball(SbGlContextHelper::Display d, SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL);
99
101 virtual void enable(QWidget *w, XtEventHandler f, XtPointer data, void *unused=NULL);
102
104 virtual void disable(QWidget *w, XtEventHandler f, XtPointer data);
105
107 virtual const SoEvent * translateEvent(QEvent *xevent);
108
114 void setRotationScaleFactor(float f) { m_guiSpaceball->setRotationScaleFactor( f ); }
118 float getRotationScaleFactor() const { return m_guiSpaceball->getRotationScaleFactor(); }
124 void setTranslationScaleFactor(float f) { m_guiSpaceball->setTranslationScaleFactor( f ); }
128 float getTranslationScaleFactor() const { return m_guiSpaceball->getTranslationScaleFactor(); }
129
133 static SbBool exists() { return exists(SoQt::getDisplay());}
138
149 SbBool isFocusToWindow() const { return m_guiSpaceball->isFocusToWindow(); }
150
151 private:
152
153 SoGuiSpaceball* m_guiSpaceball; // Implementation class for SoXxSpaceball
154
155 SoMotion3Event *motionEvent; // spaceball rotation/translation
156 SoSpaceballButtonEvent *buttonEvent; // spball button press/release
157
158 QWidget* parentWidget;
159
160#ifdef _WIN32
161 // The first widget which registered the space ball object
162 HWND m_curHwnd;
163 // Magellanstruct _MagellanControl_ Space Mouse data structure
164 struct _MagellanControl_ *magellanHandle;
165
166#else
167
168 // the X display
169 Display *display;
170
171 // device type: SPACE_BALL or MAGELLAN_SPACE_MOUSE
172 SoGuiSpaceball::DeviceType deviceType;
173
174#endif
175
176 // event translators for SPACE BALL!
177 SoMotion3Event *translateMotionEvent(QEvent *me);
178 SoSpaceballButtonEvent *translateButtonEvent(QEvent *be,
179 SoButtonEvent::State whichState);
180 // event translators for MAGELLAN SPACE MOUSE!
181 SoMotion3Event *translateMotionEventMagellan(XEvent *me);
182
183 void constructorCommon(SbGlContextHelper::Display d, SoGuiSpaceball::Mask mask);
184#endif
185};
186
187#endif /* _SO_QT_SPACEBALL_ */
188
189
Base class for all events.
Definition SoEvent.h:116
3D motion events.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
Definition SoQtDevice.h:102
static SbGlContextHelper::Display getDisplay()
This method is included for portability only.
Translates and reports events for a SpaceBall or SpaceMouse (Magellan) device.
SoQtSpaceball(SoGuiSpaceball::Mask mask=SoGuiSpaceball::ALL)
Constructor.
static SbBool exists()
Returns whether or not the spaceball device exists for use.
SoQtSpaceball(SbGlContextHelper::Display d, SoGuiSpaceball::Mask mask=SoGuiSpaceball::ALL)
Constructor.
float getTranslationScaleFactor() const
Returns the translation scale factor.
static SbBool exists(SbGlContextHelper::Display d)
Returns whether or not the spaceball device exists for use.
virtual void enable(QWidget *w, XtEventHandler f, XtPointer data, void *unused=NULL)
Enables the device for the passed widget.
void setRotationScaleFactor(float f)
The spaceball reports rotations and translations as integers.
SbBool isFocusToWindow() const
Gets the input focus method.
virtual const SoEvent * translateEvent(QEvent *xevent)
Attempts to convert the passed event into an SoEvent.
virtual void disable(QWidget *w, XtEventHandler f, XtPointer data)
Disables the device for the passed widget.
void setFocusToWindow(SbBool flag)
Sets the input focus method used to get events from the space ball.
~SoQtSpaceball()
Destructor.
float getRotationScaleFactor() const
Returns the rotation scale factor.
void setTranslationScaleFactor(float f)
The spaceball reports rotations and translations as integers.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Spaceball button...
int SbBool
Boolean type.
Definition SbBase.h:87
union _XEvent XEvent
Definition SoQtDef.h:126
void * XtPointer
Definition SoQtDef.h:122