00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _SO_QT_SPACEBALL_
00026 #define _SO_QT_SPACEBALL_
00027 #include <Inventor/Qt/OivQtCompat.h>
00028 #include <Inventor/Qt/SoQt.h>
00029 #include <Inventor/Qt/devices/SoQtDevice.h>
00030 #include <Inventor/events/SoMotion3Event.h>
00031 #include <Inventor/events/SoSpaceballButtonEvent.h>
00032
00033 #include <Inventor/Gui/devices/SoGuiSpaceball.h>
00034
00052 class SoQtSpaceball : public SoQtDevice {
00053
00054 Q_OBJECT
00055
00056 #ifdef __APPLE__
00057 public:
00058 SoQtSpaceball(SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL) { };
00059 SoQtSpaceball(Display *d, SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL) { };
00060 ~SoQtSpaceball() { };
00061 virtual void enable(QWidget *w, XtEventHandler f, XtPointer data, void *unused=NULL) { };
00062 virtual void disable(QWidget *w, XtEventHandler f, XtPointer data) { };
00063 virtual const SoEvent * translateEvent(QEvent *xevent) { return NULL;};
00064 void setRotationScaleFactor(float f) { };
00065 float getRotationScaleFactor() const { return 0.0; };
00066 void setTranslationScaleFactor(float f) { };
00067 float getTranslationScaleFactor() const { return 0.0; };
00068 static SbBool exists() { return FALSE;};
00069 static SbBool exists(Display);
00070 void setFocusToWindow(SbBool);
00071 SbBool isFocusToWindow() const { return FALSE;};
00072
00073 #else
00074 public:
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00090 SoQtSpaceball(SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL);
00094 SoQtSpaceball(SbGlContextHelper::Display d, SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL);
00098 ~SoQtSpaceball();
00099
00101 virtual void enable(QWidget *w, XtEventHandler f, XtPointer data, void *unused=NULL);
00102
00104 virtual void disable(QWidget *w, XtEventHandler f, XtPointer data);
00105
00107 virtual const SoEvent * translateEvent(QEvent *xevent);
00108
00114 void setRotationScaleFactor(float f) { m_guiSpaceball->setRotationScaleFactor( f ); }
00118 float getRotationScaleFactor() const { return m_guiSpaceball->getRotationScaleFactor(); }
00124 void setTranslationScaleFactor(float f) { m_guiSpaceball->setTranslationScaleFactor( f ); }
00128 float getTranslationScaleFactor() const { return m_guiSpaceball->getTranslationScaleFactor(); }
00129
00133 static SbBool exists() { return exists(SoQt::getDisplay());}
00137 static SbBool exists(SbGlContextHelper::Display d);
00138
00145 void setFocusToWindow(SbBool flag);
00149 SbBool isFocusToWindow() const { return m_guiSpaceball->isFocusToWindow(); }
00150
00151 private:
00152
00153 SoGuiSpaceball* m_guiSpaceball;
00154
00155 SoMotion3Event *motionEvent;
00156 SoSpaceballButtonEvent *buttonEvent;
00157
00158 QWidget* parentWidget;
00159
00160 #ifdef _WIN32
00161
00162 HWND m_curHwnd;
00163
00164 struct _MagellanControl_ *magellanHandle;
00165
00166 #else
00167
00168
00169 Display *display;
00170
00171
00172 SoGuiSpaceball::DeviceType deviceType;
00173
00174 #endif
00175
00176
00177 SoMotion3Event *translateMotionEvent(QEvent *me);
00178 SoSpaceballButtonEvent *translateButtonEvent(QEvent *be,
00179 SoButtonEvent::State whichState);
00180
00181 SoMotion3Event *translateMotionEventMagellan(XEvent *me);
00182
00183 void constructorCommon(SbGlContextHelper::Display d, SoGuiSpaceball::Mask mask);
00184 #endif
00185 };
00186
00187 #endif
00188
00189
00190