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 =========================================================================*/
41 #ifndef vtkRenderWindow_h
42 #define vtkRenderWindow_h
43 
44 #include "vtkRenderingCoreModule.h" // For export macro
45 #include "vtkWindow.h"
46 #include "vtkNew.h" // For vtkNew
47 
48 class vtkFloatArray;
49 class vtkProp;
50 class vtkCollection;
51 class vtkRenderTimerLog;
53 class vtkRenderer;
56 
57 // lets define the different types of stereo
58 #define VTK_STEREO_CRYSTAL_EYES 1
59 #define VTK_STEREO_RED_BLUE 2
60 #define VTK_STEREO_INTERLACED 3
61 #define VTK_STEREO_LEFT 4
62 #define VTK_STEREO_RIGHT 5
63 #define VTK_STEREO_DRESDEN 6
64 #define VTK_STEREO_ANAGLYPH 7
65 #define VTK_STEREO_CHECKERBOARD 8
66 #define VTK_STEREO_SPLITVIEWPORT_HORIZONTAL 9
67 #define VTK_STEREO_FAKE 10
68 
69 #define VTK_CURSOR_DEFAULT 0
70 #define VTK_CURSOR_ARROW 1
71 #define VTK_CURSOR_SIZENE 2
72 #define VTK_CURSOR_SIZENW 3
73 #define VTK_CURSOR_SIZESW 4
74 #define VTK_CURSOR_SIZESE 5
75 #define VTK_CURSOR_SIZENS 6
76 #define VTK_CURSOR_SIZEWE 7
77 #define VTK_CURSOR_SIZEALL 8
78 #define VTK_CURSOR_HAND 9
79 #define VTK_CURSOR_CROSSHAIR 10
80 
81 class VTKRENDERINGCORE_EXPORT vtkRenderWindow : public vtkWindow
82 {
83 public:
84  vtkTypeMacro(vtkRenderWindow,vtkWindow);
85  void PrintSelf(ostream& os, vtkIndent indent) override;
86 
92  static vtkRenderWindow *New();
93 
97  virtual void AddRenderer(vtkRenderer *);
98 
102  void RemoveRenderer(vtkRenderer *);
103 
107  int HasRenderer(vtkRenderer *);
108 
112  static const char *GetRenderLibrary();
113 
117  virtual const char *GetRenderingBackend();
118 
123 
124 
127  vtkRendererCollection *GetRenderers() {return this->Renderers;};
128 
136  void CaptureGL2PSSpecialProps(vtkCollection *specialProps);
137 
139 
142  vtkGetMacro(CapturingGL2PSSpecialProps, int);
144 
149  void Render() override;
150 
154  virtual void Start() = 0;
155 
159  virtual void Finalize() = 0;
160 
165  virtual void Frame() = 0;
166 
171  virtual void WaitForCompletion()=0;
172 
177  virtual void CopyResultFrame();
178 
184  virtual vtkRenderWindowInteractor *MakeRenderWindowInteractor();
185 
187 
193  virtual void HideCursor() = 0;
194  virtual void ShowCursor() = 0;
195  virtual void SetCursorPosition(int , int ) {}
197 
199 
202  vtkSetMacro(CurrentCursor,int);
203  vtkGetMacro(CurrentCursor,int);
205 
207 
210  virtual void SetFullScreen(vtkTypeBool) = 0;
211  vtkGetMacro(FullScreen,vtkTypeBool);
212  vtkBooleanMacro(FullScreen,vtkTypeBool);
214 
216 
221  vtkSetMacro(Borders,vtkTypeBool);
222  vtkGetMacro(Borders,vtkTypeBool);
223  vtkBooleanMacro(Borders,vtkTypeBool);
225 
227 
231  vtkGetMacro(StereoCapableWindow,vtkTypeBool);
232  vtkBooleanMacro(StereoCapableWindow,vtkTypeBool);
233  virtual void SetStereoCapableWindow(vtkTypeBool capable);
235 
237 
240  vtkGetMacro(StereoRender,vtkTypeBool);
241  void SetStereoRender(vtkTypeBool stereo);
242  vtkBooleanMacro(StereoRender,vtkTypeBool);
244 
246 
249  vtkSetMacro(AlphaBitPlanes, vtkTypeBool);
250  vtkGetMacro(AlphaBitPlanes, vtkTypeBool);
251  vtkBooleanMacro(AlphaBitPlanes, vtkTypeBool);
253 
255 
259  vtkSetMacro(PointSmoothing,vtkTypeBool);
260  vtkGetMacro(PointSmoothing,vtkTypeBool);
261  vtkBooleanMacro(PointSmoothing,vtkTypeBool);
263 
265 
269  vtkSetMacro(LineSmoothing,vtkTypeBool);
270  vtkGetMacro(LineSmoothing,vtkTypeBool);
271  vtkBooleanMacro(LineSmoothing,vtkTypeBool);
273 
275 
279  vtkSetMacro(PolygonSmoothing,vtkTypeBool);
280  vtkGetMacro(PolygonSmoothing,vtkTypeBool);
281  vtkBooleanMacro(PolygonSmoothing,vtkTypeBool);
283 
285 
303  vtkGetMacro(StereoType,int);
304  vtkSetMacro(StereoType,int);
306  {this->SetStereoType(VTK_STEREO_CRYSTAL_EYES);}
308  {this->SetStereoType(VTK_STEREO_RED_BLUE);}
310  {this->SetStereoType(VTK_STEREO_INTERLACED);}
312  {this->SetStereoType(VTK_STEREO_LEFT);}
314  {this->SetStereoType(VTK_STEREO_RIGHT);}
316  {this->SetStereoType(VTK_STEREO_DRESDEN);}
318  {this->SetStereoType(VTK_STEREO_ANAGLYPH);}
320  {this->SetStereoType(VTK_STEREO_CHECKERBOARD);}
322  {this->SetStereoType(VTK_STEREO_SPLITVIEWPORT_HORIZONTAL);}
324  {this->SetStereoType(VTK_STEREO_FAKE);}
326 
327  const char *GetStereoTypeAsString();
328 
333  virtual void StereoUpdate();
334 
339  virtual void StereoMidpoint();
340 
345  virtual void StereoRenderComplete();
346 
348 
355  vtkSetClampMacro(AnaglyphColorSaturation,float, 0.0f, 1.0f);
356  vtkGetMacro(AnaglyphColorSaturation,float);
358 
360 
374  vtkSetVector2Macro(AnaglyphColorMask,int);
375  vtkGetVectorMacro(AnaglyphColorMask,int,2);
377 
383  virtual void WindowRemap() = 0;
384 
386 
389  vtkSetMacro(SwapBuffers,vtkTypeBool);
390  vtkGetMacro(SwapBuffers,vtkTypeBool);
391  vtkBooleanMacro(SwapBuffers,vtkTypeBool);
393 
395 
407  virtual int SetPixelData(int x, int y, int x2, int y2, unsigned char *data,
408  int front, int right=0) = 0;
409  virtual int SetPixelData(int x, int y, int x2, int y2,
410  vtkUnsignedCharArray *data, int front, int right=0) = 0;
412 
414 
421  virtual float *GetRGBAPixelData(int x, int y, int x2, int y2, int front, int right=0) = 0;
422  virtual int GetRGBAPixelData(int x, int y, int x2, int y2, int front,
423  vtkFloatArray *data, int right=0) = 0;
424  virtual int SetRGBAPixelData(int x, int y, int x2, int y2, float *,
425  int front, int blend=0, int right=0) = 0;
426  virtual int SetRGBAPixelData(int, int, int, int, vtkFloatArray*,
427  int, int blend=0, int right=0) = 0;
428  virtual void ReleaseRGBAPixelData(float *data) = 0;
429  virtual unsigned char *GetRGBACharPixelData(int x, int y, int x2, int y2,
430  int front, int right=0) = 0;
431  virtual int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
432  vtkUnsignedCharArray *data, int right=0) = 0;
433  virtual int SetRGBACharPixelData(int x,int y, int x2, int y2,
434  unsigned char *data, int front,
435  int blend=0, int right=0) = 0;
436  virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
437  vtkUnsignedCharArray *data, int front,
438  int blend=0, int right=0) = 0;
440 
442 
447  virtual float *GetZbufferData(int x, int y, int x2, int y2) = 0;
448  virtual int GetZbufferData(int x, int y, int x2, int y2, float *z) = 0;
449  virtual int GetZbufferData(int x, int y, int x2, int y2,
450  vtkFloatArray *z) = 0;
451  virtual int SetZbufferData(int x, int y, int x2, int y2, float *z) = 0;
452  virtual int SetZbufferData(int x, int y, int x2, int y2,
453  vtkFloatArray *z) = 0;
454  float GetZbufferDataAtPoint(int x, int y)
455  {
456  float value;
457  this->GetZbufferData(x, y, x, y, &value);
458  return value;
459  }
461 
463 
466  vtkGetMacro(NeverRendered,int);
468 
470 
474  vtkGetMacro(AbortRender,int);
475  vtkSetMacro(AbortRender,int);
476  vtkGetMacro(InAbortCheck,int);
477  vtkSetMacro(InAbortCheck,int);
478  virtual int CheckAbortStatus();
480 
481  vtkGetMacro(IsPicking,vtkTypeBool);
482  vtkSetMacro(IsPicking,vtkTypeBool);
483  vtkBooleanMacro(IsPicking,vtkTypeBool);
484 
491  virtual int GetEventPending() = 0;
492 
496  virtual int CheckInRenderStatus() { return this->InRender; }
497 
501  virtual void ClearInRenderStatus() { this->InRender = 0; }
502 
504 
512  virtual void SetDesiredUpdateRate(double);
513  vtkGetMacro(DesiredUpdateRate,double);
515 
517 
523  vtkGetMacro(NumberOfLayers, int);
524  vtkSetClampMacro(NumberOfLayers, int, 1, VTK_INT_MAX);
526 
528 
531  vtkGetObjectMacro(Interactor,vtkRenderWindowInteractor);
533 
537  void SetInteractor(vtkRenderWindowInteractor *);
538 
543  void UnRegister(vtkObjectBase *o) override;
544 
546 
549  void SetDisplayId(void *) override = 0;
550  void SetWindowId(void *) override = 0;
551  virtual void SetNextWindowId(void *) = 0;
552  void SetParentId(void *) override = 0;
553  void *GetGenericDisplayId() override = 0;
554  void *GetGenericWindowId() override = 0;
555  void *GetGenericParentId() override = 0;
556  void *GetGenericContext() override = 0;
557  void *GetGenericDrawable() override = 0;
558  void SetWindowInfo(char *) override = 0;
559  virtual void SetNextWindowInfo(char *) = 0;
560  void SetParentInfo(char *) override = 0;
562 
567  virtual bool InitializeFromCurrentContext() { return false; };
568 
573  void MakeCurrent() override = 0;
574 
579  virtual bool IsCurrent()=0;
580 
587  virtual bool IsDrawable(){ return true; }
588 
594  virtual void SetForceMakeCurrent() {}
595 
599  virtual const char *ReportCapabilities() { return "Not Implemented";};
600 
604  virtual int SupportsOpenGL() { return 0;};
605 
609  virtual int IsDirect() { return 0;};
610 
615  virtual int GetDepthBufferSize() = 0;
616 
621  virtual int GetColorBufferSizes(int *rgba) = 0;
622 
624 
627  vtkSetMacro(MultiSamples,int);
628  vtkGetMacro(MultiSamples,int);
630 
632 
635  vtkSetMacro(StencilCapable, vtkTypeBool);
636  vtkGetMacro(StencilCapable, vtkTypeBool);
637  vtkBooleanMacro(StencilCapable, vtkTypeBool);
639 
641 
647  vtkSetMacro(DeviceIndex,int);
648  vtkGetMacro(DeviceIndex,int);
650 
654  virtual int GetNumberOfDevices()
655  {
656  return 0;
657  }
658 
667  virtual int SetUseOffScreenBuffers(bool) { return 0; }
668  virtual bool GetUseOffScreenBuffers() { return false; }
669 
671 
675  vtkGetMacro(UseSRGBColorSpace, bool);
676  vtkSetMacro(UseSRGBColorSpace, bool);
677  vtkBooleanMacro(UseSRGBColorSpace, bool);
679 
680 protected:
681  vtkRenderWindow();
682  ~vtkRenderWindow() override;
683 
684  virtual void DoStereoRender();
685 
690  int OldScreen[5];
699  unsigned char* StereoBuffer; // used for red blue stereo
700  float *AccumulationBuffer; // used for many techniques
702  unsigned char *ResultFrame;
707  int InRender;
713  int AnaglyphColorMask[2];
718 
720 
725 
726 private:
727  vtkRenderWindow(const vtkRenderWindow&) = delete;
728  void operator=(const vtkRenderWindow&) = delete;
729 };
730 
731 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
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
vtkTypeBool PolygonSmoothing
#define VTK_STEREO_CHECKERBOARD
vtkTypeBool LineSmoothing
vtkTypeBool PointSmoothing
#define VTK_INT_MAX
Definition: vtkType.h:157
float * AccumulationBuffer
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
void SetStereoTypeToSplitViewportHorizontal()
Set/Get what type of stereo rendering to use.
#define VTK_STEREO_DRESDEN
vtkTypeBool StereoRender
void SetStereoTypeToAnaglyph()
Set/Get what type of stereo rendering to use.
#define VTK_STEREO_RED_BLUE
abstract specification for renderers
Definition: vtkRenderer.h:57
virtual void SetParentInfo(char *)=0
These are window system independent methods that are used to help interface vtkWindow to native windo...
vtkTypeBool StencilCapable
vtkTypeBool IsPicking
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.
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
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
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:33
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...
vtkTypeBool AlphaBitPlanes
abstract base class for most VTK objects
Definition: vtkObjectBase.h:62
virtual void MakeCurrent()
Make the window current.
Definition: vtkWindow.h:182
vtkNew< vtkRenderTimerLog > RenderTimer
#define VTK_STEREO_CRYSTAL_EYES
vtkTypeBool SwapBuffers
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:48
virtual void * GetGenericDisplayId()=0
These are window system independent methods that are used to help interface vtkWindow to native windo...
vtkTypeBool FullScreen
vtkTypeBool Borders
vtkRenderWindowInteractor * Interactor
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
virtual bool GetUseOffScreenBuffers()
vtkTypeBool StereoCapableWindow
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