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

SIG_SimulationParameter.cpp

00001 #include <qvalidator.h>
00002 #include <qlineedit.h>
00003 #include <qspinbox.h>
00004 #include <qcombobox.h>
00005 #include <qradiobutton.h>
00006 
00007 #include "SIGEL_MasterGUI/SIG_SimulationParameter.h"
00008 
00009 #include "SIGEL_Tools/SIG_IO.h" // only for DEBUG!
00010 
00011 namespace SIGEL_MasterGUI
00012 {
00013 
00014 SIG_SimulationParameter::SIG_SimulationParameter( QWidget* parent,  const char* name, WFlags fl, SIGEL_GP::SIG_GPExperiment &theExperiment )
00015   : SIG_SimulationParameterBase( parent, name, fl ), theExperiment( theExperiment )
00016 {
00017   lineeditStepSize->setValidator( new QDoubleValidator( lineeditStepSize , "ValidatorStepSize") );
00018   lineeditMaximalError->setValidator( new QDoubleValidator( lineeditMaximalError , "ValidatorMaximalError") );
00019   lineeditJointlimitsSpringConstant->setValidator( new QDoubleValidator( lineeditJointlimitsSpringConstant, "lineeditJointlimitsSpringConstant" ) );
00020   lineeditJointlimitsDamperConstant->setValidator( new QDoubleValidator( lineeditJointlimitsDamperConstant, "lineeditJointlimitsDamperConstant" ) );
00021   lineeditJointfrictionConstant->setValidator( new QDoubleValidator( lineeditJointfrictionConstant, "lineeditJointfrictionConstant" ) );
00022 }
00023 
00024 SIG_SimulationParameter::~SIG_SimulationParameter()
00025 {
00026     // no need to delete child widgets, Qt does it all for us
00027 }
00028 
00029 void SIG_SimulationParameter::putIntoExperiment()
00030 {
00031   // get time to simulate out of the widget (three spinboxes)
00032   QTime theTime( spinboxHours->value(),
00033                  spinboxMins->value(),
00034                  spinboxSecs->value() );
00035   theExperiment.simulationParameter.setTimeToSimulate( theTime );
00036   
00037   // get step size out of the widget (lineedit with double validator)
00038   double stepSize = lineeditStepSize->text().toDouble();
00039   theExperiment.simulationParameter.setStepSize( stepSize );
00040   
00041   // get random seed out of the widget (spinbox)
00042   int randomSeed = spinboxRandomSeed->value();
00043   theExperiment.simulationParameter.setRandomSeed( randomSeed );
00044   
00045   // get maximal error out of the widget (lineedit with double validator)
00046   double maximalError = lineeditMaximalError->text().toDouble();
00047   theExperiment.simulationParameter.setMaximalError( maximalError );
00048 
00049   // get the skipped frames out of the widget (spinbox)
00050   theExperiment.simulationParameter.setSkipFrames( spinboxSkippedFrames->value() );
00051 
00052   // get the maximal iterations out of the widget (spinbox)
00053   theExperiment.simulationParameter.setMaximalIterations( spinboxMaximalIterations->value() );
00054 
00055   // get the maximal collision loops out of the widget (spinbox)
00056   theExperiment.simulationParameter.setMaximalCollisionLoops( spinboxMaximalCollisionLoops->value() );
00057 
00058   // get the integrator out of the widget (combobox)
00059   switch( comboboxIntegrator->currentItem() )
00060     {
00061     case 0:
00062       theExperiment.simulationParameter.setIntegrator( SIGEL_Simulation::SIG_SimulationParameters::itRungeKutta4);
00063       break;
00064     case 1:
00065       theExperiment.simulationParameter.setIntegrator( SIGEL_Simulation::SIG_SimulationParameters::itRungeKutta2);
00066       break;
00067     case 2:
00068       theExperiment.simulationParameter.setIntegrator( SIGEL_Simulation::SIG_SimulationParameters::itDoubleEuler);
00069       break;
00070     case 3:
00071       theExperiment.simulationParameter.setIntegrator( SIGEL_Simulation::SIG_SimulationParameters::itEuler);
00072       break;
00073     }
00074 
00075   // get the solve mode out of the widget (combobox)
00076   switch( comboboxSolveMode->currentItem() )
00077     {
00078     case 0:
00079       theExperiment.simulationParameter.setSolveMode( SIGEL_Simulation::SIG_SimulationParameters::smtSingleValueDecomposition );
00080       break;
00081     case 1:
00082       theExperiment.simulationParameter.setSolveMode( SIGEL_Simulation::SIG_SimulationParameters::smtConjugateGradient );
00083       break;
00084     case 2:
00085       theExperiment.simulationParameter.setSolveMode( SIGEL_Simulation::SIG_SimulationParameters::smtLUDecomposition );
00086       break;
00087     }
00088   
00089   // get the CM mode out of the widget (radiobuttons)
00090   if( radiobuttonCMModeAnalytical->isChecked() )
00091     theExperiment.simulationParameter.setAnalytical( true );
00092   else
00093     theExperiment.simulationParameter.setAnalytical( false );
00094 
00095   theExperiment.simulationParameter.setMaximalSOLIDIterations( spinboxMaxSOLIDIterations->value() );
00096 
00097   // Get the simulation library out of the widget
00098   if( radiobuttonDynamo->isChecked() )
00099     theExperiment.simulationParameter.setSimulationLibrary( SIGEL_Simulation::SIG_SimulationParameters::DynaMo );
00100   else
00101     theExperiment.simulationParameter.setSimulationLibrary( SIGEL_Simulation::SIG_SimulationParameters::DynaMechs );
00102 
00103   // Get the dynaMechs integrator out of the widgets
00104   switch( comboboxDynaMechsIntegrator->currentItem() )
00105     {
00106       // euler
00107     case 0:
00108       theExperiment.simulationParameter.setDynaMechsIntegrator( SIGEL_Simulation::SIG_SimulationParameters::Euler );
00109       break;
00110       // runge kutta 4
00111     case 1:
00112       theExperiment.simulationParameter.setDynaMechsIntegrator( SIGEL_Simulation::SIG_SimulationParameters::RungeKutta4 );
00113       break;
00114       // runga kutta 45
00115     case 2:
00116       theExperiment.simulationParameter.setDynaMechsIntegrator( SIGEL_Simulation::SIG_SimulationParameters::RungeKutta45 );
00117       break;
00118     }
00119 
00120   // get the joint constants out of the widgets
00121   double newSpringConstant = lineeditJointlimitsSpringConstant->text().toDouble();
00122   theExperiment.simulationParameter.setJointLimitsK_spring( newSpringConstant );
00123   double newDamperConstant = lineeditJointlimitsDamperConstant->text().toDouble();
00124   theExperiment.simulationParameter.setJointLimitsB_damper( newDamperConstant );
00125   double newFrictionConstant = lineeditJointfrictionConstant->text().toDouble();
00126   theExperiment.simulationParameter.setJointFrictionU_c( newFrictionConstant );
00127   /*
00128    * Some stuff has still to be set.
00129    */
00130 }
00131 
00132 void SIG_SimulationParameter::getOutOfExperiment()
00133 {
00134   // Set the time to simulate widgets (three spinboxes)
00135   QTime theTime = theExperiment.simulationParameter.getTimeToSimulate();
00136   spinboxHours->setValue( theTime.hour() );
00137   spinboxMins->setValue( theTime.minute() );
00138   spinboxSecs->setValue( theTime.second() );
00139 
00140   // Set the step size widget (line edit with double validator)
00141   QString stepSize;
00142   stepSize.setNum( theExperiment.simulationParameter.getStepSize() );
00143   lineeditStepSize->setText( stepSize );
00144 
00145   // Set the random seed widget (spinbox)
00146   spinboxRandomSeed->setValue( theExperiment.simulationParameter.getRandomSeed() );
00147 
00148   // Set the maximal error widget (line edit with double validator)
00149   QString maximalError;
00150   maximalError.setNum( theExperiment.simulationParameter.getMaximalError() );
00151   lineeditMaximalError->setText( maximalError );
00152 
00153   // Set the skipped frames widget (spinbox)
00154   spinboxSkippedFrames->setValue( theExperiment.simulationParameter.getSkipFrames() );
00155 
00156   // Set the maximal iterations widget (spinbox)
00157   spinboxMaximalIterations->setValue( theExperiment.simulationParameter.getMaximalIterations() );
00158 
00159   // Set the maximal collision loops widget (spinbox)
00160   spinboxMaximalCollisionLoops->setValue( theExperiment.simulationParameter.getMaximalCollisionLoops() );
00161 
00162   // Set the integrator combobox
00163   switch( theExperiment.simulationParameter.getIntegrator() )
00164     {
00165     case SIGEL_Simulation::SIG_SimulationParameters::itEuler:
00166       comboboxIntegrator->setCurrentItem( 3 );
00167       break;
00168     case SIGEL_Simulation::SIG_SimulationParameters::itDoubleEuler:
00169       comboboxIntegrator->setCurrentItem( 2 );
00170       break;
00171     case SIGEL_Simulation::SIG_SimulationParameters::itRungeKutta2:
00172       comboboxIntegrator->setCurrentItem( 1 );
00173       break;
00174     case SIGEL_Simulation::SIG_SimulationParameters::itRungeKutta4:
00175       comboboxIntegrator->setCurrentItem( 0 );
00176       break;
00177     }
00178   
00179   // Set the solve mode widget (combobox)
00180   switch( theExperiment.simulationParameter.getSolveMode() )
00181     {
00182     case SIGEL_Simulation::SIG_SimulationParameters::smtSingleValueDecomposition:
00183       comboboxSolveMode->setCurrentItem( 0 );
00184       break;
00185     case SIGEL_Simulation::SIG_SimulationParameters::smtConjugateGradient:
00186       comboboxSolveMode->setCurrentItem( 1 );
00187       break;
00188     case SIGEL_Simulation::SIG_SimulationParameters::smtLUDecomposition:
00189       comboboxSolveMode->setCurrentItem( 2 );
00190       break;
00191     }
00192 
00193   // set the CM (Constraints Manager) mode widget (radio button)
00194   if( theExperiment.simulationParameter.getAnalytical() )
00195     radiobuttonCMModeAnalytical->setChecked( true );
00196   else
00197     radiobuttonCMModeEmpirical->setChecked( true );
00198   
00199   spinboxMaxSOLIDIterations->setValue( theExperiment.simulationParameter.getMaximalSOLIDIterations() );
00200   
00201   // Set the simulation library widgets.
00202   if( theExperiment.simulationParameter.getSimulationLibrary() == SIGEL_Simulation::SIG_SimulationParameters::DynaMo )
00203     radiobuttonDynamo->setChecked( true );
00204   if( theExperiment.simulationParameter.getSimulationLibrary() == SIGEL_Simulation::SIG_SimulationParameters::DynaMechs )
00205     radiobuttonDynaMechs->setChecked( true );
00206 
00207   // Set the dynaMechs integrator widget
00208   switch( theExperiment.simulationParameter.getDynaMechsIntegrator() )
00209     {
00210       // euler
00211     case SIGEL_Simulation::SIG_SimulationParameters::Euler:
00212       comboboxDynaMechsIntegrator->setCurrentItem( 0 );
00213       break;
00214       // runge kutta 4
00215     case SIGEL_Simulation::SIG_SimulationParameters::RungeKutta4:
00216       comboboxDynaMechsIntegrator->setCurrentItem( 1 );
00217       break;
00218       // runga kutta 45
00219     case SIGEL_Simulation::SIG_SimulationParameters::RungeKutta45:
00220       comboboxDynaMechsIntegrator->setCurrentItem( 2 );
00221       break;
00222     }
00223 
00224   lineeditJointlimitsSpringConstant->setText( QString::number( theExperiment.simulationParameter.getJointLimitsK_spring() ) );
00225   lineeditJointlimitsDamperConstant->setText( QString::number( theExperiment.simulationParameter.getJointLimitsB_damper() ) );
00226   lineeditJointfrictionConstant->setText( QString::number( theExperiment.simulationParameter.getJointFrictionU_c() ) );
00227   /*
00228    * Some stuff has still to be set!
00229    */
00230 }
00231 
00232 }

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