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 "vtkRenderingOpenGL2Module.h" // For export macro
46 #include <stack> // for ivar
47 #include "vtkOpenGLRenderWindow.h"
48 
49 class VTKRENDERINGOPENGL2_EXPORT vtkCocoaRenderWindow : public vtkOpenGLRenderWindow
50 {
51 public:
52  static vtkCocoaRenderWindow *New();
54  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
55 
59  void Start() VTK_OVERRIDE;
60 
64  void Frame() VTK_OVERRIDE;
65 
69  virtual void WindowConfigure();
70 
79  void Initialize() VTK_OVERRIDE;
80 
87  void SetFullScreen(int) VTK_OVERRIDE;
88 
92  void WindowRemap() VTK_OVERRIDE;
93 
98  virtual void PrefFullScreen();
99 
101 
104  void SetSize(int a[2]) VTK_OVERRIDE;
105  void SetSize(int,int) VTK_OVERRIDE;
107 
111  int *GetSize() VTK_OVERRIDE;
112 
114 
117  void SetPosition(int a[2]) VTK_OVERRIDE;
118  void SetPosition(int,int) VTK_OVERRIDE;
120 
124  int *GetScreenSize() VTK_OVERRIDE;
125 
129  int *GetPosition() VTK_OVERRIDE;
130 
135  void SetWindowName(const char *) VTK_OVERRIDE;
136 
137  void SetNextWindowInfo(char *) VTK_OVERRIDE
138  {
139  vtkWarningMacro("SetNextWindowInfo not implemented (WindowRemap not implemented).");
140  }
141  void* GetGenericDrawable() VTK_OVERRIDE
142  {
143  vtkWarningMacro("Method not implemented.");
144  return 0;
145  }
146  void SetDisplayId(void*) VTK_OVERRIDE
147  {
148  vtkWarningMacro("Method not implemented.");
149  }
150  void *GetGenericDisplayId() VTK_OVERRIDE
151  {
152  vtkWarningMacro("Method not implemented.");
153  return 0;
154  }
155 
161  void SetWindowInfo(char*) VTK_OVERRIDE;
162 
168  void SetParentInfo(char*) VTK_OVERRIDE;
169 
170  void SetNextWindowId(void*) VTK_OVERRIDE
171  {
172  vtkWarningMacro("SetNextWindowId not implemented (WindowRemap not implemented).");
173  }
174 
179  bool InitializeFromCurrentContext() VTK_OVERRIDE;
180 
184  void StereoUpdate() VTK_OVERRIDE;
185 
192  void SetStereoCapableWindow(int capable) VTK_OVERRIDE;
193 
197  void MakeCurrent() VTK_OVERRIDE;
198 
202  bool IsCurrent() VTK_OVERRIDE;
203 
210  bool IsDrawable() VTK_OVERRIDE;
211 
215  void UpdateContext();
216 
220  const char *ReportCapabilities() VTK_OVERRIDE;
221 
225  int IsDirect() VTK_OVERRIDE;
226 
232  void SetForceMakeCurrent() VTK_OVERRIDE;
233 
238  int GetEventPending() VTK_OVERRIDE;
239 
241 
244  virtual void SetupPalette(void *hDC);
245  virtual void SetupPixelFormat(void *hDC, void *dwFlags, int debug,
246  int bpp=16, int zbpp=16);
248 
252  void Finalize() VTK_OVERRIDE;
253 
255 
261  void HideCursor() VTK_OVERRIDE;
262  void ShowCursor() VTK_OVERRIDE;
263  void SetCursorPosition(int x, int y) VTK_OVERRIDE;
265 
269  void SetCurrentCursor(int) VTK_OVERRIDE;
270 
275  virtual int GetViewCreated();
276 
281  virtual int GetWindowCreated();
282 
284 
287  void SetContextId(void *);
288  void *GetContextId();
289  void *GetGenericContext() VTK_OVERRIDE {return this->GetContextId();}
291 
302  virtual void SetRootWindow(void *);
303 
307  virtual void *GetRootWindow();
308 
319  void SetWindowId(void *) VTK_OVERRIDE;
320 
324  virtual void *GetWindowId();
325  void *GetGenericWindowId() VTK_OVERRIDE {return this->GetWindowId();}
326 
333  void SetParentId(void *nsview) VTK_OVERRIDE;
334 
340  virtual void *GetParentId();
341  void *GetGenericParentId() VTK_OVERRIDE { return this->GetParentId(); }
342 
353  void SetWantsBestResolution(bool wantsBest);
354  bool GetWantsBestResolution();
355 
357 
360  void SetPixelFormat(void *pixelFormat);
361  void *GetPixelFormat();
363 
365 
372  void PushContext() VTK_OVERRIDE;
373  void PopContext() VTK_OVERRIDE;
375 
376 protected:
378  ~vtkCocoaRenderWindow() VTK_OVERRIDE;
379 
380  std::stack<void *> ContextStack;
381 
382  void CreateGLContext();
383 
384  void CreateAWindow() VTK_OVERRIDE;
385  void DestroyWindow() VTK_OVERRIDE;
386  void DestroyOffScreenWindow();
387 
388  int OffScreenInitialized;
389  int OnScreenInitialized;
390 
392 
396  void SetCocoaManager(void *manager);
397  void *GetCocoaManager();
399 
400  void SetCocoaServer(void *server); // Really a vtkCocoaServer*
401  void *GetCocoaServer();
402 
403 private:
404  vtkCocoaRenderWindow(const vtkCocoaRenderWindow&) VTK_DELETE_FUNCTION;
405  void operator=(const vtkCocoaRenderWindow&) VTK_DELETE_FUNCTION;
406 
407 private:
408  // Important: this class cannot contain Objective-C instance
409  // variables for 2 reasons:
410  // 1) C++ files include this header
411  // 2) because of garbage collection (the GC scanner does not scan objects create by C++'s new)
412  // Instead, use the CocoaManager dictionary to keep a collection
413  // of what would otherwise be Objective-C instance variables.
414  void *CocoaManager; // Really an NSMutableDictionary*
415 
416  int WindowCreated;
417  int ViewCreated;
418  int CursorHidden;
419 
420  int ForceMakeCurrent;
421 
422  bool WantsBestResolution;
423 };
424 
425 #endif
OpenGL rendering window.
virtual void Finalize()=0
Finalize the rendering process.
virtual void SetForceMakeCurrent()
If called, allow MakeCurrent() to skip cache-check when called.
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.
void StereoUpdate() override
Update system if needed due to stereo rendering.
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 void SetCurrentCursor(int)
Change the shape of the cursor.
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:33
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*).
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 void PushContext()
Ability to push and pop this window&#39;s context as the current context.
const char * ReportCapabilities() override
Get report of capabilities for the render window.
void SetParentId(void *) override=0
Dummy stubs for vtkWindow API.
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 * GetGenericParentId() override
Dummy stubs for vtkWindow API.
std::stack< void * > ContextStack
virtual void Start()=0
Initialize the rendering process.
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.