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 =========================================================================*/
44 #ifndef vtkRenderWindow_h
45 #define vtkRenderWindow_h
46 
47 #include "vtkNew.h" // For vtkNew
48 #include "vtkRenderingCoreModule.h" // For export macro
49 #include "vtkSmartPointer.h" // For vtkSmartPointer
50 #include "vtkWindow.h"
51 
52 class vtkFloatArray;
53 class vtkProp;
54 class vtkCollection;
55 class vtkRenderTimerLog;
57 class vtkRenderer;
61 
62 // lets define the different types of stereo
63 #define VTK_STEREO_CRYSTAL_EYES 1
64 #define VTK_STEREO_RED_BLUE 2
65 #define VTK_STEREO_INTERLACED 3
66 #define VTK_STEREO_LEFT 4
67 #define VTK_STEREO_RIGHT 5
68 #define VTK_STEREO_DRESDEN 6
69 #define VTK_STEREO_ANAGLYPH 7
70 #define VTK_STEREO_CHECKERBOARD 8
71 #define VTK_STEREO_SPLITVIEWPORT_HORIZONTAL 9
72 #define VTK_STEREO_FAKE 10
73 #define VTK_STEREO_EMULATE 11
74 
75 #define VTK_CURSOR_DEFAULT 0
76 #define VTK_CURSOR_ARROW 1
77 #define VTK_CURSOR_SIZENE 2
78 #define VTK_CURSOR_SIZENW 3
79 #define VTK_CURSOR_SIZESW 4
80 #define VTK_CURSOR_SIZESE 5
81 #define VTK_CURSOR_SIZENS 6
82 #define VTK_CURSOR_SIZEWE 7
83 #define VTK_CURSOR_SIZEALL 8
84 #define VTK_CURSOR_HAND 9
85 #define VTK_CURSOR_CROSSHAIR 10
86 
87 class VTKRENDERINGCORE_EXPORT vtkRenderWindow : public vtkWindow
88 {
89 public:
90  vtkTypeMacro(vtkRenderWindow, vtkWindow);
91  void PrintSelf(ostream& os, vtkIndent indent) override;
92 
98  static vtkRenderWindow* New();
99 
103  virtual void AddRenderer(vtkRenderer*);
104 
108  void RemoveRenderer(vtkRenderer*);
109 
113  int HasRenderer(vtkRenderer*);
114 
118  static const char* GetRenderLibrary();
119 
123  virtual const char* GetRenderingBackend();
124 
128  vtkGetNewMacro(RenderTimer, vtkRenderTimerLog);
129 
133  vtkRendererCollection* GetRenderers() { return this->Renderers; }
134 
142  void CaptureGL2PSSpecialProps(vtkCollection* specialProps);
143 
145 
148  vtkGetMacro(CapturingGL2PSSpecialProps, int);
150 
155  void Render() override;
156 
160  virtual void Start() {}
161 
165  virtual void End(){};
166 
170  virtual void Finalize() {}
171 
176  virtual void Frame() {}
177 
182  virtual void WaitForCompletion() {}
183 
188  virtual void CopyResultFrame();
189 
195  virtual vtkRenderWindowInteractor* MakeRenderWindowInteractor();
196 
198 
204  virtual void HideCursor() {}
205  virtual void ShowCursor() {}
206  virtual void SetCursorPosition(int, int) {}
208 
210 
213  vtkSetMacro(CurrentCursor, int);
214  vtkGetMacro(CurrentCursor, int);
216 
218 
221  virtual void SetFullScreen(vtkTypeBool) {}
222  vtkGetMacro(FullScreen, vtkTypeBool);
223  vtkBooleanMacro(FullScreen, vtkTypeBool);
225 
227 
232  vtkSetMacro(Borders, vtkTypeBool);
233  vtkGetMacro(Borders, vtkTypeBool);
234  vtkBooleanMacro(Borders, vtkTypeBool);
236 
238 
242  vtkGetMacro(StereoCapableWindow, vtkTypeBool);
243  vtkBooleanMacro(StereoCapableWindow, vtkTypeBool);
244  virtual void SetStereoCapableWindow(vtkTypeBool capable);
246 
248 
251  vtkGetMacro(StereoRender, vtkTypeBool);
252  void SetStereoRender(vtkTypeBool stereo);
253  vtkBooleanMacro(StereoRender, vtkTypeBool);
255 
257 
260  vtkSetMacro(AlphaBitPlanes, vtkTypeBool);
261  vtkGetMacro(AlphaBitPlanes, vtkTypeBool);
262  vtkBooleanMacro(AlphaBitPlanes, vtkTypeBool);
264 
266 
270  vtkSetMacro(PointSmoothing, vtkTypeBool);
271  vtkGetMacro(PointSmoothing, vtkTypeBool);
272  vtkBooleanMacro(PointSmoothing, vtkTypeBool);
274 
276 
280  vtkSetMacro(LineSmoothing, vtkTypeBool);
281  vtkGetMacro(LineSmoothing, vtkTypeBool);
282  vtkBooleanMacro(LineSmoothing, vtkTypeBool);
284 
286 
290  vtkSetMacro(PolygonSmoothing, vtkTypeBool);
291  vtkGetMacro(PolygonSmoothing, vtkTypeBool);
292  vtkBooleanMacro(PolygonSmoothing, vtkTypeBool);
294 
296 
317  vtkGetMacro(StereoType, int);
318  void SetStereoType(int);
319  void SetStereoTypeToCrystalEyes() { this->SetStereoType(VTK_STEREO_CRYSTAL_EYES); }
320  void SetStereoTypeToRedBlue() { this->SetStereoType(VTK_STEREO_RED_BLUE); }
321  void SetStereoTypeToInterlaced() { this->SetStereoType(VTK_STEREO_INTERLACED); }
322  void SetStereoTypeToLeft() { this->SetStereoType(VTK_STEREO_LEFT); }
323  void SetStereoTypeToRight() { this->SetStereoType(VTK_STEREO_RIGHT); }
324  void SetStereoTypeToDresden() { this->SetStereoType(VTK_STEREO_DRESDEN); }
325  void SetStereoTypeToAnaglyph() { this->SetStereoType(VTK_STEREO_ANAGLYPH); }
326  void SetStereoTypeToCheckerboard() { this->SetStereoType(VTK_STEREO_CHECKERBOARD); }
328  {
329  this->SetStereoType(VTK_STEREO_SPLITVIEWPORT_HORIZONTAL);
330  }
331  void SetStereoTypeToFake() { this->SetStereoType(VTK_STEREO_FAKE); }
332  void SetStereoTypeToEmulate() { this->SetStereoType(VTK_STEREO_EMULATE); }
334 
336 
339  const char* GetStereoTypeAsString();
340  static const char* GetStereoTypeAsString(int type);
342 
347  virtual void StereoUpdate();
348 
353  virtual void StereoMidpoint();
354 
359  virtual void StereoRenderComplete();
360 
362 
369  vtkSetClampMacro(AnaglyphColorSaturation, float, 0.0f, 1.0f);
370  vtkGetMacro(AnaglyphColorSaturation, float);
372 
374 
388  vtkSetVector2Macro(AnaglyphColorMask, int);
389  vtkGetVectorMacro(AnaglyphColorMask, int, 2);
391 
397  virtual void WindowRemap() {}
398 
400 
403  vtkSetMacro(SwapBuffers, vtkTypeBool);
404  vtkGetMacro(SwapBuffers, vtkTypeBool);
405  vtkBooleanMacro(SwapBuffers, vtkTypeBool);
407 
409 
421  virtual int SetPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, unsigned char* /*data*/,
422  int /*front*/, int /*right*/ = 0)
423  {
424  return 0;
425  }
426  virtual int SetPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
427  vtkUnsignedCharArray* /*data*/, int /*front*/, int /*right*/ = 0)
428  {
429  return 0;
430  }
432 
434 
441  virtual float* GetRGBAPixelData(
442  int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/, int /*right*/ = 0)
443  {
444  return nullptr;
445  }
446  virtual int GetRGBAPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/,
447  vtkFloatArray* /*data*/, int /*right*/ = 0)
448  {
449  return 0;
450  }
451  virtual int SetRGBAPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float*, int /*front*/,
452  int /*blend*/ = 0, int /*right*/ = 0)
453  {
454  return 0;
455  }
456  virtual int SetRGBAPixelData(
457  int, int, int, int, vtkFloatArray*, int, int /*blend*/ = 0, int /*right*/ = 0)
458  {
459  return 0;
460  }
461  virtual void ReleaseRGBAPixelData(float* /*data*/) {}
462  virtual unsigned char* GetRGBACharPixelData(
463  int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/, int /*right*/ = 0)
464  {
465  return nullptr;
466  }
467  virtual int GetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/,
468  vtkUnsignedCharArray* /*data*/, int /*right*/ = 0)
469  {
470  return 0;
471  }
472  virtual int SetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
473  unsigned char* /*data*/, int /*front*/, int /*blend*/ = 0, int /*right*/ = 0)
474  {
475  return 0;
476  }
477  virtual int SetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
478  vtkUnsignedCharArray* /*data*/, int /*front*/, int /*blend*/ = 0, int /*right*/ = 0)
479  {
480  return 0;
481  }
483 
485 
490  virtual float* GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/) { return nullptr; }
491  virtual int GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float* /*z*/)
492  {
493  return 0;
494  }
495  virtual int GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, vtkFloatArray* /*z*/)
496  {
497  return 0;
498  }
499  virtual int SetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float* /*z*/)
500  {
501  return 0;
502  }
503  virtual int SetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, vtkFloatArray* /*z*/)
504  {
505  return 0;
506  }
507  float GetZbufferDataAtPoint(int x, int y)
508  {
509  float value;
510  this->GetZbufferData(x, y, x, y, &value);
511  return value;
512  }
514 
516 
519  vtkGetMacro(NeverRendered, int);
521 
523 
527  vtkGetMacro(AbortRender, int);
528  vtkSetMacro(AbortRender, int);
529  vtkGetMacro(InAbortCheck, int);
530  vtkSetMacro(InAbortCheck, int);
531  virtual int CheckAbortStatus();
533 
535 
538  VTK_LEGACY(vtkTypeBool GetIsPicking());
539  VTK_LEGACY(void SetIsPicking(vtkTypeBool));
540  VTK_LEGACY(void IsPickingOn());
541  VTK_LEGACY(void IsPickingOff());
543 
550  virtual vtkTypeBool GetEventPending() { return 0; }
551 
555  virtual int CheckInRenderStatus() { return this->InRender; }
556 
560  virtual void ClearInRenderStatus() { this->InRender = 0; }
561 
563 
571  virtual void SetDesiredUpdateRate(double);
572  vtkGetMacro(DesiredUpdateRate, double);
574 
576 
582  vtkGetMacro(NumberOfLayers, int);
583  vtkSetClampMacro(NumberOfLayers, int, 1, VTK_INT_MAX);
585 
587 
590  vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
592 
596  void SetInteractor(vtkRenderWindowInteractor*);
597 
602  void UnRegister(vtkObjectBase* o) override;
603 
605 
608  void SetDisplayId(void*) override {}
609  void SetWindowId(void*) override {}
610  virtual void SetNextWindowId(void*) {}
611  void SetParentId(void*) override {}
612  void* GetGenericDisplayId() override { return nullptr; }
613  void* GetGenericWindowId() override { return nullptr; }
614  void* GetGenericParentId() override { return nullptr; }
615  void* GetGenericContext() override { return nullptr; }
616  void* GetGenericDrawable() override { return nullptr; }
617  void SetWindowInfo(const char*) override {}
618  virtual void SetNextWindowInfo(const char*) {}
619  void SetParentInfo(const char*) override {}
621 
626  virtual bool InitializeFromCurrentContext() { return false; }
627 
629 
636  virtual void SetSharedRenderWindow(vtkRenderWindow*);
637  vtkGetObjectMacro(SharedRenderWindow, vtkRenderWindow);
638  virtual bool GetPlatformSupportsRenderWindowSharing() { return false; }
640 
645  void MakeCurrent() override {}
646 
651  virtual bool IsCurrent() { return false; }
652 
659  VTK_LEGACY(virtual bool IsDrawable());
660 
666  virtual void SetForceMakeCurrent() {}
667 
671  virtual const char* ReportCapabilities() { return "Not Implemented"; }
672 
676  virtual int SupportsOpenGL() { return 0; }
677 
681  virtual vtkTypeBool IsDirect() { return 0; }
682 
687  virtual int GetDepthBufferSize() { return 0; }
688 
693  virtual int GetColorBufferSizes(int* /*rgba*/) { return 0; }
694 
696 
700  virtual void SetMultiSamples(int);
701  vtkGetMacro(MultiSamples, int);
703 
705 
708  vtkSetMacro(StencilCapable, vtkTypeBool);
709  vtkGetMacro(StencilCapable, vtkTypeBool);
710  vtkBooleanMacro(StencilCapable, vtkTypeBool);
712 
714 
720  vtkSetMacro(DeviceIndex, int);
721  vtkGetMacro(DeviceIndex, int);
723 
727  virtual int GetNumberOfDevices() { return 0; }
728 
730 
734  vtkGetMacro(UseSRGBColorSpace, bool);
735  vtkSetMacro(UseSRGBColorSpace, bool);
736  vtkBooleanMacro(UseSRGBColorSpace, bool);
738 
739 protected:
740  vtkRenderWindow();
741  ~vtkRenderWindow() override;
742 
743  virtual void DoStereoRender();
744 
749  int OldScreen[5];
764  int InRender;
769  int AnaglyphColorMask[2];
774 
776 
781 
783 
784 private:
785  vtkRenderWindow(const vtkRenderWindow&) = delete;
786  void operator=(const vtkRenderWindow&) = delete;
787 
788  vtkNew<vtkStereoCompositor> StereoCompositor;
789 };
790 
791 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
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: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: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