VTK
vtkCocoaRenderWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 Module: vtkCocoaRenderWindow.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 =========================================================================*/
42 #ifndef vtkCocoaRenderWindow_h
43 #define vtkCocoaRenderWindow_h
44 
45 #include "vtkRenderingOpenGLModule.h" // For export macro
46 #include "vtkOpenGLRenderWindow.h"
47 
48 class VTKRENDERINGOPENGL_EXPORT vtkCocoaRenderWindow : public vtkOpenGLRenderWindow
49 {
50 public:
51  static vtkCocoaRenderWindow *New();
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
58  void Start() override;
59 
63  void Frame() override;
64 
68  virtual void WindowConfigure();
69 
78  virtual void Initialize();
79 
86  void SetFullScreen(int) override;
87 
91  void WindowRemap() override;
92 
97  virtual void PrefFullScreen();
98 
100 
103  void SetSize(int a[2]) override;
104  void SetSize(int,int) override;
106 
110  int *GetSize() override;
111 
113 
116  void SetPosition(int a[2]) override;
117  void SetPosition(int,int) override;
119 
123  int *GetScreenSize() override;
124 
128  int *GetPosition() override;
129 
134  void SetWindowName(const char *) override;
135 
136  void SetNextWindowInfo(char *) override
137  {
138  vtkWarningMacro("SetNextWindowInfo not implemented (WindowRemap not implemented).");
139  }
140  void* GetGenericDrawable() override
141  {
142  vtkWarningMacro("Method not implemented.");
143  return 0;
144  }
145  void SetDisplayId(void*) override
146  {
147  vtkWarningMacro("Method not implemented.");
148  }
149  void *GetGenericDisplayId() override
150  {
151  vtkWarningMacro("Method not implemented.");
152  return 0;
153  }
154 
160  void SetWindowInfo(char*) override;
161 
167  void SetParentInfo(char*) override;
168 
169  void SetNextWindowId(void*) override
170  {
171  vtkWarningMacro("SetNextWindowId not implemented (WindowRemap not implemented).");
172  }
173 
178  bool InitializeFromCurrentContext() override;
179 
186  void SetStereoCapableWindow(int capable) override;
187 
191  void MakeCurrent() override;
192 
196  bool IsCurrent() override;
197 
204  bool IsDrawable() override;
205 
209  void UpdateContext();
210 
214  const char *ReportCapabilities() override;
215 
219  int SupportsOpenGL() override;
220 
224  int IsDirect() override;
225 
231  void SetForceMakeCurrent() override;
232 
237  int GetEventPending() override;
238 
240 
243  virtual void SetupPalette(void *hDC);
244  virtual void SetupPixelFormat(void *hDC, void *dwFlags, int debug,
245  int bpp=16, int zbpp=16);
247 
251  void Finalize() override;
252 
256  int GetDepthBufferSize() override;
257 
259 
265  void HideCursor() override;
266  void ShowCursor() override;
267  void SetCursorPosition(int x, int y) override;
269 
273  void SetCurrentCursor(int) override;
274 
279  virtual int GetViewCreated();
280 
285  virtual int GetWindowCreated();
286 
288 
291  void SetContextId(void *);
292  void *GetContextId();
293  void *GetGenericContext() override {return this->GetContextId();}
295 
306  virtual void SetRootWindow(void *);
307 
311  virtual void *GetRootWindow();
312 
323  void SetWindowId(void *) override;
324 
328  virtual void *GetWindowId();
329  void *GetGenericWindowId() override {return this->GetWindowId();}
330 
337  void SetParentId(void *nsview) override;
338 
344  virtual void *GetParentId();
345  void *GetGenericParentId() override { return this->GetParentId(); }
346 
356  void SetWantsBestResolution(bool wantsBest);
357  bool GetWantsBestResolution();
358 
360 
363  void SetPixelFormat(void *pixelFormat);
364  void *GetPixelFormat();
366 
367 protected:
369  ~vtkCocoaRenderWindow() override;
370 
371  void CreateGLContext();
372 
373  void CreateAWindow() override;
374  void DestroyWindow() override;
375  void DestroyOffScreenWindow();
376 
379 
381 
385  void SetCocoaManager(void *manager);
386  void *GetCocoaManager();
388 
389  void SetCocoaServer(void *server); // Really a vtkCocoaServer*
390  void *GetCocoaServer();
391 
392 private:
394  void operator=(const vtkCocoaRenderWindow&) = delete;
395 
396 private:
397  // Important: this class cannot contain Objective-C instance
398  // variables for 2 reasons:
399  // 1) C++ files include this header
400  // 2) because of garbage collection (the GC scanner does not scan objects create by C++'s new)
401  // Instead, use the CocoaManager dictionary to keep a collection
402  // of what would otherwise be Objective-C instance variables.
403  void *CocoaManager; // Really an NSMutableDictionary*
404 
405  int WindowCreated;
406  int ViewCreated;
407  int CursorHidden;
408 
409  int ForceMakeCurrent;
410  char *Capabilities;
411 
412  bool WantsBestResolution;
413 };
414 
415 #endif
int GetDepthBufferSize() override
Get the size of the depth buffer.
OpenGL rendering window.
virtual void Finalize()=0
Finalize the rendering process.
virtual void SetForceMakeCurrent()
If called, allow MakeCurrent() to skip cache-check when called.
virtual void WindowRemap()=0
Remap the rendering window.
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.
virtual void HideCursor()=0
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
Cocoa OpenGL rendering window.
void SetDisplayId(void *) override
Dummy stubs for vtkWindow API.
static vtkRenderWindow * New()
Construct an instance of vtkRenderWindow with its screen size set to 300x300, borders turned on...
bool InitializeFromCurrentContext() override
Initialize the render window from the information associated with the currently activated OpenGL cont...
virtual int * GetScreenSize()=0
Get the current size of the screen in pixels.
virtual void SetCurrentCursor(int)
Change the shape of the cursor.
virtual void SetFullScreen(int)=0
Turn on/off rendering full screen window size.
void SetNextWindowId(void *) override
Dummy stubs for vtkWindow API.
virtual int GetEventPending()=0
Check to see if a mouse button has been pressed.
virtual void SetStereoCapableWindow(int capable)
Prescribe that the window be created in a stereo-capable mode.
virtual int IsDirect()
Is this render window using hardware acceleration? 0-false, 1-true.
virtual bool IsCurrent()=0
Tells if this window is the current graphics context for the calling thread.
void SetWindowId(void *) override=0
Dummy stubs for vtkWindow API.
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
void SetWindowInfo(char *) override=0
Dummy stubs for vtkWindow API.
void * GetGenericDisplayId() override
Dummy stubs for vtkWindow API.
void * GetGenericContext() override
Accessors for the OpenGL context (Really an NSOpenGLContext*).
int SupportsOpenGL() override
Does this render window support OpenGL? 0-false, 1-true.
virtual void SetCursorPosition(int, int)
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
virtual int * GetPosition()
Set/Get the position in screen coordinates of the rendering window.
virtual void Frame()=0
A termination method performed at the end of the rendering process to do things like swapping buffers...
const char * ReportCapabilities() override
Get report of capabilities for the render window.
void SetNextWindowInfo(char *) override
Dummy stubs for vtkWindow API.
void SetParentId(void *) override=0
Dummy stubs for vtkWindow API.
virtual int * GetSize()
Set/Get the size of the window in screen coordinates in pixels.
void SetParentInfo(char *) override=0
Dummy stubs for vtkWindow API.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetSize(int a[2]) override
Set the size of the window in screen coordinates in pixels.
void * GetGenericParentId() override
Dummy stubs for vtkWindow API.
virtual void Start()=0
Initialize the rendering process.
virtual void SetWindowName(const char *)
Get name of rendering window.
virtual void SetPosition(int, int)
Set/Get the position in screen coordinates of the rendering window.
virtual void Initialize(void)
Initialize the rendering window.
virtual void CreateAWindow()=0
Create a not-off-screen window.
void MakeCurrent() override=0
Attempt to make this window the current graphics context for the calling thread.
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
virtual void ShowCursor()=0
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
virtual bool IsDrawable()
Test if the window has a valid drawable.