Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

vtkQtRenderWindow.h

00001 /*=========================================================================
00002   vtkQtRenderWindow.h - copyright 2000 Matthias Koenig 
00003   koenig@isg.cs.uni-magdeburg.de
00004   http://wwwisg.cs.uni-magdeburg.de/~makoenig
00005   =========================================================================*/
00006 /*=========================================================================
00007   This module is an extension of the "Visualization Toolkit 
00008   ( copyright (c) 1993-2000 Ken Martin, Will Schroeder, Bill Lorensen )".
00009   and combines it with "Qt (copyright (C) 1992-2000 Troll Tech AS)".
00010   =========================================================================*/
00011 /*=========================================================================
00012 
00013   Module:    $RCSfile: vtkQtRenderWindow.h,v $
00014 
00015   Redistribution and use in source and binary forms, with or without
00016   modification, are permitted provided that the following conditions are met:
00017   
00018   * Redistributions of source code must retain the above copyright notice,
00019   this list of conditions and the following disclaimer.
00020    
00021   * Redistributions in binary form must reproduce the above copyright notice,
00022   this list of conditions and the following disclaimer in the documentation
00023   and/or other materials provided with the distribution.
00024    
00025   * Modified source versions must be plainly marked as such, and must not be
00026   misrepresented as being the original software.
00027 
00028   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00029   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00030   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00031   ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
00032   ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00033   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00034   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00035   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00036   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038   
00039   =========================================================================*/
00055 #ifndef __vtkQtRenderWindow_h
00056 #define __vtkQtRenderWindow_h
00057 
00058 #include <qgl.h>
00059 #if defined(Q_GLX)
00060 #include <qintdict.h>
00061 #define INT8  dummy_INT8
00062 #define INT32 dummy_INT32
00063 #include <GL/glx.h>
00064 #undef  INT8
00065 #undef  INT32
00066 #define  GC GC_QQQ
00067 #include <X11/Xlib.h>
00068 #include <X11/Xutil.h>
00069 #include <X11/Xos.h>
00070 #include <X11/Xatom.h>
00071 #include <X11/Xmu/StdCmap.h>
00072 #endif
00073 
00074 #include <qapplication.h>
00075 #include "vtkRenderWindow.h"
00076 #include "vtkOpenGLRenderer.h"
00077 
00078 class vtkQtRenderWindowInteractor;
00079 
00080 class VTK_EXPORT vtkQtRenderWindow : public QGLWidget, public vtkRenderWindow
00081 {
00082 public:
00083   vtkQtRenderWindow(QWidget *parent = 0, const char* name = 0, const QGLWidget *shareWidget = 0, WFlags f = 0);
00084   vtkQtRenderWindow(const QGLFormat &format, QWidget *parent = 0, const char *name = 0, const QGLWidget *shareWidget = 0, WFlags f = 0);
00085   ~vtkQtRenderWindow();
00086   static vtkQtRenderWindow *New();
00087   static void initApp();
00088 
00089   vtkTypeMacro(vtkQtRenderWindow,vtkRenderWindow);
00090   void PrintSelf(ostream& os, vtkIndent indent);
00091 
00093   virtual void *GetGenericDisplayId() {return (void *)this->GetDisplayId();};
00094   virtual void *GetGenericWindowId()  {return (void *)this->WindowId;};
00095   virtual void *GetGenericDrawable()  {return (void *)this->WindowId;};
00096 
00098   Display *GetDisplayId();
00099 
00102   void SetDisplayId(Display *);
00103   void SetDisplayId(void *);
00104 
00106   Window   GetWindowId();
00107 
00109   void SetWindowId(Window);
00110   void SetWindowId(void *);
00111 
00113   void SetWindowInfo(char *info);
00114 
00116   static void SetGlobalMaximumNumberOfMultiSamples(int val);
00117   static int  GetGlobalMaximumNumberOfMultiSamples();
00118 
00121   vtkSetMacro(MultiSamples,int);
00122   vtkGetMacro(MultiSamples,int);
00123 
00125   unsigned char *GetPixelData(int x,int y,int x2,int y2,int front);
00126   void SetPixelData(int x,int y,int x2,int y2,unsigned char *,
00127                     int front);
00128 
00130   float *GetRGBAPixelData(int x,int y,int x2,int y2,int front);
00131   void SetRGBAPixelData(int x,int y,int x2,int y2,float *,int front,
00132                         int blend=0);
00133 
00135   float *GetZbufferData( int x1, int y1, int x2, int y2 );
00136   void SetZbufferData( int x1, int y1, int x2, int y2, float *buffer );
00137 
00138   // vtk mapping to Qt
00140   void Render(); //inline
00141 
00143   void MakeCurrent(); //inline
00144 
00146   void SetSize(int w,int h); //inline
00147   void SetSize(int a[2]); //inline
00148   vtkGetVector2Macro(Size,int);
00149 
00150   vtkRenderWindowInteractor* MakeRenderWindowInteractor();
00151   void SetInteractor(vtkQtRenderWindowInteractor*);
00152 
00153   // qt functions
00154   QSizePolicy sizePolicy() const; //inline
00155   QSize sizeHint() const;  //inline
00156   QSize minimumSizeHint() const;  //inline
00157 
00158   void initializeGL();
00159   void paintGL();
00160   void resizeGL(int, int);
00161 
00162   virtual void mousePressEvent(QMouseEvent*);
00163   virtual void mouseReleaseEvent(QMouseEvent*);
00164   virtual void mouseMoveEvent(QMouseEvent*);
00165   virtual void keyPressEvent(QKeyEvent*);
00166   virtual void keyReleaseEvent(QKeyEvent*);
00167 
00168   // If this widget is not the top level widget, it does not
00169   // get focus until it receives its first mouse click. By
00170   // overloading the enterEvent and leaveEvent methods, we
00171   // give keyboard focus to the widget when the mouse enters
00172   // and remove the focus once the mouse leaves.
00173 #if 1
00174   virtual void enterEvent( QEvent * ) { setFocus(); }
00175   virtual void leaveEvent( QEvent * ) { clearFocus(); }
00176 #else
00177   virtual void enterEvent( QEvent * ) {}
00178   virtual void leaveEvent( QEvent * ) {}
00179 #endif
00180 
00181 protected:
00182   int MultiSamples;
00183   long OldMonitorSetting;
00184 
00185 private:
00186   vtkQtRenderWindowInteractor* qtRenWinInt;
00187   static QApplication *qtapp;
00188   Window   WindowId;
00189   Display *DisplayId;
00190   int      OwnWindow;
00191   int      OwnDisplay;
00192 };
00193 
00194 inline void vtkQtRenderWindow::Render()      { updateGL(); }
00195 inline void vtkQtRenderWindow::MakeCurrent() { QGLWidget::makeCurrent(); }
00196 
00197 inline void vtkQtRenderWindow::SetSize(int w,int h)    { resizeGL(w, h); QGLWidget::resize(w, h); }
00198 inline void vtkQtRenderWindow::SetSize(int a[2])       { this->SetSize(a[0], a[1]); }
00199 
00200 inline QSizePolicy vtkQtRenderWindow::sizePolicy() const
00201   { return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); }
00202 
00203 inline QSize vtkQtRenderWindow::sizeHint() const
00204   { return QSize( 500, 500 ); }
00205 
00206 inline QSize vtkQtRenderWindow::minimumSizeHint() const
00207   { return QSize( 200, 200 ); }
00208 
00209 #endif // __vtkQtRenderWindow_h
00210 
00211 
00212 

Generated at Tue Sep 26 18:33:59 2000 for Grid Edit by doxygen1.2.0 written by Dimitri van Heesch, © 1997-2000