VTK  9.0.3
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 "vtkNew.h" // For vtkNew
45 #include "vtkRenderingCoreModule.h" // For export macro
46 #include "vtkSmartPointer.h" // For vtkSmartPointer
47 #include "vtkWindow.h"
48 
49 class vtkFloatArray;
50 class vtkProp;
51 class vtkCollection;
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 
84 class VTKRENDERINGCORE_EXPORT vtkRenderWindow : public vtkWindow
85 {
86 public:
87  vtkTypeMacro(vtkRenderWindow, vtkWindow);
88  void PrintSelf(ostream& os, vtkIndent indent) override;
89 
95  static vtkRenderWindow* New();
96 
100  virtual void AddRenderer(vtkRenderer*);
101 
106 
111 
115  static const char* GetRenderLibrary();
116 
120  virtual const char* GetRenderingBackend();
121 
126 
130  vtkRendererCollection* GetRenderers() { return this->Renderers; }
131 
140 
142 
145  vtkGetMacro(CapturingGL2PSSpecialProps, int);
147 
152  void Render() override;
153 
157  virtual void Start() {}
158 
162  virtual void End(){};
163 
167  virtual void Finalize() {}
168 
173  virtual void Frame() {}
174 
179  virtual void WaitForCompletion() {}
180 
185  virtual void CopyResultFrame();
186 
193 
195 
201  virtual void HideCursor() {}
202  virtual void ShowCursor() {}
203  virtual void SetCursorPosition(int, int) {}
205 
207 
210  vtkSetMacro(CurrentCursor, int);
211  vtkGetMacro(CurrentCursor, int);
213 
215 
218  virtual void SetFullScreen(vtkTypeBool) {}
219  vtkGetMacro(FullScreen, vtkTypeBool);
220  vtkBooleanMacro(FullScreen, vtkTypeBool);
222 
224 
229  vtkSetMacro(Borders, vtkTypeBool);
230  vtkGetMacro(Borders, vtkTypeBool);
231  vtkBooleanMacro(Borders, vtkTypeBool);
233 
235 
239  vtkGetMacro(StereoCapableWindow, vtkTypeBool);
240  vtkBooleanMacro(StereoCapableWindow, vtkTypeBool);
241  virtual void SetStereoCapableWindow(vtkTypeBool capable);
243 
245 
248  vtkGetMacro(StereoRender, vtkTypeBool);
250  vtkBooleanMacro(StereoRender, vtkTypeBool);
252 
254 
257  vtkSetMacro(AlphaBitPlanes, vtkTypeBool);
258  vtkGetMacro(AlphaBitPlanes, vtkTypeBool);
259  vtkBooleanMacro(AlphaBitPlanes, vtkTypeBool);
261 
263 
267  vtkSetMacro(PointSmoothing, vtkTypeBool);
268  vtkGetMacro(PointSmoothing, vtkTypeBool);
269  vtkBooleanMacro(PointSmoothing, vtkTypeBool);
271 
273 
277  vtkSetMacro(LineSmoothing, vtkTypeBool);
278  vtkGetMacro(LineSmoothing, vtkTypeBool);
279  vtkBooleanMacro(LineSmoothing, vtkTypeBool);
281 
283 
287  vtkSetMacro(PolygonSmoothing, vtkTypeBool);
288  vtkGetMacro(PolygonSmoothing, vtkTypeBool);
289  vtkBooleanMacro(PolygonSmoothing, vtkTypeBool);
291 
293 
314  vtkGetMacro(StereoType, int);
315  void SetStereoType(int);
316  void SetStereoTypeToCrystalEyes() { this->SetStereoType(VTK_STEREO_CRYSTAL_EYES); }
317  void SetStereoTypeToRedBlue() { this->SetStereoType(VTK_STEREO_RED_BLUE); }
318  void SetStereoTypeToInterlaced() { this->SetStereoType(VTK_STEREO_INTERLACED); }
319  void SetStereoTypeToLeft() { this->SetStereoType(VTK_STEREO_LEFT); }
320  void SetStereoTypeToRight() { this->SetStereoType(VTK_STEREO_RIGHT); }
321  void SetStereoTypeToDresden() { this->SetStereoType(VTK_STEREO_DRESDEN); }
322  void SetStereoTypeToAnaglyph() { this->SetStereoType(VTK_STEREO_ANAGLYPH); }
323  void SetStereoTypeToCheckerboard() { this->SetStereoType(VTK_STEREO_CHECKERBOARD); }
325  {
326  this->SetStereoType(VTK_STEREO_SPLITVIEWPORT_HORIZONTAL);
327  }
328  void SetStereoTypeToFake() { this->SetStereoType(VTK_STEREO_FAKE); }
329  void SetStereoTypeToEmulate() { this->SetStereoType(VTK_STEREO_EMULATE); }
331 
333 
336  const char* GetStereoTypeAsString();
337  static const char* GetStereoTypeAsString(int type);
339 
344  virtual void StereoUpdate();
345 
350  virtual void StereoMidpoint();
351 
356  virtual void StereoRenderComplete();
357 
359 
366  vtkSetClampMacro(AnaglyphColorSaturation, float, 0.0f, 1.0f);
367  vtkGetMacro(AnaglyphColorSaturation, float);
369 
371 
385  vtkSetVector2Macro(AnaglyphColorMask, int);
386  vtkGetVectorMacro(AnaglyphColorMask, int, 2);
388 
394  virtual void WindowRemap() {}
395 
397 
400  vtkSetMacro(SwapBuffers, vtkTypeBool);
401  vtkGetMacro(SwapBuffers, vtkTypeBool);
402  vtkBooleanMacro(SwapBuffers, vtkTypeBool);
404 
406 
418  virtual int SetPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, unsigned char* /*data*/,
419  int /*front*/, int /*right*/ = 0)
420  {
421  return 0;
422  }
423  virtual int SetPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
424  vtkUnsignedCharArray* /*data*/, int /*front*/, int /*right*/ = 0)
425  {
426  return 0;
427  }
429 
431 
438  virtual float* GetRGBAPixelData(
439  int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/, int /*right*/ = 0)
440  {
441  return nullptr;
442  }
443  virtual int GetRGBAPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/,
444  vtkFloatArray* /*data*/, int /*right*/ = 0)
445  {
446  return 0;
447  }
448  virtual int SetRGBAPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float*, int /*front*/,
449  int /*blend*/ = 0, int /*right*/ = 0)
450  {
451  return 0;
452  }
453  virtual int SetRGBAPixelData(
454  int, int, int, int, vtkFloatArray*, int, int /*blend*/ = 0, int /*right*/ = 0)
455  {
456  return 0;
457  }
458  virtual void ReleaseRGBAPixelData(float* /*data*/) {}
459  virtual unsigned char* GetRGBACharPixelData(
460  int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/, int /*right*/ = 0)
461  {
462  return nullptr;
463  }
464  virtual int GetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/,
465  vtkUnsignedCharArray* /*data*/, int /*right*/ = 0)
466  {
467  return 0;
468  }
469  virtual int SetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
470  unsigned char* /*data*/, int /*front*/, int /*blend*/ = 0, int /*right*/ = 0)
471  {
472  return 0;
473  }
474  virtual int SetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
475  vtkUnsignedCharArray* /*data*/, int /*front*/, int /*blend*/ = 0, int /*right*/ = 0)
476  {
477  return 0;
478  }
480 
482 
487  virtual float* GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/) { return nullptr; }
488  virtual int GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float* /*z*/)
489  {
490  return 0;
491  }
492  virtual int GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, vtkFloatArray* /*z*/)
493  {
494  return 0;
495  }
496  virtual int SetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float* /*z*/)
497  {
498  return 0;
499  }
500  virtual int SetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, vtkFloatArray* /*z*/)
501  {
502  return 0;
503  }
504  float GetZbufferDataAtPoint(int x, int y)
505  {
506  float value;
507  this->GetZbufferData(x, y, x, y, &value);
508  return value;
509  }
511 
513 
516  vtkGetMacro(NeverRendered, int);
518 
520 
524  vtkGetMacro(AbortRender, int);
525  vtkSetMacro(AbortRender, int);
526  vtkGetMacro(InAbortCheck, int);
527  vtkSetMacro(InAbortCheck, int);
528  virtual int CheckAbortStatus();
530 
532 
535  VTK_LEGACY(vtkTypeBool GetIsPicking());
536  VTK_LEGACY(void SetIsPicking(vtkTypeBool));
537  VTK_LEGACY(void IsPickingOn());
538  VTK_LEGACY(void IsPickingOff());
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 
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 
634  vtkGetObjectMacro(SharedRenderWindow, vtkRenderWindow);
635  virtual bool GetPlatformSupportsRenderWindowSharing() { return false; }
637 
642  void MakeCurrent() override {}
643 
648  virtual bool IsCurrent() { return false; }
649 
656  VTK_LEGACY(virtual bool IsDrawable());
657 
663  virtual void SetForceMakeCurrent() {}
664 
668  virtual const char* ReportCapabilities() { return "Not Implemented"; }
669 
673  virtual int SupportsOpenGL() { return 0; }
674 
678  virtual vtkTypeBool IsDirect() { return 0; }
679 
684  virtual int GetDepthBufferSize() { return 0; }
685 
690  virtual int GetColorBufferSizes(int* /*rgba*/) { return 0; }
691 
693 
697  virtual void SetMultiSamples(int);
698  vtkGetMacro(MultiSamples, int);
700 
702 
705  vtkSetMacro(StencilCapable, vtkTypeBool);
706  vtkGetMacro(StencilCapable, vtkTypeBool);
707  vtkBooleanMacro(StencilCapable, vtkTypeBool);
709 
711 
717  vtkSetMacro(DeviceIndex, int);
718  vtkGetMacro(DeviceIndex, int);
720 
724  virtual int GetNumberOfDevices() { return 0; }
725 
727 
731  vtkGetMacro(UseSRGBColorSpace, bool);
732  vtkSetMacro(UseSRGBColorSpace, bool);
733  vtkBooleanMacro(UseSRGBColorSpace, bool);
735 
736 protected:
738  ~vtkRenderWindow() override;
739 
740  virtual void DoStereoRender();
741 
746  int OldScreen[5];
761  int InRender;
766  int AnaglyphColorMask[2];
771 
773 
778 
780 
781 private:
782  vtkRenderWindow(const vtkRenderWindow&) = delete;
783  void operator=(const vtkRenderWindow&) = delete;
784 
785  vtkNew<vtkStereoCompositor> StereoCompositor;
786 };
787 
788 #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:48
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:59
helper class to generate composited stereo images.
dynamic, self-adjusting array of unsigned char
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
@ 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