1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkWindow.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 =========================================================================*/ 15 // .NAME vtkWindow - window superclass for vtkRenderWindow 16 // .SECTION Description 17 // vtkWindow is an abstract object to specify the behavior of a 18 // rendering window. It contains vtkViewports. 19 20 // .SECTION see also 21 // vtkRenderWindow vtkViewport 22 23 #ifndef vtkWindow_h 24 #define vtkWindow_h 25 26 #include "vtkCommonCoreModule.h" // For export macro 27 #include "vtkObject.h" 28 29 class vtkUnsignedCharArray; 30 31 class VTKCOMMONCORE_EXPORT vtkWindow : public vtkObject 32 { 33 public: 34 vtkTypeMacro(vtkWindow,vtkObject); 35 void PrintSelf(ostream& os, vtkIndent indent); 36 37 // Description: 38 // These are window system independent methods that are used 39 // to help interface vtkWindow to native windowing systems. 40 virtual void SetDisplayId(void *) = 0; 41 virtual void SetWindowId(void *) = 0; 42 virtual void SetParentId(void *) = 0; 43 virtual void *GetGenericDisplayId() = 0; 44 virtual void *GetGenericWindowId() = 0; 45 virtual void *GetGenericParentId() = 0; 46 virtual void *GetGenericContext() = 0; 47 virtual void *GetGenericDrawable() = 0; 48 virtual void SetWindowInfo(char *) = 0; 49 virtual void SetParentInfo(char *) = 0; 50 51 // Description: 52 // Set/Get the position in screen coordinates of the rendering window. 53 virtual int *GetPosition(); 54 virtual void SetPosition(int,int); 55 virtual void SetPosition(int a[2]); 56 57 // Description: 58 // Set/Get the size of the window in screen coordinates in pixels. 59 virtual int *GetSize(); 60 virtual void SetSize(int,int); 61 virtual void SetSize(int a[2]); 62 63 // Description: 64 // GetSize() returns the size * this->TileScale, whereas this method returns 65 // the size without multiplying with the tile scale. 66 int *GetActualSize(); 67 68 // Description: 69 // Get the current size of the screen in pixels. 70 virtual int *GetScreenSize() = 0; 71 72 // Description: 73 // Keep track of whether the rendering window has been mapped to screen. 74 vtkSetMacro(Mapped,int); 75 vtkGetMacro(Mapped,int); 76 vtkBooleanMacro(Mapped,int); 77 78 // Description: 79 // Turn on/off erasing the screen between images. This allows multiple 80 // exposure sequences if turned on. You will need to turn double 81 // buffering off or make use of the SwapBuffers methods to prevent 82 // you from swapping buffers between exposures. 83 vtkSetMacro(Erase,int); 84 vtkGetMacro(Erase,int); 85 vtkBooleanMacro(Erase,int); 86 87 // Description: 88 // Keep track of whether double buffering is on or off 89 vtkSetMacro(DoubleBuffer,int); 90 vtkGetMacro(DoubleBuffer,int); 91 vtkBooleanMacro(DoubleBuffer,int); 92 93 // Description: 94 // Get name of rendering window 95 vtkGetStringMacro(WindowName); 96 vtkSetStringMacro(WindowName); 97 98 // Description: 99 // Ask each viewport owned by this Window to render its image and 100 // synchronize this process. 101 virtual void Render() = 0; 102 103 // Description: 104 // Get the pixel data of an image, transmitted as RGBRGBRGB. The 105 // front argument indicates if the front buffer should be used or the back 106 // buffer. It is the caller's responsibility to delete the resulting 107 // array. It is very important to realize that the memory in this array 108 // is organized from the bottom of the window to the top. The origin 109 // of the screen is in the lower left corner. The y axis increases as 110 // you go up the screen. So the storage of pixels is from left to right 111 // and from bottom to top. 112 // (x,y) is any corner of the rectangle. (x2,y2) is its opposite corner on 113 // the diagonal. 114 virtual unsigned char *GetPixelData(int x, int y, int x2, int y2, 115 int front) = 0; 116 virtual int GetPixelData(int x, int y, int x2, int y2, int front, 117 vtkUnsignedCharArray *data) = 0; 118 119 // Description: 120 // Return a best estimate to the dots per inch of the display 121 // device being rendered (or printed). 122 vtkGetMacro(DPI,int); 123 vtkSetClampMacro(DPI,int,1,3000); 124 125 // Description: 126 // Create a window in memory instead of on the screen. This may not be 127 // supported for every type of window and on some windows you may need to 128 // invoke this prior to the first render. 129 vtkSetMacro(OffScreenRendering,int); 130 vtkGetMacro(OffScreenRendering,int); 131 vtkBooleanMacro(OffScreenRendering,int); 132 133 // Description: 134 // Make the window current. May be overridden in subclasses to do 135 // for example a glXMakeCurrent or a wglMakeCurrent. MakeCurrent()136 virtual void MakeCurrent() {} 137 138 // Description: 139 // These methods are used by vtkWindowToImageFilter to tell a VTK window 140 // to simulate a larger window by tiling. For 3D geometry these methods 141 // have no impact. It is just in handling annotation that this information 142 // must be available to the mappers and the coordinate calculations. 143 vtkSetVector2Macro(TileScale,int); 144 vtkGetVector2Macro(TileScale,int); SetTileScale(int s)145 void SetTileScale(int s) {this->SetTileScale(s,s);} 146 vtkSetVector4Macro(TileViewport,double); 147 vtkGetVector4Macro(TileViewport,double); 148 149 protected: 150 int OffScreenRendering; 151 vtkWindow(); 152 ~vtkWindow(); 153 154 char *WindowName; 155 int Size[2]; 156 int Position[2]; 157 int Mapped; 158 int Erase; 159 int DoubleBuffer; 160 int DPI; 161 162 double TileViewport[4]; 163 int TileSize[2]; 164 int TileScale[2]; 165 166 private: 167 vtkWindow(const vtkWindow&); // Not implemented. 168 void operator=(const vtkWindow&); // Not implemented. 169 }; 170 171 #endif 172 173 174