VTK  9.6.20260202
vtkCocoaRenderWindow.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
29
30#ifndef vtkCocoaRenderWindow_h
31#define vtkCocoaRenderWindow_h
32
34#include "vtkRenderingOpenGL2Module.h" // For export macro
35#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
36#include <stack> // for ivar
37
38VTK_ABI_NAMESPACE_BEGIN
40class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkCocoaRenderWindow : public vtkOpenGLRenderWindow
41{
42public:
47 void PrintSelf(ostream& os, vtkIndent indent) override;
48
52 void Start() override;
53
57 void Frame() override;
58
62 virtual void WindowConfigure();
63
68
72 void Initialize() override;
73
80 void SetFullScreen(vtkTypeBool) override;
81
85 void WindowRemap() override;
86
91 virtual void PrefFullScreen();
92
94
102 void SetSize(int width, int height) override;
103 void SetSize(int a[2]) override { this->SetSize(a[0], a[1]); }
105
110 int* GetSize() VTK_SIZEHINT(2) override;
111
113
118 void SetPosition(int x, int y) override;
119 void SetPosition(int a[2]) override { this->SetPosition(a[0], a[1]); }
121
126 int* GetScreenSize() VTK_SIZEHINT(2) override;
127
132 int* GetPosition() VTK_SIZEHINT(2) override;
133
138 void SetWindowName(const char*) override;
139
140 void SetNextWindowInfo(const char*) override
141 {
142 vtkDebugMacro("SetNextWindowInfo not implemented (WindowRemap not implemented).");
143 }
144 void* GetGenericDrawable() override
145 {
146 vtkDebugMacro("Method not implemented.");
147 return nullptr;
148 }
149
157 void SetDisplayId(void* displayId) override
158 {
159 this->DisplayIndex = displayId ? *(reinterpret_cast<int*>(displayId)) : 0;
160 }
161
162 void* GetGenericDisplayId() override
163 {
164 vtkDebugMacro("Method not implemented.");
165 return nullptr;
166 }
167
173 void SetWindowInfo(const char*) override;
174
180 void SetParentInfo(const char*) override;
181
182 void SetNextWindowId(void*) override
183 {
184 vtkDebugMacro("SetNextWindowId not implemented (WindowRemap not implemented).");
185 }
186
192
196 bool GetPlatformSupportsRenderWindowSharing() override { return true; }
197
204 void SetStereoCapableWindow(vtkTypeBool capable) override;
205
209 void MakeCurrent() override;
210
214 void ReleaseCurrent() override;
215
219 bool IsCurrent() override;
220
225
229 const char* ReportCapabilities() override;
230
235
241 void SetForceMakeCurrent() override;
242
248
250
253 virtual void SetupPalette(void* hDC);
254 virtual void SetupPixelFormat(void* hDC, void* dwFlags, int debug, int bpp = 16, int zbpp = 16);
256
260 void Finalize() override;
261
263
269 void HideCursor() override;
270 void ShowCursor() override;
271 void SetCursorPosition(int x, int y) override;
273
277 void SetCurrentCursor(int) override;
278
284
290
292
296 void SetContextId(void*);
299 void* GetGenericContext() override { return this->GetContextId(); }
301
313 virtual void SetRootWindow(void*);
314
319 virtual void* GetRootWindow();
320
332 void SetWindowId(void*) override;
333
338 virtual void* GetWindowId();
339 void* GetGenericWindowId() override { return this->GetWindowId(); }
340
348 void SetParentId(void* nsview) override;
349
356 virtual void* GetParentId();
357 void* GetGenericParentId() override { return this->GetParentId(); }
358
369 void SetWantsBestResolution(bool wantsBest);
371
378 void SetConnectContextToNSView(bool connect);
380
382
386 void SetPixelFormat(void* pixelFormat);
390
392
399 void PushContext() override;
400 void PopContext() override;
402
403 void Render() override;
404
405protected:
408
409 std::stack<void*> ContextStack;
410
412
413 void CreateAWindow() override;
414 void DestroyWindow() override;
416
418
422 void SetCocoaManager(void* manager);
425
426 void SetCocoaServer(void* server); // Really a vtkCocoaServer*
428
429private:
431 void operator=(const vtkCocoaRenderWindow&) = delete;
432
433private:
434 // Important: this class cannot contain Objective-C instance
435 // variables for 2 reasons:
436 // 1) C++ files include this header
437 // 2) because of garbage collection (the GC scanner does not scan objects create by C++'s new)
438 // Instead, use the CocoaManager dictionary to keep a collection
439 // of what would otherwise be Objective-C instance variables.
440 void* CocoaManager; // Really an NSMutableDictionary*
441
442 vtkTypeBool WindowCreated;
443 vtkTypeBool ViewCreated;
444 vtkTypeBool CursorHidden;
445
446 vtkTypeBool ForceMakeCurrent;
447
448 bool WantsBestResolution;
449 bool ConnectContextToNSView;
450
451 int DisplayIndex = 0;
452};
453
454#define vtkCocoaRenderWindow_OVERRIDE_ATTRIBUTES vtkCocoaRenderWindow::CreateOverrideAttributes()
455VTK_ABI_NAMESPACE_END
456#endif
virtual void SetRootWindow(void *)
Sets the NSWindow* associated with this vtkRenderWindow.
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.
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).
virtual void * GetParentId()
Get the parent NSView* for this vtkRenderWindow.
void WindowRemap() override
Remap the window.
void * GetGenericDisplayId() override
These are window system independent methods that are used to help interface vtkWindow to native windo...
void SetParentId(void *nsview) override
Set the NSView* for the vtkRenderWindow to be parented within.
void * GetCocoaManager()
Accessors for the cocoa manager (Really an NSMutableDictionary*).
int * GetPosition() override
Get the position (x and y) of the rendering window in screen coordinates (in pixels).
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 * GetGenericWindowId() override
These are window system independent methods that are used to help interface vtkWindow to native windo...
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.
const char * ReportCapabilities() override
Get report of capabilities for the render window.
void SetConnectContextToNSView(bool connect)
Set to false if you want to prevent the NSOpenGLContext from being associated with the NSView.
void SetPosition(int x, int y) override
Set the position (x and y) of the rendering window in screen coordinates (in pixels).
vtkTypeBool GetEventPending() override
Check to see if an event is pending for this window.
void CreateAWindow() override
Create a not-off-screen window.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetPixelFormat(void *pixelFormat)
Accessors for the pixel format object (Really an NSOpenGLPixelFormat*).
int * GetScreenSize() override
Get the current size of the screen in pixels.
static vtkOverrideAttribute * CreateOverrideAttributes()
void PopContext() override
Ability to push and pop this window's context as the current context.
void Frame() override
Finish the rendering process.
int * GetSize() override
Get the size (width and height) of the rendering window in screen coordinates (in pixels).
virtual void * GetWindowId()
Returns the NSView* associated with this vtkRenderWindow.
void Initialize() override
Initialize the window for rendering.
void * GetGenericContext() override
Accessors for the OpenGL context (Really an NSOpenGLContext*).
virtual void SetupPixelFormat(void *hDC, void *dwFlags, int debug, int bpp=16, int zbpp=16)
Initialize OpenGL for this window.
void DestroyWindow() override
Destroy a not-off-screen window.
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.
void * GetContextId()
Accessors for the OpenGL context (Really an NSOpenGLContext*).
virtual void * GetRootWindow()
Returns the NSWindow* associated with this vtkRenderWindow.
void Start() override
Begin the rendering process.
void * GetPixelFormat()
Accessors for the pixel format object (Really an NSOpenGLPixelFormat*).
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.
static vtkCocoaRenderWindow * New()
void SetContextId(void *)
Accessors for the OpenGL context (Really an NSOpenGLContext*).
void SetPosition(int a[2]) override
Set the position (x and y) of the rendering window in screen coordinates (in pixels).
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 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...
void MakeCurrent() override
Make this windows OpenGL context the current context.
void * GetGenericDrawable() override
These are window system independent methods that are used to help interface vtkWindow to native windo...
void SetWindowName(const char *) override
Set the name of the window.
void Render() override
Ask each viewport owned by this Window to render its image and synchronize this process.
void UpdateContext()
Update this window's OpenGL context, e.g.
virtual void PrefFullScreen()
Set the preferred window size to full screen.
void * GetGenericParentId() override
These are window system independent methods that are used to help interface vtkWindow to native windo...
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
void SetNextWindowInfo(const char *) override
Dummy stubs for vtkWindow API.
vtkTypeBool IsDirect() override
Is this render window using hardware acceleration?
a simple class to control print indentation
Definition vtkIndent.h:108
Attribute for vtkObjectFactory overrides.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)
#define VTK_MARSHAL_EXCLUDE_REASON_NOT_SUPPORTED
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)
#define VTK_NEWINSTANCE