VTK  9.2.5
vtkSynchronizedRenderers.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSynchronizedRenderers.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 =========================================================================*/
33 #ifndef vtkSynchronizedRenderers_h
34 #define vtkSynchronizedRenderers_h
35 
36 #include "vtkObject.h"
37 #include "vtkRenderingParallelModule.h" // For export macro
38 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
39 #include "vtkUnsignedCharArray.h" // needed for vtkUnsignedCharArray.
40 
41 class vtkFXAAOptions;
42 class vtkRenderer;
46 class vtkOpenGLRenderer;
47 
48 class VTKRENDERINGPARALLEL_EXPORT vtkSynchronizedRenderers : public vtkObject
49 {
50 public:
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
56 
62  virtual void SetRenderer(vtkRenderer*);
65 
67 
72  vtkGetObjectMacro(ParallelController, vtkMultiProcessController);
74 
76 
80  vtkSetMacro(ParallelRendering, bool);
81  vtkGetMacro(ParallelRendering, bool);
82  vtkBooleanMacro(ParallelRendering, bool);
84 
86 
89  vtkSetClampMacro(ImageReductionFactor, int, 1, 50);
90  vtkGetMacro(ImageReductionFactor, int);
92 
94 
99  vtkSetMacro(WriteBackImages, bool);
100  vtkGetMacro(WriteBackImages, bool);
101  vtkBooleanMacro(WriteBackImages, bool);
103 
105 
110  vtkSetMacro(RootProcessId, int);
111  vtkGetMacro(RootProcessId, int);
113 
121  void CollectiveExpandForVisiblePropBounds(double bounds[6]);
122 
124 
129  vtkGetObjectMacro(CaptureDelegate, vtkSynchronizedRenderers);
131 
133 
140  vtkSetMacro(AutomaticEventHandling, bool);
141  vtkGetMacro(AutomaticEventHandling, bool);
142  vtkBooleanMacro(AutomaticEventHandling, bool);
144 
146 
157  vtkSetMacro(FixBackground, bool);
158  vtkGetMacro(FixBackground, bool);
159  vtkBooleanMacro(FixBackground, bool);
161 
162  enum
163  {
164  SYNC_RENDERER_TAG = 15101,
165  RESET_CAMERA_TAG = 15102,
166  COMPUTE_BOUNDS_TAG = 15103
167  };
168 
171  struct VTKRENDERINGPARALLEL_EXPORT vtkRawImage
172  {
173  public:
175  {
176  this->Valid = false;
177  this->Size[0] = this->Size[1] = 0;
179  }
180 
181  void Resize(int dx, int dy, int numcomps)
182  {
183  this->Valid = false;
184  this->Allocate(dx, dy, numcomps);
185  }
186 
190  void Initialize(int dx, int dy, vtkUnsignedCharArray* data);
191 
192  void MarkValid() { this->Valid = true; }
193  void MarkInValid() { this->Valid = false; }
194 
195  bool IsValid() { return this->Valid; }
196  int GetWidth() { return this->Size[0]; }
197  int GetHeight() { return this->Size[1]; }
198  vtkUnsignedCharArray* GetRawPtr() { return this->Data; }
199 
207  bool PushToViewport(vtkRenderer* renderer, bool blend = true);
208 
216  bool PushToFrameBuffer(vtkRenderer* ren, bool blend = true);
217 
218  // Captures the image from the viewport.
219  // This doesn't trigger a render, just captures what's currently there in
220  // the active buffer.
222 
223  // Save the image as a png. Useful for debugging.
224  void SaveAsPNG(VTK_FILEPATH const char* filename);
225 
226  private:
227  bool Valid;
228  int Size[2];
230 
231  void Allocate(int dx, int dy, int numcomps);
232  };
233 
234 protected:
237 
239  {
241  int Draw;
243  double Viewport[4];
244  double CameraPosition[3];
245  double CameraFocalPoint[3];
246  double CameraViewUp[3];
247  double CameraWindowCenter[2];
248  double CameraClippingRange[2];
251  double EyeTransformMatrix[16];
252  double ModelTransformMatrix[16];
253 
254  // Save/restore the struct to/from a stream.
257 
260  };
261 
262  // These methods are called on all processes as a consequence of corresponding
263  // events being called on the renderer.
264  virtual void HandleStartRender();
265  virtual void HandleEndRender();
266  virtual void HandleAbortRender() {}
267 
268  virtual void MasterStartRender();
269  virtual void SlaveStartRender();
270 
271  virtual void MasterEndRender();
272  virtual void SlaveEndRender();
273 
276 
283 
288  virtual void PushImageToScreen();
289 
292 
298 
299 private:
301  void operator=(const vtkSynchronizedRenderers&) = delete;
302 
303  class vtkObserver;
304  vtkObserver* Observer;
305  friend class vtkObserver;
306 
307  bool UseFXAA;
308  vtkOpenGLFXAAFilter* FXAAFilter;
309 
310  double LastViewport[4];
311 
312  double LastBackground[3];
313  double LastBackgroundAlpha;
314  bool LastTexturedBackground;
315  bool LastGradientBackground;
316  bool FixBackground;
317 };
318 
319 #endif
Configuration for FXAA implementations.
a simple class to control print indentation
Definition: vtkIndent.h:119
Multiprocessing communication superclass.
stream used to pass data across processes using vtkMultiProcessController.
abstract base class for most VTK objects
Definition: vtkObject.h:82
Perform FXAA antialiasing on the current framebuffer.
OpenGL renderer.
abstract specification for renderers
Definition: vtkRenderer.h:182
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 void HandleStartRender()
virtual vtkRawImage & CaptureRenderedImage()
Can be used in HandleEndRender(), MasterEndRender() or SlaveEndRender() calls to capture the rendered...
virtual vtkRenderer * GetRenderer()
Set the renderer to be synchronized by this instance.
vtkSynchronizedRenderers * CaptureDelegate
~vtkSynchronizedRenderers() override
virtual void HandleEndRender()
void CollectiveExpandForVisiblePropBounds(double bounds[6])
Computes visible prob bounds.
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
@ data
Definition: vtkX3D.h:321
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