VTK
dox/Rendering/vtkRenderWindow.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkRenderWindow.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00049 #ifndef __vtkRenderWindow_h
00050 #define __vtkRenderWindow_h
00051 
00052 #include "vtkWindow.h"
00053 
00054 class vtkFloatArray;
00055 class vtkPainterDeviceAdapter;
00056 class vtkRenderWindowInteractor;
00057 class vtkRenderer;
00058 class vtkRendererCollection;
00059 class vtkUnsignedCharArray;
00060 
00061 // lets define the different types of stereo
00062 #define VTK_STEREO_CRYSTAL_EYES 1
00063 #define VTK_STEREO_RED_BLUE     2
00064 #define VTK_STEREO_INTERLACED   3
00065 #define VTK_STEREO_LEFT         4
00066 #define VTK_STEREO_RIGHT        5
00067 #define VTK_STEREO_DRESDEN      6
00068 #define VTK_STEREO_ANAGLYPH     7
00069 #define VTK_STEREO_CHECKERBOARD 8
00070 
00071 #define VTK_CURSOR_DEFAULT   0
00072 #define VTK_CURSOR_ARROW     1
00073 #define VTK_CURSOR_SIZENE    2
00074 #define VTK_CURSOR_SIZENW    3
00075 #define VTK_CURSOR_SIZESW    4
00076 #define VTK_CURSOR_SIZESE    5
00077 #define VTK_CURSOR_SIZENS    6
00078 #define VTK_CURSOR_SIZEWE    7
00079 #define VTK_CURSOR_SIZEALL   8
00080 #define VTK_CURSOR_HAND      9
00081 #define VTK_CURSOR_CROSSHAIR 10
00082 
00084 
00091 #ifdef NDEBUG
00092 # define vtkGraphicErrorMacro(renderWindow,message)
00093 #else
00094 # define vtkGraphicErrorMacro(renderWindow,message)                     \
00095   if(renderWindow->GetReportGraphicErrors())                            \
00096     {                                                                   \
00097     renderWindow->CheckGraphicError();                                  \
00098     if(renderWindow->HasGraphicError())                                 \
00099       {                                                                 \
00100       vtkErrorMacro(<<message<<" "<<renderWindow->GetLastGraphicErrorString()); \
00101       }                                                                 \
00102     }
00103 #endif
00104 
00105 
00106 class VTK_RENDERING_EXPORT vtkRenderWindow : public vtkWindow
00107 {
00108 public:
00109   vtkTypeMacro(vtkRenderWindow,vtkWindow);
00110   void PrintSelf(ostream& os, vtkIndent indent);
00111 
00115   static vtkRenderWindow *New();
00116 
00118   virtual void AddRenderer(vtkRenderer *);
00119 
00121   void RemoveRenderer(vtkRenderer *);
00122 
00124   int HasRenderer(vtkRenderer *);
00125 
00127   static const char *GetRenderLibrary();
00128 
00130   vtkRendererCollection *GetRenderers() {return this->Renderers;};
00131 
00134   virtual void Render();
00135 
00137   virtual void Start() = 0;
00138 
00140   virtual void Finalize() = 0;
00141 
00144   virtual void Frame() = 0;
00145 
00148   virtual void WaitForCompletion()=0;
00149   
00152   virtual void CopyResultFrame();
00153   
00157   virtual vtkRenderWindowInteractor *MakeRenderWindowInteractor();
00158 
00160 
00163   virtual void HideCursor() = 0;
00164   virtual void ShowCursor() = 0;
00165   virtual void SetCursorPosition(int , int ) {};
00167 
00169 
00170   vtkSetMacro(CurrentCursor,int);
00171   vtkGetMacro(CurrentCursor,int);
00173 
00175 
00176   virtual void SetFullScreen(int) = 0;
00177   vtkGetMacro(FullScreen,int);
00178   vtkBooleanMacro(FullScreen,int);
00180 
00182 
00185   vtkSetMacro(Borders,int);
00186   vtkGetMacro(Borders,int);
00187   vtkBooleanMacro(Borders,int);
00189 
00191 
00193   vtkGetMacro(StereoCapableWindow,int);
00194   vtkBooleanMacro(StereoCapableWindow,int);
00195   virtual void SetStereoCapableWindow(int capable);
00197 
00199 
00200   vtkGetMacro(StereoRender,int);
00201   void SetStereoRender(int stereo);
00202   vtkBooleanMacro(StereoRender,int);
00204 
00206 
00207   vtkSetMacro(AlphaBitPlanes, int);
00208   vtkGetMacro(AlphaBitPlanes, int);
00209   vtkBooleanMacro(AlphaBitPlanes, int);
00211 
00213 
00215   vtkSetMacro(PointSmoothing,int);
00216   vtkGetMacro(PointSmoothing,int);
00217   vtkBooleanMacro(PointSmoothing,int);
00219 
00221 
00223   vtkSetMacro(LineSmoothing,int);
00224   vtkGetMacro(LineSmoothing,int);
00225   vtkBooleanMacro(LineSmoothing,int);
00227 
00229 
00231   vtkSetMacro(PolygonSmoothing,int);
00232   vtkGetMacro(PolygonSmoothing,int);
00233   vtkBooleanMacro(PolygonSmoothing,int);
00235 
00237 
00249   vtkGetMacro(StereoType,int);
00250   vtkSetMacro(StereoType,int);
00251   void SetStereoTypeToCrystalEyes()
00252     {this->SetStereoType(VTK_STEREO_CRYSTAL_EYES);}
00253   void SetStereoTypeToRedBlue()
00254     {this->SetStereoType(VTK_STEREO_RED_BLUE);}
00255   void SetStereoTypeToInterlaced()
00256     {this->SetStereoType(VTK_STEREO_INTERLACED);}
00257   void SetStereoTypeToLeft()
00258     {this->SetStereoType(VTK_STEREO_LEFT);}
00259   void SetStereoTypeToRight()
00260     {this->SetStereoType(VTK_STEREO_RIGHT);}
00261   void SetStereoTypeToDresden()
00262     {this->SetStereoType(VTK_STEREO_DRESDEN);}
00263   void SetStereoTypeToAnaglyph()
00264     {this->SetStereoType(VTK_STEREO_ANAGLYPH);}
00265   void SetStereoTypeToCheckerboard()
00266     {this->SetStereoType(VTK_STEREO_CHECKERBOARD);}
00268 
00269   const char *GetStereoTypeAsString();
00270 
00274   virtual void StereoUpdate();
00275 
00278   virtual void StereoMidpoint();
00279 
00282   virtual void StereoRenderComplete();
00283 
00285 
00290   vtkSetClampMacro(AnaglyphColorSaturation,float, 0.0f, 1.0f);
00291   vtkGetMacro(AnaglyphColorSaturation,float);
00293 
00295 
00306   vtkSetVector2Macro(AnaglyphColorMask,int);
00307   vtkGetVectorMacro(AnaglyphColorMask,int,2);
00309 
00313   virtual void WindowRemap() = 0;
00314 
00316 
00317   vtkSetMacro(SwapBuffers,int);
00318   vtkGetMacro(SwapBuffers,int);
00319   vtkBooleanMacro(SwapBuffers,int);
00321   
00323 
00332   virtual int SetPixelData(int x, int y, int x2, int y2, unsigned char *data,
00333                            int front) = 0;
00334   virtual int SetPixelData(int x, int y, int x2, int y2,
00335                            vtkUnsignedCharArray *data, int front) = 0;
00337 
00339 
00344   virtual float *GetRGBAPixelData(int x, int y, int x2, int y2, int front) = 0;
00345   virtual int GetRGBAPixelData(int x, int y, int x2, int y2, int front,
00346                                vtkFloatArray *data) = 0;
00347   virtual int SetRGBAPixelData(int x, int y, int x2, int y2, float *,
00348                                int front, int blend=0) = 0;
00349   virtual int SetRGBAPixelData(int, int, int, int, vtkFloatArray*,
00350                                int, int blend=0) = 0;
00351   virtual void ReleaseRGBAPixelData(float *data)=0;
00352   virtual unsigned char *GetRGBACharPixelData(int x, int y, int x2, int y2,
00353                                               int front) = 0;
00354   virtual int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
00355                                    vtkUnsignedCharArray *data) = 0;
00356   virtual int SetRGBACharPixelData(int x,int y, int x2, int y2,
00357                                    unsigned char *data, int front,
00358                                    int blend=0) = 0;
00359   virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
00360                                    vtkUnsignedCharArray *data, int front,
00361                                    int blend=0) = 0;
00363 
00365 
00367   virtual float *GetZbufferData(int x, int y, int x2, int y2) = 0;
00368   virtual int GetZbufferData(int x, int y, int x2, int y2, float *z) = 0;
00369   virtual int GetZbufferData(int x, int y, int x2, int y2,
00370                              vtkFloatArray *z) = 0;
00371   virtual int SetZbufferData(int x, int y, int x2, int y2, float *z) = 0;
00372   virtual int SetZbufferData(int x, int y, int x2, int y2,
00373                              vtkFloatArray *z) = 0;
00374   float GetZbufferDataAtPoint(int x, int y)
00375     {
00376     float value;
00377     this->GetZbufferData(x, y, x, y, &value);
00378     return value;
00379     }
00381 
00383 
00386   vtkGetMacro(AAFrames,int);
00387   vtkSetMacro(AAFrames,int);
00389 
00391 
00396   vtkGetMacro(FDFrames,int);
00397   vtkSetMacro(FDFrames,int);
00399 
00401 
00407   vtkGetMacro(SubFrames,int);
00408   virtual void SetSubFrames(int subFrames);
00410 
00412 
00413   vtkGetMacro(NeverRendered,int);
00415 
00417 
00419   vtkGetMacro(AbortRender,int);
00420   vtkSetMacro(AbortRender,int);
00421   vtkGetMacro(InAbortCheck,int);
00422   vtkSetMacro(InAbortCheck,int);
00423   virtual int CheckAbortStatus();
00425 
00426   vtkGetMacro(IsPicking,int);
00427   vtkSetMacro(IsPicking,int);
00428   vtkBooleanMacro(IsPicking,int);
00429 
00434   virtual int GetEventPending() = 0;
00435 
00437   virtual int  CheckInRenderStatus() { return this->InRender; }
00438 
00440   virtual void ClearInRenderStatus() { this->InRender = 0; }
00441 
00443 
00448   virtual void SetDesiredUpdateRate(double);
00449   vtkGetMacro(DesiredUpdateRate,double);
00451 
00453 
00457   vtkGetMacro(NumberOfLayers, int);
00458   vtkSetClampMacro(NumberOfLayers, int, 1, VTK_LARGE_INTEGER);
00460 
00462 
00463   vtkGetObjectMacro(Interactor,vtkRenderWindowInteractor);
00465 
00467   void SetInteractor(vtkRenderWindowInteractor *);
00468 
00471   virtual void UnRegister(vtkObjectBase *o);
00472 
00474 
00475   virtual void SetDisplayId(void *) = 0;
00476   virtual void SetWindowId(void *)  = 0;
00477   virtual void SetNextWindowId(void *) = 0;
00478   virtual void SetParentId(void *)  = 0;
00479   virtual void *GetGenericDisplayId() = 0;
00480   virtual void *GetGenericWindowId() = 0;
00481   virtual void *GetGenericParentId() = 0;
00482   virtual void *GetGenericContext() = 0;
00483   virtual void *GetGenericDrawable() = 0;
00484   virtual void SetWindowInfo(char *) = 0;
00485   virtual void SetNextWindowInfo(char *) = 0;
00486   virtual void SetParentInfo(char *) = 0;
00488 
00491   virtual void MakeCurrent() = 0;
00492 
00495   virtual bool IsCurrent()=0;
00496   
00500   virtual void SetForceMakeCurrent() {};
00501 
00503   virtual const char *ReportCapabilities() { return "Not Implemented";};
00504 
00506   virtual int SupportsOpenGL() { return 0;};
00507 
00509   virtual int IsDirect() { return 0;};
00510 
00513   virtual int GetDepthBufferSize() = 0;
00514 
00517   virtual int GetColorBufferSizes(int *rgba) = 0;
00518 
00520 
00522   vtkGetObjectMacro(PainterDeviceAdapter, vtkPainterDeviceAdapter);
00524 
00526 
00528   vtkSetMacro(MultiSamples,int);
00529   vtkGetMacro(MultiSamples,int);
00531 
00533 
00534   vtkSetMacro(StencilCapable, int);
00535   vtkGetMacro(StencilCapable, int);
00536   vtkBooleanMacro(StencilCapable, int);
00538   
00540 
00542   vtkSetMacro(ReportGraphicErrors,int);
00543   vtkGetMacro(ReportGraphicErrors,int);
00544   vtkBooleanMacro(ReportGraphicErrors,int);
00546   
00550   virtual void CheckGraphicError()=0;
00551   
00553   virtual int HasGraphicError()=0;
00554   
00556   virtual const char *GetLastGraphicErrorString()=0;
00557   
00558 protected:
00559   vtkRenderWindow();
00560   ~vtkRenderWindow();
00561 
00562   virtual void DoStereoRender();
00563   virtual void DoFDRender();
00564   virtual void DoAARender();
00565 
00566   vtkPainterDeviceAdapter* PainterDeviceAdapter;
00567   vtkRendererCollection *Renderers;
00568   int Borders;
00569   int FullScreen;
00570   int OldScreen[5];
00571   int PointSmoothing;
00572   int LineSmoothing;
00573   int PolygonSmoothing;
00574   int StereoRender;
00575   int StereoType;
00576   int StereoStatus; // used for keeping track of what's going on
00577   int StereoCapableWindow;
00578   int AlphaBitPlanes;
00579   vtkRenderWindowInteractor *Interactor;
00580   unsigned char* StereoBuffer; // used for red blue stereo
00581   float *AccumulationBuffer;   // used for many techniques
00582   unsigned int AccumulationBufferSize;
00583   int AAFrames;
00584   int FDFrames;
00585   int SubFrames;               // number of sub frames
00586   int CurrentSubFrame;         // what one are we on
00587   unsigned char *ResultFrame;  // used for any non immediate rendering
00588   int   SwapBuffers;
00589   double DesiredUpdateRate;
00590   int   AbortRender;
00591   int   InAbortCheck;
00592   int   InRender;
00593   int   NeverRendered;
00594   int   NumberOfLayers;
00595   int CurrentCursor;
00596   int IsPicking;
00597   float AnaglyphColorSaturation;
00598   int AnaglyphColorMask[2];
00599   int MultiSamples;
00600   int StencilCapable;
00601   
00604   int ReportGraphicErrors;
00605 
00607   double AbortCheckTime;
00608   
00609 private:
00610   vtkRenderWindow(const vtkRenderWindow&);  // Not implemented.
00611   void operator=(const vtkRenderWindow&);  // Not implemented.
00612 };
00613 
00614 #endif