/renderthread.h

http://nscow.googlecode.com/ · C Header · 75 lines · 57 code · 18 blank · 0 comment · 0 complexity · c6db72684b7d3f950719fdc344132bdd MD5 · raw file

  1. #ifndef RENDERTHREAD_H
  2. #define RENDERTHREAD_H
  3. #include <QImage>
  4. #include <QMutex>
  5. #include <QThread>
  6. #include "VectorField2D.h"
  7. #include "ScalarField2D.h"
  8. class RenderThread : public QThread
  9. {
  10. Q_OBJECT
  11. public:
  12. enum OutputType {
  13. DENSITY, VELOCITY, PRESSURE, VORTICITY
  14. };
  15. enum Actions {
  16. NONE, FORCE, DYE, INFORCE, OUTFORCE
  17. };
  18. RenderThread(QObject *parent = 0);
  19. ~RenderThread();
  20. void startSim(int xdim = 50, int ydim = 50);
  21. void startSim(QImage& image);
  22. signals:
  23. void sendImage(QImage image);
  24. public slots:
  25. void stopProcess();
  26. void startForce(double x, double y);
  27. void moreForce(double x, double y);
  28. void addDye(double x, double y);
  29. void stopAction(double, double);
  30. void addInForce(double x, double y);\
  31. void addOutForce(double x, double y);\
  32. void setNu(double nu);
  33. void setDt(double dt);
  34. void setDx(double dx);
  35. void setE(double e);
  36. void setRTool(double rForce);
  37. void setMagTool(double magTool);
  38. void setDC(double dc);
  39. void setOutput(int output);
  40. protected:
  41. void run();
  42. private:
  43. QMutex mutex;
  44. bool m_abort;
  45. QImage m_image;
  46. int m_hasAction;
  47. QPointF m_fstart;
  48. QPointF m_fend;
  49. double m_xTool;
  50. double m_yTool;
  51. int xdim;
  52. int ydim;
  53. int itsOutput;
  54. static void writeImage(const ScalarField2D& data, QImage& image);
  55. static void writeImage(const VectorField2D& data, QImage& image);
  56. };
  57. #endif // RENDERTHREAD_H