VTK  9.0.1
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 "vtkObject.h"
51 #include "vtkRenderingParallelModule.h" // For export macro
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  void PrintSelf(ostream& os, vtkIndent indent) override;
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)
195  {
197  }
199  {
201  }
202 
204 
209  vtkSetMacro(UseCompositing, int);
210  vtkGetMacro(UseCompositing, int);
211  vtkBooleanMacro(UseCompositing, int);
213 
215 
228  virtual void SetImageReductionFactor(double factor);
229  vtkGetMacro(ImageReductionFactor, double);
231 
232  vtkSetMacro(MaxImageReductionFactor, double);
233  vtkGetMacro(MaxImageReductionFactor, double);
234 
241  virtual void SetImageReductionFactorForUpdateRate(double DesiredUpdateRate);
242 
244 
249  vtkSetMacro(AutoImageReductionFactor, int);
250  vtkGetMacro(AutoImageReductionFactor, int);
251  vtkBooleanMacro(AutoImageReductionFactor, int);
253 
255 
258  vtkGetMacro(RenderTime, double);
259  vtkGetMacro(ImageProcessingTime, double);
261 
263 
272  vtkGetMacro(SyncRenderWindowRenderers, int);
273  vtkSetMacro(SyncRenderWindowRenderers, int);
274  vtkBooleanMacro(SyncRenderWindowRenderers, int);
275  virtual void AddRenderer(vtkRenderer*);
276  virtual void RemoveRenderer(vtkRenderer*);
277  virtual void RemoveAllRenderers();
279 
281 
290  vtkSetMacro(WriteBackImages, int);
291  vtkGetMacro(WriteBackImages, int);
292  vtkBooleanMacro(WriteBackImages, int);
294 
296 
301  vtkSetMacro(MagnifyImages, int);
302  vtkGetMacro(MagnifyImages, int);
303  vtkBooleanMacro(MagnifyImages, int);
305 
306  enum
307  {
309  LINEAR
310  };
311 
313 
318  virtual void SetMagnifyImageMethod(int method);
319  vtkGetMacro(MagnifyImageMethod, int);
320  void SetMagnifyImageMethodToNearest() { this->SetMagnifyImageMethod(NEAREST); }
321  void SetMagnifyImageMethodToLinear() { this->SetMagnifyImageMethod(LINEAR); }
323 
325 
328  virtual void MagnifyImage(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
329  vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
330  const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
331  static void MagnifyImageNearest(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
332  vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
333  const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
334  static void MagnifyImageLinear(vtkUnsignedCharArray* fullImage, const int fullImageSize[2],
335  vtkUnsignedCharArray* reducedImage, const int reducedImageSize[2],
336  const int fullImageViewport[4] = nullptr, const int reducedImageViewport[4] = nullptr);
338 
340 
347  virtual void GetPixelData(vtkUnsignedCharArray* data);
348  virtual void GetPixelData(int x1, int y1, int x2, int y2, vtkUnsignedCharArray* data);
350 
352 
359  virtual void GetReducedPixelData(vtkUnsignedCharArray* data);
360  virtual void GetReducedPixelData(int x1, int y1, int x2, int y2, vtkUnsignedCharArray* data);
362 
364 
367  vtkGetVector2Macro(FullImageSize, int);
369 
370 
373  vtkGetVector2Macro(ReducedImageSize, int);
375 
380  void TileWindows(int xsize, int ysize, int nColumns);
381 
383 
387  vtkSetMacro(UseRGBA, int);
388  vtkGetMacro(UseRGBA, int);
390 
392 
396  vtkSetMacro(ForceRenderWindowSize, int);
397  vtkGetMacro(ForceRenderWindowSize, int);
399 
401 
405  vtkSetVector2Macro(ForcedRenderWindowSize, int);
406  vtkGetVector2Macro(ForcedRenderWindowSize, int);
408 
409  enum Tags
410  {
411  RENDER_RMI_TAG = 34532,
412  COMPUTE_VISIBLE_PROP_BOUNDS_RMI_TAG = 54636,
413  WIN_INFO_TAG = 87834,
414  REN_INFO_TAG = 87836,
415  LIGHT_INFO_TAG = 87838,
416  REN_ID_TAG = 58794,
417  BOUNDS_TAG = 23543
418  };
419 
420  virtual void CheckForAbortRender() {}
421  virtual int CheckForAbortComposite() { return 0; }
422 
424 
430  vtkSetMacro(UseBackBuffer, int);
431  vtkGetMacro(UseBackBuffer, int);
432  vtkBooleanMacro(UseBackBuffer, int);
434 
436 
441  vtkSetMacro(SynchronizeTileProperties, int);
442  vtkGetMacro(SynchronizeTileProperties, int);
443  vtkBooleanMacro(SynchronizeTileProperties, int);
445 
447 
452  virtual void GenericStartRenderCallback();
453  virtual void GenericEndRenderCallback();
455 
456 protected:
458  ~vtkParallelRenderManager() override;
459 
461 
464  void AddRenderWindowEventHandlers();
465  void RemoveRenderWindowEventHandlers();
467 
471 
472  virtual vtkRendererCollection* GetRenderers();
473 
475  int ForcedRenderWindowSize[2];
476 
486 
489 
490  unsigned long StartRenderTag;
491  unsigned long EndRenderTag;
492  unsigned long ResetCameraTag;
494  unsigned long AbortRenderCheckTag;
495 
499 
503 
504  int UseRGBA;
506  int FullImageSize[2];
507  int ReducedImageSize[2];
508 
511 
515 
517 
518  int Lock;
523 
525 
526  double RenderTime;
528 
534 
541  virtual void SendWindowInformation() {}
542  virtual void ReceiveWindowInformation() {}
545 
555  virtual bool ProcessWindowInformation(vtkMultiProcessStream&) { return true; }
558 
560 
564  virtual void PreRenderProcessing() = 0;
565  virtual void PostRenderProcessing() = 0;
567 
572  virtual void SetRenderWindowSize();
573 
579  virtual void LocalComputeVisiblePropBounds(vtkRenderer* ren, double bounds[6]);
580 
584  virtual void MagnifyReducedImage();
585 
589  virtual void WriteFullImage();
590 
594  virtual void ReadReducedImage();
595 
600  virtual int LastRenderInFrontBuffer();
601 
605  virtual int ChooseBuffer();
606 
610  virtual void SetRenderWindowPixelData(vtkUnsignedCharArray* pixels, const int pixelDimensions[2]);
611 
618  virtual int ImageReduceRenderer(vtkRenderer*) { return 1; }
619 
621  {
622  int FullSize[2];
623  int ReducedSize[2];
626  int TileScale[2];
629  double TileViewport[4];
630 
631  // Initialize members
633 
634  // Save/restore the struct to/from a stream.
635  void Save(vtkMultiProcessStream& stream);
636  bool Restore(vtkMultiProcessStream& stream);
637  };
638 
640  {
641  int Draw;
643  double Viewport[4];
644  double CameraPosition[3];
645  double CameraFocalPoint[3];
646  double CameraViewUp[3];
647  double WindowCenter[2];
648  double CameraClippingRange[2];
650  double Background[3];
651  double Background2[3];
653 
655 
656  // Initialize members
658 
659  // Save/restore the struct to/from a stream.
660  void Save(vtkMultiProcessStream& stream);
661  bool Restore(vtkMultiProcessStream& stream);
662  };
663 
664  struct LightInfo
665  {
666  double Position[3];
667  double FocalPoint[3];
668  double Type;
669 
670  // Initialize members
672 
673  // Save/restore the struct to/from a stream.
674  void Save(vtkMultiProcessStream& stream);
675  bool Restore(vtkMultiProcessStream& stream);
676  };
677 
679  unsigned long RenderRMIId;
680  unsigned long BoundsRMIId;
682 
684 
685 private:
687  void operator=(const vtkParallelRenderManager&) = delete;
688 };
689 
690 #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:56
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:90
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:33
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.