DART  6.6.2
SimWindow.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2018, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  * https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * This code incorporates portions of Open Dynamics Engine
19  * (Copyright (c) 2001-2004, Russell L. Smith. All rights
20  * reserved.) and portions of FCL (Copyright (c) 2011, Willow
21  * Garage, Inc. All rights reserved.), which were released under
22  * the same BSD license as below
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
25  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
26  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
29  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
32  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
33  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #ifndef DART_GUI_SIMWINDOW_HPP_
40 #define DART_GUI_SIMWINDOW_HPP_
41 
42 #include <vector>
43 
44 #include <Eigen/Dense>
45 
47 #include "dart/gui/Win3D.hpp"
49 
50 namespace dart {
51 namespace gui {
52 
53 class GraphWindow;
54 
56 class SimWindow : public Win3D {
57 public:
59  SimWindow();
60 
62  virtual ~SimWindow();
63 
65  virtual void timeStepping();
66 
67  virtual void drawWorld() const;
68 
69  virtual void drawSkeletons() const;
70 
71  DART_DEPRECATED(6.0)
72  virtual void drawSkels();
73 
74  DART_DEPRECATED(6.0)
75  virtual void drawEntities();
76 
78  void displayTimer(int _val) override;
79 
81  void draw() override;
82 
84  void keyboard(unsigned char _key, int _x, int _y) override;
85 
88 
90  void saveWorld();
91 
93  void plot(Eigen::VectorXd& _data);
94 // bool isSimulating() const { return mSimulating; }
95 
96 // void setSimulatingFlag(int _flag) { mSimulating = _flag; }
97 
98 protected:
99 
100  virtual void drawSkeleton(
101  const dynamics::Skeleton* skeleton,
102  const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5),
103  bool useDefaultColor = true) const;
104 
105  virtual void drawEntity(
106  const dynamics::Entity* entity,
107  const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5),
108  bool useDefaultColor = true) const;
109 
110  virtual void drawBodyNode(
111  const dynamics::BodyNode* bodyNode,
112  const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5),
113  bool useDefaultColor = true,
114  bool recursive = false) const;
115 
116  virtual void drawShapeFrame(
117  const dynamics::ShapeFrame* shapeFrame,
118  const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5),
119  bool useDefaultColor = true) const;
120 
121  virtual void drawShape(
122  const dynamics::Shape* shape,
123  const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5)) const;
124 
125  virtual void drawPointMasses(
126  const std::vector<dynamics::PointMass*> pointMasses,
127  const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5),
128  bool useDefaultColor = true) const;
129 
130  virtual void drawMarker(
131  const dynamics::Marker* marker,
132  const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5),
133  bool useDefaultColor = true) const;
134 
137 
140 
142  bool mPlay;
143 
146 
149 
152 
154  std::vector<GraphWindow*> mGraphWindows;
155 };
156 
157 } // namespace gui
158 } // namespace dart
159 
160 #endif // DART_GUI_SIMWINDOW_HPP_
#define DART_DEPRECATED(version)
Definition: Deprecated.hpp:51
BodyNode class represents a single node of the skeleton.
Definition: BodyNode.hpp:78
Entity class is a base class for any objects that exist in the kinematic tree structure of DART.
Definition: Entity.hpp:60
Definition: Marker.hpp:50
Definition: ShapeFrame.hpp:164
Definition: Shape.hpp:49
class Skeleton
Definition: Skeleton.hpp:59
Definition: SimWindow.hpp:56
bool mShowPointMasses
If true, render point masses of soft bodies.
Definition: SimWindow.hpp:148
SimWindow()
Definition: SimWindow.cpp:70
simulation::WorldPtr mWorld
Definition: SimWindow.hpp:136
virtual void drawSkels()
Definition: SimWindow.cpp:114
virtual void drawShapeFrame(const dynamics::ShapeFrame *shapeFrame, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5), bool useDefaultColor=true) const
Definition: SimWindow.cpp:359
void saveWorld()
Save world in 'tempWorld.txt'.
Definition: SimWindow.cpp:259
virtual void drawWorld() const
Definition: SimWindow.cpp:98
void displayTimer(int _val) override
Definition: SimWindow.cpp:126
bool mSimulating
Definition: SimWindow.hpp:145
bool mPlay
Definition: SimWindow.hpp:142
virtual ~SimWindow()
Definition: SimWindow.cpp:88
int mPlayFrame
Definition: SimWindow.hpp:139
virtual void drawMarker(const dynamics::Marker *marker, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5), bool useDefaultColor=true) const
Definition: SimWindow.cpp:518
bool mShowMarkers
If true, render markers.
Definition: SimWindow.hpp:151
void keyboard(unsigned char _key, int _x, int _y) override
Definition: SimWindow.cpp:214
virtual void drawEntity(const dynamics::Entity *entity, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5), bool useDefaultColor=true) const
Definition: SimWindow.cpp:286
virtual void drawSkeletons() const
Definition: SimWindow.cpp:107
virtual void timeStepping()
Definition: SimWindow.cpp:93
virtual void drawEntities()
Definition: SimWindow.cpp:120
virtual void drawSkeleton(const dynamics::Skeleton *skeleton, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5), bool useDefaultColor=true) const
Definition: SimWindow.cpp:274
virtual void drawPointMasses(const std::vector< dynamics::PointMass * > pointMasses, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5), bool useDefaultColor=true) const
Definition: SimWindow.cpp:481
virtual void drawShape(const dynamics::Shape *shape, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5)) const
Definition: SimWindow.cpp:386
std::vector< GraphWindow * > mGraphWindows
Array of graph windows.
Definition: SimWindow.hpp:154
virtual void drawBodyNode(const dynamics::BodyNode *bodyNode, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5), bool useDefaultColor=true, bool recursive=false) const
Definition: SimWindow.cpp:309
void draw() override
Definition: SimWindow.cpp:142
void plot(Eigen::VectorXd &_data)
Plot _data in a 2D window.
Definition: SimWindow.cpp:266
void setWorld(dart::simulation::WorldPtr _world)
Definition: SimWindow.cpp:255
Definition: Win3D.hpp:44
std::shared_ptr< World > WorldPtr
Definition: World.hpp:313
Definition: BulletCollisionDetector.cpp:63