VTK  9.3.1
vtkParallelRenderManager.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2003 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
33 #ifndef vtkParallelRenderManager_h
34 #define vtkParallelRenderManager_h
35 
36 #include "vtkObject.h"
37 #include "vtkRenderingParallelModule.h" // For export macro
38 
39 VTK_ABI_NAMESPACE_BEGIN
40 class vtkDoubleArray;
43 class vtkRenderer;
45 class vtkRenderWindow;
46 class vtkTimerLog;
48 
49 class VTKRENDERINGPARALLEL_EXPORT vtkParallelRenderManager : public vtkObject
50 {
51 public:
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
62  virtual vtkRenderWindow* MakeRenderWindow();
63 
70  virtual vtkRenderer* MakeRenderer();
71 
73 
77  vtkGetObjectMacro(RenderWindow, vtkRenderWindow);
78  virtual void SetRenderWindow(vtkRenderWindow* renWin);
80 
82 
86  vtkGetObjectMacro(Controller, vtkMultiProcessController);
87  virtual void SetController(vtkMultiProcessController* controller);
89 
94  virtual void InitializePieces();
95 
103  virtual void InitializeOffScreen();
104 
111  virtual void StartInteractor();
112 
117  virtual void StartServices();
118 
122  virtual void StopServices();
123 
125 
128  virtual void StartRender();
129  virtual void EndRender();
130  virtual void SatelliteStartRender();
131  virtual void SatelliteEndRender();
132  virtual void RenderRMI();
133  virtual void ResetCamera(vtkRenderer* ren);
134  virtual void ResetCameraClippingRange(vtkRenderer* ren);
135  virtual void ComputeVisiblePropBoundsRMI(int renderId);
137 
138  virtual void InitializeRMIs();
139 
145  virtual void ResetAllCameras();
146 
150  virtual void ComputeVisiblePropBounds(vtkRenderer* ren, double bounds[6]);
151 
153 
159  vtkSetMacro(ParallelRendering, int);
160  vtkGetMacro(ParallelRendering, int);
161  vtkBooleanMacro(ParallelRendering, int);
163 
165 
171  vtkSetMacro(RenderEventPropagation, int);
172  vtkGetMacro(RenderEventPropagation, int);
173  vtkBooleanMacro(RenderEventPropagation, int);
175 
181  static void SetDefaultRenderEventPropagation(bool val)
182  {
184  }
186  {
188  }
189 
191 
196  vtkSetMacro(UseCompositing, int);
197  vtkGetMacro(UseCompositing, int);
198  vtkBooleanMacro(UseCompositing, int);
200 
202 
215  virtual void SetImageReductionFactor(double factor);
216  vtkGetMacro(ImageReductionFactor, double);
218 
219  vtkSetMacro(MaxImageReductionFactor, double);
220  vtkGetMacro(MaxImageReductionFactor, double);
221 
228  virtual void SetImageReductionFactorForUpdateRate(double DesiredUpdateRate);
229 
231 
236  vtkSetMacro(AutoImageReductionFactor, int);
237  vtkGetMacro(AutoImageReductionFactor, int);
238  vtkBooleanMacro(AutoImageReductionFactor, int);
240 
242 
245  vtkGetMacro(RenderTime, double);
246  vtkGetMacro(ImageProcessingTime, double);
248 
250 
259  vtkGetMacro(SyncRenderWindowRenderers, int);
260  vtkSetMacro(SyncRenderWindowRenderers, int);
261  vtkBooleanMacro(SyncRenderWindowRenderers, int);
262  virtual void AddRenderer(vtkRenderer*);
263  virtual void RemoveRenderer(vtkRenderer*);
264  virtual void RemoveAllRenderers();
266 
268 
277  vtkSetMacro(WriteBackImages, int);
278  vtkGetMacro(WriteBackImages, int);
279  vtkBooleanMacro(WriteBackImages, int);
281 
283 
288  vtkSetMacro(MagnifyImages, int);
289  vtkGetMacro(MagnifyImages, int);
290  vtkBooleanMacro(MagnifyImages, int);
292 
293  enum
294  {
296  LINEAR
297  };
298 
300 
305  virtual void SetMagnifyImageMethod(int method);
306  vtkGetMacro(MagnifyImageMethod, int);
307  void SetMagnifyImageMethodToNearest() { this->SetMagnifyImageMethod(NEAREST); }
308  void SetMagnifyImageMethodToLinear() { this->SetMagnifyImageMethod(LINEAR); }
310 
312 
315  virtual void MagnifyImage(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
316  vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
317  const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
318  static void MagnifyImageNearest(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
319  vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
320  const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
321  static void MagnifyImageLinear(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
322  vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
323  const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
325 
327 
334  virtual void GetPixelData(vtkUnsignedCharArray* data);
335  virtual void GetPixelData(int x1, int y1, int x2, int y2, vtkUnsignedCharArray* data);
337 
339 
346  virtual void GetReducedPixelData(vtkUnsignedCharArray* data);
347  virtual void GetReducedPixelData(int x1, int y1, int x2, int y2, vtkUnsignedCharArray* data);
349 
351 
354  vtkGetVector2Macro(FullImageSize, int);
357 
360  vtkGetVector2Macro(ReducedImageSize, int);
362 
367  void TileWindows(int xsize, int ysize, int nColumns);
368 
370 
374  vtkSetMacro(UseRGBA, int);
375  vtkGetMacro(UseRGBA, int);
377 
379 
383  vtkSetMacro(ForceRenderWindowSize, int);
384  vtkGetMacro(ForceRenderWindowSize, int);
386 
388 
392  vtkSetVector2Macro(ForcedRenderWindowSize, int);
393  vtkGetVector2Macro(ForcedRenderWindowSize, int);
395 
396  enum Tags
397  {
398  RENDER_RMI_TAG = 34532,
399  COMPUTE_VISIBLE_PROP_BOUNDS_RMI_TAG = 54636,
400  WIN_INFO_TAG = 87834,
401  REN_INFO_TAG = 87836,
402  LIGHT_INFO_TAG = 87838,
403  REN_ID_TAG = 58794,
404  BOUNDS_TAG = 23543
405  };
406 
407  virtual void CheckForAbortRender() {}
408  virtual int CheckForAbortComposite() { return 0; }
409 
411 
417  vtkSetMacro(UseBackBuffer, int);
418  vtkGetMacro(UseBackBuffer, int);
419  vtkBooleanMacro(UseBackBuffer, int);
421 
423 
428  vtkSetMacro(SynchronizeTileProperties, int);
429  vtkGetMacro(SynchronizeTileProperties, int);
430  vtkBooleanMacro(SynchronizeTileProperties, int);
432 
434 
439  virtual void GenericStartRenderCallback();
440  virtual void GenericEndRenderCallback();
442 
443 protected:
445  ~vtkParallelRenderManager() override;
446 
448 
451  void AddRenderWindowEventHandlers();
452  void RemoveRenderWindowEventHandlers();
454 
458 
459  virtual vtkRendererCollection* GetRenderers();
460 
462  int ForcedRenderWindowSize[2];
463 
473 
476 
477  unsigned long StartRenderTag;
478  unsigned long EndRenderTag;
479  unsigned long ResetCameraTag;
481  unsigned long AbortRenderCheckTag;
482 
486 
490 
491  int UseRGBA;
493  int FullImageSize[2];
494  int ReducedImageSize[2];
495 
498 
502 
504 
505  int Lock;
510 
512 
513  double RenderTime;
515 
521 
528  virtual void SendWindowInformation() {}
529  virtual void ReceiveWindowInformation() {}
532 
542  virtual bool ProcessWindowInformation(vtkMultiProcessStream&) { return true; }
545 
547 
551  virtual void PreRenderProcessing() = 0;
552  virtual void PostRenderProcessing() = 0;
554 
559  virtual void SetRenderWindowSize();
560 
566  virtual void LocalComputeVisiblePropBounds(vtkRenderer* ren, double bounds[6]);
567 
571  virtual void MagnifyReducedImage();
572 
576  virtual void WriteFullImage();
577 
581  virtual void ReadReducedImage();
582 
587  virtual int LastRenderInFrontBuffer();
588 
592  virtual int ChooseBuffer();
593 
597  virtual void SetRenderWindowPixelData(vtkUnsignedCharArray* pixels, const int pixelDimensions[2]);
598 
605  virtual int ImageReduceRenderer(vtkRenderer*) { return 1; }
606 
608  {
609  int FullSize[2];
610  int ReducedSize[2];
613  int TileScale[2];
616  double TileViewport[4];
617 
618  // Initialize members
619  RenderWindowInfo() = default;
620 
621  // Save/restore the struct to/from a stream.
622  void Save(vtkMultiProcessStream& stream);
623  bool Restore(vtkMultiProcessStream& stream);
624  };
625 
627  {
628  int Draw = 0;
629  int NumberOfLights = 0;
630  double Viewport[4] = { 0., 0., 0., 0. };
631  double CameraPosition[3] = { 0., 0., 0. };
632  double CameraFocalPoint[3] = { 0., 0., 0. };
633  double CameraViewUp[3] = { 0., 0., 0. };
634  double WindowCenter[2] = { 0., 0. };
635  double CameraClippingRange[2] = { 0., 0. };
636  double CameraViewAngle = 0.;
637  double Background[3] = { 0., 0., 0. };
638  double Background2[3] = { 0., 0., 0. };
639  bool GradientBackground = false;
640 
641  double ParallelScale = 0.;
642 
643  // Initialize members
644  RendererInfo() = default;
645 
646  // Save/restore the struct to/from a stream.
647  void Save(vtkMultiProcessStream& stream);
648  bool Restore(vtkMultiProcessStream& stream);
649  };
650 
651  struct LightInfo
652  {
653  double Position[3];
654  double FocalPoint[3];
655  double Type;
656 
657  // Initialize members
658  LightInfo() = default;
659 
660  // Save/restore the struct to/from a stream.
661  void Save(vtkMultiProcessStream& stream);
662  bool Restore(vtkMultiProcessStream& stream);
663  };
664 
666  unsigned long RenderRMIId;
667  unsigned long BoundsRMIId;
669 
671 
672 private:
674  void operator=(const vtkParallelRenderManager&) = delete;
675 };
676 
677 VTK_ABI_NAMESPACE_END
678 #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:51
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.
double AverageTimePerPixel
Used by SetImageReductionFactorForUpdateRate to smooth transitions transitions between image reductio...
abstract specification for renderers
Definition: vtkRenderer.h:61
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:84
an ordered 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:28
virtual void ReceiveRendererInformation(vtkRenderer *)
dynamic, self-adjusting array of unsigned char
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.
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.