diff --git a/slsDetectorGui/include/qDetectorMain.h b/slsDetectorGui/include/qDetectorMain.h index d139fa8f3..ba4c31d13 100644 --- a/slsDetectorGui/include/qDetectorMain.h +++ b/slsDetectorGui/include/qDetectorMain.h @@ -29,7 +29,7 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject { Q_OBJECT public: - qDetectorMain(int multiId, std::string fname, bool isDevel); + qDetectorMain(int multiId, const std::string& fname, bool isDevel); ~qDetectorMain(); private slots: @@ -51,9 +51,9 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject { private: void SetUpWidgetWindow(); - void SetUpDetector(const std::string fName, int multiID); + void SetUpDetector(const std::string& config_file, int multiID); void Initialization(); - void LoadConfigFile(const std::string fName); + void LoadConfigFile(const std::string& config_file); /** enumeration of the tabs */ enum { diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cpp b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cpp index 34ec7a218..efb001407 100644 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cpp +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cpp @@ -270,7 +270,7 @@ SlsQtH1D *SlsQtH1D::Add(double v) { // 1d hist list stuff SlsQtH1DList::SlsQtH1DList(SlsQtH1D *hist) { the_hist = hist; - the_next = 0; + the_next = nullptr; } SlsQtH1DList::~SlsQtH1DList() { delete the_next; } @@ -314,12 +314,12 @@ void SlsQtH1DList::Remove(SlsQtH1D *hist) { hl = hl->the_next; else { // match if (!hl->the_next) - hl->the_hist = 0; // first the_hist is zero when there's no next + hl->the_hist = nullptr; // first the_hist is zero when there's no next else { SlsQtH1DList *t = hl->the_next; hl->the_hist = t->the_hist; hl->the_next = t->the_next; - t->the_next = 0; + t->the_next = nullptr; delete t; } } @@ -329,7 +329,7 @@ void SlsQtH1DList::Remove(SlsQtH1D *hist) { // 1d plot stuff SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) { // n_histograms_attached=0; - hline = vline = 0; + hline = vline = nullptr; hist_list = new SlsQtH1DList(); UnknownStuff(); @@ -459,7 +459,7 @@ void SlsQt1DPlot::RemoveHLine() { if (hline) hline->detach(); delete hline; - hline = 0; + hline = nullptr; } void SlsQt1DPlot::InsertHLine(double y) { @@ -476,7 +476,7 @@ void SlsQt1DPlot::RemoveVLine() { if (vline) vline->detach(); delete vline; - vline = 0; + vline = nullptr; } void SlsQt1DPlot::InsertVLine(double x) { diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DHist.cpp b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DHist.cpp index a5c0f0c55..dc8e6dcbb 100644 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DHist.cpp +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DHist.cpp @@ -17,7 +17,7 @@ SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy, y_max = 0; interp = 0; nx_array = ny_array = 0; - data = 0; + data = nullptr; SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d, zmin, zmax); } diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cpp b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cpp index 90ae057ae..daa1e156b 100644 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cpp +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cpp @@ -31,17 +31,7 @@ SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) { Update(); } -SlsQt2DPlot::~SlsQt2DPlot() { - if (d_spectrogram) { - d_spectrogram->detach(); - // delete d_spectrogram; - } - delete hist; - delete colorMapLinearScale; - delete colorMapLogScale; - delete zoomer; - delete panner; -} +SlsQt2DPlot::~SlsQt2DPlot() = default; void SlsQt2DPlot::SetTitle(QString title) { setTitle(title); } @@ -104,8 +94,8 @@ void SlsQt2DPlot::SetupColorMap() { void SlsQt2DPlot::FillTestPlot(int mode) { static int nx = 50; static int ny = 50; - static double *the_data = 0; - if (the_data == 0) + static double *the_data = nullptr; + if (the_data == nullptr) the_data = new double[nx * ny]; double dmax = sqrt(pow(nx / 2.0 - 0.5, 2) + pow(ny / 2.0 - 0.5, 2)); @@ -221,33 +211,24 @@ QwtLinearColorMap *SlsQt2DPlot::myColourMap(QVector colourStops) { for (int is = 0; is < ns - 1; is++) { c.setRgbF(r[is], g[is], b[is]); - copyMap->addColorStop(colourStops.value(is), c); + copyMap->addColorStop(colourStops[is], c); } return copyMap; } + QwtLinearColorMap *SlsQt2DPlot::myColourMap(int log) { - - int ns = 5; - - QVector cs1(0); - QVector lcs1(0); - - cs1.append(0.); - cs1.append(0.34); - cs1.append(0.61); - cs1.append(0.84); - cs1.append(1.); + QVector cs1{0.0, 0.34, 0.61 ,0.84, 1.0}; if (log) { - for (int is = 0; is < ns; is++) { - lcs1.append((pow(10, 2 * cs1.value(is)) - 1) / 99.0); - } + QVector lcs1(cs1.size()); + for (int i = 0; i < cs1.size(); ++i) + lcs1[i] = (pow(10, 2 * cs1[i]) - 1) / 99.0; return myColourMap(lcs1); } - return myColourMap(cs1); } + void SlsQt2DPlot::Update() { if (isLog) hist->SetMinimumToFirstGreaterThanZero(); diff --git a/slsDetectorGui/src/qCloneWidget.cpp b/slsDetectorGui/src/qCloneWidget.cpp index 8c04249d7..c83c8f68a 100644 --- a/slsDetectorGui/src/qCloneWidget.cpp +++ b/slsDetectorGui/src/qCloneWidget.cpp @@ -109,7 +109,7 @@ void qCloneWidget::SavePlot() { fName = QFileDialog::getSaveFileName( this, tr("Save Snapshot "), fName, - tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), 0, + tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), nullptr, QFileDialog::ShowDirsOnly); if (!fName.isEmpty()) { if ((img.save(fName))) { diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index 17692763c..e3d8d03dd 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -26,7 +26,7 @@ int main(int argc, char **argv) { // options - std::string fname = ""; + std::string fname; bool isDeveloper = false; int64_t tempval = 0; int multiId = 0; @@ -36,12 +36,12 @@ int main(int argc, char **argv) { // These options set a flag. //{"verbose", no_argument, &verbose_flag, 1}, // These options don’t set a flag. We distinguish them by their indices. - {"developer", no_argument, 0, 'd'}, - {"config", required_argument, 0, 'f'}, - {"id", required_argument, 0, 'i'}, - {"version", no_argument, 0, 'v'}, - {"help", no_argument, 0, 'h'}, - {0, 0, 0, 0}}; + {"developer", no_argument, nullptr, 'd'}, + {"config", required_argument, nullptr, 'f'}, + {"id", required_argument, nullptr, 'i'}, + {"version", no_argument, nullptr, 'v'}, + {"help", no_argument, nullptr, 'h'}, + {nullptr, 0, nullptr, 0}}; // getopt_long stores the option index here optind = 1; @@ -93,8 +93,7 @@ int main(int argc, char **argv) { } QApplication app(argc, argv); - app.setStyle(new QPlastiqueStyle); - // app.setWindowIcon(QIcon(":/icons/images/mountain.png")); + app.setStyle(new QPlastiqueStyle); //style is deleted by QApplication try { qDetectorMain det(multiId, fname, isDeveloper); det.show(); @@ -106,8 +105,8 @@ int main(int argc, char **argv) { return 0; } -qDetectorMain::qDetectorMain(int multiId, std::string fname, bool isDevel) - : QMainWindow(0), detType(slsDetectorDefs::GENERIC), isDeveloper(isDevel), +qDetectorMain::qDetectorMain(int multiId, const std::string& fname, bool isDevel) + : QMainWindow(nullptr), detType(slsDetectorDefs::GENERIC), isDeveloper(isDevel), heightPlotWindow(0), heightCentralWidget(0) { setupUi(this); @@ -115,7 +114,7 @@ qDetectorMain::qDetectorMain(int multiId, std::string fname, bool isDevel) SetUpWidgetWindow(); } -qDetectorMain::~qDetectorMain() {} +qDetectorMain::~qDetectorMain() = default; void qDetectorMain::SetUpWidgetWindow() { setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); @@ -204,7 +203,7 @@ void qDetectorMain::SetUpWidgetWindow() { Initialization(); } -void qDetectorMain::SetUpDetector(const std::string fName, int multiID) { +void qDetectorMain::SetUpDetector(const std::string& config_file, int multiID) { // instantiate detector and set window title det = sls::make_unique(multiID); @@ -213,8 +212,8 @@ void qDetectorMain::SetUpDetector(const std::string fName, int multiID) { tabMessages = sls::make_unique(this); // loads the config file at startup - if (!fName.empty()) - LoadConfigFile(fName); + if (!config_file.empty()) + LoadConfigFile(config_file); // validate detector type (for GUI) and update menu detType = det->getDetectorType().tsquash( @@ -282,20 +281,20 @@ void qDetectorMain::Initialization() { SLOT(ExecuteHelp(QAction *))); } -void qDetectorMain::LoadConfigFile(const std::string fName) { +void qDetectorMain::LoadConfigFile(const std::string& config_file) { - FILE_LOG(logINFO) << "Loading config file at start up:" << fName; + FILE_LOG(logINFO) << "Loading config file at start up:" << config_file; struct stat st_buf; - QString file = QString(fName.c_str()); + QString file = QString(config_file.c_str()); // path doesnt exist - if (stat(fName.c_str(), &st_buf)) { + if (stat(config_file.c_str(), &st_buf)) { qDefs::Message( qDefs::WARNING, std::string("Start up configuration failed to load. The " "following file does not exist:
") + - fName, + config_file, "qDetectorMain::LoadConfigFile"); FILE_LOG(logWARNING) << "Config file does not exist"; } @@ -306,12 +305,12 @@ void qDetectorMain::LoadConfigFile(const std::string fName) { std::string( "Start up configuration failed to load. The following " "file is not a recognized file format:
") + - fName, + config_file, "qDetectorMain::LoadConfigFile"); FILE_LOG(logWARNING) << "File not recognized"; } else { try { - det->loadConfig(fName); + det->loadConfig(config_file); } CATCH_DISPLAY("Could not load config file.", "qDetectorMain::LoadConfigFile") diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 6e9c799c1..dfbc103b1 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -598,8 +598,8 @@ void qDrawPlot::SavePlot() { QString(".png"); fName = QFileDialog::getSaveFileName( - 0, tr("Save Image"), fName, - tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), 0, + nullptr, tr("Save Image"), fName, + tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), nullptr, QFileDialog::ShowDirsOnly); if (!fName.isEmpty()) { @@ -1068,7 +1068,7 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, detType == slsDetectorDefs::GOTTHARD2) { // show gain plot - if (gaindest != NULL) { + if (gaindest != nullptr) { for (ichan = 0; ichan < size; ++ichan) { uint16_t temp = (*((u_int16_t *)source)); gaindest[ichan] = ((temp & gainMask) >> gainOffset); diff --git a/slsDetectorGui/src/qTabDebugging.cpp b/slsDetectorGui/src/qTabDebugging.cpp index d81684ef1..63f169d86 100644 --- a/slsDetectorGui/src/qTabDebugging.cpp +++ b/slsDetectorGui/src/qTabDebugging.cpp @@ -106,13 +106,13 @@ void qTabDebugging::GetInfo() { // get num modules for (int i = 0; i < comboDetector->count() / 2; ++i) items.append(new QTreeWidgetItem( - (QTreeWidget *)0, QStringList(QString("Module %1").arg(i)))); + (QTreeWidget *)nullptr, QStringList(QString("Module %1").arg(i)))); treeDet->insertTopLevelItems(0, items); // gets det names for (int i = 0; i < comboDetector->count(); ++i) { QList childItems; childItems.append(new QTreeWidgetItem( - (QTreeWidget *)0, + (QTreeWidget *)nullptr, QStringList(QString("Half Module (%1)") .arg(comboDetector->itemText(i))))); treeDet->topLevelItem(i * 2)->insertChildren(0, childItems); @@ -133,7 +133,7 @@ void qTabDebugging::GetInfo() { // gets det names for (int i = 0; i < comboDetector->count(); ++i) items.append(new QTreeWidgetItem( - (QTreeWidget *)0, + (QTreeWidget *)nullptr, QStringList( QString("Module (%1)").arg(comboDetector->itemText(i))))); treeDet->insertTopLevelItems(0, items); diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index 77afad71d..7f497ce24 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -802,7 +802,7 @@ void qTabMeasurement::Enable(bool enable) { // shortcut each time, else it doesnt work a second time btnStart->setShortcut(QApplication::translate( - "TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8)); + "TabMeasurementObject", "Shift+Space", nullptr, QApplication::UnicodeUTF8)); } void qTabMeasurement::Refresh() {