VTK
dox/Rendering/vtkCarbonRenderWindow.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003 Program:   Visualization Toolkit
00004 Module:    vtkCarbonRenderWindow.h
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 =========================================================================*/
00033 #ifndef __vtkCarbonRenderWindow_h
00034 #define __vtkCarbonRenderWindow_h
00035 
00036 #if defined(__LP64__) && __LP64__
00037   #error vtkCarbonRenderWindow does not work in 64 bit
00038 #endif
00039 
00040 #include "vtkOpenGLRenderWindow.h"
00041 
00042 // The 10.3.9 SDK (and older probably) have a bug in fp.h (in the Carbon
00043 // umbrella framework) which this works around. Without this, there
00044 // would be a compile error from the Carbon header if Python wrappings
00045 // were enabled.
00046 #include <AvailabilityMacros.h> // Needed for MAC_OS_X_VERSION_MAX_ALLOWED
00047 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1040
00048   #define scalb scalbn
00049 #endif
00050 
00051 #include <Carbon/Carbon.h> // Carbon and Mac specific
00052 #include <AGL/agl.h> // Carbon and Mac specific
00053 
00054 class vtkCarbonRenderWindowInternal;
00055 
00056 
00057 class VTK_RENDERING_EXPORT vtkCarbonRenderWindow : public vtkOpenGLRenderWindow
00058 {
00059 public:
00060   static vtkCarbonRenderWindow *New();
00061   vtkTypeMacro(vtkCarbonRenderWindow,vtkOpenGLRenderWindow);
00062   void PrintSelf(ostream& os, vtkIndent indent);
00063 
00065   void Start();
00066 
00068   void Frame();
00069 
00071   virtual void WindowConfigure();
00072 
00074   virtual void WindowInitialize();
00075 
00080   virtual void Initialize();
00081 
00086   virtual void Finalize();
00087 
00089   void SetOffScreenRendering(int);
00090 
00092   virtual void SetFullScreen(int);
00093 
00095   virtual void WindowRemap();
00096 
00098   virtual void PrefFullScreen();
00099 
00101 
00102   virtual void SetSize(int a[2]);
00103   virtual void SetSize(int,int);
00105 
00107   virtual int *GetSize();
00108 
00110 
00111   virtual void SetPosition(int a[2]);
00112   virtual void SetPosition(int,int);
00114 
00116   virtual int *GetScreenSize();
00117 
00119   virtual int *GetPosition();
00120 
00123   virtual void SetWindowName(const char *);
00124   
00126   void SetWindowInfo(char *);
00127 
00128   void SetNextWindowInfo(char *)
00129     {
00130       vtkWarningMacro("SetNextWindowInfo not implemented (WindowRemap not implemented).");
00131     }
00132 
00133   //BTX
00134   virtual void *GetGenericDisplayId() {return NULL;}
00135   virtual void *GetGenericWindowId()  {return (void *)this->WindowId;}
00136   virtual void *GetGenericParentId()  {return (void *)this->ParentId;}
00137   virtual AGLContext GetContextId();
00138   virtual void *GetGenericContext()  {return (void*)this->GetContextId();}
00139   virtual void SetDisplayId(void *) {}
00140 
00141   virtual void* GetGenericDrawable()
00142     {
00143       vtkWarningMacro("GetGenericDrawable Method not implemented.");
00144       return 0;
00145     }
00146 
00147   void SetParentInfo(char*)
00148     {
00149       vtkWarningMacro("SetParentInfo Method not implemented.");
00150     }
00151 
00153 
00154   virtual HIViewRef GetWindowId();
00155   // Set the HIView window pointer.
00156   void  SetWindowId(void *foo) {this->SetWindowId((HIViewRef)foo);};
00157   void SetNextWindowId(void*)
00158     {
00159       vtkWarningMacro("SetNextWindowId not implemented (WindowRemap not implemented).");
00160     }
00162 
00164 
00165   virtual void SetParentId(HIViewRef);
00166   void  SetParentId(void *foo) {this->SetParentId((HIViewRef)foo);};
00168   
00170   virtual void SetWindowId(HIViewRef);
00171 
00173 
00174   void SetRootWindow(WindowPtr win);
00175   WindowPtr GetRootWindow();
00177 
00178   //ETX
00179 
00180   // supply base class virtual function
00181   vtkSetMacro(MultiSamples,int);
00182   vtkGetMacro(MultiSamples,int);
00183 
00188   virtual void SetStereoCapableWindow(int capable);
00189 
00191   void MakeCurrent();
00192 
00195   virtual bool IsCurrent();
00196   
00200   void SetForceMakeCurrent();
00201 
00204   virtual int IsDirect();
00205   
00208   virtual  int GetEventPending();
00209 
00211   int GetDepthBufferSize();
00212 
00214 
00216   void HideCursor();
00217   void ShowCursor();
00219   
00220   void UpdateSizeAndPosition(int xPos, int yPos, int xSize, int ySize);
00221 
00224   void UpdateGLRegion();
00225 
00226   
00227 protected:
00228   vtkCarbonRenderWindow();
00229   ~vtkCarbonRenderWindow();
00230 
00231   vtkCarbonRenderWindowInternal* Internal;
00232 
00233   int ApplicationInitialized; // Toolboxen initialized?
00234   GLint aglAttributes[64];    // input: pixel format attributes always required
00235                               //   (reset to what was actually allocated)
00236   AGLContext ContextId;
00237   HIViewRef WindowId;
00238   HIViewRef ParentId;
00239   WindowPtr RootWindow;
00240   int OwnWindow;
00241   int ScreenSize[2];
00242 
00243   int CursorHidden;
00244   int ForceMakeCurrent;
00245 
00246 
00247   // data and handlers to keep the GL view coincident with the HIView
00248   EventHandlerUPP RegionEventHandlerUPP;
00249   EventHandlerRef RegionEventHandler;
00250   static OSStatus RegionEventProcessor(EventHandlerCallRef er,
00251                                        EventRef event,
00252                                        void*);
00253 
00254   void InitializeApplication();
00255 
00256   void CreateAWindow();
00257   void DestroyWindow();
00258   
00259   void CreateOffScreenWindow(int x, int y);
00260   void DestroyOffScreenWindow();
00261   void ResizeOffScreenWindow(int x, int y);
00262 
00263 private:
00264   vtkCarbonRenderWindow(const vtkCarbonRenderWindow&);  // Not implemented.
00265   void operator=(const vtkCarbonRenderWindow&);  // Not implemented.
00266 };
00267 
00268 #endif