IpsaViewer Class Reference
[libipsaViewer classes]

Basic viewer application for loading and simulating IPSA scenes. More...

#include <IpsaViewer.h>

Inheritance diagram for IpsaViewer:

Inheritance graph
[legend]
Collaboration diagram for IpsaViewer:

Collaboration graph
[legend]

List of all members.

Public Slots

void reloadSimulation ()
void resetSimulation ()
void saveSceneToFile ()
void schedule ()
void showDialog ()

Public Member Functions

bool getVerbosity ()
 IpsaViewer (std::string filename="", SO_WINDOW parent=NULL, const char *name="IPSA Viewer", SbBool embed=TRUE)
bool isScheduled ()
bool run (bool doSchedule=false, std::string scenerySaveFile="")
void setSceneryFilename (const std::string &newFile)
void setVerbosity (bool verbosityOn=true)
virtual ~IpsaViewer ()

Protected Member Functions

virtual void createViewerButtons (SO_WINDOW parent, SbPList *buttonlist)

Protected Attributes

IpsaDialogdialog
IpsaSimulatoripsaSimulator
std::string saveFile
QPushButton * scheduleButton
SO_WINDOW window


Detailed Description

Basic viewer application for loading and simulating IPSA scenes.

Create an instance of this class to use it for simulating IPSA scenes. The code usually looks like the following example (Note that you have to call SO_PLATFORM::init() before instantiating an IpsaViewer):

 #include "IpsaViewer.h"
 #include <Inventor/Qt/SoQt.h>

 int main (int argc, char ** argv)
 {
     SO_WINDOW parentWidget = SO_PLATFORM::init(argc, argv, argv[0]);
     IpsaViewer viewer("FileToOpen.iv", parentWidget, argv[0]); // create an instance of the IpsaViewer
     viewer.run(); // start the visualisation/simulation
     return 0;
 }

The simulation behaviour can be changed by creating a subclass of IpsaSimulator and using this instead of the default IpsaSimulator instance.

Definition at line 60 of file IpsaViewer.h.


Constructor & Destructor Documentation

IpsaViewer::IpsaViewer ( std::string  filename = "",
SO_WINDOW  parent = NULL,
const char *  name = "IPSA Viewer",
SbBool  embed = TRUE 
)

The constructor of the IpsaViewer class.
It creates an IpsaSimulator instance and stores it in IpsaViewer::ipsaSimulator. Afterwards the

Parameters:
filename is set on IpsaViewer::ipsaSimulator and the IpsaViewer::window variable is set to parent.
filename name of the file getting opened by IpsaViewer::readSceneryFromFile() (default = "")
parent the parent widget of the viewer (default = NULL)
name name of the viewer (default = "IPSA Viewer")
embed tells if viewer should be embedded (default TRUE)

Definition at line 135 of file IpsaViewer.cpp.

References dialog, ipsaSimulator, IpsaSimulator::setSceneryFilename(), SO_WINDOW, and window.

IpsaViewer::~IpsaViewer (  )  [virtual]

The virtual destructor of the IpsaViewer class. It deletes IpsaViewer::ipsaSimulator.

Definition at line 158 of file IpsaViewer.cpp.

References ipsaSimulator.


Member Function Documentation

void IpsaViewer::createViewerButtons ( SO_WINDOW  parent,
SbPList *  buttonlist 
) [protected, virtual]

Add custom Qt buttons for scheduling the simulation, for showing the IpsaViewer::dialog and for resetting the simulation.

Parameters:
parent parent Qt widget
buttonlist a coin list containing all buttons already created

Definition at line 206 of file IpsaViewer.cpp.

References ipsaSimulator, IpsaSimulator::isScheduled(), resetSimulation(), saveSceneToFile(), schedule(), scheduleButton, showDialog(), and window.

bool IpsaViewer::getVerbosity (  ) 

Returns:
true if verbosity of IpsaViewer::ipsasimulator is on, false otherwise

Definition at line 319 of file IpsaViewer.cpp.

References IpsaSimulator::getVerbosity(), and ipsaSimulator.

bool IpsaViewer::isScheduled (  ) 

Returns:
true if the worlds in the scenegraph are scheduled and false otherwise

Definition at line 299 of file IpsaViewer.cpp.

References ipsaSimulator, and IpsaSimulator::isScheduled().

void IpsaViewer::reloadSimulation (  )  [slot]

This method creates a new scenegraph by calling IpsaSimulator::reload() on IpsaViewer::ipsaSimulator and afterwards sets it on IpsaViewer::examinerViewer.

Definition at line 251 of file IpsaViewer.cpp.

References IpsaSimulator::getSceneGraph(), ipsaSimulator, and IpsaSimulator::reload().

Referenced by run().

void IpsaViewer::resetSimulation (  )  [slot]

Resets the simulation by calling IpsaSimulator::reset() in IpsaViewer::ipsaSimulator.

Definition at line 261 of file IpsaViewer.cpp.

References ipsaSimulator, and IpsaSimulator::reset().

Referenced by createViewerButtons().

bool IpsaViewer::run ( bool  doSchedule = false,
std::string  scenerySaveFile = "" 
)

This method calls IpsaSimulator::reload() to initialise the simulator and create a scenegraph.
Afterwards the scenegraph is saved to the file scenerySaveFile if the parameter is not empty. When everything was set up correctly the ExaminerViewer gets started.

Parameters:
doSchedule schedules the worlds at startup if true, or not if false
scenerySaveFile save the loaded scenegraph to this file if parameter is not an empty string
Returns:
true if the scenegraph was built correctly and the visualisation finished

false if an error occured before the visualisation could be run

Definition at line 176 of file IpsaViewer.cpp.

References ipsaSimulator, reloadSimulation(), IpsaSimulator::save(), saveFile, IpsaSimulator::schedule(), and window.

void IpsaViewer::saveSceneToFile (  )  [slot]

Save current inventor scenegraph to file at location IpsaViewer::saveFile. Do nothing if IpsaViewer::saveFile is empty.

Definition at line 271 of file IpsaViewer.cpp.

References ipsaSimulator, IpsaSimulator::save(), and saveFile.

Referenced by createViewerButtons().

void IpsaViewer::schedule (  )  [slot]

void IpsaViewer::setSceneryFilename ( const std::string &  newFile  ) 

This method sets newFile as the new filename on IpsaViewer::ipsaSimulator. After calling IpsaViewer::reload() the new file is read.

Definition at line 329 of file IpsaViewer.cpp.

References ipsaSimulator, and IpsaSimulator::setSceneryFilename().

void IpsaViewer::setVerbosity ( bool  verbosityOn = true  ) 

Sets the verbosity flag on IpsaViewer::ipsaSimulator.

Parameters:
verbosityOn true for turning verbosity on, false for turning it of (default = true)

Definition at line 310 of file IpsaViewer.cpp.

References ipsaSimulator, and IpsaSimulator::setVerbosity().

void IpsaViewer::showDialog (  )  [slot]

Shows the IpsaViewer::dialog if it isn't on screen or raises it otherwise.

Definition at line 235 of file IpsaViewer.cpp.

References dialog, and IpsaDialog::reloadData().

Referenced by createViewerButtons().


Member Data Documentation

IpsaViewer::dialog [protected]

An instance of IpsaDialog.

Definition at line 96 of file IpsaViewer.h.

Referenced by IpsaViewer(), and showDialog().

IpsaViewer::saveFile [protected]

The string stored in this instance variable is used as the filename to save the Inventor file to.

Definition at line 101 of file IpsaViewer.h.

Referenced by run(), and saveSceneToFile().

Pointer to the button which is used to (un-)schedule the worlds. This is needed for changing the text on the button.

Definition at line 95 of file IpsaViewer.h.

Referenced by createViewerButtons(), and schedule().

IpsaViewer::window [protected]

Depending on the platfrom this is either a HWND on Windows or a QWidget* on Linux/Mac OS X.

Definition at line 100 of file IpsaViewer.h.

Referenced by createViewerButtons(), IpsaViewer(), and run().


The documentation for this class was generated from the following files:

Get IPSA - Inventor Physics Simulation API at SourceForge.net. Fast, secure and Free Open Source software downloads
Generated on Sat Mar 10 20:00:19 2012 for IPSA by  doxygen 1.5.8