Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Public Slots | Signals | Public Member Functions | Private Member Functions | Private Attributes | List of all members
LoadsSimulationDriver Class Reference

This class manages the display of a simulation (either an already made simulation opened in a single lml file by LoadsMovie, or a simple step given by a simulation motor). More...

#include <LoadsSimulationDriver.h>

Classes

struct  Position
 private struct to store the initial positions More...

Public Slots

void play ()
 Slot called when at each timer tick (i.e. after the same interval of time)

Signals

void doOneStep ()
 signal call when one step is to be performed

Public Member Functions

double getDt () const
 get delta-t
double getNextRefreshTime ()
 get the next planed time when the 3D will be refreshed
double getRefreshDt () const
 get delta-t between 3d view refresh
double getTime () const
 get time
double getTMax () const
 get tmax
double getTMin () const
 get tmin
bool isTimerActive ()
 is the timer currently running
 LoadsSimulationDriver (LoadsManager *, Loads *)
 Constructor.
void maxSpeed ()
 set the timer interval to maxSpeed (1000Hz)
void quicker ()
 decrease the timer interval by 5ms, thus calling doOneStep more often
void resetPositions ()
 reset the 3D positions to the initial value (stored in the map during init), (do not update the display)
void resetTMaxToDefault ()
 set default tmax (using the current loads last event)
void resetTMinToDefault ()
 set default tmin (using the current loads first event)
void resetToDefault ()
 set tmin, tmax and dt to default
void rewind ()
 rewind time to tMin (do not update the display)
void setDt (double dt)
 set the delta-t (default is 0.1)
void setLoads (Loads *)
 set the current loads to be displayed
void setRefreshDt (double)
 set delta-t between 3d view refresh (default 0.1)
void setTime (double)
 set the time to a different value ("jump" to a given time)
void setTMax (double)
 set the new tMax
void setTMin (double)
 set the new tMin
void slower ()
 increase the timer interval by 5ms, thus calling doOneStep less often
void startTimer ()
 starts the timer that will repeatedly call play and emit doOneStep
void stopTimer ()
 stop the timer
void updateDisplay (bool force)
 update the display using the current loads (and refresh the 3D viewers if parameter is true)
virtual ~LoadsSimulationDriver ()
 Destructor.

Private Member Functions

void getInitialPosition (unsigned int, double[3])
 get an initial position using the key (i.e. targetId)
void init ()
 init display and initial positions.
void updateAtomData ()
 update Atom data
void updatePositions (bool force)
 update the positions depending on the current loads (and refresh the DCs position if parameter is true)

Private Attributes

Loads * currentLoads
 the current loads
double dt
 the delta-t used to change t
QMap< unsigned int, PositioninitialPositionMap
 initial positions of all the targets
int interval
 timer interval in ms
double lastRefreshTime
 last time the display was refresh
double lastUpdateTime
 last time we updated the display
LoadsManagermyLM
 the load manager
QMap< unsigned int, PositionreferencePositionMap
 the reference pm positions (used to display the distances, ...)
double refreshDt
 the delta-t between two refresh of the 3D view
double t
 simulation time
QTimer * timer
 the simulation timer
double tMax
 last event time
double tMin
 first event time

Detailed Description

This class manages the display of a simulation (either an already made simulation opened in a single lml file by LoadsMovie, or a simple step given by a simulation motor).

It is just a utility class for handling the display of loads a given time, using a timer.

Constructor & Destructor Documentation

LoadsSimulationDriver::LoadsSimulationDriver ( LoadsManager lm,
Loads *  initialLoads 
)

Constructor.

Set the load manager, and (initial) current loads (if the loads ptr is null, then all atoms initial positions will be stored; just in case they have to move in the future)

References dt, init(), lastRefreshTime, lastUpdateTime, myLM, refreshDt, setLoads(), timer, tMax, and tMin.

LoadsSimulationDriver::~LoadsSimulationDriver ( )
virtual

Destructor.

References stopTimer(), and timer.

Member Function Documentation

void LoadsSimulationDriver::doOneStep ( )
signal

signal call when one step is to be performed

Referenced by play().

double LoadsSimulationDriver::getDt ( ) const
void LoadsSimulationDriver::getInitialPosition ( unsigned int  targetId,
double  pos[3] 
)
inlineprivate

get an initial position using the key (i.e. targetId)

References initialPositionMap.

Referenced by updateAtomData().

double LoadsSimulationDriver::getNextRefreshTime ( )

get the next planed time when the 3D will be refreshed

References lastRefreshTime, and refreshDt.

Referenced by LoadsSimulation::doOneStep(), updateDisplay(), and updatePositions().

double LoadsSimulationDriver::getRefreshDt ( ) const

get delta-t between 3d view refresh

References refreshDt.

Referenced by LoadsSimulation::doOneStep(), LoadsSimulation::LoadsSimulation(), and LoadsSimulation::pause().

double LoadsSimulationDriver::getTime ( ) const
double LoadsSimulationDriver::getTMax ( ) const
double LoadsSimulationDriver::getTMin ( ) const
void LoadsSimulationDriver::init ( )
private

init display and initial positions.

stores all the initial position of the atoms implied in the loads. if current loads is NULL, then all the atoms will have their initial positions stored.

References currentLoads, PMManagerDC::getDC(), PMManagerDC::getPhysicalModel(), LoadsManager::getPMManagerDC(), initialPositionMap, maxSpeed(), myLM, play(), resetTMaxToDefault(), resetTMinToDefault(), rewind(), timer, tMax, tMin, LoadsSimulationDriver::Position::x, LoadsSimulationDriver::Position::y, and LoadsSimulationDriver::Position::z.

Referenced by LoadsSimulationDriver().

bool LoadsSimulationDriver::isTimerActive ( )

is the timer currently running

References timer.

Referenced by LoadsSimulation::doOneStep(), LoadsMovie::play(), and LoadsSimulation::simulate().

void LoadsSimulationDriver::maxSpeed ( )

set the timer interval to maxSpeed (1000Hz)

References interval, and timer.

Referenced by init(), quicker(), and LoadsSimulation::simulate().

void LoadsSimulationDriver::play ( )
slot

Slot called when at each timer tick (i.e. after the same interval of time)

References doOneStep(), startTimer(), and timer.

Referenced by init().

void LoadsSimulationDriver::quicker ( )

decrease the timer interval by 5ms, thus calling doOneStep more often

References interval, maxSpeed(), and timer.

void LoadsSimulationDriver::resetPositions ( )

reset the 3D positions to the initial value (stored in the map during init), (do not update the display)

References PMManagerDC::getDC(), PMManagerDC::getPhysicalModel(), LoadsManager::getPMManagerDC(), initialPositionMap, lastRefreshTime, lastUpdateTime, myLM, AtomDC::resetAlreadyMovedFlag(), and AtomDC::setPosition().

Referenced by LoadsMovie::reset(), and rewind().

void LoadsSimulationDriver::resetTMaxToDefault ( )

set default tmax (using the current loads last event)

References currentLoads, myLM, and tMax.

Referenced by LoadsMovie::defaultTMax(), init(), LoadsSimulation::LoadsSimulation(), and resetToDefault().

void LoadsSimulationDriver::resetTMinToDefault ( )

set default tmin (using the current loads first event)

References currentLoads, myLM, and tMin.

Referenced by LoadsMovie::defaultTMin(), init(), and resetToDefault().

void LoadsSimulationDriver::resetToDefault ( )

set tmin, tmax and dt to default

References dt, refreshDt, resetTMaxToDefault(), and resetTMinToDefault().

void LoadsSimulationDriver::rewind ( )

rewind time to tMin (do not update the display)

References dt, LoadsManager::getLoads(), myLM, resetPositions(), t, tMin, and updatePositions().

Referenced by LoadsMovie::doOneStep(), init(), LoadsMovie::rewind(), and setTime().

void LoadsSimulationDriver::setDt ( double  dt)

set the delta-t (default is 0.1)

References dt.

Referenced by LoadsMovie::dtChanged(), LoadsSimulation::dtChanged(), and LoadsSimulation::LoadsSimulation().

void LoadsSimulationDriver::setLoads ( Loads *  l)

set the current loads to be displayed

References currentLoads.

Referenced by LoadsSimulation::doOneStep(), LoadsSimulationDriver(), and LoadsSimulation::rewind().

void LoadsSimulationDriver::setRefreshDt ( double  dt)

set delta-t between 3d view refresh (default 0.1)

References dt, and refreshDt.

Referenced by LoadsMovie::dtChanged(), LoadsSimulation::LoadsSimulation(), LoadsSimulation::pause(), and LoadsSimulation::refreshDtChanged().

void LoadsSimulationDriver::setTime ( double  newTime)
void LoadsSimulationDriver::setTMax ( double  newTMax)
void LoadsSimulationDriver::setTMin ( double  newTMin)

set the new tMin

References tMin.

Referenced by LoadsMovie::tMinChanged().

void LoadsSimulationDriver::slower ( )

increase the timer interval by 5ms, thus calling doOneStep less often

References interval, and timer.

Referenced by LoadsSimulation::doOneStep().

void LoadsSimulationDriver::startTimer ( )

starts the timer that will repeatedly call play and emit doOneStep

References interval, and timer.

Referenced by LoadsMovie::play(), play(), and LoadsSimulation::simulate().

void LoadsSimulationDriver::stopTimer ( )
void LoadsSimulationDriver::updateAtomData ( )
private
void LoadsSimulationDriver::updateDisplay ( bool  force)

update the display using the current loads (and refresh the 3D viewers if parameter is true)

Parameters
forceif true force display update independantly from refresh dt (default is false)

References getNextRefreshTime(), lastRefreshTime, myLM, t, updateAtomData(), LoadsManager::updateLoadsDisplay(), and updatePositions().

Referenced by LoadsMovie::updateDisplay(), and LoadsSimulation::updateDisplay().

void LoadsSimulationDriver::updatePositions ( bool  force)
private

update the positions depending on the current loads (and refresh the DCs position if parameter is true)

References currentLoads, PMManagerDC::getDC(), getNextRefreshTime(), PMManagerDC::getPhysicalModel(), LoadsManager::getPMManagerDC(), lastUpdateTime, myLM, AtomDC::resetAlreadyMovedFlag(), AtomDC::setPosition(), t, and updateAtomData().

Referenced by rewind(), setTime(), and updateDisplay().

Member Data Documentation

Loads* LoadsSimulationDriver::currentLoads
private
double LoadsSimulationDriver::dt
private

the delta-t used to change t

Referenced by getDt(), LoadsSimulationDriver(), resetToDefault(), rewind(), setDt(), setRefreshDt(), and setTime().

QMap<unsigned int, Position> LoadsSimulationDriver::initialPositionMap
private

initial positions of all the targets

Referenced by getInitialPosition(), init(), resetPositions(), and updateAtomData().

int LoadsSimulationDriver::interval
private

timer interval in ms

Referenced by maxSpeed(), quicker(), slower(), and startTimer().

double LoadsSimulationDriver::lastRefreshTime
private

last time the display was refresh

Referenced by getNextRefreshTime(), LoadsSimulationDriver(), resetPositions(), and updateDisplay().

double LoadsSimulationDriver::lastUpdateTime
private

last time we updated the display

Referenced by LoadsSimulationDriver(), resetPositions(), and updatePositions().

LoadsManager* LoadsSimulationDriver::myLM
private
QMap<unsigned int, Position> LoadsSimulationDriver::referencePositionMap
private

the reference pm positions (used to display the distances, ...)

Referenced by updateAtomData().

double LoadsSimulationDriver::refreshDt
private

the delta-t between two refresh of the 3D view

Referenced by getNextRefreshTime(), getRefreshDt(), LoadsSimulationDriver(), resetToDefault(), and setRefreshDt().

double LoadsSimulationDriver::t
private

simulation time

Referenced by getTime(), rewind(), setTime(), updateDisplay(), and updatePositions().

QTimer* LoadsSimulationDriver::timer
private
double LoadsSimulationDriver::tMax
private

last event time

Referenced by getTMax(), init(), LoadsSimulationDriver(), resetTMaxToDefault(), and setTMax().

double LoadsSimulationDriver::tMin
private

The documentation for this class was generated from the following files: