00001 00008 #ifndef RTVOLUMERENDERER_H 00009 #define RTVOLUMERENDERER_H 00010 00011 #include <gl/glew.h> // must be included before gl.h 00012 00013 #include <wx/wx.h> 00014 #include <wx/glcanvas.h> 00015 #include "VolumeTexture.h" 00016 #include "TransferTexture.h" 00017 #include "TransferFunctionWidget.h" 00018 #include "Shader.h" 00019 #include "Camera.h" 00020 #include "Cube.h" 00021 00027 class RTVolumeRenderer : public wxGLCanvas, public TransferPlotChangeListner 00028 { 00029 public: 00030 00040 RTVolumeRenderer(wxWindow *parent, int w, int h); 00041 00048 void ResizeRenderer(int w, int h); 00049 00053 void Draw(); 00054 00060 void ShouldDrawCube(bool yn); 00061 00067 void ShouldDrawCubeOutline(bool yn); 00068 00074 void ShouldDrawPlanes(bool yn); 00075 00082 void UseVolumeTexture(bool yn); 00083 00089 void SetPlanes(int n); 00090 00096 void SetLightDirection(const Vector3f &dir); 00097 00105 void SetLightDiffuseColor(const Color4f &c); 00106 00112 void MouseMove(wxMouseEvent &m); 00113 00119 void MouseLeftUp(wxMouseEvent &m); 00120 00126 void MouseLeftDown(wxMouseEvent &m); 00127 00133 void MouseWheel(wxMouseEvent &m); 00134 00140 void KeyDown(wxKeyEvent &k); 00141 00147 void SetFrameTime(float t) { dt = t; } 00148 00154 void SetBackgroundColor(const Color4f &c); 00155 00161 void SetCubeColor(const Color4f &c); 00162 00168 void SetOutlineColor(const Color4f &c); 00169 00175 void SetPlaneColor(const Color4f &c); 00176 00180 void ToggleCameraAttachment() { attachPlanesToView = !attachPlanesToView; } 00181 00187 void SetQuickMovmentRendering(bool quick) { quickRendering = quick; } 00188 00198 bool LoadVolumeDataSet(const char *name, const char *path, VTInfo &info); 00199 00208 int CopyHistogram(unsigned int *data, int n) { return volTex.CopyHistogram(data, n); } 00209 00215 virtual void TransferPlotChanged(TransferFunctionPlot *plot); 00216 00217 protected: 00218 00219 void InitOpenGL(); 00220 00224 void Clear(); 00225 00226 Camera camera; 00227 00228 Cube cube; 00229 00230 bool drawCube; 00231 bool drawOutline; 00232 bool drawPlanes; 00233 bool useTexture; 00234 00235 bool redraw; 00236 bool viewChanged; 00237 bool quickRendering; 00238 bool attachPlanesToView; 00239 00240 float delayDrawTimer; // used in non-realtime mode to delay drawing in anticipation of user input 00241 00242 bool mouseDown; 00243 int lastMouseX; 00244 int lastMouseY; 00245 00246 float dt; 00247 00248 int width; 00249 int height; 00250 00251 VolumeTexture volTex; 00252 TransferTexture transferFunc; 00253 ShaderProgram shader; 00254 00255 CubeFrame frame; 00256 Point3f points[7]; 00257 int tris[12]; 00258 00259 DECLARE_EVENT_TABLE() 00260 }; 00261 00262 #endif // GLWINDOW_H