VTK  9.4.20241222
vtkSynchronizedRenderers.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
21#ifndef vtkSynchronizedRenderers_h
22#define vtkSynchronizedRenderers_h
23
24#include "vtkObject.h"
25#include "vtkRenderingParallelModule.h" // For export macro
26#include "vtkSmartPointer.h" // needed for vtkSmartPointer.
27#include "vtkUnsignedCharArray.h" // needed for vtkUnsignedCharArray.
28
29#include <memory> // for std::unique_ptr
30
31VTK_ABI_NAMESPACE_BEGIN
32class vtkFXAAOptions;
33class vtkRenderer;
38
39class VTKRENDERINGPARALLEL_EXPORT vtkSynchronizedRenderers : public vtkObject
40{
41public:
44 void PrintSelf(ostream& os, vtkIndent indent) override;
45
47
53 virtual void SetRenderer(vtkRenderer*);
56
58
63 vtkGetObjectMacro(ParallelController, vtkMultiProcessController);
65
67
71 vtkSetMacro(ParallelRendering, bool);
72 vtkGetMacro(ParallelRendering, bool);
73 vtkBooleanMacro(ParallelRendering, bool);
75
77
80 vtkSetClampMacro(ImageReductionFactor, int, 1, 50);
81 vtkGetMacro(ImageReductionFactor, int);
83
85
90 vtkSetMacro(WriteBackImages, bool);
91 vtkGetMacro(WriteBackImages, bool);
92 vtkBooleanMacro(WriteBackImages, bool);
94
96
101 vtkSetMacro(RootProcessId, int);
102 vtkGetMacro(RootProcessId, int);
104
113
115
120 vtkGetObjectMacro(CaptureDelegate, vtkSynchronizedRenderers);
122
124
130
132
139 vtkSetMacro(AutomaticEventHandling, bool);
140 vtkGetMacro(AutomaticEventHandling, bool);
141 vtkBooleanMacro(AutomaticEventHandling, bool);
143
145
156 vtkSetMacro(FixBackground, bool);
157 vtkGetMacro(FixBackground, bool);
158 vtkBooleanMacro(FixBackground, bool);
160
161 enum
162 {
163 SYNC_RENDERER_TAG = 15101,
164 RESET_CAMERA_TAG = 15102,
165 COMPUTE_BOUNDS_TAG = 15103
166 };
167
170 struct VTKRENDERINGPARALLEL_EXPORT vtkRawImage
171 {
172 public:
174 {
175 this->Valid = false;
176 this->Size[0] = this->Size[1] = 0;
178 }
179
180 void Resize(int dx, int dy, int numcomps)
181 {
182 this->Valid = false;
183 this->Allocate(dx, dy, numcomps);
184 }
185
189 void Initialize(int dx, int dy, vtkUnsignedCharArray* data);
190
191 void MarkValid() { this->Valid = true; }
192 void MarkInValid() { this->Valid = false; }
193
194 bool IsValid() { return this->Valid; }
195 int GetWidth() { return this->Size[0]; }
196 int GetHeight() { return this->Size[1]; }
197 vtkUnsignedCharArray* GetRawPtr() { return this->Data; }
198
206 bool PushToViewport(vtkRenderer* renderer, bool blend = true);
207
215 bool PushToFrameBuffer(vtkRenderer* ren, bool blend = true);
216
217 // Captures the image from the viewport.
218 // This doesn't trigger a render, just captures what's currently there in
219 // the active buffer.
221
222 // Save the image as a png. Useful for debugging.
223 void SaveAsPNG(VTK_FILEPATH const char* filename);
224
225 private:
226 bool Valid;
227 int Size[2];
229
230 void Allocate(int dx, int dy, int numcomps);
231 };
232
233protected:
236
238 {
240 int Draw;
242 double Viewport[4];
243 double CameraPosition[3];
244 double CameraFocalPoint[3];
245 double CameraViewUp[3];
246 double CameraWindowCenter[2];
247 double CameraClippingRange[2];
250 double EyeTransformMatrix[16];
251 double ModelTransformMatrix[16];
252
253 // Save/restore the struct to/from a stream.
256
259 };
260
261 // These methods are called on all processes as a consequence of corresponding
262 // events being called on the renderer.
263 virtual void HandleStartRender();
264 virtual void HandleEndRender();
265 virtual void HandleAbortRender() {}
266
267 virtual void MasterStartRender();
268 virtual void SlaveStartRender();
269
270 virtual void MasterEndRender();
271 virtual void SlaveEndRender();
272
275
282
287 virtual void PushImageToScreen();
288
291
297
298private:
300 void operator=(const vtkSynchronizedRenderers&) = delete;
301
302 class vtkObserver;
303 vtkObserver* Observer;
304 friend class vtkObserver;
305
306 bool UseFXAA;
307 vtkOpenGLFXAAFilter* FXAAFilter;
308
309 double LastViewport[4];
310
311 double LastBackground[3];
312 double LastBackgroundAlpha;
313 bool LastTexturedBackground;
314 bool LastGradientBackground;
315 bool FixBackground;
316
317 class vtkInternals;
318 std::unique_ptr<vtkInternals> Internal;
319};
320
321VTK_ABI_NAMESPACE_END
322#endif
Configuration for FXAA implementations.
a simple class to control print indentation
Definition vtkIndent.h:108
Multiprocessing communication superclass.
stream used to pass data across processes using vtkMultiProcessController.
abstract base class for most VTK objects
Definition vtkObject.h:162
Perform FXAA antialiasing on the current framebuffer.
OpenGL renderer.
abstract specification for renderers
Hold a reference to a vtkObjectBase instance.
static vtkSmartPointer< T > New()
Create an instance of a VTK object.
synchronizes renderers across processes.
virtual void SetParallelController(vtkMultiProcessController *)
Set the parallel message communicator.
virtual void SlaveStartRender()
virtual void SetRenderer(vtkRenderer *)
Set the renderer to be synchronized by this instance.
static vtkSynchronizedRenderers * New()
virtual vtkRawImage & CaptureRenderedImage()
Can be used in HandleEndRender(), MasterEndRender() or SlaveEndRender() calls to capture the rendered...
virtual void HandleStartRender()
vtkSynchronizedRenderers * CaptureDelegate
~vtkSynchronizedRenderers() override
virtual void HandleEndRender()
void CollectiveExpandForVisiblePropBounds(double bounds[6])
Computes visible prob bounds.
void EnableSynchronizableActors(bool)
Allows synchronizing collections of actors from local to remote renderer.
virtual vtkRenderer * GetRenderer()
Set the renderer to be synchronized by this instance.
vtkMultiProcessController * ParallelController
virtual void SetCaptureDelegate(vtkSynchronizedRenderers *)
When set, this->CaptureRenderedImage() does not capture image from the screen instead passes the call...
virtual void MasterEndRender()
virtual void SlaveEndRender()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void MasterStartRender()
virtual void PushImageToScreen()
Can be used in HandleEndRender(), MasterEndRender() or SlaveEndRender() calls to paste back the image...
dynamic, self-adjusting array of unsigned char
bool Restore(vtkMultiProcessStream &stream)
void Save(vtkMultiProcessStream &stream)
vtkRawImage can be used to make it easier to deal with images for compositing/communicating over clie...
void SaveAsPNG(VTK_FILEPATH const char *filename)
void Initialize(int dx, int dy, vtkUnsignedCharArray *data)
Create the buffer from an image data.
bool PushToViewport(vtkRenderer *renderer, bool blend=true)
Pushes the image to the viewport.
void Resize(int dx, int dy, int numcomps)
bool PushToFrameBuffer(vtkRenderer *ren, bool blend=true)
This is a raw version of PushToViewport() that assumes that the glViewport() has already been setup e...
#define VTK_FILEPATH