Computer Assited Medical Intervention Tool Kit  version 4.0
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-2016 Univ. Grenoble Alpes, 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 updateAtomData();
69 
71  void resetToDefault();
72 
74  void resetTMinToDefault();
75 
77  double getTMin() const;
78 
80  void setTMin(double);
81 
83  void resetTMaxToDefault();
84 
86  double getTMax() const;
87 
89  void setTMax(double);
90 
92  void setDt(double dt);
93 
95  double getDt() const;
96 
98  double getTime() const;
99 
101  void setTime(double);
102 
104  double getRefreshDt() const;
105 
107  void setRefreshDt(double);
108 
110  double getNextRefreshTime();
111 
113  void setLoads(Loads *);
114 
116  void startTimer();
117 
119  void stopTimer();
120 
122  bool isTimerActive();
123 
125  void resetPositions();
126 
128  void rewind();
129 
131  void slower();
132 
134  void quicker();
135 
137  void maxSpeed();
138 
139 signals:
140 
142  void doOneStep();
143 
144 public slots:
145 
147  void play();
148 
149 private :
151  struct Position {
152  double x;
153  double y;
154  double z;
155  };
156 
159 
162 
167  void init();
168 
170  QMap<unsigned int, Position> initialPositionMap;
171 
173  QTimer *timer;
174 
176  double t;
177 
179  double dt;
180 
182  double tMin;
183 
185  double tMax;
186 
188  double refreshDt;
189 
192 
195 
197  void getInitialPosition(unsigned int, double [3]);
198 
200  void updatePositions(bool force);
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)
Definition: LoadsSimulationDriver.cpp:573
double getTMax() const
get tmax
Definition: LoadsSimulationDriver.cpp:599
void slower()
increase the timer interval by 5ms, thus calling doOneStep less often
Definition: LoadsSimulationDriver.cpp:656
void getInitialPosition(unsigned int, double [3])
get an initial position using the key (i.e. targetId)
Definition: LoadsSimulationDriver.h:209
LoadsManager * myLM
the load manager
Definition: LoadsSimulationDriver.h:158
bool isTimerActive()
is the timer currently running
Definition: LoadsSimulationDriver.cpp:560
void maxSpeed()
set the timer interval to maxSpeed (1000Hz)
Definition: LoadsSimulationDriver.cpp:676
Loads * currentLoads
the current loads
Definition: LoadsSimulationDriver.h:161
void quicker()
decrease the timer interval by 5ms, thus calling doOneStep more often
Definition: LoadsSimulationDriver.cpp:664
QMap< unsigned int, Position > initialPositionMap
initial positions of all the targets
Definition: LoadsSimulationDriver.h:170
private struct to store the initial positions
Definition: LoadsSimulationDriver.h:151
LoadsSimulationDriver(LoadsManager *, Loads *)
Constructor.
Definition: LoadsSimulationDriver.cpp:54
virtual ~LoadsSimulationDriver()
Destructor.
Definition: LoadsSimulationDriver.cpp:72
double z
Definition: LoadsSimulationDriver.h:154
double refreshDt
the delta-t between two refresh of the 3D view
Definition: LoadsSimulationDriver.h:188
void rewind()
rewind time to tMin (do not update the display)
Definition: LoadsSimulationDriver.cpp:167
double tMin
first event time
Definition: LoadsSimulationDriver.h:182
double getTMin() const
get tmin
Definition: LoadsSimulationDriver.cpp:581
QTimer * timer
the simulation timer
Definition: LoadsSimulationDriver.h:173
void setDt(double dt)
set the delta-t (default is 0.1)
Definition: LoadsSimulationDriver.cpp:614
void resetTMaxToDefault()
set default tmax (using the current loads last event)
Definition: LoadsSimulationDriver.cpp:591
void setTime(double)
set the time to a different value ("jump" to a given time)
Definition: LoadsSimulationDriver.cpp:625
This class makes it possible to manage a list of "Load".
Definition: Loads.h:71
void updatePositions(bool force)
update the positions depending on the current loads (and refresh the DCs position if parameter is tru...
Definition: LoadsSimulationDriver.cpp:412
void updateAtomData()
only update the Atom data
Definition: LoadsSimulationDriver.cpp:213
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)
Definition: LoadsSimulationDriver.cpp:514
void resetPositions()
reset the 3D positions to the initial value (stored in the map during init), (do not update the displ...
Definition: LoadsSimulationDriver.cpp:187
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:194
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
Definition: LoadsSimulationDriver.cpp:604
double tMax
last event time
Definition: LoadsSimulationDriver.h:185
void updateDisplay(bool force)
update the display using the current loads (and refresh the 3D viewers if parameter is true) ...
Definition: LoadsSimulationDriver.cpp:525
void init()
init display and initial positions.
Definition: LoadsSimulationDriver.cpp:80
void setLoads(Loads *)
set the current loads to be displayed
Definition: LoadsSimulationDriver.cpp:161
void startTimer()
starts the timer that will repeatedly call play and emit doOneStep
Definition: LoadsSimulationDriver.cpp:550
double dt
the delta-t used to change t
Definition: LoadsSimulationDriver.h:179
void stopTimer()
stop the timer
Definition: LoadsSimulationDriver.cpp:555
void resetToDefault()
set tmin, tmax and dt to default
Definition: LoadsSimulationDriver.cpp:566
double getNextRefreshTime()
get the next planed time when the 3D will be refreshed
Definition: LoadsSimulationDriver.cpp:544
int interval
timer interval in ms
Definition: LoadsSimulationDriver.h:206
double getDt() const
get delta-t
Definition: LoadsSimulationDriver.cpp:609
double getRefreshDt() const
get delta-t between 3d view refresh
Definition: LoadsSimulationDriver.cpp:646
double x
Definition: LoadsSimulationDriver.h:152
double t
simulation time
Definition: LoadsSimulationDriver.h:176
This dialog allows one to see the simulation It plays the impload, allowing the user to see the evolu...
Definition: LoadsMovie.h:42
void setTMin(double)
set the new tMin
Definition: LoadsSimulationDriver.cpp:586
void setRefreshDt(double)
set delta-t between 3d view refresh (default 0.1)
Definition: LoadsSimulationDriver.cpp:651
void doOneStep()
signal call when one step is to be performed
double y
Definition: LoadsSimulationDriver.h:153
double lastUpdateTime
last time we updated the display
Definition: LoadsSimulationDriver.h:191
double getTime() const
get time
Definition: LoadsSimulationDriver.cpp:620