void Model::start() { paused_ = false; pauseMutex_.unlock(); if(!thread_) { newSimulation(); thread_ = new boost::thread(boost::ref(*this)); stopThreads_ = false; } }
MainWindow::MainWindow() { // defaults time_ = 0; // create menus in menu bar QMenu * fileMenu = menuBar()->addMenu("&File"); // create tool bars QToolBar * toolbar = addToolBar("toolbar"); QToolBar * toolbarBottom = new QToolBar("bottom toolbar", this); addToolBar(Qt::BottomToolBarArea, toolbarBottom); // new simulation action QAction * newSimulationAction = new QAction("New Simulation", this); newSimulationAction->setStatusTip("New simulation"); connect(newSimulationAction, SIGNAL(triggered()), this, SLOT(newSimulation())); // open data set action /*QAction * openDataSetAction = new QAction("Open Data Set", this); openDataSetAction->setStatusTip("Open data set"); connect(openDataSetAction, SIGNAL(triggered()), this, SLOT(openDataSet()));*/ // new chart action QAction * newChartAction = new QAction("New Chart", this); newChartAction->setStatusTip("New chart"); connect(newChartAction, SIGNAL(triggered()), this, SLOT(newChart())); #if USE_DISPLAYCLUSTER // connect to DisplayCluster action QAction * connectToDisplayClusterAction = new QAction("Connect to DisplayCluster", this); connectToDisplayClusterAction->setStatusTip("Connect to DisplayCluster"); connect(connectToDisplayClusterAction, SIGNAL(triggered()), this, SLOT(connectToDisplayCluster())); // disconnect from DisplayCluster action QAction * disconnectFromDisplayClusterAction = new QAction("Disconnect from DisplayCluster", this); disconnectFromDisplayClusterAction->setStatusTip("Disconnect from DisplayCluster"); connect(disconnectFromDisplayClusterAction, SIGNAL(triggered()), this, SLOT(disconnectFromDisplayCluster())); #endif // add actions to menus fileMenu->addAction(newSimulationAction); // fileMenu->addAction(openDataSetAction); fileMenu->addAction(newChartAction); #if USE_DISPLAYCLUSTER fileMenu->addAction(connectToDisplayClusterAction); fileMenu->addAction(disconnectFromDisplayClusterAction); #endif // add actions to toolbar toolbar->addAction(newSimulationAction); // toolbar->addAction(openDataSetAction); toolbar->addAction(newChartAction); // make map widgets the main view QTabWidget * tabWidget = new QTabWidget(); IliMapWidget * iliMapWidget = new IliMapWidget(); tabWidget->addTab(iliMapWidget, "ILI View"); EpidemicMapWidget * epidemicMapWidget = new EpidemicMapWidget(); tabWidget->addTab(epidemicMapWidget, "Infected"); StockpileMapWidget * antiviralsStockpileMapWidget = new StockpileMapWidget(); antiviralsStockpileMapWidget->setType(STOCKPILE_ANTIVIRALS); tabWidget->addTab(antiviralsStockpileMapWidget, "Antivirals Stockpile"); StockpileMapWidget * vaccinesStockpileMapWidget = new StockpileMapWidget(); vaccinesStockpileMapWidget->setType(STOCKPILE_VACCINES); tabWidget->addTab(vaccinesStockpileMapWidget, "Vaccines Stockpile"); setCentralWidget(tabWidget); // create event monitor and widget EventMonitor * eventMonitor = new EventMonitor(this); QDockWidget * eventMonitorDockWidget = new QDockWidget("Event Monitor", this); eventMonitorDockWidget->setWidget(new EventMonitorWidget(eventMonitor)); addDockWidget(Qt::TopDockWidgetArea, eventMonitorDockWidget); QDockWidget * timelineDockWidget = new QDockWidget("Timeline", this); timelineDockWidget->setWidget(new TimelineWidget(this, eventMonitor)); addDockWidget(Qt::TopDockWidgetArea, timelineDockWidget); // tabify event monitor and timeline widgets tabifyDockWidget(eventMonitorDockWidget, timelineDockWidget); // setup time slider and add it to bottom toolbar with label timeSlider_ = new QSlider(Qt::Horizontal, this); connect(timeSlider_, SIGNAL(valueChanged(int)), this, SLOT(setTime(int))); toolbarBottom->addWidget(new QLabel("Time")); toolbarBottom->addWidget(timeSlider_); // previous timestep button QAction * previousTimestepAction = new QAction(QIcon::fromTheme("media-seek-backward"), "Back", this); previousTimestepAction->setStatusTip(tr("Move backward one day")); connect(previousTimestepAction, SIGNAL(triggered()), this, SLOT(previousTimestep())); toolbarBottom->addAction(previousTimestepAction); // play timesteps button playTimestepsAction_ = new QAction(QIcon::fromTheme("media-seek-play"), "Run", this); playTimestepsAction_->setStatusTip(tr("Run simulation")); playTimestepsAction_->setCheckable(true); connect(playTimestepsAction_, SIGNAL(toggled(bool)), this, SLOT(playTimesteps(bool))); toolbarBottom->addAction(playTimestepsAction_); // next timestep button QAction * nextTimestepAction = new QAction(QIcon::fromTheme("media-seek-forward"), "Forward", this); nextTimestepAction->setStatusTip(tr("Move forward one day")); connect(nextTimestepAction, SIGNAL(triggered()), this, SLOT(nextTimestep())); toolbarBottom->addAction(nextTimestepAction); // parameters dock QDockWidget * parametersDockWidget = new QDockWidget("Parameters", this); parametersDockWidget->setWidget(new ParametersWidget()); addDockWidget(Qt::LeftDockWidgetArea, parametersDockWidget); // initial cases dock initialCasesWidget_ = new EpidemicInitialCasesWidget(this); QDockWidget * initialCasesDockWidget = new QDockWidget("Initial Cases", this); initialCasesDockWidget->setWidget(initialCasesWidget_); addDockWidget(Qt::LeftDockWidgetArea, initialCasesDockWidget); // stockpile network dock QDockWidget * stockpileNetworkDockWidget = new QDockWidget("Stockpile", this); stockpileNetworkDockWidget->setWidget(new StockpileNetworkWidget(this)); addDockWidget(Qt::LeftDockWidgetArea, stockpileNetworkDockWidget); // stockpile consumption dock QDockWidget * stockpileConsumptionDockWidget = new QDockWidget("Stockpile Priorities", this); stockpileConsumptionDockWidget->setWidget(new StockpileConsumptionWidget()); addDockWidget(Qt::LeftDockWidgetArea, stockpileConsumptionDockWidget); // priority group definition dock QDockWidget * priorityGroupDefinitionDockWidget = new QDockWidget("Priority Groups", this); priorityGroupDefinitionDockWidget->setWidget(new PriorityGroupDefinitionWidget()); addDockWidget(Qt::LeftDockWidgetArea, priorityGroupDefinitionDockWidget); // NPI definition dock QDockWidget * npiDefinitionDockWidget = new QDockWidget("NPI", this); npiDefinitionDockWidget->setWidget(new NpiDefinitionWidget(this)); addDockWidget(Qt::LeftDockWidgetArea, npiDefinitionDockWidget); // info dock QDockWidget * infoDockWidget = new QDockWidget("Info", this); infoDockWidget->setWidget(new EpidemicInfoWidget(this)); addDockWidget(Qt::LeftDockWidgetArea, infoDockWidget); // tabify parameters, initial cases, stockpile network, and info docks tabifyDockWidget(parametersDockWidget, initialCasesDockWidget); tabifyDockWidget(parametersDockWidget, stockpileNetworkDockWidget); tabifyDockWidget(parametersDockWidget, stockpileConsumptionDockWidget); tabifyDockWidget(parametersDockWidget, priorityGroupDefinitionDockWidget); tabifyDockWidget(parametersDockWidget, npiDefinitionDockWidget); tabifyDockWidget(parametersDockWidget, infoDockWidget); // chart docks // an epidemic chart QDockWidget * chartDockWidget = new QDockWidget("Chart", this); chartDockWidget->setWidget(new EpidemicChartWidget(this)); addDockWidget(Qt::BottomDockWidgetArea, chartDockWidget); // and a stockpile chart chartDockWidget = new QDockWidget("Chart", this); chartDockWidget->setWidget(new StockpileChartWidget(this)); addDockWidget(Qt::BottomDockWidgetArea, chartDockWidget); // make other signal / slot connections connect(this, SIGNAL(dataSetChanged(boost::shared_ptr<EpidemicDataSet>)), iliMapWidget, SLOT(setDataSet(boost::shared_ptr<EpidemicDataSet>))); connect(this, SIGNAL(dataSetChanged(boost::shared_ptr<EpidemicDataSet>)), epidemicMapWidget, SLOT(setDataSet(boost::shared_ptr<EpidemicDataSet>))); connect(this, SIGNAL(dataSetChanged(boost::shared_ptr<EpidemicDataSet>)), antiviralsStockpileMapWidget, SLOT(setDataSet(boost::shared_ptr<EpidemicDataSet>))); connect(this, SIGNAL(dataSetChanged(boost::shared_ptr<EpidemicDataSet>)), vaccinesStockpileMapWidget, SLOT(setDataSet(boost::shared_ptr<EpidemicDataSet>))); connect(this, SIGNAL(dataSetChanged()), this, SLOT(resetTimeSlider())); connect(this, SIGNAL(numberOfTimestepsChanged()), this, SLOT(resetTimeSlider())); connect(this, SIGNAL(timeChanged(int)), iliMapWidget, SLOT(setTime(int))); connect(this, SIGNAL(timeChanged(int)), epidemicMapWidget, SLOT(setTime(int))); connect(this, SIGNAL(timeChanged(int)), antiviralsStockpileMapWidget, SLOT(setTime(int))); connect(this, SIGNAL(timeChanged(int)), vaccinesStockpileMapWidget, SLOT(setTime(int))); connect(&playTimestepsTimer_, SIGNAL(timeout()), this, SLOT(playTimesteps())); // show the window show(); }