vtkWindow.h 6.27 KB
Newer Older
Ken Martin's avatar
Ken Martin committed
1 2 3 4 5
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkWindow.h

6
  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 8
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
Ken Martin's avatar
Ken Martin committed
9

10 11
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
     PURPOSE.  See the above copyright notice for more information.
Ken Martin's avatar
Ken Martin committed
13 14

=========================================================================*/
15 16 17 18 19 20 21 22 23 24
/**
 * @class   vtkWindow
 * @brief   window superclass for vtkRenderWindow
 *
 * vtkWindow is an abstract object to specify the behavior of a
 * rendering window.  It contains vtkViewports.
 *
 * @sa
 * vtkRenderWindow vtkViewport
*/
Ken Martin's avatar
Ken Martin committed
25

26 27
#ifndef vtkWindow_h
#define vtkWindow_h
Ken Martin's avatar
Ken Martin committed
28

29
#include "vtkCommonCoreModule.h" // For export macro
Ken Martin's avatar
Ken Martin committed
30 31
#include "vtkObject.h"

32 33
class vtkUnsignedCharArray;

34
class VTKCOMMONCORE_EXPORT vtkWindow : public vtkObject
Ken Martin's avatar
Ken Martin committed
35 36
{
public:
37
  vtkTypeMacro(vtkWindow,vtkObject);
38
  void PrintSelf(ostream& os, vtkIndent indent) override;
Ken Martin's avatar
Ken Martin committed
39

40 41 42 43 44
  //@{
  /**
   * These are window system independent methods that are used
   * to help interface vtkWindow to native windowing systems.
   */
Ken Martin's avatar
Ken Martin committed
45 46 47 48 49 50
  virtual void SetDisplayId(void *) = 0;
  virtual void SetWindowId(void *)  = 0;
  virtual void SetParentId(void *)  = 0;
  virtual void *GetGenericDisplayId() = 0;
  virtual void *GetGenericWindowId()  = 0;
  virtual void *GetGenericParentId()  = 0;
51
  virtual void *GetGenericContext()   = 0;
52
  virtual void *GetGenericDrawable()  = 0;
Ken Martin's avatar
Ken Martin committed
53
  virtual void SetWindowInfo(char *) = 0;
54
  virtual void SetParentInfo(char *) = 0;
55
  //@}
Ken Martin's avatar
Ken Martin committed
56

57 58 59
  //@{
  /**
   * Set/Get the position in screen coordinates of the rendering window.
60
   * Measured in pixels.
61
   */
Ken Martin's avatar
Ken Martin committed
62 63 64
  virtual int *GetPosition();
  virtual void SetPosition(int,int);
  virtual void SetPosition(int a[2]);
65
  //@}
Ken Martin's avatar
Ken Martin committed
66

67 68 69 70
  //@{
  /**
   * Set/Get the size of the window in screen coordinates in pixels.
   */
Ken Martin's avatar
Ken Martin committed
71 72 73
  virtual int *GetSize();
  virtual void SetSize(int,int);
  virtual void SetSize(int a[2]);
74
  //@}
Ken Martin's avatar
Ken Martin committed
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 81
  int *GetActualSize();

82 83 84
  /**
   * Get the current size of the screen in pixels.
   */
85 86
  virtual int     *GetScreenSize() = 0;

87 88 89 90
  //@{
  /**
   * Keep track of whether the rendering window has been mapped to screen.
   */
91 92 93
  vtkSetMacro(Mapped,vtkTypeBool);
  vtkGetMacro(Mapped,vtkTypeBool);
  vtkBooleanMacro(Mapped,vtkTypeBool);
94 95 96 97 98 99 100 101 102
  //@}

  //@{
  /**
   * Turn on/off erasing the screen between images. This allows multiple
   * exposure sequences if turned on. You will need to turn double
   * buffering off or make use of the SwapBuffers methods to prevent
   * you from swapping buffers between exposures.
   */
103 104 105
  vtkSetMacro(Erase,vtkTypeBool);
  vtkGetMacro(Erase,vtkTypeBool);
  vtkBooleanMacro(Erase,vtkTypeBool);
106
  //@}
Ken Martin's avatar
Ken Martin committed
107

108 109 110 111
  //@{
  /**
   * Keep track of whether double buffering is on or off
   */
112 113 114
  vtkSetMacro(DoubleBuffer,vtkTypeBool);
  vtkGetMacro(DoubleBuffer,vtkTypeBool);
  vtkBooleanMacro(DoubleBuffer,vtkTypeBool);
115
  //@}
116

117 118 119 120
  //@{
  /**
   * Get name of rendering window
   */
Ken Martin's avatar
Ken Martin committed
121
  vtkGetStringMacro(WindowName);
122
  vtkSetStringMacro(WindowName);
123
  //@}
Ken Martin's avatar
Ken Martin committed
124

125 126 127 128
  /**
   * Ask each viewport owned by this Window to render its image and
   * synchronize this process.
   */
Ken Martin's avatar
Ken Martin committed
129 130
  virtual void Render() = 0;

131 132 133 134 135 136 137 138 139 140 141 142 143
  //@{
  /**
   * Get the pixel data of an image, transmitted as RGBRGBRGB. The
   * front argument indicates if the front buffer should be used or the back
   * buffer. It is the caller's responsibility to delete the resulting
   * array. It is very important to realize that the memory in this array
   * is organized from the bottom of the window to the top. The origin
   * of the screen is in the lower left corner. The y axis increases as
   * you go up the screen. So the storage of pixels is from left to right
   * and from bottom to top.
   * (x,y) is any corner of the rectangle. (x2,y2) is its opposite corner on
   * the diagonal.
   */
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
  //@}
Ken Martin's avatar
Ken Martin committed
149

150 151 152 153 154
  //@{
  /**
   * Return a best estimate to the dots per inch of the display
   * device being rendered (or printed).
   */
Ken Martin's avatar
Ken Martin committed
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 163 164
   * will return false if the DPI could not be detected. Use GetDPI() to
   * inspect the detected value.
   */
David C. Lonie's avatar
David C. Lonie committed
165 166
  virtual bool DetectDPI() { return false; }

167 168 169 170 171 172
  //@{
  /**
   * Create a window in memory instead of on the screen. This may not be
   * supported for every type of window and on some windows you may need to
   * invoke this prior to the first render.
   */
173 174 175
  vtkSetMacro(OffScreenRendering,vtkTypeBool);
  vtkGetMacro(OffScreenRendering,vtkTypeBool);
  vtkBooleanMacro(OffScreenRendering,vtkTypeBool);
176
  //@}
177

178 179 180 181
  /**
   * Make the window current. May be overridden in subclasses to do
   * for example a glXMakeCurrent or a wglMakeCurrent.
   */
182
  virtual void MakeCurrent() {}
183

184 185 186 187 188 189 190
  //@{
  /**
   * These methods are used by vtkWindowToImageFilter to tell a VTK window
   * to simulate a larger window by tiling. For 3D geometry these methods
   * have no impact. It is just in handling annotation that this information
   * must be available to the mappers and the coordinate calculations.
   */
191 192 193
  vtkSetVector2Macro(TileScale,int);
  vtkGetVector2Macro(TileScale,int);
  void SetTileScale(int s) {this->SetTileScale(s,s);}
Ken Martin's avatar
Ken Martin committed
194 195
  vtkSetVector4Macro(TileViewport,double);
  vtkGetVector4Macro(TileViewport,double);
196
  //@}
Ken Martin's avatar
Ken Martin committed
197

Ken Martin's avatar
Ken Martin committed
198
protected:
199
  vtkTypeBool OffScreenRendering;
200
  vtkWindow();
201
  ~vtkWindow() override;
202

Ken Martin's avatar
Ken Martin committed
203 204 205
  char *WindowName;
  int Size[2];
  int Position[2];
206 207 208
  vtkTypeBool Mapped;
  vtkTypeBool Erase;
  vtkTypeBool DoubleBuffer;
Ken Martin's avatar
Ken Martin committed
209
  int DPI;
Ken Martin's avatar
Ken Martin committed
210

Ken Martin's avatar
Ken Martin committed
211 212
  double TileViewport[4];
  int    TileSize[2];
213
  int    TileScale[2];
214

215
private:
216 217
  vtkWindow(const vtkWindow&) = delete;
  void operator=(const vtkWindow&) = delete;
Ken Martin's avatar
Ken Martin committed
218 219 220 221 222
};

#endif