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