#include <IpsaSimulator.h>
Public Member Functions | |
SoNode * | getSceneGraph () |
bool | getVerbosity () |
IpsaSimulator () | |
bool | isScheduled () |
void | reload () |
void | reset () |
void | save (const std::string &saveFile) |
void | schedule () |
void | setDelegate (IpsaSimulatorDelegate *delegate) |
void | setSceneryFilename (const std::string &newFile) |
void | setVerbosity (bool verbosityOn=true) |
virtual | ~IpsaSimulator () |
Static Public Member Functions | |
static void | ExpandFileNodes (SoNode *root) |
Protected Member Functions | |
void | applyPrefixNodes () |
virtual bool | buildScenery () |
SoSeparator * | createPhysicsWorldIfMissing (SoNode *root) |
SoNode * | readSceneryFromFile (bool expandFileNodesInGraph=true) |
Protected Attributes | |
IpsaSimulatorDelegate * | delegate |
bool | isIpsaScheduled |
std::string | sceneryFilename |
SoSeparator * | simulationRoot |
bool | verboseOutput |
Create an instance of this class to use it. This is done in the QtEmbedding executable for example and usually looks like this:
#include "IpsaSimulator.h" int main (int argc, char ** argv) { // create an instance of the IpsaSimulator IpsaSimulator simulator(); return 0; }
To change how the shown scenery is built it is possible to set the IpsaSimulator::delegate using the IpsaSimulator::setDelegate(IpsaSimulatorDelegat*) method.
#include <IPSA/IpsaSimulator.h> #include <IPSA/IpsaSimulatorDelegate.h> #include <IPSA/ipsaclasses.h> #include <iostream> class MyIpsaSimulator : public IpsaSimulator, public IpsaSimulatorDelegate { public: MyIpsaSimulator() : IpsaSimulator(parent, embed) { this-ipsaSimulator->setDelegate(this); } protected: virtual SoNode* createScenery(); }; SoNode* MyIpsaSimulator::createScenery() { SoNode* root = new SoSeparator; root->ref(); // create your own scenegraph // ... // the remaining code return root; } int main (int argc, char ** argv) { MyIpsaSimulator simulator(); viewer.reload(); return 0; }
Definition at line 35 of file IpsaSimulator.h.
IpsaSimulator::IpsaSimulator | ( | ) |
The constructor of the IpsaSimulator class.
It calls SoWorldPhysics::initClasses().
Definition at line 149 of file IpsaSimulator.cpp.
References SoWorldPhysics::initClasses().
IpsaSimulator::~IpsaSimulator | ( | ) | [virtual] |
The virtual destructor of the IpsaSimulator class.
Definition at line 163 of file IpsaSimulator.cpp.
References SoWorldPhysics::DeInit().
void IpsaSimulator::applyPrefixNodes | ( | ) | [protected] |
Searches all SoPrefixNodes in the scenegraph of the viewer and calls SoPrefixNode::updatePrefixes() on all of them.
Definition at line 314 of file IpsaSimulator.cpp.
References simulationRoot, and SoPrefixNode::updatePrefixes().
Referenced by buildScenery().
bool IpsaSimulator::buildScenery | ( | ) | [protected, virtual] |
The virtual method IpsaSimulator::buildScenery() is used to create a scenegraph.
If IpsaSimulator::delegate has been set through IpsaSimulator::setDelegate(IpsaSimulatorDelegate*) the delegate is used to construct the scenery. Otherwise the scenegraph is constructed by reading in the file stored in IpsaSimulator::sceneryFilename.
false if no scenery could be created.
Definition at line 198 of file IpsaSimulator.cpp.
References SoWorldPhysics::ApplyActionToWorldPhysicNodesInGraph(), applyPrefixNodes(), createPhysicsWorldIfMissing(), IpsaSimulatorDelegate::createScenery(), delegate, SoWorldPhysics::InitialiseWorldCB(), readSceneryFromFile(), and simulationRoot.
Referenced by reload().
SoSeparator * IpsaSimulator::createPhysicsWorldIfMissing | ( | SoNode * | root | ) | [protected] |
Searches through the supplied Inventor tree and creates a default SoWorldPhysics if none was found and adds root
as a child node.
root | the node to search through |
root
if at least one SoWorldPhysics was present, the SoWorldPhysics which has been created otherwise Definition at line 278 of file IpsaSimulator.cpp.
Referenced by buildScenery().
void IpsaSimulator::ExpandFileNodes | ( | SoNode * | root | ) | [static] |
This routine searches for and expands all SoFile nodes in the given scene graph. It does this by making all the children of a SoFile node the children of its parent. (Code for this function taken from ivcat)
root | the Inventor node to perform the expansion on. |
Definition at line 344 of file IpsaSimulator.cpp.
Referenced by readSceneryFromFile().
SoNode * IpsaSimulator::getSceneGraph | ( | ) |
Definition at line 181 of file IpsaSimulator.cpp.
References simulationRoot.
Referenced by Instruction::GetAllNodesOfTypeFromViewer(), IpsaViewerWidget::reload(), IpsaViewer::reloadSimulation(), UnscheduleIPSA::vExecute(), StepIPSA::vExecute(), ShowJoints::vExecute(), SetStepsizeIPSA::vExecute(), ScheduleIPSA::vExecute(), and SaveIVFile::vExecute().
IpsaSimulator::getVerbosity | ( | ) | [inline] |
Definition at line 44 of file IpsaSimulator.h.
Referenced by IpsaViewerWidget::getVerbosity(), IpsaViewer::getVerbosity(), ListAllJoints::vExecute(), and ListAllBodies::vExecute().
IpsaSimulator::isScheduled | ( | ) | [inline] |
Definition at line 50 of file IpsaSimulator.h.
Referenced by IpsaViewer::createViewerButtons(), IpsaViewerWidget::isScheduled(), IpsaViewer::isScheduled(), IpsaViewerWidget::schedule(), and IpsaViewer::schedule().
SoNode * IpsaSimulator::readSceneryFromFile | ( | bool | expandFileNodesInGraph = true |
) | [protected] |
This method tries to read the scenegraph from the file IpsaSimulator::sceneryFilename and sets it as the scenegraph of the current innstance of IpsaSimulator. Before the scenegraph is set it may get expanded depending on the parameter of the method.
expandFileNodesInGraph | perform expansion if true (default) or not otherwise. |
false if the file couldn't be opened or a problem was encountered while reading the file.
Definition at line 235 of file IpsaSimulator.cpp.
References ExpandFileNodes(), and sceneryFilename.
Referenced by buildScenery().
void IpsaSimulator::reload | ( | ) |
Resets the simulation by deleting the scene and calling IpsaSimulator::buildScenery() again.
Definition at line 432 of file IpsaSimulator.cpp.
References buildScenery(), SoWorldPhysics::DeInit(), SoWorldPhysics::Init(), isIpsaScheduled, schedule(), and simulationRoot.
Referenced by IpsaViewerWidget::reload(), and IpsaViewer::reloadSimulation().
void IpsaSimulator::reset | ( | ) |
Resets the simulation by internally resetting physic nodes.
Definition at line 454 of file IpsaSimulator.cpp.
References SoWorldPhysics::ApplyActionToWorldPhysicNodesInGraph(), isIpsaScheduled, SoWorldPhysics::ResetWorldCB(), schedule(), and simulationRoot.
Referenced by IpsaViewerWidget::reset(), IpsaViewer::resetSimulation(), ResetIPSA::vExecute(), and ResetViewer::vExecute().
void IpsaSimulator::save | ( | const std::string & | saveFile | ) |
Save current inventor scenegraph to file at location saveFile
. Do nothing if saveFile
is empty.
Definition at line 468 of file IpsaSimulator.cpp.
References simulationRoot.
Referenced by IpsaViewer::run(), IpsaViewerWidget::save(), and IpsaViewer::saveSceneToFile().
void IpsaSimulator::schedule | ( | ) |
Schedules ALL SoWorldPhysics if IpsaSimulator::isScheduled is set to false and unschedules ALL SoWorldPhyiscs if the IpsaSimulator::isScheduled is set to true. Afterwards IpsaSimulator::isScheduled is inverted to reflect the current state.
Definition at line 488 of file IpsaSimulator.cpp.
References SoWorldPhysics::ApplyActionToWorldPhysicNodesInGraph(), isIpsaScheduled, SoWorldPhysics::ScheduleWorldCB(), simulationRoot, and SoWorldPhysics::UnscheduleWorldCB().
Referenced by reload(), reset(), IpsaViewer::run(), IpsaViewerWidget::schedule(), and IpsaViewer::schedule().
void IpsaSimulator::setDelegate | ( | IpsaSimulatorDelegate * | delegate | ) |
This method sets a delegate object which must inherit from IpsaSimulatorDelegate.
Definition at line 172 of file IpsaSimulator.cpp.
IpsaSimulator::setSceneryFilename | ( | const std::string & | newFile | ) | [inline] |
Set IpsaSimulator::sceneFilename to a new file. After calling IpsaSimulator::buildScenery() the new file is read.
Definition at line 46 of file IpsaSimulator.h.
Referenced by IpsaViewer::IpsaViewer(), IpsaViewerWidget::setSceneryFilename(), and IpsaViewer::setSceneryFilename().
IpsaSimulator::setVerbosity | ( | bool | verbosityOn = true |
) | [inline] |
Sets the IpsaSimulator::verbosity flag.
verbosityOn | true for turning verbosity on, false for turning it of (default = true) |
Definition at line 43 of file IpsaSimulator.h.
Referenced by IpsaViewerWidget::setVerbosity(), IpsaViewer::setVerbosity(), and SetVerbosity::vExecute().
IpsaSimulator::delegate [protected] |
This object is used to delegate the creation of the scenegraph to. It implements the IpsaSimulatorDelegate interface.
Definition at line 72 of file IpsaSimulator.h.
Referenced by buildScenery().
IpsaSimulator::isIpsaScheduled [protected] |
Contains true if the current SoWorldPhysics instances are scheduled, false otherwise.
Definition at line 67 of file IpsaSimulator.h.
Referenced by reload(), reset(), and schedule().
IpsaSimulator::sceneryFilename [protected] |
This is the filename of the inventor scenegraph which can be loaded by the IpsaSimulator::readSceneryFromFile() method.
Definition at line 68 of file IpsaSimulator.h.
Referenced by readSceneryFromFile().
SoSeparator* IpsaSimulator::simulationRoot [protected] |
Definition at line 70 of file IpsaSimulator.h.
Referenced by applyPrefixNodes(), buildScenery(), getSceneGraph(), reload(), reset(), save(), and schedule().
IpsaSimulator::verboseOutput [protected] |
Used by commands to determine if the output should be verbose.
Definition at line 66 of file IpsaSimulator.h.
Generated on Sat Mar 10 20:00:19 2012 for IPSA by 1.5.8 |