diff --git a/slsDetectorGui/forms/form_tab_dataoutput.ui b/slsDetectorGui/forms/form_tab_dataoutput.ui index 3d56a55f3..50b838b2c 100644 --- a/slsDetectorGui/forms/form_tab_dataoutput.ui +++ b/slsDetectorGui/forms/form_tab_dataoutput.ui @@ -35,9 +35,9 @@ 20 - 110 + 160 731 - 206 + 166 @@ -47,12 +47,15 @@ 15 - 20 + 25 701 - 176 + 126 + + 3 + @@ -85,6 +88,9 @@ false + + Qt::ClickFocus + Flat field corrections. #flatfield# filename @@ -270,93 +276,217 @@ - + - 19 - 20 - 746 - 41 + 20 + 25 + 731 + 116 - - QFrame::NoFrame + + <nobr> +Directory where one saves the data. +</nobr><br> + #outdir# +<br> + - - QFrame::Plain + + Output Directory - + - 10 - 6 - 706 - 28 + 5 + 10 + 721 + 96 - - - -1 + + <nobr> +Directory where one saves the data. +</nobr><br> + #outdir# +<br> + + + + QFrame::NoFrame + + + QFrame::Plain + + + + + 10 + 10 + 701 + 86 + - - - - - 0 - 0 - - - - <nobr> + + + 4 + + + + + <nobr> Directory where one saves the data. </nobr><br> #outdir# <br> - - - Output Directory : - - - - - - - <nobr> + + + Browse + + + + :/icons/images/browse.png:/icons/images/browse.png + + + + + + + Qt::NoFocus + + + <nobr> Directory where one saves the data. </nobr><br> #outdir# <br> - - - - - - - <nobr> + + + false + + + QLineEdit::Normal + + + true + + + + + + + Qt::StrongFocus + + + <nobr> Directory where one saves the data. </nobr><br> #outdir# <br> - - - Browse - - - - :/icons/images/browse.png:/icons/images/browse.png - - - - + + + + + + + + 0 + 0 + + + + + + + + + 2 + 2 + 2 + + + + + + + + + 0 + 0 + 0 + + + + + + + + + 119 + 119 + 119 + + + + + + + + <nobr> +Directory where one saves the data. +</nobr><br> + #outdir# +<br> + + + + Readout: + + + + + + + + 0 + 0 + + + + + 180 + 0 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + - dispOutputDir - btnOutputBrowse + dispReadOutputDir chkFlatField dispFlatField btnFlatField diff --git a/slsDetectorGui/include/qDetectorMain.h b/slsDetectorGui/include/qDetectorMain.h index 181ab9cde..8833836f4 100644 --- a/slsDetectorGui/include/qDetectorMain.h +++ b/slsDetectorGui/include/qDetectorMain.h @@ -14,7 +14,7 @@ /** Qt Project Class Headers */ #include "qDrawPlot.h" #include "qTabMeasurement.h" -class qTabDataOutput; +#include "qTabDataOutput.h" class qTabPlot; class qTabActions; class qTabAdvanced; @@ -80,6 +80,9 @@ public: /** Returns file path */ QString GetFilePath(){QString s = QString(myDet->getFilePath().c_str());qDefs::checkErrorMessage(myDet); return s;}; + /** Verifies if output directories for all the receivers exist */ + int DoesOutputDirExist(){return tab_dataoutput->VerifyOutputDirectory();}; + private: /** The Qt Application */ QApplication *theApp; diff --git a/slsDetectorGui/include/qTabDataOutput.h b/slsDetectorGui/include/qTabDataOutput.h index 437afce4f..57aaaad88 100644 --- a/slsDetectorGui/include/qTabDataOutput.h +++ b/slsDetectorGui/include/qTabDataOutput.h @@ -40,6 +40,10 @@ public: */ void Refresh(); + /** verify output directories + * /returns success or fail + */ + int VerifyOutputDirectory(); private: @@ -53,6 +57,9 @@ private: QString errFlatFieldTip; QString outDirTip; QPalette red; + QPalette black; + QPalette *red1; + QPalette *black1; /** methods */ /** Sets up the widget */ @@ -61,11 +68,12 @@ private: /** Sets up all the slots and signals */ void Initialization(); + /** Populate the readouts + */ + void PopulateDetectors(); + private slots: -/** Sets the output directory - */ -void setOutputDir(); /** Open dialog to choose the output directory */ void browseOutputDir(); @@ -91,6 +99,12 @@ void SetAngularCorrection(); /**discard bad channels*/ void DiscardBadChannels(); +/** set output directory*/ +void SetOutputDir(); + +/** set output directory*/ +void GetOutputDir(); + signals: /**signal to enable/disable positions in Actions*/ void AngularConversionSignal(bool); diff --git a/slsDetectorGui/include/qTabMeasurement.h b/slsDetectorGui/include/qTabMeasurement.h index fc6a0c375..4788fbb5d 100644 --- a/slsDetectorGui/include/qTabMeasurement.h +++ b/slsDetectorGui/include/qTabMeasurement.h @@ -16,6 +16,7 @@ class multiSlsDetector; /** Qt Project Class Headers */ #include "qDrawPlot.h" +class qDetectorMain; /** *@short sets up the measurement parameters @@ -33,7 +34,7 @@ public: * @param detector is the detector returned from the detector tab * @param plot plot object reference */ - qTabMeasurement(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot); + qTabMeasurement(qDetectorMain *parent,multiSlsDetector*& detector, qDrawPlot*& plot); /** Destructor */ @@ -167,6 +168,8 @@ private slots: private: + /** parent widget */ + qDetectorMain *thisParent; /** The sls detector object */ multiSlsDetector *myDet; /** The Plot widget */ diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp index bc8615ff1..2586c92c9 100644 --- a/slsDetectorGui/src/qTabDataOutput.cpp +++ b/slsDetectorGui/src/qTabDataOutput.cpp @@ -57,23 +57,28 @@ void qTabDataOutput::SetupWidgetWindow(){ /** error message **/ red = QPalette(); red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); + black = QPalette(); + black.setColor(QPalette::Active,QPalette::WindowText,Qt::black); + + red1 = new QPalette(); + red1->setColor(QPalette::Text,Qt::red); + black1 = new QPalette(); + black1->setColor(QPalette::Text,Qt::black); + flatFieldTip = dispFlatField->toolTip(); errFlatFieldTip = QString("Flat field corrections.
" " #flatfield# filename

")+ QString("" "Enter a valid file to enable Flat Field."); + outDirTip = boxOutDir->toolTip(); + - outDirTip = dispOutputDir->toolTip(); Initialization(); - - // output dir -#ifdef VERBOSE - cout << "Getting output directory" << endl; -#endif - dispOutputDir->setText(QString(myDet->getFilePath().c_str())); - + disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); + PopulateDetectors(); + connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); //flat field correction from server #ifdef VERBOSE @@ -131,7 +136,10 @@ void qTabDataOutput::SetupWidgetWindow(){ void qTabDataOutput::Initialization(){ //output dir - connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(setOutputDir())); + connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); + connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); + + connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(browseOutputDir())); //flat field correction connect(chkFlatField, SIGNAL(toggled(bool)), this, SLOT(SetFlatField())); @@ -149,7 +157,7 @@ void qTabDataOutput::Initialization(){ } //------------------------------------------------------------------------------------------------------------------------------------------------- - +/* void qTabDataOutput::setOutputDir(){ disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(setOutputDir())); @@ -199,9 +207,6 @@ void qTabDataOutput::setOutputDir(){ break; } } - /* myDet->setFilePath(string(path.toAscii().constData())); - if(myDet->getFilePath()!=(string(path.toAscii().constData()))) - error=true;*/ } if(!error){ @@ -233,7 +238,7 @@ void qTabDataOutput::setOutputDir(){ qDefs::checkErrorMessage(myDet); } - +*/ //------------------------------------------------------------------------------------------------------------------------------------------------- @@ -242,7 +247,7 @@ void qTabDataOutput::browseOutputDir() QString directory = QFileDialog::getExistingDirectory(this,tr("Choose Output Directory "),dispOutputDir->text()); if (!directory.isEmpty()) dispOutputDir->setText(directory); - setOutputDir(); + SetOutputDir(); } @@ -542,14 +547,10 @@ void qTabDataOutput::Refresh(){ #ifdef VERBOSE cout << "Getting output directory" << endl; #endif - dispOutputDir->setText(QString(myDet->getFilePath().c_str())); - lblOutputDir->setText("Output Directory: "); - lblOutputDir->setPalette(chkRate->palette()); - lblOutputDir->setToolTip(outDirTip); - dispOutputDir->setToolTip(outDirTip); - btnOutputBrowse->setToolTip(outDirTip); - //making sure it is set - setOutputDir(); + disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); + PopulateDetectors(); + connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); + //flat field correction from server #ifdef VERBOSE @@ -611,3 +612,208 @@ void qTabDataOutput::Refresh(){ //------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabDataOutput::PopulateDetectors(){ +#ifdef VERBOSE + cout << "Populating detectors" << endl; +#endif + comboDetector->clear(); + if(myDet->setReceiverOnline() == slsDetectorDefs::OFFLINE_FLAG){ + boxOutDir->setTitle("Output Directory"); + comboDetector->addItem("All"); + } + + //if receiver, add detectors + else{ + boxOutDir->setTitle("Receiver Output Directory"); + for(int i=0;igetNumberOfDetectors();i++) + comboDetector->addItem(QString(myDet->getHostname(i).c_str())); + } + GetOutputDir(); +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabDataOutput::GetOutputDir(){ +#ifdef VERBOSE + cout << "Getting output directory" << endl; +#endif + + if(!comboDetector->itemText(0).compare("All")){ + dispReadOutputDir->setText(QString(myDet->getFilePath().c_str())); + }else{ + slsDetector *det = myDet->getSlsDetector(comboDetector->currentIndex()); + qDefs::checkErrorMessage(myDet); + dispReadOutputDir->setText(QString(det->getFilePath().c_str())); + } + + + VerifyOutputDirectory(); + + //clear field to write + disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); + dispOutputDir->setText(""); + dispOutputDir->setPalette(*black1); + connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +int qTabDataOutput::VerifyOutputDirectory(){ +#ifdef VERBOSE + cout << "Verifying output directory" << endl; +#endif + bool error = false; + QString path = ""; + QString errTip = outDirTip; + QString detName = ""; + + path = dispReadOutputDir->text(); + + //no receiver + if(!comboDetector->itemText(0).compare("All")){ + if(myDet->setFilePath(string(path.toAscii().constData())).empty()){ + qDefs::Message(qDefs::WARNING,string("Enter a valid output directory"),"Data Output"); + error = true; + dispReadOutputDir->setText(QString(myDet->getFilePath().c_str())); + boxOutDir->setTitle("Receiver Output Directory*"); + }else if(!qDefs::checkErrorMessage(myDet).empty()){ + error = true; + dispReadOutputDir->setText(QString(myDet->getFilePath().c_str())); + dispReadOutputDir->setPalette(*red1); + boxOutDir->setPalette(red); + boxOutDir->setTitle("Output Directory*"); + errTip = outDirTip + + QString("" + "Enter a valid path to change Output Directory."); + boxOutDir->setToolTip(errTip); + } + } + + //receiver + else{ + for(int i=0;igetNumberOfDetectors();i++){ + detName = comboDetector->itemText(i); + slsDetector *det = myDet->getSlsDetector(i); + qDefs::checkErrorMessage(myDet); + if(det->setFilePath(det->getFilePath()).empty()){ + qDefs::Message(qDefs::WARNING,string("Enter a valid output directory for ") + + string(detName.toAscii().constData()) + string(" readout"),"Data Output"); + error = true; + dispReadOutputDir->setText(QString(det->getFilePath().c_str())); + boxOutDir->setTitle("Receiver Output Directory*"); + }else if(!qDefs::checkErrorMessage(det).empty()){ + error = true; + dispReadOutputDir->setText(QString(det->getFilePath().c_str())); + boxOutDir->setTitle("Receiver Output Directory*"); + } + } + } + + //if error, display in red + if(error){ +#ifdef VERBOSE + cout << "The output path doesnt exist anymore" << endl; +#endif + dispReadOutputDir->setPalette(*red1); + boxOutDir->setPalette(red); + errTip = errTip + + QString("
" + "Enter a valid path for ") + detName + + QString( " readout to change Output Directory."); + boxOutDir->setToolTip(errTip); + + return slsDetectorDefs::FAIL; + } + + //no error + else{ +#ifdef VERBOSE + cout << "The output path has been verified" << endl; +#endif + dispReadOutputDir->setPalette(*black1); + boxOutDir->setPalette(black); + if(!comboDetector->itemText(0).compare("All")) + boxOutDir->setTitle("Output Directory"); + else + boxOutDir->setTitle("Receiver Output Directory"); + boxOutDir->setToolTip(outDirTip); + } + + return slsDetectorDefs::OK; +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabDataOutput::SetOutputDir(){ + +#ifdef VERBOSE + cout << "Setting output directory" << endl; +#endif + + bool error = false; + QString path = dispOutputDir->text(); + + if(path.isEmpty()) + return; + + disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); + + //gets rid of the end '/'s + while(path.endsWith('/')) path.chop(1); + dispOutputDir->setText(path); + + if(!comboDetector->itemText(0).compare("All")){ + myDet->setFilePath(string(dispOutputDir->text().toAscii().constData())); + if(!qDefs::checkErrorMessage(myDet).empty()){ +#ifdef VERBOSE + cout << "The output path could not be set" << endl; +#endif + myDet->setFilePath(string(dispReadOutputDir->text().toAscii().constData())); + error = true; + dispOutputDir->setPalette(*red1); + } + } + + else{ + slsDetector *det = myDet->getSlsDetector(comboDetector->currentIndex()); + qDefs::checkErrorMessage(myDet); + det->setFilePath(string(dispOutputDir->text().toAscii().constData())); + if(!qDefs::checkErrorMessage(det).empty()){ +#ifdef VERBOSE + cout << "The output path could not be set" << endl; +#endif + det->setFilePath(string(dispReadOutputDir->text().toAscii().constData())); + error = true; + dispOutputDir->setPalette(*red1); + } + + cout<<"filepath:"<getFilePath()<setPalette(*black1); + dispReadOutputDir->setText(dispOutputDir->text()); + dispOutputDir->setText(""); + VerifyOutputDirectory(); + } + + connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); + +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index 1a3b82dfc..c96d22398 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -7,6 +7,7 @@ //Qt Project Class Headers #include "qTabMeasurement.h" +#include "qDetectorMain.h" //Project Class Headers #include "slsDetector.h" #include "multiSlsDetector.h" @@ -23,8 +24,8 @@ using namespace std; //------------------------------------------------------------------------------------------------------------------------------------------------- -qTabMeasurement::qTabMeasurement(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot): - QWidget(parent),myDet(detector),myPlot(plot),expertMode(false){ +qTabMeasurement::qTabMeasurement(qDetectorMain *parent,multiSlsDetector*& detector, qDrawPlot*& plot): + thisParent(parent),myDet(detector),myPlot(plot),expertMode(false){ setupUi(this); SetupWidgetWindow(); Initialization(); @@ -38,6 +39,7 @@ qTabMeasurement::qTabMeasurement(QWidget *parent,multiSlsDetector*& detector, qD qTabMeasurement::~qTabMeasurement(){ delete myDet; delete myPlot; + delete thisParent; } @@ -308,6 +310,14 @@ void qTabMeasurement::setRunIndex(int index){ void qTabMeasurement::startStopAcquisition(){ if(btnStartStop->isChecked()){ + + if(thisParent->DoesOutputDirExist() == slsDetectorDefs::FAIL){ + disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); + btnStartStop->click(); + connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); + return; + } + #ifdef VERBOSE cout << endl << endl << "Starting Acquisition" << endl; #endif