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 
00087 #ifndef VTK_LEGACY_REMOVE
00088 // This macro should not be used, see vtkOpenGLError.h for
00089 // GL error handling functions and macros.
00090 #if defined NDEBUG
00091 # define vtkGraphicErrorMacro(renderWindow,message)   \
00092   renderWindow->CheckGraphicError();
00093 #else
00094 # define vtkGraphicErrorMacro(renderWindow,message)   \
00095   renderWindow->CheckGraphicError();                  \
00096   if ( renderWindow->GetReportGraphicErrors()         \
00097     && renderWindow->HasGraphicError() )              \
00098     {                                                 \
00099     vtkErrorMacro(                                    \
00100       << message << " "                               \
00101       << renderWindow->GetLastGraphicErrorString());  \
00102     }
00103 # endif
00104 #endif
00105 
00106 class VTKRENDERINGCORE_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 
00137   void CaptureGL2PSSpecialProps(vtkCollection *specialProps);
00138 
00140 
00141   vtkGetMacro(CapturingGL2PSSpecialProps, int);
00143 
00146   virtual void Render();
00147 
00149   virtual void Start() = 0;
00150 
00152   virtual void Finalize() = 0;
00153 
00156   virtual void Frame() = 0;
00157 
00160   virtual void WaitForCompletion()=0;
00161 
00164   virtual void CopyResultFrame();
00165 
00169   virtual vtkRenderWindowInteractor *MakeRenderWindowInteractor();
00170 
00172 
00175   virtual void HideCursor() = 0;
00176   virtual void ShowCursor() = 0;
00177   virtual void SetCursorPosition(int , int ) {}
00179 
00181 
00182   vtkSetMacro(CurrentCursor,int);
00183   vtkGetMacro(CurrentCursor,int);
00185 
00187 
00188   virtual void SetFullScreen(int) = 0;
00189   vtkGetMacro(FullScreen,int);
00190   vtkBooleanMacro(FullScreen,int);
00192 
00194 
00197   vtkSetMacro(Borders,int);
00198   vtkGetMacro(Borders,int);
00199   vtkBooleanMacro(Borders,int);
00201 
00203 
00205   vtkGetMacro(StereoCapableWindow,int);
00206   vtkBooleanMacro(StereoCapableWindow,int);
00207   virtual void SetStereoCapableWindow(int capable);
00209 
00211 
00212   vtkGetMacro(StereoRender,int);
00213   void SetStereoRender(int stereo);
00214   vtkBooleanMacro(StereoRender,int);
00216 
00218 
00219   vtkSetMacro(AlphaBitPlanes, int);
00220   vtkGetMacro(AlphaBitPlanes, int);
00221   vtkBooleanMacro(AlphaBitPlanes, int);
00223 
00225 
00227   vtkSetMacro(PointSmoothing,int);
00228   vtkGetMacro(PointSmoothing,int);
00229   vtkBooleanMacro(PointSmoothing,int);
00231 
00233 
00235   vtkSetMacro(LineSmoothing,int);
00236   vtkGetMacro(LineSmoothing,int);
00237   vtkBooleanMacro(LineSmoothing,int);
00239 
00241 
00243   vtkSetMacro(PolygonSmoothing,int);
00244   vtkGetMacro(PolygonSmoothing,int);
00245   vtkBooleanMacro(PolygonSmoothing,int);
00247 
00249 
00261   vtkGetMacro(StereoType,int);
00262   vtkSetMacro(StereoType,int);
00263   void SetStereoTypeToCrystalEyes()
00264     {this->SetStereoType(VTK_STEREO_CRYSTAL_EYES);}
00265   void SetStereoTypeToRedBlue()
00266     {this->SetStereoType(VTK_STEREO_RED_BLUE);}
00267   void SetStereoTypeToInterlaced()
00268     {this->SetStereoType(VTK_STEREO_INTERLACED);}
00269   void SetStereoTypeToLeft()
00270     {this->SetStereoType(VTK_STEREO_LEFT);}
00271   void SetStereoTypeToRight()
00272     {this->SetStereoType(VTK_STEREO_RIGHT);}
00273   void SetStereoTypeToDresden()
00274     {this->SetStereoType(VTK_STEREO_DRESDEN);}
00275   void SetStereoTypeToAnaglyph()
00276     {this->SetStereoType(VTK_STEREO_ANAGLYPH);}
00277   void SetStereoTypeToCheckerboard()
00278     {this->SetStereoType(VTK_STEREO_CHECKERBOARD);}
00279   void SetStereoTypeToSplitViewportHorizontal()
00280     {this->SetStereoType(VTK_STEREO_SPLITVIEWPORT_HORIZONTAL);}
00282 
00283   const char *GetStereoTypeAsString();
00284 
00288   virtual void StereoUpdate();
00289 
00292   virtual void StereoMidpoint();
00293 
00296   virtual void StereoRenderComplete();
00297 
00299 
00304   vtkSetClampMacro(AnaglyphColorSaturation,float, 0.0f, 1.0f);
00305   vtkGetMacro(AnaglyphColorSaturation,float);
00307 
00309 
00320   vtkSetVector2Macro(AnaglyphColorMask,int);
00321   vtkGetVectorMacro(AnaglyphColorMask,int,2);
00323 
00327   virtual void WindowRemap() = 0;
00328 
00330 
00331   vtkSetMacro(SwapBuffers,int);
00332   vtkGetMacro(SwapBuffers,int);
00333   vtkBooleanMacro(SwapBuffers,int);
00335 
00337 
00346   virtual int SetPixelData(int x, int y, int x2, int y2, unsigned char *data,
00347                            int front) = 0;
00348   virtual int SetPixelData(int x, int y, int x2, int y2,
00349                            vtkUnsignedCharArray *data, int front) = 0;
00351 
00353 
00358   virtual float *GetRGBAPixelData(int x, int y, int x2, int y2, int front) = 0;
00359   virtual int GetRGBAPixelData(int x, int y, int x2, int y2, int front,
00360                                vtkFloatArray *data) = 0;
00361   virtual int SetRGBAPixelData(int x, int y, int x2, int y2, float *,
00362                                int front, int blend=0) = 0;
00363   virtual int SetRGBAPixelData(int, int, int, int, vtkFloatArray*,
00364                                int, int blend=0) = 0;
00365   virtual void ReleaseRGBAPixelData(float *data)=0;
00366   virtual unsigned char *GetRGBACharPixelData(int x, int y, int x2, int y2,
00367                                               int front) = 0;
00368   virtual int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
00369                                    vtkUnsignedCharArray *data) = 0;
00370   virtual int SetRGBACharPixelData(int x,int y, int x2, int y2,
00371                                    unsigned char *data, int front,
00372                                    int blend=0) = 0;
00373   virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
00374                                    vtkUnsignedCharArray *data, int front,
00375                                    int blend=0) = 0;
00377 
00379 
00381   virtual float *GetZbufferData(int x, int y, int x2, int y2) = 0;
00382   virtual int GetZbufferData(int x, int y, int x2, int y2, float *z) = 0;
00383   virtual int GetZbufferData(int x, int y, int x2, int y2,
00384                              vtkFloatArray *z) = 0;
00385   virtual int SetZbufferData(int x, int y, int x2, int y2, float *z) = 0;
00386   virtual int SetZbufferData(int x, int y, int x2, int y2,
00387                              vtkFloatArray *z) = 0;
00388   float GetZbufferDataAtPoint(int x, int y)
00389     {
00390     float value;
00391     this->GetZbufferData(x, y, x, y, &value);
00392     return value;
00393     }
00395 
00397 
00400   vtkGetMacro(AAFrames,int);
00401   vtkSetMacro(AAFrames,int);
00403 
00405 
00410   vtkGetMacro(FDFrames,int);
00411   virtual void SetFDFrames (int fdFrames);
00413 
00415 
00420   vtkGetMacro(UseConstantFDOffsets,int);
00421   vtkSetMacro(UseConstantFDOffsets,int);
00423 
00425 
00431   vtkGetMacro(SubFrames,int);
00432   virtual void SetSubFrames(int subFrames);
00434 
00436 
00437   vtkGetMacro(NeverRendered,int);
00439 
00441 
00443   vtkGetMacro(AbortRender,int);
00444   vtkSetMacro(AbortRender,int);
00445   vtkGetMacro(InAbortCheck,int);
00446   vtkSetMacro(InAbortCheck,int);
00447   virtual int CheckAbortStatus();
00449 
00450   vtkGetMacro(IsPicking,int);
00451   vtkSetMacro(IsPicking,int);
00452   vtkBooleanMacro(IsPicking,int);
00453 
00458   virtual int GetEventPending() = 0;
00459 
00461   virtual int  CheckInRenderStatus() { return this->InRender; }
00462 
00464   virtual void ClearInRenderStatus() { this->InRender = 0; }
00465 
00467 
00472   virtual void SetDesiredUpdateRate(double);
00473   vtkGetMacro(DesiredUpdateRate,double);
00475 
00477 
00481   vtkGetMacro(NumberOfLayers, int);
00482   vtkSetClampMacro(NumberOfLayers, int, 1, VTK_INT_MAX);
00484 
00486 
00487   vtkGetObjectMacro(Interactor,vtkRenderWindowInteractor);
00489 
00491   void SetInteractor(vtkRenderWindowInteractor *);
00492 
00495   virtual void UnRegister(vtkObjectBase *o);
00496 
00498 
00499   virtual void SetDisplayId(void *) = 0;
00500   virtual void SetWindowId(void *)  = 0;
00501   virtual void SetNextWindowId(void *) = 0;
00502   virtual void SetParentId(void *)  = 0;
00503   virtual void *GetGenericDisplayId() = 0;
00504   virtual void *GetGenericWindowId() = 0;
00505   virtual void *GetGenericParentId() = 0;
00506   virtual void *GetGenericContext() = 0;
00507   virtual void *GetGenericDrawable() = 0;
00508   virtual void SetWindowInfo(char *) = 0;
00509   virtual void SetNextWindowInfo(char *) = 0;
00510   virtual void SetParentInfo(char *) = 0;
00512 
00515   virtual bool InitializeFromCurrentContext() { return false; };
00516 
00519   virtual void MakeCurrent() = 0;
00520 
00523   virtual bool IsCurrent()=0;
00524 
00529   virtual bool IsDrawable(){ return true; }
00530 
00534   virtual void SetForceMakeCurrent() {}
00535 
00537   virtual const char *ReportCapabilities() { return "Not Implemented";};
00538 
00540   virtual int SupportsOpenGL() { return 0;};
00541 
00543   virtual int IsDirect() { return 0;};
00544 
00547   virtual int GetDepthBufferSize() = 0;
00548 
00551   virtual int GetColorBufferSizes(int *rgba) = 0;
00552 
00554 
00556   vtkGetObjectMacro(PainterDeviceAdapter, vtkPainterDeviceAdapter);
00558 
00560 
00562   vtkSetMacro(MultiSamples,int);
00563   vtkGetMacro(MultiSamples,int);
00565 
00567 
00568   vtkSetMacro(StencilCapable, int);
00569   vtkGetMacro(StencilCapable, int);
00570   vtkBooleanMacro(StencilCapable, int);
00572 
00574 
00577   VTK_LEGACY(void SetReportGraphicErrors(int val));
00578   VTK_LEGACY(void SetReportGraphicErrorsOn());
00579   VTK_LEGACY(void SetReportGraphicErrorsOff());
00580   VTK_LEGACY(int GetReportGraphicErrors());
00582 
00583 #ifndef VTK_LEGACY_REMOVE
00584 
00585 
00586   virtual void CheckGraphicError() = 0;
00587   virtual int HasGraphicError() = 0;
00588   virtual const char *GetLastGraphicErrorString() = 0;
00589 #endif
00590 
00591 
00592 protected:
00593   vtkRenderWindow();
00594   ~vtkRenderWindow();
00595 
00596   virtual void DoStereoRender();
00597   virtual void DoFDRender();
00598   virtual void DoAARender();
00599 
00600   vtkPainterDeviceAdapter* PainterDeviceAdapter;
00601   vtkRendererCollection *Renderers;
00602   int Borders;
00603   int FullScreen;
00604   int OldScreen[5];
00605   int PointSmoothing;
00606   int LineSmoothing;
00607   int PolygonSmoothing;
00608   int StereoRender;
00609   int StereoType;
00610   int StereoStatus; // used for keeping track of what's going on
00611   int StereoCapableWindow;
00612   int AlphaBitPlanes;
00613   vtkRenderWindowInteractor *Interactor;
00614   unsigned char* StereoBuffer; // used for red blue stereo
00615   float *AccumulationBuffer;   // used for many techniques
00616   unsigned int AccumulationBufferSize;
00617   int AAFrames;
00618   int FDFrames;
00619   int UseConstantFDOffsets; // to use the same offsets at each rendering
00620   double *ConstantFDOffsets[2];
00621   int SubFrames;               // number of sub frames
00622   int CurrentSubFrame;         // what one are we on
00623   unsigned char *ResultFrame;  // used for any non immediate rendering
00624   int   SwapBuffers;
00625   double DesiredUpdateRate;
00626   int   AbortRender;
00627   int   InAbortCheck;
00628   int   InRender;
00629   int   NeverRendered;
00630   int   NumberOfLayers;
00631   int CurrentCursor;
00632   int IsPicking;
00633   float AnaglyphColorSaturation;
00634   int AnaglyphColorMask[2];
00635   int MultiSamples;
00636   int StencilCapable;
00637   int CapturingGL2PSSpecialProps;
00638 
00639 #ifndef VTK_LEGACY_REMOVE
00640 
00641 
00644   int ReportGraphicErrors;
00645 #endif
00646 
00647 
00649   double AbortCheckTime;
00650 
00651 private:
00652   vtkRenderWindow(const vtkRenderWindow&);  // Not implemented.
00653   void operator=(const vtkRenderWindow&);  // Not implemented.
00654 };
00655 
00656 #endif