1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkTDxUnixDevice.h
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 // .NAME vtkTDxUnixDevice - Implementation of vtkTDxDevice on Unix
16 // .SECTION Description
17 // vtkTDxUnixDevice is a concrete implementation of vtkTDxDevice on Unix
18 // It uses the Magellan API.
19 // .SECTION See Also
20 // vtkTDxDevice, vtkTDxWinDevice
21 
22 #ifndef vtkTDxUnixDevice_h
23 #define vtkTDxUnixDevice_h
24 
25 #include "vtkRenderingOpenGLModule.h" // For export macro
26 #include "vtkTDxDevice.h"
27 //#include <X11/Xlib.h> // Needed for X types used in the public interface
28 class vtkRenderWindowInteractor;
29 
30 // We cannot include <X11/Xlib.h> (which defines "Display *",
31 // "Window" and "XEvent *") because it defines macro like None that would
32 // conflict with qt4/Qt/qcoreevent.h which defines None as a QEvent::Type
33 // value.
34 typedef void vtkTDxUnixDeviceDisplay;
35 typedef unsigned int vtkTDxUnixDeviceWindow;
36 typedef void vtkTDxUnixDeviceXEvent;
37 
38 class VTKRENDERINGOPENGL_EXPORT vtkTDxUnixDevice : public vtkTDxDevice
39 {
40 public:
41   static vtkTDxUnixDevice *New();
42   vtkTypeMacro(vtkTDxUnixDevice,vtkTDxDevice);
43   void PrintSelf(ostream& os, vtkIndent indent);
44 
45   // Description:
46   // Get the ID of the X Display. Initial value is 0.
47   // The return value type is actually a "Display *"
48   vtkTDxUnixDeviceDisplay *GetDisplayId() const;
49 
50   // Description:
51   // Get the ID of the X Window. Initial value is 0.
52   // The return value type is actually a "Window"
53   vtkTDxUnixDeviceWindow GetWindowId() const;
54 
55   // Description:
56   // Set the ID of the X Display.
57   // The argument type is actually a "Display *".
58   // \pre not_yet_initialized: !GetInitialized()
59   void SetDisplayId(vtkTDxUnixDeviceDisplay *id);
60 
61   // Description:
62   // Set the ID of the X Window.
63   // \pre not_yet_initialized: !GetInitialized()
64   void SetWindowId(vtkTDxUnixDeviceWindow id);
65 
66   // Description:
67   // Initialize the device with the current display and window ids.
68   // It updates the value of GetInitialized().
69   // Initialization can fail (if the device is not present or the driver is
70   // not running). You must look for the value of
71   // GetInitialized() before processing further.
72   // This interactor does not have to be set  before calling Initialize().
73   // However, in order to handle the events the Interactor has to be set
74   // otherwise ProcessEvent will be a no-op.
75   // \pre not_yet_initialized: !GetInitialized()
76   // \pre valid_display: GetDisplayId()!=0
77   // \pre valid_window: GetWindowId()!=0
78   // \pre valid_interactor: GetInteractor()!=0
79   void Initialize();
80 
81   // Description:
82   // See description in the superclass. Implementation for Unix.
83   virtual void Close();
84 
85   // Description:
86   // Translate the X11 event by invoking a VTK event, if the event came from
87   // the device.
88   // Return true if the event passed in argument was effectively an event from
89   // the device, return false otherwise.
90   // The interactor has to be set in order to get some events, otherwise they
91   // will be ignored.
92   // \pre initialized: GetInitialized()
93   // \pre e_exists: e!=0
94   // \pre e_is_client_message: e->type==ClientMessage
95   bool ProcessEvent(const vtkTDxUnixDeviceXEvent *e);
96 
97   // Description:
98   // PROBABLY TRANSFER IT TO THE SUPERCLASS
99   // Get/Set Scale factor on the translation motion. Initial value is 1.0
100   vtkGetMacro(TranslationScale,double);
101   vtkSetMacro(TranslationScale,double);
102 
103   // Description:
104   // PROBABLY TRANSFER IT TO THE SUPERCLASS
105   // Get/Set Scale factor on the rotation motion. Initial value is 1.0
106   vtkGetMacro(RotationScale,double);
107   vtkSetMacro(RotationScale,double);
108 
109   // Description:
110   // Set the sensitivity of the device for the current application.
111   // A neutral value is 1.0.
112   // \pre initialized: GetInitialized()
113   void SetSensitivity(double sensitivity);
114 
115 protected:
116   // Description:
117   // Default constructor. Just set initial values for
118   // DisplayId (0), WindowId (0), TranslationScale (1.0),
119   // RotationScale (1.0).
120   vtkTDxUnixDevice();
121 
122   // Description:
123   // Destructor. If the device is not initialized, do nothing. If the device
124   // is initialized, close the device.
125   virtual ~vtkTDxUnixDevice();
126 
127   vtkTDxUnixDeviceDisplay *DisplayId;
128   vtkTDxUnixDeviceWindow WindowId;
129 
130   double TranslationScale;
131   double RotationScale;
132 
133 private:
134   vtkTDxUnixDevice(const vtkTDxUnixDevice&);  // Not implemented.
135   void operator=(const vtkTDxUnixDevice&);  // Not implemented.
136 };
137 
138 #endif
139