VTK  9.0.2
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 
115 
120 
124  static const char* GetRenderLibrary();
125 
129  virtual const char* GetRenderingBackend();
130 
135 
139  vtkRendererCollection* GetRenderers() { return this->Renderers; }
140 
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 
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);
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 
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 
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:
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
create and manipulate ordered lists of objects
Definition: vtkCollection.h:53
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:36
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract base class for most VTK objects
Definition: vtkObjectBase.h:64
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:54
Asynchronously measures GPU execution times for a series of events.
platform-independent render window interaction including picking and frame rate control.
create a window for renderers to draw into
void SetStereoTypeToDresden()
virtual void SetDesiredUpdateRate(double)
Set/Get the desired update rate.
virtual void ReleaseRGBAPixelData(float *)
virtual int GetZbufferData(int, int, int, int, float *)
void SetStereoType(int)
static const char * GetRenderLibrary()
What rendering library has the user requested.
virtual int SetRGBACharPixelData(int, int, int, int, unsigned char *, int, int=0, int=0)
virtual int SetZbufferData(int, int, int, int, float *)
vtkRendererCollection * GetRenderers()
Return the collection of renderers in the render window.
virtual bool IsDrawable()
Test if the window has a valid drawable.
void SetStereoTypeToRedBlue()
virtual float * GetRGBAPixelData(int, int, int, int, int, int=0)
Same as Get/SetPixelData except that the image also contains an alpha component.
vtkNew< vtkRenderTimerLog > RenderTimer
void SetParentInfo(const char *) override
virtual void Finalize()
Finalize the rendering process.
const char * GetStereoTypeAsString()
Returns the stereo type as a string.
void SetInteractor(vtkRenderWindowInteractor *)
Set the interactor to the render window.
vtkTypeBool GetIsPicking()
virtual bool GetPlatformSupportsRenderWindowSharing()
double AbortCheckTime
The universal time since the last abort check occurred.
virtual int SetRGBAPixelData(int, int, int, int, float *, int, int=0, int=0)
virtual int SetPixelData(int, int, int, int, unsigned char *, int, int=0)
Set/Get the pixel data of an image, transmitted as RGBRGBRGB.
virtual void AddRenderer(vtkRenderer *)
Add a renderer to the list of renderers.
void * GetGenericDisplayId() override
virtual void Frame()
A termination method performed at the end of the rendering process to do things like swapping buffers...
vtkTypeBool LineSmoothing
vtkRenderWindowInteractor * Interactor
void SetStereoTypeToFake()
virtual int GetZbufferData(int, int, int, int, vtkFloatArray *)
float AnaglyphColorSaturation
vtkTypeBool FullScreen
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...
void SetStereoTypeToInterlaced()
void CaptureGL2PSSpecialProps(vtkCollection *specialProps)
The GL2PS exporter must handle certain props in a special way (e.g.
void * GetGenericWindowId() override
virtual int GetRGBACharPixelData(int, int, int, int, int, vtkUnsignedCharArray *, int=0)
virtual unsigned char * GetRGBACharPixelData(int, int, int, int, int, int=0)
float GetZbufferDataAtPoint(int x, int y)
virtual void WaitForCompletion()
Block the thread until the actual rendering is finished().
virtual void StereoRenderComplete()
Handles work required once both views have been rendered when using stereo rendering.
virtual void SetStereoCapableWindow(vtkTypeBool capable)
virtual int SetPixelData(int, int, int, int, vtkUnsignedCharArray *, int, int=0)
vtkTypeBool PolygonSmoothing
static vtkRenderWindow * New()
Construct an instance of vtkRenderWindow with its screen size set to 300x300, borders turned on,...
~vtkRenderWindow() override
virtual int GetDepthBufferSize()
This method should be defined by the subclass.
void SetStereoRender(vtkTypeBool stereo)
void SetStereoTypeToLeft()
virtual void SetFullScreen(vtkTypeBool)
Turn on/off rendering full screen window size.
virtual void SetNextWindowId(void *)
virtual bool InitializeFromCurrentContext()
Initialize the render window from the information associated with the currently activated OpenGL cont...
void SetWindowInfo(const char *) override
void * GetGenericContext() override
virtual void DoStereoRender()
virtual int GetRGBAPixelData(int, int, int, int, int, vtkFloatArray *, int=0)
virtual void SetNextWindowInfo(const char *)
virtual void ClearInRenderStatus()
Clear status (after an exception was thrown for example)
virtual vtkRenderWindowInteractor * MakeRenderWindowInteractor()
Create an interactor to control renderers in this window.
void Render() override
Ask each renderer owned by this RenderWindow to render its image and synchronize this process.
vtkSmartPointer< vtkUnsignedCharArray > ResultFrame
void SetParentId(void *) override
virtual void End()
Update the system, if needed, at end of render process.
void MakeCurrent() override
Attempt to make this window the current graphics context for the calling thread.
virtual int CheckAbortStatus()
virtual void SetForceMakeCurrent()
If called, allow MakeCurrent() to skip cache-check when called.
void SetWindowId(void *) override
void SetStereoTypeToCheckerboard()
static const char * GetStereoTypeAsString(int type)
void UnRegister(vtkObjectBase *o) override
This Method detects loops of RenderWindow<->Interactor, so objects are freed properly.
virtual float * GetZbufferData(int, int, int, int)
Set/Get the zbuffer data from the frame buffer.
virtual int SupportsOpenGL()
Does this render window support OpenGL? 0-false, 1-true.
vtkTypeBool AlphaBitPlanes
vtkRenderWindow * SharedRenderWindow
virtual void StereoUpdate()
Update the system, if needed, due to stereo rendering.
virtual void SetMultiSamples(int)
Set / Get the number of multisamples to use for hardware antialiasing.
virtual void Start()
Start the rendering process for a frame.
void SetStereoTypeToAnaglyph()
virtual void CopyResultFrame()
Performed at the end of the rendering process to generate image.
void * GetGenericParentId() override
virtual int SetRGBACharPixelData(int, int, int, int, vtkUnsignedCharArray *, int, int=0, int=0)
vtkRendererCollection * Renderers
virtual int SetRGBAPixelData(int, int, int, int, vtkFloatArray *, int, int=0, int=0)
vtkTypeBool StencilCapable
virtual void WindowRemap()
Remap the rendering window.
void RemoveRenderer(vtkRenderer *)
Remove a renderer from the list of renderers.
virtual int SetZbufferData(int, int, int, int, vtkFloatArray *)
vtkTypeBool StereoRender
void SetIsPicking(vtkTypeBool)
virtual int GetColorBufferSizes(int *)
Get the size of the color buffer.
vtkGetNewMacro(RenderTimer, vtkRenderTimerLog)
Get the render timer log for this window.
virtual void SetSharedRenderWindow(vtkRenderWindow *)
Set/Get an already existing window that this window should share data with if possible.
vtkTypeBool PointSmoothing
vtkTypeBool StereoCapableWindow
virtual void SetCursorPosition(int, int)
virtual vtkTypeBool GetEventPending()
Check to see if a mouse button has been pressed.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void StereoMidpoint()
Intermediate method performs operations required between the rendering of the left and right eye.
void SetDisplayId(void *) override
Dummy stubs for vtkWindow API.
void SetStereoTypeToEmulate()
virtual const char * ReportCapabilities()
Get report of capabilities for the render window.
void SetStereoTypeToSplitViewportHorizontal()
int HasRenderer(vtkRenderer *)
Query if a renderer is in the list of renderers.
virtual int GetNumberOfDevices()
Returns the number of devices (graphics cards) on a system.
virtual void ShowCursor()
vtkSmartPointer< vtkUnsignedCharArray > StereoBuffer
virtual vtkTypeBool IsDirect()
Is this render window using hardware acceleration? 0-false, 1-true.
void SetStereoTypeToCrystalEyes()
vtkTypeBool SwapBuffers
void SetStereoTypeToRight()
virtual int CheckInRenderStatus()
Are we rendering at the moment.
vtkTypeBool Borders
virtual bool IsCurrent()
Tells if this window is the current graphics context for the calling thread.
void * GetGenericDrawable() override
virtual const char * GetRenderingBackend()
What rendering backend has the user requested.
an ordered list of renderers
abstract specification for renderers
Definition: vtkRenderer.h:68
helper class to generate composited stereo images.
dynamic, self-adjusting array of unsigned char
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
@ value
Definition: vtkX3D.h:226
@ type
Definition: vtkX3D.h:522
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_STEREO_ANAGLYPH
#define VTK_STEREO_SPLITVIEWPORT_HORIZONTAL
#define VTK_STEREO_DRESDEN
#define VTK_STEREO_CHECKERBOARD
#define VTK_STEREO_CRYSTAL_EYES
#define VTK_STEREO_RIGHT
#define VTK_STEREO_FAKE
#define VTK_STEREO_RED_BLUE
#define VTK_STEREO_INTERLACED
#define VTK_STEREO_EMULATE
#define VTK_STEREO_LEFT
#define VTK_INT_MAX
Definition: vtkType.h:155