DART
6.7.3
|
#include <Viewer.hpp>
Public Member Functions | |
Viewer (const ::osg::Vec4 &clearColor=::osg::Vec4(0.9, 0.9, 0.9, 1.0)) | |
Constructor for dart::gui::osg::Viewer. More... | |
virtual | ~Viewer () |
Destructor. More... | |
void | captureScreen (const std::string &filename) |
Capture the current screen in a png file. More... | |
void | record (const std::string &directory, const std::string &prefix="image", bool restart=false, std::size_t digits=6) |
As the screen refreshes, save screen capture images to the specified directory. More... | |
void | pauseRecording () |
If the Viewer is recording, then pause the recording. More... | |
bool | isRecording () const |
Returns true if the Viewer is currently recording. More... | |
virtual void | switchDefaultEventHandler (bool _on) |
Creates the default event handler for this dart::gui::osg::Viewer. More... | |
DefaultEventHandler * | getDefaultEventHandler () const |
Return a pointer to the default event handler. More... | |
virtual void | switchHeadlights (bool _on) |
Pass in true to turn headlights on, false to turn headlights off. More... | |
bool | checkHeadlights () const |
True iff headlights are currently set to true. More... | |
void | addWorldNode (WorldNode *_newWorldNode, bool _active=true) |
Add a WorldNode to this Viewer. More... | |
void | removeWorldNode (WorldNode *_oldWorldNode) |
Remove a WorldNode from this Viewer. More... | |
void | removeWorldNode (std::shared_ptr< dart::simulation::World > _oldWorld) |
Remove the WorldNode associated with _oldWorld from this Viewer. More... | |
WorldNode * | getWorldNode (std::shared_ptr< dart::simulation::World > _world) const |
Get the WorldNode associated with the given _world. More... | |
void | addAttachment (ViewerAttachment *_attachment) |
Add an attachment to this Viewer. More... | |
void | removeAttachment (ViewerAttachment *_attachment) |
Remove the attachment from this Viewer. More... | |
const std::unordered_set< ViewerAttachment * > & | getAttachments () const |
Get the set of attachments in this Viewer. More... | |
::osg::Group * | getLightGroup () |
Get the Group node that contains the LightSources for this Viewer. More... | |
const ::osg::Group * | getLightGroup () const |
Get the Group node that contains the LightSources for this Viewer. More... | |
const ::osg::ref_ptr<::osg::LightSource > & | getLightSource (std::size_t index=0) const |
Get one of the LightSources of this Viewer index either 0 or 1 Useful for shadowing techniques. More... | |
void | setupDefaultLights () |
Set up the default lighting scheme. More... | |
void | setUpwardsDirection (const ::osg::Vec3 &_up) |
Set the direction that this Viewer should consider to be upwards (default is <0,0,1>) More... | |
void | setUpwardsDirection (const Eigen::Vector3d &_up) |
Set the direction that this Viewer should consider to be upwards (default is <0,0,1>) More... | |
void | setWorldNodeActive (WorldNode *_node, bool _active=true) |
Set the given WorldNode to active. More... | |
void | setWorldNodeActive (std::shared_ptr< dart::simulation::World > _world, bool _active=true) |
Set the given World to active. More... | |
void | simulate (bool _on) |
Set all currently active WorldNodes to simulate _on. More... | |
bool | isSimulating () const |
Return true iff this Viewer is currently set to simulate. More... | |
void | allowSimulation (bool _allow) |
Prevent simulation from starting, even if simulate(true) is called. More... | |
bool | isAllowingSimulation () const |
Return true iff this Viewer is currently allowing simulation to happen. More... | |
DragAndDrop * | enableDragAndDrop (dart::dynamics::Entity *_entity) |
Returns a nullptr if _entity is not a type that can support the built-in drag and drop features, otherwise it returns a pointer to the DragAndDrop interface object that has been created (allowing you to configure it). More... | |
SimpleFrameDnD * | enableDragAndDrop (dart::dynamics::SimpleFrame *_frame) |
A version of enableDragAndDrop specifically for SimpleFrame objects. More... | |
SimpleFrameShapeDnD * | enableDragAndDrop (dart::dynamics::SimpleFrame *_frame, dart::dynamics::Shape *_shape) |
A version of enableDragAndDrop specifically for a single shape within a SimpleFrame object. More... | |
InteractiveFrameDnD * | enableDragAndDrop (InteractiveFrame *_frame) |
A version of enableDragAndDrop specifically for InteractiveFrames. More... | |
BodyNodeDnD * | enableDragAndDrop (dart::dynamics::BodyNode *_bn, bool _useExternalIK=true, bool _useWholeBody=false) |
A version of enableDragAndDrop specifically for BodyNodes. More... | |
bool | disableDragAndDrop (DragAndDrop *_dnd) |
Delete a DragAndDrop object. More... | |
bool | disableDragAndDrop (SimpleFrameDnD *_dnd) |
Delete a SimpleFrameDnD object. More... | |
bool | disableDragAndDrop (SimpleFrameShapeDnD *_dnd) |
Delete a SimpleFrameShapeDnD object. More... | |
bool | disableDragAndDrop (InteractiveFrameDnD *_dnd) |
Delete an InteractiveFrameDnD object. More... | |
bool | disableDragAndDrop (BodyNodeDnD *_dnd) |
Delete a BodyNodeDnD object. More... | |
const std::string & | getInstructions () const |
Get a string containing the user interface constructions for this Viewer. More... | |
void | addInstructionText (const std::string &_instruction) |
Add something to the instructions for this Viewer. More... | |
virtual void | updateViewer () |
Called automatically at the beginning of each render cycle. More... | |
void | updateDragAndDrops () |
Called automatically by updateViewer() More... | |
const ::osg::ref_ptr<::osg::Group > & | getRootGroup () const |
Get the root ::osg::Group of this Viewer. More... | |
void | setVerticalFieldOfView (double fov) |
Sets the vertical field of view of the master camera of the view. More... | |
double | getVerticalFieldOfView () const |
Returns the vertical field of view of the master camera of the view. More... | |
Protected Member Functions | |
void | sendDestructionNotification () const |
Send a destruction notification to all Observers. More... | |
void | addObserver (Observer *_observer) const |
Add an Observer to the list of Observers. More... | |
void | removeObserver (Observer *_observer) const |
Remove an Observer from the list of Observers. More... | |
Protected Attributes | |
std::size_t | mImageSequenceNum |
Current number of the image sequence for screen recording. More... | |
std::size_t | mImageDigits |
Number of digits to use when saving an image sequence. More... | |
bool | mRecording |
Whether or not the Viewer is currently recording. More... | |
bool | mScreenCapture |
Whether or not the Viewer is staged for a screen capture. More... | |
std::string | mImageDirectory |
Directory for saving images. More... | |
std::string | mImagePrefix |
Prefix to apply to images. More... | |
std::string | mScreenCapName |
Name for the next screen capture. More... | |
::osg::ref_ptr< DefaultEventHandler > | mDefaultEventHandler |
Default WorldNodeEventHandler for this dart::gui::osg::Viewer. More... | |
::osg::ref_ptr<::osg::Group > | mRootGroup |
The root node of this Viewer. More... | |
::osg::ref_ptr<::osg::Group > | mLightGroup |
The Group Node containing light sources. More... | |
::osg::ref_ptr<::osg::Light > | mLight1 |
Non-headlights Light #1. More... | |
::osg::ref_ptr<::osg::LightSource > | mLightSource1 |
Non-headlights LightSource #1. More... | |
::osg::ref_ptr<::osg::Light > | mLight2 |
Non-headlights Light #2. More... | |
::osg::ref_ptr<::osg::LightSource > | mLightSource2 |
Non-headlights LightSource #2. More... | |
::osg::Vec3 | mUpwards |
Vector pointing upwards. More... | |
::osg::Vec3 | mOver |
Vector pointing to the side. More... | |
bool | mSimulating |
True iff this Viewer is currently simulating. More... | |
bool | mAllowSimulation |
True iff this Viewer is allowing simulation. More... | |
bool | mHeadlights |
True iff headlights were last set to be on. More... | |
std::map< WorldNode *, bool > | mWorldNodes |
Map of WorldNodes in this dart::gui::osg::Viewer. More... | |
std::unordered_set< ViewerAttachment * > | mAttachments |
std::string | mInstructions |
string of instructions for this Viewer More... | |
std::map< dart::dynamics::SimpleFrame *, SimpleFrameDnD * > | mSimpleFrameDnDMap |
Map from SimpleFrame ptrs to SimpleFrameDnD ptrs. More... | |
std::multimap< dart::dynamics::Shape *, SimpleFrameShapeDnD * > | mSimpleFrameShapeDnDMap |
Multimap from Shape ptrs to SimpleFrameShapeDnD ptrs. More... | |
std::map< InteractiveFrame *, InteractiveFrameDnD * > | mInteractiveFrameDnDMap |
Map from InteractiveFrame ptrs to InteractiveFrameDnD ptrs. More... | |
std::map< dart::dynamics::BodyNode *, BodyNodeDnD * > | mBodyNodeDnDMap |
Map from BodyNode ptrs to BodyNodeDnD ptrs. More... | |
std::set< Observer * > | mObservers |
List of current Observers. More... | |
Friends | |
class | SaveScreen |
dart::gui::osg::Viewer::Viewer | ( | const ::osg::Vec4 & | clearColor = ::osg::Vec4(0.9,0.9,0.9,1.0) | ) |
Constructor for dart::gui::osg::Viewer.
This will automatically create the default event handler.
|
virtual |
Destructor.
void dart::gui::osg::Viewer::addAttachment | ( | ViewerAttachment * | _attachment | ) |
void dart::gui::osg::Viewer::addInstructionText | ( | const std::string & | _instruction | ) |
Add something to the instructions for this Viewer.
You are strongly recommended to end your string with an end-of-line character. An end-of-line character will NOT be added automatically.
|
protectedinherited |
Add an Observer to the list of Observers.
void dart::gui::osg::Viewer::addWorldNode | ( | WorldNode * | _newWorldNode, |
bool | _active = true |
||
) |
void dart::gui::osg::Viewer::allowSimulation | ( | bool | _allow | ) |
Prevent simulation from starting, even if simulate(true) is called.
void dart::gui::osg::Viewer::captureScreen | ( | const std::string & | filename | ) |
Capture the current screen in a png file.
The filename argument should include the full path for the file.
It is recommended that you end the filename with ".png". That is the type of file that will be produced, but the extension will not be added on automatically.
bool dart::gui::osg::Viewer::checkHeadlights | ( | ) | const |
True iff headlights are currently set to true.
bool dart::gui::osg::Viewer::disableDragAndDrop | ( | BodyNodeDnD * | _dnd | ) |
Delete a BodyNodeDnD object.
Returns true if a DnD existed and could be deleted
bool dart::gui::osg::Viewer::disableDragAndDrop | ( | DragAndDrop * | _dnd | ) |
Delete a DragAndDrop object.
Returns true if the DnD was active and has now been deleted
bool dart::gui::osg::Viewer::disableDragAndDrop | ( | InteractiveFrameDnD * | _dnd | ) |
Delete an InteractiveFrameDnD object.
Returns true if a DnD existed and could be deleted
bool dart::gui::osg::Viewer::disableDragAndDrop | ( | SimpleFrameDnD * | _dnd | ) |
Delete a SimpleFrameDnD object.
Returns true if the DnD was active and has now been deleted
bool dart::gui::osg::Viewer::disableDragAndDrop | ( | SimpleFrameShapeDnD * | _dnd | ) |
Delete a SimpleFrameShapeDnD object.
Returns true if a DnD existed and could be deleted
BodyNodeDnD * dart::gui::osg::Viewer::enableDragAndDrop | ( | dart::dynamics::BodyNode * | _bn, |
bool | _useExternalIK = true , |
||
bool | _useWholeBody = false |
||
) |
A version of enableDragAndDrop specifically for BodyNodes.
DragAndDrop * dart::gui::osg::Viewer::enableDragAndDrop | ( | dart::dynamics::Entity * | _entity | ) |
Returns a nullptr if _entity is not a type that can support the built-in drag and drop features, otherwise it returns a pointer to the DragAndDrop interface object that has been created (allowing you to configure it).
If a DragAndDrop interface already existed for this object, the existing one will be returned.
SimpleFrameDnD * dart::gui::osg::Viewer::enableDragAndDrop | ( | dart::dynamics::SimpleFrame * | _frame | ) |
A version of enableDragAndDrop specifically for SimpleFrame objects.
SimpleFrameShapeDnD * dart::gui::osg::Viewer::enableDragAndDrop | ( | dart::dynamics::SimpleFrame * | _frame, |
dart::dynamics::Shape * | _shape | ||
) |
A version of enableDragAndDrop specifically for a single shape within a SimpleFrame object.
Dragging and Dropping the shape will also drag and drop the entire Frame
InteractiveFrameDnD * dart::gui::osg::Viewer::enableDragAndDrop | ( | InteractiveFrame * | _frame | ) |
A version of enableDragAndDrop specifically for InteractiveFrames.
const std::unordered_set< ViewerAttachment * > & dart::gui::osg::Viewer::getAttachments | ( | ) | const |
Get the set of attachments in this Viewer.
DefaultEventHandler * dart::gui::osg::Viewer::getDefaultEventHandler | ( | ) | const |
Return a pointer to the default event handler.
const std::string & dart::gui::osg::Viewer::getInstructions | ( | ) | const |
Get a string containing the user interface constructions for this Viewer.
osg::Group * dart::gui::osg::Viewer::getLightGroup | ( | ) |
Get the Group node that contains the LightSources for this Viewer.
const ::osg::Group * dart::gui::osg::Viewer::getLightGroup | ( | ) | const |
Get the Group node that contains the LightSources for this Viewer.
const ::osg::ref_ptr<::osg::LightSource > & dart::gui::osg::Viewer::getLightSource | ( | std::size_t | index = 0 | ) | const |
Get one of the LightSources of this Viewer index either 0 or 1 Useful for shadowing techniques.
const ::osg::ref_ptr<::osg::Group > & dart::gui::osg::Viewer::getRootGroup | ( | ) | const |
Get the root ::osg::Group of this Viewer.
double dart::gui::osg::Viewer::getVerticalFieldOfView | ( | ) | const |
Returns the vertical field of view of the master camera of the view.
WorldNode * dart::gui::osg::Viewer::getWorldNode | ( | std::shared_ptr< dart::simulation::World > | _world | ) | const |
bool dart::gui::osg::Viewer::isAllowingSimulation | ( | ) | const |
Return true iff this Viewer is currently allowing simulation to happen.
bool dart::gui::osg::Viewer::isRecording | ( | ) | const |
Returns true if the Viewer is currently recording.
bool dart::gui::osg::Viewer::isSimulating | ( | ) | const |
Return true iff this Viewer is currently set to simulate.
void dart::gui::osg::Viewer::pauseRecording | ( | ) |
void dart::gui::osg::Viewer::record | ( | const std::string & | directory, |
const std::string & | prefix = "image" , |
||
bool | restart = false , |
||
std::size_t | digits = 6 |
||
) |
As the screen refreshes, save screen capture images to the specified directory.
The prefix argument will be the first part of the name of each image. The second part of the image will contain an integer with "digits" number of digits; any unused leading digits will be filled with 0. The integer corresponds to its number in the sequence of frames.
Set the restart argument to true if you want the sequence counter to restart from 0.
void dart::gui::osg::Viewer::removeAttachment | ( | ViewerAttachment * | _attachment | ) |
Remove the attachment from this Viewer.
|
protectedinherited |
Remove an Observer from the list of Observers.
void dart::gui::osg::Viewer::removeWorldNode | ( | std::shared_ptr< dart::simulation::World > | _oldWorld | ) |
void dart::gui::osg::Viewer::removeWorldNode | ( | WorldNode * | _oldWorldNode | ) |
|
protectedinherited |
Send a destruction notification to all Observers.
This will cause all Observers to behave as if this Subject has been permanently deleted, so it should only be called when that behavior is desired.
void dart::gui::osg::Viewer::setupDefaultLights | ( | ) |
Set up the default lighting scheme.
void dart::gui::osg::Viewer::setUpwardsDirection | ( | const ::osg::Vec3 & | _up | ) |
Set the direction that this Viewer should consider to be upwards (default is <0,0,1>)
void dart::gui::osg::Viewer::setUpwardsDirection | ( | const Eigen::Vector3d & | _up | ) |
Set the direction that this Viewer should consider to be upwards (default is <0,0,1>)
void dart::gui::osg::Viewer::setVerticalFieldOfView | ( | double | fov | ) |
Sets the vertical field of view of the master camera of the view.
[in] | fov | Vertical field of view in degrees. |
void dart::gui::osg::Viewer::setWorldNodeActive | ( | std::shared_ptr< dart::simulation::World > | _world, |
bool | _active = true |
||
) |
Set the given World to active.
void dart::gui::osg::Viewer::setWorldNodeActive | ( | WorldNode * | _node, |
bool | _active = true |
||
) |
Set the given WorldNode to active.
void dart::gui::osg::Viewer::simulate | ( | bool | _on | ) |
Set all currently active WorldNodes to simulate _on.
|
virtual |
Creates the default event handler for this dart::gui::osg::Viewer.
|
virtual |
Pass in true to turn headlights on, false to turn headlights off.
void dart::gui::osg::Viewer::updateDragAndDrops | ( | ) |
Called automatically by updateViewer()
|
virtual |
Called automatically at the beginning of each render cycle.
|
friend |
|
protected |
True iff this Viewer is allowing simulation.
|
protected |
|
protected |
Map from BodyNode ptrs to BodyNodeDnD ptrs.
|
protected |
Default WorldNodeEventHandler for this dart::gui::osg::Viewer.
|
protected |
True iff headlights were last set to be on.
|
protected |
Number of digits to use when saving an image sequence.
|
protected |
Directory for saving images.
|
protected |
Prefix to apply to images.
|
protected |
Current number of the image sequence for screen recording.
|
protected |
string of instructions for this Viewer
|
protected |
Map from InteractiveFrame ptrs to InteractiveFrameDnD ptrs.
|
protected |
Non-headlights Light #1.
|
protected |
Non-headlights Light #2.
|
protected |
The Group Node containing light sources.
|
protected |
Non-headlights LightSource #1.
|
protected |
Non-headlights LightSource #2.
|
mutableprotectedinherited |
List of current Observers.
|
protected |
Vector pointing to the side.
|
protected |
Whether or not the Viewer is currently recording.
|
protected |
The root node of this Viewer.
|
protected |
Name for the next screen capture.
|
protected |
Whether or not the Viewer is staged for a screen capture.
|
protected |
Map from SimpleFrame ptrs to SimpleFrameDnD ptrs.
|
protected |
Multimap from Shape ptrs to SimpleFrameShapeDnD ptrs.
We use a multimap in order to support the possibility of a single Shape being used by multiple objects
|
protected |
True iff this Viewer is currently simulating.
|
protected |
Vector pointing upwards.
|
protected |
Map of WorldNodes in this dart::gui::osg::Viewer.
A WorldNode will map to true iff it is currently active