VTK  9.0.20200808
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:
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 
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  void SetDisplayId(void*) override
157  {
158  // no-op
159  vtkDebugMacro("Method not implemented.");
160  }
161  void* GetGenericDisplayId() override
162  {
163  vtkDebugMacro("Method not implemented.");
164  return nullptr;
165  }
166 
172  void SetWindowInfo(const char*) override;
173 
179  void SetParentInfo(const char*) override;
180 
181  void SetNextWindowId(void*) override
182  {
183  vtkDebugMacro("SetNextWindowId not implemented (WindowRemap not implemented).");
184  }
185 
190  bool InitializeFromCurrentContext() override;
191 
195  bool GetPlatformSupportsRenderWindowSharing() override { return true; }
196 
203  void SetStereoCapableWindow(vtkTypeBool capable) override;
204 
208  void MakeCurrent() override;
209 
213  bool IsCurrent() override;
214 
222  "Deprecated in 9.1 because no one knows what it's for and nothing uses it")
223  bool IsDrawable() override;
224 
228  void UpdateContext();
229 
233  const char* ReportCapabilities() override;
234 
238  vtkTypeBool IsDirect() override;
239 
245  void SetForceMakeCurrent() override;
246 
251  vtkTypeBool GetEventPending() override;
252 
254 
257  virtual void SetupPalette(void* hDC);
258  virtual void SetupPixelFormat(void* hDC, void* dwFlags, int debug, int bpp = 16, int zbpp = 16);
260 
264  void Finalize() override;
265 
267 
273  void HideCursor() override;
274  void ShowCursor() override;
275  void SetCursorPosition(int x, int y) override;
277 
281  void SetCurrentCursor(int) override;
282 
287  virtual vtkTypeBool GetViewCreated();
288 
293  virtual vtkTypeBool GetWindowCreated();
294 
296 
299  void SetContextId(void*);
300  void* GetContextId();
301  void* GetGenericContext() override { return this->GetContextId(); }
303 
314  virtual void SetRootWindow(void*);
315 
319  virtual void* GetRootWindow();
320 
331  void SetWindowId(void*) override;
332 
336  virtual void* GetWindowId();
337  void* GetGenericWindowId() override { return this->GetWindowId(); }
338 
345  void SetParentId(void* nsview) override;
346 
352  virtual void* GetParentId();
353  void* GetGenericParentId() override { return this->GetParentId(); }
354 
365  void SetWantsBestResolution(bool wantsBest);
366  bool GetWantsBestResolution();
367 
374  void SetConnectContextToNSView(bool connect);
375  bool GetConnectContextToNSView();
376 
378 
381  void SetPixelFormat(void* pixelFormat);
382  void* GetPixelFormat();
384 
386 
393  void PushContext() override;
394  void PopContext() override;
396 
397 protected:
399  ~vtkCocoaRenderWindow() override;
400 
401  std::stack<void*> ContextStack;
402 
403  void CreateGLContext();
404 
405  void CreateAWindow() override;
406  void DestroyWindow() override;
408 
410 
414  void SetCocoaManager(void* manager);
415  void* GetCocoaManager();
417 
418  void SetCocoaServer(void* server); // Really a vtkCocoaServer*
419  void* GetCocoaServer();
420 
421 private:
423  void operator=(const vtkCocoaRenderWindow&) = delete;
424 
425 private:
426  // Important: this class cannot contain Objective-C instance
427  // variables for 2 reasons:
428  // 1) C++ files include this header
429  // 2) because of garbage collection (the GC scanner does not scan objects create by C++'s new)
430  // Instead, use the CocoaManager dictionary to keep a collection
431  // of what would otherwise be Objective-C instance variables.
432  void* CocoaManager; // Really an NSMutableDictionary*
433 
434  vtkTypeBool WindowCreated;
435  vtkTypeBool ViewCreated;
436  vtkTypeBool CursorHidden;
437 
438  vtkTypeBool ForceMakeCurrent;
439 
440  bool WantsBestResolution;
441  bool ConnectContextToNSView;
442 };
443 
444 #endif
vtkOpenGLRenderWindow::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkCocoaRenderWindow::ContextStack
std::stack< void * > ContextStack
Definition: vtkCocoaRenderWindow.h:401
vtkX3D::connect
Definition: vtkX3D.h:182
vtkRenderWindow::SetWindowInfo
void SetWindowInfo(const char *) override
Definition: vtkRenderWindow.h:628
vtkWindow::GetSize
virtual int * GetSize()
Get the size (width and height) of the rendering window in screen coordinates (in pixels).
vtkRenderWindow::SetWindowId
void SetWindowId(void *) override
Definition: vtkRenderWindow.h:620
vtkCocoaRenderWindow::GetGenericDrawable
void * GetGenericDrawable() override
Definition: vtkCocoaRenderWindow.h:151
vtkRenderWindow::WindowRemap
virtual void WindowRemap()
Remap the rendering window.
Definition: vtkRenderWindow.h:404
vtkOpenGLRenderWindow::PopContext
virtual void PopContext()
Definition: vtkOpenGLRenderWindow.h:334
vtkCocoaRenderWindow::SetDisplayId
void SetDisplayId(void *) override
Dummy stubs for vtkWindow API.
Definition: vtkCocoaRenderWindow.h:156
vtkWindow::SetSize
virtual void SetSize(int width, int height)
Set the size (width and height) of the rendering window in screen coordinates (in pixels).
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkCocoaRenderWindow::GetGenericDisplayId
void * GetGenericDisplayId() override
Definition: vtkCocoaRenderWindow.h:161
vtkX3D::height
Definition: vtkX3D.h:260
vtkOpenGLRenderWindow::InitializeFromCurrentContext
bool InitializeFromCurrentContext() override
Initialize the render window from the information associated with the currently activated OpenGL cont...
vtkRenderWindow::MakeCurrent
void MakeCurrent() override
Attempt to make this window the current graphics context for the calling thread.
Definition: vtkRenderWindow.h:656
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkCocoaRenderWindow::SetNextWindowId
void SetNextWindowId(void *) override
Definition: vtkCocoaRenderWindow.h:181
vtkRenderWindow::SetParentInfo
void SetParentInfo(const char *) override
Definition: vtkRenderWindow.h:630
vtkWindow::GetScreenSize
virtual int * GetScreenSize()
Get the current size of the screen in pixels.
Definition: vtkWindow.h:105
vtkRenderWindow::SetStereoCapableWindow
virtual void SetStereoCapableWindow(vtkTypeBool capable)
vtkCocoaRenderWindow::OnScreenInitialized
vtkTypeBool OnScreenInitialized
Definition: vtkCocoaRenderWindow.h:407
vtkRenderWindow::SetParentId
void SetParentId(void *) override
Definition: vtkRenderWindow.h:622
vtkCocoaRenderWindow::GetPlatformSupportsRenderWindowSharing
bool GetPlatformSupportsRenderWindowSharing() override
Does this platform support render window data sharing.
Definition: vtkCocoaRenderWindow.h:195
vtkCocoaRenderWindow::SetPosition
void SetPosition(int a[2]) override
Definition: vtkCocoaRenderWindow.h:126
vtkCocoaRenderWindow::SetSize
void SetSize(int a[2]) override
Definition: vtkCocoaRenderWindow.h:110
vtkCocoaRenderWindow
Cocoa OpenGL rendering window.
Definition: vtkCocoaRenderWindow.h:49
vtkCocoaRenderWindow::GetGenericParentId
void * GetGenericParentId() override
Definition: vtkCocoaRenderWindow.h:353
vtkOpenGLRenderWindow::Frame
void Frame() override
A termination method performed at the end of the rendering process to do things like swapping buffers...
vtkRenderWindow::SetFullScreen
virtual void SetFullScreen(vtkTypeBool)
Turn on/off rendering full screen window size.
Definition: vtkRenderWindow.h:228
vtkOpenGLRenderWindow::DestroyWindow
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
vtkCocoaRenderWindow::GetGenericWindowId
void * GetGenericWindowId() override
Definition: vtkCocoaRenderWindow.h:337
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:53
vtkOpenGLRenderWindow::Start
void Start(void) override
Begin the rendering process.
vtkRenderWindow::IsCurrent
virtual bool IsCurrent()
Tells if this window is the current graphics context for the calling thread.
Definition: vtkRenderWindow.h:662
vtkRenderWindow::VTK_DEPRECATED_IN_9_1_0
VTK_DEPRECATED_IN_9_1_0("Deprecated in 9.1 because no one knows what it's for and nothing uses it") virtual bool IsDrawable()
Test if the window has a valid drawable.
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:333
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkOpenGLRenderWindow::Initialize
virtual void Initialize(void)
Initialize the rendering window.
Definition: vtkOpenGLRenderWindow.h:302
vtkOpenGLRenderWindow::CreateAWindow
virtual void CreateAWindow()=0
Create a not-off-screen window.
vtkOpenGLRenderWindow.h