]> SALOME platform Git repositories - modules/kernel.git/blob - src/VTKViewer/VTKViewer_RenderWindow.h
Salome HOME
NRI : KERNEL is now defined in KERNELCatalog.
[modules/kernel.git] / src / VTKViewer / VTKViewer_RenderWindow.h
1 //  File      : VTKViewer_RenderWindow.h
2 //  Created   : Wed Mar 20 11:33:30 2002
3 //  Author    : Nicolas REJNERI
4 //  Project   : SALOME
5 //  Module    : VTKViewer
6 //  Copyright : Open CASCADE 2002
7 //  $Header$
8
9 #ifndef VTKViewer_RenderWindow_h
10 #define VTKViewer_RenderWindow_h
11
12 #include <stdlib.h>
13 #include <vtkRenderWindow.h>
14 #include <qgl.h>
15
16 #include "QAD_Popup.h"
17
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
28 {
29   Q_OBJECT 
30     public:
31   /* popup management */
32   void                    onCreatePopup();
33
34   /* ------------------------------------------------------------
35    * Methods from vtkRenderWindow class. 
36    */
37   static VTKViewer_RenderWindow *New(QWidget *parent=0, const char *name=0) {
38     return new VTKViewer_RenderWindow(parent,name) ;
39   };
40   const char *GetClassName() {return "VTKViewer_RenderWindow";};
41   void PrintSelf(ostream& os, vtkIndent indent);
42   
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);
50
51   virtual void *GetGenericDisplayId();
52   virtual void *GetGenericWindowId();
53   virtual void *GetGenericContext();
54
55   // stereo rendering stuff
56   virtual void StereoUpdate();
57
58   // Description:
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);
62
63   // Description:
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,
67                                 int blend=0);
68
69   // Description:
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();
74
75   /* ------------------------------------------------------------
76    * Methods from QGLWidget class. 
77    */
78   virtual void setContext( QGLContext *context, 
79                            const QGLContext *shareContext=0, 
80                            bool deleteOldContex=TRUE ) ;
81
82   protected slots:
83     void onChangeBackgroundColor();
84
85   //NRIprotected:
86  public:
87   bool mInitialized ;
88   VTKViewer_RenderWindow(QWidget *parent, const char *name);
89   ~VTKViewer_RenderWindow() ;
90   VTKViewer_RenderWindow(const VTKViewer_RenderWindow&) { } 
91   void operator=(const VTKViewer_RenderWindow&) { } 
92
93   /* ------------------------------------------------------------
94    * Methods from QGLWidget class. 
95    */
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 * ) ;
103   //
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
109   // of these methods. 
110   //
111 /*    virtual void focusInEvent( QFocusEvent * ) { repaint(FALSE) ; } */
112 /*    virtual void focusOutEvent( QFocusEvent * ) { repaint(FALSE) ; } */
113   //
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. 
119   //
120  /*   virtual void enterEvent( QEvent * ) { setFocus() ; } */
121 /*    virtual void leaveEvent( QEvent * ) { clearFocus() ; } */
122
123   /* ------------------------------------------------------------
124    * A few signals which will help us write an interactor for this
125    * render window. 
126    */
127  signals:
128   //
129   // Mouse moved. 
130   //
131   void MouseMove(const QMouseEvent *event) ;
132   //
133   // Left button pressed/released at the specified location.
134   //
135   void LeftButtonPressed(const QMouseEvent *event) ;
136   void LeftButtonReleased(const QMouseEvent *event) ;
137   //
138   // Middle button pressed/released at the specified location.
139   //
140   void MiddleButtonPressed(const QMouseEvent *event) ;
141   void MiddleButtonReleased(const QMouseEvent *event) ;
142   //
143   // Right button pressed/released at the specified location.
144   //
145   void RightButtonPressed(const QMouseEvent *event) ;
146   void RightButtonReleased(const QMouseEvent *event) ;
147   //
148   // Any mouse button pressed.
149   //
150   void ButtonPressed(const QMouseEvent *event) ;
151   void ButtonReleased(const QMouseEvent *event) ;
152   //
153   // Any key pressed.
154   //
155   void KeyPressed(QKeyEvent *event) ;
156 };
157
158 #endif