void MainWindow::initComputation(void) { deleteComputation(); thread1 = new QThread(); ct = new ComputationWorker(); // Make the computations in a seperate thread to avoid GUI blocking ct->moveToThread(thread1); connect(thread1, &QThread::started, ct, &ComputationWorker::doWork); // Load satellite position and camera server url from settings ct->camUrl = settings.value("capture/camUrl", "http://127.0.0.1:3000").value<QString>(); ct->rectX = settings.value("satellite/rect_x", 0).toInt(); ct->rectY = settings.value("satellite/rect_y", 0).toInt(); ct->rectR = settings.value("satellite/rect_r", 0).toInt(); // Connect the computationRunningStateChanged signal to inform the GUI // about changes and errors in the computation worker connect(ct, SIGNAL(computeRunningStateChanged(bool)), this, SLOT(computeRunningState(bool))); // Connect the slots of various results produced in the computation worker // with the GUI functions that display them accordingly connect(ct, SIGNAL(dimensionsChanged(int,int)), this, SLOT(dimensionsChanged(int,int))); connect(ct, SIGNAL(statusMessage(QString)), this, SLOT(computationStatusMessage(QString))); connect(ct, SIGNAL(cameraImageReady(QImage)), this, SLOT(cameraImageReceived(QImage))); connect(ct, SIGNAL(magnitudeSpectrumReady(QImage)), this, SLOT(magnitudeSpectrumReceived(QImage))); connect(ct, SIGNAL(phaseAngleReady(QImage)), this, SLOT(phaseAngleReceived(QImage))); thread1->start(); }
/** * The Settings-Button was pressed. Stop the computation, display the settings * dialog. The user might adjust the crop region that the ComputationWorker processes * or the URL of the camera server might change, so we need to reinitiate the * ComputationWorker afterwards, to ensure the new settings are used accordingly. */ void MainWindow::actionSettingsPressed(bool) { deleteComputation(); SettingsDialog d(this); d.exec(); initComputation(); }
void ConfigStat::compute() { deleteComputation(); initComputation(); computeDistanceMatrix(); computeCenter(); computeCentroid(); computeBetweennessCenter(); }
void MainWindow::computeButtonPressed() { // Toggle button state if(!computeButtonRunning) { // Button displays start, should start ct qDebug() << "Requested ct start"; initComputation(); } else { // Button displays stop, should stop ct qDebug() << "Requested ct stop"; deleteComputation(); } }
MainWindow::~MainWindow() { qDebug() << "Ending main window"; qDebug() << settings.value("satellite/rect_x", QVariant::Int); settings.setValue("satellite/rect_x", ct->rectX); settings.setValue("satellite/rect_y", ct->rectY); settings.setValue("satellite/rect_r", ct->rectR); settings.sync(); qDebug() << "Settings written"; deleteComputation(); if(threedEnabled) delete threedViewer; delete ui; }
ConfigStat::~ConfigStat() { deleteComputation(); }