33 #ifndef DART_GUI_OSG_VIEWER_HPP_ 34 #define DART_GUI_OSG_VIEWER_HPP_ 38 #include <unordered_set> 40 #include <osgShadow/ShadowTechnique> 41 #include <osgViewer/Viewer> 45 #include "dart/common/ClassWithVirtualBase.hpp" 46 #include "dart/common/Subject.hpp" 65 class DefaultEventHandler;
68 class SimpleFrameShapeDnD;
69 class InteractiveFrame;
70 class InteractiveFrameDnD;
75 DART_DECLARE_CLASS_WITH_VIRTUAL_BASE_BEGIN
89 virtual void refresh() = 0;
93 const Viewer* getViewer()
const;
99 virtual void customAttach(
Viewer* newViewer);
105 virtual void attach(
Viewer* newViewer);
116 Viewer(const ::osg::Vec4& clearColor = ::osg::Vec4(0.9, 0.9, 0.9, 1.0));
129 void captureScreen(
const std::string& filename);
142 const std::string& directory,
143 const std::string& prefix =
"image",
144 bool restart =
false,
145 std::size_t digits = 6);
150 void pauseRecording();
153 bool isRecording()
const;
156 virtual void switchDefaultEventHandler(
bool _on);
162 virtual void switchHeadlights(
bool _on);
165 bool checkHeadlights()
const;
170 void addWorldNode(
WorldNode* _newWorldNode,
bool _active =
true);
173 void removeWorldNode(
WorldNode* _oldWorldNode);
176 void removeWorldNode(std::shared_ptr<dart::simulation::World> _oldWorld);
181 std::shared_ptr<dart::simulation::World> _world)
const;
191 const std::unordered_set<ViewerAttachment*>& getAttachments()
const;
194 ::osg::Group* getLightGroup();
197 const ::osg::Group* getLightGroup()
const;
202 const ::osg::ref_ptr<::osg::LightSource>& getLightSource(
203 std::size_t index = 0)
const;
206 void setupDefaultLights();
210 void setUpwardsDirection(const ::osg::Vec3& _up);
214 void setUpwardsDirection(
const Eigen::Vector3d& _up);
217 void setWorldNodeActive(
WorldNode* _node,
bool _active =
true);
220 void setWorldNodeActive(
221 std::shared_ptr<dart::simulation::World> _world,
bool _active =
true);
224 void simulate(
bool _on);
227 bool isSimulating()
const;
230 void allowSimulation(
bool _allow);
233 bool isAllowingSimulation()
const;
257 bool _useExternalIK =
true,
258 bool _useWholeBody =
false);
281 const std::string& getInstructions()
const;
286 void addInstructionText(
const std::string& _instruction);
289 virtual void updateViewer();
292 void updateDragAndDrops();
295 const ::osg::ref_ptr<::osg::Group>& getRootGroup()
const;
299 void setVerticalFieldOfView(
double fov);
304 double getVerticalFieldOfView()
const;
370 std::unordered_set<ViewerAttachment*> mAttachments;
384 std::multimap<dart::dynamics::Shape*, SimpleFrameShapeDnD*>
393 DART_DECLARE_CLASS_WITH_VIRTUAL_BASE_END
399 #endif // DART_GUI_OSG_VIEWER_HPP_ bool mRecording
Whether or not the Viewer is currently recording.
Definition: Viewer.hpp:316
std::multimap< dart::dynamics::Shape *, SimpleFrameShapeDnD * > mSimpleFrameShapeDnDMap
Multimap from Shape ptrs to SimpleFrameShapeDnD ptrs.
Definition: Viewer.hpp:385
std::string mScreenCapName
Name for the next screen capture.
Definition: Viewer.hpp:328
std::string mInstructions
string of instructions for this Viewer
Definition: Viewer.hpp:373
bool mScreenCapture
Whether or not the Viewer is staged for a screen capture.
Definition: Viewer.hpp:319
The Subject class is a base class for any object that wants to report when it gets destroyed...
Definition: Subject.hpp:57
::osg::ref_ptr<::osg::Group > mLightGroup
The Group Node containing light sources.
Definition: Viewer.hpp:337
DragAndDrop is a class that facilitates enabling various kinds of dart Entities to be dragged and dro...
Definition: DragAndDrop.hpp:59
std::string mImageDirectory
Directory for saving images.
Definition: Viewer.hpp:322
Definition: Viewer.hpp:76
::osg::Vec3 mUpwards
Vector pointing upwards.
Definition: Viewer.hpp:352
bool mHeadlights
True iff headlights were last set to be on.
Definition: Viewer.hpp:364
std::map<::osg::ref_ptr< WorldNode >, bool > mWorldNodes
Map of WorldNodes in this dart::gui::osg::Viewer.
Definition: Viewer.hpp:368
std::string mImagePrefix
Prefix to apply to images.
Definition: Viewer.hpp:325
bool mAllowSimulation
True iff this Viewer is allowing simulation.
Definition: Viewer.hpp:361
::osg::ref_ptr<::osg::LightSource > mLightSource2
Non-headlights LightSource #2.
Definition: Viewer.hpp:349
std::size_t mImageDigits
Number of digits to use when saving an image sequence.
Definition: Viewer.hpp:313
Definition: InteractiveFrame.hpp:109
std::map< InteractiveFrame *, InteractiveFrameDnD * > mInteractiveFrameDnDMap
Map from InteractiveFrame ptrs to InteractiveFrameDnD ptrs.
Definition: Viewer.hpp:388
::osg::ref_ptr< DefaultEventHandler > mDefaultEventHandler
Default WorldNodeEventHandler for this dart::gui::osg::Viewer.
Definition: Viewer.hpp:331
Entity class is a base class for any objects that exist in the kinematic tree structure of DART...
Definition: Entity.hpp:60
Definition: test_Signal.cpp:68
::osg::ref_ptr<::osg::LightSource > mLightSource1
Non-headlights LightSource #1.
Definition: Viewer.hpp:343
::osg::ref_ptr<::osg::Light > mLight1
Non-headlights Light #1.
Definition: Viewer.hpp:340
WorldNode class encapsulates a World to be displayed in OpenSceneGraph.
Definition: WorldNode.hpp:64
std::size_t mImageSequenceNum
Current number of the image sequence for screen recording.
Definition: Viewer.hpp:310
Definition: Aspect.cpp:40
::osg::ref_ptr<::osg::Light > mLight2
Non-headlights Light #2.
Definition: Viewer.hpp:346
bool mSimulating
True iff this Viewer is currently simulating.
Definition: Viewer.hpp:358
Definition: DragAndDrop.hpp:234
std::map< dart::dynamics::BodyNode *, BodyNodeDnD * > mBodyNodeDnDMap
Map from BodyNode ptrs to BodyNodeDnD ptrs.
Definition: Viewer.hpp:391
Definition: DragAndDrop.hpp:264
::osg::ref_ptr<::osg::Group > mRootGroup
The root node of this Viewer.
Definition: Viewer.hpp:334
BodyNode class represents a single node of the skeleton.
Definition: BodyNode.hpp:74
std::map< dart::dynamics::SimpleFrame *, SimpleFrameDnD * > mSimpleFrameDnDMap
Map from SimpleFrame ptrs to SimpleFrameDnD ptrs.
Definition: Viewer.hpp:379
SimpleFrameShapeDnD is a version of SimpleFrameDnD that allows a specific Shape within the SimpleFram...
Definition: DragAndDrop.hpp:206
::osg::Vec3 mOver
Vector pointing to the side.
Definition: Viewer.hpp:355
Definition: Viewer.hpp:111
Definition: DefaultEventHandler.hpp:103
Definition: Viewer.cpp:55
SimpleFrameDnD is a DragAndDrop implementation for SimpleFrame objects.
Definition: DragAndDrop.hpp:176
The SimpleFrame class offers a user-friendly way of creating arbitrary Frames within the kinematic tr...
Definition: SimpleFrame.hpp:51