VTK  9.0.3
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:
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 
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 
221  VTK_LEGACY(bool IsDrawable() override);
222 
227 
231  const char* ReportCapabilities() override;
232 
236  vtkTypeBool IsDirect() override;
237 
243  void SetForceMakeCurrent() override;
244 
250 
252 
255  virtual void SetupPalette(void* hDC);
256  virtual void SetupPixelFormat(void* hDC, void* dwFlags, int debug, int bpp = 16, int zbpp = 16);
258 
262  void Finalize() override;
263 
265 
271  void HideCursor() override;
272  void ShowCursor() override;
273  void SetCursorPosition(int x, int y) override;
275 
279  void SetCurrentCursor(int) override;
280 
286 
292 
294 
297  void SetContextId(void*);
298  void* GetContextId();
299  void* GetGenericContext() override { return this->GetContextId(); }
301 
312  virtual void SetRootWindow(void*);
313 
317  virtual void* GetRootWindow();
318 
329  void SetWindowId(void*) override;
330 
334  virtual void* GetWindowId();
335  void* GetGenericWindowId() override { return this->GetWindowId(); }
336 
343  void SetParentId(void* nsview) override;
344 
350  virtual void* GetParentId();
351  void* GetGenericParentId() override { return this->GetParentId(); }
352 
363  void SetWantsBestResolution(bool wantsBest);
365 
374 
376 
379  void SetPixelFormat(void* pixelFormat);
380  void* GetPixelFormat();
382 
384 
391  void PushContext() override;
392  void PopContext() override;
394 
395 protected:
398 
399  std::stack<void*> ContextStack;
400 
402 
403  void CreateAWindow() override;
404  void DestroyWindow() override;
406 
408 
412  void SetCocoaManager(void* manager);
415 
416  void SetCocoaServer(void* server); // Really a vtkCocoaServer*
417  void* GetCocoaServer();
418 
419 private:
421  void operator=(const vtkCocoaRenderWindow&) = delete;
422 
423 private:
424  // Important: this class cannot contain Objective-C instance
425  // variables for 2 reasons:
426  // 1) C++ files include this header
427  // 2) because of garbage collection (the GC scanner does not scan objects create by C++'s new)
428  // Instead, use the CocoaManager dictionary to keep a collection
429  // of what would otherwise be Objective-C instance variables.
430  void* CocoaManager; // Really an NSMutableDictionary*
431 
432  vtkTypeBool WindowCreated;
433  vtkTypeBool ViewCreated;
434  vtkTypeBool CursorHidden;
435 
436  vtkTypeBool ForceMakeCurrent;
437 
438  bool WantsBestResolution;
439  bool ConnectContextToNSView;
440 };
441 
442 #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.
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
void WindowRemap() override
Remap the window.
void * GetGenericDisplayId() override
void SetParentId(void *nsview) override
Set the NSView* for the vtkRenderWindow to be parented within.
bool IsDrawable() override
Test if the window has a valid drawable.
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
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
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*).
void PopContext() override
void Frame() override
Finish the rendering process.
static vtkCocoaRenderWindow * New()
void Initialize() override
Initialize the window for rendering.
void SetDisplayId(void *) override
Dummy stubs for vtkWindow API.
virtual void SetupPixelFormat(void *hDC, void *dwFlags, int debug, int bpp=16, int zbpp=16)
void DestroyWindow() override
Destroy a not-off-screen window.
void * GetGenericContext() override
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
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 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
virtual void * GetRootWindow()
Returns the NSWindow* associated with this vtkRenderWindow.
virtual vtkTypeBool GetViewCreated()
Get the ViewCreated flag.
void SetNextWindowId(void *) override
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
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.
std::stack< void * > ContextStack
vtkTypeBool IsDirect() override
Is this render window using hardware acceleration? 0-false, 1-true.
void * GetGenericDrawable() override
a simple class to control print indentation
Definition: vtkIndent.h:34
OpenGL rendering window.
@ connect
Definition: vtkX3D.h:182
@ height
Definition: vtkX3D.h:260
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)