Lagrangian Liquid Simulation
Master Thesis project on simulation of liquids using Lagrangian approach and SPH
include/Simulation.h
Go to the documentation of this file.
00001 #ifndef SIMULATION_H
00002 #define SIMULATION_H
00003 
00004 #include <QString>
00005 
00006 #include "ngl/Camera.h"
00007 #include "ngl/Colour.h"
00008 #include "ngl/SpotLight.h"
00009 #include "ngl/TransformStack.h"
00010 
00011 #include "ShaderLibrary.h"
00012 #include "Solver.h"
00013 #include "Environment.h"
00014 #include "Cache.h"
00015 
00016 #include <QtOpenGL>
00017 
00027 
00028 class Simulation : public QGLWidget
00029 {
00030 Q_OBJECT
00031 
00032 public:
00035     Simulation(
00036             QWidget* _parent
00037         );
00038 
00040     ~Simulation();
00041 
00044     void keyPress(QKeyEvent* _event);
00045 
00047     inline Solver* getSolver() const { return  m_solver; }
00048 
00050     inline Environment* getEnvironment() const { return  m_environment; }
00051 
00053     inline Integration* getIntegration() const { return  m_integration; }
00054 
00056     void setup2DTopView();
00057 
00059     void setup2DFrontView();
00060 
00062     void toggleCache();
00063 
00065     void toggleAutomaticCacheFlush();
00066 
00068     void updateFPSTimer();
00069 
00071     void flushCache();
00072 
00073 
00075     inline bool getCacheEnabled() const { return m_cacheEnabled; }
00076 
00078     inline int getCacheSamplingInterval() const { return m_cacheSamplingInterval; }
00079 
00081     inline bool getCacheAutomaticFlushEnabled () const { return m_cacheAutomaticFlushEnabled; }
00082 
00084     inline int getCacheAutomaticFlushInterval() const { return m_cacheAutomaticFlushInterval; }
00085 
00087     inline bool getCacheExportRBDEnabled() const { return m_cacheExportRBDEnabled; }
00088 
00090     inline bool getCacheExportBoundaryEnabled() const { return m_cacheExportBoundaryEnabled; }
00091 
00093     inline std::string getCachePath() const { return m_cachePath; }
00094 
00095 
00098     inline void setCacheEnabled(const bool _v) { m_cacheEnabled = _v; }
00099 
00102     inline void setCacheSamplingInterval(const int _v) { m_cacheSamplingInterval = _v; }
00103 
00106     inline void setCacheAutomaticFlushEnabled (const bool _v) { m_cacheAutomaticFlushEnabled = _v; }
00107 
00110     inline void setCacheAutomaticFlushInterval(const int _v) { m_cacheAutomaticFlushInterval = _v; }
00111 
00114     inline void setCacheExportRBDEnabled(const bool _v) { m_cacheExportRBDEnabled = _v; }
00115 
00118     inline void setCacheExportBoundaryEnabled(const bool _v) { m_cacheExportBoundaryEnabled = _v; }
00119 
00120 
00121 public slots:
00124     void updateCameraZoom(const int _depth);
00125 
00126 
00127 protected:
00129     void initializeGL();
00130 
00134     void resizeGL
00135                 (
00136                     const int _w,
00137                     const int _h
00138                 );
00139 
00141     void paintGL();
00142 
00143 
00144 private :
00146     int m_spinXFace;
00147 
00149     int m_spinYFace;
00150 
00152     bool m_rotate;
00153 
00155     int m_origX;
00156 
00158     int m_origY;
00159 
00161     int m_moveX;
00162 
00164     int m_moveY;
00165 
00167     bool m_move;
00168 
00170     int m_origMoveX;
00171 
00173     int m_origMoveY;
00174 
00176     bool m_drawHelp;
00177 
00179     float m_aspect;
00180 
00182     int m_mouseMoveSensitivity;
00183 
00185     int m_frameRate;
00186 
00188     ngl::TransformStack m_transformStack;
00189 
00191     ngl::Light m_light;
00192 
00194     ngl::Camera m_camera;
00195 
00197     ShaderLibrary* m_shaderLibrary;
00198 
00200     Solver* m_solver;
00201 
00203     Environment* m_environment;
00204 
00206     Integration* m_integration;
00207 
00209     Cache* m_cache;
00210 
00212     float m_lastCamZ;
00213 
00215     int m_frameCounter;
00216 
00218     int m_mainSimulationTimer;
00219 
00221     QTimer* m_fpsTimer;
00222 
00224     bool m_fpsTimerEnabled;
00225 
00227     QTimer* m_simulationCacheTimer;
00228 
00230     QTimer* m_simulationCacheAutoFlushTimer;
00231 
00233     int m_simulationCacheFrameNumber;
00234 
00236     bool m_cacheEnabled;
00237 
00239     int m_cacheSamplingInterval;
00240 
00242     bool m_cacheAutomaticFlushEnabled;
00243 
00245     int m_cacheAutomaticFlushInterval;
00246 
00248     bool m_cacheExportRBDEnabled;
00249 
00251     bool m_cacheExportBoundaryEnabled;
00252 
00254     std::string m_cachePath;
00255 
00256 
00257 private :
00259     void timerEvent(QTimerEvent* _event);
00260 
00262     void createCamera();
00263 
00265     void createLight();
00266 
00268     void displayHelp();
00269 
00272     void mouseMoveEvent(
00273                             QMouseEvent* _event
00274                         );
00275 
00278     void mousePressEvent(
00279                             QMouseEvent* _event
00280                         );
00281 
00284     void mouseReleaseEvent(
00285                             QMouseEvent* _event
00286                             );
00287 
00289     void initialiseSimulation();
00290 
00292     void deleteSimulationObjects();
00293 
00294 
00295 
00296 private slots:
00298     void processFPS();
00299 
00301     void processSimulationCache();
00302 
00304     void processSimulationCacheAutoFlush();
00305 
00306 
00307 };
00308 #endif // SIMULATION_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator