NTRT Simulator
 All Classes Files Functions Variables Typedefs Friends Pages
tgSimView Class Reference
Inheritance diagram for tgSimView:
Collaboration diagram for tgSimView:

Public Member Functions

 tgSimView (tgWorld &world, double stepSize=1.0/120.0, double renderRate=1.0/60.0)
 
tgWorldworld ()
 
virtual void setup ()
 
virtual void teardown ()
 
virtual void run ()
 
virtual void run (int steps)
 
virtual void render () const
 
virtual void render (const tgModelVisitor &r) const
 
virtual void reset ()
 
void setRenderRate (double renderRate)
 
double getRenderRate () const
 
void setStepSize (double stepSize)
 
double getStepSize () const
 

Protected Member Functions

void bindToSimulation (tgSimulation &simulation)
 
void releaseFromSimulation ()
 
void bindToWorld (tgWorld &world)
 
bool isInitialzed () const
 

Protected Attributes

tgSimulationm_pSimulation
 
tgModelVisitorm_pModelVisitor
 
double m_stepSize
 
double m_renderRate
 
double m_renderTime
 

Friends

class tgSimulation
 

Detailed Description

Definition at line 33 of file tgSimView.h.

Constructor & Destructor Documentation

tgSimView::tgSimView ( tgWorld world,
double  stepSize = 1.0/120.0,
double  renderRate = 1.0/60.0 
)

The only constructor..

Parameters
[in]worlda reference to the tgWorld being simulated.
[in]stepSizethe time interval for advancing the simulation; std::invalid_argument is thrown if not positive
[in]renderRatethe time interval for updating the graphics; std::invalid_argument is thrown if less than stepSize
Exceptions
std::invalid_argumentif stepSize is not positive or renderRate is less than stepSize

Definition at line 35 of file tgSimView.cpp.

Member Function Documentation

void tgSimView::bindToSimulation ( tgSimulation simulation)
protected

Called by a constructor of friend class tgSimulation when an instance of this class is passed as argument to the constructor. Cache a back pointer to the tgSimulation

Parameters
[in,out]simulationa reference to the tgSimulation being constructed
Exceptions
std::invalid_argumentif the tgSimView already has a back pointer.

Definition at line 76 of file tgSimView.cpp.

Here is the caller graph for this function:

void tgSimView::bindToWorld ( tgWorld world)
protected

When bound to a tgSimulation, a tgWorld becomes available for the first time.

Parameters
[in,out]worlda reference to a newly-available tgWorld

Definition at line 104 of file tgSimView.cpp.

Here is the caller graph for this function:

double tgSimView::getRenderRate ( ) const
inline

Return the interval in seconds at which the graphics are rendered.

Returns
the interval in seconds at which the graphics are rendered

Definition at line 101 of file tgSimView.h.

double tgSimView::getStepSize ( ) const
inline

Return the interval in seconds at which the graphics are rendered.

Returns
the interval in seconds at which the graphics are rendered

Definition at line 116 of file tgSimView.h.

bool tgSimView::isInitialzed ( ) const
inlineprotected
Todo:
Get rid of this.

Definition at line 145 of file tgSimView.h.

Here is the caller graph for this function:

void tgSimView::releaseFromSimulation ( )
protected

Called by the destructor of friend class tgSimulation. Assure that m_pView has a NULL back pointer to its tgSimulation. This allows the tgSimView to be re-used.

Definition at line 95 of file tgSimView.cpp.

void tgSimView::run ( )
virtual

Run until stoppeed by user

Reimplemented in tgSimViewGraphics.

Definition at line 131 of file tgSimView.cpp.

Here is the caller graph for this function:

void tgSimView::run ( int  steps)
virtual

Run for a specific number of steps

Reimplemented in tgSimViewGraphics.

Definition at line 137 of file tgSimView.cpp.

Here is the call graph for this function:

void tgSimView::setRenderRate ( double  renderRate)

Set the interval in seconds at which the graphics are to be rendered. It is set to the minimum of the renderRate argument and the current step size.

Parameters
[in]renderRatethe interval in seconds at which the graphics are to be rendered

Definition at line 189 of file tgSimView.cpp.

Here is the caller graph for this function:

void tgSimView::setStepSize ( double  stepSize)

Set the interval in seconds at which the simulation is advanced. The render rate is adjusted to be no less than stepSize.

Parameters
[in]stepSizethe interval in seconds at which the simulation is advanced; std::invalid_argument is thrown if stepSize is not positive
Exceptions
std::invalid_argumentif stepSize is not positive

Definition at line 197 of file tgSimView.cpp.

Here is the call graph for this function:

tgWorld& tgSimView::world ( )
inline

Return a reference to the tgWorld being simulated.

Returns
a reference to the tgWorld being simulated

Definition at line 64 of file tgSimView.h.

Friends And Related Function Documentation

friend class tgSimulation
friend

Allow tgSimulation to set tgSimView::m_pSimulation to be a back pointer to itself when the tgSimView is passed to the tgSimulation.

Definition at line 40 of file tgSimView.h.

Member Data Documentation

tgModelVisitor* tgSimView::m_pModelVisitor
protected

An object that knows how to visit the various models for rendering or data logging.

Note
This is a pointer to avoid #including the header file.

Definition at line 162 of file tgSimView.h.

tgSimulation* tgSimView::m_pSimulation
protected

A back pointer to the simulation that owns this view. Made protected to allow tgSimulatorWithGraphics to inherit it. The constructor initializes it to NULL and it becomes non-NULL when added to a simulation.

Definition at line 155 of file tgSimView.h.

double tgSimView::m_renderRate
protected

The interval in seconds at which the graphics are rendered. It must be be greater than or equal to m_stepSize.

Definition at line 175 of file tgSimView.h.

double tgSimView::m_renderTime
protected

The time in seconds when the next render should be. It must be non-negative.

Definition at line 181 of file tgSimView.h.

double tgSimView::m_stepSize
protected

The interval in seconds at which the simulation is advanced. It must be positive and it must be less than or equal to m_renderRate.

Definition at line 169 of file tgSimView.h.


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