VTK  9.0.1
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 =========================================================================*/
30 #ifndef vtkSynchronizedRenderers_h
31 #define vtkSynchronizedRenderers_h
32 
33 #include "vtkObject.h"
34 #include "vtkRenderingParallelModule.h" // For export macro
35 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
36 #include "vtkUnsignedCharArray.h" // needed for vtkUnsignedCharArray.
37 
38 class vtkFXAAOptions;
39 class vtkRenderer;
43 class vtkOpenGLRenderer;
44 
45 class VTKRENDERINGPARALLEL_EXPORT vtkSynchronizedRenderers : public vtkObject
46 {
47 public:
50  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
53 
59  virtual void SetRenderer(vtkRenderer*);
62 
64 
69  vtkGetObjectMacro(ParallelController, vtkMultiProcessController);
71 
73 
77  vtkSetMacro(ParallelRendering, bool);
78  vtkGetMacro(ParallelRendering, bool);
79  vtkBooleanMacro(ParallelRendering, bool);
81 
83 
86  vtkSetClampMacro(ImageReductionFactor, int, 1, 50);
87  vtkGetMacro(ImageReductionFactor, int);
89 
91 
96  vtkSetMacro(WriteBackImages, bool);
97  vtkGetMacro(WriteBackImages, bool);
98  vtkBooleanMacro(WriteBackImages, bool);
100 
102 
107  vtkSetMacro(RootProcessId, int);
108  vtkGetMacro(RootProcessId, int);
110 
118  void CollectiveExpandForVisiblePropBounds(double bounds[6]);
119 
121 
126  vtkGetObjectMacro(CaptureDelegate, vtkSynchronizedRenderers);
128 
130 
137  vtkSetMacro(AutomaticEventHandling, bool);
138  vtkGetMacro(AutomaticEventHandling, bool);
139  vtkBooleanMacro(AutomaticEventHandling, bool);
141 
143 
154  vtkSetMacro(FixBackground, bool);
155  vtkGetMacro(FixBackground, bool);
156  vtkBooleanMacro(FixBackground, bool);
158 
159  enum
160  {
161  SYNC_RENDERER_TAG = 15101,
162  RESET_CAMERA_TAG = 15102,
163  COMPUTE_BOUNDS_TAG = 15103
164  };
165 
168  struct VTKRENDERINGPARALLEL_EXPORT vtkRawImage
169  {
170  public:
172  {
173  this->Valid = false;
174  this->Size[0] = this->Size[1] = 0;
176  }
177 
178  void Resize(int dx, int dy, int numcomps)
179  {
180  this->Valid = false;
181  this->Allocate(dx, dy, numcomps);
182  }
183 
187  void Initialize(int dx, int dy, vtkUnsignedCharArray* data);
188 
189  void MarkValid() { this->Valid = true; }
190  void MarkInValid() { this->Valid = false; }
191 
192  bool IsValid() { return this->Valid; }
193  int GetWidth() { return this->Size[0]; }
194  int GetHeight() { return this->Size[1]; }
195  vtkUnsignedCharArray* GetRawPtr() { return this->Data; }
196 
201  bool PushToViewport(vtkRenderer* renderer);
202 
208 
209  // Captures the image from the viewport.
210  // This doesn't trigger a render, just captures what's currently there in
211  // the active buffer.
213 
214  // Save the image as a png. Useful for debugging.
215  void SaveAsPNG(const char* filename);
216 
217  private:
218  bool Valid;
219  int Size[2];
221 
222  void Allocate(int dx, int dy, int numcomps);
223  };
224 
225 protected:
228 
230  {
232  int Draw;
234  double Viewport[4];
235  double CameraPosition[3];
236  double CameraFocalPoint[3];
237  double CameraViewUp[3];
238  double CameraWindowCenter[2];
239  double CameraClippingRange[2];
242  double EyeTransformMatrix[16];
243  double ModelTransformMatrix[16];
244 
245  // Save/restore the struct to/from a stream.
248 
251  };
252 
253  // These methods are called on all processes as a consequence of corresponding
254  // events being called on the renderer.
255  virtual void HandleStartRender();
256  virtual void HandleEndRender();
257  virtual void HandleAbortRender() {}
258 
259  virtual void MasterStartRender();
260  virtual void SlaveStartRender();
261 
262  virtual void MasterEndRender();
263  virtual void SlaveEndRender();
264 
267 
274 
279  virtual void PushImageToScreen();
280 
283 
289 
290 private:
292  void operator=(const vtkSynchronizedRenderers&) = delete;
293 
294  class vtkObserver;
295  vtkObserver* Observer;
296  friend class vtkObserver;
297 
298  bool UseFXAA;
299  vtkOpenGLFXAAFilter* FXAAFilter;
300 
301  double LastViewport[4];
302 
303  double LastBackground[3];
304  double LastBackgroundAlpha;
305  bool LastTexturedBackground;
306  bool LastGradientBackground;
307  bool FixBackground;
308 };
309 
310 #endif
Configuration for FXAA implementations.
a simple class to control print indentation
Definition: vtkIndent.h:34
Multiprocessing communication superclass.
stream used to pass data across processes using vtkMultiProcessController.
abstract base class for most VTK objects
Definition: vtkObject.h:54
Perform FXAA antialiasing on the current framebuffer.
OpenGL renderer.
abstract specification for renderers
Definition: vtkRenderer.h:59
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()
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 Initialize(int dx, int dy, vtkUnsignedCharArray *data)
Create the buffer from an image data.
void SaveAsPNG(const char *filename)
bool PushToFrameBuffer(vtkRenderer *ren)
This is a raw version of PushToViewport() that assumes that the glViewport() has already been setup e...
bool PushToViewport(vtkRenderer *renderer)
Pushes the image to the viewport.
void Resize(int dx, int dy, int numcomps)