VTK
vtkRenderWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkRenderWindow.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
47 #ifndef vtkRenderWindow_h
48 #define vtkRenderWindow_h
49 
50 #include "vtkRenderingCoreModule.h" // For export macro
51 #include "vtkWindow.h"
52 #include "vtkNew.h" // For vtkNew
53 
54 class vtkFloatArray;
55 #ifndef VTK_LEGACY_REMOVE
57 #endif
58 class vtkProp;
59 class vtkCollection;
60 class vtkRenderTimerLog;
62 class vtkRenderer;
65 
66 // lets define the different types of stereo
67 #define VTK_STEREO_CRYSTAL_EYES 1
68 #define VTK_STEREO_RED_BLUE 2
69 #define VTK_STEREO_INTERLACED 3
70 #define VTK_STEREO_LEFT 4
71 #define VTK_STEREO_RIGHT 5
72 #define VTK_STEREO_DRESDEN 6
73 #define VTK_STEREO_ANAGLYPH 7
74 #define VTK_STEREO_CHECKERBOARD 8
75 #define VTK_STEREO_SPLITVIEWPORT_HORIZONTAL 9
76 #define VTK_STEREO_FAKE 10
77 
78 #define VTK_CURSOR_DEFAULT 0
79 #define VTK_CURSOR_ARROW 1
80 #define VTK_CURSOR_SIZENE 2
81 #define VTK_CURSOR_SIZENW 3
82 #define VTK_CURSOR_SIZESW 4
83 #define VTK_CURSOR_SIZESE 5
84 #define VTK_CURSOR_SIZENS 6
85 #define VTK_CURSOR_SIZEWE 7
86 #define VTK_CURSOR_SIZEALL 8
87 #define VTK_CURSOR_HAND 9
88 #define VTK_CURSOR_CROSSHAIR 10
89 
90 class VTKRENDERINGCORE_EXPORT vtkRenderWindow : public vtkWindow
91 {
92 public:
93  vtkTypeMacro(vtkRenderWindow,vtkWindow);
94  void PrintSelf(ostream& os, vtkIndent indent) override;
95 
101  static vtkRenderWindow *New();
102 
106  virtual void AddRenderer(vtkRenderer *);
107 
111  void RemoveRenderer(vtkRenderer *);
112 
116  int HasRenderer(vtkRenderer *);
117 
121  static const char *GetRenderLibrary();
122 
126  virtual const char *GetRenderingBackend();
127 
132 
133 
136  vtkRendererCollection *GetRenderers() {return this->Renderers;};
137 
145  void CaptureGL2PSSpecialProps(vtkCollection *specialProps);
146 
148 
151  vtkGetMacro(CapturingGL2PSSpecialProps, int);
153 
158  void Render() override;
159 
163  virtual void Start() = 0;
164 
168  virtual void Finalize() = 0;
169 
174  virtual void Frame() = 0;
175 
180  virtual void WaitForCompletion()=0;
181 
186  virtual void CopyResultFrame();
187 
193  virtual vtkRenderWindowInteractor *MakeRenderWindowInteractor();
194 
196 
202  virtual void HideCursor() = 0;
203  virtual void ShowCursor() = 0;
204  virtual void SetCursorPosition(int , int ) {}
206 
208 
211  vtkSetMacro(CurrentCursor,int);
212  vtkGetMacro(CurrentCursor,int);
214 
216 
219  virtual void SetFullScreen(int) = 0;
220  vtkGetMacro(FullScreen,int);
221  vtkBooleanMacro(FullScreen,int);
223 
225 
230  vtkSetMacro(Borders,int);
231  vtkGetMacro(Borders,int);
232  vtkBooleanMacro(Borders,int);
234 
236 
240  vtkGetMacro(StereoCapableWindow,int);
241  vtkBooleanMacro(StereoCapableWindow,int);
242  virtual void SetStereoCapableWindow(int capable);
244 
246 
249  vtkGetMacro(StereoRender,int);
250  void SetStereoRender(int stereo);
251  vtkBooleanMacro(StereoRender,int);
253 
255 
258  vtkSetMacro(AlphaBitPlanes, int);
259  vtkGetMacro(AlphaBitPlanes, int);
260  vtkBooleanMacro(AlphaBitPlanes, int);
262 
264 
268  vtkSetMacro(PointSmoothing,int);
269  vtkGetMacro(PointSmoothing,int);
270  vtkBooleanMacro(PointSmoothing,int);
272 
274 
278  vtkSetMacro(LineSmoothing,int);
279  vtkGetMacro(LineSmoothing,int);
280  vtkBooleanMacro(LineSmoothing,int);
282 
284 
288  vtkSetMacro(PolygonSmoothing,int);
289  vtkGetMacro(PolygonSmoothing,int);
290  vtkBooleanMacro(PolygonSmoothing,int);
292 
294 
312  vtkGetMacro(StereoType,int);
313  vtkSetMacro(StereoType,int);
315  {this->SetStereoType(VTK_STEREO_CRYSTAL_EYES);}
317  {this->SetStereoType(VTK_STEREO_RED_BLUE);}
319  {this->SetStereoType(VTK_STEREO_INTERLACED);}
321  {this->SetStereoType(VTK_STEREO_LEFT);}
323  {this->SetStereoType(VTK_STEREO_RIGHT);}
325  {this->SetStereoType(VTK_STEREO_DRESDEN);}
327  {this->SetStereoType(VTK_STEREO_ANAGLYPH);}
329  {this->SetStereoType(VTK_STEREO_CHECKERBOARD);}
331  {this->SetStereoType(VTK_STEREO_SPLITVIEWPORT_HORIZONTAL);}
333  {this->SetStereoType(VTK_STEREO_FAKE);}
335 
336  const char *GetStereoTypeAsString();
337 
342  virtual void StereoUpdate();
343 
348  virtual void StereoMidpoint();
349 
354  virtual void StereoRenderComplete();
355 
357 
364  vtkSetClampMacro(AnaglyphColorSaturation,float, 0.0f, 1.0f);
365  vtkGetMacro(AnaglyphColorSaturation,float);
367 
369 
383  vtkSetVector2Macro(AnaglyphColorMask,int);
384  vtkGetVectorMacro(AnaglyphColorMask,int,2);
386 
392  virtual void WindowRemap() = 0;
393 
395 
398  vtkSetMacro(SwapBuffers,int);
399  vtkGetMacro(SwapBuffers,int);
400  vtkBooleanMacro(SwapBuffers,int);
402 
404 
416  virtual int SetPixelData(int x, int y, int x2, int y2, unsigned char *data,
417  int front, int right=0) = 0;
418  virtual int SetPixelData(int x, int y, int x2, int y2,
419  vtkUnsignedCharArray *data, int front, int right=0) = 0;
421 
423 
430  virtual float *GetRGBAPixelData(int x, int y, int x2, int y2, int front, int right=0) = 0;
431  virtual int GetRGBAPixelData(int x, int y, int x2, int y2, int front,
432  vtkFloatArray *data, int right=0) = 0;
433  virtual int SetRGBAPixelData(int x, int y, int x2, int y2, float *,
434  int front, int blend=0, int right=0) = 0;
435  virtual int SetRGBAPixelData(int, int, int, int, vtkFloatArray*,
436  int, int blend=0, int right=0) = 0;
437  virtual void ReleaseRGBAPixelData(float *data) = 0;
438  virtual unsigned char *GetRGBACharPixelData(int x, int y, int x2, int y2,
439  int front, int right=0) = 0;
440  virtual int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
441  vtkUnsignedCharArray *data, int right=0) = 0;
442  virtual int SetRGBACharPixelData(int x,int y, int x2, int y2,
443  unsigned char *data, int front,
444  int blend=0, int right=0) = 0;
445  virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
446  vtkUnsignedCharArray *data, int front,
447  int blend=0, int right=0) = 0;
449 
451 
456  virtual float *GetZbufferData(int x, int y, int x2, int y2) = 0;
457  virtual int GetZbufferData(int x, int y, int x2, int y2, float *z) = 0;
458  virtual int GetZbufferData(int x, int y, int x2, int y2,
459  vtkFloatArray *z) = 0;
460  virtual int SetZbufferData(int x, int y, int x2, int y2, float *z) = 0;
461  virtual int SetZbufferData(int x, int y, int x2, int y2,
462  vtkFloatArray *z) = 0;
463  float GetZbufferDataAtPoint(int x, int y)
464  {
465  float value;
466  this->GetZbufferData(x, y, x, y, &value);
467  return value;
468  }
470 
472 
477  VTK_LEGACY(virtual void SetAAFrames(int));
478  VTK_LEGACY(virtual int GetAAFrames());
480 
482 
489  VTK_LEGACY(virtual int GetFDFrames());
490  VTK_LEGACY(virtual void SetFDFrames(int fdFrames));
492 
494 
501  VTK_LEGACY(virtual int GetUseConstantFDOffsets());
502  VTK_LEGACY(virtual void SetUseConstantFDOffsets(int));
504 
506 
514  VTK_LEGACY(virtual int GetSubFrames());
515  VTK_LEGACY(virtual void SetSubFrames(int subFrames));
517 
519 
522  vtkGetMacro(NeverRendered,int);
524 
526 
530  vtkGetMacro(AbortRender,int);
531  vtkSetMacro(AbortRender,int);
532  vtkGetMacro(InAbortCheck,int);
533  vtkSetMacro(InAbortCheck,int);
534  virtual int CheckAbortStatus();
536 
537  vtkGetMacro(IsPicking,int);
538  vtkSetMacro(IsPicking,int);
539  vtkBooleanMacro(IsPicking,int);
540 
547  virtual int GetEventPending() = 0;
548 
552  virtual int CheckInRenderStatus() { return this->InRender; }
553 
557  virtual void ClearInRenderStatus() { this->InRender = 0; }
558 
560 
568  virtual void SetDesiredUpdateRate(double);
569  vtkGetMacro(DesiredUpdateRate,double);
571 
573 
579  vtkGetMacro(NumberOfLayers, int);
580  vtkSetClampMacro(NumberOfLayers, int, 1, VTK_INT_MAX);
582 
584 
587  vtkGetObjectMacro(Interactor,vtkRenderWindowInteractor);
589 
593  void SetInteractor(vtkRenderWindowInteractor *);
594 
599  void UnRegister(vtkObjectBase *o) override;
600 
602 
605  void SetDisplayId(void *) override = 0;
606  void SetWindowId(void *) override = 0;
607  virtual void SetNextWindowId(void *) = 0;
608  void SetParentId(void *) override = 0;
609  void *GetGenericDisplayId() override = 0;
610  void *GetGenericWindowId() override = 0;
611  void *GetGenericParentId() override = 0;
612  void *GetGenericContext() override = 0;
613  void *GetGenericDrawable() override = 0;
614  void SetWindowInfo(char *) override = 0;
615  virtual void SetNextWindowInfo(char *) = 0;
616  void SetParentInfo(char *) override = 0;
618 
623  virtual bool InitializeFromCurrentContext() { return false; };
624 
629  void MakeCurrent() override = 0;
630 
635  virtual bool IsCurrent()=0;
636 
643  virtual bool IsDrawable(){ return true; }
644 
650  virtual void SetForceMakeCurrent() {}
651 
655  virtual const char *ReportCapabilities() { return "Not Implemented";};
656 
660  virtual int SupportsOpenGL() { return 0;};
661 
665  virtual int IsDirect() { return 0;};
666 
671  virtual int GetDepthBufferSize() = 0;
672 
677  virtual int GetColorBufferSizes(int *rgba) = 0;
678 
680 
685  VTK_LEGACY(vtkPainterDeviceAdapter *GetPainterDeviceAdapter());
687 
689 
692  vtkSetMacro(MultiSamples,int);
693  vtkGetMacro(MultiSamples,int);
695 
697 
700  vtkSetMacro(StencilCapable, int);
701  vtkGetMacro(StencilCapable, int);
702  vtkBooleanMacro(StencilCapable, int);
704 
706 
712  vtkSetMacro(DeviceIndex,int);
713  vtkGetMacro(DeviceIndex,int);
715 
719  virtual int GetNumberOfDevices()
720  {
721  return 0;
722  }
723 
732  virtual int SetUseOffScreenBuffers(bool) { return 0; }
733  virtual bool GetUseOffScreenBuffers() { return false; }
734 
736 
740  vtkGetMacro(UseSRGBColorSpace, bool);
741  vtkSetMacro(UseSRGBColorSpace, bool);
742  vtkBooleanMacro(UseSRGBColorSpace, bool);
744 
745 protected:
746  vtkRenderWindow();
747  ~vtkRenderWindow() override;
748 
749  virtual void DoStereoRender();
750  virtual void DoFDRender();
751  virtual void DoAARender();
752 
753 #ifndef VTK_LEGACY_REMOVE
755 #endif
758  int Borders;
760  int OldScreen[5];
769  unsigned char* StereoBuffer; // used for red blue stereo
770  float *AccumulationBuffer; // used for many techniques
772  int AAFrames;
773  int FDFrames;
774  int UseConstantFDOffsets; // to use the same offsets at each rendering
775  double *ConstantFDOffsets[2];
776  int SubFrames; // number of sub frames
777  int CurrentSubFrame; // what one are we on
778  unsigned char *ResultFrame; // used for any non immediate rendering
783  int InRender;
789  int AnaglyphColorMask[2];
794 
796 
801 
802 private:
803  vtkRenderWindow(const vtkRenderWindow&) = delete;
804  void operator=(const vtkRenderWindow&) = delete;
805 };
806 
807 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
virtual void SetForceMakeCurrent()
If called, allow MakeCurrent() to skip cache-check when called.
void SetStereoTypeToRight()
Set/Get what type of stereo rendering to use.
virtual void * GetGenericDrawable()=0
These are window system independent methods that are used to help interface vtkWindow to native windo...
virtual void SetDisplayId(void *)=0
These are window system independent methods that are used to help interface vtkWindow to native windo...
virtual int SetUseOffScreenBuffers(bool)
Create and bind offscreen rendering buffers without destroying the current OpenGL context...
#define VTK_STEREO_RIGHT
void SetStereoTypeToFake()
Set/Get what type of stereo rendering to use.
#define VTK_STEREO_FAKE
float AnaglyphColorSaturation
#define VTK_STEREO_CHECKERBOARD
#define VTK_INT_MAX
Definition: vtkType.h:157
float * AccumulationBuffer
vtkPainterDeviceAdapter * PainterDeviceAdapter
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
void SetStereoTypeToSplitViewportHorizontal()
Set/Get what type of stereo rendering to use.
#define VTK_STEREO_DRESDEN
void SetStereoTypeToAnaglyph()
Set/Get what type of stereo rendering to use.
#define VTK_STEREO_RED_BLUE
abstract specification for renderers
Definition: vtkRenderer.h:63
virtual void SetParentInfo(char *)=0
These are window system independent methods that are used to help interface vtkWindow to native windo...
virtual void * GetGenericContext()=0
These are window system independent methods that are used to help interface vtkWindow to native windo...
#define VTK_STEREO_INTERLACED
void SetStereoTypeToCrystalEyes()
Set/Get what type of stereo rendering to use.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
unsigned char * ResultFrame
platform-independent render window interaction including picking and frame rate control.
virtual const char * ReportCapabilities()
Get report of capabilities for the render window.
virtual int IsDirect()
Is this render window using hardware acceleration? 0-false, 1-true.
virtual int SupportsOpenGL()
Does this render window support OpenGL? 0-false, 1-true.
an ordered list of renderers
An adapter between a vtkPainter and a rendering device.
virtual int CheckInRenderStatus()
Are we rendering at the moment.
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
void SetStereoTypeToRedBlue()
Set/Get what type of stereo rendering to use.
double AbortCheckTime
The universal time since the last abort check occurred.
vtkGetNewMacro(RenderTimer, vtkRenderTimerLog) vtkRendererCollection *GetRenderers()
Get the render timer log for this window.
unsigned int AccumulationBufferSize
a simple class to control print indentation
Definition: vtkIndent.h:39
void SetStereoTypeToCheckerboard()
Set/Get what type of stereo rendering to use.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
float GetZbufferDataAtPoint(int x, int y)
Set/Get the zbuffer data from the frame buffer.
void SetStereoTypeToInterlaced()
Set/Get what type of stereo rendering to use.
virtual void SetWindowId(void *)=0
These are window system independent methods that are used to help interface vtkWindow to native windo...
virtual void SetCursorPosition(int, int)
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
abstract base class for most VTK objects
Definition: vtkObjectBase.h:68
virtual void MakeCurrent()
Make the window current.
Definition: vtkWindow.h:185
vtkNew< vtkRenderTimerLog > RenderTimer
#define VTK_STEREO_CRYSTAL_EYES
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
dynamic, self-adjusting array of unsigned char
virtual void SetParentId(void *)=0
These are window system independent methods that are used to help interface vtkWindow to native windo...
void SetStereoTypeToDresden()
Set/Get what type of stereo rendering to use.
virtual void SetWindowInfo(char *)=0
These are window system independent methods that are used to help interface vtkWindow to native windo...
create a window for renderers to draw into
#define VTK_STEREO_SPLITVIEWPORT_HORIZONTAL
virtual bool InitializeFromCurrentContext()
Initialize the render window from the information associated with the currently activated OpenGL cont...
virtual void ClearInRenderStatus()
Clear status (after an exception was thrown for example)
create and manipulate ordered lists of objects
Definition: vtkCollection.h:51
virtual void * GetGenericDisplayId()=0
These are window system independent methods that are used to help interface vtkWindow to native windo...
vtkRenderWindowInteractor * Interactor
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual bool GetUseOffScreenBuffers()
unsigned char * StereoBuffer
#define VTK_STEREO_LEFT
virtual void * GetGenericParentId()=0
These are window system independent methods that are used to help interface vtkWindow to native windo...
virtual int GetNumberOfDevices()
Returns the number of devices (graphics cards) on a system.
virtual void Render()=0
Ask each viewport owned by this Window to render its image and synchronize this process.
void SetStereoTypeToLeft()
Set/Get what type of stereo rendering to use.
#define VTK_STEREO_ANAGLYPH
virtual bool IsDrawable()
Test if the window has a valid drawable.
Asynchronously measures GPU execution times for a series of events.
virtual void * GetGenericWindowId()=0
These are window system independent methods that are used to help interface vtkWindow to native windo...
vtkRendererCollection * Renderers