![]() |
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * Visualisation Toolkit adapter class * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2003 by Mathew Robertson. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 *********************************************************************************/ 00022 #ifdef HAVE_VTK 00023 #ifndef FXVTKWINDOW_H 00024 #define FXVTKWINDOW_H 00025 00026 /** 00027 * Adapter class for accessing the VTK Visualisation toolkit 00028 * 00029 * (I have no idea where who produced this class, 00030 * I have cleaned it up where appropriate) 00031 */ 00032 #ifndef FXFRAME_H 00033 #include <fox/FXFrame.h> 00034 using namespace FX; 00035 #endif 00036 namespace FXEX { 00037 00038 class vtkRenderer; 00039 class vtkRenderWindow; 00040 00041 class FXAPI FXVTKWindow : public FXFrame { 00042 FXDECLARE(FXVTKWindow) 00043 00044 private: 00045 FXint state; // state of current animation 00046 FXint updateRate; // the rate of spin - use -1 for update on idle 00047 vtkRenderer *renderer; // the VTK render engine 00048 vtkRenderWindow *renderWindow; // the VTK rendered window 00049 00050 private: 00051 // disallow these operators 00052 FXVTKWindow(const FXVTKWindow&); 00053 FXVTKWindow &operator=(const FXVTKWindow&); 00054 00055 protected: 00056 // internal animation states 00057 enum { 00058 IS_IDLE=0, 00059 IS_ROTATE=1, 00060 IS_DOLLY=2, 00061 IS_PAN=4, 00062 IS_SPIN=8, 00063 IS_LAST=16 00064 }; 00065 00066 protected: 00067 // serialisation 00068 FXVTKWindow() : FXFrame(){} 00069 00070 // tell the VTK engine to render the window 00071 void render(); 00072 00073 // get the renderer size 00074 FXint getSize(FXint n); 00075 00076 // get the renderer center 00077 FXdouble getCenter(FXint n); 00078 00079 // make sure the light source is following the camera 00080 void CheckLightFollowCamera(); 00081 00082 public: 00083 /// return default width 00084 virtual FXint getDefaultWidth(); 00085 00086 /// return default height 00087 virtual FXint getDefaultHeight(); 00088 00089 public: 00090 enum{ 00091 ID_ANIMATE=FXFrame::ID_LAST, 00092 ID_LAST, 00093 }; 00094 00095 public: 00096 long onPaint(FXObject*,FXSelector,void*); 00097 long onLeave(FXObject*,FXSelector,void*); 00098 long onLeftBtnPress(FXObject*,FXSelector,void*); 00099 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00100 long onMiddleBtnPress(FXObject*,FXSelector,void*); 00101 long onMiddleBtnRelease(FXObject*,FXSelector,void*); 00102 long onRightBtnPress(FXObject*,FXSelector,void*); 00103 long onRightBtnRelease(FXObject*,FXSelector,void*); 00104 long onAnimate(FXObject*,FXSelector,void *ptr); 00105 00106 public: 00107 /// create a VTK rendereing window 00108 FXVTKWindow(FXComposite* p,FXuint opts=FRAME_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0, 00109 FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); 00110 00111 /// creates resources 00112 virtual void create(); 00113 00114 /// set the animation speed (in milliseconds) - set to 0 to animate when idle 00115 void animationSpeed(FXint sp) { updateRate=sp; } 00116 00117 /// get the animation speed (in milliseconds) 00118 FXint animationSpeed() { return updateRate; } 00119 00120 /// set VTK window to be double buffered 00121 void doubleBuffer(FXbool b=TRUE); 00122 00123 /// returns a pointer to the VTK renderer 00124 vtkRenderer* getRenderer(); 00125 00126 // start the animation 00127 void animate(); 00128 00129 // stop the animation 00130 void stopAnimate(); 00131 00132 // Dolly animation 00133 void Dolly(FXint x,FXint y); 00134 00135 // Pan animation 00136 void Pan(FXint x,FXint y); 00137 00138 // Rotate animation 00139 void Rotate(FXint x,FXint y); 00140 00141 // Rotate animation 00142 void Rotate(FXdouble ryf); 00143 00144 /// Spin animation 00145 void Spin(FXint x,FXint y); 00146 00147 /// save the VTK rendered image as a PPM formated image 00148 void SaveImageAsPPM(const FXString& file); 00149 00150 /// save the VTK rendered image as a BMP formated image 00151 void SaveImageAsBMP(const FXString& file); 00152 00153 /// save resources 00154 virtual void save(FXStream& store) const; 00155 00156 /// load resources 00157 virtual void load(FXStream& store); 00158 00159 /// destructor 00160 virtual ~FXVTKWindow(); 00161 }; 00162 00163 } // namespace FXEX 00164 #endif // FXVTKWINDOW_H 00165 #endif