VTK
vtkRenderWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkRenderWindow.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  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
41 #ifndef vtkRenderWindow_h
42 #define vtkRenderWindow_h
43 
44 #include "vtkRenderingCoreModule.h" // For export macro
45 #include "vtkWindow.h"
46 #include "vtkNew.h" // For vtkNew
47 
48 class vtkFloatArray;
50 class vtkProp;
51 class vtkCollection;
52 class vtkRenderTimerLog;
54 class vtkRenderer;
57 
58 // lets define the different types of stereo
59 #define VTK_STEREO_CRYSTAL_EYES 1
60 #define VTK_STEREO_RED_BLUE 2
61 #define VTK_STEREO_INTERLACED 3
62 #define VTK_STEREO_LEFT 4
63 #define VTK_STEREO_RIGHT 5
64 #define VTK_STEREO_DRESDEN 6
65 #define VTK_STEREO_ANAGLYPH 7
66 #define VTK_STEREO_CHECKERBOARD 8
67 #define VTK_STEREO_SPLITVIEWPORT_HORIZONTAL 9
68 #define VTK_STEREO_FAKE 10
69 
70 #define VTK_CURSOR_DEFAULT 0
71 #define VTK_CURSOR_ARROW 1
72 #define VTK_CURSOR_SIZENE 2
73 #define VTK_CURSOR_SIZENW 3
74 #define VTK_CURSOR_SIZESW 4
75 #define VTK_CURSOR_SIZESE 5
76 #define VTK_CURSOR_SIZENS 6
77 #define VTK_CURSOR_SIZEWE 7
78 #define VTK_CURSOR_SIZEALL 8
79 #define VTK_CURSOR_HAND 9
80 #define VTK_CURSOR_CROSSHAIR 10
81 
82 class VTKRENDERINGCORE_EXPORT vtkRenderWindow : public vtkWindow
83 {
84 public:
85  vtkTypeMacro(vtkRenderWindow,vtkWindow);
86  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
87 
93  static vtkRenderWindow *New();
94 
98  virtual void AddRenderer(vtkRenderer *);
99 
103  void RemoveRenderer(vtkRenderer *);
104 
108  int HasRenderer(vtkRenderer *);
109 
113  static const char *GetRenderLibrary();
114 
118  virtual const char *GetRenderingBackend();
119 
123  vtkGetNewMacro(RenderTimer, vtkRenderTimerLog)
124 
125 
128  vtkRendererCollection *GetRenderers() {return this->Renderers;};
129 
137  void CaptureGL2PSSpecialProps(vtkCollection *specialProps);
138 
140 
143  vtkGetMacro(CapturingGL2PSSpecialProps, int);
145 
150  void Render() VTK_OVERRIDE;
151 
155  virtual void Start() = 0;
156 
160  virtual void Finalize() = 0;
161 
166  virtual void Frame() = 0;
167 
172  virtual void WaitForCompletion()=0;
173 
178  virtual void CopyResultFrame();
179 
185  virtual vtkRenderWindowInteractor *MakeRenderWindowInteractor();
186 
188 
194  virtual void HideCursor() = 0;
195  virtual void ShowCursor() = 0;
196  virtual void SetCursorPosition(int , int ) {}
198 
200 
203  vtkSetMacro(CurrentCursor,int);
204  vtkGetMacro(CurrentCursor,int);
206 
208 
211  virtual void SetFullScreen(int) = 0;
212  vtkGetMacro(FullScreen,int);
213  vtkBooleanMacro(FullScreen,int);
215 
217 
222  vtkSetMacro(Borders,int);
223  vtkGetMacro(Borders,int);
224  vtkBooleanMacro(Borders,int);
226 
228 
232  vtkGetMacro(StereoCapableWindow,int);
233  vtkBooleanMacro(StereoCapableWindow,int);
234  virtual void SetStereoCapableWindow(int capable);
236 
238 
241  vtkGetMacro(StereoRender,int);
242  void SetStereoRender(int stereo);
243  vtkBooleanMacro(StereoRender,int);
245 
247 
250  vtkSetMacro(AlphaBitPlanes, int);
251  vtkGetMacro(AlphaBitPlanes, int);
252  vtkBooleanMacro(AlphaBitPlanes, int);
254 
256 
260  vtkSetMacro(PointSmoothing,int);
261  vtkGetMacro(PointSmoothing,int);
262  vtkBooleanMacro(PointSmoothing,int);
264 
266 
270  vtkSetMacro(LineSmoothing,int);
271  vtkGetMacro(LineSmoothing,int);
272  vtkBooleanMacro(LineSmoothing,int);
274 
276 
280  vtkSetMacro(PolygonSmoothing,int);
281  vtkGetMacro(PolygonSmoothing,int);
282  vtkBooleanMacro(PolygonSmoothing,int);
284 
286 
304  vtkGetMacro(StereoType,int);
305  vtkSetMacro(StereoType,int);
307  {this->SetStereoType(VTK_STEREO_CRYSTAL_EYES);}
309  {this->SetStereoType(VTK_STEREO_RED_BLUE);}
311  {this->SetStereoType(VTK_STEREO_INTERLACED);}
313  {this->SetStereoType(VTK_STEREO_LEFT);}
315  {this->SetStereoType(VTK_STEREO_RIGHT);}
317  {this->SetStereoType(VTK_STEREO_DRESDEN);}
319  {this->SetStereoType(VTK_STEREO_ANAGLYPH);}
321  {this->SetStereoType(VTK_STEREO_CHECKERBOARD);}
323  {this->SetStereoType(VTK_STEREO_SPLITVIEWPORT_HORIZONTAL);}
325  {this->SetStereoType(VTK_STEREO_FAKE);}
327 
328  const char *GetStereoTypeAsString();
329 
334  virtual void StereoUpdate();
335 
340  virtual void StereoMidpoint();
341 
346  virtual void StereoRenderComplete();
347 
349 
356  vtkSetClampMacro(AnaglyphColorSaturation,float, 0.0f, 1.0f);
357  vtkGetMacro(AnaglyphColorSaturation,float);
359 
361 
375  vtkSetVector2Macro(AnaglyphColorMask,int);
376  vtkGetVectorMacro(AnaglyphColorMask,int,2);
378 
384  virtual void WindowRemap() = 0;
385 
387 
390  vtkSetMacro(SwapBuffers,int);
391  vtkGetMacro(SwapBuffers,int);
392  vtkBooleanMacro(SwapBuffers,int);
394 
396 
408  virtual int SetPixelData(int x, int y, int x2, int y2, unsigned char *data,
409  int front) = 0;
410  virtual int SetPixelData(int x, int y, int x2, int y2,
411  vtkUnsignedCharArray *data, int front) = 0;
413 
415 
422  virtual float *GetRGBAPixelData(int x, int y, int x2, int y2, int front) = 0;
423  virtual int GetRGBAPixelData(int x, int y, int x2, int y2, int front,
424  vtkFloatArray *data) = 0;
425  virtual int SetRGBAPixelData(int x, int y, int x2, int y2, float *,
426  int front, int blend=0) = 0;
427  virtual int SetRGBAPixelData(int, int, int, int, vtkFloatArray*,
428  int, int blend=0) = 0;
429  virtual void ReleaseRGBAPixelData(float *data)=0;
430  virtual unsigned char *GetRGBACharPixelData(int x, int y, int x2, int y2,
431  int front) = 0;
432  virtual int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
434  virtual int SetRGBACharPixelData(int x,int y, int x2, int y2,
435  unsigned char *data, int front,
436  int blend=0) = 0;
437  virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
438  vtkUnsignedCharArray *data, int front,
439  int blend=0) = 0;
441 
443 
448  virtual float *GetZbufferData(int x, int y, int x2, int y2) = 0;
449  virtual int GetZbufferData(int x, int y, int x2, int y2, float *z) = 0;
450  virtual int GetZbufferData(int x, int y, int x2, int y2,
451  vtkFloatArray *z) = 0;
452  virtual int SetZbufferData(int x, int y, int x2, int y2, float *z) = 0;
453  virtual int SetZbufferData(int x, int y, int x2, int y2,
454  vtkFloatArray *z) = 0;
455  float GetZbufferDataAtPoint(int x, int y)
456  {
457  float value;
458  this->GetZbufferData(x, y, x, y, &value);
459  return value;
460  }
462 
464 
469  vtkGetMacro(AAFrames,int);
470  vtkSetMacro(AAFrames,int);
472 
474 
481  vtkGetMacro(FDFrames,int);
482  virtual void SetFDFrames (int fdFrames);
484 
486 
493  vtkGetMacro(UseConstantFDOffsets,int);
494  vtkSetMacro(UseConstantFDOffsets,int);
496 
498 
506  vtkGetMacro(SubFrames,int);
507  virtual void SetSubFrames(int subFrames);
509 
511 
514  vtkGetMacro(NeverRendered,int);
516 
518 
522  vtkGetMacro(AbortRender,int);
523  vtkSetMacro(AbortRender,int);
524  vtkGetMacro(InAbortCheck,int);
525  vtkSetMacro(InAbortCheck,int);
526  virtual int CheckAbortStatus();
528 
529  vtkGetMacro(IsPicking,int);
530  vtkSetMacro(IsPicking,int);
531  vtkBooleanMacro(IsPicking,int);
532 
539  virtual int GetEventPending() = 0;
540 
544  virtual int CheckInRenderStatus() { return this->InRender; }
545 
549  virtual void ClearInRenderStatus() { this->InRender = 0; }
550 
552 
560  virtual void SetDesiredUpdateRate(double);
561  vtkGetMacro(DesiredUpdateRate,double);
563 
565 
571  vtkGetMacro(NumberOfLayers, int);
572  vtkSetClampMacro(NumberOfLayers, int, 1, VTK_INT_MAX);
574 
576 
579  vtkGetObjectMacro(Interactor,vtkRenderWindowInteractor);
581 
585  void SetInteractor(vtkRenderWindowInteractor *);
586 
591  void UnRegister(vtkObjectBase *o) VTK_OVERRIDE;
592 
594 
597  void SetDisplayId(void *) VTK_OVERRIDE = 0;
598  void SetWindowId(void *) VTK_OVERRIDE = 0;
599  virtual void SetNextWindowId(void *) = 0;
600  void SetParentId(void *) VTK_OVERRIDE = 0;
601  void *GetGenericDisplayId() VTK_OVERRIDE = 0;
602  void *GetGenericWindowId() VTK_OVERRIDE = 0;
603  void *GetGenericParentId() VTK_OVERRIDE = 0;
604  void *GetGenericContext() VTK_OVERRIDE = 0;
605  void *GetGenericDrawable() VTK_OVERRIDE = 0;
606  void SetWindowInfo(char *) VTK_OVERRIDE = 0;
607  virtual void SetNextWindowInfo(char *) = 0;
608  void SetParentInfo(char *) VTK_OVERRIDE = 0;
610 
615  virtual bool InitializeFromCurrentContext() { return false; };
616 
621  void MakeCurrent() VTK_OVERRIDE = 0;
622 
627  virtual bool IsCurrent()=0;
628 
635  virtual bool IsDrawable(){ return true; }
636 
642  virtual void SetForceMakeCurrent() {}
643 
647  virtual const char *ReportCapabilities() { return "Not Implemented";};
648 
652  virtual int SupportsOpenGL() { return 0;};
653 
657  virtual int IsDirect() { return 0;};
658 
663  virtual int GetDepthBufferSize() = 0;
664 
669  virtual int GetColorBufferSizes(int *rgba) = 0;
670 
672 
677  vtkGetObjectMacro(PainterDeviceAdapter, vtkPainterDeviceAdapter);
679 
681 
684  vtkSetMacro(MultiSamples,int);
685  vtkGetMacro(MultiSamples,int);
687 
689 
692  vtkSetMacro(StencilCapable, int);
693  vtkGetMacro(StencilCapable, int);
694  vtkBooleanMacro(StencilCapable, int);
696 
698 
704  vtkSetMacro(DeviceIndex,int);
705  vtkGetMacro(DeviceIndex,int);
707 
711  virtual int GetNumberOfDevices()
712  {
713  return 0;
714  }
715 
724  virtual int SetUseOffScreenBuffers(bool) { return 0; }
725  virtual bool GetUseOffScreenBuffers() { return false; }
726 
727 protected:
728  vtkRenderWindow();
729  ~vtkRenderWindow() VTK_OVERRIDE;
730 
731  virtual void DoStereoRender();
732  virtual void DoFDRender();
733  virtual void DoAARender();
734 
735  vtkPainterDeviceAdapter* PainterDeviceAdapter;
737  vtkNew<vtkRenderTimerLog> RenderTimer;
738  int Borders;
739  int FullScreen;
740  int OldScreen[5];
741  int PointSmoothing;
742  int LineSmoothing;
743  int PolygonSmoothing;
744  int StereoRender;
745  int StereoType;
746  int StereoStatus; // used for keeping track of what's going on
747  int StereoCapableWindow;
748  int AlphaBitPlanes;
750  unsigned char* StereoBuffer; // used for red blue stereo
751  float *AccumulationBuffer; // used for many techniques
752  unsigned int AccumulationBufferSize;
753  int AAFrames;
754  int FDFrames;
755  int UseConstantFDOffsets; // to use the same offsets at each rendering
756  double *ConstantFDOffsets[2];
757  int SubFrames; // number of sub frames
758  int CurrentSubFrame; // what one are we on
759  unsigned char *ResultFrame; // used for any non immediate rendering
760  int SwapBuffers;
761  double DesiredUpdateRate;
762  int AbortRender;
763  int InAbortCheck;
764  int InRender;
765  int NeverRendered;
766  int NumberOfLayers;
767  int CurrentCursor;
768  int IsPicking;
769  float AnaglyphColorSaturation;
770  int AnaglyphColorMask[2];
771  int MultiSamples;
772  int StencilCapable;
773  int CapturingGL2PSSpecialProps;
774  int DeviceIndex;
775 
779  double AbortCheckTime;
780 
781 private:
782  vtkRenderWindow(const vtkRenderWindow&) VTK_DELETE_FUNCTION;
783  void operator=(const vtkRenderWindow&) VTK_DELETE_FUNCTION;
784 };
785 
786 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
virtual void SetForceMakeCurrent()
If called, allow MakeCurrent() to skip cache-check when called.
void SetStereoTypeToRight()
Set/Get what type of stereo rendering to use.
virtual void SetDisplayId(void *)=0
These are window system independent methods that are used to help interface vtkWindow to native windo...
virtual int SetUseOffScreenBuffers(bool)
Create and bind offscreen rendering buffers without destroying the current OpenGL context...
#define VTK_STEREO_RIGHT
void SetStereoTypeToFake()
Set/Get what type of stereo rendering to use.
#define VTK_STEREO_FAKE
#define VTK_STEREO_CHECKERBOARD
#define VTK_INT_MAX
Definition: vtkType.h:157
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
void SetStereoTypeToSplitViewportHorizontal()
Set/Get what type of stereo rendering to use.
#define VTK_STEREO_DRESDEN
void SetStereoTypeToAnaglyph()
Set/Get what type of stereo rendering to use.
#define VTK_STEREO_RED_BLUE
abstract specification for renderers
Definition: vtkRenderer.h:57
#define VTK_STEREO_INTERLACED
void SetStereoTypeToCrystalEyes()
Set/Get what type of stereo rendering to use.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
platform-independent render window interaction including picking and frame rate control.
virtual const char * ReportCapabilities()
Get report of capabilities for the render window.
virtual int IsDirect()
Is this render window using hardware acceleration? 0-false, 1-true.
virtual int SupportsOpenGL()
Does this render window support OpenGL? 0-false, 1-true.
an ordered list of renderers
An adapter between a vtkPainter and a rendering device.
virtual int CheckInRenderStatus()
Are we rendering at the moment.
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
void SetStereoTypeToRedBlue()
Set/Get what type of stereo rendering to use.
a simple class to control print indentation
Definition: vtkIndent.h:33
void SetStereoTypeToCheckerboard()
Set/Get what type of stereo rendering to use.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
float GetZbufferDataAtPoint(int x, int y)
Set/Get the zbuffer data from the frame buffer.
void SetStereoTypeToInterlaced()
Set/Get what type of stereo rendering to use.
abstract base class for most VTK objects
Definition: vtkObjectBase.h:62
virtual void MakeCurrent()
Make the window current.
Definition: vtkWindow.h:182
#define VTK_STEREO_CRYSTAL_EYES
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
dynamic, self-adjusting array of unsigned char
void SetStereoTypeToDresden()
Set/Get what type of stereo rendering to use.
create a window for renderers to draw into
#define VTK_STEREO_SPLITVIEWPORT_HORIZONTAL
virtual void ClearInRenderStatus()
Clear status (after an exception was thrown for example)
create and manipulate ordered lists of objects
Definition: vtkCollection.h:48
Allocate and hold a VTK object.
Definition: vtkNew.h:61
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual bool GetUseOffScreenBuffers()
#define VTK_STEREO_LEFT
virtual int GetNumberOfDevices()
Returns the number of devices (graphics cards) on a system.
virtual void Render()=0
Ask each viewport owned by this Window to render its image and synchronize this process.
void SetStereoTypeToLeft()
Set/Get what type of stereo rendering to use.
#define VTK_STEREO_ANAGLYPH
Asynchronously measures GPU execution times for a series of events.