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) override;
55 
59  void Start() override;
60 
64  void Frame() override;
65 
69  virtual void WindowConfigure();
70 
79  void Initialize() override;
80 
87  void SetFullScreen(vtkTypeBool) override;
88 
92  void WindowRemap() override;
93 
98  virtual void PrefFullScreen();
99 
101 
104  void SetSize(int a[2]) override;
105  void SetSize(int,int) override;
107 
111  int *GetSize() VTK_SIZEHINT(2) override;
112 
114 
117  void SetPosition(int a[2]) override;
118  void SetPosition(int,int) override;
120 
124  int *GetScreenSize() VTK_SIZEHINT(2) override;
125 
129  int *GetPosition() VTK_SIZEHINT(2) override;
130 
135  void SetWindowName(const char *) override;
136 
137  void SetNextWindowInfo(const char *) override
138  {
139  vtkWarningMacro("SetNextWindowInfo not implemented (WindowRemap not implemented).");
140  }
141  void* GetGenericDrawable() override
142  {
143  vtkWarningMacro("Method not implemented.");
144  return nullptr;
145  }
146  void SetDisplayId(void*) override
147  {
148  vtkWarningMacro("Method not implemented.");
149  }
150  void *GetGenericDisplayId() override
151  {
152  vtkWarningMacro("Method not implemented.");
153  return nullptr;
154  }
155 
161  void SetWindowInfo(const char*) override;
162 
168  void SetParentInfo(const char*) override;
169 
170  void SetNextWindowId(void*) override
171  {
172  vtkWarningMacro("SetNextWindowId not implemented (WindowRemap not implemented).");
173  }
174 
179  bool InitializeFromCurrentContext() override;
180 
184  bool GetPlatformSupportsRenderWindowSharing() override { return true; };
185 
192  void SetStereoCapableWindow(vtkTypeBool capable) override;
193 
197  void MakeCurrent() override;
198 
202  bool IsCurrent() override;
203 
210  bool IsDrawable() override;
211 
215  void UpdateContext();
216 
220  const char *ReportCapabilities() override;
221 
225  int IsDirect() override;
226 
232  void SetForceMakeCurrent() override;
233 
238  int GetEventPending() 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() override;
253 
255 
261  void HideCursor() override;
262  void ShowCursor() override;
263  void SetCursorPosition(int x, int y) override;
265 
269  void SetCurrentCursor(int) override;
270 
275  virtual int GetViewCreated();
276 
281  virtual int GetWindowCreated();
282 
284 
287  void SetContextId(void *);
288  void *GetContextId();
289  void *GetGenericContext() override {return this->GetContextId();}
291 
302  virtual void SetRootWindow(void *);
303 
307  virtual void *GetRootWindow();
308 
319  void SetWindowId(void *) override;
320 
324  virtual void *GetWindowId();
325  void *GetGenericWindowId() override {return this->GetWindowId();}
326 
333  void SetParentId(void *nsview) override;
334 
340  virtual void *GetParentId();
341  void *GetGenericParentId() 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() override;
373  void PopContext() override;
375 
376 protected:
378  ~vtkCocoaRenderWindow() override;
379 
380  std::stack<void *> ContextStack;
381 
382  void CreateGLContext();
383 
384  void CreateAWindow() override;
385  void DestroyWindow() override;
386  void DestroyOffScreenWindow();
387 
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:
405  void operator=(const vtkCocoaRenderWindow&) = delete;
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
vtkOpenGLRenderWindow::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkOpenGLRenderWindow::SetSize
void SetSize(int a[2]) override
Set the size of the window in screen coordinates in pixels.
vtkRenderWindow::Start
virtual void Start()=0
Initialize the rendering process.
vtkCocoaRenderWindow::OnScreenInitialized
int OnScreenInitialized
Definition: vtkCocoaRenderWindow.h:389
vtkRenderWindow::ShowCursor
virtual void ShowCursor()=0
vtkWindow::GetSize
virtual int * GetSize()
Set/Get the size of the window in screen coordinates in pixels.
vtkRenderWindow::HideCursor
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...
vtkRenderWindow::Finalize
virtual void Finalize()=0
Finalize the rendering process.
vtkRenderWindow::SetFullScreen
virtual void SetFullScreen(vtkTypeBool)=0
Turn on/off rendering full screen window size.
vtkRenderWindow::IsCurrent
virtual bool IsCurrent()=0
Tells if this window is the current graphics context for the calling thread.
vtkCocoaRenderWindow::GetGenericDrawable
void * GetGenericDrawable() override
Definition: vtkCocoaRenderWindow.h:141
vtkRenderWindow::SetWindowId
void SetWindowId(void *) override=0
vtkRenderWindow::SetForceMakeCurrent
virtual void SetForceMakeCurrent()
If called, allow MakeCurrent() to skip cache-check when called.
Definition: vtkRenderWindow.h:613
vtkRenderWindow::WindowRemap
virtual void WindowRemap()=0
Remap the rendering window.
vtkOpenGLRenderWindow::PopContext
virtual void PopContext()
Definition: vtkOpenGLRenderWindow.h:398
vtkCocoaRenderWindow::SetDisplayId
void SetDisplayId(void *) override
Dummy stubs for vtkWindow API.
Definition: vtkCocoaRenderWindow.h:146
vtkRenderWindow::SetParentId
void SetParentId(void *) override=0
vtkCocoaRenderWindow::OffScreenInitialized
int OffScreenInitialized
Definition: vtkCocoaRenderWindow.h:388
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkCocoaRenderWindow::GetGenericDisplayId
void * GetGenericDisplayId() override
Definition: vtkCocoaRenderWindow.h:150
vtkCocoaRenderWindow::GetGenericContext
void * GetGenericContext() override
Definition: vtkCocoaRenderWindow.h:289
vtkOpenGLRenderWindow::InitializeFromCurrentContext
bool InitializeFromCurrentContext() override
Initialize the render window from the information associated with the currently activated OpenGL cont...
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkRenderWindow::SetWindowInfo
void SetWindowInfo(const char *) override=0
vtkCocoaRenderWindow::SetNextWindowId
void SetNextWindowId(void *) override
Definition: vtkCocoaRenderWindow.h:170
vtkRenderWindow::SetCurrentCursor
virtual void SetCurrentCursor(int)
Change the shape of the cursor.
vtkRenderWindow::MakeCurrent
void MakeCurrent() override=0
Attempt to make this window the current graphics context for the calling thread.
vtkRenderWindow::SetStereoCapableWindow
virtual void SetStereoCapableWindow(vtkTypeBool capable)
vtkCocoaRenderWindow::GetPlatformSupportsRenderWindowSharing
bool GetPlatformSupportsRenderWindowSharing() override
Does this platform support render window data sharing.
Definition: vtkCocoaRenderWindow.h:184
vtkCocoaRenderWindow
Cocoa OpenGL rendering window.
Definition: vtkCocoaRenderWindow.h:49
vtkOpenGLRenderWindow::ReportCapabilities
const char * ReportCapabilities() override
Get report of capabilities for the render window.
vtkRenderWindow::SetCursorPosition
virtual void SetCursorPosition(int, int)
Definition: vtkRenderWindow.h:201
vtkCocoaRenderWindow::GetGenericParentId
void * GetGenericParentId() override
Definition: vtkCocoaRenderWindow.h:341
vtkCocoaRenderWindow::ContextStack
std::stack< void * > ContextStack
Definition: vtkCocoaRenderWindow.h:380
vtkRenderWindow::IsDrawable
virtual bool IsDrawable()
Test if the window has a valid drawable.
Definition: vtkRenderWindow.h:606
vtkOpenGLRenderWindow::DestroyWindow
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
vtkCocoaRenderWindow::GetGenericWindowId
void * GetGenericWindowId() override
Definition: vtkCocoaRenderWindow.h:325
vtkRenderWindow::IsDirect
virtual int IsDirect()
Is this render window using hardware acceleration? 0-false, 1-true.
Definition: vtkRenderWindow.h:628
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:53
vtkRenderWindow::Frame
virtual void Frame()=0
A termination method performed at the end of the rendering process to do things like swapping buffers...
vtkRenderWindow::New
static vtkRenderWindow * New()
Construct an instance of vtkRenderWindow with its screen size set to 300x300, borders turned on,...
vtkOpenGLRenderWindow::PushContext
virtual void PushContext()
Ability to push and pop this window's context as the current context.
Definition: vtkOpenGLRenderWindow.h:397
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkRenderWindow::GetEventPending
virtual int GetEventPending()=0
Check to see if a mouse button has been pressed.
vtkOpenGLRenderWindow::Initialize
virtual void Initialize(void)
Initialize the rendering window.
Definition: vtkOpenGLRenderWindow.h:366
vtkOpenGLRenderWindow::CreateAWindow
virtual void CreateAWindow()=0
Create a not-off-screen window.
vtkOpenGLRenderWindow.h
vtkRenderWindow::SetParentInfo
void SetParentInfo(const char *) override=0