VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkCocoaRenderWindow.h,v $ 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00041 #ifndef __vtkCocoaRenderWindow_h 00042 #define __vtkCocoaRenderWindow_h 00043 00044 #include "vtkOpenGLRenderWindow.h" 00045 00046 class VTK_RENDERING_EXPORT vtkCocoaRenderWindow : public vtkOpenGLRenderWindow 00047 { 00048 public: 00049 static vtkCocoaRenderWindow *New(); 00050 vtkTypeRevisionMacro(vtkCocoaRenderWindow,vtkOpenGLRenderWindow); 00051 void PrintSelf(ostream& os, vtkIndent indent); 00052 00054 virtual void Start(); 00055 00057 virtual void Frame(); 00058 00060 virtual void WindowConfigure(); 00061 00065 virtual void Initialize(); 00066 00068 virtual void SetFullScreen(int); 00069 00071 virtual void WindowRemap(); 00072 00074 virtual void PrefFullScreen(); 00075 00077 00078 virtual void SetSize(int*); 00079 virtual void SetSize(int,int); 00081 00083 virtual int *GetSize(); 00084 00086 00087 virtual void SetPosition(int*); 00088 virtual void SetPosition(int,int); 00090 00092 virtual int *GetScreenSize(); 00093 00095 virtual int *GetPosition(); 00096 00099 virtual void SetWindowName(const char *); 00100 00101 void SetNextWindowInfo(char *) 00102 { 00103 vtkWarningMacro("SetNextWindowInfo not implemented (WindowRemap not implemented)."); 00104 } 00105 virtual void SetParentId(void *) 00106 { 00107 vtkWarningMacro("Method not implemented."); 00108 } 00109 virtual void* GetGenericParentId() 00110 { 00111 vtkWarningMacro("Method not implemented."); 00112 return 0; 00113 } 00114 virtual void* GetGenericDrawable() 00115 { 00116 vtkWarningMacro("Method not implemented."); 00117 return 0; 00118 } 00119 00123 virtual void SetWindowInfo(char*); 00124 00125 virtual void SetParentInfo(char*) 00126 { 00127 vtkWarningMacro("Method not implemented."); 00128 } 00129 void SetNextWindowId(void*) 00130 { 00131 vtkWarningMacro("SetNextWindowId not implemented (WindowRemap not implemented)."); 00132 } 00133 00134 00136 virtual void StereoUpdate(); 00137 00142 virtual void SetStereoCapableWindow(int capable); 00143 00145 virtual void MakeCurrent(); 00146 00149 virtual bool IsCurrent(); 00150 00152 void UpdateContext(); 00153 00155 const char *ReportCapabilities(); 00156 00158 int SupportsOpenGL(); 00159 00161 int IsDirect(); 00162 00166 virtual void SetForceMakeCurrent(); 00167 00170 virtual int GetEventPending(); 00171 00173 00174 virtual void SetupPalette(void *hDC); 00175 virtual void SetupPixelFormat(void *hDC, void *dwFlags, int debug, 00176 int bpp=16, int zbpp=16); 00178 00180 void Finalize(); 00181 00183 void RegisterTextureResource (GLuint id); 00184 00186 int GetDepthBufferSize(); 00187 00189 00192 virtual void HideCursor(); 00193 virtual void ShowCursor(); 00194 virtual void SetCursorPosition(int x, int y); 00196 00198 virtual void SetCurrentCursor(int); 00199 00202 virtual int GetWindowCreated(); 00203 00205 00206 void SetContextId(void *); 00207 void *GetContextId(); 00208 virtual void *GetGenericContext() {return this->GetContextId();} 00210 00219 virtual void SetWindowId(void *); 00220 00222 00223 virtual void *GetWindowId(); 00224 virtual void *GetGenericWindowId() {return this->GetWindowId();} 00226 00235 virtual void SetDisplayId(void *); 00236 00238 00239 virtual void *GetDisplayId(); 00240 virtual void *GetGenericDisplayId() {return this->GetDisplayId();} 00242 00244 00246 vtkGetMacro(ScaleFactor, double); 00248 00250 00252 void SetPixelFormat(void *pixelFormat); 00253 void *GetPixelFormat(); 00255 00256 protected: 00257 vtkCocoaRenderWindow(); 00258 ~vtkCocoaRenderWindow(); 00259 00260 void CreateGLContext(); 00261 00262 void CreateAWindow(); 00263 void DestroyWindow(); 00264 void DestroyOffScreenWindow(); 00265 00266 int OffScreenInitialized; 00267 int OnScreenInitialized; 00268 00269 // Using CGFloat would be better, but doing it this way avoids pulling in 00270 // Apple headers, which cause problems with the 10.3 SDK and python wrappings. 00271 #if defined(__LP64__) && __LP64__ 00272 double ScaleFactor; 00273 #else 00274 float ScaleFactor; 00275 #endif 00276 00278 00280 void SetCocoaManager(void *manager); 00281 void *GetCocoaManager(); 00283 00284 private: 00285 vtkCocoaRenderWindow(const vtkCocoaRenderWindow&); // Not implemented. 00286 void operator=(const vtkCocoaRenderWindow&); // Not implemented. 00287 00288 private: 00289 // Important: this class cannot contain Objective-C instance 00290 // variables for 2 reasons: 00291 // 1) C++ files include this header 00292 // 2) because of garbage collection (the GC scanner does not scan objects create by C++'s new) 00293 // Instead, use the CocoaManager dictionary to keep a collection 00294 // of what would otherwise be Objective-C instance variables. 00295 void *CocoaManager; // Really an NSMutableDictionary* 00296 00297 int WindowCreated; 00298 int ViewCreated; 00299 int CursorHidden; 00300 00301 int ForceMakeCurrent; 00302 char *Capabilities; 00303 }; 00304 00305 #endif