From 252e924f927457ca996fb4821664ca0bde3cd9ed Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 27 Mar 2018 17:49:01 +0200 Subject: [PATCH] separated start gui button into start and stop to prevent multiple click syndrome --- slsDetectorGui/forms/form_tab_measurement.ui | 139 ++++++++++++++----- slsDetectorGui/gitInfo.txt | 8 +- slsDetectorGui/include/gitInfoGui.h | 6 +- slsDetectorGui/include/qDrawPlot.h | 1 - slsDetectorGui/include/qTabMeasurement.h | 20 ++- slsDetectorGui/src/qDetectorMain.cpp | 1 - slsDetectorGui/src/qDrawPlot.cpp | 1 - slsDetectorGui/src/qTabMeasurement.cpp | 102 +++++--------- 8 files changed, 153 insertions(+), 125 deletions(-) diff --git a/slsDetectorGui/forms/form_tab_measurement.ui b/slsDetectorGui/forms/form_tab_measurement.ui index 4b325f5b0..f4ce14964 100644 --- a/slsDetectorGui/forms/form_tab_measurement.ui +++ b/slsDetectorGui/forms/form_tab_measurement.ui @@ -133,44 +133,6 @@ - - - - 30 - 289 - 319 - 31 - - - - - 0 - 0 - - - - Qt::NoFocus - - - Starts or Stops Acquisition - - - Start - - - - :/icons/images/start.png:/icons/images/start.png - - - Shift+Space - - - true - - - false - - @@ -999,6 +961,107 @@ Frame period between exposures. + + + + 30 + 297 + 318 + 30 + + + + + + + + 0 + 0 + + + + Qt::NoFocus + + + Starts Acquisition + + + Start + + + + :/icons/images/start.png:/icons/images/start.png + + + Shift+Space + + + false + + + false + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + true + + + + 0 + 0 + + + + + 70 + 16777215 + + + + Qt::NoFocus + + + Stops Acquisition + + + Stop + + + + :/icons/images/stop.png:/icons/images/stop.png + + + Shift+Space + + + false + + + false + + + + + spinNumMeasurements diff --git a/slsDetectorGui/gitInfo.txt b/slsDetectorGui/gitInfo.txt index 18233bfd2..df5e478bd 100644 --- a/slsDetectorGui/gitInfo.txt +++ b/slsDetectorGui/gitInfo.txt @@ -1,9 +1,9 @@ Path: slsDetectorsPackage/slsDetectorGui URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: b8bdbf4da61f95b88893b02ddabc2491b16fa10f -Revision: 492 +Repsitory UUID: fe2ba8621b33bc00f51c8cd4d33e98b7d4ebfa41 +Revision: 493 Branch: developer Last Changed Author: Dhanya_Thattil -Last Changed Rev: 3746 -Last Changed Date: 2018-03-26 17:27:44.000000002 +0200 ./src/qTabSettings.cpp +Last Changed Rev: 3747 +Last Changed Date: 2018-03-27 17:30:53.000000002 +0200 ./include/qTabMeasurement.h diff --git a/slsDetectorGui/include/gitInfoGui.h b/slsDetectorGui/include/gitInfoGui.h index 9dac684be..bd01362fb 100644 --- a/slsDetectorGui/include/gitInfoGui.h +++ b/slsDetectorGui/include/gitInfoGui.h @@ -1,6 +1,6 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "b8bdbf4da61f95b88893b02ddabc2491b16fa10f" +#define GITREPUUID "fe2ba8621b33bc00f51c8cd4d33e98b7d4ebfa41" #define GITAUTH "Dhanya_Thattil" -#define GITREV 0x3746 -#define GITDATE 0x20180326 +#define GITREV 0x3747 +#define GITDATE 0x20180327 #define GITBRANCH "developer" diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index 63f9e5b07..54a4a2542 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -617,7 +617,6 @@ void saveErrorSignal(QString); void AcquisitionErrorSignal(QString); void UpdatePlotSignal(); void GainPlotSignal(bool); -void AcquisitionFinishedSignal(); }; diff --git a/slsDetectorGui/include/qTabMeasurement.h b/slsDetectorGui/include/qTabMeasurement.h index 8b925a343..362fba590 100644 --- a/slsDetectorGui/include/qTabMeasurement.h +++ b/slsDetectorGui/include/qTabMeasurement.h @@ -50,14 +50,14 @@ public: */ void SetExpertMode(bool enable); - /** Returns the status of the Start/Stop Acquisition button + /** Returns the status of the acquisition in gui */ - bool GetStartStatus(){return btnStartStop->isChecked();}; + bool GetStartStatus(){return (!btnStart->isEnabled());}; /** Click the Start/Stop Acquisition button * This is used if this command came from gui client */ - void ClickStartStop(){btnStartStop->click();myPlot->SetClientInitiated();}; + void ClickStartStop(){startAcquisition();myPlot->SetClientInitiated();}; /** Returns progress bar value */ int GetProgress(){return progressBar->value();}; @@ -65,10 +65,6 @@ public: public slots: - /** Unconnects start/stop button when acquisition is finished - */ - void AcquisitionFinished(); - /** update plot is finished, * changes start/stop text and enables/disables all widgets */ @@ -131,9 +127,13 @@ private slots: */ void setRunIndex(int index); - /** starts/stops Acquisition + /** starts Acquisition */ - void startStopAcquisition(); + void startAcquisition(); + + /** stops Acquisition + */ + void stopAcquisition(); /** Set number of frames * @param val number of frames to be set @@ -193,8 +193,6 @@ private: QPalette red; /** expert mode */ bool expertMode; - QIcon *iconStart; - QIcon *iconStop; /** to access items in settings combobox */ QStandardItemModel* model; diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index 763b32afe..766dac696 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -336,7 +336,6 @@ void qDetectorMain::Initialization(){ // Plotting // When the acquisition is finished, must update the meas tab connect(myPlot, SIGNAL(UpdatingPlotFinished()), this, SLOT(EnableTabs())); - connect(myPlot, SIGNAL(AcquisitionFinishedSignal()), tab_measurement, SLOT(AcquisitionFinished())); connect(myPlot, SIGNAL(UpdatingPlotFinished()), tab_measurement, SLOT(UpdateFinished())); //This should not be called as it will change file name to measurement when run finished //connect(myPlot, SIGNAL(UpdatingPlotFinished()), tab_plot, SLOT(Refresh())); diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 7385097fb..6ad3e2ec8 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -1296,7 +1296,6 @@ int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus){ #ifdef VERBOSE cout << "\nEntering Acquisition Finished with status " ; #endif - emit AcquisitionFinishedSignal(); QString status = QString(slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str()); #ifdef VERBOSE cout << status.toAscii().constData() << " and progress " << currentProgress << endl; diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index b6e28ce0e..fa246e84a 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -94,12 +94,6 @@ void qTabMeasurement::SetupWidgetWindow(){ chkFile->setChecked(myDet->enableWriteToFile()); dispFileName->setEnabled(myDet->enableWriteToFile()); - - //creating the icons for the buttons - iconStart = new QIcon(":/icons/images/start.png"); - iconStop = new QIcon(":/icons/images/stop.png"); - - //Timer to update the progress bar progressTimer = new QTimer(this); @@ -267,8 +261,10 @@ void qTabMeasurement::Initialization(){ connect(dispFileName, SIGNAL(editingFinished()),this, SLOT(setFileName())); //File Index connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - //Start/Stop Acquisition - connect(btnStartStop, SIGNAL(clicked()), this, SLOT(startStopAcquisition())); + //Start Acquisition + connect(btnStart, SIGNAL(clicked()), this, SLOT(startAcquisition())); + //Stop Acquisition + connect(btnStop, SIGNAL(clicked()), this, SLOT(stopAcquisition())); //Timing Mode connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int)));// //progress bar @@ -309,75 +305,53 @@ void qTabMeasurement::Enable(bool enable){ frameNotTimeResolved->setEnabled(enable); //shortcut each time, else it doesnt work a second time - btnStartStop->setShortcut(QApplication::translate("TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8)); + btnStart->setShortcut(QApplication::translate("TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8)); } //------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabMeasurement::startStopAcquisition(){ - if(btnStartStop->isChecked()){ - - //if file write enabled and output dir doesnt exist - if((chkFile->isChecked())&&(thisParent->DoesOutputDirExist() == slsDetectorDefs::FAIL)){ - if(qDefs::Message(qDefs::QUESTION, - "Your data will not be saved.
Disable File write and Proceed with acquisition anyway?", - "qTabMeasurement::startStopAcquisition") == slsDetectorDefs::FAIL){ - disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); - btnStartStop->click(); - connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); - return; - }else{ - //done because for receiver it cant save a file with blank file path and returns without acquiring even to the gui - disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); - chkFile->setChecked(false); - EnableFileWrite(false); - connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); - } - } +void qTabMeasurement::startAcquisition(){ + btnStart->setEnabled(false); + //if file write enabled and output dir doesnt exist + if((chkFile->isChecked())&&(thisParent->DoesOutputDirExist() == slsDetectorDefs::FAIL)){ + if(qDefs::Message(qDefs::QUESTION, + "Your data will not be saved.
Disable File write and Proceed with acquisition anyway?", + "qTabMeasurement::startAcquisition") == slsDetectorDefs::FAIL){ + btnStart->setEnabled(true); + return; + }else{ + //done because for receiver it cant save a file with blank file path and returns without acquiring even to the gui + disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); + chkFile->setChecked(false); + EnableFileWrite(false); + connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); + } + } #ifdef VERBOSE - cout << endl << endl << "Starting Acquisition" << endl; + cout << endl << endl << "Starting Acquisition" << endl; #endif - //btnStartStop->setStyleSheet("color:red"); - btnStartStop->setText("Stop"); - btnStartStop->setIcon(*iconStop); - lblProgressIndex->setText(QString::number(0)); - Enable(0); - progressBar->setValue(0); - progressTimer->start(100); + lblProgressIndex->setText(QString::number(0)); + Enable(0); + progressBar->setValue(0); + progressTimer->start(100); - emit StartSignal(); - }else{ -#ifdef VERBOSE - cout << "Stopping Acquisition" << endl<< endl; -#endif - //emit StopSignal(); commented out to prevent undefined state - myDet->stopAcquisition(); - /* commented out to prevent undefined state - myDet->waitForReceiverReadToFinish(); - UpdateProgress(); - //spin index - disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - spinIndex->setValue(myDet->getFileIndex()); - connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - progressTimer->stop(); - btnStartStop->setText("Start"); - btnStartStop->setIcon(*iconStart); - btnStartStop->setChecked(false); - Enable(1);*/ - } - qDefs::checkErrorMessage(myDet,"qTabMeasurement::startStopAcquisition"); + emit StartSignal(); + qDefs::checkErrorMessage(myDet,"qTabMeasurement::startAcquisition"); } //------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabMeasurement::AcquisitionFinished(){ - disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); - btnStartStop->setText("Wait"); +void qTabMeasurement::stopAcquisition(){ +#ifdef VERBOSE + cout << "Stopping Acquisition" << endl<< endl; +#endif + myDet->stopAcquisition(); + qDefs::checkErrorMessage(myDet,"qTabMeasurement::stopAcquisition"); } @@ -391,12 +365,8 @@ void qTabMeasurement::UpdateFinished(){ connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); progressTimer->stop(); - /*disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); done in AcquisitionFinished() already */ - btnStartStop->setText("Start"); - btnStartStop->setIcon(*iconStart); - btnStartStop->setChecked(false); Enable(1); - connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); + btnStart->setEnabled(true); qDefs::checkErrorMessage(myDet,"qTabMeasurement::UpdateFinished"); }