mantaflow  0.10
A framework for fluid simulation
customctrl.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  * GUI extension from python
12  *
13  ******************************************************************************/
14 
15 #ifndef _CUSTOMCTRL_H__
16 #define _CUSTOMCTRL_H__
17 
18 #include <QSlider>
19 #include <QLabel>
20 #include <QCheckBox>
21 #include <QBoxLayout>
22 #include "manta.h"
23 
24 namespace Manta {
25 
26 // fwd decl.
27 class Mesh;
28 class GuiThread;
29 class MainThread;
30 
33 PYTHON class CustomControl : public PbClass {
34 public:
35  PYTHON() CustomControl();
36 
37  virtual void init(QBoxLayout* layout) {};
38 
39 protected:
40 };
41 
43 class TextCheckbox : public QCheckBox {
44  Q_OBJECT
45 public:
46  TextCheckbox(const std::string& name, bool val);
47  void attach(QBoxLayout* layout);
48  void set(bool v);
49  bool get();
50 
51 public slots:
52  void update(int v);
53 
54 protected:
55  bool mVal;
56  QLabel* mLabel;
57  QString mSName;
58 };
59 
61 class TextSlider : public QSlider {
62  Q_OBJECT
63 public:
64  TextSlider(const std::string& name, float val, float min, float max);
65  void attach(QBoxLayout* layout);
66  void set(float v);
67  float get();
68 
69 public slots:
70  void update(int v);
71 
72 protected:
73  float mMin, mMax, mScale;
74  QLabel* mLabel;
75  QString mSName;
76 };
77 
80 PYTHON class CustomSlider : public CustomControl {
81 public:
82  PYTHON() CustomSlider(std::string text, float val, float min, float max);
83  virtual void init(QBoxLayout* layout);
84 
85  PYTHON() float get();
86  PYTHON() void set(float v);
87 
88 protected:
89  float mMin, mMax, mVal;
90  std::string mSName;
91  TextSlider* mSlider;
92 };
93 
96 PYTHON class CustomCheckbox : public CustomControl {
97 public:
98  PYTHON() CustomCheckbox(std::string text, bool val);
99  virtual void init(QBoxLayout* layout);
100 
101  PYTHON() bool get();
102  PYTHON() void set(bool v);
103 
104 protected:
105  bool mVal;
106  std::string mSName;
107  TextCheckbox* mCheckbox;
108 };
109 
110 
113 PYTHON class Gui : public PbClass {
114 public:
115  PYTHON() Gui();
116 
117  PYTHON() void setBackgroundMesh(Mesh* m);
118  PYTHON() void show(bool twoD=false);
119  PYTHON() void update();
120  PYTHON() void pause();
121  PYTHON() PbClass* addControl(PbType t);
122  PYTHON() void screenshot(std::string filename);
123 
124  // control display upon startup
125  PYTHON() void nextRealGrid();
126  PYTHON() void nextVec3Grid();
127  PYTHON() void nextParts();
128  PYTHON() void nextPdata();
129  PYTHON() void nextMesh();
130  PYTHON() void nextVec3Display();
131  PYTHON() void nextMeshDisplay();
132  PYTHON() void nextPartDisplay();
133  PYTHON() void toggleHideGrids();
134  PYTHON() void setCamPos(float x, float y, float z);
135  PYTHON() void setCamRot(float x, float y, float z);
136  PYTHON() void windowSize(int w, int h);
137 
138 protected:
139  GuiThread* mGuiPtr;
140  MainThread* mMainPtr;
141 };
142 
143 } // namespace
144 
145 #endif
146 
147 
148 
Definition: commonkernels.h:22
Checkbox with attached text display.
Definition: customctrl.h:43
Definition: customctrl.h:96
Definition: customctrl.h:113
encapsulates working/python thread
Definition: qtmain.h:47
Definition: customctrl.h:33
Definition: customctrl.h:80
Slider with attached text display.
Definition: customctrl.h:61
encapsulates GUI thread
Definition: qtmain.h:28
Triangle mesh class.
Definition: mesh.h:126