VTK  9.0.1
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 =========================================================================*/
50 #ifndef vtkRenderWindow_h
51 #define vtkRenderWindow_h
52 
53 #include "vtkNew.h" // For vtkNew
54 #include "vtkRenderingCoreModule.h" // For export macro
55 #include "vtkSmartPointer.h" // For vtkSmartPointer
56 #include "vtkWindow.h"
57 
58 class vtkFloatArray;
59 class vtkProp;
60 class vtkCollection;
61 class vtkRenderTimerLog;
63 class vtkRenderer;
67 
68 // lets define the different types of stereo
69 #define VTK_STEREO_CRYSTAL_EYES 1
70 #define VTK_STEREO_RED_BLUE 2
71 #define VTK_STEREO_INTERLACED 3
72 #define VTK_STEREO_LEFT 4
73 #define VTK_STEREO_RIGHT 5
74 #define VTK_STEREO_DRESDEN 6
75 #define VTK_STEREO_ANAGLYPH 7
76 #define VTK_STEREO_CHECKERBOARD 8
77 #define VTK_STEREO_SPLITVIEWPORT_HORIZONTAL 9
78 #define VTK_STEREO_FAKE 10
79 #define VTK_STEREO_EMULATE 11
80 
81 #define VTK_CURSOR_DEFAULT 0
82 #define VTK_CURSOR_ARROW 1
83 #define VTK_CURSOR_SIZENE 2
84 #define VTK_CURSOR_SIZENW 3
85 #define VTK_CURSOR_SIZESW 4
86 #define VTK_CURSOR_SIZESE 5
87 #define VTK_CURSOR_SIZENS 6
88 #define VTK_CURSOR_SIZEWE 7
89 #define VTK_CURSOR_SIZEALL 8
90 #define VTK_CURSOR_HAND 9
91 #define VTK_CURSOR_CROSSHAIR 10
92 
93 class VTKRENDERINGCORE_EXPORT vtkRenderWindow : public vtkWindow
94 {
95 public:
96  vtkTypeMacro(vtkRenderWindow, vtkWindow);
97  void PrintSelf(ostream& os, vtkIndent indent) override;
98 
104  static vtkRenderWindow* New();
105 
109  virtual void AddRenderer(vtkRenderer*);
110 
114  void RemoveRenderer(vtkRenderer*);
115 
119  int HasRenderer(vtkRenderer*);
120 
124  static const char* GetRenderLibrary();
125 
129  virtual const char* GetRenderingBackend();
130 
134  vtkGetNewMacro(RenderTimer, vtkRenderTimerLog);
135 
139  vtkRendererCollection* GetRenderers() { return this->Renderers; }
140 
148  void CaptureGL2PSSpecialProps(vtkCollection* specialProps);
149 
151 
154  vtkGetMacro(CapturingGL2PSSpecialProps, int);
156 
161  void Render() override;
162 
166  virtual void Start() {}
167 
171  virtual void End(){};
172 
176  virtual void Finalize() {}
177 
182  virtual void Frame() {}
183 
188  virtual void WaitForCompletion() {}
189 
194  virtual void CopyResultFrame();
195 
201  virtual vtkRenderWindowInteractor* MakeRenderWindowInteractor();
202 
204 
210  virtual void HideCursor() {}
211  virtual void ShowCursor() {}
212  virtual void SetCursorPosition(int, int) {}
214 
216 
219  vtkSetMacro(CurrentCursor, int);
220  vtkGetMacro(CurrentCursor, int);
222 
224 
227  virtual void SetFullScreen(vtkTypeBool) {}
228  vtkGetMacro(FullScreen, vtkTypeBool);
229  vtkBooleanMacro(FullScreen, vtkTypeBool);
231 
233 
238  vtkSetMacro(Borders, vtkTypeBool);
239  vtkGetMacro(Borders, vtkTypeBool);
240  vtkBooleanMacro(Borders, vtkTypeBool);
242 
244 
248  vtkGetMacro(StereoCapableWindow, vtkTypeBool);
249  vtkBooleanMacro(StereoCapableWindow, vtkTypeBool);
250  virtual void SetStereoCapableWindow(vtkTypeBool capable);
252 
254 
257  vtkGetMacro(StereoRender, vtkTypeBool);
258  void SetStereoRender(vtkTypeBool stereo);
259  vtkBooleanMacro(StereoRender, vtkTypeBool);
261 
263 
266  vtkSetMacro(AlphaBitPlanes, vtkTypeBool);
267  vtkGetMacro(AlphaBitPlanes, vtkTypeBool);
268  vtkBooleanMacro(AlphaBitPlanes, vtkTypeBool);
270 
272 
276  vtkSetMacro(PointSmoothing, vtkTypeBool);
277  vtkGetMacro(PointSmoothing, vtkTypeBool);
278  vtkBooleanMacro(PointSmoothing, vtkTypeBool);
280 
282 
286  vtkSetMacro(LineSmoothing, vtkTypeBool);
287  vtkGetMacro(LineSmoothing, vtkTypeBool);
288  vtkBooleanMacro(LineSmoothing, vtkTypeBool);
290 
292 
296  vtkSetMacro(PolygonSmoothing, vtkTypeBool);
297  vtkGetMacro(PolygonSmoothing, vtkTypeBool);
298  vtkBooleanMacro(PolygonSmoothing, vtkTypeBool);
300 
302 
323  vtkGetMacro(StereoType, int);
324  void SetStereoType(int);
325  void SetStereoTypeToCrystalEyes() { this->SetStereoType(VTK_STEREO_CRYSTAL_EYES); }
326  void SetStereoTypeToRedBlue() { this->SetStereoType(VTK_STEREO_RED_BLUE); }
327  void SetStereoTypeToInterlaced() { this->SetStereoType(VTK_STEREO_INTERLACED); }
328  void SetStereoTypeToLeft() { this->SetStereoType(VTK_STEREO_LEFT); }
329  void SetStereoTypeToRight() { this->SetStereoType(VTK_STEREO_RIGHT); }
330  void SetStereoTypeToDresden() { this->SetStereoType(VTK_STEREO_DRESDEN); }
331  void SetStereoTypeToAnaglyph() { this->SetStereoType(VTK_STEREO_ANAGLYPH); }
332  void SetStereoTypeToCheckerboard() { this->SetStereoType(VTK_STEREO_CHECKERBOARD); }
334  {
335  this->SetStereoType(VTK_STEREO_SPLITVIEWPORT_HORIZONTAL);
336  }
337  void SetStereoTypeToFake() { this->SetStereoType(VTK_STEREO_FAKE); }
338  void SetStereoTypeToEmulate() { this->SetStereoType(VTK_STEREO_EMULATE); }
340 
342 
345  const char* GetStereoTypeAsString();
346  static const char* GetStereoTypeAsString(int type);
348 
353  virtual void StereoUpdate();
354 
359  virtual void StereoMidpoint();
360 
365  virtual void StereoRenderComplete();
366 
368 
375  vtkSetClampMacro(AnaglyphColorSaturation, float, 0.0f, 1.0f);
376  vtkGetMacro(AnaglyphColorSaturation, float);
378 
380 
394  vtkSetVector2Macro(AnaglyphColorMask, int);
395  vtkGetVectorMacro(AnaglyphColorMask, int, 2);
397 
403  virtual void WindowRemap() {}
404 
406 
409  vtkSetMacro(SwapBuffers, vtkTypeBool);
410  vtkGetMacro(SwapBuffers, vtkTypeBool);
411  vtkBooleanMacro(SwapBuffers, vtkTypeBool);
413 
415 
427  virtual int SetPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, unsigned char* /*data*/,
428  int /*front*/, int /*right*/ = 0)
429  {
430  return 0;
431  }
432  virtual int SetPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
433  vtkUnsignedCharArray* /*data*/, int /*front*/, int /*right*/ = 0)
434  {
435  return 0;
436  }
438 
440 
447  virtual float* GetRGBAPixelData(
448  int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/, int /*right*/ = 0)
449  {
450  return nullptr;
451  }
452  virtual int GetRGBAPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/,
453  vtkFloatArray* /*data*/, int /*right*/ = 0)
454  {
455  return 0;
456  }
457  virtual int SetRGBAPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float*, int /*front*/,
458  int /*blend*/ = 0, int /*right*/ = 0)
459  {
460  return 0;
461  }
462  virtual int SetRGBAPixelData(
463  int, int, int, int, vtkFloatArray*, int, int /*blend*/ = 0, int /*right*/ = 0)
464  {
465  return 0;
466  }
467  virtual void ReleaseRGBAPixelData(float* /*data*/) {}
468  virtual unsigned char* GetRGBACharPixelData(
469  int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/, int /*right*/ = 0)
470  {
471  return nullptr;
472  }
473  virtual int GetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/,
474  vtkUnsignedCharArray* /*data*/, int /*right*/ = 0)
475  {
476  return 0;
477  }
478  virtual int SetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
479  unsigned char* /*data*/, int /*front*/, int /*blend*/ = 0, int /*right*/ = 0)
480  {
481  return 0;
482  }
483  virtual int SetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
484  vtkUnsignedCharArray* /*data*/, int /*front*/, int /*blend*/ = 0, int /*right*/ = 0)
485  {
486  return 0;
487  }
489 
491 
496  virtual float* GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/) { return nullptr; }
497  virtual int GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float* /*z*/)
498  {
499  return 0;
500  }
501  virtual int GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, vtkFloatArray* /*z*/)
502  {
503  return 0;
504  }
505  virtual int SetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float* /*z*/)
506  {
507  return 0;
508  }
509  virtual int SetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, vtkFloatArray* /*z*/)
510  {
511  return 0;
512  }
513  float GetZbufferDataAtPoint(int x, int y)
514  {
515  float value;
516  this->GetZbufferData(x, y, x, y, &value);
517  return value;
518  }
520 
522 
525  vtkGetMacro(NeverRendered, int);
527 
529 
533  vtkGetMacro(AbortRender, int);
534  vtkSetMacro(AbortRender, int);
535  vtkGetMacro(InAbortCheck, int);
536  vtkSetMacro(InAbortCheck, int);
537  virtual int CheckAbortStatus();
539 
541 
544  VTK_LEGACY(vtkTypeBool GetIsPicking());
545  VTK_LEGACY(void SetIsPicking(vtkTypeBool));
546  VTK_LEGACY(void IsPickingOn());
547  VTK_LEGACY(void IsPickingOff());
549 
556  virtual vtkTypeBool GetEventPending() { return 0; }
557 
561  virtual int CheckInRenderStatus() { return this->InRender; }
562 
566  virtual void ClearInRenderStatus() { this->InRender = 0; }
567 
569 
577  virtual void SetDesiredUpdateRate(double);
578  vtkGetMacro(DesiredUpdateRate, double);
580 
582 
588  vtkGetMacro(NumberOfLayers, int);
589  vtkSetClampMacro(NumberOfLayers, int, 1, VTK_INT_MAX);
591 
593 
596  vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
598 
602  void SetInteractor(vtkRenderWindowInteractor*);
603 
608  void UnRegister(vtkObjectBase* o) override;
609 
611 
614  void SetDisplayId(void*) override {}
615  void SetWindowId(void*) override {}
616  virtual void SetNextWindowId(void*) {}
617  void SetParentId(void*) override {}
618  void* GetGenericDisplayId() override { return nullptr; }
619  void* GetGenericWindowId() override { return nullptr; }
620  void* GetGenericParentId() override { return nullptr; }
621  void* GetGenericContext() override { return nullptr; }
622  void* GetGenericDrawable() override { return nullptr; }
623  void SetWindowInfo(const char*) override {}
624  virtual void SetNextWindowInfo(const char*) {}
625  void SetParentInfo(const char*) override {}
627 
632  virtual bool InitializeFromCurrentContext() { return false; }
633 
635 
642  virtual void SetSharedRenderWindow(vtkRenderWindow*);
643  vtkGetObjectMacro(SharedRenderWindow, vtkRenderWindow);
644  virtual bool GetPlatformSupportsRenderWindowSharing() { return false; }
646 
651  void MakeCurrent() override {}
652 
657  virtual bool IsCurrent() { return false; }
658 
665  VTK_LEGACY(virtual bool IsDrawable());
666 
672  virtual void SetForceMakeCurrent() {}
673 
677  virtual const char* ReportCapabilities() { return "Not Implemented"; }
678 
682  virtual int SupportsOpenGL() { return 0; }
683 
687  virtual vtkTypeBool IsDirect() { return 0; }
688 
693  virtual int GetDepthBufferSize() { return 0; }
694 
699  virtual int GetColorBufferSizes(int* /*rgba*/) { return 0; }
700 
702 
706  virtual void SetMultiSamples(int);
707  vtkGetMacro(MultiSamples, int);
709 
711 
714  vtkSetMacro(StencilCapable, vtkTypeBool);
715  vtkGetMacro(StencilCapable, vtkTypeBool);
716  vtkBooleanMacro(StencilCapable, vtkTypeBool);
718 
720 
726  vtkSetMacro(DeviceIndex, int);
727  vtkGetMacro(DeviceIndex, int);
729 
733  virtual int GetNumberOfDevices() { return 0; }
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 
755  int OldScreen[5];
770  int InRender;
775  int AnaglyphColorMask[2];
780 
782 
787 
789 
790 private:
791  vtkRenderWindow(const vtkRenderWindow&) = delete;
792  void operator=(const vtkRenderWindow&) = delete;
793 
794  vtkNew<vtkStereoCompositor> StereoCompositor;
795 };
796 
797 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:53
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
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:155
virtual int GetColorBufferSizes(int *)
Get the size of the color buffer.
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
void MakeCurrent() override
Attempt to make this window the current graphics context for the calling thread.
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
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:67
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:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
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: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.
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:63
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:52
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:166
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