Back to index

salome-gui  6.5.0
SVTK_SpaceMouse.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME VTKViewer : build VTK viewer into Salome desktop
00024 //  File   : SVTK_SpaceMouse.h
00025 //  Author : Alexander SLADKOV
00026 
00027 #ifndef SVTK_SpaceMouse_h
00028 #define SVTK_SpaceMouse_h
00029 
00030 #ifndef WIN32
00031 extern "C"
00032 {
00033 #include <X11/X.h>
00034 #include <X11/Xlib.h>
00035 }
00036 #endif
00037 
00038 class SVTK_SpaceMouse 
00039 {
00040  public:
00041 
00042   // access to SpaceMouse utility class
00043   static SVTK_SpaceMouse* getInstance();
00044 
00045   enum MoveData { x, y, z, a, b, c };
00046   enum EventType { SpaceMouseMove = 1, SpaceButtonPress, SpaceButtonRelease };
00047 
00048   typedef struct  {
00049     int type;
00050     int button;
00051     double data[6];
00052     int period;
00053   } MoveEvent;
00054 
00055   bool isSpaceMouseOn() const { return spaceMouseOn != 0; }
00056 
00057 #ifndef WIN32
00058   int initialize     ( Display*, Window );
00059   int setWindow      ( Display*, Window );
00060   int translateEvent ( Display*, XEvent*, MoveEvent*, double, double );
00061   int close          ( Display* );
00062 #endif
00063 
00064  private:
00065   SVTK_SpaceMouse();
00066   static SVTK_SpaceMouse* myInstance;
00067 
00068 #ifndef WIN32
00069   Atom XMotionEvent;
00070   Atom XButtonPressEvent;
00071   Atom XButtonReleaseEvent;
00072   Atom XCommandEvent;
00073 
00074   Window win;
00075 #endif
00076   int spaceMouseOn;
00077 };
00078 
00079 #endif