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 =========================================================================*/
49 #ifndef vtkParallelRenderManager_h
50 #define vtkParallelRenderManager_h
51 
52 #include "vtkRenderingParallelModule.h" // For export macro
53 #include "vtkObject.h"
54 
55 class vtkDoubleArray;
58 class vtkRenderer;
60 class vtkRenderWindow;
61 class vtkTimerLog;
63 
64 class VTKRENDERINGPARALLEL_EXPORT vtkParallelRenderManager : public vtkObject
65 {
66 public:
68  virtual void PrintSelf(ostream &os, vtkIndent indent);
69 
75  virtual vtkRenderWindow *MakeRenderWindow();
76 
81  virtual vtkRenderer *MakeRenderer();
82 
84 
86  vtkGetObjectMacro(RenderWindow, vtkRenderWindow);
87  virtual void SetRenderWindow(vtkRenderWindow *renWin);
89 
91 
93  vtkGetObjectMacro(Controller, vtkMultiProcessController);
94  virtual void SetController(vtkMultiProcessController *controller);
96 
99  virtual void InitializePieces();
100 
106  virtual void InitializeOffScreen();
107 
112  virtual void StartInteractor();
113 
116  virtual void StartServices();
117 
119  virtual void StopServices();
120 
122 
123  virtual void StartRender();
124  virtual void EndRender();
125  virtual void SatelliteStartRender();
126  virtual void SatelliteEndRender();
127  virtual void RenderRMI();
128  virtual void ResetCamera(vtkRenderer *ren);
129  virtual void ResetCameraClippingRange(vtkRenderer *ren);
130  virtual void ComputeVisiblePropBoundsRMI(int renderId);
132 
133  virtual void InitializeRMIs();
134 
138  virtual void ResetAllCameras();
139 
141  virtual void ComputeVisiblePropBounds(vtkRenderer *ren, double bounds[6]);
142 
144 
148  vtkSetMacro(ParallelRendering, int);
149  vtkGetMacro(ParallelRendering, int);
150  vtkBooleanMacro(ParallelRendering, int);
152 
154 
158  vtkSetMacro(RenderEventPropagation, int);
159  vtkGetMacro(RenderEventPropagation, int);
160  vtkBooleanMacro(RenderEventPropagation, int);
162 
164 
167  static void SetDefaultRenderEventPropagation(bool val)
172 
174 
177  vtkSetMacro(UseCompositing, int);
178  vtkGetMacro(UseCompositing, int);
179  vtkBooleanMacro(UseCompositing, int);
181 
183 
194  virtual void SetImageReductionFactor(double factor);
195  vtkGetMacro(ImageReductionFactor, double);
197 
198  vtkSetMacro(MaxImageReductionFactor, double);
199  vtkGetMacro(MaxImageReductionFactor, double);
200 
206  virtual void SetImageReductionFactorForUpdateRate(double DesiredUpdateRate);
207 
209 
212  vtkSetMacro(AutoImageReductionFactor, int);
213  vtkGetMacro(AutoImageReductionFactor, int);
214  vtkBooleanMacro(AutoImageReductionFactor, int);
216 
218 
219  vtkGetMacro(RenderTime, double);
220  vtkGetMacro(ImageProcessingTime, double);
222 
224 
232  vtkGetMacro(SyncRenderWindowRenderers, int);
233  vtkSetMacro(SyncRenderWindowRenderers, int);
234  vtkBooleanMacro(SyncRenderWindowRenderers, int);
235  virtual void AddRenderer(vtkRenderer *);
236  virtual void RemoveRenderer(vtkRenderer *);
237  virtual void RemoveAllRenderers();
239 
241 
248  vtkSetMacro(WriteBackImages, int);
249  vtkGetMacro(WriteBackImages, int);
250  vtkBooleanMacro(WriteBackImages, int);
252 
254 
257  vtkSetMacro(MagnifyImages, int);
258  vtkGetMacro(MagnifyImages, int);
259  vtkBooleanMacro(MagnifyImages, int);
261 
262 //BTX
263  enum { NEAREST, LINEAR };
264 //ETX
265 
267 
270  virtual void SetMagnifyImageMethod(int method);
271  vtkGetMacro(MagnifyImageMethod, int);
273  this->SetMagnifyImageMethod(NEAREST);
274  }
276  this->SetMagnifyImageMethod(LINEAR);
277  }
279 
281 
282  virtual void MagnifyImage(vtkUnsignedCharArray *fullImage,
283  const int fullImageSize[2],
284  vtkUnsignedCharArray *reducedImage,
285  const int reducedImageSize[2],
286  const int fullImageViewport[4] = NULL,
287  const int reducedImageViewport[4] = NULL);
288  static void MagnifyImageNearest(vtkUnsignedCharArray *fullImage,
289  const int fullImageSize[2],
290  vtkUnsignedCharArray *reducedImage,
291  const int reducedImageSize[2],
292  const int fullImageViewport[4] = NULL,
293  const int reducedImageViewport[4] = NULL);
294  static void MagnifyImageLinear(vtkUnsignedCharArray *fullImage,
295  const int fullImageSize[2],
296  vtkUnsignedCharArray *reducedImage,
297  const int reducedImageSize[2],
298  const int fullImageViewport[4] = NULL,
299  const int reducedImageViewport[4] = NULL);
301 
303 
308  virtual void GetPixelData(vtkUnsignedCharArray *data);
309  virtual void GetPixelData(int x1, int y1, int x2, int y2,
312 
314 
319  virtual void GetReducedPixelData(vtkUnsignedCharArray *data);
320  virtual void GetReducedPixelData(int x1, int y1, int x2, int y2,
323 
325 
326  vtkGetVector2Macro(FullImageSize, int);
328 
329 
330  vtkGetVector2Macro(ReducedImageSize, int);
332 
335  void TileWindows(int xsize, int ysize, int nColumns);
336 
338 
340  vtkSetMacro(UseRGBA, int);
341  vtkGetMacro(UseRGBA, int);
343 
345 
348  vtkSetMacro(ForceRenderWindowSize, int);
349  vtkGetMacro(ForceRenderWindowSize, int);
351 
353 
355  vtkSetVector2Macro(ForcedRenderWindowSize, int);
356  vtkGetVector2Macro(ForcedRenderWindowSize, int);
358 
359 //BTX
360  enum Tags {
361  RENDER_RMI_TAG=34532,
362  COMPUTE_VISIBLE_PROP_BOUNDS_RMI_TAG=54636,
363  WIN_INFO_TAG=87834,
364  REN_INFO_TAG=87836,
365  LIGHT_INFO_TAG=87838,
366  REN_ID_TAG=58794,
367  BOUNDS_TAG=23543
368  };
369 
370  virtual void CheckForAbortRender() {}
371  virtual int CheckForAbortComposite() {return 0;}
372 //ETX
373 
375 
379  vtkSetMacro(UseBackBuffer, int);
380  vtkGetMacro(UseBackBuffer, int);
381  vtkBooleanMacro(UseBackBuffer, int);
383 
385 
389  vtkSetMacro(SynchronizeTileProperties, int);
390  vtkGetMacro(SynchronizeTileProperties, int);
391  vtkBooleanMacro(SynchronizeTileProperties, int);
393 
395 
397  virtual void GenericStartRenderCallback();
398  virtual void GenericEndRenderCallback();
400 
401 //BTX
402 protected:
405 
406 
408 
409  void AddRenderWindowEventHandlers();
410  void RemoveRenderWindowEventHandlers();
412 
416 
417  virtual vtkRendererCollection *GetRenderers();
418 
420  int ForcedRenderWindowSize[2];
421 
429 
432 
433  unsigned long StartRenderTag;
434  unsigned long EndRenderTag;
435  unsigned long ResetCameraTag;
437  unsigned long AbortRenderCheckTag;
438 
442 
446 
447  int UseRGBA;
449  int FullImageSize[2];
450  int ReducedImageSize[2];
451 
454 
458 
460 
461  int Lock;
466 
468 
469  double RenderTime;
471 
475 
477 
481  virtual void SendWindowInformation() {}
482  virtual void ReceiveWindowInformation() {}
486 
488 
496  { return true; }
500  vtkMultiProcessStream&) { return true; }
502 
504 
506  virtual void PreRenderProcessing() = 0;
507  virtual void PostRenderProcessing() = 0;
509 
512  virtual void SetRenderWindowSize();
513 
517  virtual void LocalComputeVisiblePropBounds(vtkRenderer *ren, double bounds[6]);
518 
520  virtual void MagnifyReducedImage();
521 
523  virtual void WriteFullImage();
524 
526  virtual void ReadReducedImage();
527 
530  virtual int LastRenderInFrontBuffer();
531 
533  virtual int ChooseBuffer();
534 
536 
537  virtual void SetRenderWindowPixelData(vtkUnsignedCharArray *pixels,
538  const int pixelDimensions[2]);
540 
545  virtual int ImageReduceRenderer(vtkRenderer *) { return 1; }
546 
548  {
549  int FullSize[2];
550  int ReducedSize[2];
553  int TileScale[2];
556  double TileViewport[4];
557 
558  // Save/restore the struct to/from a stream.
559  void Save(vtkMultiProcessStream& stream);
560  bool Restore(vtkMultiProcessStream& stream);
561  };
562 
564  {
565  int Draw;
567  double Viewport[4];
568  double CameraPosition[3];
569  double CameraFocalPoint[3];
570  double CameraViewUp[3];
571  double WindowCenter[2];
572  double CameraClippingRange[2];
574  double Background[3];
575  double Background2[3];
577 
579 
580  // Save/restore the struct to/from a stream.
581  void Save(vtkMultiProcessStream& stream);
582  bool Restore(vtkMultiProcessStream& stream);
583  };
584 
585  struct LightInfo
586  {
587  double Position[3];
588  double FocalPoint[3];
589  double Type;
590  // Save/restore the struct to/from a stream.
591  void Save(vtkMultiProcessStream& stream);
592  bool Restore(vtkMultiProcessStream& stream);
593  };
594 
596  unsigned long RenderRMIId;
597  unsigned long BoundsRMIId;
599 
601 
602 private:
603  vtkParallelRenderManager(const vtkParallelRenderManager &); //Not implemented
604  void operator=(const vtkParallelRenderManager &); //Not implemented
605 //ETX
606 };
607 
608 #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:61
stream used to pass data across processes using vtkMultiProcessController.
vtkUnsignedCharArray * ReducedImage
An object to control parallel rendering.
virtual void SetRenderWindow(vtkRenderWindow *renwin)
abstract specification for renderers
Definition: vtkRenderer.h:63
virtual void SendRendererInformation(vtkRenderer *)
static void SetDefaultRenderEventPropagation(bool val)
dynamic, self-adjusting array of double
Timer support and logging.
Definition: vtkTimerLog.h:81
a list of renderers
virtual void CollectWindowInformation(vtkMultiProcessStream &)
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void ReceiveRendererInformation(vtkRenderer *)
dynamic, self-adjusting array of unsigned char
vtkWeakPointer< vtkRenderWindow > RenderWindow
create a window for renderers to draw into
vtkRendererCollection * Renderers
virtual void CollectRendererInformation(vtkRenderer *, vtkMultiProcessStream &)
virtual int ImageReduceRenderer(vtkRenderer *)
Multiprocessing communication superclass.