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 =========================================================================*/
44 #ifndef vtkParallelRenderManager_h
45 #define vtkParallelRenderManager_h
46 
47 #include "vtkRenderingParallelModule.h" // For export macro
48 #include "vtkObject.h"
49 
50 class vtkDoubleArray;
53 class vtkRenderer;
55 class vtkRenderWindow;
56 class vtkTimerLog;
58 
59 class VTKRENDERINGPARALLEL_EXPORT vtkParallelRenderManager : public vtkObject
60 {
61 public:
63  void PrintSelf(ostream &os, vtkIndent indent) override;
64 
72  virtual vtkRenderWindow *MakeRenderWindow();
73 
80  virtual vtkRenderer *MakeRenderer();
81 
83 
87  vtkGetObjectMacro(RenderWindow, vtkRenderWindow);
88  virtual void SetRenderWindow(vtkRenderWindow *renWin);
90 
92 
96  vtkGetObjectMacro(Controller, vtkMultiProcessController);
97  virtual void SetController(vtkMultiProcessController *controller);
99 
104  virtual void InitializePieces();
105 
113  virtual void InitializeOffScreen();
114 
121  virtual void StartInteractor();
122 
127  virtual void StartServices();
128 
132  virtual void StopServices();
133 
135 
138  virtual void StartRender();
139  virtual void EndRender();
140  virtual void SatelliteStartRender();
141  virtual void SatelliteEndRender();
142  virtual void RenderRMI();
143  virtual void ResetCamera(vtkRenderer *ren);
144  virtual void ResetCameraClippingRange(vtkRenderer *ren);
145  virtual void ComputeVisiblePropBoundsRMI(int renderId);
147 
148  virtual void InitializeRMIs();
149 
155  virtual void ResetAllCameras();
156 
160  virtual void ComputeVisiblePropBounds(vtkRenderer *ren, double bounds[6]);
161 
163 
169  vtkSetMacro(ParallelRendering, int);
170  vtkGetMacro(ParallelRendering, int);
171  vtkBooleanMacro(ParallelRendering, int);
173 
175 
181  vtkSetMacro(RenderEventPropagation, int);
182  vtkGetMacro(RenderEventPropagation, int);
183  vtkBooleanMacro(RenderEventPropagation, int);
185 
191  static void SetDefaultRenderEventPropagation(bool val)
195 
197 
202  vtkSetMacro(UseCompositing, int);
203  vtkGetMacro(UseCompositing, int);
204  vtkBooleanMacro(UseCompositing, int);
206 
208 
221  virtual void SetImageReductionFactor(double factor);
222  vtkGetMacro(ImageReductionFactor, double);
224 
225  vtkSetMacro(MaxImageReductionFactor, double);
226  vtkGetMacro(MaxImageReductionFactor, double);
227 
234  virtual void SetImageReductionFactorForUpdateRate(double DesiredUpdateRate);
235 
237 
242  vtkSetMacro(AutoImageReductionFactor, int);
243  vtkGetMacro(AutoImageReductionFactor, int);
244  vtkBooleanMacro(AutoImageReductionFactor, int);
246 
248 
251  vtkGetMacro(RenderTime, double);
252  vtkGetMacro(ImageProcessingTime, double);
254 
256 
265  vtkGetMacro(SyncRenderWindowRenderers, int);
266  vtkSetMacro(SyncRenderWindowRenderers, int);
267  vtkBooleanMacro(SyncRenderWindowRenderers, int);
268  virtual void AddRenderer(vtkRenderer *);
269  virtual void RemoveRenderer(vtkRenderer *);
270  virtual void RemoveAllRenderers();
272 
274 
283  vtkSetMacro(WriteBackImages, int);
284  vtkGetMacro(WriteBackImages, int);
285  vtkBooleanMacro(WriteBackImages, int);
287 
289 
294  vtkSetMacro(MagnifyImages, int);
295  vtkGetMacro(MagnifyImages, int);
296  vtkBooleanMacro(MagnifyImages, int);
298 
299  enum { NEAREST, LINEAR };
300 
302 
307  virtual void SetMagnifyImageMethod(int method);
308  vtkGetMacro(MagnifyImageMethod, int);
310  this->SetMagnifyImageMethod(NEAREST);
311  }
313  this->SetMagnifyImageMethod(LINEAR);
314  }
316 
318 
321  virtual void MagnifyImage(vtkUnsignedCharArray *fullImage,
322  const int fullImageSize[2],
323  vtkUnsignedCharArray *reducedImage,
324  const int reducedImageSize[2],
325  const int fullImageViewport[4] = nullptr,
326  const int reducedImageViewport[4] = nullptr);
327  static void MagnifyImageNearest(vtkUnsignedCharArray *fullImage,
328  const int fullImageSize[2],
329  vtkUnsignedCharArray *reducedImage,
330  const int reducedImageSize[2],
331  const int fullImageViewport[4] = nullptr,
332  const int reducedImageViewport[4] = nullptr);
333  static void MagnifyImageLinear(vtkUnsignedCharArray *fullImage,
334  const int fullImageSize[2],
335  vtkUnsignedCharArray *reducedImage,
336  const int reducedImageSize[2],
337  const int fullImageViewport[4] = nullptr,
338  const int reducedImageViewport[4] = nullptr);
340 
342 
349  virtual void GetPixelData(vtkUnsignedCharArray *data);
350  virtual void GetPixelData(int x1, int y1, int x2, int y2,
353 
355 
362  virtual void GetReducedPixelData(vtkUnsignedCharArray *data);
363  virtual void GetReducedPixelData(int x1, int y1, int x2, int y2,
366 
368 
371  vtkGetVector2Macro(FullImageSize, int);
373 
374 
377  vtkGetVector2Macro(ReducedImageSize, int);
379 
384  void TileWindows(int xsize, int ysize, int nColumns);
385 
387 
391  vtkSetMacro(UseRGBA, int);
392  vtkGetMacro(UseRGBA, int);
394 
396 
400  vtkSetMacro(ForceRenderWindowSize, int);
401  vtkGetMacro(ForceRenderWindowSize, int);
403 
405 
409  vtkSetVector2Macro(ForcedRenderWindowSize, int);
410  vtkGetVector2Macro(ForcedRenderWindowSize, int);
412 
413  enum Tags {
414  RENDER_RMI_TAG=34532,
415  COMPUTE_VISIBLE_PROP_BOUNDS_RMI_TAG=54636,
416  WIN_INFO_TAG=87834,
417  REN_INFO_TAG=87836,
418  LIGHT_INFO_TAG=87838,
419  REN_ID_TAG=58794,
420  BOUNDS_TAG=23543
421  };
422 
423  virtual void CheckForAbortRender() {}
424  virtual int CheckForAbortComposite() {return 0;}
425 
427 
433  vtkSetMacro(UseBackBuffer, int);
434  vtkGetMacro(UseBackBuffer, int);
435  vtkBooleanMacro(UseBackBuffer, int);
437 
439 
444  vtkSetMacro(SynchronizeTileProperties, int);
445  vtkGetMacro(SynchronizeTileProperties, int);
446  vtkBooleanMacro(SynchronizeTileProperties, int);
448 
450 
455  virtual void GenericStartRenderCallback();
456  virtual void GenericEndRenderCallback();
458 
459 protected:
461  ~vtkParallelRenderManager() override;
462 
463 
465 
468  void AddRenderWindowEventHandlers();
469  void RemoveRenderWindowEventHandlers();
471 
475 
476  virtual vtkRendererCollection *GetRenderers();
477 
479  int ForcedRenderWindowSize[2];
480 
490 
493 
494  unsigned long StartRenderTag;
495  unsigned long EndRenderTag;
496  unsigned long ResetCameraTag;
498  unsigned long AbortRenderCheckTag;
499 
503 
507 
508  int UseRGBA;
510  int FullImageSize[2];
511  int ReducedImageSize[2];
512 
515 
519 
521 
522  int Lock;
527 
529 
530  double RenderTime;
532 
538 
545  virtual void SendWindowInformation() {}
546  virtual void ReceiveWindowInformation() {}
549 
560  { return true; }
564  vtkMultiProcessStream&) { return true; }
565 
567 
571  virtual void PreRenderProcessing() = 0;
572  virtual void PostRenderProcessing() = 0;
574 
579  virtual void SetRenderWindowSize();
580 
586  virtual void LocalComputeVisiblePropBounds(vtkRenderer *ren, double bounds[6]);
587 
591  virtual void MagnifyReducedImage();
592 
596  virtual void WriteFullImage();
597 
601  virtual void ReadReducedImage();
602 
607  virtual int LastRenderInFrontBuffer();
608 
612  virtual int ChooseBuffer();
613 
617  virtual void SetRenderWindowPixelData(vtkUnsignedCharArray *pixels,
618  const int pixelDimensions[2]);
619 
626  virtual int ImageReduceRenderer(vtkRenderer *) { return 1; }
627 
629  {
630  int FullSize[2];
631  int ReducedSize[2];
634  int TileScale[2];
637  double TileViewport[4];
638 
639  // Initialize members
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  // Initialize members
666 
667  // Save/restore the struct to/from a stream.
668  void Save(vtkMultiProcessStream& stream);
669  bool Restore(vtkMultiProcessStream& stream);
670  };
671 
672  struct LightInfo
673  {
674  double Position[3];
675  double FocalPoint[3];
676  double Type;
677 
678  // Initialize members
680 
681  // Save/restore the struct to/from a stream.
682  void Save(vtkMultiProcessStream& stream);
683  bool Restore(vtkMultiProcessStream& stream);
684  };
685 
687  unsigned long RenderRMIId;
688  unsigned long BoundsRMIId;
690 
692 
693 private:
695  void operator=(const vtkParallelRenderManager &) = delete;
696 
697 };
698 
699 #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: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.
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:57
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:85
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.