mantaflow  0.10
A framework for fluid simulation
qtmain.h
Go to the documentation of this file.
1 
2 /******************************************************************************
3  *
4  * MantaFlow fluid solver framework
5  * Copyright 2011 Tobias Pfaff, Nils Thuerey
6  *
7  * This program is free software, distributed under the terms of the
8  * GNU General Public License (GPL)
9  * http://www.gnu.org/licenses
10  *
11  * QT threads
12  *
13  ******************************************************************************/
14 #ifndef _QTMAIN_H_
15 #define _QTMAIN_H_
16 
17 #include <QThread>
18 #include <QApplication>
19 #include <vector>
20 #include <QMutex>
21 #include <QWaitCondition>
22 #include "mainwindow.h"
23 #include "manta.h"
24 
25 namespace Manta {
26 
28 class GuiThread : public QObject {
29  Q_OBJECT
30 public:
31 
32  GuiThread(QApplication& app);
33 
35  inline MainWnd* getWindow() { return &mWnd; }
36 
37 public slots:
38  void sendEvent(int e);
39  void exitApp();
40 
41 protected:
42  QApplication& mApp;
43  MainWnd mWnd;
44 };
45 
47 class MainThread : public QThread {
48  Q_OBJECT
49 public:
50  MainThread(std::vector<std::string>& args);
51 
53  void sendAndWait(int e);
54  void send(int e);
55 
57  inline void threadSleep(int msec) { msleep(msec); }
58  inline bool isFinished() { return mFinished; }
59  inline void setFinished() { mFinished = true; }
60 
61 public slots:
62  void wakeUp();
63  void killMe();
64 
65 signals:
66  void sendToGui(int event);
67 
68 protected:
69  QMutex mMutex;
70  QWaitCondition mWait;
71  bool mFinished;
72  std::vector<std::string> mArgs;
73  void run();
74 };
75 
76 } // namespace
77 
78 #endif
79 
Definition: commonkernels.h:22
Definition: pclass.cpp:24
Definition: mainwindow.h:28
MainWnd * getWindow()
obtain window handle
Definition: qtmain.h:35
encapsulates working/python thread
Definition: qtmain.h:47
encapsulates GUI thread
Definition: qtmain.h:28
void threadSleep(int msec)
sleep for given number of milliseconds
Definition: qtmain.h:57