VTK
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 "vtkRenderingParallelModule.h" // For export macro
37 #include "vtkObject.h"
38 #include "vtkUnsignedCharArray.h" // needed for vtkUnsignedCharArray.
39 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
40 
41 class vtkFXAAOptions;
42 class vtkRenderer;
46 class vtkOpenGLRenderer;
47 
48 class VTKRENDERINGPARALLEL_EXPORT vtkSynchronizedRenderers : public vtkObject
49 {
50 public:
51  static vtkSynchronizedRenderers* New();
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
56 
62  virtual void SetRenderer(vtkRenderer*);
63  virtual vtkRenderer* GetRenderer();
65 
67 
71  virtual void SetParallelController(vtkMultiProcessController*);
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  // @deprecated in VTK 8.1. FXAA state and options are now directly obtained
106  // from the renderer.
107  VTK_LEGACY(void SetUseFXAA(bool));
108  VTK_LEGACY(bool GetUseFXAA());
109  VTK_LEGACY(void UseFXAAOn());
110  VTK_LEGACY(void UseFXAAOff());
111  VTK_LEGACY(vtkFXAAOptions* GetFXAAOptions());
112  VTK_LEGACY(void SetFXAAOptions(vtkFXAAOptions*));
114 
116 
121  vtkSetMacro(RootProcessId, int);
122  vtkGetMacro(RootProcessId, int);
124 
132  void CollectiveExpandForVisiblePropBounds(double bounds[6]);
133 
135 
139  virtual void SetCaptureDelegate(vtkSynchronizedRenderers*);
140  vtkGetObjectMacro(CaptureDelegate, vtkSynchronizedRenderers);
142 
144 
151  vtkSetMacro(AutomaticEventHandling, bool);
152  vtkGetMacro(AutomaticEventHandling, bool);
153  vtkBooleanMacro(AutomaticEventHandling, bool);
155 
156  enum
157  {
158  SYNC_RENDERER_TAG = 15101,
159  RESET_CAMERA_TAG = 15102,
160  COMPUTE_BOUNDS_TAG = 15103
161  };
162 
165  struct VTKRENDERINGPARALLEL_EXPORT vtkRawImage
166  {
167  public:
169  {
170  this->Valid = false;
171  this->Size[0] = this->Size[1] = 0;
173  }
174 
175  void Resize(int dx, int dy, int numcomps)
176  {
177  this->Valid = false;
178  this->Allocate(dx, dy, numcomps);
179  }
180 
184  void Initialize(int dx, int dy, vtkUnsignedCharArray* data);
185 
186  void MarkValid() { this->Valid = true; }
187  void MarkInValid() { this->Valid = false; }
188 
189  bool IsValid() { return this->Valid; }
190  int GetWidth() { return this->Size[0];}
191  int GetHeight() { return this->Size[1];}
193  { return this->Data; }
194 
195  // Pushes the image to the viewport.
196  bool PushToViewport(vtkRenderer*);
197 
198  // This is a raw version of PushToViewport() that assumes that the
199  // glViewport() has already been setup externally.
200  // the argument is optional for backwards compat with old OpenGL
201  bool PushToFrameBuffer(vtkRenderer *ren = nullptr);
202 
203  // Captures the image from the viewport.
204  // This doesn't trigger a render, just captures what's currently there in
205  // the active buffer.
206  bool Capture(vtkRenderer*);
207 
208  // Save the image as a png. Useful for debugging.
209  void SaveAsPNG(const char* filename);
210 
211  private:
212  bool Valid;
213  int Size[2];
215 
216  void Allocate(int dx, int dy, int numcomps);
217  };
218 
219 protected:
221  ~vtkSynchronizedRenderers() override;
222 
224  {
226  int Draw;
228  double Viewport[4];
229  double CameraPosition[3];
230  double CameraFocalPoint[3];
231  double CameraViewUp[3];
232  double CameraWindowCenter[2];
233  double CameraClippingRange[2];
236  double EyeTransformMatrix[16];
237  double ModelTransformMatrix[16];
238 
239  // Save/restore the struct to/from a stream.
240  void Save(vtkMultiProcessStream& stream);
241  bool Restore(vtkMultiProcessStream& stream);
242 
243  void CopyFrom(vtkRenderer*);
244  void CopyTo(vtkRenderer*);
245  };
246 
247  // These methods are called on all processes as a consequence of corresponding
248  // events being called on the renderer.
249  virtual void HandleStartRender();
250  virtual void HandleEndRender();
251  virtual void HandleAbortRender() {}
252 
253  virtual void MasterStartRender();
254  virtual void SlaveStartRender();
255 
256  virtual void MasterEndRender();
257  virtual void SlaveEndRender();
258 
261 
269  virtual vtkRawImage& CaptureRenderedImage();
270 
276  virtual void PushImageToScreen();
277 
281 
287 
288 private:
290  void operator=(const vtkSynchronizedRenderers&) = delete;
291 
292  class vtkObserver;
293  vtkObserver* Observer;
294  friend class vtkObserver;
295 
296  bool UseFXAA;
297  vtkOpenGLFXAAFilter* FXAAFilter;
298 
299  double LastViewport[4];
300 };
301 
302 #endif
303 
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
stream used to pass data across processes using vtkMultiProcessController.
vtkSynchronizedRenderers * CaptureDelegate
abstract specification for renderers
Definition: vtkRenderer.h:63
static vtkSmartPointer< T > New()
Create an instance of a VTK object.
vtkRawImage can be used to make it easier to deal with images for compositing/communicating over clie...
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkMultiProcessController * ParallelController
dynamic, self-adjusting array of unsigned char
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void Resize(int dx, int dy, int numcomps)
synchronizes renderers across processes.
Perform FXAA antialiasing on the current framebuffer.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
OpenGL renderer.
Configuration for FXAA implementations.
Multiprocessing communication superclass.