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 =========================================================================*/
30 #ifndef vtkSynchronizedRenderers_h
31 #define vtkSynchronizedRenderers_h
32 
33 #include "vtkRenderingParallelModule.h" // For export macro
34 #include "vtkObject.h"
35 #include "vtkUnsignedCharArray.h" // needed for vtkUnsignedCharArray.
36 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
37 
38 class vtkFXAAOptions;
39 class vtkRenderer;
43 class vtkOpenGLRenderer;
44 
45 class VTKRENDERINGPARALLEL_EXPORT vtkSynchronizedRenderers : public vtkObject
46 {
47 public:
48  static vtkSynchronizedRenderers* New();
50  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
51 
53 
59  virtual void SetRenderer(vtkRenderer*);
60  virtual vtkRenderer* GetRenderer();
62 
64 
68  virtual void SetParallelController(vtkMultiProcessController*);
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 
106  vtkSetMacro(UseFXAA, bool)
107  vtkGetMacro(UseFXAA, bool)
108  vtkBooleanMacro(UseFXAA, bool)
110 
112 
115  vtkGetObjectMacro(FXAAOptions, vtkFXAAOptions)
116  virtual void SetFXAAOptions(vtkFXAAOptions*);
118 
120 
125  vtkSetMacro(RootProcessId, int);
126  vtkGetMacro(RootProcessId, int);
128 
136  void CollectiveExpandForVisiblePropBounds(double bounds[6]);
137 
139 
143  virtual void SetCaptureDelegate(vtkSynchronizedRenderers*);
144  vtkGetObjectMacro(CaptureDelegate, vtkSynchronizedRenderers);
146 
148 
155  vtkSetMacro(AutomaticEventHandling, bool);
156  vtkGetMacro(AutomaticEventHandling, bool);
157  vtkBooleanMacro(AutomaticEventHandling, bool);
159 
160  enum
161  {
162  SYNC_RENDERER_TAG = 15101,
163  RESET_CAMERA_TAG = 15102,
164  COMPUTE_BOUNDS_TAG = 15103
165  };
166 
169  struct VTKRENDERINGPARALLEL_EXPORT vtkRawImage
170  {
171  public:
173  {
174  this->Valid = false;
175  this->Size[0] = this->Size[1] = 0;
177  }
178 
179  void Resize(int dx, int dy, int numcomps)
180  {
181  this->Valid = false;
182  this->Allocate(dx, dy, numcomps);
183  }
184 
188  void Initialize(int dx, int dy, vtkUnsignedCharArray* data);
189 
190  void MarkValid() { this->Valid = true; }
191  void MarkInValid() { this->Valid = false; }
192 
193  bool IsValid() { return this->Valid; }
194  int GetWidth() { return this->Size[0];}
195  int GetHeight() { return this->Size[1];}
197  { return this->Data; }
198 
199  // Pushes the image to the viewport.
200  bool PushToViewport(vtkRenderer*);
201 
202  // This is a raw version of PushToViewport() that assumes that the
203  // glViewport() has already been setup externally.
204  // the argument is optional for backwards compat with old OpenGL
205  bool PushToFrameBuffer(vtkRenderer *ren = NULL);
206 
207  // Captures the image from the viewport.
208  // This doesn't trigger a render, just captures what's currently there in
209  // the active buffer.
210  bool Capture(vtkRenderer*);
211 
212  // Save the image as a png. Useful for debugging.
213  void SaveAsPNG(const char* filename);
214 
215  private:
216  bool Valid;
217  int Size[2];
219 
220  void Allocate(int dx, int dy, int numcomps);
221  };
222 
223 protected:
226 
228  {
230  int Draw;
232  double Viewport[4];
233  double CameraPosition[3];
234  double CameraFocalPoint[3];
235  double CameraViewUp[3];
236  double CameraWindowCenter[2];
237  double CameraClippingRange[2];
240  double EyeTransformMatrix[16];
241  double ModelTransformMatrix[16];
242 
243  // Save/restore the struct to/from a stream.
244  void Save(vtkMultiProcessStream& stream);
245  bool Restore(vtkMultiProcessStream& stream);
246 
247  void CopyFrom(vtkRenderer*);
248  void CopyTo(vtkRenderer*);
249  };
250 
251  bool UseFXAA;
254 
255  // These methods are called on all processes as a consequence of corresponding
256  // events being called on the renderer.
257  virtual void HandleStartRender();
258  virtual void HandleEndRender();
259  virtual void HandleAbortRender() {}
260 
261  virtual void MasterStartRender();
262  virtual void SlaveStartRender();
263 
264  virtual void MasterEndRender();
265  virtual void SlaveEndRender();
266 
269 
277  virtual vtkRawImage& CaptureRenderedImage();
278 
284  virtual void PushImageToScreen();
285 
289 
295 
296 private:
297  vtkSynchronizedRenderers(const vtkSynchronizedRenderers&) VTK_DELETE_FUNCTION;
298  void operator=(const vtkSynchronizedRenderers&) VTK_DELETE_FUNCTION;
299 
300  class vtkObserver;
301  vtkObserver* Observer;
302  friend class vtkObserver;
303 
304  double LastViewport[4];
305 };
306 
307 #endif
308 
vtkOpenGLFXAAFilter * FXAAFilter
abstract base class for most VTK objects
Definition: vtkObject.h:53
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:57
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:33
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.