VTK
dox/Rendering/Core/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 "vtkRenderingCoreModule.h" // For export macro
00053 #include "vtkWindow.h"
00054 
00055 class vtkFloatArray;
00056 class vtkPainterDeviceAdapter;
00057 class vtkProp;
00058 class vtkCollection;
00059 class vtkRenderWindowInteractor;
00060 class vtkRenderer;
00061 class vtkRendererCollection;
00062 class vtkUnsignedCharArray;
00063 
00064 // lets define the different types of stereo
00065 #define VTK_STEREO_CRYSTAL_EYES 1
00066 #define VTK_STEREO_RED_BLUE     2
00067 #define VTK_STEREO_INTERLACED   3
00068 #define VTK_STEREO_LEFT         4
00069 #define VTK_STEREO_RIGHT        5
00070 #define VTK_STEREO_DRESDEN      6
00071 #define VTK_STEREO_ANAGLYPH     7
00072 #define VTK_STEREO_CHECKERBOARD 8
00073 #define VTK_STEREO_SPLITVIEWPORT_HORIZONTAL 9
00074 
00075 #define VTK_CURSOR_DEFAULT   0
00076 #define VTK_CURSOR_ARROW     1
00077 #define VTK_CURSOR_SIZENE    2
00078 #define VTK_CURSOR_SIZENW    3
00079 #define VTK_CURSOR_SIZESW    4
00080 #define VTK_CURSOR_SIZESE    5
00081 #define VTK_CURSOR_SIZENS    6
00082 #define VTK_CURSOR_SIZEWE    7
00083 #define VTK_CURSOR_SIZEALL   8
00084 #define VTK_CURSOR_HAND      9
00085 #define VTK_CURSOR_CROSSHAIR 10
00086 
00088 
00095 #ifdef NDEBUG
00096 # define vtkGraphicErrorMacro(renderWindow,message)
00097 #else
00098 # define vtkGraphicErrorMacro(renderWindow,message)                     \
00099   if(renderWindow->GetReportGraphicErrors())                            \
00100     {                                                                   \
00101     renderWindow->CheckGraphicError();                                  \
00102     if(renderWindow->HasGraphicError())                                 \
00103       {                                                                 \
00104       vtkErrorMacro(<<message<<" "<<renderWindow->GetLastGraphicErrorString()); \
00105       }                                                                 \
00106     }
00107 #endif
00108 
00109 
00110 class VTKRENDERINGCORE_EXPORT vtkRenderWindow : public vtkWindow
00111 {
00112 public:
00113   vtkTypeMacro(vtkRenderWindow,vtkWindow);
00114   void PrintSelf(ostream& os, vtkIndent indent);
00115 
00119   static vtkRenderWindow *New();
00120 
00122   virtual void AddRenderer(vtkRenderer *);
00123 
00125   void RemoveRenderer(vtkRenderer *);
00126 
00128   int HasRenderer(vtkRenderer *);
00129 
00131   static const char *GetRenderLibrary();
00132 
00134   vtkRendererCollection *GetRenderers() {return this->Renderers;};
00135 
00141   void CaptureGL2PSSpecialProps(vtkCollection *specialProps);
00142 
00144 
00145   vtkGetMacro(CapturingGL2PSSpecialProps, int);
00147 
00150   virtual void Render();
00151 
00153   virtual void Start() = 0;
00154 
00156   virtual void Finalize() = 0;
00157 
00160   virtual void Frame() = 0;
00161 
00164   virtual void WaitForCompletion()=0;
00165 
00168   virtual void CopyResultFrame();
00169 
00173   virtual vtkRenderWindowInteractor *MakeRenderWindowInteractor();
00174 
00176 
00179   virtual void HideCursor() = 0;
00180   virtual void ShowCursor() = 0;
00181   virtual void SetCursorPosition(int , int ) {};
00183 
00185 
00186   vtkSetMacro(CurrentCursor,int);
00187   vtkGetMacro(CurrentCursor,int);
00189 
00191 
00192   virtual void SetFullScreen(int) = 0;
00193   vtkGetMacro(FullScreen,int);
00194   vtkBooleanMacro(FullScreen,int);
00196 
00198 
00201   vtkSetMacro(Borders,int);
00202   vtkGetMacro(Borders,int);
00203   vtkBooleanMacro(Borders,int);
00205 
00207 
00209   vtkGetMacro(StereoCapableWindow,int);
00210   vtkBooleanMacro(StereoCapableWindow,int);
00211   virtual void SetStereoCapableWindow(int capable);
00213 
00215 
00216   vtkGetMacro(StereoRender,int);
00217   void SetStereoRender(int stereo);
00218   vtkBooleanMacro(StereoRender,int);
00220 
00222 
00223   vtkSetMacro(AlphaBitPlanes, int);
00224   vtkGetMacro(AlphaBitPlanes, int);
00225   vtkBooleanMacro(AlphaBitPlanes, int);
00227 
00229 
00231   vtkSetMacro(PointSmoothing,int);
00232   vtkGetMacro(PointSmoothing,int);
00233   vtkBooleanMacro(PointSmoothing,int);
00235 
00237 
00239   vtkSetMacro(LineSmoothing,int);
00240   vtkGetMacro(LineSmoothing,int);
00241   vtkBooleanMacro(LineSmoothing,int);
00243 
00245 
00247   vtkSetMacro(PolygonSmoothing,int);
00248   vtkGetMacro(PolygonSmoothing,int);
00249   vtkBooleanMacro(PolygonSmoothing,int);
00251 
00253 
00265   vtkGetMacro(StereoType,int);
00266   vtkSetMacro(StereoType,int);
00267   void SetStereoTypeToCrystalEyes()
00268     {this->SetStereoType(VTK_STEREO_CRYSTAL_EYES);}
00269   void SetStereoTypeToRedBlue()
00270     {this->SetStereoType(VTK_STEREO_RED_BLUE);}
00271   void SetStereoTypeToInterlaced()
00272     {this->SetStereoType(VTK_STEREO_INTERLACED);}
00273   void SetStereoTypeToLeft()
00274     {this->SetStereoType(VTK_STEREO_LEFT);}
00275   void SetStereoTypeToRight()
00276     {this->SetStereoType(VTK_STEREO_RIGHT);}
00277   void SetStereoTypeToDresden()
00278     {this->SetStereoType(VTK_STEREO_DRESDEN);}
00279   void SetStereoTypeToAnaglyph()
00280     {this->SetStereoType(VTK_STEREO_ANAGLYPH);}
00281   void SetStereoTypeToCheckerboard()
00282     {this->SetStereoType(VTK_STEREO_CHECKERBOARD);}
00283   void SetStereoTypeToSplitViewportHorizontal()
00284     {this->SetStereoType(VTK_STEREO_SPLITVIEWPORT_HORIZONTAL);}
00286 
00287   const char *GetStereoTypeAsString();
00288 
00292   virtual void StereoUpdate();
00293 
00296   virtual void StereoMidpoint();
00297 
00300   virtual void StereoRenderComplete();
00301 
00303 
00308   vtkSetClampMacro(AnaglyphColorSaturation,float, 0.0f, 1.0f);
00309   vtkGetMacro(AnaglyphColorSaturation,float);
00311 
00313 
00324   vtkSetVector2Macro(AnaglyphColorMask,int);
00325   vtkGetVectorMacro(AnaglyphColorMask,int,2);
00327 
00331   virtual void WindowRemap() = 0;
00332 
00334 
00335   vtkSetMacro(SwapBuffers,int);
00336   vtkGetMacro(SwapBuffers,int);
00337   vtkBooleanMacro(SwapBuffers,int);
00339 
00341 
00350   virtual int SetPixelData(int x, int y, int x2, int y2, unsigned char *data,
00351                            int front) = 0;
00352   virtual int SetPixelData(int x, int y, int x2, int y2,
00353                            vtkUnsignedCharArray *data, int front) = 0;
00355 
00357 
00362   virtual float *GetRGBAPixelData(int x, int y, int x2, int y2, int front) = 0;
00363   virtual int GetRGBAPixelData(int x, int y, int x2, int y2, int front,
00364                                vtkFloatArray *data) = 0;
00365   virtual int SetRGBAPixelData(int x, int y, int x2, int y2, float *,
00366                                int front, int blend=0) = 0;
00367   virtual int SetRGBAPixelData(int, int, int, int, vtkFloatArray*,
00368                                int, int blend=0) = 0;
00369   virtual void ReleaseRGBAPixelData(float *data)=0;
00370   virtual unsigned char *GetRGBACharPixelData(int x, int y, int x2, int y2,
00371                                               int front) = 0;
00372   virtual int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
00373                                    vtkUnsignedCharArray *data) = 0;
00374   virtual int SetRGBACharPixelData(int x,int y, int x2, int y2,
00375                                    unsigned char *data, int front,
00376                                    int blend=0) = 0;
00377   virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
00378                                    vtkUnsignedCharArray *data, int front,
00379                                    int blend=0) = 0;
00381 
00383 
00385   virtual float *GetZbufferData(int x, int y, int x2, int y2) = 0;
00386   virtual int GetZbufferData(int x, int y, int x2, int y2, float *z) = 0;
00387   virtual int GetZbufferData(int x, int y, int x2, int y2,
00388                              vtkFloatArray *z) = 0;
00389   virtual int SetZbufferData(int x, int y, int x2, int y2, float *z) = 0;
00390   virtual int SetZbufferData(int x, int y, int x2, int y2,
00391                              vtkFloatArray *z) = 0;
00392   float GetZbufferDataAtPoint(int x, int y)
00393     {
00394     float value;
00395     this->GetZbufferData(x, y, x, y, &value);
00396     return value;
00397     }
00399 
00401 
00404   vtkGetMacro(AAFrames,int);
00405   vtkSetMacro(AAFrames,int);
00407 
00409 
00414   vtkGetMacro(FDFrames,int);
00415   virtual void SetFDFrames (int fdFrames);
00417 
00419 
00424   vtkGetMacro(UseConstantFDOffsets,int);
00425   vtkSetMacro(UseConstantFDOffsets,int);
00427 
00429 
00435   vtkGetMacro(SubFrames,int);
00436   virtual void SetSubFrames(int subFrames);
00438 
00440 
00441   vtkGetMacro(NeverRendered,int);
00443 
00445 
00447   vtkGetMacro(AbortRender,int);
00448   vtkSetMacro(AbortRender,int);
00449   vtkGetMacro(InAbortCheck,int);
00450   vtkSetMacro(InAbortCheck,int);
00451   virtual int CheckAbortStatus();
00453 
00454   vtkGetMacro(IsPicking,int);
00455   vtkSetMacro(IsPicking,int);
00456   vtkBooleanMacro(IsPicking,int);
00457 
00462   virtual int GetEventPending() = 0;
00463 
00465   virtual int  CheckInRenderStatus() { return this->InRender; }
00466 
00468   virtual void ClearInRenderStatus() { this->InRender = 0; }
00469 
00471 
00476   virtual void SetDesiredUpdateRate(double);
00477   vtkGetMacro(DesiredUpdateRate,double);
00479 
00481 
00485   vtkGetMacro(NumberOfLayers, int);
00486   vtkSetClampMacro(NumberOfLayers, int, 1, VTK_INT_MAX);
00488 
00490 
00491   vtkGetObjectMacro(Interactor,vtkRenderWindowInteractor);
00493 
00495   void SetInteractor(vtkRenderWindowInteractor *);
00496 
00499   virtual void UnRegister(vtkObjectBase *o);
00500 
00502 
00503   virtual void SetDisplayId(void *) = 0;
00504   virtual void SetWindowId(void *)  = 0;
00505   virtual void SetNextWindowId(void *) = 0;
00506   virtual void SetParentId(void *)  = 0;
00507   virtual void *GetGenericDisplayId() = 0;
00508   virtual void *GetGenericWindowId() = 0;
00509   virtual void *GetGenericParentId() = 0;
00510   virtual void *GetGenericContext() = 0;
00511   virtual void *GetGenericDrawable() = 0;
00512   virtual void SetWindowInfo(char *) = 0;
00513   virtual void SetNextWindowInfo(char *) = 0;
00514   virtual void SetParentInfo(char *) = 0;
00516 
00519   virtual bool InitializeFromCurrentContext() { return false; };
00520 
00523   virtual void MakeCurrent() = 0;
00524 
00527   virtual bool IsCurrent()=0;
00528 
00532   virtual void SetForceMakeCurrent() {};
00533 
00535   virtual const char *ReportCapabilities() { return "Not Implemented";};
00536 
00538   virtual int SupportsOpenGL() { return 0;};
00539 
00541   virtual int IsDirect() { return 0;};
00542 
00545   virtual int GetDepthBufferSize() = 0;
00546 
00549   virtual int GetColorBufferSizes(int *rgba) = 0;
00550 
00552 
00554   vtkGetObjectMacro(PainterDeviceAdapter, vtkPainterDeviceAdapter);
00556 
00558 
00560   vtkSetMacro(MultiSamples,int);
00561   vtkGetMacro(MultiSamples,int);
00563 
00565 
00566   vtkSetMacro(StencilCapable, int);
00567   vtkGetMacro(StencilCapable, int);
00568   vtkBooleanMacro(StencilCapable, int);
00570 
00572 
00574   vtkSetMacro(ReportGraphicErrors,int);
00575   vtkGetMacro(ReportGraphicErrors,int);
00576   vtkBooleanMacro(ReportGraphicErrors,int);
00578 
00582   virtual void CheckGraphicError()=0;
00583 
00585   virtual int HasGraphicError()=0;
00586 
00588   virtual const char *GetLastGraphicErrorString()=0;
00589 
00590 protected:
00591   vtkRenderWindow();
00592   ~vtkRenderWindow();
00593 
00594   virtual void DoStereoRender();
00595   virtual void DoFDRender();
00596   virtual void DoAARender();
00597 
00598   vtkPainterDeviceAdapter* PainterDeviceAdapter;
00599   vtkRendererCollection *Renderers;
00600   int Borders;
00601   int FullScreen;
00602   int OldScreen[5];
00603   int PointSmoothing;
00604   int LineSmoothing;
00605   int PolygonSmoothing;
00606   int StereoRender;
00607   int StereoType;
00608   int StereoStatus; // used for keeping track of what's going on
00609   int StereoCapableWindow;
00610   int AlphaBitPlanes;
00611   vtkRenderWindowInteractor *Interactor;
00612   unsigned char* StereoBuffer; // used for red blue stereo
00613   float *AccumulationBuffer;   // used for many techniques
00614   unsigned int AccumulationBufferSize;
00615   int AAFrames;
00616   int FDFrames;
00617   int UseConstantFDOffsets; // to use the same offsets at each rendering
00618   double *ConstantFDOffsets[2];
00619   int SubFrames;               // number of sub frames
00620   int CurrentSubFrame;         // what one are we on
00621   unsigned char *ResultFrame;  // used for any non immediate rendering
00622   int   SwapBuffers;
00623   double DesiredUpdateRate;
00624   int   AbortRender;
00625   int   InAbortCheck;
00626   int   InRender;
00627   int   NeverRendered;
00628   int   NumberOfLayers;
00629   int CurrentCursor;
00630   int IsPicking;
00631   float AnaglyphColorSaturation;
00632   int AnaglyphColorMask[2];
00633   int MultiSamples;
00634   int StencilCapable;
00635   int CapturingGL2PSSpecialProps;
00636 
00639   int ReportGraphicErrors;
00640 
00642   double AbortCheckTime;
00643 
00644 private:
00645   vtkRenderWindow(const vtkRenderWindow&);  // Not implemented.
00646   void operator=(const vtkRenderWindow&);  // Not implemented.
00647 };
00648 
00649 #endif