Emdee
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
moleculardynamics.h
Go to the documentation of this file.
1 #ifndef MOLECULARDYNAMICS_H
2 #define MOLECULARDYNAMICS_H
3 
4 #include <QObject>
5 #include <QQuickItem3D>
6 #include <QElapsedTimer>
7 #include <vector>
8 
9 using std::vector;
10 
11 class MoleculeSystem;
13 
14 class MolecularDynamics : public QQuickItem3D
15 {
16  Q_OBJECT
18  Q_PROPERTY(double temperature READ temperature NOTIFY temperatureChanged)
19  Q_PROPERTY(double pressure READ pressure NOTIFY pressureChanged)
21  Q_PROPERTY(SortMode sortPoints READ sortPoints WRITE setSortPoints NOTIFY sortPointsChanged)
22  Q_PROPERTY(double fps READ fps NOTIFY fpsChanged)
23 public:
24  explicit MolecularDynamics(QQuickItem *parent = 0);
25 
26  void drawItem(QGLPainter *painter);
27 
28  Q_INVOKABLE void stepForward();
29  double targetTemperature() const;
30 
31  bool useThermostat() const;
32 
33  double fps() const
34  {
35  return m_fps;
36  }
37 
38  SortMode sortPoints() const
39  {
40  return m_sortPoints;
41  }
42 
43  double temperature() const
44  {
45  return m_temperature;
46  }
47 
48  double pressure() const
49  {
50  return m_pressure;
51  }
52 
53 signals:
54 
55  void targetTemperatureChanged(double arg);
56 
57  void useThermostatChanged(bool arg);
58 
59  void fpsChanged(double arg);
60 
61  void sortPointsChanged(SortMode arg);
62 
63  void temperatureChanged(double arg);
64 
65  void pressureChanged(double arg);
66 
67 public slots:
68 
69 void setTargetTemperature(double arg);
70 
71 void setUseThermostat(bool arg);
72 
73 void setSortPoints(SortMode arg)
74 {
75  if (m_sortPoints != arg) {
76  m_sortPoints = arg;
77  emit sortPointsChanged(arg);
78  }
79 }
80 
81 private:
82  QList<QVector3D> m_points;
83  MoleculeSystem *m_moleculeSystem;
84  QGLSceneNode* m_geometry;
85  BerendsenThermostat* m_thermostat;
86  double m_targetTemperature;
87  bool m_useThermostat;
88 
89  QArray<QVector3D> vertices;
90  QArray<QVector3D> normals;
91  QArray<QVector2D> texCoords;
92  QArray<uint> indexes;
93  double m_fps;
94  QElapsedTimer fpsTimer;
95  SortMode m_sortPoints;
96  double m_pressure;
97  double m_temperature;
98 };
99 
100 #endif // MOLECULARDYNAMICS_H