Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LoadsSimulationDriver.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2013 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 #ifndef LOADSSIMULATIONDRIVER_H
27 #define LOADSSIMULATIONDRIVER_H
28 
29 #include <QObject>
30 #include <QMap>
31 class QTimer;
32 
33 //class declared in this file
34 class LoadsMovie;
35 class LoadsManager;
36 class Loads;
37 
47 class LoadsSimulationDriver : public QObject {
48 
49  Q_OBJECT
50 
51 public:
58 
60  virtual ~LoadsSimulationDriver();
61 
65  void updateDisplay(bool force);
66 
68  void resetToDefault();
69 
71  void resetTMinToDefault();
72 
74  double getTMin() const;
75 
77  void setTMin(double);
78 
80  void resetTMaxToDefault();
81 
83  double getTMax() const;
84 
86  void setTMax(double);
87 
89  void setDt(double dt);
90 
92  double getDt() const;
93 
95  double getTime() const;
96 
98  void setTime(double);
99 
101  double getRefreshDt() const;
102 
104  void setRefreshDt(double);
105 
107  double getNextRefreshTime();
108 
110  void setLoads(Loads *);
111 
113  void startTimer();
114 
116  void stopTimer();
117 
119  bool isTimerActive();
120 
122  void resetPositions();
123 
125  void rewind();
126 
128  void slower();
129 
131  void quicker();
132 
134  void maxSpeed();
135 
136 signals:
137 
139  void doOneStep();
140 
141 public slots:
142 
144  void play();
145 
146 private :
148  struct Position {
149  double x;
150  double y;
151  double z;
152  };
153 
156 
158  Loads * currentLoads;
159 
164  void init();
165 
167  QMap<unsigned int, Position> initialPositionMap;
168 
170  QTimer *timer;
171 
173  double t;
174 
176  double dt;
177 
179  double tMin;
180 
182  double tMax;
183 
185  double refreshDt;
186 
189 
192 
194  void getInitialPosition(unsigned int, double [3]);
195 
197  void updatePositions(bool force);
198 
200  void updateAtomData();
201 
203  QMap<unsigned int, Position> referencePositionMap;
204 
206  int interval;
207 };
208 
209 inline void LoadsSimulationDriver::getInitialPosition(unsigned int targetId, double pos[3]) {
210  QMap<unsigned int, Position>::const_iterator it = initialPositionMap.find(targetId);
211  if (it == initialPositionMap.end())
212  pos[0] = pos[1] = pos[2] = 0.0;
213  else {
214  pos[0] = it.value().x;
215  pos[1] = it.value().y;
216  pos[2] = it.value().z;
217  }
218 }
219 
220 
221 #endif // LOADSSIMULATIONDRIVER_H
222 
223