VTK  9.3.1
vtkRenderWindow.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
38 #ifndef vtkRenderWindow_h
39 #define vtkRenderWindow_h
40 
41 #include "vtkEventData.h" // for enums
42 #include "vtkNew.h" // For vtkNew
43 #include "vtkRenderingCoreModule.h" // For export macro
44 #include "vtkSmartPointer.h" // For vtkSmartPointer
45 #include "vtkWindow.h"
46 
47 VTK_ABI_NAMESPACE_BEGIN
48 class vtkFloatArray;
49 class vtkProp;
50 class vtkCollection;
51 class vtkMatrix4x4;
52 class vtkRenderTimerLog;
54 class vtkRenderer;
58 
59 // lets define the different types of stereo
60 #define VTK_STEREO_CRYSTAL_EYES 1
61 #define VTK_STEREO_RED_BLUE 2
62 #define VTK_STEREO_INTERLACED 3
63 #define VTK_STEREO_LEFT 4
64 #define VTK_STEREO_RIGHT 5
65 #define VTK_STEREO_DRESDEN 6
66 #define VTK_STEREO_ANAGLYPH 7
67 #define VTK_STEREO_CHECKERBOARD 8
68 #define VTK_STEREO_SPLITVIEWPORT_HORIZONTAL 9
69 #define VTK_STEREO_FAKE 10
70 #define VTK_STEREO_EMULATE 11
71 
72 #define VTK_CURSOR_DEFAULT 0
73 #define VTK_CURSOR_ARROW 1
74 #define VTK_CURSOR_SIZENE 2
75 #define VTK_CURSOR_SIZENW 3
76 #define VTK_CURSOR_SIZESW 4
77 #define VTK_CURSOR_SIZESE 5
78 #define VTK_CURSOR_SIZENS 6
79 #define VTK_CURSOR_SIZEWE 7
80 #define VTK_CURSOR_SIZEALL 8
81 #define VTK_CURSOR_HAND 9
82 #define VTK_CURSOR_CROSSHAIR 10
83 #define VTK_CURSOR_CUSTOM 11
84 
85 class VTKRENDERINGCORE_EXPORT vtkRenderWindow : public vtkWindow
86 {
87 public:
88  vtkTypeMacro(vtkRenderWindow, vtkWindow);
89  void PrintSelf(ostream& os, vtkIndent indent) override;
90 
96  static vtkRenderWindow* New();
97 
101  virtual void AddRenderer(vtkRenderer*);
102 
106  void RemoveRenderer(vtkRenderer*);
107 
111  vtkTypeBool HasRenderer(vtkRenderer*);
112 
116  static const char* GetRenderLibrary();
117 
121  virtual const char* GetRenderingBackend();
122 
126  vtkGetNewMacro(RenderTimer, vtkRenderTimerLog);
127 
131  vtkRendererCollection* GetRenderers() { return this->Renderers; }
132 
140  void CaptureGL2PSSpecialProps(vtkCollection* specialProps);
141 
143 
146  vtkGetMacro(CapturingGL2PSSpecialProps, int);
148 
153  void Render() override;
154 
158  virtual void Start() {}
159 
163  virtual void End(){};
164 
168  virtual void Finalize() {}
169 
174  virtual void Frame() {}
175 
180  virtual void WaitForCompletion() {}
181 
186  virtual void CopyResultFrame();
187 
193  virtual vtkRenderWindowInteractor* MakeRenderWindowInteractor();
194 
196 
202  virtual void HideCursor() {}
203  virtual void ShowCursor() {}
204  virtual void SetCursorPosition(int, int) {}
206 
208 
211  vtkSetMacro(CurrentCursor, int);
212  vtkGetMacro(CurrentCursor, int);
214 
216 
220  vtkSetFilePathMacro(CursorFileName);
221  vtkGetFilePathMacro(CursorFileName);
223 
225 
228  virtual void SetFullScreen(vtkTypeBool) {}
229  vtkGetMacro(FullScreen, vtkTypeBool);
230  vtkBooleanMacro(FullScreen, vtkTypeBool);
232 
234 
239  vtkSetMacro(Borders, vtkTypeBool);
240  vtkGetMacro(Borders, vtkTypeBool);
241  vtkBooleanMacro(Borders, vtkTypeBool);
243 
245 
249  vtkGetMacro(StereoCapableWindow, vtkTypeBool);
250  vtkBooleanMacro(StereoCapableWindow, vtkTypeBool);
251  virtual void SetStereoCapableWindow(vtkTypeBool capable);
253 
255 
258  vtkGetMacro(StereoRender, vtkTypeBool);
259  void SetStereoRender(vtkTypeBool stereo);
260  vtkBooleanMacro(StereoRender, vtkTypeBool);
262 
264 
267  vtkSetMacro(AlphaBitPlanes, vtkTypeBool);
268  vtkGetMacro(AlphaBitPlanes, vtkTypeBool);
269  vtkBooleanMacro(AlphaBitPlanes, vtkTypeBool);
271 
273 
277  vtkSetMacro(PointSmoothing, vtkTypeBool);
278  vtkGetMacro(PointSmoothing, vtkTypeBool);
279  vtkBooleanMacro(PointSmoothing, vtkTypeBool);
281 
283 
287  vtkSetMacro(LineSmoothing, vtkTypeBool);
288  vtkGetMacro(LineSmoothing, vtkTypeBool);
289  vtkBooleanMacro(LineSmoothing, vtkTypeBool);
291 
293 
297  vtkSetMacro(PolygonSmoothing, vtkTypeBool);
298  vtkGetMacro(PolygonSmoothing, vtkTypeBool);
299  vtkBooleanMacro(PolygonSmoothing, vtkTypeBool);
301 
303 
324  vtkGetMacro(StereoType, int);
325  void SetStereoType(int);
326  void SetStereoTypeToCrystalEyes() { this->SetStereoType(VTK_STEREO_CRYSTAL_EYES); }
327  void SetStereoTypeToRedBlue() { this->SetStereoType(VTK_STEREO_RED_BLUE); }
328  void SetStereoTypeToInterlaced() { this->SetStereoType(VTK_STEREO_INTERLACED); }
329  void SetStereoTypeToLeft() { this->SetStereoType(VTK_STEREO_LEFT); }
330  void SetStereoTypeToRight() { this->SetStereoType(VTK_STEREO_RIGHT); }
331  void SetStereoTypeToDresden() { this->SetStereoType(VTK_STEREO_DRESDEN); }
332  void SetStereoTypeToAnaglyph() { this->SetStereoType(VTK_STEREO_ANAGLYPH); }
333  void SetStereoTypeToCheckerboard() { this->SetStereoType(VTK_STEREO_CHECKERBOARD); }
335  {
336  this->SetStereoType(VTK_STEREO_SPLITVIEWPORT_HORIZONTAL);
337  }
338  void SetStereoTypeToFake() { this->SetStereoType(VTK_STEREO_FAKE); }
339  void SetStereoTypeToEmulate() { this->SetStereoType(VTK_STEREO_EMULATE); }
341 
343 
346  const char* GetStereoTypeAsString();
347  static const char* GetStereoTypeAsString(int type);
349 
354  virtual void StereoUpdate();
355 
360  virtual void StereoMidpoint();
361 
366  virtual void StereoRenderComplete();
367 
369 
376  vtkSetClampMacro(AnaglyphColorSaturation, float, 0.0f, 1.0f);
377  vtkGetMacro(AnaglyphColorSaturation, float);
379 
381 
395  vtkSetVector2Macro(AnaglyphColorMask, int);
396  vtkGetVectorMacro(AnaglyphColorMask, int, 2);
398 
404  virtual void WindowRemap() {}
405 
407 
410  vtkSetMacro(SwapBuffers, vtkTypeBool);
411  vtkGetMacro(SwapBuffers, vtkTypeBool);
412  vtkBooleanMacro(SwapBuffers, vtkTypeBool);
414 
416 
428  virtual int SetPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, unsigned char* /*data*/,
429  int /*front*/, int /*right*/ = 0)
430  {
431  return 0;
432  }
433  virtual int SetPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
434  vtkUnsignedCharArray* /*data*/, int /*front*/, int /*right*/ = 0)
435  {
436  return 0;
437  }
439 
441 
448  virtual float* GetRGBAPixelData(
449  int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/, int /*right*/ = 0)
450  {
451  return nullptr;
452  }
453  virtual int GetRGBAPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/,
454  vtkFloatArray* /*data*/, int /*right*/ = 0)
455  {
456  return 0;
457  }
458  virtual int SetRGBAPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float*, int /*front*/,
459  int /*blend*/ = 0, int /*right*/ = 0)
460  {
461  return 0;
462  }
463  virtual int SetRGBAPixelData(
464  int, int, int, int, vtkFloatArray*, int, int /*blend*/ = 0, int /*right*/ = 0)
465  {
466  return 0;
467  }
468  virtual void ReleaseRGBAPixelData(float* /*data*/) {}
469  virtual unsigned char* GetRGBACharPixelData(
470  int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/, int /*right*/ = 0)
471  {
472  return nullptr;
473  }
474  virtual int GetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/,
475  vtkUnsignedCharArray* /*data*/, int /*right*/ = 0)
476  {
477  return 0;
478  }
479  virtual int SetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
480  unsigned char* /*data*/, int /*front*/, int /*blend*/ = 0, int /*right*/ = 0)
481  {
482  return 0;
483  }
484  virtual int SetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
485  vtkUnsignedCharArray* /*data*/, int /*front*/, int /*blend*/ = 0, int /*right*/ = 0)
486  {
487  return 0;
488  }
490 
492 
497  virtual float* GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/) { return nullptr; }
498  virtual int GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float* /*z*/)
499  {
500  return 0;
501  }
502  virtual int GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, vtkFloatArray* /*z*/)
503  {
504  return 0;
505  }
506  virtual int SetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float* /*z*/)
507  {
508  return 0;
509  }
510  virtual int SetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, vtkFloatArray* /*z*/)
511  {
512  return 0;
513  }
514  float GetZbufferDataAtPoint(int x, int y)
515  {
516  float value;
517  this->GetZbufferData(x, y, x, y, &value);
518  return value;
519  }
521 
523 
526  vtkGetMacro(NeverRendered, int);
528 
530 
534  vtkGetMacro(AbortRender, int);
535  vtkSetMacro(AbortRender, int);
536  vtkGetMacro(InAbortCheck, int);
537  vtkSetMacro(InAbortCheck, int);
538  virtual int CheckAbortStatus();
540 
547  virtual vtkTypeBool GetEventPending() { return 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  virtual void SetInteractor(vtkRenderWindowInteractor*);
594 
599  void UnRegister(vtkObjectBase* o) override;
600 
602 
605  void SetDisplayId(void*) override {}
606  void SetWindowId(void*) override {}
607  virtual void SetNextWindowId(void*) {}
608  void SetParentId(void*) override {}
609  void* GetGenericDisplayId() override { return nullptr; }
610  void* GetGenericWindowId() override { return nullptr; }
611  void* GetGenericParentId() override { return nullptr; }
612  void* GetGenericContext() override { return nullptr; }
613  void* GetGenericDrawable() override { return nullptr; }
614  void SetWindowInfo(const char*) override {}
615  virtual void SetNextWindowInfo(const char*) {}
616  void SetParentInfo(const char*) override {}
618 
623  virtual bool InitializeFromCurrentContext() { return false; }
624 
626 
633  virtual void SetSharedRenderWindow(vtkRenderWindow*);
634  vtkGetObjectMacro(SharedRenderWindow, vtkRenderWindow);
635  virtual bool GetPlatformSupportsRenderWindowSharing() { return false; }
637 
642  virtual bool IsCurrent() { return false; }
643 
649  virtual void SetForceMakeCurrent() {}
650 
654  virtual const char* ReportCapabilities() { return "Not Implemented"; }
655 
659  virtual int SupportsOpenGL() { return 0; }
660 
664  virtual vtkTypeBool IsDirect() { return 0; }
665 
670  virtual int GetDepthBufferSize() { return 0; }
671 
676  virtual int GetColorBufferSizes(int* /*rgba*/) { return 0; }
677 
679 
683  virtual void SetMultiSamples(int);
684  vtkGetMacro(MultiSamples, int);
686 
688 
691  vtkSetMacro(StencilCapable, vtkTypeBool);
692  vtkGetMacro(StencilCapable, vtkTypeBool);
693  vtkBooleanMacro(StencilCapable, vtkTypeBool);
695 
697 
703  vtkSetMacro(DeviceIndex, int);
704  vtkGetMacro(DeviceIndex, int);
706 
710  virtual int GetNumberOfDevices() { return 0; }
711 
713 
717  vtkGetMacro(UseSRGBColorSpace, bool);
718  vtkSetMacro(UseSRGBColorSpace, bool);
719  vtkBooleanMacro(UseSRGBColorSpace, bool);
721 
727  virtual void GetPhysicalToWorldMatrix(vtkMatrix4x4* matrix);
728 
735  virtual bool GetDeviceToWorldMatrixForDevice(
736  vtkEventDataDevice device, vtkMatrix4x4* deviceToWorldMatrix);
737 
738 protected:
739  vtkRenderWindow();
740  ~vtkRenderWindow() override;
741 
742  virtual void DoStereoRender();
743 
748  int OldScreen[5];
763  int InRender;
768  int AnaglyphColorMask[2];
773 
776 
781 
783 
784 private:
785  vtkRenderWindow(const vtkRenderWindow&) = delete;
786  void operator=(const vtkRenderWindow&) = delete;
787 
788  vtkNew<vtkStereoCompositor> StereoCompositor;
789 };
790 
791 VTK_ABI_NAMESPACE_END
792 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:45
virtual int SetRGBACharPixelData(int, int, int, int, vtkUnsignedCharArray *, int, int=0, int=0)
Same as Get/SetPixelData except that the image also contains an alpha component.
virtual void Start()
Start the rendering process for a frame.
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 int GetDepthBufferSize()
This method should be defined by the subclass.
#define VTK_STEREO_RIGHT
vtkSmartPointer< vtkUnsignedCharArray > StereoBuffer
virtual float * GetZbufferData(int, int, int, int)
Set/Get the zbuffer data from the frame buffer.
void SetStereoTypeToFake()
Set/Get what type of stereo rendering to use.
#define VTK_STEREO_FAKE
float AnaglyphColorSaturation
vtkTypeBool PolygonSmoothing
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:30
virtual void SetFullScreen(vtkTypeBool)
Turn on/off rendering full screen window size.
void * GetGenericDisplayId() override
Dummy stubs for vtkWindow API.
void * GetGenericContext() override
Dummy stubs for vtkWindow API.
virtual void WindowRemap()
Remap the rendering window.
void SetDisplayId(void *) override
Dummy stubs for vtkWindow API.
virtual int SetPixelData(int, int, int, int, unsigned char *, int, int=0)
Set/Get the pixel data of an image, transmitted as RGBRGBRGB.
virtual int SetZbufferData(int, int, int, int, vtkFloatArray *)
Set/Get the zbuffer data from the frame buffer.
#define VTK_STEREO_CHECKERBOARD
vtkTypeBool LineSmoothing
virtual void HideCursor()
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
virtual void SetNextWindowId(void *)
Dummy stubs for vtkWindow API.
vtkTypeBool PointSmoothing
#define VTK_INT_MAX
Definition: vtkType.h:144
virtual int GetColorBufferSizes(int *)
Get the size of the color buffer.
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:30
void SetStereoTypeToSplitViewportHorizontal()
Set/Get what type of stereo rendering to use.
vtkRenderWindow * SharedRenderWindow
#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:61
vtkSmartPointer< vtkUnsignedCharArray > ResultFrame
void SetWindowInfo(const char *) override
Dummy stubs for vtkWindow API.
virtual bool IsCurrent()
Tells if this window is the current graphics context for the calling thread.
virtual void Finalize()
Finalize the rendering process.
vtkTypeBool StencilCapable
virtual int GetRGBACharPixelData(int, int, int, int, int, vtkUnsignedCharArray *, int=0)
Same as Get/SetPixelData except that the image also contains an alpha component.
virtual int GetZbufferData(int, int, int, int, vtkFloatArray *)
Set/Get the zbuffer data from the frame buffer.
void SetParentId(void *) override
Dummy stubs for vtkWindow API.
#define VTK_STEREO_INTERLACED
void SetStereoTypeToCrystalEyes()
Set/Get what type of stereo rendering to use.
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
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 SupportsOpenGL()
Does this render window support OpenGL? 0-false, 1-true.
#define VTK_STEREO_EMULATE
virtual int GetRGBAPixelData(int, int, int, int, int, vtkFloatArray *, int=0)
Same as Get/SetPixelData except that the image also contains an alpha component.
virtual void SetNextWindowInfo(const char *)
Dummy stubs for vtkWindow API.
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 SetWindowId(void *) override
Dummy stubs for vtkWindow API.
void SetStereoTypeToRedBlue()
Set/Get what type of stereo rendering to use.
double AbortCheckTime
The universal time since the last abort check occurred.
virtual int SetZbufferData(int, int, int, int, float *)
Set/Get the zbuffer data from the frame buffer.
a simple class to control print indentation
Definition: vtkIndent.h:28
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.
virtual void ShowCursor()
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
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.
void SetStereoTypeToEmulate()
Set/Get what type of stereo rendering to use.
virtual void WaitForCompletion()
Block the thread until the actual rendering is finished().
void * GetGenericParentId() override
Dummy stubs for vtkWindow API.
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...
virtual int SetPixelData(int, int, int, int, vtkUnsignedCharArray *, int, int=0)
Set/Get the pixel data of an image, transmitted as RGBRGBRGB.
virtual void ReleaseRGBAPixelData(float *)
Same as Get/SetPixelData except that the image also contains an alpha component.
vtkTypeBool AlphaBitPlanes
abstract base class for most VTK objects
Definition: vtkObjectBase.h:62
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:14
vtkNew< vtkRenderTimerLog > RenderTimer
#define VTK_STEREO_CRYSTAL_EYES
vtkTypeBool SwapBuffers
vtkRendererCollection * GetRenderers()
Return the collection of renderers in the render window.
dynamic, self-adjusting array of unsigned char
virtual vtkTypeBool GetEventPending()
Check to see if a mouse button has been pressed.
void SetStereoTypeToDresden()
Set/Get what type of stereo rendering to use.
virtual int SetRGBAPixelData(int, int, int, int, float *, int, int=0, int=0)
Same as Get/SetPixelData except that the image also contains an alpha component.
virtual int SetRGBAPixelData(int, int, int, int, vtkFloatArray *, int, int=0, int=0)
Same as Get/SetPixelData except that the image also contains an alpha component.
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:44
virtual bool GetPlatformSupportsRenderWindowSharing()
Set/Get an already existing window that this window should share data with if possible.
virtual unsigned char * GetRGBACharPixelData(int, int, int, int, int, int=0)
Same as Get/SetPixelData except that the image also contains an alpha component.
vtkTypeBool FullScreen
virtual void End()
Update the system, if needed, at end of render process.
virtual float * GetRGBAPixelData(int, int, int, int, int, int=0)
Same as Get/SetPixelData except that the image also contains an alpha component.
virtual void Render()
Ask each viewport owned by this Window to render its image and synchronize this process.
Definition: vtkWindow.h:162
helper class to generate composited stereo images.
vtkTypeBool Borders
vtkRenderWindowInteractor * Interactor
void SetParentInfo(const char *) override
Dummy stubs for vtkWindow API.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkTypeBool StereoCapableWindow
virtual int GetZbufferData(int, int, int, int, float *)
Set/Get the zbuffer data from the frame buffer.
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.
#define VTK_STEREO_LEFT
virtual int GetNumberOfDevices()
Returns the number of devices (graphics cards) on a system.
virtual vtkTypeBool IsDirect()
Is this render window using hardware acceleration? 0-false, 1-true.
void SetStereoTypeToLeft()
Set/Get what type of stereo rendering to use.
#define VTK_STEREO_ANAGLYPH
virtual void Frame()
A termination method performed at the end of the rendering process to do things like swapping buffers...
Asynchronously measures GPU execution times for a series of events.
virtual int SetRGBACharPixelData(int, int, int, int, unsigned char *, int, int=0, int=0)
Same as Get/SetPixelData except that the image also contains an alpha component.
vtkRendererCollection * Renderers