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
00053 class SoQtSpaceball : public SoQtDevice {
00054
00055 Q_OBJECT
00056
00057 #ifdef __APPLE__
00058 public:
00059 SoQtSpaceball(SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL) { };
00060 SoQtSpaceball(Display *d, SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL) { };
00061 ~SoQtSpaceball() { };
00062 virtual void enable(QWidget *w, XtEventHandler f, XtPointer data, void *unused=NULL) { };
00063 virtual void disable(QWidget *w, XtEventHandler f, XtPointer data) { };
00064 virtual const SoEvent * translateEvent(QEvent *xevent) { return NULL;};
00065 void setRotationScaleFactor(float f) { };
00066 float getRotationScaleFactor() const { return 0.0; };
00067 void setTranslationScaleFactor(float f) { };
00068 float getTranslationScaleFactor() const { return 0.0; };
00069 static SbBool exists() { return FALSE;};
00070 static SbBool exists(Display);
00071 void setFocusToWindow(SbBool);
00072 SbBool isFocusToWindow() const { return FALSE;};
00073
00074 #else
00075 public:
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00091 SoQtSpaceball(SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL);
00095 SoQtSpaceball(SbGlContextHelper::Display d, SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL);
00099 ~SoQtSpaceball();
00100
00102 virtual void enable(QWidget *w, XtEventHandler f, XtPointer data, void *unused=NULL);
00103
00105 virtual void disable(QWidget *w, XtEventHandler f, XtPointer data);
00106
00108 virtual const SoEvent * translateEvent(QEvent *xevent);
00109
00115 void setRotationScaleFactor(float f) { m_guiSpaceball->setRotationScaleFactor( f ); }
00119 float getRotationScaleFactor() const { return m_guiSpaceball->getRotationScaleFactor(); }
00125 void setTranslationScaleFactor(float f) { m_guiSpaceball->setTranslationScaleFactor( f ); }
00129 float getTranslationScaleFactor() const { return m_guiSpaceball->getTranslationScaleFactor(); }
00130
00134 static SbBool exists() { return exists(SoQt::getDisplay());}
00138 static SbBool exists(SbGlContextHelper::Display d);
00139
00146 void setFocusToWindow(SbBool flag);
00150 SbBool isFocusToWindow() const { return m_guiSpaceball->isFocusToWindow(); }
00151
00152 private:
00153
00154 SoGuiSpaceball* m_guiSpaceball;
00155
00156 SoMotion3Event *motionEvent;
00157 SoSpaceballButtonEvent *buttonEvent;
00158
00159 QWidget* parentWidget;
00160
00161 #ifdef _WIN32
00162
00163 HWND m_curHwnd;
00164
00165 struct _MagellanControl_ *magellanHandle;
00166
00167 #else
00168
00169
00170 Display *display;
00171
00172
00173 SoGuiSpaceball::DeviceType deviceType;
00174
00175 #endif
00176
00177
00178 SoMotion3Event *translateMotionEvent(QEvent *me);
00179 SoSpaceballButtonEvent *translateButtonEvent(QEvent *be,
00180 SoButtonEvent::State whichState);
00181
00182 SoMotion3Event *translateMotionEventMagellan(XEvent *me);
00183
00184 void constructorCommon(SbGlContextHelper::Display d, SoGuiSpaceball::Mask mask);
00185 #endif
00186 };
00187
00188 #endif
00189
00190
00191