MainWindow::MainWindow() { loadMapAction = new QAction( tr("Load Map"), this ); startSimAction = new QAction( tr("Start Simulation"), this ); stopSimAction = new QAction( tr("Stop Simulation"), this ); exitAction = new QAction( tr("Exit"), this ); aboutAction = new QAction( tr("About"), this ); connect( loadMapAction, SIGNAL(triggered()), this, SLOT(loadMap()) ); connect( startSimAction, SIGNAL(triggered()), this, SLOT(startSimulation()) ); connect( stopSimAction, SIGNAL(triggered()), this, SLOT(stopSimulation()) ); connect( exitAction, SIGNAL(triggered()), this, SLOT(exit()) ); connect( aboutAction, SIGNAL(triggered()), this, SLOT(about()) ); topMenu = menuBar()->addMenu( tr("File") ); topMenu->addAction( loadMapAction ); topMenu->addSeparator(); topMenu->addAction( startSimAction ); topMenu->addAction( stopSimAction ); topMenu->addSeparator(); topMenu->addAction( exitAction ); customiseMapAction = new QAction( tr("Customise Map"), this ); connect( customiseMapAction, SIGNAL(triggered()), this, SLOT(customiseMap()) ); topMenu = menuBar()->addMenu( tr("Options") ); topMenu->addAction( customiseMapAction ); topMenu = menuBar()->addMenu( tr("Help") ); topMenu->addAction( aboutAction ); showMaximized(); drawMain = new DrawWidgetMW(); setCentralWidget( drawMain ); simthread = new QThread(); simwrk = new SimulationWorker( drawMain ); simwrk->moveToThread( simthread ); statusBar(); statusBar()->addPermanentWidget( &scaleLabel ); connect( simthread, SIGNAL(started()), simwrk, SLOT(startModeling()) ); connect( simwrk, SIGNAL(finished()), simthread, SLOT(quit()) ); connect( drawMain, SIGNAL( sendScale( int ) ), this, SLOT( showScale( const int ) ) ); setWindowTitle( tr("Water Movement Simulation Tool") ); }
SimMainWindow::SimMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::SimMainWindow) { ui->setupUi(this); mEngine = new LifeEngine(100,100); mView = new LifeEngineView(mEngine); mLifeFileView = new LifeFileView; mLifesView = new LifesView(mEngine); mUndoStack = new QUndoStack(this); mOldLifeCount = 0; ui->dock1->setWidget(mLifeFileView); ui->dock2->setWidget(mLifesView); ui->dock1->setWindowTitle(mLifeFileView->windowTitle()); ui->dock2->setWindowTitle(mLifesView->windowTitle()); setCentralWidget(mView); ui->menuEdit->addActions(mLifeFileView->actions()); ui->menuEdit->addSeparator(); ui->menuEdit->addActions(mLifesView->actions()); connect(mView->gridView()->grid(),SIGNAL(squareClicked(QPoint)),this,SLOT(clicked(QPoint))); connect(ui->actionRun,SIGNAL(triggered()),this,SLOT(startSimulation())); connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(newSim())); connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(saveSim())); connect(ui->actionSaveAs,SIGNAL(triggered()),this,SLOT(saveAsSim())); connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(openSim())); connect(ui->actionClear,SIGNAL(triggered()),this,SLOT(clear())); connect(ui->actionAnimator,SIGNAL(triggered()),this,SLOT(showAnimator())); connect(ui->actionLifeEditor,SIGNAL(triggered()),this,SLOT(showLifeEditor())); connect(mLifesView,SIGNAL(changed()),this,SLOT(refresh())); connect(mLifesView,SIGNAL(clicked()),this,SLOT(setGridSelection())); connect(ui->actionAboutQt,SIGNAL(triggered()),this,SLOT(showAboutQt())); connect(ui->actionAbout,SIGNAL(triggered()),this,SLOT(showAbout())); connect(ui->actionUndo,SIGNAL(triggered()),mUndoStack,SLOT(undo())); connect(ui->actionRedo,SIGNAL(triggered()),mUndoStack,SLOT(redo())); connect(mUndoStack,SIGNAL(canUndoChanged(bool)),ui->actionUndo,SLOT(setEnabled(bool))); connect(mUndoStack,SIGNAL(canRedoChanged(bool)),ui->actionRedo,SLOT(setEnabled(bool))); ui->actionSave->setEnabled(false); newSim(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); newDebug = NULL; newAgent = NULL; newEnvironment = NULL; newBeep = NULL; started = false; paused = false; scene = new QGraphicsScene(this); ui->graphicsView->setScene(scene); setCentralWidget(ui->graphicsView); //automatically trigger updates for now timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(timeToStep())); timer->start(10); //connect menus to their corresponding slots connect(ui->actionStep,SIGNAL(triggered()),this,SLOT(timeToStep())); connect(ui->actionAgent_2, SIGNAL(triggered()), this, SLOT(createNewAgentWindow())); connect(ui->actionAdd_Environment, SIGNAL(triggered()), this, SLOT(createNewEnvironmentWindow())); connect(ui->actionStart, SIGNAL(triggered()), this, SLOT(startSimulation())); connect(ui->actionCreate_New_Beep, SIGNAL(triggered()), this, SLOT(createNewBeepTypeWindow())); connect(ui->actionPause, SIGNAL(triggered()), this, SLOT(pauseSimulation())); connect(ui->actionContinue, SIGNAL(triggered()), this, SLOT(unPauseSimulation())); /*for(int i = 5; i < 26; i++) for(int j = 15; j < 26; j++) pointTemps.push_back(std::make_pair (std::make_pair (i,j), 100));*/ /*QGraphicsEllipseItem *tempEllipse = new QGraphicsEllipseItem(); for(unsigned i = 0; i < 2; i++){ Robot tempRobot = Robot(); tempRobot.setBody(tempEllipse); robots.push_back(tempRobot); } for(unsigned i = 0; i<robots.size(); i++){ robots[i].updateDrawPosition(scene); }*/ reDraw(); }
void Dialog::createInitialPopulationForm() { form_group_box = new QGroupBox(tr("Initial Populations (millions):")); QFormLayout *layout = new QFormLayout; for(int i = 0; i < NumberofSpecies; i++) { input_labels[i] = new QLabel(tr("Species %1 : ").arg(i + 1)); line_edits[i] = new QLineEdit; line_edits[i]->setValidator(new QIntValidator); layout->addRow(input_labels[i], line_edits[i]); } start_sim = new QPushButton("Start Simulation"); connect(start_sim, SIGNAL(clicked()), this, SLOT(startSimulation())); layout->addWidget(start_sim); form_group_box->setLayout(layout); }
FormSimulator::FormSimulator(FormMain* parent) : QDialog(parent), m_ui(new Ui::FormSimulator), m_mainWindow(parent), m_isActive(false), m_activeSimulation(NULL) { m_ui->setupUi(this); // Load some needed settings. m_isVisibleOnStartup = qApp->settings()->value(APP_CFG_SIMULATOR, "visible_on_startup", false).toBool(); m_isSticked = qApp->settings()->value(APP_CFG_SIMULATOR, "is_sticked", false).toBool(); // Do necessary initializations. setupIcons(); setupPhoneWidget(); connect(parent, SIGNAL(moved()), this, SLOT(conditionallyAttachToParent())); connect(parent, SIGNAL(resized()), this, SLOT(conditionallyAttachToParent())); connect(m_ui->m_btnRunSimulation, SIGNAL(clicked()), this, SLOT(startSimulation())); connect(m_ui->m_btnStopSimulation, SIGNAL(clicked()), this, SLOT(stopSimulation())); connect(m_ui->m_btnGoBack, SIGNAL(clicked()), this, SLOT(goBack())); connect(this, SIGNAL(stopEnableChanged(bool)), m_ui->m_btnStopSimulation, SLOT(setEnabled(bool))); // This window mustn't be deleted when closed by user. setAttribute(Qt::WA_DeleteOnClose, false); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); }
void FormMain::createConnections() { // General connections. connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit())); connect(m_ui->m_actionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(m_ui->m_actionCheckForUpdates, SIGNAL(triggered()), this, SLOT(showUpdates())); connect(m_ui->m_actionAboutToolkit, SIGNAL(triggered()), this, SLOT(showAbout())); connect(m_ui->m_actionSettings, SIGNAL(triggered()), this, SLOT(showSettings())); connect(m_ui->m_actionHelp, SIGNAL(triggered()), this, SLOT(showHelp())); // View connections. connect(m_ui->m_actionViewSimulatorWindow, SIGNAL(toggled(bool)), this, SLOT(switchSimulatorWindow(bool))); connect(m_ui->m_actionStickSimulatorWindow, SIGNAL(toggled(bool)), m_simulatorWindow, SLOT(setIsSticked(bool))); // Extra simulator connections. connect(m_simulatorWindow, SIGNAL(closed()), this, SLOT(onSimulatorWindowClosed())); connect(m_simulatorWindow, SIGNAL(stopEnableChanged(bool)), m_ui->m_actionSimulatorStop, SLOT(setEnabled(bool))); connect(m_ui->m_actionSimulatorStop, SIGNAL(triggered()), m_simulatorWindow->m_ui->m_btnStopSimulation, SLOT(click())); connect(m_ui->m_actionSimulatorRun, SIGNAL(triggered()), this, SLOT(startSimulation())); connect(m_ui->m_actionSimulatorGoBack, SIGNAL(triggered()), this, SLOT(takeSimulationOneStepBack())); // Project connections. connect(m_ui->m_actionNewProject, SIGNAL(triggered()), this ,SLOT(openNewProjectDialog())); connect(m_ui->m_actionSaveProject, SIGNAL(triggered()), this ,SLOT(openSaveProjectDialog())); connect(m_ui->m_actionSaveProjectAs, SIGNAL(triggered()), this, SLOT(openSaveProjectAsDialog())); connect(m_ui->m_actionLoadProject, SIGNAL(triggered()), this ,SLOT(openLoadProjectDialog())); connect(m_ui->m_actionOpenOutputDirectory, SIGNAL(triggered()), this, SLOT(openOutputDirectory())); // Template system connections. connect(qApp->templateManager(), SIGNAL(newTemplateCoreCreated(TemplateCore*)), this, SLOT(setTemplateCore(TemplateCore*))); connect(qApp, SIGNAL(externalApplicationsRechecked()), this, SLOT(onExternalApplicationsChanged())); connect(m_ui->m_actionGenerateMobileApplication, SIGNAL(triggered()), this, SLOT(generateMobileApplication())); connect(m_ui->m_actionUploadApplicationToStore, SIGNAL(triggered()), this, SLOT(uploadMobileApplicationToStore())); connect(qApp->templateManager()->generator(), SIGNAL(generationStarted()), this, SLOT(onGenerationStarted())); connect(qApp->templateManager()->generator(), SIGNAL(generationFinished(TemplateCore::GenerationResult,QString)), this, SLOT(onGenerationDone(TemplateCore::GenerationResult,QString))); connect(qApp->templateManager()->generator(), SIGNAL(generationProgress(int,QString)), this, SLOT(onGenerationProgress(int,QString))); }
void MainWindow::Toolbar() { QPixmap openIcon((const char**) open_xpm); QPixmap redoIcon((const char**) redo_xpm); QPixmap simulateIcon((const char**) simulate_xpm); QPixmap stopIcon((const char**) stop_xpm); QPixmap cameraIcon((const char**) camera_xpm); QPixmap filmIcon((const char**) film_xpm); QPixmap frontViewIcon((const char**) frontView_xpm); QPixmap topViewIcon((const char**) topView_xpm); QPixmap rightSideViewIcon((const char**) rightSideView_xpm); toolbar = addToolBar("main toolbar"); QAction *open = toolbar->addAction(QIcon(openIcon), "Open Scene (Ctrl + O)"); QAction *redo = toolbar->addAction(QIcon(redoIcon), "Load last viewed scene (Ctrl + Shift + Q)"); toolbar->addSeparator(); QAction *simulate = toolbar->addAction(QIcon(simulateIcon), "Start Simulation (Ctrl + R"); QAction *stop = toolbar->addAction(QIcon(stopIcon), "Stop Simulation (Ctrl + C"); stop->setVisible(false); toolbar->addSeparator(); QAction *camera = toolbar->addAction(QIcon(cameraIcon), "Export screenshot"); QAction *film = toolbar->addAction(QIcon(filmIcon), "Export film sequence"); toolbar->addSeparator(); QAction *front = toolbar->addAction(QIcon(frontViewIcon), "View scene from front"); QAction *top = toolbar->addAction(QIcon(topViewIcon), "View scene from top"); QAction *rightSide = toolbar->addAction(QIcon(rightSideViewIcon), "View scene from right"); connect(open, SIGNAL(triggered()), this, SLOT(loadScene())); connect(redo, SIGNAL(triggered()), this, SLOT(quickLoad())); connect(simulate, SIGNAL(triggered()), this, SLOT(startSimulation())); connect(stop, SIGNAL(triggered()), this, SLOT(stopSimulation())); connect(camera, SIGNAL(triggered()), this, SLOT(camera())); connect(film, SIGNAL(triggered()), this, SLOT(film())); connect(front, SIGNAL(triggered()), this, SLOT(front())); connect(top, SIGNAL(triggered()), this, SLOT(top())); connect(rightSide, SIGNAL(triggered()), this, SLOT(side())); }
void MdiChild::simulate() { if (ui->modelsList->currentRow() >= 1) { startSimulation(this, radioData, ui->modelsList->currentRow()-1); } }
void MdiChild::on_SimulateTxButton_clicked() { startSimulation(this, radioData, -1); }
void AtsMainWindow::startSimulationActionTriggered() { startSimulation(); }
void Mediator::handleCommand(int index){ int fd = socketManager->getConnectedFD(index); char messageIN[BUFFER_SIZE]; int rd = ioStream->readLine(fd, messageIN, BUFFER_SIZE); if (rd > 0){ cout << "[From Command...]\t" << messageIN << flush; char* command = strtok(messageIN, "|"); if (strcmp(command,"init") ==0){ char* ip = strtok(NULL, "|\n"); int cmd_port = atoi(strtok(NULL, "|\n")); int data_port = atoi(strtok(NULL, "|\n")); int time_port = atoi(strtok(NULL, "|\n")); int info_port = atoi(strtok(NULL, "|\n")); initClient(ip, fd, cmd_port, data_port, time_port, info_port); } else if (strcmp(command,"putfile") ==0){ long fileSize = 0; char* filename = strtok(NULL, "|"); sscanf(strtok(NULL, "|\n"), "%d", &fileSize); int data_fd = clientList.getActiveClient()->data_fd; putfile(filename, fileSize, fd, data_fd); } else if (strcmp(command,"startSimulation") == 0){ char* command = strtok(NULL, "|\n"); int timePort; sscanf(strtok(NULL, "|\n"), "%d", &timePort); startSimulation(command, false); } else if (strcmp(command,"pauseSimulation") == 0){ pauseSimulation(strtok(NULL, "|\n")); } else if (strcmp(command,"stopSimulation") == 0){ stopSimulation(strtok(NULL, "|\n")); } else if (strcmp(command,"resumeSimulation") == 0){ resumeSimulation(strtok(NULL, "|\n")); } else if (strcmp(command,"abortSimulation") == 0){ abortSimulation(); } else if (strcmp(command, "getResults\n") == 0){ getResults(); } /* else if (strcmp(command, "getFileList\n") == 0){ getFileList(); } */ else if (strcmp(command, "getFile") == 0){ getFile(strtok(NULL, "|\n")); } else if (strcmp(command, "reconnect") == 0){ reconnect(strtok(NULL, "\n"), fd); } else if (strcmp(command, "sendtoSE") == 0){ sendtoSE("From GUI : ", strtok(NULL, "|")); } else if (strcmp(command, "console") == 0){ commandConsole(strtok(NULL, "\n"), fd); } else if (strcmp(command, "init_remote") == 0){ initRemote(strtok(NULL, "\n"), fd); } else cout << "else??\n" << flush; } else{ if (currentSession == 0){ abortSimulation(); }else{ closeClient(); } } }
void FormMain::startSimulation() { showSimulator(); QTimer::singleShot(0, m_simulatorWindow, SLOT(startSimulation())); }
void MdiChild::simulate() { if (getCurrentRow() > 0) { startSimulation(this, radioData, getCurrentRow()-1); } }
void MainWindow::createActions() { //loadAct loadSceneAct = new QAction(tr("&Load Scene"), this); loadSceneAct->setShortcut(Qt::CTRL + Qt::Key_O); loadSceneAct->setStatusTip(tr("Load scene")); connect(loadSceneAct, SIGNAL(triggered()), this, SLOT(loadScene())); //quickLoadAct quickLoadAct = new QAction(tr("&Quick Load"), this); quickLoadAct->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_Q); quickLoadAct->setStatusTip(tr("Load last scene")); connect(quickLoadAct, SIGNAL(triggered()), this, SLOT(quickLoad())); //saveSceneAct saveSceneAct = new QAction(tr("&Save Scene"), this); saveSceneAct->setShortcut(Qt::CTRL + Qt::Key_S); saveSceneAct->setStatusTip(tr("Save Scene")); connect(saveSceneAct, SIGNAL(triggered()), this, SLOT(saveScene())); loadPluginFileAct = new QAction(tr("&Load Plugin"), this); loadPluginFileAct->setShortcut(Qt::CTRL + Qt::Key_L); loadPluginFileAct->setStatusTip(tr("Load plugin file")); connect(loadPluginFileAct, SIGNAL(triggered()), this, SLOT(loadPluginFileWithDialog())); loadPluginDirAct = new QAction(tr("&Load Plugin Directory"), this); loadPluginDirAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_L); loadPluginDirAct->setStatusTip(tr("Load all plugins in directory")); connect(loadPluginDirAct, SIGNAL(triggered()), this, SLOT(loadPluginDirWithDialog())); /// save workspace configuration action saveWorkspaceConfigurationAct = new QAction(tr("Save Workspace"), this); saveWorkspaceConfigurationAct->setStatusTip(tr("Save the configuration of the workspace")); connect(saveWorkspaceConfigurationAct, SIGNAL(triggered()), this, SLOT(saveWorkspace())); /// save new workspace configuration action saveNewWorkspaceConfigurationAct = new QAction(tr("Save Workspace As..."), this); saveNewWorkspaceConfigurationAct->setStatusTip(tr("Save a new workspace configuration")); connect(saveNewWorkspaceConfigurationAct, SIGNAL(triggered()), this, SLOT(saveNewWorkspace())); /// load workspace configuration action loadWorkspaceConfigurationAct = new QAction(tr("Load Workspace"), this); loadWorkspaceConfigurationAct->setStatusTip(tr("Load a workspace configuration")); connect(loadWorkspaceConfigurationAct, SIGNAL(triggered()), this, SLOT(loadWorkspace())); //closeAct closeSceneAct = new QAction(tr("&Close"), this); closeSceneAct->setShortcut(Qt::CTRL + Qt::Key_W); closeSceneAct->setStatusTip(tr("Close Scene")); connect(closeSceneAct, SIGNAL(triggered()), this, SLOT(close())); //exitAct exitAct = new QAction(tr("&Exit"), this); exitAct->setShortcuts(QKeySequence::Quit); exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, SIGNAL(triggered()), this, SLOT(exit())); //frontAct frontAct = new QAction(tr("Front"), this); frontAct->setStatusTip(tr("Camera Front View")); connect(frontAct, SIGNAL(triggered()), this, SLOT(front())); //topAct topAct = new QAction(tr("Top"), this); topAct->setStatusTip(tr("Camera Top View")); connect(topAct, SIGNAL(triggered()), this, SLOT(top())); //sideAct sideAct = new QAction(tr("Side"), this); sideAct->setStatusTip(tr("Camera Side View")); connect(sideAct, SIGNAL(triggered()), this, SLOT(side())); //startSimulationAct startSimulationAct = new QAction(tr("Start Simulation"), this); startSimulationAct->setShortcut(Qt::CTRL + Qt::Key_R); connect(startSimulationAct, SIGNAL(triggered()), this, SLOT(startSimulation())); //stopSimulationAct stopSimulationAct = new QAction(tr("Stop Simulation"), this); stopSimulationAct->setShortcut(Qt::CTRL + Qt::Key_C); connect(stopSimulationAct, SIGNAL(triggered()), this, SLOT(stopSimulation())); //simulateSingleStepAct simulateSingleStepAct = new QAction(tr("Simulate Single Step"), this); simulateSingleStepAct->setStatusTip(tr("Simulates one step at a time")); simulateSingleStepAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_R); connect(simulateSingleStepAct, SIGNAL(triggered()), this, SLOT(simulateSingleStep())); //renderDuringSimulationAct renderDuringSimulationAct = new QAction(tr("Render during Simulation"), this); connect(renderDuringSimulationAct, SIGNAL(triggered()), this, SLOT(renderDuringSimulation())); //whiteAct whiteAct = new QAction(tr("White"), this); connect(whiteAct, SIGNAL(triggered()), this, SLOT(white())); //grayAct grayAct = new QAction(tr("Gray"), this); connect(grayAct, SIGNAL(triggered()), this, SLOT(gray())); //BlackAct blackAct = new QAction(tr("Black"), this); connect(blackAct, SIGNAL(triggered()), this, SLOT(black())); //resetCameraAct resetCameraAct = new QAction(tr("Reset Camera"), this); resetCameraAct->setStatusTip(tr("Reset Camera Angle")); connect(resetCameraAct, SIGNAL(triggered()), this, SLOT(resetCamera())); //xga1024x768Act xga1024x768Act = new QAction(tr("XGA 1024 x 768"), this); xga1024x768Act->setCheckable(true); xga1024x768Act->setChecked(true); connect(xga1024x768Act, SIGNAL(triggered()), this, SLOT(xga1024x768())); //vga640x480Act vga640x480Act = new QAction(tr("VGA 640 x 768"), this); vga640x480Act->setCheckable(true); connect(vga640x480Act, SIGNAL(triggered()), this, SLOT(vga640x480())); //hd1280x720Act hd1280x720Act = new QAction(tr("HD 1280 x 720"), this); hd1280x720Act->setCheckable(true); connect(hd1280x720Act, SIGNAL(triggered()), this, SLOT(hd1280x720())); //aboutAct aboutAct = new QAction(tr("About"), this); aboutAct->setShortcut(Qt::Key_F1); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); }