diff --git a/slsDetectorGui/forms/form_detectormain.ui b/slsDetectorGui/forms/form_detectormain.ui
index b1acaf00e..5282111a3 100755
--- a/slsDetectorGui/forms/form_detectormain.ui
+++ b/slsDetectorGui/forms/form_detectormain.ui
@@ -145,6 +145,10 @@
SLS Detector GUI
+
+
+ :/icons/images/mountain.png:/icons/images/mountain.png
+
Qt::ImhNone
@@ -416,6 +420,8 @@ p, li { white-space: pre-wrap; }
-
+
+
+
diff --git a/slsDetectorGui/include/qDetectorMain.h b/slsDetectorGui/include/qDetectorMain.h
index 6aa512cdc..0b93dac7a 100755
--- a/slsDetectorGui/include/qDetectorMain.h
+++ b/slsDetectorGui/include/qDetectorMain.h
@@ -30,8 +30,7 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
Q_OBJECT
public:
- qDetectorMain(int argc, char **argv, QApplication *app,
- QWidget *parent = 0);
+ qDetectorMain(int multiId, std::string fname, bool isDevel);
~qDetectorMain();
private slots:
diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h
index 99e86fea6..826c8ecca 100755
--- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h
+++ b/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h
@@ -77,14 +77,14 @@ class SlsQtH1D:public QwtPlotCurve{
int ndata;
int n_array;
double dx;
- double *x,*y;
+ double *x{nullptr},*y{nullptr};
double ymin,ymax;
double firstXgt0,firstYgt0;
void Initailize();
int SetUpArrays(int n);
int CheckIndex(int bx);
- QPen* pen_ptr;
+ QPen* pen_ptr{nullptr};
};
@@ -151,12 +151,12 @@ class SlsQt1DPlot:public QwtPlot{
void SetLogY(bool yes=1);
private:
- SlsQtH1DList* hist_list;
- SlsQt1DZoomer* zoomer;
- QwtPlotPanner* panner;
+ SlsQtH1DList* hist_list{nullptr};
+ SlsQt1DZoomer* zoomer{nullptr};
+ QwtPlotPanner* panner{nullptr};
- QwtPlotMarker *hline;
- QwtPlotMarker *vline;
+ QwtPlotMarker *hline{nullptr};
+ QwtPlotMarker *vline{nullptr};
bool disableZoom{false};
int ystep{0};
diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h
index 2def642f7..144bd1296 100755
--- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h
+++ b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h
@@ -20,7 +20,7 @@ class SlsQt2DPlot: public QwtPlot{
public:
SlsQt2DPlot(QWidget * = NULL);
-
+ ~SlsQt2DPlot();
void SetTitle(QString title);
void SetXTitle(QString title);
void SetYTitle(QString title);
@@ -77,17 +77,17 @@ private:
QwtLinearColorMap* myColourMap(QVector colourStops);
QwtLinearColorMap* myColourMap(int log=0);
- QwtPlotSpectrogram *d_spectrogram;
- SlsQt2DHist* hist;
- SlsQt2DZoomer* zoomer;
- QwtPlotPanner* panner;
- QwtScaleWidget *rightAxis;
+ QwtPlotSpectrogram *d_spectrogram{nullptr};
+ SlsQt2DHist* hist{nullptr};
+ SlsQt2DZoomer* zoomer{nullptr};
+ QwtPlotPanner* panner{nullptr};
+ QwtScaleWidget *rightAxis{nullptr};
- QwtLinearColorMap* colorMapLinearScale;
- QwtLinearColorMap* colorMapLogScale;
+ QwtLinearColorMap* colorMapLinearScale{nullptr};
+ QwtLinearColorMap* colorMapLogScale{nullptr};
#if QWT_VERSION<0x060000
- QwtValueList* contourLevelsLinear;
- QwtValueList* contourLevelsLog;
+ QwtValueList* contourLevelsLinear{nullptr};
+ QwtValueList* contourLevelsLog{nullptr};
#else
QList contourLevelsLinear;
QList contourLevelsLog;
diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx
index 86f5542b6..54045005d 100755
--- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx
+++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx
@@ -21,7 +21,7 @@
#define QwtLog10ScaleEngine QwtLogScaleEngine
#endif
-SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data) : QwtPlotCurve(title) {
+SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data) : QwtPlotCurve(title), x(nullptr), y(nullptr), pen_ptr(nullptr) {
Initailize();
SetData(n, min, max, data);
}
@@ -33,15 +33,18 @@ SlsQtH1D::SlsQtH1D(QString title, int n, double *data_x, double *data_y) : QwtPl
void SlsQtH1D::Initailize() {
ndata = n_array = 0;
- x = y = 0;
+ x = y = nullptr;
pen_ptr = new QPen();
SetLineColor();
}
SlsQtH1D::~SlsQtH1D() {
- delete x;
- delete y;
- delete pen_ptr;
+ if (x)
+ delete [] x;
+ if (y)
+ delete [] y;
+ if (pen_ptr)
+ delete pen_ptr;
}
void SlsQtH1D::Attach(SlsQt1DPlot *p) {
@@ -358,12 +361,16 @@ SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) {
}
SlsQt1DPlot::~SlsQt1DPlot() {
- delete hist_list;
-
+ if (hist_list)
+ delete hist_list;
if (hline)
delete hline;
if (vline)
delete vline;
+ if (zoomer)
+ delete zoomer;
+ if (panner)
+ delete panner;
}
void SlsQt1DPlot::CalculateNResetZoomBase() {
diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx
index cd87aff9c..ee6749f45 100755
--- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx
+++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx
@@ -52,6 +52,30 @@ SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
}
+SlsQt2DPlot::~SlsQt2DPlot() {
+ if (d_spectrogram) {
+ d_spectrogram->detach();
+ }
+ if (hist)
+ delete hist;
+ if (colorMapLinearScale)
+ delete colorMapLinearScale;
+ if (colorMapLogScale)
+ delete colorMapLogScale;
+
+
+ if (zoomer)
+ delete zoomer;
+ if (panner)
+ delete panner;
+#if QWT_VERSION<0x060000
+ if (contourLevelsLinear)
+ delete contourLevelsLinear;
+ if (contourLevelsLog)
+ delete contourLevelsLog;
+#endif
+}
+
void SlsQt2DPlot::SetTitle(QString title) {
setTitle(title);
}
@@ -94,7 +118,7 @@ void SlsQt2DPlot::SetZFont(const QFont& f) {
}
void SlsQt2DPlot::SetupColorMap() {
-
+
colorMapLinearScale = myColourMap(0);
#if QWT_VERSION < 0x060000
d_spectrogram->setColorMap(*colorMapLinearScale);
diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp
index 47fda49ec..139b56729 100755
--- a/slsDetectorGui/src/qDetectorMain.cpp
+++ b/slsDetectorGui/src/qDetectorMain.cpp
@@ -26,27 +26,10 @@
#include
int main(int argc, char **argv) {
- QApplication *theApp = new QApplication(argc, argv);
- theApp->setStyle(new QPlastiqueStyle);
- theApp->setWindowIcon(QIcon(":/icons/images/mountain.png"));
- try {
- qDetectorMain *det = new qDetectorMain(argc, argv, theApp, 0);
- det->show();
- theApp->exec();
- } catch (const std::exception &e) {
- qDefs::Message(qDefs::CRITICAL,
- std::string(e.what()) + "\nExiting Gui :'( ", "main");
- }
- return 0;
-}
-
-qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app,
- QWidget *parent)
- : QMainWindow(parent), detType(slsDetectorDefs::GENERIC), isDeveloper(0),
- heightPlotWindow(0), heightCentralWidget(0) {
// options
std::string fname = "";
+ bool isDeveloper = false;
int64_t tempval = 0;
int multiId = 0;
@@ -81,7 +64,7 @@ qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app,
break;
case 'd':
- isDeveloper = 1;
+ isDeveloper = true;
break;
case 'i':
@@ -92,7 +75,7 @@ qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app,
tempval = APIGUI;
FILE_LOG(logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x"
<< std::hex << tempval << ")";
- return;
+ return 0;
case 'h':
default:
@@ -107,10 +90,29 @@ qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app,
"\t only when more than one multi "
"detector object is needed.\n\n";
FILE_LOG(logERROR) << help_message;
- exit(EXIT_FAILURE);
+ return -1;
}
}
+
+ QApplication app(argc, argv);
+ app.setStyle(new QPlastiqueStyle);
+ //app.setWindowIcon(QIcon(":/icons/images/mountain.png"));
+ try {
+ qDetectorMain det(multiId, fname, isDeveloper);
+ det.show();
+ app.exec();
+ } catch (const std::exception &e) {
+ qDefs::Message(qDefs::CRITICAL,
+ std::string(e.what()) + "\nExiting Gui :'( ", "main");
+ }
+ return 0;
+}
+
+qDetectorMain::qDetectorMain(int multiId, std::string fname, bool isDevel)
+ : QMainWindow(0), detType(slsDetectorDefs::GENERIC), isDeveloper(isDevel),
+ heightPlotWindow(0), heightCentralWidget(0) {
+
setupUi(this);
SetUpDetector(fname, multiId);
SetUpWidgetWindow();