PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

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