VTK
vtkParallelRenderManager.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkParallelRenderManager.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  Copyright 2003 Sandia Corporation. Under the terms of Contract
11  DE-AC04-94AL85000, there is a non-exclusive license for use of this work by
12  or on behalf of the U.S. Government. Redistribution and use in source and
13  binary forms, with or without modification, are permitted provided that this
14  Notice and any statement of authorship are reproduced on all copies.
15 
16  This software is distributed WITHOUT ANY WARRANTY; without even
17  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18  PURPOSE. See the above copyright notice for more information.
19 
20 =========================================================================*/
47 #ifndef vtkParallelRenderManager_h
48 #define vtkParallelRenderManager_h
49 
50 #include "vtkRenderingParallelModule.h" // For export macro
51 #include "vtkObject.h"
52 
53 class vtkDoubleArray;
56 class vtkRenderer;
58 class vtkRenderWindow;
59 class vtkTimerLog;
61 
62 class VTKRENDERINGPARALLEL_EXPORT vtkParallelRenderManager : public vtkObject
63 {
64 public:
66  virtual void PrintSelf(ostream &os, vtkIndent indent);
67 
75  virtual vtkRenderWindow *MakeRenderWindow();
76 
83  virtual vtkRenderer *MakeRenderer();
84 
86 
90  vtkGetObjectMacro(RenderWindow, vtkRenderWindow);
91  virtual void SetRenderWindow(vtkRenderWindow *renWin);
93 
95 
99  vtkGetObjectMacro(Controller, vtkMultiProcessController);
100  virtual void SetController(vtkMultiProcessController *controller);
102 
107  virtual void InitializePieces();
108 
116  virtual void InitializeOffScreen();
117 
124  virtual void StartInteractor();
125 
130  virtual void StartServices();
131 
135  virtual void StopServices();
136 
138 
141  virtual void StartRender();
142  virtual void EndRender();
143  virtual void SatelliteStartRender();
144  virtual void SatelliteEndRender();
145  virtual void RenderRMI();
146  virtual void ResetCamera(vtkRenderer *ren);
147  virtual void ResetCameraClippingRange(vtkRenderer *ren);
148  virtual void ComputeVisiblePropBoundsRMI(int renderId);
150 
151  virtual void InitializeRMIs();
152 
158  virtual void ResetAllCameras();
159 
163  virtual void ComputeVisiblePropBounds(vtkRenderer *ren, double bounds[6]);
164 
166 
172  vtkSetMacro(ParallelRendering, int);
173  vtkGetMacro(ParallelRendering, int);
174  vtkBooleanMacro(ParallelRendering, int);
176 
178 
184  vtkSetMacro(RenderEventPropagation, int);
185  vtkGetMacro(RenderEventPropagation, int);
186  vtkBooleanMacro(RenderEventPropagation, int);
188 
194  static void SetDefaultRenderEventPropagation(bool val)
198 
200 
205  vtkSetMacro(UseCompositing, int);
206  vtkGetMacro(UseCompositing, int);
207  vtkBooleanMacro(UseCompositing, int);
209 
211 
224  virtual void SetImageReductionFactor(double factor);
225  vtkGetMacro(ImageReductionFactor, double);
227 
228  vtkSetMacro(MaxImageReductionFactor, double);
229  vtkGetMacro(MaxImageReductionFactor, double);
230 
237  virtual void SetImageReductionFactorForUpdateRate(double DesiredUpdateRate);
238 
240 
245  vtkSetMacro(AutoImageReductionFactor, int);
246  vtkGetMacro(AutoImageReductionFactor, int);
247  vtkBooleanMacro(AutoImageReductionFactor, int);
249 
251 
254  vtkGetMacro(RenderTime, double);
255  vtkGetMacro(ImageProcessingTime, double);
257 
259 
268  vtkGetMacro(SyncRenderWindowRenderers, int);
269  vtkSetMacro(SyncRenderWindowRenderers, int);
270  vtkBooleanMacro(SyncRenderWindowRenderers, int);
271  virtual void AddRenderer(vtkRenderer *);
272  virtual void RemoveRenderer(vtkRenderer *);
273  virtual void RemoveAllRenderers();
275 
277 
286  vtkSetMacro(WriteBackImages, int);
287  vtkGetMacro(WriteBackImages, int);
288  vtkBooleanMacro(WriteBackImages, int);
290 
292 
297  vtkSetMacro(MagnifyImages, int);
298  vtkGetMacro(MagnifyImages, int);
299  vtkBooleanMacro(MagnifyImages, int);
301 
302  enum { NEAREST, LINEAR };
303 
305 
310  virtual void SetMagnifyImageMethod(int method);
311  vtkGetMacro(MagnifyImageMethod, int);
313  this->SetMagnifyImageMethod(NEAREST);
314  }
316  this->SetMagnifyImageMethod(LINEAR);
317  }
319 
321 
324  virtual void MagnifyImage(vtkUnsignedCharArray *fullImage,
325  const int fullImageSize[2],
326  vtkUnsignedCharArray *reducedImage,
327  const int reducedImageSize[2],
328  const int fullImageViewport[4] = NULL,
329  const int reducedImageViewport[4] = NULL);
330  static void MagnifyImageNearest(vtkUnsignedCharArray *fullImage,
331  const int fullImageSize[2],
332  vtkUnsignedCharArray *reducedImage,
333  const int reducedImageSize[2],
334  const int fullImageViewport[4] = NULL,
335  const int reducedImageViewport[4] = NULL);
336  static void MagnifyImageLinear(vtkUnsignedCharArray *fullImage,
337  const int fullImageSize[2],
338  vtkUnsignedCharArray *reducedImage,
339  const int reducedImageSize[2],
340  const int fullImageViewport[4] = NULL,
341  const int reducedImageViewport[4] = NULL);
343 
345 
352  virtual void GetPixelData(vtkUnsignedCharArray *data);
353  virtual void GetPixelData(int x1, int y1, int x2, int y2,
356 
358 
365  virtual void GetReducedPixelData(vtkUnsignedCharArray *data);
366  virtual void GetReducedPixelData(int x1, int y1, int x2, int y2,
369 
371 
374  vtkGetVector2Macro(FullImageSize, int);
376 
377 
380  vtkGetVector2Macro(ReducedImageSize, int);
382 
387  void TileWindows(int xsize, int ysize, int nColumns);
388 
390 
394  vtkSetMacro(UseRGBA, int);
395  vtkGetMacro(UseRGBA, int);
397 
399 
403  vtkSetMacro(ForceRenderWindowSize, int);
404  vtkGetMacro(ForceRenderWindowSize, int);
406 
408 
412  vtkSetVector2Macro(ForcedRenderWindowSize, int);
413  vtkGetVector2Macro(ForcedRenderWindowSize, int);
415 
416  enum Tags {
417  RENDER_RMI_TAG=34532,
418  COMPUTE_VISIBLE_PROP_BOUNDS_RMI_TAG=54636,
419  WIN_INFO_TAG=87834,
420  REN_INFO_TAG=87836,
421  LIGHT_INFO_TAG=87838,
422  REN_ID_TAG=58794,
423  BOUNDS_TAG=23543
424  };
425 
426  virtual void CheckForAbortRender() {}
427  virtual int CheckForAbortComposite() {return 0;}
428 
430 
436  vtkSetMacro(UseBackBuffer, int);
437  vtkGetMacro(UseBackBuffer, int);
438  vtkBooleanMacro(UseBackBuffer, int);
440 
442 
447  vtkSetMacro(SynchronizeTileProperties, int);
448  vtkGetMacro(SynchronizeTileProperties, int);
449  vtkBooleanMacro(SynchronizeTileProperties, int);
451 
453 
458  virtual void GenericStartRenderCallback();
459  virtual void GenericEndRenderCallback();
461 
462 protected:
465 
466 
468 
471  void AddRenderWindowEventHandlers();
472  void RemoveRenderWindowEventHandlers();
474 
478 
479  virtual vtkRendererCollection *GetRenderers();
480 
482  int ForcedRenderWindowSize[2];
483 
493 
496 
497  unsigned long StartRenderTag;
498  unsigned long EndRenderTag;
499  unsigned long ResetCameraTag;
501  unsigned long AbortRenderCheckTag;
502 
506 
510 
511  int UseRGBA;
513  int FullImageSize[2];
514  int ReducedImageSize[2];
515 
518 
522 
524 
525  int Lock;
530 
532 
533  double RenderTime;
535 
541 
548  virtual void SendWindowInformation() {}
549  virtual void ReceiveWindowInformation() {}
552 
563  { return true; }
567  vtkMultiProcessStream&) { return true; }
568 
570 
574  virtual void PreRenderProcessing() = 0;
575  virtual void PostRenderProcessing() = 0;
577 
582  virtual void SetRenderWindowSize();
583 
589  virtual void LocalComputeVisiblePropBounds(vtkRenderer *ren, double bounds[6]);
590 
594  virtual void MagnifyReducedImage();
595 
599  virtual void WriteFullImage();
600 
604  virtual void ReadReducedImage();
605 
610  virtual int LastRenderInFrontBuffer();
611 
615  virtual int ChooseBuffer();
616 
620  virtual void SetRenderWindowPixelData(vtkUnsignedCharArray *pixels,
621  const int pixelDimensions[2]);
622 
629  virtual int ImageReduceRenderer(vtkRenderer *) { return 1; }
630 
632  {
633  int FullSize[2];
634  int ReducedSize[2];
637  int TileScale[2];
640  double TileViewport[4];
641 
642  // Save/restore the struct to/from a stream.
643  void Save(vtkMultiProcessStream& stream);
644  bool Restore(vtkMultiProcessStream& stream);
645  };
646 
648  {
649  int Draw;
651  double Viewport[4];
652  double CameraPosition[3];
653  double CameraFocalPoint[3];
654  double CameraViewUp[3];
655  double WindowCenter[2];
656  double CameraClippingRange[2];
658  double Background[3];
659  double Background2[3];
661 
663 
664  // Save/restore the struct to/from a stream.
665  void Save(vtkMultiProcessStream& stream);
666  bool Restore(vtkMultiProcessStream& stream);
667  };
668 
669  struct LightInfo
670  {
671  double Position[3];
672  double FocalPoint[3];
673  double Type;
674  // Save/restore the struct to/from a stream.
675  void Save(vtkMultiProcessStream& stream);
676  bool Restore(vtkMultiProcessStream& stream);
677  };
678 
680  unsigned long RenderRMIId;
681  unsigned long BoundsRMIId;
683 
685 
686 private:
687  vtkParallelRenderManager(const vtkParallelRenderManager &) VTK_DELETE_FUNCTION;
688  void operator=(const vtkParallelRenderManager &) VTK_DELETE_FUNCTION;
689 
690 };
691 
692 #endif //vtkParalleRenderManager_h
vtkUnsignedCharArray * FullImage
virtual bool ProcessWindowInformation(vtkMultiProcessStream &)
vtkMultiProcessController * Controller
virtual bool ProcessRendererInformation(vtkRenderer *, vtkMultiProcessStream &)
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.
vtkUnsignedCharArray * ReducedImage
An object to control parallel rendering.
virtual void SetRenderWindow(vtkRenderWindow *renwin)
double AverageTimePerPixel
Used by SetImageReductionFactorForUpdateRate to smooth transitions transitions between image reductio...
abstract specification for renderers
Definition: vtkRenderer.h:63
virtual void SendRendererInformation(vtkRenderer *)
static void SetDefaultRenderEventPropagation(bool val)
Get/Set the default value used for RenderEventPropagation when a new instance of vtkParallelRenderMan...
void SetMagnifyImageMethodToNearest()
Sets the method used to magnify images.
dynamic, self-adjusting array of double
Timer support and logging.
Definition: vtkTimerLog.h:80
a list of renderers
virtual void CollectWindowInformation(vtkMultiProcessStream &)
Subclass should override these methods (instead of SendWindowInformation/ReceiveWindowInformation or ...
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void ReceiveRendererInformation(vtkRenderer *)
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
dynamic, self-adjusting array of unsigned char
vtkWeakPointer< vtkRenderWindow > RenderWindow
create a window for renderers to draw into
virtual void SendWindowInformation()
Used to synchronize rendering information per frame.
int RootProcessId
The "root" node's process id.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void SetMagnifyImageMethodToLinear()
Sets the method used to magnify images.
vtkRendererCollection * Renderers
virtual void CollectRendererInformation(vtkRenderer *, vtkMultiProcessStream &)
virtual int ImageReduceRenderer(vtkRenderer *)
Returns true if the image for the given renderer should be rendered at a reduced size to be magnified...
Multiprocessing communication superclass.