Lagrangian Liquid Simulation
Master Thesis project on simulation of liquids using Lagrangian approach and SPH
src/MainApp.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 #include "MainApp.h"
00006 #include "Configuration.h"
00007 
00008 #include "ui_MainWindow.h"
00009 
00010 
00011 
00012 MainApp::MainApp
00013                 (
00014                     QWidget* _parent
00015                 ):
00016                 QMainWindow(_parent),
00017                 m_ui(new Ui::MainWindow)
00018 {
00019     // setup the user interface
00020     m_ui->setupUi(this);
00021 
00022     //create a new instance of the world and give it an initial aspect ratio
00023     m_simulation = new Simulation(this);
00024 
00025     m_ui->s_mainGridLayout->addWidget(m_simulation, 0, 0, 4, 2);
00026 
00027     //setup signals/slots
00028     setupConnections();
00029 }
00030 
00031 MainApp::~MainApp()
00032 {
00033     delete m_ui;
00034 }
00035 
00036 void MainApp::setupConnections()
00037 {
00038     //read from simulation objects and initialise states of controls
00039 
00040     //---------------------------------------------------------------------------------------------------------------------
00041     //TAB : SOLVER
00042     //timestep
00043     m_ui->spin_solver_timestep->setValue(m_simulation->getIntegration()->getTimestep());
00044 
00045     //smoothing length
00046     m_ui->spin_solver_smoothingLength->setValue(m_simulation->getSolver()->getSmoothingLength());
00047 
00048 
00049     //---------------------------------------------------------------------------------------------------------------------
00050     //TAB : FLUID
00052     for (int i = 0; i < m_simulation->getSolver()->getNameList().size(); ++i)
00053     {
00054         m_ui->cmb_fluid_currentFluid->addItems(QStringList(QString(m_simulation->getSolver()->getNameList()[i].c_str())));
00055     }
00056 
00057     //update controls for the first fluid
00058     if (m_simulation->getSolver()->getNameList().size() >= 1) refreshControlsFromFluid(0);
00059 
00060     //toggle hose marker drawing
00061     m_ui->chk_fluid_hose_drawMarker->setChecked(m_simulation->getSolver()->getDrawHoseMarker());
00062 
00063     //hose centre
00064     m_ui->spin_hose_centre_x->setValue(m_simulation->getSolver()->getHoseCenter().m_x);
00065     m_ui->spin_hose_centre_y->setValue(m_simulation->getSolver()->getHoseCenter().m_y);
00066     m_ui->spin_hose_centre_z->setValue(m_simulation->getSolver()->getHoseCenter().m_z);
00067 
00068     //hose velocity
00069     m_ui->spin_hose_velocity_x->setValue(m_simulation->getSolver()->getHoseVelocity().m_x);
00070     m_ui->spin_hose_velocity_y->setValue(m_simulation->getSolver()->getHoseVelocity().m_y);
00071     m_ui->spin_hose_velocity_z->setValue(m_simulation->getSolver()->getHoseVelocity().m_z);
00072 
00073     //wait until first time properties
00074     m_ui->chk_fluid_hose_waitUntilBoundary->setChecked(m_simulation->getSolver()->getHoseWaitUntilHitBoundary());
00075     m_ui->chk_fluid_hose_waitUntilRBD->setChecked(m_simulation->getSolver()->getHoseWaitUntilHitRBD());
00076 
00077 
00078     //---------------------------------------------------------------------------------------------------------------------
00079     //TAB : CACHE
00080     //cache toggle
00081     m_ui->chk_cache_enable->setChecked(m_simulation->getCacheEnabled());
00082 
00083     //cache sampling interval
00084     m_ui->spin_cache_samplingInterval->setValue(m_simulation->getCacheSamplingInterval());
00085 
00086     //cache automatic sampling
00087     m_ui->chk_cache_automaticFlush->setChecked(m_simulation->getCacheAutomaticFlushEnabled());
00088     m_ui->spin_cache_automaticFlushInterval->setValue(m_simulation->getCacheAutomaticFlushInterval() / 1000);   //ms -> s
00089 
00090     //cache rbd and boundary
00091     m_ui->chk_cache_exportRBD->setChecked(m_simulation->getCacheExportRBDEnabled());
00092     m_ui->chk_cache_exportBoundary->setChecked(m_simulation->getCacheExportBoundaryEnabled());
00093 
00094 
00095     //---------------------------------------------------------------------------------------------------------------------
00096     //TAB : ENVIRONMENT
00097 
00098     //SUBTAB : BOUNDARY
00099     //boundary centre
00100     m_ui->spin_environment_boundary_centre_x->setValue(m_simulation->getEnvironment()->getBoundaryPosition().m_x);
00101     m_ui->spin_environment_boundary_centre_y->setValue(m_simulation->getEnvironment()->getBoundaryPosition().m_y);
00102     m_ui->spin_environment_boundary_centre_z->setValue(m_simulation->getEnvironment()->getBoundaryPosition().m_z);
00103 
00104     //boundary dimension
00105     m_ui->spin_environment_boundary_size_x->setValue(m_simulation->getEnvironment()->getBoundaryDimension().m_x);
00106     m_ui->spin_environment_boundary_size_y->setValue(m_simulation->getEnvironment()->getBoundaryDimension().m_x);
00107     m_ui->spin_environment_boundary_size_z->setValue(m_simulation->getEnvironment()->getBoundaryDimension().m_x);
00108 
00109     //restitution coefficients
00110     m_ui->spin_environment_boundary_restitutionForFluid->setValue(m_simulation->getEnvironment()->getBoundaryRestitutionCoefficientForFluid());
00111     m_ui->spin_environment_boundary_restitutionForRBD->setValue(m_simulation->getEnvironment()->getBoundaryRestitutionCoefficientForRBD());
00112 
00113     //periodic wall
00114     m_ui->chk_environment_boundary_enablePeriodicWall->setChecked(m_simulation->getEnvironment()->getPeriodicWallEnabled());
00115     m_ui->spin_environment_boundary_periodicWall_speed->setValue(m_simulation->getEnvironment()->getPeriodicWallSpeed());
00116     m_ui->spin_environment_boundary_periodicWall_angleIncrement->setValue(m_simulation->getEnvironment()->getPeriodicWallAngleIncrement());
00117     m_ui->spin_environment_boundary_periodicWall_maxAmplitude->setValue(m_simulation->getEnvironment()->getPeriodicWallMaxAmplitude());
00118 
00119 
00120     //SUBTAB : RBD
00121     //restitution coefficients
00122     m_ui->spin_environment_rbd_restitution->setValue(m_simulation->getEnvironment()->getObstacleRestitutionCoefficient());
00123 
00124     //capsule resolution
00125     m_ui->spin_environment_capsule_resolution->setValue(m_simulation->getEnvironment()->getCapsuleResolution());
00126 
00127     //build sphere combo list
00128     for (int i = 0; i < m_simulation->getEnvironment()->getSphereNameList().size(); ++i)
00129     {
00130         m_ui->cmb_environment_sphere->addItems(QStringList(QString(m_simulation->getEnvironment()->getSphereNameList()[i].c_str())));
00131     }
00132 
00133     //update controls for the first sphere
00134     if (m_simulation->getEnvironment()->getSphereNameList().size() >= 1) refreshControlsFromSphere(0);
00135 
00136     //build sphere combo list
00137     for (int i = 0; i < m_simulation->getEnvironment()->getCapsuleNameList().size(); ++i)
00138     {
00139         m_ui->cmb_environment_capsule->addItems(QStringList(QString(m_simulation->getEnvironment()->getCapsuleNameList()[i].c_str())));
00140     }
00141 
00142     //update controls for the first capsule
00143     if (m_simulation->getEnvironment()->getCapsuleNameList().size() >= 1) refreshControlsFromCapsule(0);
00144 
00145 
00146     //OUTSIDE BUTTONS
00147     m_ui->cmd_autoMove->setText(m_simulation->getSolver()->getEnableAutoFluidUpdate() ? "AutoMove Stop" : "AutoMove Start");
00148 
00149 
00150     //GLOBAL CAMERA
00151     //setup camera zoom control and signal here
00152     //read camera z value from config file and set it to the slider
00153     ngl::Camera m_camera = Configuration::initialiseCamera(1.0);
00154     m_ui->sld_cameraZoom->setValue(-m_camera.getEye().m_z);
00155     connect(m_ui->sld_cameraZoom, SIGNAL(valueChanged(int)), m_simulation, SLOT(updateCameraZoom(int)));
00156 }
00157 
00158 void MainApp::refreshControlsFromFluid(const int _fluidId)
00159 {
00160     //density
00161     m_ui->spin_fluid_restDensity->setValue(m_simulation->getSolver()->getHoseParticlePrototypeList()[_fluidId].getMaterialRestDensity());
00162 
00163     //gas constant
00164     m_ui->spin_fluid_gasConstant->setValue(m_simulation->getSolver()->getHoseParticlePrototypeList()[_fluidId].getGasConstant());
00165 
00166     //viscosity constant
00167     m_ui->spin_fluid_viscosityConstant->setValue(m_simulation->getSolver()->getHoseParticlePrototypeList()[_fluidId].getViscosityConstant());
00168 
00169     //surface tension
00170     m_ui->spin_fluid_surfaceCoefficient->setValue(m_simulation->getSolver()->getHoseParticlePrototypeList()[_fluidId].getSurfaceTensionCoefficient());
00171     m_ui->spin_fluid_surfaceThreshold->setValue(m_simulation->getSolver()->getHoseParticlePrototypeList()[_fluidId].getSurfaceTensionThreshold());
00172 
00173     //interface tension
00174     m_ui->spin_fluid_interfaceCoefficient->setValue(m_simulation->getSolver()->getHoseParticlePrototypeList()[_fluidId].getInterfaceTensionCoefficient());
00175     m_ui->spin_fluid_interfaceThreshold->setValue(m_simulation->getSolver()->getHoseParticlePrototypeList()[_fluidId].getInterfaceTensionThreshold());
00176 
00177     //interface color
00178     bool minus = m_simulation->getSolver()->getHoseParticlePrototypeList()[_fluidId].getInterfaceColorCoefficient() < 0;
00179     m_ui->spin_fluid_interfaceColorMinus->setChecked(minus);
00180     m_ui->spin_fluid_interfaceColorPlus->setChecked(!minus);
00181 }
00182 
00183 void MainApp::refreshControlsFromSphere(const int _sphereId)
00184 {
00185     //position
00186     m_ui->spin_environment_sphere_centre_x->setValue(m_simulation->getEnvironment()->getSphereObstacleList()[_sphereId].getPosition().m_x);
00187     m_ui->spin_environment_sphere_centre_y->setValue(m_simulation->getEnvironment()->getSphereObstacleList()[_sphereId].getPosition().m_y);
00188     m_ui->spin_environment_sphere_centre_z->setValue(m_simulation->getEnvironment()->getSphereObstacleList()[_sphereId].getPosition().m_z);
00189 
00190     //velocity
00191     m_ui->spin_environment_sphere_velocity_x->setValue(m_simulation->getEnvironment()->getSphereObstacleList()[_sphereId].getVelocity().m_x);
00192     m_ui->spin_environment_sphere_velocity_y->setValue(m_simulation->getEnvironment()->getSphereObstacleList()[_sphereId].getVelocity().m_y);
00193     m_ui->spin_environment_sphere_velocity_z->setValue(m_simulation->getEnvironment()->getSphereObstacleList()[_sphereId].getVelocity().m_z);
00194 
00195     //radius
00196     m_ui->spin_environment_sphere_radius->setValue(m_simulation->getEnvironment()->getSphereObstacleList()[_sphereId].getRadius());
00197 
00198     //static
00199     m_ui->chk_environment_sphere_isStatic->setChecked(!m_simulation->getEnvironment()->getSphereObstacleList()[_sphereId].getMoveable());
00200 }
00201 
00202 void MainApp::refreshControlsFromCapsule(const int _capsuleId)
00203 {
00204     //centre
00205     m_ui->spin_environment_capsule_centre_x->setValue(m_simulation->getEnvironment()->getCapsuleObstacleList()[_capsuleId].getPosition().m_x);
00206     m_ui->spin_environment_capsule_centre_y->setValue(m_simulation->getEnvironment()->getCapsuleObstacleList()[_capsuleId].getPosition().m_y);
00207     m_ui->spin_environment_capsule_centre_z->setValue(m_simulation->getEnvironment()->getCapsuleObstacleList()[_capsuleId].getPosition().m_z);
00208 
00209     //angle
00210     m_ui->spin_environment_capsule_incrementAngle->setValue(m_simulation->getEnvironment()->getCapsuleObstacleList()[_capsuleId].getIncrementAngle());
00211 
00212     //radius
00213     m_ui->spin_environment_capsule_radius->setValue(m_simulation->getEnvironment()->getCapsuleObstacleList()[_capsuleId].getRadius());
00214 
00215     //static
00216     m_ui->chk_environment_capsule_isStatic->setChecked(!m_simulation->getEnvironment()->getCapsuleObstacleList()[_capsuleId].getMoveable());
00217 }
00218 
00219 void MainApp::keyPressEvent(
00220                                QKeyEvent* _event
00221                             )
00222 {
00223     // this method is called every time the main window recives a key event.
00224     this->setFocus(Qt::ActiveWindowFocusReason);
00225 
00226     switch (_event->key())
00227     {
00228         case Qt::Key_Escape : QApplication::exit(EXIT_SUCCESS); break;
00229 
00230         case Qt::Key_M : showFullScreen(); break;
00231         case Qt::Key_N : showNormal(); break;
00232 
00233         default : break;
00234     }
00235 
00236     m_simulation->keyPress(_event);
00237 }
00238 
00239 //SIMULATION SLOTS
00240 void MainApp::on_cmd_2DTopView_clicked()
00241 {
00242     //setup top view
00243     m_simulation->setup2DTopView();
00244 }
00245 
00246 void MainApp::on_cmd_2DFrontView_clicked()
00247 {
00248     //setup front view
00249     m_simulation->setup2DFrontView();
00250 }
00251 
00252 void MainApp::on_chk_cache_enable_clicked(bool checked)
00253 {
00254     m_simulation->setCacheEnabled(checked);
00255     m_simulation->toggleCache();
00256 }
00257 
00258 void MainApp::on_spin_cache_samplingInterval_valueChanged(int value)
00259 {
00260     m_simulation->setCacheSamplingInterval(value);
00261     m_simulation->toggleCache();
00262 }
00263 
00264 void MainApp::on_chk_cache_exportRBD_clicked(bool checked)
00265 {
00266     m_simulation->setCacheExportRBDEnabled(checked);
00267 }
00268 
00269 void MainApp::on_chk_cache_exportBoundary_clicked(bool checked)
00270 {
00271     m_simulation->setCacheExportBoundaryEnabled(checked);
00272 }
00273 
00274 void MainApp::on_chk_cache_automaticFlush_clicked(bool checked)
00275 {
00276     m_simulation->setCacheAutomaticFlushEnabled(checked);
00277     m_simulation->toggleCache();
00278 }
00279 
00280 void MainApp::on_spin_cache_automaticFlushInterval_valueChanged(int value)
00281 {
00282     m_simulation->setCacheAutomaticFlushInterval(value * 1000);     //s -> ms
00283     m_simulation->toggleAutomaticCacheFlush();
00284 }
00285 
00286 void MainApp::on_chk_fluid_hose_drawMarker_clicked(bool checked)
00287 {
00288     m_simulation->getSolver()->setDrawHoseMarker(checked);
00289 
00290     m_simulation->updateGL();
00291 }
00292 
00293 void MainApp::on_chk_fluid_hose_waitUntilBoundary_clicked(bool checked)
00294 {
00295     m_simulation->getSolver()->setHoseWaitUntilHitBoundary(checked);
00296 }
00297 
00298 void MainApp::on_chk_fluid_hose_waitUntilRBD_clicked(bool checked)
00299 {
00300     m_simulation->getSolver()->setHoseWaitUntilHitRBD(checked);
00301 }
00302 
00303 void MainApp::on_spin_hose_centre_x_valueChanged(int value)
00304 {
00305     m_simulation->getSolver()->setHoseCenter(ngl::Vector(value, m_simulation->getSolver()->getHoseCenter().m_y, m_simulation->getSolver()->getHoseCenter().m_z));
00306 
00307     m_simulation->updateGL();
00308 }
00309 
00310 void MainApp::on_spin_hose_centre_y_valueChanged(int value)
00311 {
00312     m_simulation->getSolver()->setHoseCenter(ngl::Vector(m_simulation->getSolver()->getHoseCenter().m_x, value, m_simulation->getSolver()->getHoseCenter().m_z));
00313 
00314     m_simulation->updateGL();
00315 }
00316 
00317 void MainApp::on_spin_hose_centre_z_valueChanged(int value)
00318 {
00319     m_simulation->getSolver()->setHoseCenter(ngl::Vector(m_simulation->getSolver()->getHoseCenter().m_x, m_simulation->getSolver()->getHoseCenter().m_y, value));
00320 
00321     m_simulation->updateGL();
00322 }
00323 
00324 void MainApp::on_spin_hose_velocity_x_valueChanged(int value)
00325 {
00326     m_simulation->getSolver()->setHoseVelocity(ngl::Vector(value, m_simulation->getSolver()->getHoseVelocity().m_y, m_simulation->getSolver()->getHoseVelocity().m_z));
00327 }
00328 
00329 void MainApp::on_spin_hose_velocity_y_valueChanged(int value)
00330 {
00331     m_simulation->getSolver()->setHoseVelocity(ngl::Vector(m_simulation->getSolver()->getHoseVelocity().m_x, value, m_simulation->getSolver()->getHoseVelocity().m_z));
00332 }
00333 
00334 void MainApp::on_spin_hose_velocity_z_valueChanged(int value)
00335 {
00336     m_simulation->getSolver()->setHoseVelocity(ngl::Vector(m_simulation->getSolver()->getHoseVelocity().m_x, m_simulation->getSolver()->getHoseVelocity().m_y, value));
00337 }
00338 
00339 void MainApp::on_spin_environment_rbd_restitution_valueChanged(double value)
00340 {
00341     m_simulation->getEnvironment()->setObstacleRestitutionCoefficient(value);
00342 }
00343 
00344 void MainApp::on_spin_environment_capsule_resolution_valueChanged(int value)
00345 {
00346     m_simulation->getEnvironment()->setCapsuleResolution(value);
00347 
00348     m_simulation->updateGL();
00349 }
00350 
00351 void MainApp::on_spin_environment_boundary_centre_x_valueChanged(int value)
00352 {
00353     m_simulation->getEnvironment()->setBoundaryPosition(ngl::Vector(value, m_simulation->getEnvironment()->getBoundaryPosition().m_y, m_simulation->getEnvironment()->getBoundaryPosition().m_z));
00354 
00355     m_simulation->updateGL();
00356 }
00357 
00358 
00359 void MainApp::on_spin_environment_boundary_centre_y_valueChanged(int value)
00360 {
00361     m_simulation->getEnvironment()->setBoundaryPosition(ngl::Vector(m_simulation->getEnvironment()->getBoundaryPosition().m_x, value, m_simulation->getEnvironment()->getBoundaryPosition().m_z));
00362 
00363     m_simulation->updateGL();
00364 }
00365 
00366 void MainApp::on_spin_environment_boundary_centre_z_valueChanged(int value)
00367 {
00368     m_simulation->getEnvironment()->setBoundaryPosition(ngl::Vector(m_simulation->getEnvironment()->getBoundaryPosition().m_x, m_simulation->getEnvironment()->getBoundaryPosition().m_y, value));
00369 
00370     m_simulation->updateGL();
00371 }
00372 
00373 void MainApp::on_checkBox_clicked(bool checked)
00374 {
00375     m_simulation->getEnvironment()->setBoundaryBoundTop(checked);
00376 }
00377 
00378 void MainApp::on_spin_environment_boundary_restitutionForFluid_valueChanged(double value)
00379 {
00380     m_simulation->getEnvironment()->setBoundaryRestitutionCoefficientForFluid(value);
00381 }
00382 
00383 void MainApp::on_spin_environment_boundary_restitutionForRBD_valueChanged(double value)
00384 {
00385     m_simulation->getEnvironment()->setBoundaryRestitutionCoefficientForRBD(value);
00386 }
00387 
00388 void MainApp::on_chk_environment_boundary_enablePeriodicWall_clicked(bool checked)
00389 {
00390     m_simulation->getEnvironment()->setPeriodicWallEnabled(checked);
00391 }
00392 
00393 void MainApp::on_spin_environment_boundary_periodicWall_maxAmplitude_valueChanged(int value)
00394 {
00395     m_simulation->getEnvironment()->setPeriodicWallMaxAmplitude(value);
00396 }
00397 
00398 void MainApp::on_spin_environment_boundary_periodicWall_speed_valueChanged(double value)
00399 {
00400     m_simulation->getEnvironment()->setPeriodicWallSpeed(value);
00401 }
00402 
00403 void MainApp::on_spin_environment_boundary_periodicWall_angleIncrement_valueChanged(int value)
00404 {
00405     m_simulation->getEnvironment()->setPeriodicWallAngleIncrement(value);
00406 }
00407 
00408 void MainApp::on_spin_environment_boundary_size_x_valueChanged(int value)
00409 {
00410     m_simulation->getEnvironment()->setBoundaryDimension(ngl::Vector(value, m_simulation->getEnvironment()->getBoundaryDimension().m_y, m_simulation->getEnvironment()->getBoundaryDimension().m_z));
00411 
00412     m_simulation->updateGL();
00413 }
00414 
00415 void MainApp::on_spin_environment_boundary_size_y_valueChanged(int value)
00416 {
00417     m_simulation->getEnvironment()->setBoundaryDimension(ngl::Vector(m_simulation->getEnvironment()->getBoundaryDimension().m_x, value, m_simulation->getEnvironment()->getBoundaryDimension().m_z));
00418 
00419     m_simulation->updateGL();
00420 }
00421 
00422 void MainApp::on_spin_environment_boundary_size_z_valueChanged(int value)
00423 {
00424     m_simulation->getEnvironment()->setBoundaryDimension(ngl::Vector(m_simulation->getEnvironment()->getBoundaryDimension().m_x, m_simulation->getEnvironment()->getBoundaryDimension().m_y, value));
00425 
00426     m_simulation->updateGL();
00427 }
00428 
00429 void MainApp::on_cmb_environment_sphere_currentIndexChanged(int index)
00430 {
00431     refreshControlsFromSphere(index);
00432 }
00433 
00434 void MainApp::on_cmb_environment_capsule_currentIndexChanged(int index)
00435 {
00436     refreshControlsFromCapsule(index);
00437 }
00438 
00439 void MainApp::on_spin_environment_sphere_centre_x_valueChanged(int value)
00440 {
00441     //get currently selected sphere id
00442     int id = m_ui->cmb_environment_sphere->currentIndex();
00443 
00444     //get position
00445     ngl::Vector pos = m_simulation->getEnvironment()->getSphereObstacleList()[id].getPosition();
00446 
00447     //update currently selected object
00448     m_simulation->getEnvironment()->getSphereObstacleList()[id].updatePosition(ngl::Vector(value, pos.m_y, pos.m_z));
00449 
00450     m_simulation->updateGL();
00451 }
00452 
00453 void MainApp::on_spin_environment_sphere_centre_y_valueChanged(int value)
00454 {
00455     //get currently selected sphere id
00456     int id = m_ui->cmb_environment_sphere->currentIndex();
00457 
00458     //get position
00459     ngl::Vector pos = m_simulation->getEnvironment()->getSphereObstacleList()[id].getPosition();
00460 
00461     //update currently selected object
00462     m_simulation->getEnvironment()->getSphereObstacleList()[id].updatePosition(ngl::Vector(pos.m_x, value, pos.m_z));
00463 
00464     m_simulation->updateGL();
00465 }
00466 
00467 void MainApp::on_spin_environment_sphere_centre_z_valueChanged(int value)
00468 {
00469     //get currently selected sphere id
00470     int id = m_ui->cmb_environment_sphere->currentIndex();
00471 
00472     //get position
00473     ngl::Vector pos = m_simulation->getEnvironment()->getSphereObstacleList()[id].getPosition();
00474 
00475     //update currently selected object
00476     m_simulation->getEnvironment()->getSphereObstacleList()[id].updatePosition(ngl::Vector(pos.m_x, pos.m_y, value));
00477 
00478     m_simulation->updateGL();
00479 }
00480 
00481 void MainApp::on_spin_environment_sphere_velocity_x_valueChanged(int value)
00482 {
00483     //get currently selected sphere id
00484     int id = m_ui->cmb_environment_sphere->currentIndex();
00485 
00486     //get velocity
00487     ngl::Vector pos = m_simulation->getEnvironment()->getSphereObstacleList()[id].getVelocity();
00488 
00489     //update currently selected object
00490     m_simulation->getEnvironment()->getSphereObstacleList()[id].updateVelocity(ngl::Vector(value, pos.m_y, pos.m_z));
00491 
00492     m_simulation->updateGL();
00493 }
00494 
00495 void MainApp::on_spin_environment_sphere_velocity_y_valueChanged(int value)
00496 {
00497     //get currently selected sphere id
00498     int id = m_ui->cmb_environment_sphere->currentIndex();
00499 
00500     //get position
00501     ngl::Vector pos = m_simulation->getEnvironment()->getSphereObstacleList()[id].getVelocity();
00502 
00503     //update currently selected object
00504     m_simulation->getEnvironment()->getSphereObstacleList()[id].updateVelocity(ngl::Vector(pos.m_x, value, pos.m_z));
00505 
00506     m_simulation->updateGL();
00507 }
00508 
00509 void MainApp::on_spin_environment_sphere_velocity_z_valueChanged(int value)
00510 {
00511     //get currently selected sphere id
00512     int id = m_ui->cmb_environment_sphere->currentIndex();
00513 
00514     //get position
00515     ngl::Vector pos = m_simulation->getEnvironment()->getSphereObstacleList()[id].getVelocity();
00516 
00517     //update currently selected object
00518     m_simulation->getEnvironment()->getSphereObstacleList()[id].updateVelocity(ngl::Vector(pos.m_x, pos.m_y, value));
00519 
00520     m_simulation->updateGL();
00521 }
00522 
00523 void MainApp::on_spin_environment_sphere_radius_valueChanged(double value)
00524 {
00525     //get currently selected sphere id
00526     int id = m_ui->cmb_environment_sphere->currentIndex();
00527 
00528     //update currently selected object
00529     m_simulation->getEnvironment()->getSphereObstacleList()[id].setRadius(value);
00530 
00531     m_simulation->updateGL();
00532 }
00533 
00534 void MainApp::on_chk_environment_sphere_isStatic_clicked(bool checked)
00535 {
00536     //get currently selected sphere id
00537     int id = m_ui->cmb_environment_sphere->currentIndex();
00538 
00539     //update currently selected object
00540     m_simulation->getEnvironment()->getSphereObstacleList()[id].setMoveable(!checked);
00541 }
00542 
00543 void MainApp::on_spin_environment_capsule_radius_valueChanged(double value)
00544 {
00545     //get currently selected capsule id
00546     int id = m_ui->cmb_environment_capsule->currentIndex();
00547 
00548     //update currently selected object
00549     m_simulation->getEnvironment()->getCapsuleObstacleList()[id].setRadius(value);
00550 
00551     m_simulation->updateGL();
00552 }
00553 
00554 void MainApp::on_chk_environment_capsule_isStatic_clicked(bool checked)
00555 {
00556     //get currently selected capsule id
00557     int id = m_ui->cmb_environment_capsule->currentIndex();
00558 
00559     //update currently selected object
00560     m_simulation->getEnvironment()->getCapsuleObstacleList()[id].setMoveable(!checked);
00561 }
00562 
00563 void MainApp::on_spin_environment_capsule_incrementAngle_valueChanged(int value)
00564 {
00565     //get currently selected capsule id
00566     int id = m_ui->cmb_environment_capsule->currentIndex();
00567 
00568     //update currently selected object
00569     m_simulation->getEnvironment()->getCapsuleObstacleList()[id].setIncrementAngle(value);
00570 }
00571 
00572 void MainApp::on_spin_environment_capsule_centre_x_valueChanged(double value)
00573 {
00574     //get currently selected capsule id
00575     int id = m_ui->cmb_environment_capsule->currentIndex();
00576 
00577     //get position
00578     ngl::Vector pos = m_simulation->getEnvironment()->getCapsuleObstacleList()[id].getPosition();
00579 
00580     //update currently selected object
00581     m_simulation->getEnvironment()->getCapsuleObstacleList()[id].updatePosition(ngl::Vector(value, pos.m_y, pos.m_z));
00582 
00583     m_simulation->updateGL();
00584 }
00585 
00586 void MainApp::on_spin_environment_capsule_centre_y_valueChanged(double value)
00587 {
00588     //get currently selected capsule id
00589     int id = m_ui->cmb_environment_capsule->currentIndex();
00590 
00591     //get position
00592     ngl::Vector pos = m_simulation->getEnvironment()->getCapsuleObstacleList()[id].getPosition();
00593 
00594     //update currently selected object
00595     m_simulation->getEnvironment()->getCapsuleObstacleList()[id].updatePosition(ngl::Vector(pos.m_x, value, pos.m_z));
00596 
00597     m_simulation->updateGL();
00598 }
00599 
00600 void MainApp::on_spin_environment_capsule_centre_z_valueChanged(double value)
00601 {
00602     //get currently selected capsule id
00603     int id = m_ui->cmb_environment_capsule->currentIndex();
00604 
00605     //get position
00606     ngl::Vector pos = m_simulation->getEnvironment()->getCapsuleObstacleList()[id].getPosition();
00607 
00608     //update currently selected object
00609     m_simulation->getEnvironment()->getCapsuleObstacleList()[id].updatePosition(ngl::Vector(pos.m_x, pos.m_y, value));
00610 
00611     m_simulation->updateGL();
00612 }
00613 
00614 void MainApp::on_spin_solver_timestep_valueChanged(double value)
00615 {
00616     m_simulation->getIntegration()->setTimestep(value);
00617 }
00618 
00619 void MainApp::on_cmb_solver_integrationMethod_currentIndexChanged(int index)
00620 {
00621     m_simulation->getIntegration()->setIntegrationType(index);
00622 }
00623 
00624 void MainApp::on_spin_solver_smoothingLength_valueChanged(double value)
00625 {
00626     m_simulation->getSolver()->setSmoothingLength(value);
00627 }
00628 
00629 void MainApp::on_cmb_fluid_currentFluid_currentIndexChanged(int index)
00630 {
00631     m_simulation->getSolver()->setCurrentHoseableFluid(index);
00632 
00633     refreshControlsFromFluid(index);
00634 }
00635 
00636 void MainApp::on_spin_fluid_restDensity_valueChanged(double value)
00637 {
00638     //get currently selected fluid id
00639     int id = m_ui->cmb_fluid_currentFluid->currentIndex();
00640 
00641     //update currently selected object
00642     m_simulation->getSolver()->updateRestDensityForFluid(id, value);
00643 }
00644 
00645 void MainApp::on_spin_fluid_gasConstant_valueChanged(double value)
00646 {
00647     //get currently selected fluid id
00648     int id = m_ui->cmb_fluid_currentFluid->currentIndex();
00649 
00650     //update currently selected object
00651     m_simulation->getSolver()->updateGasConstantForFluid(id, value);
00652 }
00653 
00654 void MainApp::on_spin_fluid_viscosityConstant_valueChanged(double value)
00655 {
00656     //get currently selected fluid id
00657     int id = m_ui->cmb_fluid_currentFluid->currentIndex();
00658 
00659     //update currently selected object
00660     m_simulation->getSolver()->updateViscosityConstantForFluid(id, value);
00661 }
00662 
00663 void MainApp::on_spin_fluid_surfaceCoefficient_valueChanged(double value)
00664 {
00665     //get currently selected fluid id
00666     int id = m_ui->cmb_fluid_currentFluid->currentIndex();
00667 
00668     //update currently selected object
00669     m_simulation->getSolver()->updateSurfaceCoefficientForFluid(id, value);
00670 }
00671 
00672 void MainApp::on_spin_fluid_surfaceThreshold_valueChanged(double value)
00673 {
00674     //get currently selected fluid id
00675     int id = m_ui->cmb_fluid_currentFluid->currentIndex();
00676 
00677     //update currently selected object
00678     m_simulation->getSolver()->updateSurfaceThresholdForFluid(id, value);
00679 }
00680 
00681 void MainApp::on_spin_fluid_interfaceCoefficient_valueChanged(double value)
00682 {
00683     //get currently selected fluid id
00684     int id = m_ui->cmb_fluid_currentFluid->currentIndex();
00685 
00686     //update currently selected object
00687     m_simulation->getSolver()->updateInterfaceCoefficientForFluid(id, value);
00688 }
00689 
00690 void MainApp::on_spin_fluid_interfaceThreshold_valueChanged(double value)
00691 {
00692     //get currently selected fluid id
00693     int id = m_ui->cmb_fluid_currentFluid->currentIndex();
00694 
00695     //update currently selected object
00696     m_simulation->getSolver()->updateInterfaceThresholdForFluid(id, value);
00697 }
00698 
00699 void MainApp::on_spin_fluid_interfaceColorMinus_clicked(bool checked)
00700 {
00701     //get currently selected fluid id
00702     int id = m_ui->cmb_fluid_currentFluid->currentIndex();
00703 
00704 
00705     if (checked)
00706         //update currently selected object
00707         m_simulation->getSolver()->updateInterfaceColorForFluid(id, -0.5);
00708     else
00709         //update currently selected object
00710         m_simulation->getSolver()->updateInterfaceColorForFluid(id, 0.5);
00711 
00712 }
00713 
00714 void MainApp::on_spin_fluid_interfaceColorPlus_clicked(bool checked)
00715 {
00716     //get currently selected fluid id
00717     int id = m_ui->cmb_fluid_currentFluid->currentIndex();
00718 
00719 
00720     if (checked)
00721         //update currently selected object
00722         m_simulation->getSolver()->updateInterfaceColorForFluid(id, 0.5);
00723     else
00724         //update currently selected object
00725         m_simulation->getSolver()->updateInterfaceColorForFluid(id, -0.5);
00726 }
00727 
00728 void MainApp::on_cmd_singleStep_clicked()
00729 {
00730     m_simulation->getSolver()->updateFluid(m_simulation->getEnvironment(), m_simulation->getIntegration());
00731 
00732     m_simulation->updateGL();
00733 }
00734 
00735 void MainApp::on_cmd_autoMove_clicked()
00736 {
00737     m_ui->cmd_autoMove->setText(!m_simulation->getSolver()->getEnableAutoFluidUpdate() ? "AutoMove Stop" : "AutoMove Start");
00738 
00739     m_simulation->getSolver()->toggleEnableAutoFluidUpdate();
00740     m_simulation->updateFPSTimer();
00741 
00742     m_simulation->updateGL();
00743 }
00744 
00745 void MainApp::on_cmd_flushCache_clicked()
00746 {
00747     m_simulation->flushCache();
00748 }
00749 
00750 void MainApp::on_cmd_injectParticle_clicked()
00751 {
00752     m_simulation->getSolver()->injectParticles();
00753 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator