VTK  9.1.0
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 "vtkOpenGLRenderWindow.h"
46 #include "vtkRenderingOpenGL2Module.h" // For export macro
47 #include <stack> // for ivar
48 
49 class VTKRENDERINGOPENGL2_EXPORT vtkCocoaRenderWindow : public vtkOpenGLRenderWindow
50 {
51 public:
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 
109  void SetSize(int width, int height) override;
110  void SetSize(int a[2]) override { this->SetSize(a[0], a[1]); }
112 
117  int* GetSize() VTK_SIZEHINT(2) override;
118 
120 
125  void SetPosition(int x, int y) override;
126  void SetPosition(int a[2]) override { this->SetPosition(a[0], a[1]); }
128 
133  int* GetScreenSize() VTK_SIZEHINT(2) override;
134 
139  int* GetPosition() VTK_SIZEHINT(2) override;
140 
145  void SetWindowName(const char*) override;
146 
147  void SetNextWindowInfo(const char*) override
148  {
149  vtkDebugMacro("SetNextWindowInfo not implemented (WindowRemap not implemented).");
150  }
151  void* GetGenericDrawable() override
152  {
153  vtkDebugMacro("Method not implemented.");
154  return nullptr;
155  }
156 
164  void SetDisplayId(void* displayId) override
165  {
166  this->DisplayIndex = displayId ? *(reinterpret_cast<int*>(displayId)) : 0;
167  }
168 
169  void* GetGenericDisplayId() override
170  {
171  vtkDebugMacro("Method not implemented.");
172  return nullptr;
173  }
174 
180  void SetWindowInfo(const char*) override;
181 
187  void SetParentInfo(const char*) override;
188 
189  void SetNextWindowId(void*) override
190  {
191  vtkDebugMacro("SetNextWindowId not implemented (WindowRemap not implemented).");
192  }
193 
199 
203  bool GetPlatformSupportsRenderWindowSharing() override { return true; }
204 
211  void SetStereoCapableWindow(vtkTypeBool capable) override;
212 
216  void MakeCurrent() override;
217 
221  void ReleaseCurrent() override;
222 
226  bool IsCurrent() override;
227 
235  "Deprecated in 9.1 because no one knows what it's for and nothing uses it")
236  bool IsDrawable() override;
237 
241  void UpdateContext();
242 
246  const char* ReportCapabilities() override;
247 
251  vtkTypeBool IsDirect() override;
252 
258  void SetForceMakeCurrent() override;
259 
264  vtkTypeBool GetEventPending() override;
265 
267 
270  virtual void SetupPalette(void* hDC);
271  virtual void SetupPixelFormat(void* hDC, void* dwFlags, int debug, int bpp = 16, int zbpp = 16);
273 
277  void Finalize() override;
278 
280 
286  void HideCursor() override;
287  void ShowCursor() override;
288  void SetCursorPosition(int x, int y) override;
290 
294  void SetCurrentCursor(int) override;
295 
300  virtual vtkTypeBool GetViewCreated();
301 
306  virtual vtkTypeBool GetWindowCreated();
307 
309 
312  void SetContextId(void*);
313  void* GetContextId();
314  void* GetGenericContext() override { return this->GetContextId(); }
316 
327  virtual void SetRootWindow(void*);
328 
332  virtual void* GetRootWindow();
333 
344  void SetWindowId(void*) override;
345 
349  virtual void* GetWindowId();
350  void* GetGenericWindowId() override { return this->GetWindowId(); }
351 
358  void SetParentId(void* nsview) override;
359 
365  virtual void* GetParentId();
366  void* GetGenericParentId() override { return this->GetParentId(); }
367 
378  void SetWantsBestResolution(bool wantsBest);
380 
389 
391 
394  void SetPixelFormat(void* pixelFormat);
395  void* GetPixelFormat();
397 
399 
406  void PushContext() override;
407  void PopContext() override;
409 
410 protected:
413 
414  std::stack<void*> ContextStack;
415 
417 
418  void CreateAWindow() override;
419  void DestroyWindow() override;
421 
423 
427  void SetCocoaManager(void* manager);
430 
431  void SetCocoaServer(void* server); // Really a vtkCocoaServer*
432  void* GetCocoaServer();
433 
434 private:
436  void operator=(const vtkCocoaRenderWindow&) = delete;
437 
438 private:
439  // Important: this class cannot contain Objective-C instance
440  // variables for 2 reasons:
441  // 1) C++ files include this header
442  // 2) because of garbage collection (the GC scanner does not scan objects create by C++'s new)
443  // Instead, use the CocoaManager dictionary to keep a collection
444  // of what would otherwise be Objective-C instance variables.
445  void* CocoaManager; // Really an NSMutableDictionary*
446 
447  vtkTypeBool WindowCreated;
448  vtkTypeBool ViewCreated;
449  vtkTypeBool CursorHidden;
450 
451  vtkTypeBool ForceMakeCurrent;
452 
453  bool WantsBestResolution;
454  bool ConnectContextToNSView;
455 
456  int DisplayIndex = 0;
457 };
458 
459 #endif
vtkCocoaRenderWindow::SetCocoaManager
void SetCocoaManager(void *manager)
Accessors for the cocoa manager (Really an NSMutableDictionary*).
vtkCocoaRenderWindow::GetConnectContextToNSView
bool GetConnectContextToNSView()
vtkCocoaRenderWindow::~vtkCocoaRenderWindow
~vtkCocoaRenderWindow() override
vtkCocoaRenderWindow::CreateAWindow
void CreateAWindow() override
Create a not-off-screen window.
vtkCocoaRenderWindow::ContextStack
std::stack< void * > ContextStack
Definition: vtkCocoaRenderWindow.h:414
vtkCocoaRenderWindow::GetWindowId
virtual void * GetWindowId()
Returns the NSView* associated with this vtkRenderWindow.
vtkX3D::connect
@ connect
Definition: vtkX3D.h:182
vtkCocoaRenderWindow::SetPixelFormat
void SetPixelFormat(void *pixelFormat)
Accessors for the pixel format object (Really an NSOpenGLPixelFormat*).
vtkCocoaRenderWindow::Start
void Start() override
Begin the rendering process.
vtkCocoaRenderWindow::SetSize
void SetSize(int width, int height) override
Set the size (width and height) of the rendering window in screen coordinates (in pixels).
vtkCocoaRenderWindow::GetSize
int * GetSize() override
Get the size (width and height) of the rendering window in screen coordinates (in pixels).
vtkCocoaRenderWindow::SetWindowId
void SetWindowId(void *) override
Sets the NSView* associated with this vtkRenderWindow.
vtkCocoaRenderWindow::SetCocoaServer
void SetCocoaServer(void *server)
VTK_DEPRECATED_IN_9_1_0
#define VTK_DEPRECATED_IN_9_1_0(reason)
Definition: vtkDeprecation.h:117
vtkCocoaRenderWindow::CreateGLContext
void CreateGLContext()
vtkCocoaRenderWindow::GetGenericDrawable
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.
Definition: vtkCocoaRenderWindow.h:151
vtkCocoaRenderWindow::SetConnectContextToNSView
void SetConnectContextToNSView(bool connect)
Set to false if you want to prevent the NSOpenGLContext from being associated with the NSView.
vtkCocoaRenderWindow::GetPixelFormat
void * GetPixelFormat()
Accessors for the pixel format object (Really an NSOpenGLPixelFormat*).
vtkCocoaRenderWindow::MakeCurrent
void MakeCurrent() override
Make this windows OpenGL context the current context.
vtkCocoaRenderWindow::PushContext
void PushContext() override
Ability to push and pop this window's context as the current context.
vtkCocoaRenderWindow::SetDisplayId
void SetDisplayId(void *displayId) override
Set the index of the NSScreen on which the window should be created.
Definition: vtkCocoaRenderWindow.h:164
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:48
vtkCocoaRenderWindow::New
static vtkCocoaRenderWindow * New()
vtkCocoaRenderWindow::GetGenericDisplayId
void * GetGenericDisplayId() override
Dummy stubs for vtkWindow API.
Definition: vtkCocoaRenderWindow.h:169
vtkX3D::height
@ height
Definition: vtkX3D.h:260
vtkCocoaRenderWindow::Initialize
void Initialize() override
Initialize the window for rendering.
vtkCocoaRenderWindow::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:113
vtkCocoaRenderWindow::SetNextWindowId
void SetNextWindowId(void *) override
Dummy stubs for vtkWindow API.
Definition: vtkCocoaRenderWindow.h:189
vtkCocoaRenderWindow::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkCocoaRenderWindow::PopContext
void PopContext() override
Ability to push and pop this window's context as the current context.
vtkCocoaRenderWindow::SetWantsBestResolution
void SetWantsBestResolution(bool wantsBest)
Set to true if you want to force NSViews created by this object to have their wantsBestResolutionOpen...
vtkCocoaRenderWindow::OnScreenInitialized
vtkTypeBool OnScreenInitialized
Definition: vtkCocoaRenderWindow.h:420
vtkCocoaRenderWindow::GetPlatformSupportsRenderWindowSharing
bool GetPlatformSupportsRenderWindowSharing() override
Does this platform support render window data sharing.
Definition: vtkCocoaRenderWindow.h:203
vtkCocoaRenderWindow::SetPosition
void SetPosition(int a[2]) override
Set the position (x and y) of the rendering window in screen coordinates (in pixels).
Definition: vtkCocoaRenderWindow.h:126
vtkCocoaRenderWindow::GetCocoaManager
void * GetCocoaManager()
Accessors for the cocoa manager (Really an NSMutableDictionary*).
vtkCocoaRenderWindow::SetSize
void SetSize(int a[2]) override
Set the size (width and height) of the rendering window in screen coordinates (in pixels).
Definition: vtkCocoaRenderWindow.h:110
vtkCocoaRenderWindow
Cocoa OpenGL rendering window.
Definition: vtkCocoaRenderWindow.h:50
vtkCocoaRenderWindow::SetStereoCapableWindow
void SetStereoCapableWindow(vtkTypeBool capable) override
Prescribe that the window be created in a stereo-capable mode.
vtkCocoaRenderWindow::SetParentInfo
void SetParentInfo(const char *) override
See the documentation for SetParentId().
vtkCocoaRenderWindow::GetCocoaServer
void * GetCocoaServer()
vtkCocoaRenderWindow::SetRootWindow
virtual void SetRootWindow(void *)
Sets the NSWindow* associated with this vtkRenderWindow.
vtkCocoaRenderWindow::GetGenericParentId
void * GetGenericParentId() override
Dummy stubs for vtkWindow API.
Definition: vtkCocoaRenderWindow.h:366
vtkCocoaRenderWindow::SetFullScreen
void SetFullScreen(vtkTypeBool) override
Change the window to fill the entire screen.
vtkCocoaRenderWindow::ReleaseCurrent
void ReleaseCurrent() override
Release the current context.
vtkCocoaRenderWindow::GetGenericWindowId
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
Definition: vtkCocoaRenderWindow.h:350
vtkCocoaRenderWindow::SetParentId
void SetParentId(void *nsview) override
Set the NSView* for the vtkRenderWindow to be parented within.
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:83
vtkCocoaRenderWindow::vtkCocoaRenderWindow
vtkCocoaRenderWindow()
vtkCocoaRenderWindow::WindowConfigure
virtual void WindowConfigure()
Specify various window parameters.
vtkCocoaRenderWindow::PrefFullScreen
virtual void PrefFullScreen()
Set the preferred window size to full screen.
vtkCocoaRenderWindow::GetParentId
virtual void * GetParentId()
Get the parent NSView* for this vtkRenderWindow.
vtkCocoaRenderWindow::GetScreenSize
int * GetScreenSize() override
Get the current size of the screen in pixels.
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkCocoaRenderWindow::Frame
void Frame() override
Finish the rendering process.
vtkCocoaRenderWindow::GetRootWindow
virtual void * GetRootWindow()
Returns the NSWindow* associated with this vtkRenderWindow.
vtkCocoaRenderWindow::SetWindowInfo
void SetWindowInfo(const char *) override
Set this RenderWindow's window id to a pre-existing window.
vtkOpenGLRenderWindow.h
vtkCocoaRenderWindow::WindowRemap
void WindowRemap() override
Remap the window.
vtkCocoaRenderWindow::DestroyWindow
void DestroyWindow() override
Destroy a not-off-screen window.
vtkCocoaRenderWindow::IsCurrent
bool IsCurrent() override
Tells if this window is the current OpenGL context for the calling thread.
vtkCocoaRenderWindow::GetWantsBestResolution
bool GetWantsBestResolution()