TnFXVTKCanvas.h

Go to the documentation of this file.
00001 /* This file was taken from http://sourceforge.net/projects/vtkfox
00002 Resides in the public domain
00003 */
00004 #if FX_GRAPHINGMODULE
00005 
00006 #ifndef TNFXVTKCANVAS_H
00007 #define TNFXVTKCANVAS_H
00008 
00009 #include "FXGLCanvas.h"
00010 #include "FXGenericTools.h"
00011 #if HAVE_VTK
00012 #include <vtkRenderWindowInteractor.h>
00013 #endif
00014 
00015 namespace FX {
00016 
00024 class vtkTnFXRenderWindowInteractor;
00025 
00032 template<class type> class TnFXVTKHold : public Generic::ptr<type, Pol::destructiveCopyNoDelete>
00033 {
00034 public:
00035     TnFXVTKHold(type *p=0) : Generic::ptr<type, Pol::destructiveCopyNoDelete>(p) { }
00036     ~TnFXVTKHold()
00037     {
00038         if(PtrPtr(*this)) PtrRelease(*this)->Delete();
00039     }
00040     TnFXVTKHold &operator=(const TnFXVTKHold &o)
00041     {
00042         if(PtrPtr(*this)) PtrRelease(*this)->Delete();
00043         Generic::ptr<type, Pol::destructiveCopyNoDelete>::data=o.data;
00044         o.data=0;
00045         return *this;
00046     }
00047 };
00048 
00060 class FXGRAPHINGMODULEAPI TnFXVTKCanvas : public FXGLCanvas
00061 {
00062     FXDECLARE(TnFXVTKCanvas)
00063 
00064     vtkTnFXRenderWindowInteractor *_fxrwi;
00065     void *_id;
00066     void *_display;
00067 protected:
00068     TnFXVTKCanvas() {}
00069     
00070     // not implemented (should cause compile error if object is copied)
00071     TnFXVTKCanvas(const TnFXVTKCanvas& FVC);
00072     TnFXVTKCanvas& operator=(const TnFXVTKCanvas& FVC);
00073 public:
00075     TnFXVTKCanvas(FXComposite *p, FXGLVisual *vis, FXObject *tgt = NULL, FXSelector sel = 0, FXuint opts = 0, FXint x = 0, FXint y = 0, FXint w = 0, FXint h = 0);
00076     TnFXVTKCanvas(FXComposite *p, FXGLVisual *vis, FXGLCanvas *sharegroup, FXObject *tgt=NULL, FXSelector sel=0, FXuint opts=0, FXint x=0, FXint y=0, FXint w=0, FXint h=0);
00077     ~TnFXVTKCanvas();
00078 
00080     vtkTnFXRenderWindowInteractor* interactor() const throw();
00082     void setInteractor(vtkTnFXRenderWindowInteractor *fxrwi) throw();
00083     
00086     virtual void render(bool makeCurrent=true);
00087 
00088     virtual void create();
00089 
00090 public:
00091     long onPaint(FXObject *obj, FXSelector sel, void *data);
00092     long onTimeout(FXObject *obj, FXSelector sel, void *data);
00093     long onResize(FXObject *obj, FXSelector sel, void *data);
00094     
00095     long onLeftButtonDown(FXObject *obj, FXSelector sel, void *data);
00096     long onLeftButtonUp(FXObject *obj, FXSelector sel, void *data);
00097     long onMiddleButtonDown(FXObject *obj, FXSelector sel, void *data);
00098     long onMiddleButtonUp(FXObject *obj, FXSelector sel, void *data);
00099     long onRightButtonDown(FXObject *obj, FXSelector sel, void *data);
00100     long onRightButtonUp(FXObject *obj, FXSelector sel, void *data);
00101     long onMotion(FXObject *obj, FXSelector sel, void *data);
00102     long onKeyboard(FXObject *obj, FXSelector sel, void *data);
00103 };
00104 
00119 #ifdef HAVE_VTK
00120 
00121 // Suppress warning about vtkRenderWindowInteractor not being a suitable base class
00122 #ifdef _MSC_VER
00123 #if _MSC_VER >= 1200
00124 #pragma warning( push )
00125 #endif
00126 #pragma warning( disable : 4275 )
00127 #endif
00128 
00129 class FXGRAPHINGMODULEAPI vtkTnFXRenderWindowInteractor : public vtkRenderWindowInteractor
00130 {
00131 public:
00133     vtkTnFXRenderWindowInteractor(TnFXVTKCanvas *canvas=0);
00134     ~vtkTnFXRenderWindowInteractor();
00135 
00137     TnFXVTKCanvas *canvas() const throw();
00139     void setCanvas(TnFXVTKCanvas *canvas) throw();
00140     
00141     virtual void Initialize();
00142     virtual void Enable();
00143     virtual void Disable();
00144     virtual void Start();
00145     virtual void SetRenderWindow(vtkRenderWindow *renderer);
00146     virtual void UpdateSize(int w, int h);
00147     virtual void TerminateApp();
00148     virtual int CreateTimer(int timertype);
00149     virtual int DestroyTimer(void);
00150 
00151     
00152     virtual char const* GetClassNameW() const { return "vtkTnFXRenderWindowInteractor"; }
00153     
00154 protected:
00155     // not implemented (should cause compile error)
00156     vtkTnFXRenderWindowInteractor(const vtkTnFXRenderWindowInteractor& RWI);
00157     vtkTnFXRenderWindowInteractor& operator=(const vtkTnFXRenderWindowInteractor& RWI);
00158     
00159 private:
00160     TnFXVTKCanvas *_canvas;
00161 };
00162 
00163 // Restore previous warning levels
00164 #ifdef _MSC_VER
00165 #if _MSC_VER >= 1200
00166 #pragma warning( pop )
00167 #endif
00168 #endif
00169 
00170 #endif
00171 
00172 }
00173 
00174 #endif
00175 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:26 2009 for TnFOX by doxygen v1.4.7