Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

SIG_SimulationControls.cpp

00001 #include "SIGEL_SlaveGUI/SIG_SimulationControls.h"
00002 
00003 #include <qapplication.h>
00004 
00005 #include <cstdlib>
00006 
00007 namespace SIGEL_SlaveGUI
00008 {
00009 
00010   SIG_SimulationControls::SIG_SimulationControls(QMainWindow *mainWindow, QString name)
00011     : QActionGroup( mainWindow ),
00012       mainWindow(mainWindow),
00013       simulationRunning( false )
00014   {
00015     char *sigelRootCString = std::getenv( "SIGEL_ROOT" );
00016 
00017     QString sigelRootString( sigelRootCString );
00018 
00019     stopAction = new QAction( this, "stopAction" );
00020     playAction = new QAction( this, "playAction" );
00021     stepAction = new QAction( this, "stepAction" );
00022     fForwardAction = new QAction( this, "fForwardAction" );
00023     // recordAction = new QAction( this, "recordAction" );
00024     alterMovieSettingsAction = new QAction( this, "alterMovieSettingsAction" );
00025     quitAction = new QAction( this, "quitAction" );
00026 
00027     stopIcons.setPixmap( sigelRootString + "/pixmaps/stopButton.xpm", QIconSet::Large );
00028     playIcons.setPixmap( sigelRootString + "/pixmaps/startButton.xpm", QIconSet::Large );
00029     stepIcons.setPixmap( sigelRootString + "/pixmaps/stepButton.xpm", QIconSet::Large );
00030     pauseIcons.setPixmap( sigelRootString + "/pixmaps/pauseButton.xpm", QIconSet::Large );
00031     fForwardIcons.setPixmap( sigelRootString + "/pixmaps/ffButton.xpm", QIconSet::Large );
00032     // recordIcons.setPixmap( sigelRootString + "/pixmaps/videoallow.xpm", QIconSet::Large );
00033     recordingAllowedIcons.setPixmap( sigelRootString + "/pixmaps/videoallow.xpm", QIconSet::Large );
00034     recordingDisallowedIcons.setPixmap( sigelRootString + "/pixmaps/videodisallow.xpm", QIconSet::Large ); 
00035     quitIcons.setPixmap( sigelRootString + "/pixmaps/quitApplicationSmall.xpm", QIconSet::Large );
00036 
00037     stopAction->setIconSet( stopIcons );
00038     playAction->setIconSet( playIcons );
00039     stepAction->setIconSet( stepIcons );
00040     fForwardAction->setIconSet( fForwardIcons );
00041     // recordAction->setIconSet( recordIcons );
00042     alterMovieSettingsAction->setIconSet( recordingDisallowedIcons );
00043     quitAction->setIconSet( quitIcons );
00044 
00045     stopAction->setStatusTip( "Stops and restarts the simulation." );
00046     playAction->setStatusTip( "Starts/pauses the simulation." );
00047     stepAction->setStatusTip( "Lets the simulation progress about one timestep." );
00048     fForwardAction->setStatusTip( "Lets the simulation progress about 5 seconds." );
00049     // recordAction->setStatusTip( "Toggle the recording of the simulation." );
00050     alterMovieSettingsAction->setStatusTip( "Alter the movie settings." );
00051     quitAction->setStatusTip( "Closes the simulation visualization." );
00052 
00053     connect( playAction,
00054              SIGNAL(activated()),
00055              SLOT(slotPlayPressed()) );
00056 
00057     connect( stopAction,
00058              SIGNAL(activated()),
00059              SLOT(slotStopPressed()) );
00060 
00061     QObject::connect( quitAction,
00062                       SIGNAL(activated()),
00063                       qApp,
00064                       SLOT(quit()) );
00065 
00066   };
00067 
00068   SIG_SimulationControls::~SIG_SimulationControls()
00069   { };
00070 
00071   void SIG_SimulationControls::slotPlayPressed()
00072   {
00073     simulationRunning = !simulationRunning;
00074 
00075     stepAction->setEnabled( !simulationRunning );
00076     fForwardAction->setEnabled( !simulationRunning );
00077 
00078     if (simulationRunning)
00079       playAction->setIconSet( pauseIcons );
00080     else
00081       playAction->setIconSet( playIcons );
00082   };
00083 
00084   void SIG_SimulationControls::slotStopPressed()
00085   {
00086     simulationRunning = false;
00087 
00088     stepAction->setEnabled( true );
00089     fForwardAction->setEnabled( true );
00090 
00091     playAction->setIconSet( playIcons );
00092   };
00093 
00094   void SIG_SimulationControls::slotRecordingAllowed( bool isAllowed )
00095   {
00096     if( isAllowed )
00097       alterMovieSettingsAction->setIconSet( recordingAllowedIcons );
00098     else
00099       alterMovieSettingsAction->setIconSet( recordingDisallowedIcons );
00100   };
00101 }

Generated at Mon Sep 3 01:32:32 2001 for PG 368 - SIGEL by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000