1 // File : VTKViewer_RenderWindow.h
2 // Created : Wed Mar 20 11:33:30 2002
3 // Author : Nicolas REJNERI
6 // Copyright : Open CASCADE 2002
9 #ifndef VTKViewer_RenderWindow_h
10 #define VTKViewer_RenderWindow_h
13 #include <vtkRenderWindow.h>
16 #include "QAD_Popup.h"
18 // ------------------------------------------------------------
19 // :TRICKY: Fri Apr 21 22:19:27 2000 Pagey
20 // The Signal/Slot mechanism used by Qt requires that QGLWidget
21 // appear as the first class when using multiple inheritance.
22 // Hence the order of the two classes QGLWidget and vtkRenderWindow
23 // matters here. Be careful not to change it by accident.
24 // ------------------------------------------------------------
25 class VTK_EXPORT VTKViewer_RenderWindow :
26 public QGLWidget, virtual public vtkRenderWindow,
27 public QAD_PopupClientServer
31 /* popup management */
34 /* ------------------------------------------------------------
35 * Methods from vtkRenderWindow class.
37 static VTKViewer_RenderWindow *New(QWidget *parent=0, const char *name=0) {
38 return new VTKViewer_RenderWindow(parent,name) ;
40 const char *GetClassName() {return "VTKViewer_RenderWindow";};
41 void PrintSelf(ostream& os, vtkIndent indent);
43 virtual void Start(void);
44 virtual void Frame(void);
45 void WindowInitialize(void);
46 virtual void SetFullScreen(int);
47 virtual void WindowRemap(void);
48 void PrefFullScreen(void);
49 void SetSize(int,int);
51 virtual void *GetGenericDisplayId();
52 virtual void *GetGenericWindowId();
53 virtual void *GetGenericContext();
55 // stereo rendering stuff
56 virtual void StereoUpdate();
59 // Set/Get the pixel data of an image, transmitted as RGBRGB...
60 virtual unsigned char *GetPixelData(int x,int y,int x2,int y2,int front);
61 virtual void SetPixelData(int x,int y,int x2,int y2,unsigned char *,int front);
64 // Set/Get the pixel data of an image, transmitted as RGBARGBA...
65 virtual float *GetRGBAPixelData(int x,int y,int x2,int y2,int front);
66 virtual void SetRGBAPixelData(int x,int y,int x2,int y2,float *,int front,
70 // Set/Get the zbuffer data from an image
71 virtual float *GetZbufferData( int x1, int y1, int x2, int y2 );
72 virtual void SetZbufferData( int x1, int y1, int x2, int y2, float *buffer );
73 virtual void MakeCurrent();
75 /* ------------------------------------------------------------
76 * Methods from QGLWidget class.
78 virtual void setContext( QGLContext *context,
79 const QGLContext *shareContext=0,
80 bool deleteOldContex=TRUE ) ;
83 void onChangeBackgroundColor();
88 VTKViewer_RenderWindow(QWidget *parent, const char *name);
89 ~VTKViewer_RenderWindow() ;
90 VTKViewer_RenderWindow(const VTKViewer_RenderWindow&) { }
91 void operator=(const VTKViewer_RenderWindow&) { }
93 /* ------------------------------------------------------------
94 * Methods from QGLWidget class.
96 virtual void initializeGL() ;
97 virtual void paintGL() ;
98 virtual void resizeGL(int w, int h) ;
99 virtual void mouseMoveEvent( QMouseEvent * ) ;
100 virtual void mousePressEvent( QMouseEvent * ) ;
101 virtual void mouseReleaseEvent( QMouseEvent * ) ;
102 virtual void keyPressEvent( QKeyEvent * ) ;
104 // Every focus-in and focus-out event results in a repaint
105 // through the default implementations of focusInEvent and
106 // focusOutEvent. This results in a flicker in the vtkQGLRenderWindow
107 // ever time the cursor moves in or out of the widget. We can
108 // disble this by calling repaint(FALSE) in the implementation
111 /* virtual void focusInEvent( QFocusEvent * ) { repaint(FALSE) ; } */
112 /* virtual void focusOutEvent( QFocusEvent * ) { repaint(FALSE) ; } */
114 // If this widget is not the top level widget, it does not
115 // get focus until it receives its first mouse click. By
116 // overloading the enterEvent and leaveEvent methods, we
117 // give keyboard focus to the widget when the mouse enters
118 // and remove the focus once the mouse leaves.
120 /* virtual void enterEvent( QEvent * ) { setFocus() ; } */
121 /* virtual void leaveEvent( QEvent * ) { clearFocus() ; } */
123 /* ------------------------------------------------------------
124 * A few signals which will help us write an interactor for this
131 void MouseMove(const QMouseEvent *event) ;
133 // Left button pressed/released at the specified location.
135 void LeftButtonPressed(const QMouseEvent *event) ;
136 void LeftButtonReleased(const QMouseEvent *event) ;
138 // Middle button pressed/released at the specified location.
140 void MiddleButtonPressed(const QMouseEvent *event) ;
141 void MiddleButtonReleased(const QMouseEvent *event) ;
143 // Right button pressed/released at the specified location.
145 void RightButtonPressed(const QMouseEvent *event) ;
146 void RightButtonReleased(const QMouseEvent *event) ;
148 // Any mouse button pressed.
150 void ButtonPressed(const QMouseEvent *event) ;
151 void ButtonReleased(const QMouseEvent *event) ;
155 void KeyPressed(QKeyEvent *event) ;