VTK  9.6.20260221
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
20
21#ifndef vtkSynchronizedRenderers_h
22#define vtkSynchronizedRenderers_h
23
24#include "vtkIndependentViewerCollection.h" // needed for vtkIndependentViewerCollection
25#include "vtkObject.h"
26#include "vtkRenderingParallelModule.h" // For export macro
27#include "vtkSmartPointer.h" // needed for vtkSmartPointer.
28#include "vtkUnsignedCharArray.h" // needed for vtkUnsignedCharArray.
29
30#include <memory> // for std::unique_ptr
31
32VTK_ABI_NAMESPACE_BEGIN
33class vtkFXAAOptions;
34class vtkRenderer;
39
40class VTKRENDERINGPARALLEL_EXPORT vtkSynchronizedRenderers : public vtkObject
41{
42public:
45 void PrintSelf(ostream& os, vtkIndent indent) override;
46
48
54 virtual void SetRenderer(vtkRenderer*);
57
59
67
69
76
78
82 vtkSetMacro(ParallelRendering, bool);
83 vtkGetMacro(ParallelRendering, bool);
84 vtkBooleanMacro(ParallelRendering, bool);
86
88
91 vtkSetClampMacro(ImageReductionFactor, int, 1, 50);
92 vtkGetMacro(ImageReductionFactor, int);
94
96
101 vtkSetMacro(WriteBackImages, bool);
102 vtkGetMacro(WriteBackImages, bool);
103 vtkBooleanMacro(WriteBackImages, bool);
105
107
112 vtkSetMacro(RootProcessId, int);
113 vtkGetMacro(RootProcessId, int);
115
124
126
133
135
141
143
150 vtkSetMacro(AutomaticEventHandling, bool);
151 vtkGetMacro(AutomaticEventHandling, bool);
152 vtkBooleanMacro(AutomaticEventHandling, bool);
154
156
167 vtkSetMacro(FixBackground, bool);
168 vtkGetMacro(FixBackground, bool);
169 vtkBooleanMacro(FixBackground, bool);
171
172 enum
173 {
177 };
178
181 struct VTKRENDERINGPARALLEL_EXPORT vtkRawImage
182 {
183 public:
185 {
186 this->Valid = false;
187 this->Size[0] = this->Size[1] = 0;
189 }
190
191 void Resize(int dx, int dy, int numcomps)
192 {
193 this->Valid = false;
194 this->Allocate(dx, dy, numcomps);
195 }
196
200 void Initialize(int dx, int dy, vtkUnsignedCharArray* data);
201
202 void MarkValid() { this->Valid = true; }
203 void MarkInValid() { this->Valid = false; }
204
205 bool IsValid() { return this->Valid; }
206 int GetWidth() { return this->Size[0]; }
207 int GetHeight() { return this->Size[1]; }
208 vtkUnsignedCharArray* GetRawPtr() { return this->Data; }
209
217 bool PushToViewport(vtkRenderer* renderer, bool blend = true);
218
226 bool PushToFrameBuffer(vtkRenderer* ren, bool blend = true);
227
228 // Captures the image from the viewport.
229 // This doesn't trigger a render, just captures what's currently there in
230 // the active buffer.
232
233 // Save the image as a png. Useful for debugging.
234 void SaveAsPNG(VTK_FILEPATH const char* filename);
235
236 private:
237 bool Valid;
238 int Size[2];
240
241 void Allocate(int dx, int dy, int numcomps);
242 };
243
244protected:
247
249 {
251 int Draw;
253 double Viewport[4];
254 double CameraPosition[3];
256 double CameraViewUp[3];
264
265 // Save/restore the struct to/from a stream.
268
271 };
272
273 // These methods are called on all processes as a consequence of corresponding
274 // events being called on the renderer.
275 virtual void HandleStartRender();
276 virtual void HandleEndRender();
277 virtual void HandleAbortRender() {}
278
279 virtual void MasterStartRender();
280 virtual void SlaveStartRender();
281
282 virtual void MasterEndRender();
283 virtual void SlaveEndRender();
284
288
295
300 virtual void PushImageToScreen();
301
304
310
311private:
313 void operator=(const vtkSynchronizedRenderers&) = delete;
314
315 class vtkObserver;
316 vtkObserver* Observer;
317 friend class vtkObserver;
318
319 bool UseFXAA;
320 vtkOpenGLFXAAFilter* FXAAFilter;
321
322 double LastViewport[4];
323
324 double LastBackground[3];
325 double LastBackgroundAlpha;
326 bool LastTexturedBackground;
327 bool LastGradientBackground;
328 bool FixBackground;
329
330 class vtkInternals;
331 std::unique_ptr<vtkInternals> Internal;
332};
333
334VTK_ABI_NAMESPACE_END
335#endif
Configuration for FXAA implementations.
a simple class to control print indentation
Definition vtkIndent.h:108
Store data for independent viewers.
Multiprocessing communication superclass.
stream used to pass data across processes using vtkMultiProcessController.
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.
virtual void SetParallelController(vtkMultiProcessController *)
Set the parallel message communicator.
vtkIndependentViewerCollection * IndependentViewers
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 Initialize(int dx, int dy, vtkUnsignedCharArray *data)
Create the buffer from an image data.
void SaveAsPNG(const char *filename)
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