void QViPhyManager::updateObjects() { loadSimulation(); loadRenderer(); _objects.unite(_newObjects); _newObjects.clear(); }
void QViPhyManager::setupSimulation() { switch (_odeSolverEnum) { case ODESolverEnum::LEAPFROG: _simulation->changeODESolver(std::make_unique<Leapfrog>(Leapfrog())); break; case ODESolverEnum::EULER: _simulation->changeODESolver(std::make_unique<Euler>(Euler())); } loadSimulation(); }
void Simulation::run() { int userChoice; while (userChoice = menu.displayMenu(MAIN_MENU)) { switch (userChoice) { case 1: // Run with current options loadSimulation(); runSimulation(); case 2: // View current options displayCurrentOptions(); break; case 3: // Change current options changeOptions(); break; case 4: // Randomize Options randomizeOptions(); break; default: return; } } }
DMMainWindow::DMMainWindow(QWidget * parent) : QMainWindow(parent), ui(new Ui::DMMainWindow) { // qt init Q_INIT_RESOURCE(icons); ui->setupUi(this); this->setParent(parent); // logger init log_updater = new GuiLogSink(); connect(log_updater, SIGNAL(newLogLine(QString)), SLOT(newLogLine(QString)), Qt::QueuedConnection); #if defined DEBUG || _DEBUG DM::Log::init(log_updater,DM::Debug); #else DM::Log::init(log_updater,DM::Standard); #endif // add log export to file QString logfilepath = QDir::tempPath() + "/dynamind" + QDateTime::currentDateTime().toString("_yyMMdd_hhmmss_zzz")+".log"; if(QFile::exists(logfilepath)) QFile::remove(logfilepath); outputFile = new ofstream(logfilepath.toStdString().c_str()); DM::Log::addLogSink(new DM::OStreamLogSink(*outputFile)); DM::Logger() << "logfile: " << logfilepath; // init python env DM::PythonEnv *env = DM::PythonEnv::getInstance(); env->addPythonPath(QApplication::applicationDirPath().toStdString()); env->addOverWriteStdCout(); // init simulation, we only use one instance this->simulation = new GUISimulation(parent, ui->tabWidget_4); simulationThread = NULL; simulationThreadWrapper = NULL; this->simulation->registerModulesFromDefaultLocation(); this->simulation->registerModulesFromSettings(); createModuleListView(); connect( ui->actionRun, SIGNAL( triggered() ), this, SLOT( runSimulation() ), Qt::DirectConnection ); connect( ui->actionPreferences, SIGNAL ( triggered() ), this, SLOT(preferences() ), Qt::DirectConnection ); connect(ui->actionSave, SIGNAL(triggered()), this , SLOT(saveSimulation()), Qt::DirectConnection); connect(ui->actionSaveAs, SIGNAL(triggered()), this , SLOT(saveAsSimulation()), Qt::DirectConnection); connect(ui->actionOpen, SIGNAL(triggered()), this , SLOT(loadSimulation()), Qt::DirectConnection); connect(ui->actionNew, SIGNAL(triggered()), this , SLOT(clearSimulation()), Qt::DirectConnection); connect(ui->actionReload_Modules, SIGNAL(triggered()), this , SLOT(ReloadModules()), Qt::DirectConnection); connect(ui->actionUpdate, SIGNAL(triggered()), this , SLOT(updateSimulation()), Qt::DirectConnection); connect(ui->actionReset, SIGNAL(triggered()), this , SLOT(resetSimulation()), Qt::DirectConnection); connect(ui->actionCancel, SIGNAL(triggered()), this, SLOT(cancelSimulation()), Qt::DirectConnection); connect(ui->actionCancel, SIGNAL(triggered()), this, SLOT(cancelSimulation()), Qt::DirectConnection); connect(ui->actionShow_Help, SIGNAL(triggered()), this, SLOT(showHelp()), Qt::DirectConnection); QStringList args = QCoreApplication::arguments(); if (args.size() == 2) { this->clearSimulation(); this->getSimulation()->currentDocument = args[1]; simulation->loadSimulation(args[1].toStdString()); } ui->actionCancel->setEnabled(false); // load from qsettings QSettings settings; DM::DBConnectorConfig cfg = DM::DBConnector::getInstance()->getConfig(); qulonglong v = settings.value("cacheBlockwritingSize", -1).toULongLong(); if (v != (qulonglong)-1) cfg.cacheBlockwritingSize = v; v = settings.value("queryStackSize", -1).toULongLong(); if (v != (qulonglong)-1) cfg.queryStackSize = v; int i = settings.value("peterDatastream", -1).toInt(); if (i != -1) cfg.peterDatastream = (bool)i; }