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
This commit is contained in:
l_maliakal_d 2012-10-01 15:45:47 +00:00
parent 7eb48a300d
commit 9fc66d571e
4 changed files with 87 additions and 73 deletions

View File

@ -21,7 +21,7 @@ public:
qDefs(){}; qDefs(){};
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
#define GUI_VERSION 0.11 #define GUI_VERSION 0.12
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -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){ 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]:"<<histYAxis[0][500]<<endl; /** for each plot*/
for(int hist_num=0;hist_num<nHists;hist_num++){ for(int hist_num=0;hist_num<nHists;hist_num++){
/** create hists */ /** create hists */
SlsQtH1D* k; SlsQtH1D* k;
@ -131,7 +131,7 @@ void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,doub
void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis,string histTitle[],bool lines,bool markers){ void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis,string histTitle[],bool lines,bool markers){
/** for each plot*/cout<<"qclone angle nhists:"<<nHists<<endl; /** for each plot*/
for(int hist_num=0;hist_num<nHists;hist_num++){ for(int hist_num=0;hist_num<nHists;hist_num++){
/** create hists */ /** create hists */
SlsQtH1D* k; SlsQtH1D* k;

View File

@ -894,84 +894,86 @@ void qDrawPlot::UpdatePlot(){
// only if no plot isnt enabled // only if no plot isnt enabled
if(plotEnable){ if(plotEnable){
LockLastImageArray(); LockLastImageArray();
//1-d plot stuff //so that it doesnt plot every single thing
if(plot_in_scope==1){ if(lastImageNumber!=last_plot_number){
if(lastImageNumber){ //1-d plot stuff
if(plot_in_scope==1){
if(lastImageNumber){
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout << "Last Image Number:" << lastImageNumber << endl; cout << "Last Image Number:" << lastImageNumber << endl;
#endif #endif
if(histNBins){ if(histNBins){
Clear1DPlot(); Clear1DPlot();
plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); plot1D->SetYTitle(histYAxisTitle.toAscii().constData());
for(int hist_num=0;hist_num<(int)nHists;hist_num++){ for(int hist_num=0;hist_num<(int)nHists;hist_num++){
SlsQtH1D* h; SlsQtH1D* h;
if(hist_num+1>plot1D_hists.size()){ if(hist_num+1>plot1D_hists.size()){
if(anglePlot) if(anglePlot)
plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAngleAxis,histYAngleAxis)); plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAngleAxis,histYAngleAxis));
else else
plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAxis,GetHistYAxis(hist_num))); plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAxis,GetHistYAxis(hist_num)));
h->SetLineColor(hist_num+1); h->SetLineColor(hist_num+1);
}else{ }else{
h=plot1D_hists.at(hist_num); h=plot1D_hists.at(hist_num);
if(anglePlot) if(anglePlot)
h->SetData(histNBins,histXAngleAxis,histYAngleAxis); h->SetData(histNBins,histXAngleAxis,histYAngleAxis);
else else
h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num)); h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num));
}
SetStyle(h);
h->setTitle(GetHistTitle(hist_num));
h->Attach(plot1D);
} }
SetStyle(h); // update range if required
h->setTitle(GetHistTitle(hist_num)); if(XYRangeChanged){
h->Attach(plot1D); 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:"<<startPixel<<endl;
cout<<"endpixel:"<<endPixel<<endl;
//plot2D->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 // update range if required
if(XYRangeChanged){ if(XYRangeChanged){
if(!IsXYRange[qDefs::XMINIMUM]) XYRangeValues[qDefs::XMINIMUM]= plot1D->GetXMinimum(); if(!IsXYRange[qDefs::XMINIMUM]) XYRangeValues[qDefs::XMINIMUM]= plot2D->GetPlot()->GetXMinimum();
if(!IsXYRange[qDefs::XMAXIMUM]) XYRangeValues[qDefs::XMAXIMUM]= plot1D->GetXMaximum(); if(!IsXYRange[qDefs::XMAXIMUM]) XYRangeValues[qDefs::XMAXIMUM]= plot2D->GetPlot()->GetXMaximum();
if(!IsXYRange[qDefs::YMINIMUM]) XYRangeValues[qDefs::YMINIMUM]= plot1D->GetYMinimum(); if(!IsXYRange[qDefs::YMINIMUM]) XYRangeValues[qDefs::YMINIMUM]= plot2D->GetPlot()->GetYMinimum();
if(!IsXYRange[qDefs::YMAXIMUM]) XYRangeValues[qDefs::YMAXIMUM]= plot1D->GetYMaximum(); if(!IsXYRange[qDefs::YMAXIMUM]) XYRangeValues[qDefs::YMAXIMUM]= plot2D->GetPlot()->GetYMaximum();
plot1D->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); plot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]);
plot1D->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); plot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]);
XYRangeChanged = false; XYRangeChanged = false;
} }
if(saveAll) SavePlotAutomatic(); if(saveAll) SavePlotAutomatic();
} }
} }
}//2-d plot stuff //}
else{ last_plot_number=lastImageNumber;
if(lastImageArray){
if(lastImageNumber&&last_plot_number!=(int)lastImageNumber && //there is a new plot //set plot title
nPixelsX>0&&nPixelsY>0){ boxPlot->setTitle(plotTitle);
cout<<"startpixel:"<<startPixel<<endl;
cout<<"endpixel:"<<endPixel<<endl;
//plot2D->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();
}
} }
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 acqq stopped before this line, it continues from here, shouldnt restart plotting timer
if(!stop_signal){ if(!stop_signal){
@ -1042,15 +1044,16 @@ void qDrawPlot::ClonePlot(){
} }
if(found) winClone[i]->SetRange(IsXYRange,XYRangeValues); if(found) winClone[i]->SetRange(IsXYRange,XYRangeValues);
//copy data //copy data
LockLastImageArray(); //LockLastImageArray();
if(!anglePlot) if(!anglePlot)
winClone[i]->SetCloneHists((int)nHists,histNBins,histXAxis,histYAxis,histTitle,lines,markers); winClone[i]->SetCloneHists((int)nHists,histNBins,histXAxis,histYAxis,histTitle,lines,markers);
else else
winClone[i]->SetCloneHists((int)nHists,histNBins,histXAngleAxis,histYAngleAxis,histTitle,lines,markers); winClone[i]->SetCloneHists((int)nHists,histNBins,histXAngleAxis,histYAngleAxis,histTitle,lines,markers);
UnlockLastImageArray(); //UnlockLastImageArray();
} }
} }
else{ else{
plot2D = new SlsQt2DPlotLayout(boxPlot); plot2D = new SlsQt2DPlotLayout(boxPlot);
plot2D->setFont(QFont("Sans Serif",9,QFont::Normal)); plot2D->setFont(QFont("Sans Serif",9,QFont::Normal));
plot2D->setTitle(GetImageTitle()); plot2D->setTitle(GetImageTitle());

View File

@ -310,7 +310,12 @@ void qTabMeasurement::startStopAcquisition(){
emit StopSignal(); emit StopSignal();
myDet->stopAcquisition(); myDet->stopAcquisition();
progressTimer->stop(); 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->setText("Start");
btnStartStop->setIcon(*iconStart); btnStartStop->setIcon(*iconStart);
btnStartStop->setChecked(false); btnStartStop->setChecked(false);
@ -330,8 +335,14 @@ void qTabMeasurement::UpdateFinished(){
btnStartStop->setChecked(false); btnStartStop->setChecked(false);
Enable(1); Enable(1);
connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition()));
UpdateProgress(); 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(); progressTimer->stop();
} }
} }
@ -352,7 +363,7 @@ void qTabMeasurement::SetCurrentMeasurement(int val){
void qTabMeasurement::UpdateProgress(){ void qTabMeasurement::UpdateProgress(){
progressBar->setValue((int)myPlot->GetProgress()); progressBar->setValue((int)myPlot->GetProgress());
lblProgressIndex->setText(QString::number(myPlot->GetFileIndex())); lblProgressIndex->setText(QString::number(myPlot->GetFileIndex()+1));
} }