Computer Assited Medical Intervention Tool Kit  version 3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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-2014 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 
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 
void resetTMinToDefault()
set default tmin (using the current loads first event)
void slower()
increase the timer interval by 5ms, thus calling doOneStep less often
LoadsManager * myLM
the load manager
Definition: LoadsSimulationDriver.h:155
bool isTimerActive()
is the timer currently running
void maxSpeed()
set the timer interval to maxSpeed (1000Hz)
virtual ~LoadsSimulationDriver()
Destructor.
Loads * currentLoads
the current loads
Definition: LoadsSimulationDriver.h:158
void quicker()
decrease the timer interval by 5ms, thus calling doOneStep more often
QMap< unsigned int, Position > initialPositionMap
initial positions of all the targets
Definition: LoadsSimulationDriver.h:167
private struct to store the initial positions
Definition: LoadsSimulationDriver.h:148
LoadsSimulationDriver(LoadsManager *, Loads *)
Constructor.
double getDt() const
get delta-t
double z
Definition: LoadsSimulationDriver.h:151
double refreshDt
the delta-t between two refresh of the 3D view
Definition: LoadsSimulationDriver.h:185
void rewind()
rewind time to tMin (do not update the display)
void getInitialPosition(unsigned int, double[3])
get an initial position using the key (i.e. targetId)
Definition: LoadsSimulationDriver.h:209
double tMin
first event time
Definition: LoadsSimulationDriver.h:179
QTimer * timer
the simulation timer
Definition: LoadsSimulationDriver.h:170
void setDt(double dt)
set the delta-t (default is 0.1)
void resetTMaxToDefault()
set default tmax (using the current loads last event)
void setTime(double)
set the time to a different value ("jump" to a given time)
This class makes it possible to manage a list of "Load".
Definition: Loads.h:70
void updatePositions(bool force)
update the positions depending on the current loads (and refresh the DCs position if parameter is tru...
void updateAtomData()
update Atom data
QMap< unsigned int, Position > referencePositionMap
the reference pm positions (used to display the distances, ...)
Definition: LoadsSimulationDriver.h:203
void play()
Slot called when at each timer tick (i.e. after the same interval of time)
void resetPositions()
reset the 3D positions to the initial value (stored in the map during init), (do not update the displ...
This class manages the applied all loads (see LML), deformation add-on, atom data monitoring and atom...
Definition: LoadsManager.h:69
double lastRefreshTime
last time the display was refresh
Definition: LoadsSimulationDriver.h:191
This class manages the display of a simulation (either an already made simulation opened in a single ...
Definition: LoadsSimulationDriver.h:47
void setTMax(double)
set the new tMax
double tMax
last event time
Definition: LoadsSimulationDriver.h:182
void updateDisplay(bool force)
update the display using the current loads (and refresh the 3D viewers if parameter is true) ...
void init()
init display and initial positions.
void setLoads(Loads *)
set the current loads to be displayed
double getTime() const
get time
void startTimer()
starts the timer that will repeatedly call play and emit doOneStep
double dt
the delta-t used to change t
Definition: LoadsSimulationDriver.h:176
double getTMin() const
get tmin
void stopTimer()
stop the timer
void resetToDefault()
set tmin, tmax and dt to default
double getNextRefreshTime()
get the next planed time when the 3D will be refreshed
int interval
timer interval in ms
Definition: LoadsSimulationDriver.h:206
double getRefreshDt() const
get delta-t between 3d view refresh
double x
Definition: LoadsSimulationDriver.h:149
double t
simulation time
Definition: LoadsSimulationDriver.h:173
This dialog allows to see the simulation It plays the impload, allowing the user to see the evolution...
Definition: LoadsMovie.h:42
void setTMin(double)
set the new tMin
void setRefreshDt(double)
set delta-t between 3d view refresh (default 0.1)
void doOneStep()
signal call when one step is to be performed
double y
Definition: LoadsSimulationDriver.h:150
double lastUpdateTime
last time we updated the display
Definition: LoadsSimulationDriver.h:188
double getTMax() const
get tmax