VTK  9.4.20250105
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
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
39class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkCocoaRenderWindow : public vtkOpenGLRenderWindow
40{
41public:
44 void PrintSelf(ostream& os, vtkIndent indent) override;
45
49 void Start() override;
50
54 void Frame() override;
55
59 virtual void WindowConfigure();
60
69 void Initialize() override;
70
77 void SetFullScreen(vtkTypeBool) override;
78
82 void WindowRemap() override;
83
88 virtual void PrefFullScreen();
89
91
99 void SetSize(int width, int height) override;
100 void SetSize(int a[2]) override { this->SetSize(a[0], a[1]); }
102
107 int* GetSize() VTK_SIZEHINT(2) override;
108
110
115 void SetPosition(int x, int y) override;
116 void SetPosition(int a[2]) override { this->SetPosition(a[0], a[1]); }
118
123 int* GetScreenSize() VTK_SIZEHINT(2) override;
124
129 int* GetPosition() VTK_SIZEHINT(2) override;
130
135 void SetWindowName(const char*) override;
136
137 void SetNextWindowInfo(const char*) override
138 {
139 vtkDebugMacro("SetNextWindowInfo not implemented (WindowRemap not implemented).");
140 }
141 void* GetGenericDrawable() override
142 {
143 vtkDebugMacro("Method not implemented.");
144 return nullptr;
145 }
146
154 void SetDisplayId(void* displayId) override
155 {
156 this->DisplayIndex = displayId ? *(reinterpret_cast<int*>(displayId)) : 0;
157 }
158
159 void* GetGenericDisplayId() override
160 {
161 vtkDebugMacro("Method not implemented.");
162 return nullptr;
163 }
164
170 void SetWindowInfo(const char*) override;
171
177 void SetParentInfo(const char*) override;
178
179 void SetNextWindowId(void*) override
180 {
181 vtkDebugMacro("SetNextWindowId not implemented (WindowRemap not implemented).");
182 }
183
189
193 bool GetPlatformSupportsRenderWindowSharing() override { return true; }
194
201 void SetStereoCapableWindow(vtkTypeBool capable) override;
202
206 void MakeCurrent() override;
207
211 void ReleaseCurrent() override;
212
216 bool IsCurrent() override;
217
222
226 const char* ReportCapabilities() override;
227
232
238 void SetForceMakeCurrent() override;
239
245
247
250 virtual void SetupPalette(void* hDC);
251 virtual void SetupPixelFormat(void* hDC, void* dwFlags, int debug, int bpp = 16, int zbpp = 16);
253
257 void Finalize() override;
258
260
266 void HideCursor() override;
267 void ShowCursor() override;
268 void SetCursorPosition(int x, int y) override;
270
274 void SetCurrentCursor(int) override;
275
281
287
289
293 void SetContextId(void*);
295 void* GetContextId();
296 void* GetGenericContext() override { return this->GetContextId(); }
298
310 virtual void SetRootWindow(void*);
311
316 virtual void* GetRootWindow();
317
329 void SetWindowId(void*) override;
330
335 virtual void* GetWindowId();
336 void* GetGenericWindowId() override { return this->GetWindowId(); }
337
345 void SetParentId(void* nsview) override;
346
353 virtual void* GetParentId();
354 void* GetGenericParentId() override { return this->GetParentId(); }
355
366 void SetWantsBestResolution(bool wantsBest);
368
375 void SetConnectContextToNSView(bool connect);
377
379
383 void SetPixelFormat(void* pixelFormat);
385 void* GetPixelFormat();
387
389
396 void PushContext() override;
397 void PopContext() override;
399
400 void Render() override;
401
402protected:
405
406 std::stack<void*> ContextStack;
407
408 void CreateGLContext();
409
410 void CreateAWindow() override;
411 void DestroyWindow() override;
412 vtkTypeBool OnScreenInitialized;
413
415
419 void SetCocoaManager(void* manager);
420 void* GetCocoaManager();
422
423 void SetCocoaServer(void* server); // Really a vtkCocoaServer*
424 void* GetCocoaServer();
425
426private:
428 void operator=(const vtkCocoaRenderWindow&) = delete;
429
430private:
431 // Important: this class cannot contain Objective-C instance
432 // variables for 2 reasons:
433 // 1) C++ files include this header
434 // 2) because of garbage collection (the GC scanner does not scan objects create by C++'s new)
435 // Instead, use the CocoaManager dictionary to keep a collection
436 // of what would otherwise be Objective-C instance variables.
437 void* CocoaManager; // Really an NSMutableDictionary*
438
439 vtkTypeBool WindowCreated;
440 vtkTypeBool ViewCreated;
441 vtkTypeBool CursorHidden;
442
443 vtkTypeBool ForceMakeCurrent;
444
445 bool WantsBestResolution;
446 bool ConnectContextToNSView;
447
448 int DisplayIndex = 0;
449};
450
451VTK_ABI_NAMESPACE_END
452#endif
Cocoa OpenGL rendering 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.
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
These are window system independent methods that are used to help interface vtkWindow to native windo...
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.
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.
vtkTypeBool GetEventPending() override
Check to see if an event is pending for this window.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int * GetScreenSize() override
Get the current size of the screen in pixels.
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).
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 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 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.
static vtkCocoaRenderWindow * New()
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 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 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.
vtkTypeBool IsDirect() override
Is this render window using hardware acceleration? 0-false, 1-true.
a simple class to control print indentation
Definition vtkIndent.h:108
OpenGL rendering window.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)
#define VTK_MARSHAL_EXCLUDE_REASON_NOT_SUPPORTED
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)