DART  6.10.1
SimWindow.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2021, 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 SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef DART_GUI_GLUT_SIMWINDOW_HPP_
34 #define DART_GUI_GLUT_SIMWINDOW_HPP_
35 
36 #include <vector>
37 
38 #include <Eigen/Dense>
39 
41 #include "dart/gui/glut/Win3D.hpp"
43 
44 namespace dart {
45 namespace gui {
46 namespace glut {
47 
48 class GraphWindow;
49 
51 class SimWindow : public Win3D
52 {
53 public:
55  SimWindow();
56 
58  virtual ~SimWindow();
59 
61  virtual void timeStepping();
62 
63  virtual void drawWorld() const;
64 
65  virtual void drawSkeletons() const;
66 
67  DART_DEPRECATED(6.0)
68  virtual void drawSkels();
69 
70  DART_DEPRECATED(6.0)
71  virtual void drawEntities();
72 
74  void displayTimer(int _val) override;
75 
77  void draw() override;
78 
80  void keyboard(unsigned char _key, int _x, int _y) override;
81 
84 
86  void saveWorld();
87 
89  void plot(Eigen::VectorXd& _data);
90  // bool isSimulating() const { return mSimulating; }
91 
92  // void setSimulatingFlag(int _flag) { mSimulating = _flag; }
93 
94 protected:
95  virtual void drawSkeleton(
96  const dynamics::Skeleton* skeleton,
97  const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5),
98  bool useDefaultColor = true) const;
99 
100  virtual void drawEntity(
101  const dynamics::Entity* entity,
102  const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5),
103  bool useDefaultColor = true) const;
104 
105  virtual void drawBodyNode(
106  const dynamics::BodyNode* bodyNode,
107  const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5),
108  bool useDefaultColor = true,
109  bool recursive = false) const;
110 
111  virtual void drawShapeFrame(
112  const dynamics::ShapeFrame* shapeFrame,
113  const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5),
114  bool useDefaultColor = true) const;
115 
116  virtual void drawShape(
117  const dynamics::Shape* shape,
118  const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5)) const;
119 
120  virtual void drawPointMasses(
121  const std::vector<dynamics::PointMass*> pointMasses,
122  const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5),
123  bool useDefaultColor = true) const;
124 
125  virtual void drawMarker(
126  const dynamics::Marker* marker,
127  const Eigen::Vector4d& color = Eigen::Vector4d::Constant(0.5),
128  bool useDefaultColor = true) const;
129 
132 
135 
137  bool mPlay;
138 
141 
144 
147 
149  std::vector<GraphWindow*> mGraphWindows;
150 };
151 
152 } // namespace glut
153 } // namespace gui
154 } // namespace dart
155 
156 #endif // DART_GUI_GLUT_SIMWINDOW_HPP_
#define DART_DEPRECATED(version)
Definition: Deprecated.hpp:51
BodyNode class represents a single node of the skeleton.
Definition: BodyNode.hpp:79
Entity class is a base class for any objects that exist in the kinematic tree structure of DART.
Definition: Entity.hpp:61
Definition: Marker.hpp:50
Definition: ShapeFrame.hpp:192
Definition: Shape.hpp:54
class Skeleton
Definition: Skeleton.hpp:59
Definition: SimWindow.hpp:52
virtual void drawSkeletons() const
Definition: SimWindow.cpp:111
virtual void drawWorld() const
Definition: SimWindow.cpp:102
virtual void drawShape(const dynamics::Shape *shape, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5)) const
Definition: SimWindow.cpp:419
bool mShowMarkers
If true, render markers.
Definition: SimWindow.hpp:146
void keyboard(unsigned char _key, int _x, int _y) override
Definition: SimWindow.cpp:236
void displayTimer(int _val) override
Definition: SimWindow.cpp:130
bool mPlay
Definition: SimWindow.hpp:137
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:340
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:521
virtual void timeStepping()
Definition: SimWindow.cpp:96
virtual void drawMarker(const dynamics::Marker *marker, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5), bool useDefaultColor=true) const
Definition: SimWindow.cpp:558
std::vector< GraphWindow * > mGraphWindows
Array of graph windows.
Definition: SimWindow.hpp:149
void setWorld(dart::simulation::WorldPtr _world)
Definition: SimWindow.cpp:281
virtual void drawSkels()
Definition: SimWindow.cpp:118
void saveWorld()
Save world in 'tempWorld.txt'.
Definition: SimWindow.cpp:286
virtual ~SimWindow()
Definition: SimWindow.cpp:90
simulation::WorldPtr mWorld
Definition: SimWindow.hpp:131
virtual void drawShapeFrame(const dynamics::ShapeFrame *shapeFrame, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5), bool useDefaultColor=true) const
Definition: SimWindow.cpp:391
SimWindow()
Definition: SimWindow.cpp:72
int mPlayFrame
Definition: SimWindow.hpp:134
bool mSimulating
Definition: SimWindow.hpp:140
bool mShowPointMasses
If true, render point masses of soft bodies.
Definition: SimWindow.hpp:143
void draw() override
Definition: SimWindow.cpp:151
virtual void drawEntity(const dynamics::Entity *entity, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5), bool useDefaultColor=true) const
Definition: SimWindow.cpp:316
virtual void drawSkeleton(const dynamics::Skeleton *skeleton, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5), bool useDefaultColor=true) const
Definition: SimWindow.cpp:303
void plot(Eigen::VectorXd &_data)
Plot _data in a 2D window.
Definition: SimWindow.cpp:294
virtual void drawEntities()
Definition: SimWindow.cpp:124
Definition: Win3D.hpp:46
::dart::gui::glut::GraphWindow GraphWindow
Definition: GraphWindow.hpp:52
std::shared_ptr< World > WorldPtr
Definition: SmartPointer.hpp:41
Definition: BulletCollisionDetector.cpp:65