From bd47c969ddde85a620115cf4f168d0aa0dccea77 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Mon, 9 Mar 2020 12:49:24 +0100 Subject: [PATCH] WIP --- .../slsDetectorPlotting/src/SlsQt1DPlot.cxx | 22 +++---- .../slsDetectorPlotting/src/SlsQt2DHist.cxx | 4 +- slsDetectorGui/src/qCloneWidget.cpp | 8 +-- slsDetectorGui/src/qDrawPlot.cpp | 58 ++++++++----------- slsDetectorGui/src/qTabDataOutput.cpp | 1 - slsDetectorGui/src/qTabDebugging.cpp | 4 -- slsDetectorGui/src/qTabMeasurement.cpp | 1 - slsDetectorGui/src/qTabMessages.cpp | 3 +- slsDetectorGui/src/qTabPlot.cpp | 3 +- slsDetectorGui/src/qTabSettings.cpp | 3 - 10 files changed, 42 insertions(+), 65 deletions(-) diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx index 7159375a9..1220275bc 100755 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx @@ -39,11 +39,11 @@ void SlsQtH1D::Initailize() { } SlsQtH1D::~SlsQtH1D() { - if (x) + delete [] x; - if (y) + delete [] y; - if (pen_ptr) + delete pen_ptr; } @@ -210,9 +210,9 @@ int SlsQtH1D::SetUpArrays(int n) { if (n + 1 > n_array) { n_array = n + 1; - if (x) + delete x; - if (y) + delete y; x = new double[n_array]; y = new double[n_array]; @@ -276,7 +276,7 @@ SlsQtH1DList::SlsQtH1DList(SlsQtH1D *hist) { } SlsQtH1DList::~SlsQtH1DList() { - if (the_next) + delete the_next; } @@ -352,15 +352,15 @@ SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) { } SlsQt1DPlot::~SlsQt1DPlot() { - if (hist_list) + delete hist_list; - if (hline) + delete hline; - if (vline) + delete vline; - if (zoomer) + delete zoomer; - if (panner) + delete panner; } diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DHist.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DHist.cxx index 48c410df2..d96fc248d 100755 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DHist.cxx +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DHist.cxx @@ -20,7 +20,7 @@ SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy, doubl } -SlsQt2DHist::~SlsQt2DHist(){if(data) delete [] data;} +SlsQt2DHist::~SlsQt2DHist(){ delete [] data;} int SlsQt2DHist::GetBinIndex(int bx, int by){ int b = bx*ny+by; @@ -65,7 +65,7 @@ void SlsQt2DHist::SetData(int nbinsx, double xmin, double xmax, int nbinsy,doubl } if(nbinsx*nbinsy>nx_array*ny_array){ - if(data) delete [] data; + delete [] data; data = new double [nbinsx*nbinsy+1]; //one for under/overflow bin nx_array = nbinsx; ny_array = nbinsy; diff --git a/slsDetectorGui/src/qCloneWidget.cpp b/slsDetectorGui/src/qCloneWidget.cpp index 148b0d4dc..d9130be6a 100755 --- a/slsDetectorGui/src/qCloneWidget.cpp +++ b/slsDetectorGui/src/qCloneWidget.cpp @@ -22,13 +22,13 @@ qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot* p1, SlsQt2DPlot* p2, Sl } qCloneWidget::~qCloneWidget() { - if (plot1d) + delete plot1d; - if (plot2d) + delete plot2d; - if (gainplot1d) + delete gainplot1d; - if (gainplot2d) + delete gainplot2d; } diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 3b7d3c5c5..171b69f33 100755 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -20,39 +20,27 @@ qDrawPlot::qDrawPlot(QWidget *parent, sls::Detector *detector) : QWidget(parent) } qDrawPlot::~qDrawPlot() { - DetachHists(); for (QVector::iterator h = hists1d.begin(); - h != hists1d.end(); ++h) - delete *h; + h != hists1d.end(); ++h){ + delete *h; + } + hists1d.clear(); - - if (datax1d) - delete [] datax1d; + delete [] datax1d; for (auto &it : datay1d) delete [] it; - if (gainDatay1d) - delete [] gainDatay1d; - if (data2d) - delete [] data2d; - if (gainData) - delete [] gainData; - - if (plot1d) - delete plot1d; - if (gainhist1d) - delete gainhist1d; - if (gainplot1d) - delete gainplot1d; - if (plot2d) - delete plot2d; - if (gainplot2d) - delete gainplot2d; - - if (pedestalVals) - delete [] pedestalVals; - if (tempPedestalVals) - delete [] tempPedestalVals; + + delete [] gainDatay1d; + delete [] data2d; + delete [] gainData; + delete plot1d; + delete gainhist1d; + delete gainplot1d; + delete plot2d; + delete gainplot2d; + delete [] pedestalVals; + delete [] tempPedestalVals; } void qDrawPlot::SetupWidgetWindow() { @@ -127,7 +115,7 @@ void qDrawPlot::SetupPlots() { widgetStatistics->hide(); // setup 1d data - if (datax1d) + delete[] datax1d; datax1d = new double[nPixelsX]; if (datay1d.size()) { @@ -160,7 +148,7 @@ void qDrawPlot::SetupPlots() { h->Attach(plot1d); plot1d->hide(); - if (gainDatay1d) + delete[] gainDatay1d; gainDatay1d = new double[nPixelsX]; // default display data @@ -189,7 +177,7 @@ void qDrawPlot::SetupPlots() { gainplot1d->hide(); // setup 2d data - if (data2d) + delete [] data2d; data2d = new double[nPixelsY * nPixelsX]; for (unsigned int px = 0; px < nPixelsX; ++px) @@ -199,7 +187,7 @@ void qDrawPlot::SetupPlots() { pow(nPixelsX / 2, 2) / pow(1 + 1, 2) + pow(double(py) - nPixelsY / 2, 2) / pow(nPixelsY / 2, 2)) / sqrt(2); - if (gainData) + delete [] gainData; gainData = new double[nPixelsY * nPixelsX]; for (unsigned int px = 0; px < nPixelsX; ++px) @@ -714,7 +702,7 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra nPixelsX = data->nx; nPixelsY = data->ny; FILE_LOG(logINFO) << "Change in Detector Shape:\n\tnPixelsX:" << nPixelsX << " nPixelsY:" << nPixelsY; - if (data2d) + delete [] data2d; data2d = new double[nPixelsY * nPixelsX]; std::fill(data2d, data2d + nPixelsX * nPixelsY, 0); @@ -742,11 +730,11 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra // reset pedestal if (resetPedestal) { pedestalCount = 0; - if (pedestalVals != nullptr) + delete [] pedestalVals; pedestalVals = new double[nPixels]; std::fill(pedestalVals, pedestalVals + nPixels, 0); - if (tempPedestalVals != nullptr) + delete [] tempPedestalVals; tempPedestalVals = new double[nPixels]; std::fill(tempPedestalVals, tempPedestalVals + nPixels, 0); diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp index 49df19c0b..b12084cb5 100755 --- a/slsDetectorGui/src/qTabDataOutput.cpp +++ b/slsDetectorGui/src/qTabDataOutput.cpp @@ -17,7 +17,6 @@ qTabDataOutput::qTabDataOutput(QWidget *parent, sls::Detector *detector) : QWidg } qTabDataOutput::~qTabDataOutput() { - if (btnGroupRate) delete btnGroupRate; } diff --git a/slsDetectorGui/src/qTabDebugging.cpp b/slsDetectorGui/src/qTabDebugging.cpp index 30844a861..9fe7114b0 100755 --- a/slsDetectorGui/src/qTabDebugging.cpp +++ b/slsDetectorGui/src/qTabDebugging.cpp @@ -17,13 +17,9 @@ qTabDebugging::qTabDebugging(QWidget *parent, sls::Detector *detector) : } qTabDebugging::~qTabDebugging() { - if (treeDet) delete treeDet; - if (lblDetectorHostname) delete lblDetectorHostname; - if (lblDetectorFirmware) delete lblDetectorFirmware; - if (lblDetectorSoftware) delete lblDetectorSoftware; } diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index cfd1698d1..702f5ebb3 100755 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -18,7 +18,6 @@ qTabMeasurement::qTabMeasurement(QWidget *parent, sls::Detector *detector, qDraw } qTabMeasurement::~qTabMeasurement() { - if (progressTimer) delete progressTimer; } diff --git a/slsDetectorGui/src/qTabMessages.cpp b/slsDetectorGui/src/qTabMessages.cpp index 397cb7c60..a813c5d7b 100755 --- a/slsDetectorGui/src/qTabMessages.cpp +++ b/slsDetectorGui/src/qTabMessages.cpp @@ -19,8 +19,7 @@ qTabMessages::qTabMessages(QWidget *parent) : QWidget(parent) { qTabMessages::~qTabMessages() { process->close(); - if (process) - delete process; + delete process; } void qTabMessages::SetupWidgetWindow() { diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index 83703e364..f6d23bbec 100755 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -27,8 +27,7 @@ qTabPlot::qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p) : } qTabPlot::~qTabPlot() { - if (btnGroupPlotType) - delete btnGroupPlotType; + delete btnGroupPlotType; } void qTabPlot::SetupWidgetWindow() { diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index 59172de8f..6d4ddad93 100755 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -40,12 +40,9 @@ void qTabSettings::SetupWidgetWindow() { SetupDetectorSettings(); } spinThreshold->setValue(-1); - Initialization(); - // default for the disabled GetDynamicRange(); - Refresh(); }