diff --git a/slsDetectorGui/forms/form_scan.ui b/slsDetectorGui/forms/form_scan.ui index 68321732c..0d8cf06ea 100644 --- a/slsDetectorGui/forms/form_scan.ui +++ b/slsDetectorGui/forms/form_scan.ui @@ -369,6 +369,11 @@ Trimbits Scan + + + Position Scan + + Custom Script diff --git a/slsDetectorGui/forms/form_tab_advanced.ui b/slsDetectorGui/forms/form_tab_advanced.ui index a78e1c4ea..38987ac72 100644 --- a/slsDetectorGui/forms/form_tab_advanced.ui +++ b/slsDetectorGui/forms/form_tab_advanced.ui @@ -31,208 +31,6 @@ Form - - - - 25 - 83 - 740 - 93 - - - - Files: - - - - 0 - - - 0 - - - 0 - - - 5 - - - -1 - - - 9 - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Trimbit File: - - - - - - - - 0 - 0 - - - - Load - - - - - - - - 0 - 0 - - - - Save - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 120 - 20 - - - - - - - - - 0 - 0 - - - - Calibration File: - - - - - - - - 0 - 0 - - - - Load - - - - - - - - 0 - 0 - - - - Save - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - - - 0 - 0 - - - - Output File: - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - - - Browse - - - - - - - @@ -310,19 +108,6 @@ - - - - - 0 - 0 - - - - Offline Improvement - - - diff --git a/slsDetectorGui/include/qDetectorMain.h b/slsDetectorGui/include/qDetectorMain.h index 5142b62b8..1e80ccd3f 100644 --- a/slsDetectorGui/include/qDetectorMain.h +++ b/slsDetectorGui/include/qDetectorMain.h @@ -68,6 +68,8 @@ private: multiSlsDetector *myDet; /** sls detector id */ int detID; + /** true for mythen and eiger */ + bool digitalDetector; /** The Plot widget */ qDrawPlot *myPlot; /**Tab Widget */ diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index f0e578f65..e7bb9f3c9 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -206,6 +206,7 @@ private: multiSlsDetector *myDet; + /** Widgets needed to plot the clone */ /** Max Number of Clone Windows */ static const int MAXCloneWindows = 50; diff --git a/slsDetectorGui/include/qScanWidget.h b/slsDetectorGui/include/qScanWidget.h index bb7fb2fa9..927fb7e22 100644 --- a/slsDetectorGui/include/qScanWidget.h +++ b/slsDetectorGui/include/qScanWidget.h @@ -45,7 +45,7 @@ private: int id; /**type of steps*/ enum sizeIndex{RangeValues, CustomValues, FileValues}; - enum modes{None,EnergyScan,ThresholdScan,TrimbitsScan,CustomScript,NumModes}; + enum modes{None,EnergyScan,ThresholdScan,TrimbitsScan,PositionScan,CustomScript,NumModes}; static const string modeNames[NumModes]; /**values*/ diff --git a/slsDetectorGui/slsDetectorGui.pro b/slsDetectorGui/slsDetectorGui.pro index a57c8e744..c7593e21e 100644 --- a/slsDetectorGui/slsDetectorGui.pro +++ b/slsDetectorGui/slsDetectorGui.pro @@ -6,7 +6,7 @@ UI_HEADERS_DIR = forms/include RESOURCES += icons.qrc -DEFINES += VERBOSE DACS_INT #VERYVERBOSE +DEFINES += VERBOSE DACS_INT VERYVERBOSE target.path += $(DESTDIR) diff --git a/slsDetectorGui/src/qCloneWidget.cpp b/slsDetectorGui/src/qCloneWidget.cpp index 606138be5..5539ed5ce 100644 --- a/slsDetectorGui/src/qCloneWidget.cpp +++ b/slsDetectorGui/src/qCloneWidget.cpp @@ -79,7 +79,7 @@ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot //cloneplot2D->setContentsMargins(0,0,0,0); gridClone->addWidget(cloneplot2D,0,0); cloneBox->setFlat(true); - cloneBox->setContentsMargins(0,5,0,0); + cloneBox->setContentsMargins(0,20,0,0); } /** main window widgets */ diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index b09024f6c..80e5683ec 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -147,10 +147,10 @@ void qDetectorMain::SetUpWidgetWindow(){ tabs->setTabEnabled(Debugging,false); //beamline mode to false tabs->setTabEnabled(Advanced,false); - actionLoadTrimbits->hide(); - actionSaveTrimbits->hide(); - actionLoadCalibration->hide(); - actionSaveCalibration->hide(); + actionLoadTrimbits->setVisible(false); + actionSaveTrimbits->setVisible(false); + actionLoadCalibration->setVisible(false); + actionSaveCalibration->setVisible(false); dockWidgetPlot->setFloating(false); dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); tabs->setTabEnabled(Developer,isDeveloper); @@ -193,10 +193,11 @@ void qDetectorMain::SetUpDetector(){ else{ slsDetectorDefs::detectorType detType = myDet->getDetectorsType(); // Check if type valid. If not, exit - switch(detType){ - case slsDetectorDefs::MYTHEN: break; - case slsDetectorDefs::EIGER: break; - case slsDetectorDefs::GOTTHARD: break; + switch(detType){//digitalDetector decides if trimbits should be shown + case slsDetectorDefs::MYTHEN: digitalDetector = true; break; + case slsDetectorDefs::EIGER: digitalDetector = true; break; + case slsDetectorDefs::GOTTHARD: digitalDetector = false;break; + case slsDetectorDefs::AGIPD: digitalDetector = false;break; default: string detName = myDet->slsDetectorBase::getDetectorType(detType); string errorMess = host+string(" has unknown detector type \"")+ @@ -275,16 +276,16 @@ void qDetectorMain::EnableModes(QAction *action){ else if(action==actionExpert){ enable = actionExpert->isChecked(); tabs->setTabEnabled(Advanced,enable); - if(enable){ - actionLoadTrimbits->show(); - actionSaveTrimbits->show(); - actionLoadCalibration->show(); - actionSaveCalibration->show(); + if((enable)&&(digitalDetector)){ + actionLoadTrimbits->setVisible(true); + actionSaveTrimbits->setVisible(true); + actionLoadCalibration->setVisible(true); + actionSaveCalibration->setVisible(true); }else{ - actionLoadTrimbits->hide(); - actionSaveTrimbits->hide(); - actionLoadCalibration->hide(); - actionSaveCalibration->hide(); + actionLoadTrimbits->setVisible(false); + actionSaveTrimbits->setVisible(false); + actionLoadCalibration->setVisible(false); + actionSaveCalibration->setVisible(false); } #ifdef VERBOSE cout << "Setting Expert Mode to " << enable << endl; @@ -373,6 +374,20 @@ void qDetectorMain::ExecuteUtilities(QAction *action){ qDefs::InfoMessage("The configuration parameters have been successfully saved.","Main"); } } + else if(action==actionLoadTrimbits){ +#ifdef VERBOSE + cout << "Loading Trimbits" << endl; +#endif + QString fName = QString(myDet->getFilePath().c_str()); + fName = QFileDialog::getOpenFileName(this, + tr("Load Detector Trimbits"),fName, + tr("Trimbit files (*.trim *.sn*)")); + // Gets called when cancelled as well + if (!fName.isEmpty()){ + //myDet->readConfigurationFile(string(fName.toAscii().constData())); + qDefs::InfoMessage("The parameters have been successfully configured.","Main"); + } + } Refresh(tabs->currentIndex()); } @@ -492,10 +507,10 @@ void qDetectorMain::EnableTabs(){ if(enable==false){ tabs->setTabEnabled(Debugging,enable); tabs->setTabEnabled(Advanced,enable); - actionLoadTrimbits->hide(); - actionSaveTrimbits->hide(); - actionLoadCalibration->hide(); - actionSaveCalibration->hide(); + actionLoadTrimbits->setVisible(false); + actionSaveTrimbits->setVisible(false); + actionLoadCalibration->setVisible(false); + actionSaveCalibration->setVisible(false); tabs->setTabEnabled(Developer,enable); } else{ @@ -504,16 +519,16 @@ void qDetectorMain::EnableTabs(){ tabs->setTabEnabled(Debugging,enable); if(actionExpert->isChecked()){ tabs->setTabEnabled(Advanced,enable); - if(enable){ - actionLoadTrimbits->show(); - actionSaveTrimbits->show(); - actionLoadCalibration->show(); - actionSaveCalibration->show(); + if((enable)&&(digitalDetector)){ + actionLoadTrimbits->setVisible(true); + actionSaveTrimbits->setVisible(true); + actionLoadCalibration->setVisible(true); + actionSaveCalibration->setVisible(true); }else{ - actionLoadTrimbits->hide(); - actionSaveTrimbits->hide(); - actionLoadCalibration->hide(); - actionSaveCalibration->hide(); + actionLoadTrimbits->setVisible(false); + actionSaveTrimbits->setVisible(false); + actionLoadCalibration->setVisible(false); + actionSaveCalibration->setVisible(false); } } if(isDeveloper) diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 7c26be425..089d03430 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -264,6 +264,7 @@ bool qDrawPlot::StartOrStopThread(bool start){ progress = 0; currentFrame = 0; stop_signal = 0; + histTitle[0] = ""; //for 2d scans int currentIndex = myDet->getFileIndex(); @@ -283,7 +284,6 @@ bool qDrawPlot::StartOrStopThread(bool start){ }else if(scanArgument==Level0){ //no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab int numSteps = myDet->getScanSteps(0); - //if(values) delete [] values; double *values = new double[numSteps]; myDet->getScanSteps(0,values); @@ -292,6 +292,17 @@ bool qDrawPlot::StartOrStopThread(bool start){ nPixelsY = numSteps; currentScanValue = values[0]; } + else { + //no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab + int numSteps = myDet->getScanSteps(1); + double *values = new double[numSteps]; + myDet->getScanSteps(1,values); + + maxPixelsY = values[numSteps-1]; + minPixelsY = values[0]; + nPixelsY = numSteps; + currentScanValue = values[0]; + } pixelWidth = (maxPixelsY -minPixelsY)/(nPixelsY-1); startPixel = minPixelsY -(pixelWidth/2); endPixel = maxPixelsY + (pixelWidth/2); @@ -375,6 +386,8 @@ int qDrawPlot::GetData(detectorData *data){ cout << "Entering GetDatafunction" << endl; #endif if(!stop_signal){ + //set title + SetPlotTitle(QString(data->fileName).section('/',-1)); //Plot Disabled if(!plotEnable) { @@ -432,7 +445,6 @@ int qDrawPlot::GetData(detectorData *data){ //if scan argument is 2d if(scanArgument!=None){ if(scanArgument==AllFrames){ - /*title should include which scan, also by measurement tab*/ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ lastImageNumber= currentFrame+1; char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title; @@ -444,12 +456,10 @@ int qDrawPlot::GetData(detectorData *data){ return 0; } else if(scanArgument==FileIndex){ - /*title should include which scan, also by measurement tab*/ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ if(currentIndex == minPixelsY) currentScanDivLevel = 0; lastImageNumber= currentFrame+1; char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title; - //memcpy(lastImageArray+(currentIndex*nPixelsX),data->values,nPixelsX*sizeof(double)); for(unsigned int px=0;pxvalues[px]; pthread_mutex_unlock(&(last_image_complete_mutex)); } @@ -458,28 +468,29 @@ int qDrawPlot::GetData(detectorData *data){ return 0; } else if(scanArgument==Level0){ - /*title should include which scan, also by measurement tab*/ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ if(currentScanVariable0!=currentScanValue) currentScanDivLevel++; currentScanValue = currentScanVariable0; - lastImageNumber= currentFrame+1; char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title; - //memcpy(lastImageArray+(currentIndex*nPixelsX),data->values,nPixelsX*sizeof(double)); - - //for(int i=values[currentScan];ivalues,nPixelsX*sizeof(double)); - - //memcpy(lastImageArray+(currentScanDivLevel*nPixelsX),data->values,nPixelsX*sizeof(double)); for(unsigned int px=0;pxvalues[px]; - cout<<"lastImageArray[0*1280+500]:"<values[px]; pthread_mutex_unlock(&(last_image_complete_mutex)); } currentFrame++; return 0; } - + else { + if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ + if(currentScanVariable1!=currentScanValue) currentScanDivLevel++; + currentScanValue = currentScanVariable1; + lastImageNumber= currentFrame+1; + char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title; + for(unsigned int px=0;pxvalues[px]; + pthread_mutex_unlock(&(last_image_complete_mutex)); + } + currentFrame++; + return 0; + } } //normal measurement or 1d scans @@ -490,8 +501,9 @@ int qDrawPlot::GetData(detectorData *data){ //1d if(plot_in_scope==1){ - // Titles - sprintf(temp_title,"Frame Index %d",currentIndex); histTitle[0] = temp_title; + // Titles changed to "" inside startstopthread + //sprintf(temp_title,"Frame Index %d",currentIndex); histTitle[0] = temp_title; + // Persistency if(currentPersistency < persistency)currentPersistency++; else currentPersistency=persistency; diff --git a/slsDetectorGui/src/qScanWidget.cpp b/slsDetectorGui/src/qScanWidget.cpp index 158db4b0b..24e513e8b 100644 --- a/slsDetectorGui/src/qScanWidget.cpp +++ b/slsDetectorGui/src/qScanWidget.cpp @@ -25,7 +25,7 @@ using namespace std; int qScanWidget::NUM_SCAN_WIDGETS(0); -const string qScanWidget::modeNames[NumModes]={"","energy","threshold","trimbits","custom script"}; +const string qScanWidget::modeNames[NumModes]={"","energy","threshold","trimbits","position","custom script"}; //------------------------------------------------------------------------------------------------------------------------------------------------- qScanWidget::qScanWidget(QWidget *parent,multiSlsDetector*& detector): @@ -331,7 +331,7 @@ void qScanWidget::SetMode(int mode){ EnableSizeWidgets(); //set the mode - SetScan(mode); + /*SetScan(mode);*/ } @@ -354,27 +354,15 @@ int qScanWidget::SetScan(int mode){ else values = NULL; for(int i=0;isetScan(id,modeNames[mode],actualNumSteps,values,parameter); - break; - case EnergyScan: - myDet->setScan(id,modeNames[mode],actualNumSteps,values,parameter); - break; - case ThresholdScan: - myDet->setScan(id,modeNames[mode],actualNumSteps,values,parameter); - break; - case TrimbitsScan: - myDet->setScan(id,modeNames[mode],actualNumSteps,values,parameter); - break; - case CustomScript: + if(mode==CustomScript) myDet->setScan(id,script,actualNumSteps,values,parameter); - break; - } + else + cout<<"return values:"<setScan(id,modeNames[mode],actualNumSteps,values,parameter)<getScanMode(id); + int actualMode = myDet->getScanMode(id);cout<<"actualmode:"<text().section('/',-1); //is a file if(file.contains('.')){ @@ -468,12 +461,12 @@ void qScanWidget::SetScriptFile(){ //dont display if theres a none fName = dispScript->text(); - if( (!fName.compare("none"))|| - (!fName.compare("energy"))|| - (!fName.compare("threshold"))|| - (!fName.compare("trimbits")) ) - dispScript->setText(""); - + //none isnt in the modeNames list, so check separately + if(!fName.compare("none")) + dispScript->setText(""); + for(int i=1;isetText(""); } @@ -492,11 +485,12 @@ void qScanWidget::SetParameter(){ myDet->setScanParameter(id,parameter.toAscii().constData()); //dont display if theres a none parameter = dispParameter->text(); - if( (!parameter.compare("none"))|| - (!parameter.compare("energy"))|| - (!parameter.compare("threshold"))|| - (!parameter.compare("trimbits")) ) + //none isnt in the modeNames list, so check separately + if(!parameter.compare("none")) dispParameter->setText(""); + for(int i=1;isetText(""); } diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index f76cd10aa..92fe7d639 100644 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -572,7 +572,6 @@ void qTabPlot::SetScanArgument(){ //if scans if(boxScan->isEnabled()){ - //setting the title according to the scans QString mainTitle = QString(" Level 0 : ") + modeNames[myDet->getScanMode(0)] + QString(" | Level 1 : ") + modeNames[myDet->getScanMode(1)] + QString(""); @@ -641,7 +640,7 @@ void qTabPlot::SetScanArgument(){ void qTabPlot::Refresh(){ SetFrequency(); - EnableScanBox(); + if(!myPlot->isRunning()) EnableScanBox(); }