VTK  9.6.20260202
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
146
147#ifndef vtkRenderWindow_h
148#define vtkRenderWindow_h
149
150#include "vtkEventData.h" // for enums
151#include "vtkNew.h" // For vtkNew
152#include "vtkRenderingCoreModule.h" // For export macro
153#include "vtkSmartPointer.h" // For vtkSmartPointer
154#include "vtkWindow.h"
155#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
156
157VTK_ABI_NAMESPACE_BEGIN
158class vtkCollection;
159class vtkFloatArray;
161class vtkMatrix4x4;
162class vtkProp;
165class vtkRenderer;
169
170// lets define the different types of stereo
171#define VTK_STEREO_CRYSTAL_EYES 1
172#define VTK_STEREO_RED_BLUE 2
173#define VTK_STEREO_INTERLACED 3
174#define VTK_STEREO_LEFT 4
175#define VTK_STEREO_RIGHT 5
176#define VTK_STEREO_DRESDEN 6
177#define VTK_STEREO_ANAGLYPH 7
178#define VTK_STEREO_CHECKERBOARD 8
179#define VTK_STEREO_SPLITVIEWPORT_HORIZONTAL 9
180#define VTK_STEREO_FAKE 10
181#define VTK_STEREO_EMULATE 11
182#define VTK_STEREO_ZSPACE_INSPIRE 12
183
184class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkRenderWindow : public vtkWindow
185{
186public:
188 void PrintSelf(ostream& os, vtkIndent indent) override;
189
196
200 virtual void AddRenderer(vtkRenderer*);
201
206
211
215 static const char* GetRenderLibrary();
216
220 virtual const char* GetRenderingBackend();
221
227
232
241
243
246 vtkGetMacro(CapturingGL2PSSpecialProps, int);
248
253 void Render() override;
254
258 virtual void Start() {}
259
263 virtual void End() {}
264
270 virtual void Initialize() {}
271
273
276 vtkGetMacro(Initialized, bool);
278
282 virtual void Finalize() {}
283
288 virtual void Frame() {}
289
294 virtual void WaitForCompletion() {}
295
300 virtual void CopyResultFrame();
301
308
310
313 virtual void SetFullScreen(vtkTypeBool) {}
314 vtkGetMacro(FullScreen, vtkTypeBool);
315 vtkBooleanMacro(FullScreen, vtkTypeBool);
317
319
323 vtkGetMacro(Coverable, vtkTypeBool);
324 vtkBooleanMacro(Coverable, vtkTypeBool);
325 virtual void SetCoverable(vtkTypeBool coverable);
327
329
335 virtual void SetStereoCapableWindow(vtkTypeBool capable);
337
339
360 vtkGetMacro(StereoType, int);
361 void SetStereoType(int);
377
379
383 static const char* GetStereoTypeAsString(int type);
385
387
392 vtkBooleanMacro(StereoRender, vtkTypeBool);
394
396
401 vtkBooleanMacro(AlphaBitPlanes, vtkTypeBool);
403
405
411 vtkBooleanMacro(PointSmoothing, vtkTypeBool);
413
415
421 vtkBooleanMacro(LineSmoothing, vtkTypeBool);
423
425
431 vtkBooleanMacro(PolygonSmoothing, vtkTypeBool);
433
438 virtual void StereoUpdate();
439
444 virtual void StereoMidpoint();
445
450 virtual void StereoRenderComplete();
451
453
460 vtkSetClampMacro(AnaglyphColorSaturation, float, 0.0f, 1.0f);
461 vtkGetMacro(AnaglyphColorSaturation, float);
463
465
479 vtkSetVector2Macro(AnaglyphColorMask, int);
480 vtkGetVectorMacro(AnaglyphColorMask, int, 2);
482
488 virtual void WindowRemap() {}
489
491
496 vtkBooleanMacro(SwapBuffers, vtkTypeBool);
498
500
512 virtual int SetPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, unsigned char* /*data*/,
513 int /*front*/, int /*right*/ = 0)
514 {
515 return 0;
516 }
517 virtual int SetPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
518 vtkUnsignedCharArray* /*data*/, int /*front*/, int /*right*/ = 0)
519 {
520 return 0;
521 }
522
523
525
532 virtual float* GetRGBAPixelData(
533 int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/, int /*right*/ = 0)
534 {
535 return nullptr;
536 }
537 virtual int GetRGBAPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/,
538 vtkFloatArray* /*data*/, int /*right*/ = 0)
539 {
540 return 0;
541 }
542 virtual int SetRGBAPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float*, int /*front*/,
543 int /*blend*/ = 0, int /*right*/ = 0)
544 {
545 return 0;
546 }
547 virtual int SetRGBAPixelData(
548 int, int, int, int, vtkFloatArray*, int, int /*blend*/ = 0, int /*right*/ = 0)
549 {
550 return 0;
551 }
552 virtual void ReleaseRGBAPixelData(float* /*data*/) {}
553 virtual unsigned char* GetRGBACharPixelData(
554 int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/, int /*right*/ = 0)
555 {
556 return nullptr;
557 }
558 virtual int GetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, int /*front*/,
559 vtkUnsignedCharArray* /*data*/, int /*right*/ = 0)
560 {
561 return 0;
562 }
563 virtual int SetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
564 unsigned char* /*data*/, int /*front*/, int /*blend*/ = 0, int /*right*/ = 0)
565 {
566 return 0;
567 }
568 virtual int SetRGBACharPixelData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/,
569 vtkUnsignedCharArray* /*data*/, int /*front*/, int /*blend*/ = 0, int /*right*/ = 0)
570 {
571 return 0;
572 }
573
574
576
581 virtual float* GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/) { return nullptr; }
582 virtual int GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float* /*z*/)
583 {
584 return 0;
585 }
586 virtual int GetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, vtkFloatArray* /*z*/)
587 {
588 return 0;
589 }
590 virtual int SetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, float* /*z*/)
591 {
592 return 0;
593 }
594 virtual int SetZbufferData(int /*x*/, int /*y*/, int /*x2*/, int /*y2*/, vtkFloatArray* /*z*/)
595 {
596 return 0;
597 }
598 float GetZbufferDataAtPoint(int x, int y)
599 {
600 float value = 1.0f;
601 this->GetZbufferData(x, y, x, y, &value);
602 return value;
603 }
604
605
607
610 vtkGetMacro(NeverRendered, int);
612
614
618 vtkGetMacro(AbortRender, int);
619 vtkSetMacro(AbortRender, int);
620 vtkGetMacro(InAbortCheck, int);
621 vtkSetMacro(InAbortCheck, int);
622 virtual int CheckAbortStatus();
624
631 virtual vtkTypeBool GetEventPending() { return 0; }
632
636 virtual int CheckInRenderStatus() { return this->InRender; }
637
641 virtual void ClearInRenderStatus() { this->InRender = 0; }
642
644
652 virtual void SetDesiredUpdateRate(double);
653 vtkGetMacro(DesiredUpdateRate, double);
655
657
663 vtkGetMacro(NumberOfLayers, int);
664 vtkSetClampMacro(NumberOfLayers, int, 1, VTK_INT_MAX);
666
668
673
678
683 void UnRegister(vtkObjectBase* o) override;
684
686
689 void SetDisplayId(void*) override {}
690 void SetWindowId(void*) override {}
691 virtual void SetNextWindowId(void*) {}
692 void SetParentId(void*) override {}
693 void* GetGenericDisplayId() override { return nullptr; }
694 void* GetGenericWindowId() override { return nullptr; }
695 void* GetGenericParentId() override { return nullptr; }
696 void* GetGenericContext() override { return nullptr; }
697 void* GetGenericDrawable() override { return nullptr; }
698 void SetWindowInfo(const char*) override {}
699 virtual void SetNextWindowInfo(const char*) {}
700 void SetParentInfo(const char*) override {}
702
707 virtual bool InitializeFromCurrentContext() { return false; }
708
710
719 virtual bool GetPlatformSupportsRenderWindowSharing() { return false; }
721
726 virtual bool IsCurrent() { return false; }
727
733 virtual void SetForceMakeCurrent() {}
734
738 virtual const char* ReportCapabilities() { return "Not Implemented"; }
739
743 virtual int SupportsOpenGL() { return 0; }
744
748 virtual vtkTypeBool IsDirect() { return 0; }
749
754 virtual int GetDepthBufferSize() { return 0; }
755
760 virtual int GetColorBufferSizes(int* /*rgba*/) { return 0; }
761
763
768 virtual void SetMultiSamples(int);
769 vtkGetMacro(MultiSamples, int);
771
773
778 vtkBooleanMacro(StencilCapable, vtkTypeBool);
780
782
788 vtkSetMacro(DeviceIndex, int);
789 vtkGetMacro(DeviceIndex, int);
791
795 virtual int GetNumberOfDevices() { return 0; }
796
798
802 vtkGetMacro(UseSRGBColorSpace, bool);
803 vtkSetMacro(UseSRGBColorSpace, bool);
804 vtkBooleanMacro(UseSRGBColorSpace, bool);
806
807 enum : vtkTypeUInt16
808 {
810 };
811
813
821 virtual void SetPhysicalViewDirection(double, double, double);
822 virtual void SetPhysicalViewDirection(double[3]);
823 vtkGetVector3Macro(PhysicalViewDirection, double);
825
827
835 virtual void SetPhysicalViewUp(double, double, double);
836 virtual void SetPhysicalViewUp(double[3]);
837 vtkGetVector3Macro(PhysicalViewUp, double);
839
841
849 virtual void SetPhysicalTranslation(double, double, double);
850 virtual void SetPhysicalTranslation(double[3]);
851 vtkGetVector3Macro(PhysicalTranslation, double);
853
855
864 virtual void SetPhysicalScale(double);
865 vtkGetMacro(PhysicalScale, double);
867
875
882
890 vtkEventDataDevice device, vtkMatrix4x4* deviceToWorldMatrix);
891
893
899 vtkGetMacro(EnableTranslucentSurface, bool);
900 vtkSetMacro(EnableTranslucentSurface, bool);
901 vtkBooleanMacro(EnableTranslucentSurface, bool);
903
905
912
913protected:
915 ~vtkRenderWindow() override;
916
917 virtual void DoStereoRender();
918
923 int OldScreen[5];
947
949
954
956
957 // -Z axis of the Physical to World matrix
958 double PhysicalViewDirection[3] = { 0.0, 0.0, -1.0 };
959 // Y axis of the Physical to World matrix
960 double PhysicalViewUp[3] = { 0.0, 1.0, 0.0 };
961 // Inverse of the translation component of the Physical to World matrix, in mm
962 double PhysicalTranslation[3] = { 0.0, 0.0, 0.0 };
963 // Scale of the Physical to World matrix
964 double PhysicalScale = 1.0;
965
967
968 bool Initialized = false;
969
971
972private:
973 vtkRenderWindow(const vtkRenderWindow&) = delete;
974 void operator=(const vtkRenderWindow&) = delete;
975
976 vtkNew<vtkStereoCompositor> StereoCompositor;
977};
978
979VTK_ABI_NAMESPACE_END
980#endif
create and manipulate ordered lists of objects
dynamic, self-adjusting array of float
create a window for renderers to draw into
a simple class to control print indentation
Definition vtkIndent.h:108
represent and manipulate 4x4 transformation matrices
Allocate and hold a VTK object.
Definition vtkNew.h:167
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:69
Asynchronously measures GPU execution times for a series of events.
platform-independent render window interaction including picking and frame rate control.
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.
void SetStereoTypeToDresden()
Set/Get what type of stereo rendering to use.
virtual void SetDesiredUpdateRate(double)
Set/Get the desired update rate.
virtual void ReleaseRGBAPixelData(float *)
Same as Get/SetPixelData except that the image also contains an alpha component.
virtual void SetPhysicalViewUp(double, double, double)
Set/get physical coordinate system in world coordinate system.
virtual int GetZbufferData(int, int, int, int, float *)
Set/Get the zbuffer data from the frame buffer.
void SetStereoType(int)
Set/Get what type of stereo rendering to use.
virtual void SetPhysicalTranslation(double, double, double)
Set/get physical coordinate system in world coordinate system.
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.
virtual int SetZbufferData(int, int, int, int, float *)
Set/Get the zbuffer data from the frame buffer.
void SetStereoTypeToRedBlue()
Set/Get what type of stereo rendering to use.
virtual void Initialize()
Initializes the rendering process.
vtkNew< vtkRenderTimerLog > RenderTimer
void SetParentInfo(const char *) override
Dummy stubs for vtkWindow API.
virtual void Finalize()
Finalize the rendering process.
void * GetGenericParentId() override
Dummy stubs for vtkWindow API.
virtual bool GetPlatformSupportsRenderWindowSharing()
Set/Get an already existing window that this window should share data with if possible.
virtual void SetHardwareWindow(vtkHardwareWindow *win)
Set/Get the platform hardware window associated with this window.
virtual const char * GetRenderingBackend()
What rendering backend has the user requested.
virtual vtkHardwareWindow * GetHardwareWindow()
Set/Get the platform hardware window associated with this window.
double AbortCheckTime
The universal time since the last abort check occurred.
virtual void SetPhysicalTranslation(double[3])
Set/get physical coordinate system in world coordinate system.
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 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.
virtual const char * ReportCapabilities()
Get report of capabilities for the render window.
virtual void GetPhysicalToWorldMatrix(vtkMatrix4x4 *matrix)
Get physical to world transform matrix.
virtual void Frame()
A termination method performed at the end of the rendering process to do things like swapping buffers...
vtkTypeBool LineSmoothing
virtual void SetCoverable(vtkTypeBool coverable)
Set/Get whether windows should be coverable (as opposed to always on top).
double PhysicalTranslation[3]
vtkRenderWindowInteractor * Interactor
void SetStereoTypeToFake()
Set/Get what type of stereo rendering to use.
virtual bool GetDeviceToWorldMatrixForDevice(vtkEventDataDevice device, vtkMatrix4x4 *deviceToWorldMatrix)
Store in deviceToWorldMatrix the matrix that goes from device coordinates to world coordinates.
static const char * GetStereoTypeAsString(int type)
Returns the stereo type as a string.
virtual int GetZbufferData(int, int, int, int, vtkFloatArray *)
Set/Get the zbuffer data from the frame buffer.
vtkTypeBool FullScreen
void SetStereoTypeToInterlaced()
Set/Get what type of stereo rendering to use.
static vtkRenderWindow * New()
Construct an instance of vtkRenderWindow with its screen size set to 300x300, borders turned on,...
void CaptureGL2PSSpecialProps(vtkCollection *specialProps)
The GL2PS exporter must handle certain props in a special way (e.g.
vtkTypeBool HasRenderer(vtkRenderer *)
Query if a renderer is in the list of renderers.
virtual int GetRGBACharPixelData(int, int, int, int, int, vtkUnsignedCharArray *, int=0)
Same as Get/SetPixelData except that the image also contains an alpha component.
float GetZbufferDataAtPoint(int x, int y)
Set/Get the zbuffer data from the frame buffer.
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)
Prescribe that the window be created in a stereo-capable mode.
virtual int SetPixelData(int, int, int, int, vtkUnsignedCharArray *, int, int=0)
Set/Get the pixel data of an image, transmitted as RGBRGBRGB.
vtkTypeBool PolygonSmoothing
virtual vtkRenderWindowInteractor * MakeRenderWindowInteractor()
Create an interactor to control renderers in this window.
virtual void SetPhysicalToWorldMatrix(vtkMatrix4x4 *matrix)
Set physical to world transform matrix.
virtual int GetDepthBufferSize()
This method should be defined by the subclass.
void SetStereoRender(vtkTypeBool stereo)
Turn on/off stereo rendering.
void SetStereoTypeToLeft()
Set/Get what type of stereo rendering to use.
virtual void SetFullScreen(vtkTypeBool)
Turn on/off rendering full screen window size.
virtual void SetNextWindowId(void *)
Dummy stubs for vtkWindow API.
virtual bool InitializeFromCurrentContext()
Initialize the render window from the information associated with the currently activated OpenGL cont...
void SetWindowInfo(const char *) override
Dummy stubs for vtkWindow API.
virtual void DoStereoRender()
virtual void SetPhysicalViewDirection(double, double, double)
Set/get physical coordinate system in world coordinate system.
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.
virtual void ClearInRenderStatus()
Clear status (after an exception was thrown for example)
virtual float * GetZbufferData(int, int, int, int)
Set/Get the zbuffer data from the frame buffer.
vtkTypeBool Coverable
void Render() override
Ask each renderer owned by this RenderWindow to render its image and synchronize this process.
void * GetGenericContext() override
Dummy stubs for vtkWindow API.
vtkSmartPointer< vtkUnsignedCharArray > ResultFrame
void SetParentId(void *) override
Dummy stubs for vtkWindow API.
virtual void SetInteractor(vtkRenderWindowInteractor *)
Set the interactor to the render window.
virtual void End()
Update the system, if needed, at end of render process.
virtual void SetPhysicalViewDirection(double[3])
Set/get physical coordinate system in world coordinate system.
virtual int CheckAbortStatus()
This is a flag that can be set to interrupt a rendering that is in progress.
virtual void SetForceMakeCurrent()
If called, allow MakeCurrent() to skip cache-check when called.
void SetWindowId(void *) override
Dummy stubs for vtkWindow API.
virtual void SetPhysicalViewUp(double[3])
Set/get physical coordinate system in world coordinate system.
void SetStereoTypeToCheckerboard()
Set/Get what type of stereo rendering to use.
double PhysicalViewDirection[3]
void UnRegister(vtkObjectBase *o) override
This Method detects loops of RenderWindow<->Interactor, so objects are freed properly.
virtual int SupportsOpenGL()
Does this render window support OpenGL?
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()
Set/Get what type of stereo rendering to use.
virtual void CopyResultFrame()
Performed at the end of the rendering process to generate image.
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.
vtkRendererCollection * Renderers
virtual unsigned char * GetRGBACharPixelData(int, int, int, int, int, 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.
vtkTypeBool StencilCapable
static const char * GetRenderLibrary()
What rendering library has the user requested.
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
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 *)
Set/Get the zbuffer data from the frame buffer.
vtkTypeBool StereoRender
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 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.
vtkSmartPointer< vtkHardwareWindow > HardwareWindow
void SetStereoTypeToEmulate()
Set/Get what type of stereo rendering to use.
void SetStereoTypeToSplitViewportHorizontal()
Set/Get what type of stereo rendering to use.
virtual int GetNumberOfDevices()
Returns the number of devices (graphics cards) on a system.
vtkSmartPointer< vtkUnsignedCharArray > StereoBuffer
virtual float * GetRGBAPixelData(int, int, int, int, int, int=0)
Same as Get/SetPixelData except that the image also contains an alpha component.
virtual vtkTypeBool IsDirect()
Is this render window using hardware acceleration?
vtkRendererCollection * GetRenderers()
Return the collection of renderers in the render window.
void SetStereoTypeToCrystalEyes()
Set/Get what type of stereo rendering to use.
vtkTypeBool SwapBuffers
double PhysicalViewUp[3]
virtual void SetPhysicalScale(double)
Set/get physical coordinate system in world coordinate system.
void SetStereoTypeToRight()
Set/Get what type of stereo rendering to use.
virtual int CheckInRenderStatus()
Are we rendering at the moment.
void * GetGenericDisplayId() override
Dummy stubs for vtkWindow API.
virtual bool IsCurrent()
Tells if this window is the current graphics context for the calling thread.
const char * GetStereoTypeAsString()
Returns the stereo type as a string.
an ordered list of renderers
abstract specification for renderers
Hold a reference to a vtkObjectBase instance.
helper class to generate composited stereo images.
dynamic, self-adjusting array of unsigned char
int vtkTypeBool
Definition vtkABI.h:64
vtkEventDataDevice
platform-independent event data structures
#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:183
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)