NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgSimView.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed
7  * under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * http://www.apache.org/licenses/LICENSE-2.0.
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
15  * either express or implied. See the License for the specific language
16  * governing permissions and limitations under the License.
17 */
18 
19 #ifndef TG_SIM_VIEW_H
20 #define TG_SIM_VIEW_H
21 
29 // Forward declarations
30 class tgModelVisitor;
31 class tgSimulation;
32 class tgWorld;
33 
34 class tgSimView
35 {
36 
41  friend class tgSimulation;
42 
43 public:
44 
56  double stepSize = 1.0/1000.0,
57  double renderRate = 1.0/60.0);
58 
59  virtual ~tgSimView();
60 
65  tgWorld& world() { return m_world; }
66 
71  virtual void setup();
72 
77  virtual void teardown();
78 
82  virtual void run();
83 
87  virtual void run(int steps);
88 
92  virtual void render() const;
93 
97  virtual void render(const tgModelVisitor& r) const;
98 
103  virtual void reset();
104 
112  void setRenderRate(double renderRate);
113 
118  double getRenderRate() const { return m_renderRate; }
119 
127  void setStepSize(double stepSize);
128 
133  double getStepSize() const { return m_stepSize; }
134 
135 protected:
136 
145  void bindToSimulation(tgSimulation& simulation);
146 
152  void releaseFromSimulation();
153 
159  void bindToWorld(tgWorld& world);
160 
162  bool isInitialzed() const { return m_initialized; }
163 
164 protected:
165 
173 
180 
188  double m_stepSize;
189 
199  double m_renderRate;
200 
205  double m_renderTime;
206 
207 private:
208 
210  bool invariant() const;
211 
212 private:
213 
215  tgWorld& m_world;
216 
218  bool m_initialized;
219 };
220 
221 #endif // TG_SIM_VIEW_H
void bindToWorld(tgWorld &world)
Definition: tgSimView.cpp:105
bool isInitialzed() const
Definition: tgSimView.h:162
virtual void render() const
Definition: tgSimView.cpp:161
double m_stepSize
Definition: tgSimView.h:188
double m_renderTime
Definition: tgSimView.h:205
void bindToSimulation(tgSimulation &simulation)
Definition: tgSimView.cpp:77
tgModelVisitor * m_pModelVisitor
Definition: tgSimView.h:179
virtual void teardown()
Definition: tgSimView.cpp:121
double getStepSize() const
Definition: tgSimView.h:133
void releaseFromSimulation()
Definition: tgSimView.cpp:96
double getRenderRate() const
Definition: tgSimView.h:118
void setRenderRate(double renderRate)
Definition: tgSimView.cpp:188
virtual void setup()
Definition: tgSimView.cpp:109
void setStepSize(double stepSize)
Definition: tgSimView.cpp:196
double m_renderRate
Definition: tgSimView.h:199
tgSimulation * m_pSimulation
Definition: tgSimView.h:172
tgWorld & world()
Definition: tgSimView.h:65
virtual void reset()
Definition: tgSimView.cpp:179
virtual void run()
Definition: tgSimView.cpp:132
tgSimView(tgWorld &world, double stepSize=1.0/1000.0, double renderRate=1.0/60.0)
Definition: tgSimView.cpp:36