From 87410f09deb376883726271738acfa1b139c8868 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Wed, 10 Oct 2012 10:25:31 +0000 Subject: [PATCH] check if outdir exists,indent Actions,degreeC,cascode,thresholdscan(ev),not saving data secondary title,got rid of 2d sampledata git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@86 af1100a4-978c-4157-bff7-07162d2ba061 --- slsDetectorGui/forms/form_scan.ui | 2 +- slsDetectorGui/forms/form_tab_dataoutput.ui | 29 ++++++++- slsDetectorGui/forms/form_tab_plot.ui | 2 +- slsDetectorGui/include/qDefs.h | 2 +- slsDetectorGui/include/qDrawPlot.h | 6 +- slsDetectorGui/include/qTabActions.h | 12 +++- slsDetectorGui/include/qTabDataOutput.h | 1 + slsDetectorGui/src/qDrawPlot.cpp | 33 +++++----- slsDetectorGui/src/qScanWidget.cpp | 6 +- slsDetectorGui/src/qTabActions.cpp | 67 ++++++++++++++++----- slsDetectorGui/src/qTabDataOutput.cpp | 33 ++++++++-- slsDetectorGui/src/qTabDeveloper.cpp | 17 +++--- slsDetectorGui/src/qTabMeasurement.cpp | 3 +- 13 files changed, 156 insertions(+), 57 deletions(-) diff --git a/slsDetectorGui/forms/form_scan.ui b/slsDetectorGui/forms/form_scan.ui index f01e88cb0..e5790c978 100644 --- a/slsDetectorGui/forms/form_scan.ui +++ b/slsDetectorGui/forms/form_scan.ui @@ -367,7 +367,7 @@ Defines scan range for a <b>Constant Step Size</b> with the followin - Energy Scan + Energy Scan (eV) diff --git a/slsDetectorGui/forms/form_tab_dataoutput.ui b/slsDetectorGui/forms/form_tab_dataoutput.ui index 853b53cb8..e2ad9d6d6 100644 --- a/slsDetectorGui/forms/form_tab_dataoutput.ui +++ b/slsDetectorGui/forms/form_tab_dataoutput.ui @@ -299,23 +299,48 @@ -1 - + 0 0 + + <nobr> +Directory where one saves the data. +</nobr><br> + #outdir# +<br> + + Output Directory : - + + + <nobr> +Directory where one saves the data. +</nobr><br> + #outdir# +<br> + + + + + <nobr> +Directory where one saves the data. +</nobr><br> + #outdir# +<br> + + Browse diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index 1a55404bd..8ddd673c9 100644 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -638,7 +638,7 @@ - Title: + Title Prefix: diff --git a/slsDetectorGui/include/qDefs.h b/slsDetectorGui/include/qDefs.h index 5e9589b57..9d55103a8 100644 --- a/slsDetectorGui/include/qDefs.h +++ b/slsDetectorGui/include/qDefs.h @@ -21,7 +21,7 @@ public: qDefs(){}; //------------------------------------------------------------------------------------------------------------------------------------------------- -#define GUI_VERSION 0.12 +#define GUI_VERSION 0.13 //------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index 5d8c31b96..f970ad1c2 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -52,6 +52,9 @@ public: int GetProgress(){return progress;}; /** gets the file index to the measurement tab*/ int GetFileIndex(){return currentFileIndex;}; + /** sets file write enable , if not enabled, + * file index wont increase and so you need secondary titles to differentitate between plots*/ + void SetEnableFileWrite(bool enable){fileSaveEnable = enable;}; /** sets plot Title prefix*/ void SetPlotTitlePrefix(QString title) {plotTitle_prefix = title;} @@ -448,7 +451,8 @@ static const int TRIM_HISTOGRAM_XMAX = 63; /**if the values increment backwards*/ bool backwardScanPlot; - +/**if files will be saved and index increased*/ +bool fileSaveEnable; signals: void UpdatingPlotFinished(); diff --git a/slsDetectorGui/include/qTabActions.h b/slsDetectorGui/include/qTabActions.h index 0add44491..35f955124 100644 --- a/slsDetectorGui/include/qTabActions.h +++ b/slsDetectorGui/include/qTabActions.h @@ -85,7 +85,17 @@ private: slsDetectorDefs::detectorType detType; - enum actionIndex{Scan0=1, Scan1, NumPositions=4, NumTotalActions=9}; + enum actionIndex{ + ActionStart, + Scan0, + Scan1, + ActionBefore, + NumPositions, + HeaderBefore, + HeaderAfter, + ActionAfter, + ActionStop, + NumTotalActions}; QGridLayout *gridLayout; QButtonGroup *group; diff --git a/slsDetectorGui/include/qTabDataOutput.h b/slsDetectorGui/include/qTabDataOutput.h index 0f5a9d680..8c65edb0a 100644 --- a/slsDetectorGui/include/qTabDataOutput.h +++ b/slsDetectorGui/include/qTabDataOutput.h @@ -49,6 +49,7 @@ private: QString flatFieldTip; QString errFlatFieldTip; + QString outDirTip; QPalette red; /** methods */ diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index febd7a493..1a3364524 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -66,15 +66,17 @@ void qDrawPlot::SetupWidgetWindow(){ //gui_acquisition_thread_running = 0; // Default Plotting plot_in_scope = 0; - //2d lastImageNumber = 0; last_plot_number = 0; nPixelsX = myDet->getTotalNumberOfChannels(); nPixelsY = 100; nAnglePixelsX = 1; - minPixelsY = 0; + maxPixelsY = 0; + startPixel=-0.5; + endPixel=nPixelsY-0.5; + //2d lastImageArray = 0; //1d @@ -156,6 +158,7 @@ void qDrawPlot::SetupWidgetWindow(){ plot2D = new SlsQt2DPlotLayout(boxPlot); plot2D->setFont(QFont("Sans Serif",9,QFont::Normal)); + plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,lastImageArray); plot2D->setTitle(GetImageTitle()); plot2D->SetXTitle(imageXAxisTitle); plot2D->SetYTitle(imageYAxisTitle); @@ -182,6 +185,8 @@ void qDrawPlot::SetupWidgetWindow(){ fileName = QString(myDet->getFileName().c_str()); + fileSaveEnable= myDet->enableWriteToFile(); + // Setting the callback function to get data from detector class myDet->registerDataCallback(&(GetDataCallBack),this); @@ -540,7 +545,10 @@ int qDrawPlot::GetData(detectorData *data){ //Plot Disabled if(!plotEnable) return 0; - + // secondary title necessary to differentiate between frames when not saving data + char temp_title[2000]; + if(fileSaveEnable) strcpy(temp_title,""); + else sprintf(temp_title,"#%d",currentFrame); //angle plotting @@ -549,8 +557,9 @@ int qDrawPlot::GetData(detectorData *data){ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ //set title plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); + // Title + histTitle[0] = temp_title; - cout<angles==NULL){ cout<<"\n\nWARNING:RETURNED NULL instead of angles."<values,nPixelsX*sizeof(double)); @@ -646,8 +653,6 @@ int qDrawPlot::GetData(detectorData *data){ if(currentFileIndex == minPixelsY) currentScanDivLevel = 0; lastImageNumber= currentFrame+1; //title - char temp_title[2000]; - sprintf(temp_title,"Image Index %d",currentFileIndex); imageTitle = temp_title; //copy data for(unsigned int px=0;pxvalues[px]; @@ -678,8 +683,6 @@ int qDrawPlot::GetData(detectorData *data){ currentScanValue = cs0; lastImageNumber= currentFrame+1; //title - char temp_title[2000]; - sprintf(temp_title,"Image Index %d",currentFileIndex); imageTitle = temp_title; //copy data for(unsigned int px=0;pxvalues[px]; @@ -706,8 +709,6 @@ int qDrawPlot::GetData(detectorData *data){ currentScanValue = cs1; lastImageNumber= currentFrame+1; //title - char temp_title[2000]; - sprintf(temp_title,"Image Index %d",currentFileIndex); imageTitle = temp_title; //copy data for(unsigned int px=0;pxvalues[px]; @@ -724,13 +725,13 @@ int qDrawPlot::GetData(detectorData *data){ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ //set title plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1); - char temp_title[2000]; // only if you got the lock, do u need to remember lastimagenumber to plot lastImageNumber= currentFrame+1; //1d if(plot_in_scope==1){ - // Titles changed to "" inside startstopthread + // Titles + histTitle[0] = temp_title; // Persistency if(currentPersistency < persistency)currentPersistency++; else currentPersistency=persistency; @@ -742,9 +743,8 @@ int qDrawPlot::GetData(detectorData *data){ memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double)); } //2d - else{ + else{cout<GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,lastImageArray); plot2D->setFont(QFont("Sans Serif",9,QFont::Normal)); plot2D->setTitle(GetImageTitle()); plot2D->SetXTitle(imageXAxisTitle); diff --git a/slsDetectorGui/src/qScanWidget.cpp b/slsDetectorGui/src/qScanWidget.cpp index 99453ca93..dabe62075 100644 --- a/slsDetectorGui/src/qScanWidget.cpp +++ b/slsDetectorGui/src/qScanWidget.cpp @@ -92,7 +92,7 @@ void qScanWidget::SetupWidgetWindow(){ spinFrom->setMinimum(-1000000); spinFrom->setKeyboardTracking(false); spinFrom->setFixedWidth(80); - spinFrom->setDecimals(4); + spinFrom->setDecimals(2); lblTo->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); lblTo->setToolTip(rangeTip); lblTo->setFixedWidth(18); @@ -102,7 +102,7 @@ void qScanWidget::SetupWidgetWindow(){ spinTo->setMinimum(-1000000); spinTo->setKeyboardTracking(false); spinTo->setFixedWidth(80); - spinTo->setDecimals(4); + spinTo->setDecimals(2); lblSize->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); lblSize->setToolTip(rangeTip); lblSize->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); @@ -113,7 +113,7 @@ void qScanWidget::SetupWidgetWindow(){ spinSize->setSingleStep(0.1); spinSize->setToolTip(rangeTip); spinSize->setKeyboardTracking(false); - spinSize->setDecimals(4); + spinSize->setDecimals(2); //spinSize->setMinimum(0.0001); layoutRange->addItem(new QSpacerItem(40,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); diff --git a/slsDetectorGui/src/qTabActions.cpp b/slsDetectorGui/src/qTabActions.cpp index 7cac28e22..edcc12346 100644 --- a/slsDetectorGui/src/qTabActions.cpp +++ b/slsDetectorGui/src/qTabActions.cpp @@ -40,7 +40,8 @@ qTabActions::~qTabActions(){ void qTabActions::SetupWidgetWindow(){ // Window Settings - setFixedSize(710,350); + setFixedHeight(350); + //setFixedSize(710,350); setContentsMargins(0,0,0,0); // Scroll Area Settings @@ -62,7 +63,7 @@ void qTabActions::SetupWidgetWindow(){ QPalette p; p.setColor(QPalette::Shadow,QColor(0,0,0,0)); p.setColor(QPalette::Button,QColor(0,0,0,0)); - +/*get rid of this vector*/ char names[NumTotalActions][200] = { "Action at Start", "Scan Level 0", @@ -81,6 +82,10 @@ void qTabActions::SetupWidgetWindow(){ QString tip = "Click on the \"+\" to Expand or \"-\" to Collapse."; + + + int hIndent=0, vIndent=0, colspan=6; + QLabel *lblReal; // For each level of Actions for(int i=0;isetToolTip(tip); - btnExpand[i]->setCheckable(true); btnExpand[i]->setChecked(false); btnExpand[i]->setFixedSize(16,16); @@ -98,32 +102,62 @@ void qTabActions::SetupWidgetWindow(){ btnExpand[i]->setFlat(true); btnExpand[i]->setIconSize(QSize(16,16)); btnExpand[i]->setPalette(p); - group->addButton(btnExpand[i],i); - //add the widgets to the layout , depending on the type create the widgets - gridLayout->addWidget(btnExpand[i],(i*2),0); - gridLayout->addWidget(lblName[i],(i*2),1); - if(i==NumPositions){ + //add label and button to expand or collapse + gridLayout->addWidget(btnExpand[i],vIndent,hIndent,1,1); + gridLayout->addWidget(lblName[i],vIndent,hIndent+1,1,colspan); + + //creating the action/scan/position widgets and adding them + switch(i){ + case NumPositions: CreatePositionsWidget(); - gridLayout->addWidget(positionWidget,(i*2)+1,1,1,2); + gridLayout->addWidget(positionWidget,vIndent+1,hIndent+1,1,colspan); positionWidget->hide(); - }else if((i==Scan0)||(i==Scan1)){ + break; + case Scan0: + case Scan1: scanWidget[qScanWidget::NUM_SCAN_WIDGETS] = new qScanWidget(this,myDet); - gridLayout->addWidget(scanWidget[qScanWidget::NUM_SCAN_WIDGETS-1],(i*2)+1,1,1,2); + gridLayout->addWidget(scanWidget[qScanWidget::NUM_SCAN_WIDGETS-1],vIndent+1,hIndent+1,1,colspan); scanWidget[qScanWidget::NUM_SCAN_WIDGETS-1]->hide(); - }else{ + break; + default: actionWidget[qActionsWidget::NUM_ACTION_WIDGETS] = new qActionsWidget(this,myDet); - gridLayout->addWidget(actionWidget[qActionsWidget::NUM_ACTION_WIDGETS-1],(i*2)+1,1,1,2); + gridLayout->addWidget(actionWidget[qActionsWidget::NUM_ACTION_WIDGETS-1],vIndent+1,hIndent+1,1,colspan); actionWidget[qActionsWidget::NUM_ACTION_WIDGETS-1]->hide(); + break; + } + + //incrementing the vertical and horizontal indent + vIndent+=2; + switch(i){ + case HeaderBefore: + //real time acquisition + palette->setColor(QPalette::Active,QPalette::WindowText,QColor(0,0,200,255)); + lblReal = new QLabel(" Real Time Acquisition"); + lblReal->setFixedHeight(25); + //lblReal->setPalette(*palette); + gridLayout->addWidget(lblReal,vIndent,hIndent+1,1,colspan); + vIndent++; + break; + case HeaderAfter: + hIndent-=2; + colspan+=2; + break; + case ActionAfter: + hIndent=0; + colspan=6; + break; + default: + hIndent++; + colspan--; + break; } - //gridLayout->addWidget(btnExpand[i],(i*2),i); - //gridLayout->addWidget(lblName[i],(i*2),i+1); - //gridLayout->addWidget(actionWidget[i],(i*2)+1,i+1,1,2); } + //Number of positions is only for mythen or gotthard detType = myDet->getDetectorsType(); if((detType == slsDetectorDefs::EIGER) || (detType == slsDetectorDefs::AGIPD)) { @@ -174,6 +208,7 @@ void qTabActions::SetupWidgetWindow(){ void qTabActions::CreatePositionsWidget(){ positionWidget = new QWidget; positionWidget->setFixedHeight(25); + positionWidget->setFixedWidth(680); QGridLayout *layout = new QGridLayout(positionWidget); layout->setContentsMargins(0,0,0,0); diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp index d5887033d..50d841b93 100644 --- a/slsDetectorGui/src/qTabDataOutput.cpp +++ b/slsDetectorGui/src/qTabDataOutput.cpp @@ -64,6 +64,7 @@ void qTabDataOutput::SetupWidgetWindow(){ QString("" "Enter a valid file to enable Flat Field."); + outDirTip = dispOutputDir->toolTip(); Initialization(); @@ -146,13 +147,29 @@ void qTabDataOutput::setOutputDir(){ while(path.endsWith('/')) path.chop(1); dispOutputDir->setText(path); - //if(QFile::exists(path)) + if(QFile::exists(path)){ + lblOutputDir->setText("Output Directory: "); + lblOutputDir->setPalette(chkRate->palette()); + lblOutputDir->setToolTip(outDirTip); + dispOutputDir->setToolTip(outDirTip); + btnOutputBrowse->setToolTip(outDirTip); + myDet->setFilePath(string(path.toAscii().constData())); + #ifdef VERBOSE + cout << "Output Directory changed to :"<getFilePath() << endl; + #endif + } + else{ + lblOutputDir->setText("Output Directory:*"); + lblOutputDir->setPalette(red); + QString errTip = outDirTip + + QString("" + "Enter a valid path to change Output Directory."); + lblOutputDir->setToolTip(errTip); + dispOutputDir->setToolTip(errTip); + btnOutputBrowse->setToolTip(errTip); + } - myDet->setFilePath(string(path.toAscii().constData())); -#ifdef VERBOSE - cout << "Output Directory changed to :"<getFilePath() << endl; -#endif connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(setOutputDir())); } @@ -454,7 +471,11 @@ void qTabDataOutput::Refresh(){ 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); //flat field correction from server #ifdef VERBOSE diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp index 32a00201d..3b7692ab2 100644 --- a/slsDetectorGui/src/qTabDeveloper.cpp +++ b/slsDetectorGui/src/qTabDeveloper.cpp @@ -71,14 +71,14 @@ void qTabDeveloper::SetupWidgetWindow(){ case slsDetectorDefs::GOTTHARD: NUM_DAC_WIDGETS = 8; NUM_ADC_WIDGETS = 2; - dacNames.push_back("Reference Voltage:"); - dacNames.push_back("Cascade n Voltage:"); - dacNames.push_back("Cascade p Voltage:"); - dacNames.push_back("Comp. Output Voltage:"); - dacNames.push_back("Cascade out Voltage:"); - dacNames.push_back("Comp. Input Voltage:"); - dacNames.push_back("Comp. Ref Voltage:"); - dacNames.push_back("Base Test Current:"); + dacNames.push_back("v Reference:"); + dacNames.push_back("v Cascode n:"); + dacNames.push_back("v Cascode p:"); + dacNames.push_back("v Comp. Output:"); + dacNames.push_back("v Cascode out"); + dacNames.push_back("v Comp. Input:"); + dacNames.push_back("v Comp. Ref:"); + dacNames.push_back("i Base Test:"); adcNames.push_back("Temperature ADC:"); adcNames.push_back("Temperature FPGA:"); @@ -194,6 +194,7 @@ void qTabDeveloper::CreateADCWidgets(){ lblAdcs[i] = new QLabel(QString(adcNames[i].c_str()),boxAdcs); spinAdcs[i] = new QDoubleSpinBox(boxAdcs); spinAdcs[i]->setMaximum(10000); + if(detType==slsDetectorDefs::GOTTHARD) spinAdcs[i]->setSuffix(0x00b0+QString("C")); adcLayout->addWidget(lblAdcs[i],(int)(i/2),((i%2)==0)?1:4); adcLayout->addWidget(spinAdcs[i],(int)(i/2),((i%2)==0)?2:5); diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index f5c2ae8da..69d239a91 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -364,7 +364,7 @@ void qTabMeasurement::SetCurrentMeasurement(int val){ void qTabMeasurement::UpdateProgress(){ progressBar->setValue((int)myPlot->GetProgress()); - lblProgressIndex->setText(QString::number(myPlot->GetFileIndex()+1)); + lblProgressIndex->setText(QString::number(myPlot->GetFileIndex())); } @@ -728,6 +728,7 @@ void qTabMeasurement::EnableFileWrite(bool enable){ myDet->enableWriteToFile(enable); dispFileName->setEnabled(enable); if(enable) setFileName(dispFileName->text()); + myPlot->SetEnableFileWrite(enable); }; //-------------------------------------------------------------------------------------------------------------------------------------------------