VTK  9.2.20230326
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 VTK_ABI_NAMESPACE_BEGIN
50 class VTKRENDERINGOPENGL2_EXPORT vtkCocoaRenderWindow : public vtkOpenGLRenderWindow
51 {
52 public:
55  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
60  void Start() override;
61 
65  void Frame() override;
66 
70  virtual void WindowConfigure();
71 
80  void Initialize() override;
81 
88  void SetFullScreen(vtkTypeBool) override;
89 
93  void WindowRemap() override;
94 
99  virtual void PrefFullScreen();
100 
102 
110  void SetSize(int width, int height) override;
111  void SetSize(int a[2]) override { this->SetSize(a[0], a[1]); }
113 
118  int* GetSize() VTK_SIZEHINT(2) override;
119 
121 
126  void SetPosition(int x, int y) override;
127  void SetPosition(int a[2]) override { this->SetPosition(a[0], a[1]); }
129 
134  int* GetScreenSize() VTK_SIZEHINT(2) override;
135 
140  int* GetPosition() VTK_SIZEHINT(2) override;
141 
146  void SetWindowName(const char*) override;
147 
148  void SetNextWindowInfo(const char*) override
149  {
150  vtkDebugMacro("SetNextWindowInfo not implemented (WindowRemap not implemented).");
151  }
152  void* GetGenericDrawable() override
153  {
154  vtkDebugMacro("Method not implemented.");
155  return nullptr;
156  }
157 
165  void SetDisplayId(void* displayId) override
166  {
167  this->DisplayIndex = displayId ? *(reinterpret_cast<int*>(displayId)) : 0;
168  }
169 
170  void* GetGenericDisplayId() override
171  {
172  vtkDebugMacro("Method not implemented.");
173  return nullptr;
174  }
175 
181  void SetWindowInfo(const char*) override;
182 
188  void SetParentInfo(const char*) override;
189 
190  void SetNextWindowId(void*) override
191  {
192  vtkDebugMacro("SetNextWindowId not implemented (WindowRemap not implemented).");
193  }
194 
200 
204  bool GetPlatformSupportsRenderWindowSharing() override { return true; }
205 
212  void SetStereoCapableWindow(vtkTypeBool capable) override;
213 
217  void MakeCurrent() override;
218 
222  void ReleaseCurrent() override;
223 
227  bool IsCurrent() override;
228 
233 
237  const char* ReportCapabilities() override;
238 
242  vtkTypeBool IsDirect() override;
243 
249  void SetForceMakeCurrent() override;
250 
256 
258 
261  virtual void SetupPalette(void* hDC);
262  virtual void SetupPixelFormat(void* hDC, void* dwFlags, int debug, int bpp = 16, int zbpp = 16);
264 
268  void Finalize() override;
269 
271 
277  void HideCursor() override;
278  void ShowCursor() override;
279  void SetCursorPosition(int x, int y) override;
281 
285  void SetCurrentCursor(int) override;
286 
292 
298 
300 
303  void SetContextId(void*);
304  void* GetContextId();
305  void* GetGenericContext() override { return this->GetContextId(); }
307 
318  virtual void SetRootWindow(void*);
319 
323  virtual void* GetRootWindow();
324 
335  void SetWindowId(void*) override;
336 
340  virtual void* GetWindowId();
341  void* GetGenericWindowId() override { return this->GetWindowId(); }
342 
349  void SetParentId(void* nsview) override;
350 
356  virtual void* GetParentId();
357  void* GetGenericParentId() override { return this->GetParentId(); }
358 
369  void SetWantsBestResolution(bool wantsBest);
371 
380 
382 
385  void SetPixelFormat(void* pixelFormat);
386  void* GetPixelFormat();
388 
390 
397  void PushContext() override;
398  void PopContext() override;
400 
401 protected:
404 
405  std::stack<void*> ContextStack;
406 
408 
409  void CreateAWindow() override;
410  void DestroyWindow() override;
412 
414 
418  void SetCocoaManager(void* manager);
421 
422  void SetCocoaServer(void* server); // Really a vtkCocoaServer*
423  void* GetCocoaServer();
424 
425 private:
427  void operator=(const vtkCocoaRenderWindow&) = delete;
428 
429 private:
430  // Important: this class cannot contain Objective-C instance
431  // variables for 2 reasons:
432  // 1) C++ files include this header
433  // 2) because of garbage collection (the GC scanner does not scan objects create by C++'s new)
434  // Instead, use the CocoaManager dictionary to keep a collection
435  // of what would otherwise be Objective-C instance variables.
436  void* CocoaManager; // Really an NSMutableDictionary*
437 
438  vtkTypeBool WindowCreated;
439  vtkTypeBool ViewCreated;
440  vtkTypeBool CursorHidden;
441 
442  vtkTypeBool ForceMakeCurrent;
443 
444  bool WantsBestResolution;
445  bool ConnectContextToNSView;
446 
447  int DisplayIndex = 0;
448 };
449 
450 VTK_ABI_NAMESPACE_END
451 #endif
Cocoa OpenGL rendering window.
virtual void SetRootWindow(void *)
Sets the NSWindow* associated with this vtkRenderWindow.
const char * ReportCapabilities() override
Get report of capabilities for the render window.
void SetWindowInfo(const char *) override
Set this RenderWindow's window id to a pre-existing window.
void SetDisplayId(void *displayId) override
Set the index of the NSScreen on which the window should be created.
int * GetSize() override
Get the size (width and height) of the rendering window in screen coordinates (in pixels).
void SetParentInfo(const char *) override
See the documentation for SetParentId().
void SetSize(int a[2]) override
Set the size (width and height) of the rendering window in screen coordinates (in pixels).
void WindowRemap() override
Remap the window.
void * GetGenericDisplayId() override
Dummy stubs for vtkWindow API.
void SetParentId(void *nsview) override
Set the NSView* for the vtkRenderWindow to be parented within.
void SetCocoaServer(void *server)
void SetCocoaManager(void *manager)
Accessors for the cocoa manager (Really an NSMutableDictionary*).
void SetFullScreen(vtkTypeBool) override
Change the window to fill the entire screen.
void SetCurrentCursor(int) override
Change the shape of the cursor.
void SetCursorPosition(int x, int y) override
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
void SetStereoCapableWindow(vtkTypeBool capable) override
Prescribe that the window be created in a stereo-capable mode.
void PushContext() override
Ability to push and pop this window's context as the current context.
void SetConnectContextToNSView(bool connect)
Set to false if you want to prevent the NSOpenGLContext from being associated with the NSView.
vtkTypeBool GetEventPending() override
Check to see if an event is pending for this window.
void CreateAWindow() override
Create a not-off-screen window.
void * GetGenericWindowId() override
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 * GetPixelFormat()
Accessors for the pixel format object (Really an NSOpenGLPixelFormat*).
void SetPixelFormat(void *pixelFormat)
Accessors for the pixel format object (Really an NSOpenGLPixelFormat*).
void PopContext() override
Ability to push and pop this window's context as the current context.
void Frame() override
Finish the rendering process.
static vtkCocoaRenderWindow * New()
void Initialize() override
Initialize the window for rendering.
virtual void SetupPixelFormat(void *hDC, void *dwFlags, int debug, int bpp=16, int zbpp=16)
Initialize OpenGL for this window.
void * GetCocoaManager()
Accessors for the cocoa manager (Really an NSMutableDictionary*).
void DestroyWindow() override
Destroy a not-off-screen window.
void * GetGenericContext() override
Accessors for the OpenGL context (Really an NSOpenGLContext*).
void SetWantsBestResolution(bool wantsBest)
Set to true if you want to force NSViews created by this object to have their wantsBestResolutionOpen...
void Finalize() override
Clean up device contexts, rendering contexts, etc.
~vtkCocoaRenderWindow() override
void Start() override
Begin the rendering process.
void ShowCursor() override
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
virtual vtkTypeBool GetWindowCreated()
Get the WindowCreated flag.
bool IsCurrent() override
Tells if this window is the current OpenGL context for the calling thread.
bool GetPlatformSupportsRenderWindowSharing() override
Does this platform support render window data sharing.
int * GetScreenSize() override
Get the current size of the screen in pixels.
void * GetContextId()
Accessors for the OpenGL context (Really an NSOpenGLContext*).
void SetContextId(void *)
Accessors for the OpenGL context (Really an NSOpenGLContext*).
virtual void * GetParentId()
Get the parent NSView* for this vtkRenderWindow.
void SetPosition(int a[2]) override
Set the position (x and y) of the rendering window in screen coordinates (in pixels).
virtual void * GetRootWindow()
Returns the NSWindow* associated with this vtkRenderWindow.
virtual vtkTypeBool GetViewCreated()
Get the ViewCreated flag.
void SetNextWindowId(void *) override
Dummy stubs for vtkWindow API.
void SetSize(int width, int height) override
Set the size (width and height) of the rendering window in screen coordinates (in pixels).
void * GetGenericParentId() override
Dummy stubs for vtkWindow API.
void SetForceMakeCurrent() override
If called, allow MakeCurrent() to skip cache-check when called.
bool GetConnectContextToNSView()
void SetWindowId(void *) override
Sets the NSView* associated with this vtkRenderWindow.
void HideCursor() override
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
bool InitializeFromCurrentContext() override
Initialize the render window from the information associated with the currently activated OpenGL cont...
virtual void * GetWindowId()
Returns the NSView* associated with this vtkRenderWindow.
void MakeCurrent() override
Make this windows OpenGL context the current context.
void UpdateContext()
Update this window's OpenGL context, e.g.
virtual void PrefFullScreen()
Set the preferred window size to full screen.
virtual void SetupPalette(void *hDC)
Initialize OpenGL for this window.
virtual void WindowConfigure()
Specify various window parameters.
void ReleaseCurrent() override
Release the current context.
std::stack< void * > ContextStack
vtkTypeBool IsDirect() override
Is this render window using hardware acceleration? 0-false, 1-true.
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.
a simple class to control print indentation
Definition: vtkIndent.h:120
OpenGL rendering window.
@ connect
Definition: vtkX3D.h:188
@ height
Definition: vtkX3D.h:266
int vtkTypeBool
Definition: vtkABI.h:71
#define VTK_SIZEHINT(...)