VTK: Rendering/OpenGL2/vtkCocoaRenderWindow.h Source File

| VTK 9.3.1

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
33 #include "vtkOpenGLRenderWindow.h"
34 #include "vtkRenderingOpenGL2Module.h" // For export macro
35 #include <stack> // for ivar
36
37 VTK_ABI_NAMESPACE_BEGIN
38 class VTKRENDERINGOPENGL2_EXPORT vtkCocoaRenderWindow : public vtkOpenGLRenderWindow
39 {
40 public:
41 static vtkCocoaRenderWindow* New();
42 vtkTypeMacro(vtkCocoaRenderWindow, vtkOpenGLRenderWindow);
43 void PrintSelf(ostream& os, vtkIndent indent) override;
44
48 void Start() override;
49
53 void Frame() override;
54
58 virtual void WindowConfigure();
59
68 void Initialize() override;
69
76 void SetFullScreen(vtkTypeBool) override;
77
81 void WindowRemap() override;
82
87 virtual void PrefFullScreen();
88
90
98 void SetSize(int width, int height) override;
99 void SetSize(int a[2]) override { this->SetSize(a[0], a[1]); }
101
106 int* GetSize() VTK_SIZEHINT(2) override;
107
109
114 void SetPosition(int x, int y) override;
115 void SetPosition(int a[2]) override { this->SetPosition(a[0], a[1]); }
117
122 int* GetScreenSize() VTK_SIZEHINT(2) override;
123
128 int* GetPosition() VTK_SIZEHINT(2) override;
129
134 void SetWindowName(const char*) override;
135
136 void SetNextWindowInfo(const char*) override
137 {
138 vtkDebugMacro("SetNextWindowInfo not implemented (WindowRemap not implemented).");
139 }
140 void* GetGenericDrawable() override
141 {
142 vtkDebugMacro("Method not implemented.");
143 return nullptr;
144 }
145
153 void SetDisplayId(void* displayId) override
154 {
155 this->DisplayIndex = displayId ? *(reinterpret_cast<int*>(displayId)) : 0;
156 }
157
158 void* GetGenericDisplayId() override
159 {
160 vtkDebugMacro("Method not implemented.");
161 return nullptr;
162 }
163
169 void SetWindowInfo(const char*) override;
170
176 void SetParentInfo(const char*) override;
177
178 void SetNextWindowId(void*) override
179 {
180 vtkDebugMacro("SetNextWindowId not implemented (WindowRemap not implemented).");
181 }
182
187 bool InitializeFromCurrentContext() override;
188
192 bool GetPlatformSupportsRenderWindowSharing() override { return true; }
193
200 void SetStereoCapableWindow(vtkTypeBool capable) override;
201
205 void MakeCurrent() override;
206
210 void ReleaseCurrent() override;
211
215 bool IsCurrent() override;
216
220 void UpdateContext();
221
225 const char* ReportCapabilities() override;
226
230 vtkTypeBool IsDirect() override;
231
237 void SetForceMakeCurrent() override;
238
243 vtkTypeBool GetEventPending() override;
244
246
249 virtual void SetupPalette(void* hDC);
250 virtual void SetupPixelFormat(void* hDC, void* dwFlags, int debug, int bpp = 16, int zbpp = 16);
252
256 void Finalize() override;
257
259
265 void HideCursor() override;
266 void ShowCursor() override;
267 void SetCursorPosition(int x, int y) override;
269
273 void SetCurrentCursor(int) override;
274
279 virtual vtkTypeBool GetViewCreated();
280
285 virtual vtkTypeBool GetWindowCreated();
286
288
291 void SetContextId(void*);
292 void* GetContextId();
293 void* GetGenericContext() override { return this->GetContextId(); }
295
306 virtual void SetRootWindow(void*);
307
311 virtual void* GetRootWindow();
312
323 void SetWindowId(void*) override;
324
328 virtual void* GetWindowId();
329 void* GetGenericWindowId() override { return this->GetWindowId(); }
330
337 void SetParentId(void* nsview) override;
338
344 virtual void* GetParentId();
345 void* GetGenericParentId() override { return this->GetParentId(); }
346
357 void SetWantsBestResolution(bool wantsBest);
358 bool GetWantsBestResolution();
359
366 void SetConnectContextToNSView(bool connect);
367 bool GetConnectContextToNSView();
368
370
373 void SetPixelFormat(void* pixelFormat);
374 void* GetPixelFormat();
376
378
385 void PushContext() override;
386 void PopContext() override;
388
389 void Render() override;
390
391 protected:
392 vtkCocoaRenderWindow();
393 ~vtkCocoaRenderWindow() override;
394
395 std::stack<void*> ContextStack;
396
397 void CreateGLContext();
398
399 void CreateAWindow() override;
400 void DestroyWindow() override;
401 vtkTypeBool OnScreenInitialized;
402
404
408 void SetCocoaManager(void* manager);
409 void* GetCocoaManager();
411
412 void SetCocoaServer(void* server); // Really a vtkCocoaServer*
413 void* GetCocoaServer();
414
415 private:
416 vtkCocoaRenderWindow(const vtkCocoaRenderWindow&) = delete;
417 void operator=(const vtkCocoaRenderWindow&) = delete;
418
419 private:
420 // Important: this class cannot contain Objective-C instance
421 // variables for 2 reasons:
422 // 1) C++ files include this header
423 // 2) because of garbage collection (the GC scanner does not scan objects create by C++'s new)
424 // Instead, use the CocoaManager dictionary to keep a collection
425 // of what would otherwise be Objective-C instance variables.
426 void* CocoaManager; // Really an NSMutableDictionary*
427
428 vtkTypeBool WindowCreated;
429 vtkTypeBool ViewCreated;
430 vtkTypeBool CursorHidden;
431
432 vtkTypeBool ForceMakeCurrent;
433
434 bool WantsBestResolution;
435 bool ConnectContextToNSView;
436
437 int DisplayIndex = 0;
438 };
439
440 VTK_ABI_NAMESPACE_END
441 #endif
vtkCocoaRenderWindow
Cocoa OpenGL rendering window.
Definition: vtkCocoaRenderWindow.h:39
vtkCocoaRenderWindow::SetRootWindow
virtual void SetRootWindow(void *)
Sets the NSWindow* associated with this vtkRenderWindow.
vtkCocoaRenderWindow::ReportCapabilities
const char * ReportCapabilities() override
Get report of capabilities for the render window.
vtkCocoaRenderWindow::SetWindowInfo
void SetWindowInfo(const char *) override
Set this RenderWindow's window id to a pre-existing window.
vtkCocoaRenderWindow::SetDisplayId
void SetDisplayId(void *displayId) override
Set the index of the NSScreen on which the window should be created.
Definition: vtkCocoaRenderWindow.h:153
vtkCocoaRenderWindow::GetSize
int * GetSize() override
Get the size (width and height) of the rendering window in screen coordinates (in pixels).
vtkCocoaRenderWindow::SetParentInfo
void SetParentInfo(const char *) override
See the documentation for SetParentId().
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:99
vtkCocoaRenderWindow::WindowRemap
void WindowRemap() override
Remap the window.
vtkCocoaRenderWindow::GetGenericDisplayId
void * GetGenericDisplayId() override
Dummy stubs for vtkWindow API.
Definition: vtkCocoaRenderWindow.h:158
vtkCocoaRenderWindow::SetParentId
void SetParentId(void *nsview) override
Set the NSView* for the vtkRenderWindow to be parented within.
vtkCocoaRenderWindow::SetCocoaServer
void SetCocoaServer(void *server)
vtkCocoaRenderWindow::SetCocoaManager
void SetCocoaManager(void *manager)
Accessors for the cocoa manager (Really an NSMutableDictionary*).
vtkCocoaRenderWindow::SetFullScreen
void SetFullScreen(vtkTypeBool) override
Change the window to fill the entire screen.
vtkCocoaRenderWindow::SetCurrentCursor
void SetCurrentCursor(int) override
Change the shape of the cursor.
vtkCocoaRenderWindow::SetCursorPosition
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...
vtkCocoaRenderWindow::GetCocoaServer
void * GetCocoaServer()
vtkCocoaRenderWindow::SetStereoCapableWindow
void SetStereoCapableWindow(vtkTypeBool capable) override
Prescribe that the window be created in a stereo-capable mode.
vtkCocoaRenderWindow::PushContext
void PushContext() override
Ability to push and pop this window's context as the current context.
vtkCocoaRenderWindow::SetConnectContextToNSView
void SetConnectContextToNSView(bool connect)
Set to false if you want to prevent the NSOpenGLContext from being associated with the NSView.
vtkCocoaRenderWindow::GetEventPending
vtkTypeBool GetEventPending() override
Check to see if an event is pending for this window.
vtkCocoaRenderWindow::CreateAWindow
void CreateAWindow() override
Create a not-off-screen window.
vtkCocoaRenderWindow::GetGenericWindowId
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
Definition: vtkCocoaRenderWindow.h:329
vtkCocoaRenderWindow::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkCocoaRenderWindow::GetWantsBestResolution
bool GetWantsBestResolution()
vtkCocoaRenderWindow::GetPixelFormat
void * GetPixelFormat()
Accessors for the pixel format object (Really an NSOpenGLPixelFormat*).
vtkCocoaRenderWindow::SetPixelFormat
void SetPixelFormat(void *pixelFormat)
Accessors for the pixel format object (Really an NSOpenGLPixelFormat*).
vtkCocoaRenderWindow::OnScreenInitialized
vtkTypeBool OnScreenInitialized
Definition: vtkCocoaRenderWindow.h:401
vtkCocoaRenderWindow::PopContext
void PopContext() override
Ability to push and pop this window's context as the current context.
vtkCocoaRenderWindow::Frame
void Frame() override
Finish the rendering process.
vtkCocoaRenderWindow::New
static vtkCocoaRenderWindow * New()
vtkCocoaRenderWindow::Initialize
void Initialize() override
Initialize the window for rendering.
vtkCocoaRenderWindow::SetupPixelFormat
virtual void SetupPixelFormat(void *hDC, void *dwFlags, int debug, int bpp=16, int zbpp=16)
Initialize OpenGL for this window.
vtkCocoaRenderWindow::GetCocoaManager
void * GetCocoaManager()
Accessors for the cocoa manager (Really an NSMutableDictionary*).
vtkCocoaRenderWindow::DestroyWindow
void DestroyWindow() override
Destroy a not-off-screen window.
vtkCocoaRenderWindow::GetGenericContext
void * GetGenericContext() override
Accessors for the OpenGL context (Really an NSOpenGLContext*).
Definition: vtkCocoaRenderWindow.h:293
vtkCocoaRenderWindow::SetWantsBestResolution
void SetWantsBestResolution(bool wantsBest)
Set to true if you want to force NSViews created by this object to have their wantsBestResolutionOpen...
vtkCocoaRenderWindow::Finalize
void Finalize() override
Clean up device contexts, rendering contexts, etc.
vtkCocoaRenderWindow::~vtkCocoaRenderWindow
~vtkCocoaRenderWindow() override
vtkCocoaRenderWindow::Start
void Start() override
Begin the rendering process.
vtkCocoaRenderWindow::ShowCursor
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...
vtkCocoaRenderWindow::GetWindowCreated
virtual vtkTypeBool GetWindowCreated()
Get the WindowCreated flag.
vtkCocoaRenderWindow::IsCurrent
bool IsCurrent() override
Tells if this window is the current OpenGL context for the calling thread.
vtkCocoaRenderWindow::GetPlatformSupportsRenderWindowSharing
bool GetPlatformSupportsRenderWindowSharing() override
Does this platform support render window data sharing.
Definition: vtkCocoaRenderWindow.h:192
vtkCocoaRenderWindow::vtkCocoaRenderWindow
vtkCocoaRenderWindow()
vtkCocoaRenderWindow::GetScreenSize
int * GetScreenSize() override
Get the current size of the screen in pixels.
vtkCocoaRenderWindow::GetContextId
void * GetContextId()
Accessors for the OpenGL context (Really an NSOpenGLContext*).
vtkCocoaRenderWindow::SetContextId
void SetContextId(void *)
Accessors for the OpenGL context (Really an NSOpenGLContext*).
vtkCocoaRenderWindow::GetParentId
virtual void * GetParentId()
Get the parent NSView* for this vtkRenderWindow.
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:115
vtkCocoaRenderWindow::GetRootWindow
virtual void * GetRootWindow()
Returns the NSWindow* associated with this vtkRenderWindow.
vtkCocoaRenderWindow::GetViewCreated
virtual vtkTypeBool GetViewCreated()
Get the ViewCreated flag.
vtkCocoaRenderWindow::SetNextWindowId
void SetNextWindowId(void *) override
Dummy stubs for vtkWindow API.
Definition: vtkCocoaRenderWindow.h:178
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::GetGenericParentId
void * GetGenericParentId() override
Dummy stubs for vtkWindow API.
Definition: vtkCocoaRenderWindow.h:345
vtkCocoaRenderWindow::SetForceMakeCurrent
void SetForceMakeCurrent() override
If called, allow MakeCurrent() to skip cache-check when called.
vtkCocoaRenderWindow::GetConnectContextToNSView
bool GetConnectContextToNSView()
vtkCocoaRenderWindow::SetWindowId
void SetWindowId(void *) override
Sets the NSView* associated with this vtkRenderWindow.
vtkCocoaRenderWindow::HideCursor
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...
vtkCocoaRenderWindow::InitializeFromCurrentContext
bool InitializeFromCurrentContext() override
Initialize the render window from the information associated with the currently activated OpenGL cont...
vtkCocoaRenderWindow::GetWindowId
virtual void * GetWindowId()
Returns the NSView* associated with this vtkRenderWindow.
vtkCocoaRenderWindow::MakeCurrent
void MakeCurrent() override
Make this windows OpenGL context the current context.
vtkCocoaRenderWindow::CreateGLContext
void CreateGLContext()
vtkCocoaRenderWindow::Render
void Render() override
Ask each renderer owned by this RenderWindow to render its image and synchronize this process.
vtkCocoaRenderWindow::UpdateContext
void UpdateContext()
Update this window's OpenGL context, e.g.
vtkCocoaRenderWindow::PrefFullScreen
virtual void PrefFullScreen()
Set the preferred window size to full screen.
vtkCocoaRenderWindow::SetupPalette
virtual void SetupPalette(void *hDC)
Initialize OpenGL for this window.
vtkCocoaRenderWindow::WindowConfigure
virtual void WindowConfigure()
Specify various window parameters.
vtkCocoaRenderWindow::ReleaseCurrent
void ReleaseCurrent() override
Release the current context.
vtkCocoaRenderWindow::ContextStack
std::stack< void * > ContextStack
Definition: vtkCocoaRenderWindow.h:395
vtkCocoaRenderWindow::IsDirect
vtkTypeBool IsDirect() override
Is this render window using hardware acceleration? 0-false, 1-true.
vtkCocoaRenderWindow::GetGenericDrawable
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.
Definition: vtkCocoaRenderWindow.h:140
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:53
vtkX3D::connect
@ connect
Definition: vtkX3D.h:176
vtkX3D::height
@ height
Definition: vtkX3D.h:254
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64
vtkOpenGLRenderWindow.h
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:36