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);
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 
109  vtkSetMacro(UseFXAA, bool)
110  vtkGetMacro(UseFXAA, bool)
111  vtkBooleanMacro(UseFXAA, bool)
113 
115 
118  vtkGetObjectMacro(FXAAOptions, vtkFXAAOptions)
119  virtual void SetFXAAOptions(vtkFXAAOptions*);
121 
123 
128  vtkSetMacro(RootProcessId, int);
129  vtkGetMacro(RootProcessId, int);
131 
139  void CollectiveExpandForVisiblePropBounds(double bounds[6]);
140 
142 
146  virtual void SetCaptureDelegate(vtkSynchronizedRenderers*);
147  vtkGetObjectMacro(CaptureDelegate, vtkSynchronizedRenderers);
149 
151 
158  vtkSetMacro(AutomaticEventHandling, bool);
159  vtkGetMacro(AutomaticEventHandling, bool);
160  vtkBooleanMacro(AutomaticEventHandling, bool);
162 
163  enum
164  {
165  SYNC_RENDERER_TAG = 15101,
166  RESET_CAMERA_TAG = 15102,
167  COMPUTE_BOUNDS_TAG = 15103
168  };
169 
172  struct VTKRENDERINGPARALLEL_EXPORT vtkRawImage
173  {
174  public:
176  {
177  this->Valid = false;
178  this->Size[0] = this->Size[1] = 0;
180  }
181 
182  void Resize(int dx, int dy, int numcomps)
183  {
184  this->Valid = false;
185  this->Allocate(dx, dy, numcomps);
186  }
187 
191  void Initialize(int dx, int dy, vtkUnsignedCharArray* data);
192 
193  void MarkValid() { this->Valid = true; }
194  void MarkInValid() { this->Valid = false; }
195 
196  bool IsValid() { return this->Valid; }
197  int GetWidth() { return this->Size[0];}
198  int GetHeight() { return this->Size[1];}
200  { return this->Data; }
201 
202  // Pushes the image to the viewport.
203  bool PushToViewport(vtkRenderer*);
204 
205  // This is a raw version of PushToViewport() that assumes that the
206  // glViewport() has already been setup externally.
207  // the argument is optional for backwards compat with old OpenGL
208  bool PushToFrameBuffer(vtkRenderer *ren = NULL);
209 
210  // Captures the image from the viewport.
211  // This doesn't trigger a render, just captures what's currently there in
212  // the active buffer.
213  bool Capture(vtkRenderer*);
214 
215  // Save the image as a png. Useful for debugging.
216  void SaveAsPNG(const char* filename);
217 
218  private:
219  bool Valid;
220  int Size[2];
222 
223  void Allocate(int dx, int dy, int numcomps);
224  };
225 
226 protected:
229 
231  {
233  int Draw;
235  double Viewport[4];
236  double CameraPosition[3];
237  double CameraFocalPoint[3];
238  double CameraViewUp[3];
239  double CameraWindowCenter[2];
240  double CameraClippingRange[2];
243  double EyeTransformMatrix[16];
244  double ModelTransformMatrix[16];
245 
246  // Save/restore the struct to/from a stream.
247  void Save(vtkMultiProcessStream& stream);
248  bool Restore(vtkMultiProcessStream& stream);
249 
250  void CopyFrom(vtkRenderer*);
251  void CopyTo(vtkRenderer*);
252  };
253 
254  bool UseFXAA;
257 
258  // These methods are called on all processes as a consequence of corresponding
259  // events being called on the renderer.
260  virtual void HandleStartRender();
261  virtual void HandleEndRender();
262  virtual void HandleAbortRender() {}
263 
264  virtual void MasterStartRender();
265  virtual void SlaveStartRender();
266 
267  virtual void MasterEndRender();
268  virtual void SlaveEndRender();
269 
272 
280  virtual vtkRawImage& CaptureRenderedImage();
281 
287  virtual void PushImageToScreen();
288 
292 
298 
299 private:
300  vtkSynchronizedRenderers(const vtkSynchronizedRenderers&) VTK_DELETE_FUNCTION;
301  void operator=(const vtkSynchronizedRenderers&) VTK_DELETE_FUNCTION;
302 
303  class vtkObserver;
304  vtkObserver* Observer;
305  friend class vtkObserver;
306 
307  double LastViewport[4];
308 };
309 
310 #endif
311 
vtkOpenGLFXAAFilter * FXAAFilter
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.