DART  6.7.3
SimWindow.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2019, 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 public:
54  SimWindow();
55 
57  virtual ~SimWindow();
58 
60  virtual void timeStepping();
61 
62  virtual void drawWorld() const;
63 
64  virtual void drawSkeletons() const;
65 
66  DART_DEPRECATED(6.0)
67  virtual void drawSkels();
68 
69  DART_DEPRECATED(6.0)
70  virtual void drawEntities();
71 
73  void displayTimer(int _val) override;
74 
76  void draw() override;
77 
79  void keyboard(unsigned char _key, int _x, int _y) override;
80 
83 
85  void saveWorld();
86 
88  void plot(Eigen::VectorXd& _data);
89 // bool isSimulating() const { return mSimulating; }
90 
91 // void setSimulatingFlag(int _flag) { mSimulating = _flag; }
92 
93 protected:
94 
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: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:53
class Skeleton
Definition: Skeleton.hpp:59
Definition: SimWindow.hpp:51
virtual void drawSkeletons() const
Definition: SimWindow.cpp:108
virtual void drawWorld() const
Definition: SimWindow.cpp:99
virtual void drawShape(const dynamics::Shape *shape, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5)) const
Definition: SimWindow.cpp:387
bool mShowMarkers
If true, render markers.
Definition: SimWindow.hpp:146
void keyboard(unsigned char _key, int _x, int _y) override
Definition: SimWindow.cpp:215
void displayTimer(int _val) override
Definition: SimWindow.cpp:127
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:310
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:482
virtual void timeStepping()
Definition: SimWindow.cpp:94
virtual void drawMarker(const dynamics::Marker *marker, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5), bool useDefaultColor=true) const
Definition: SimWindow.cpp:519
std::vector< GraphWindow * > mGraphWindows
Array of graph windows.
Definition: SimWindow.hpp:149
void setWorld(dart::simulation::WorldPtr _world)
Definition: SimWindow.cpp:256
virtual void drawSkels()
Definition: SimWindow.cpp:115
void saveWorld()
Save world in 'tempWorld.txt'.
Definition: SimWindow.cpp:260
virtual ~SimWindow()
Definition: SimWindow.cpp:89
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:360
SimWindow()
Definition: SimWindow.cpp:71
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:143
virtual void drawEntity(const dynamics::Entity *entity, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5), bool useDefaultColor=true) const
Definition: SimWindow.cpp:287
virtual void drawSkeleton(const dynamics::Skeleton *skeleton, const Eigen::Vector4d &color=Eigen::Vector4d::Constant(0.5), bool useDefaultColor=true) const
Definition: SimWindow.cpp:275
void plot(Eigen::VectorXd &_data)
Plot _data in a 2D window.
Definition: SimWindow.cpp:267
virtual void drawEntities()
Definition: SimWindow.cpp:121
Definition: Win3D.hpp:45
::dart::gui::glut::GraphWindow GraphWindow
Definition: GraphWindow.hpp:51
std::shared_ptr< World > WorldPtr
Definition: SmartPointer.hpp:41
Definition: BulletCollisionDetector.cpp:63