From 409519a3db81db65f162d8629cca06ba61f9f4fd Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Mon, 13 Nov 2017 15:25:49 +0100 Subject: [PATCH] fixed the double plot due to unzooming in gui --- .../slsDetectorPlotting/include/SlsQt2DPlot.h | 2 +- .../slsDetectorPlotting/src/SlsQt2DPlot.cxx | 4 ++-- slsDetectorGui/src/qDrawPlot.cpp | 19 +++++++++++-------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h index 967eb68fe..8b1944392 100644 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h +++ b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h @@ -68,7 +68,7 @@ public: SlsQt2DPlot(QWidget * = NULL); // SlsQt2DHist *GetHistogram(){ return hist; } - void UnZoom(); + void UnZoom(bool replot=true); void SetZoom(double xmin,double ymin,double x_width,double y_width); diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx index 5875806e2..d45ddc578 100644 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx @@ -164,13 +164,13 @@ void SlsQt2DPlot::SetupZoom(){ //replot(); }*/ -void SlsQt2DPlot::UnZoom(){ +void SlsQt2DPlot::UnZoom(bool replot){ #if QWT_VERSION<0x060000 zoomer->setZoomBase(QwtDoubleRect(hist->GetXMin(),hist->GetYMin(),hist->GetXMax()-hist->GetXMin(),hist->GetYMax()-hist->GetYMin())); #else zoomer->setZoomBase(QRectF(hist->GetXMin(),hist->GetYMin(),hist->GetXMax()-hist->GetXMin(),hist->GetYMax()-hist->GetYMin())); #endif - zoomer->setZoomBase();//Call replot for the attached plot before initializing the zoomer with its scales. + zoomer->setZoomBase(replot);//Call replot for the attached plot before initializing the zoomer with its scales. // zoomer->zoom(0); } diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index b6fa8795e..dcbb55377 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -487,7 +487,10 @@ bool qDrawPlot::StartOrStopThread(bool start){ plot2D->GetPlot()->SetXMinMax(-0.5,nPixelsX+0.5); plot2D->GetPlot()->SetYMinMax(startPixel,endPixel); plot2D->GetPlot()->SetZoom(-0.5,startPixel,nPixelsX,endPixel-startPixel); - plot2D->GetPlot()->UnZoom(); + if (boxPlot->title() == "Sample Plot") + plot2D->GetPlot()->UnZoom(); + else + plot2D->GetPlot()->UnZoom(false); /*XYRangeChanged = true;*/ boxPlot->setTitle("Old_Plot.raw"); @@ -856,13 +859,13 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){ memcpy(histYAngleAxis,data->values,nAnglePixelsX*sizeof(double)); SetHistXAxisTitle("Angles"); } + plotRequired = true; UnlockLastImageArray(); currentFrame++; #ifdef VERYVERBOSE cout << "Exiting GetData Function " << endl; #endif emit UpdatePlotSignal(); - plotRequired = true; return 0; } @@ -906,11 +909,11 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){ imageTitle = temp_title; //copy data memcpy(lastImageArray+(currentScanDivLevel*nPixelsX),data->values,nPixelsX*sizeof(double)); + plotRequired = true; UnlockLastImageArray(); currentFrame++; currentScanDivLevel++; emit UpdatePlotSignal(); - plotRequired = true; return 0; } //file index @@ -925,11 +928,11 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){ imageTitle = temp_title; //copy data for(unsigned int px=0;pxvalues[px]; + plotRequired = true; UnlockLastImageArray(); currentFrame++; currentScanDivLevel++; emit UpdatePlotSignal(); - plotRequired = true; return 0; } //level0 @@ -951,10 +954,10 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){ imageTitle = temp_title; //copy data for(unsigned int px=0;pxvalues[px]; + plotRequired = true; UnlockLastImageArray(); currentFrame++; emit UpdatePlotSignal(); - plotRequired = true; return 0; } //level1 @@ -976,10 +979,10 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){ imageTitle = temp_title; //copy data for(unsigned int px=0;pxvalues[px]; + plotRequired = true; UnlockLastImageArray(); currentFrame++; emit UpdatePlotSignal(); - plotRequired = true; return 0; } @@ -1169,14 +1172,14 @@ int qDrawPlot::GetData(detectorData *data,int fIndex, int subIndex){ } /* pthread_mutex_unlock(&(last_image_complete_mutex)); }*/ + plotRequired = true; UnlockLastImageArray(); #ifdef VERYVERBOSE cprintf(BLUE,"currentframe:%d \tcurrentframeindex:%d\n",currentFrame,currentFrameIndex); #endif - emit UpdatePlotSignal(); - plotRequired = true; currentFrame++; + emit UpdatePlotSignal(); }