VTK
dox/Rendering/OpenGL/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 VTK_USE_CARBON cannot work in 64 bit; use VTK_USE_COCOA instead.
00038 #endif
00039 #if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
00040   #error VTK_USE_CARBON cannot work with the OS X 10.7 SDK or later; use VTK_USE_COCOA instead.
00041 #endif
00042 
00043 #include "vtkRenderingOpenGLModule.h" // For export macro
00044 #include "vtkOpenGLRenderWindow.h"
00045 
00046 #include <Carbon/Carbon.h> // Carbon and Mac specific
00047 #include <AGL/agl.h> // Carbon and Mac specific
00048 
00049 class vtkCarbonRenderWindowInternal;
00050 
00051 
00052 class VTKRENDERINGOPENGL_EXPORT vtkCarbonRenderWindow : public vtkOpenGLRenderWindow
00053 {
00054 public:
00055   static vtkCarbonRenderWindow *New();
00056   vtkTypeMacro(vtkCarbonRenderWindow,vtkOpenGLRenderWindow);
00057   void PrintSelf(ostream& os, vtkIndent indent);
00058 
00060   void Start();
00061 
00063   void Frame();
00064 
00066   virtual void WindowConfigure();
00067 
00069   virtual void WindowInitialize();
00070 
00075   virtual void Initialize();
00076 
00081   virtual void Finalize();
00082 
00084   void SetOffScreenRendering(int);
00085 
00087   virtual void SetFullScreen(int);
00088 
00090   virtual void WindowRemap();
00091 
00093   virtual void PrefFullScreen();
00094 
00096 
00097   virtual void SetSize(int a[2]);
00098   virtual void SetSize(int,int);
00100 
00102   virtual int *GetSize();
00103 
00105 
00106   virtual void SetPosition(int a[2]);
00107   virtual void SetPosition(int,int);
00109 
00111   virtual int *GetScreenSize();
00112 
00114   virtual int *GetPosition();
00115 
00118   virtual void SetWindowName(const char *);
00119 
00121   void SetWindowInfo(char *);
00122 
00123   void SetNextWindowInfo(char *)
00124     {
00125       vtkWarningMacro("SetNextWindowInfo not implemented (WindowRemap not implemented).");
00126     }
00127 
00128   //BTX
00129   virtual void *GetGenericDisplayId() {return NULL;}
00130   virtual void *GetGenericWindowId()  {return (void *)this->WindowId;}
00131   virtual void *GetGenericParentId()  {return (void *)this->ParentId;}
00132   virtual AGLContext GetContextId();
00133   virtual void *GetGenericContext()  {return (void*)this->GetContextId();}
00134   virtual void SetDisplayId(void *) {}
00135 
00136   virtual void* GetGenericDrawable()
00137     {
00138       vtkWarningMacro("GetGenericDrawable Method not implemented.");
00139       return 0;
00140     }
00141 
00142   void SetParentInfo(char*)
00143     {
00144       vtkWarningMacro("SetParentInfo Method not implemented.");
00145     }
00146 
00148 
00149   virtual HIViewRef GetWindowId();
00150   // Set the HIView window pointer.
00151   void  SetWindowId(void *foo) {this->SetWindowId((HIViewRef)foo);};
00152   void SetNextWindowId(void*)
00153     {
00154       vtkWarningMacro("SetNextWindowId not implemented (WindowRemap not implemented).");
00155     }
00157 
00159 
00160   virtual void SetParentId(HIViewRef);
00161   void  SetParentId(void *foo) {this->SetParentId((HIViewRef)foo);};
00163 
00165   virtual void SetWindowId(HIViewRef);
00166 
00168 
00169   void SetRootWindow(WindowPtr win);
00170   WindowPtr GetRootWindow();
00172 
00173   //ETX
00174 
00175   // supply base class virtual function
00176   vtkSetMacro(MultiSamples,int);
00177   vtkGetMacro(MultiSamples,int);
00178 
00183   virtual void SetStereoCapableWindow(int capable);
00184 
00186   void MakeCurrent();
00187 
00190   virtual bool IsCurrent();
00191 
00195   void SetForceMakeCurrent();
00196 
00199   virtual int IsDirect();
00200 
00203   virtual  int GetEventPending();
00204 
00206   int GetDepthBufferSize();
00207 
00209 
00211   void HideCursor();
00212   void ShowCursor();
00214 
00215   void UpdateSizeAndPosition(int xPos, int yPos, int xSize, int ySize);
00216 
00219   void UpdateGLRegion();
00220 
00221 
00222 protected:
00223   vtkCarbonRenderWindow();
00224   ~vtkCarbonRenderWindow();
00225 
00226   vtkCarbonRenderWindowInternal* Internal;
00227 
00228   int ApplicationInitialized; // Toolboxen initialized?
00229   GLint aglAttributes[64];    // input: pixel format attributes always required
00230                               //   (reset to what was actually allocated)
00231   AGLContext ContextId;
00232   HIViewRef WindowId;
00233   HIViewRef ParentId;
00234   WindowPtr RootWindow;
00235   int OwnWindow;
00236   int ScreenSize[2];
00237 
00238   int CursorHidden;
00239   int ForceMakeCurrent;
00240 
00241 
00242   // data and handlers to keep the GL view coincident with the HIView
00243   EventHandlerUPP RegionEventHandlerUPP;
00244   EventHandlerRef RegionEventHandler;
00245   static OSStatus RegionEventProcessor(EventHandlerCallRef er,
00246                                        EventRef event,
00247                                        void*);
00248 
00249   void InitializeApplication();
00250 
00251   void CreateAWindow();
00252   void DestroyWindow();
00253 
00254   void CreateOffScreenWindow(int x, int y);
00255   void DestroyOffScreenWindow();
00256   void ResizeOffScreenWindow(int x, int y);
00257 
00258 private:
00259   vtkCarbonRenderWindow(const vtkCarbonRenderWindow&);  // Not implemented.
00260   void operator=(const vtkCarbonRenderWindow&);  // Not implemented.
00261 };
00262 
00263 #endif