From 9fc66d571ed8c39d690d3218be55f03c3c56ac96 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Mon, 1 Oct 2012 15:45:47 +0000 Subject: [PATCH] bug fix: run index, plots only new data, lockimage for clone git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@83 af1100a4-978c-4157-bff7-07162d2ba061 --- slsDetectorGui/include/qDefs.h | 2 +- slsDetectorGui/src/qCloneWidget.cpp | 4 +- slsDetectorGui/src/qDrawPlot.cpp | 137 +++++++++++++------------ slsDetectorGui/src/qTabMeasurement.cpp | 17 ++- 4 files changed, 87 insertions(+), 73 deletions(-) diff --git a/slsDetectorGui/include/qDefs.h b/slsDetectorGui/include/qDefs.h index 529c43631..5e9589b57 100644 --- a/slsDetectorGui/include/qDefs.h +++ b/slsDetectorGui/include/qDefs.h @@ -21,7 +21,7 @@ public: qDefs(){}; //------------------------------------------------------------------------------------------------------------------------------------------------- -#define GUI_VERSION 0.11 +#define GUI_VERSION 0.12 //------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qCloneWidget.cpp b/slsDetectorGui/src/qCloneWidget.cpp index 980e37a9f..7080cc548 100644 --- a/slsDetectorGui/src/qCloneWidget.cpp +++ b/slsDetectorGui/src/qCloneWidget.cpp @@ -96,7 +96,7 @@ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot //------------------------------------------------------------------------------------------------------------------------------------------------- void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis[],string histTitle[],bool lines,bool markers){ - /** for each plot*/cout<<"qclone histYAxis[0][500]:"<SetXTitle(histXAxisTitle.toAscii().constData()); - plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); - for(int hist_num=0;hist_num<(int)nHists;hist_num++){ - SlsQtH1D* h; - if(hist_num+1>plot1D_hists.size()){ - if(anglePlot) - plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAngleAxis,histYAngleAxis)); - else - plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAxis,GetHistYAxis(hist_num))); - h->SetLineColor(hist_num+1); - }else{ - h=plot1D_hists.at(hist_num); - if(anglePlot) - h->SetData(histNBins,histXAngleAxis,histYAngleAxis); - else - h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num)); + if(histNBins){ + Clear1DPlot(); + plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); + plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); + for(int hist_num=0;hist_num<(int)nHists;hist_num++){ + SlsQtH1D* h; + if(hist_num+1>plot1D_hists.size()){ + if(anglePlot) + plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAngleAxis,histYAngleAxis)); + else + plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAxis,GetHistYAxis(hist_num))); + h->SetLineColor(hist_num+1); + }else{ + h=plot1D_hists.at(hist_num); + if(anglePlot) + h->SetData(histNBins,histXAngleAxis,histYAngleAxis); + else + h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num)); + } + SetStyle(h); + h->setTitle(GetHistTitle(hist_num)); + h->Attach(plot1D); } - SetStyle(h); - h->setTitle(GetHistTitle(hist_num)); - h->Attach(plot1D); + // update range if required + if(XYRangeChanged){ + if(!IsXYRange[qDefs::XMINIMUM]) XYRangeValues[qDefs::XMINIMUM]= plot1D->GetXMinimum(); + if(!IsXYRange[qDefs::XMAXIMUM]) XYRangeValues[qDefs::XMAXIMUM]= plot1D->GetXMaximum(); + if(!IsXYRange[qDefs::YMINIMUM]) XYRangeValues[qDefs::YMINIMUM]= plot1D->GetYMinimum(); + if(!IsXYRange[qDefs::YMAXIMUM]) XYRangeValues[qDefs::YMAXIMUM]= plot1D->GetYMaximum(); + plot1D->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); + plot1D->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); + XYRangeChanged = false; + } + if(saveAll) SavePlotAutomatic(); + } + } + }//2-d plot stuff + else{ + if(lastImageArray){ + if(lastImageNumber&&last_plot_number!=(int)lastImageNumber && //there is a new plot + nPixelsX>0&&nPixelsY>0){ + cout<<"startpixel:"<GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,-0.5,nPixelsY-0.5,lastImageArray); + plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,lastImageArray); + plot2D->setTitle(GetImageTitle()); + plot2D->SetXTitle(imageXAxisTitle); + plot2D->SetYTitle(imageYAxisTitle); + plot2D->SetZTitle(imageZAxisTitle); + plot2D->UpdateNKeepSetRangeIfSet(); //this will keep a "set" z range, and call Plot()->Update(); } // update range if required if(XYRangeChanged){ - if(!IsXYRange[qDefs::XMINIMUM]) XYRangeValues[qDefs::XMINIMUM]= plot1D->GetXMinimum(); - if(!IsXYRange[qDefs::XMAXIMUM]) XYRangeValues[qDefs::XMAXIMUM]= plot1D->GetXMaximum(); - if(!IsXYRange[qDefs::YMINIMUM]) XYRangeValues[qDefs::YMINIMUM]= plot1D->GetYMinimum(); - if(!IsXYRange[qDefs::YMAXIMUM]) XYRangeValues[qDefs::YMAXIMUM]= plot1D->GetYMaximum(); - plot1D->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); - plot1D->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); + if(!IsXYRange[qDefs::XMINIMUM]) XYRangeValues[qDefs::XMINIMUM]= plot2D->GetPlot()->GetXMinimum(); + if(!IsXYRange[qDefs::XMAXIMUM]) XYRangeValues[qDefs::XMAXIMUM]= plot2D->GetPlot()->GetXMaximum(); + if(!IsXYRange[qDefs::YMINIMUM]) XYRangeValues[qDefs::YMINIMUM]= plot2D->GetPlot()->GetYMinimum(); + if(!IsXYRange[qDefs::YMAXIMUM]) XYRangeValues[qDefs::YMAXIMUM]= plot2D->GetPlot()->GetYMaximum(); + plot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); + plot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); XYRangeChanged = false; } if(saveAll) SavePlotAutomatic(); } } - }//2-d plot stuff - else{ - if(lastImageArray){ - if(lastImageNumber&&last_plot_number!=(int)lastImageNumber && //there is a new plot - nPixelsX>0&&nPixelsY>0){ - cout<<"startpixel:"<GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,-0.5,nPixelsY-0.5,lastImageArray); - plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,lastImageArray); - plot2D->setTitle(GetImageTitle()); - plot2D->SetXTitle(imageXAxisTitle); - plot2D->SetYTitle(imageYAxisTitle); - plot2D->SetZTitle(imageZAxisTitle); - plot2D->UpdateNKeepSetRangeIfSet(); //this will keep a "set" z range, and call Plot()->Update(); - } - // update range if required - if(XYRangeChanged){ - if(!IsXYRange[qDefs::XMINIMUM]) XYRangeValues[qDefs::XMINIMUM]= plot2D->GetPlot()->GetXMinimum(); - if(!IsXYRange[qDefs::XMAXIMUM]) XYRangeValues[qDefs::XMAXIMUM]= plot2D->GetPlot()->GetXMaximum(); - if(!IsXYRange[qDefs::YMINIMUM]) XYRangeValues[qDefs::YMINIMUM]= plot2D->GetPlot()->GetYMinimum(); - if(!IsXYRange[qDefs::YMAXIMUM]) XYRangeValues[qDefs::YMAXIMUM]= plot2D->GetPlot()->GetYMaximum(); - plot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); - plot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); - XYRangeChanged = false; - } - if(saveAll) SavePlotAutomatic(); - } + //} + last_plot_number=lastImageNumber; + + //set plot title + boxPlot->setTitle(plotTitle); } + UnlockLastImageArray(); } - last_plot_number=lastImageNumber; - - //set plot title - boxPlot->setTitle(plotTitle); - - if(plotEnable) UnlockLastImageArray(); - //if acqq stopped before this line, it continues from here, shouldnt restart plotting timer if(!stop_signal){ @@ -1042,15 +1044,16 @@ void qDrawPlot::ClonePlot(){ } if(found) winClone[i]->SetRange(IsXYRange,XYRangeValues); //copy data - LockLastImageArray(); + //LockLastImageArray(); if(!anglePlot) winClone[i]->SetCloneHists((int)nHists,histNBins,histXAxis,histYAxis,histTitle,lines,markers); else winClone[i]->SetCloneHists((int)nHists,histNBins,histXAngleAxis,histYAngleAxis,histTitle,lines,markers); - UnlockLastImageArray(); + //UnlockLastImageArray(); } } else{ + plot2D = new SlsQt2DPlotLayout(boxPlot); plot2D->setFont(QFont("Sans Serif",9,QFont::Normal)); plot2D->setTitle(GetImageTitle()); diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index 28a752a90..595251712 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -310,7 +310,12 @@ void qTabMeasurement::startStopAcquisition(){ emit StopSignal(); myDet->stopAcquisition(); progressTimer->stop(); - spinIndex->setValue(myPlot->GetFileIndex()); + //spin index + disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + spinIndex->setValue(myDet->getFileIndex()); + lblProgressIndex->setText(QString::number(spinIndex->value())); + connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + btnStartStop->setText("Start"); btnStartStop->setIcon(*iconStart); btnStartStop->setChecked(false); @@ -330,8 +335,14 @@ void qTabMeasurement::UpdateFinished(){ btnStartStop->setChecked(false); Enable(1); connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); + UpdateProgress(); - spinIndex->setValue(myPlot->GetFileIndex()); + //spin index + disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + spinIndex->setValue(myDet->getFileIndex()); + lblProgressIndex->setText(QString::number(spinIndex->value())); + connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + progressTimer->stop(); } } @@ -352,7 +363,7 @@ void qTabMeasurement::SetCurrentMeasurement(int val){ void qTabMeasurement::UpdateProgress(){ progressBar->setValue((int)myPlot->GetProgress()); - lblProgressIndex->setText(QString::number(myPlot->GetFileIndex())); + lblProgressIndex->setText(QString::number(myPlot->GetFileIndex()+1)); }