mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-12 07:30:03 +02:00
clang-tidy nullptr
This commit is contained in:
parent
ee799b540a
commit
d818e2570f
@ -29,7 +29,7 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
qDetectorMain(int multiId, std::string fname, bool isDevel);
|
qDetectorMain(int multiId, const std::string& fname, bool isDevel);
|
||||||
~qDetectorMain();
|
~qDetectorMain();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -51,9 +51,9 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void SetUpWidgetWindow();
|
void SetUpWidgetWindow();
|
||||||
void SetUpDetector(const std::string fName, int multiID);
|
void SetUpDetector(const std::string& config_file, int multiID);
|
||||||
void Initialization();
|
void Initialization();
|
||||||
void LoadConfigFile(const std::string fName);
|
void LoadConfigFile(const std::string& config_file);
|
||||||
|
|
||||||
/** enumeration of the tabs */
|
/** enumeration of the tabs */
|
||||||
enum {
|
enum {
|
||||||
|
@ -270,7 +270,7 @@ SlsQtH1D *SlsQtH1D::Add(double v) {
|
|||||||
// 1d hist list stuff
|
// 1d hist list stuff
|
||||||
SlsQtH1DList::SlsQtH1DList(SlsQtH1D *hist) {
|
SlsQtH1DList::SlsQtH1DList(SlsQtH1D *hist) {
|
||||||
the_hist = hist;
|
the_hist = hist;
|
||||||
the_next = 0;
|
the_next = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SlsQtH1DList::~SlsQtH1DList() { delete the_next; }
|
SlsQtH1DList::~SlsQtH1DList() { delete the_next; }
|
||||||
@ -314,12 +314,12 @@ void SlsQtH1DList::Remove(SlsQtH1D *hist) {
|
|||||||
hl = hl->the_next;
|
hl = hl->the_next;
|
||||||
else { // match
|
else { // match
|
||||||
if (!hl->the_next)
|
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 {
|
else {
|
||||||
SlsQtH1DList *t = hl->the_next;
|
SlsQtH1DList *t = hl->the_next;
|
||||||
hl->the_hist = t->the_hist;
|
hl->the_hist = t->the_hist;
|
||||||
hl->the_next = t->the_next;
|
hl->the_next = t->the_next;
|
||||||
t->the_next = 0;
|
t->the_next = nullptr;
|
||||||
delete t;
|
delete t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -329,7 +329,7 @@ void SlsQtH1DList::Remove(SlsQtH1D *hist) {
|
|||||||
// 1d plot stuff
|
// 1d plot stuff
|
||||||
SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) {
|
SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) {
|
||||||
// n_histograms_attached=0;
|
// n_histograms_attached=0;
|
||||||
hline = vline = 0;
|
hline = vline = nullptr;
|
||||||
hist_list = new SlsQtH1DList();
|
hist_list = new SlsQtH1DList();
|
||||||
|
|
||||||
UnknownStuff();
|
UnknownStuff();
|
||||||
@ -459,7 +459,7 @@ void SlsQt1DPlot::RemoveHLine() {
|
|||||||
if (hline)
|
if (hline)
|
||||||
hline->detach();
|
hline->detach();
|
||||||
delete hline;
|
delete hline;
|
||||||
hline = 0;
|
hline = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlsQt1DPlot::InsertHLine(double y) {
|
void SlsQt1DPlot::InsertHLine(double y) {
|
||||||
@ -476,7 +476,7 @@ void SlsQt1DPlot::RemoveVLine() {
|
|||||||
if (vline)
|
if (vline)
|
||||||
vline->detach();
|
vline->detach();
|
||||||
delete vline;
|
delete vline;
|
||||||
vline = 0;
|
vline = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlsQt1DPlot::InsertVLine(double x) {
|
void SlsQt1DPlot::InsertVLine(double x) {
|
||||||
|
@ -17,7 +17,7 @@ SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy,
|
|||||||
y_max = 0;
|
y_max = 0;
|
||||||
interp = 0;
|
interp = 0;
|
||||||
nx_array = ny_array = 0;
|
nx_array = ny_array = 0;
|
||||||
data = 0;
|
data = nullptr;
|
||||||
SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d, zmin, zmax);
|
SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d, zmin, zmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,8 +104,8 @@ void SlsQt2DPlot::SetupColorMap() {
|
|||||||
void SlsQt2DPlot::FillTestPlot(int mode) {
|
void SlsQt2DPlot::FillTestPlot(int mode) {
|
||||||
static int nx = 50;
|
static int nx = 50;
|
||||||
static int ny = 50;
|
static int ny = 50;
|
||||||
static double *the_data = 0;
|
static double *the_data = nullptr;
|
||||||
if (the_data == 0)
|
if (the_data == nullptr)
|
||||||
the_data = new double[nx * ny];
|
the_data = new double[nx * ny];
|
||||||
|
|
||||||
double dmax = sqrt(pow(nx / 2.0 - 0.5, 2) + pow(ny / 2.0 - 0.5, 2));
|
double dmax = sqrt(pow(nx / 2.0 - 0.5, 2) + pow(ny / 2.0 - 0.5, 2));
|
||||||
|
@ -109,7 +109,7 @@ void qCloneWidget::SavePlot() {
|
|||||||
|
|
||||||
fName = QFileDialog::getSaveFileName(
|
fName = QFileDialog::getSaveFileName(
|
||||||
this, tr("Save Snapshot "), fName,
|
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);
|
QFileDialog::ShowDirsOnly);
|
||||||
if (!fName.isEmpty()) {
|
if (!fName.isEmpty()) {
|
||||||
if ((img.save(fName))) {
|
if ((img.save(fName))) {
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
// options
|
// options
|
||||||
std::string fname = "";
|
std::string fname;
|
||||||
bool isDeveloper = false;
|
bool isDeveloper = false;
|
||||||
int64_t tempval = 0;
|
int64_t tempval = 0;
|
||||||
int multiId = 0;
|
int multiId = 0;
|
||||||
@ -36,12 +36,12 @@ int main(int argc, char **argv) {
|
|||||||
// These options set a flag.
|
// These options set a flag.
|
||||||
//{"verbose", no_argument, &verbose_flag, 1},
|
//{"verbose", no_argument, &verbose_flag, 1},
|
||||||
// These options don’t set a flag. We distinguish them by their indices.
|
// These options don’t set a flag. We distinguish them by their indices.
|
||||||
{"developer", no_argument, 0, 'd'},
|
{"developer", no_argument, nullptr, 'd'},
|
||||||
{"config", required_argument, 0, 'f'},
|
{"config", required_argument, nullptr, 'f'},
|
||||||
{"id", required_argument, 0, 'i'},
|
{"id", required_argument, nullptr, 'i'},
|
||||||
{"version", no_argument, 0, 'v'},
|
{"version", no_argument, nullptr, 'v'},
|
||||||
{"help", no_argument, 0, 'h'},
|
{"help", no_argument, nullptr, 'h'},
|
||||||
{0, 0, 0, 0}};
|
{nullptr, 0, nullptr, 0}};
|
||||||
|
|
||||||
// getopt_long stores the option index here
|
// getopt_long stores the option index here
|
||||||
optind = 1;
|
optind = 1;
|
||||||
@ -93,8 +93,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
app.setStyle(new QPlastiqueStyle);
|
app.setStyle(new QPlastiqueStyle); //style is deleted by QApplication
|
||||||
// app.setWindowIcon(QIcon(":/icons/images/mountain.png"));
|
|
||||||
try {
|
try {
|
||||||
qDetectorMain det(multiId, fname, isDeveloper);
|
qDetectorMain det(multiId, fname, isDeveloper);
|
||||||
det.show();
|
det.show();
|
||||||
@ -106,8 +105,8 @@ int main(int argc, char **argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDetectorMain::qDetectorMain(int multiId, std::string fname, bool isDevel)
|
qDetectorMain::qDetectorMain(int multiId, const std::string& fname, bool isDevel)
|
||||||
: QMainWindow(0), detType(slsDetectorDefs::GENERIC), isDeveloper(isDevel),
|
: QMainWindow(nullptr), detType(slsDetectorDefs::GENERIC), isDeveloper(isDevel),
|
||||||
heightPlotWindow(0), heightCentralWidget(0) {
|
heightPlotWindow(0), heightCentralWidget(0) {
|
||||||
|
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
@ -115,7 +114,7 @@ qDetectorMain::qDetectorMain(int multiId, std::string fname, bool isDevel)
|
|||||||
SetUpWidgetWindow();
|
SetUpWidgetWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
qDetectorMain::~qDetectorMain() {}
|
qDetectorMain::~qDetectorMain() = default;
|
||||||
|
|
||||||
void qDetectorMain::SetUpWidgetWindow() {
|
void qDetectorMain::SetUpWidgetWindow() {
|
||||||
setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||||
@ -204,7 +203,7 @@ void qDetectorMain::SetUpWidgetWindow() {
|
|||||||
Initialization();
|
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
|
// instantiate detector and set window title
|
||||||
det = sls::make_unique<sls::Detector>(multiID);
|
det = sls::make_unique<sls::Detector>(multiID);
|
||||||
@ -213,8 +212,8 @@ void qDetectorMain::SetUpDetector(const std::string fName, int multiID) {
|
|||||||
tabMessages = sls::make_unique<qTabMessages>(this);
|
tabMessages = sls::make_unique<qTabMessages>(this);
|
||||||
|
|
||||||
// loads the config file at startup
|
// loads the config file at startup
|
||||||
if (!fName.empty())
|
if (!config_file.empty())
|
||||||
LoadConfigFile(fName);
|
LoadConfigFile(config_file);
|
||||||
|
|
||||||
// validate detector type (for GUI) and update menu
|
// validate detector type (for GUI) and update menu
|
||||||
detType = det->getDetectorType().tsquash(
|
detType = det->getDetectorType().tsquash(
|
||||||
@ -282,20 +281,20 @@ void qDetectorMain::Initialization() {
|
|||||||
SLOT(ExecuteHelp(QAction *)));
|
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;
|
struct stat st_buf;
|
||||||
QString file = QString(fName.c_str());
|
QString file = QString(config_file.c_str());
|
||||||
|
|
||||||
// path doesnt exist
|
// path doesnt exist
|
||||||
if (stat(fName.c_str(), &st_buf)) {
|
if (stat(config_file.c_str(), &st_buf)) {
|
||||||
qDefs::Message(
|
qDefs::Message(
|
||||||
qDefs::WARNING,
|
qDefs::WARNING,
|
||||||
std::string("<nobr>Start up configuration failed to load. The "
|
std::string("<nobr>Start up configuration failed to load. The "
|
||||||
"following file does not exist:</nobr><br><nobr>") +
|
"following file does not exist:</nobr><br><nobr>") +
|
||||||
fName,
|
config_file,
|
||||||
"qDetectorMain::LoadConfigFile");
|
"qDetectorMain::LoadConfigFile");
|
||||||
FILE_LOG(logWARNING) << "Config file does not exist";
|
FILE_LOG(logWARNING) << "Config file does not exist";
|
||||||
}
|
}
|
||||||
@ -306,12 +305,12 @@ void qDetectorMain::LoadConfigFile(const std::string fName) {
|
|||||||
std::string(
|
std::string(
|
||||||
"<nobr>Start up configuration failed to load. The following "
|
"<nobr>Start up configuration failed to load. The following "
|
||||||
"file is not a recognized file format:</nobr><br><nobr>") +
|
"file is not a recognized file format:</nobr><br><nobr>") +
|
||||||
fName,
|
config_file,
|
||||||
"qDetectorMain::LoadConfigFile");
|
"qDetectorMain::LoadConfigFile");
|
||||||
FILE_LOG(logWARNING) << "File not recognized";
|
FILE_LOG(logWARNING) << "File not recognized";
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
det->loadConfig(fName);
|
det->loadConfig(config_file);
|
||||||
}
|
}
|
||||||
CATCH_DISPLAY("Could not load config file.",
|
CATCH_DISPLAY("Could not load config file.",
|
||||||
"qDetectorMain::LoadConfigFile")
|
"qDetectorMain::LoadConfigFile")
|
||||||
|
@ -598,8 +598,8 @@ void qDrawPlot::SavePlot() {
|
|||||||
QString(".png");
|
QString(".png");
|
||||||
|
|
||||||
fName = QFileDialog::getSaveFileName(
|
fName = QFileDialog::getSaveFileName(
|
||||||
0, tr("Save Image"), fName,
|
nullptr, tr("Save Image"), 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);
|
QFileDialog::ShowDirsOnly);
|
||||||
|
|
||||||
if (!fName.isEmpty()) {
|
if (!fName.isEmpty()) {
|
||||||
@ -1068,7 +1068,7 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size,
|
|||||||
detType == slsDetectorDefs::GOTTHARD2) {
|
detType == slsDetectorDefs::GOTTHARD2) {
|
||||||
|
|
||||||
// show gain plot
|
// show gain plot
|
||||||
if (gaindest != NULL) {
|
if (gaindest != nullptr) {
|
||||||
for (ichan = 0; ichan < size; ++ichan) {
|
for (ichan = 0; ichan < size; ++ichan) {
|
||||||
uint16_t temp = (*((u_int16_t *)source));
|
uint16_t temp = (*((u_int16_t *)source));
|
||||||
gaindest[ichan] = ((temp & gainMask) >> gainOffset);
|
gaindest[ichan] = ((temp & gainMask) >> gainOffset);
|
||||||
|
@ -106,13 +106,13 @@ void qTabDebugging::GetInfo() {
|
|||||||
// get num modules
|
// get num modules
|
||||||
for (int i = 0; i < comboDetector->count() / 2; ++i)
|
for (int i = 0; i < comboDetector->count() / 2; ++i)
|
||||||
items.append(new QTreeWidgetItem(
|
items.append(new QTreeWidgetItem(
|
||||||
(QTreeWidget *)0, QStringList(QString("Module %1").arg(i))));
|
(QTreeWidget *)nullptr, QStringList(QString("Module %1").arg(i))));
|
||||||
treeDet->insertTopLevelItems(0, items);
|
treeDet->insertTopLevelItems(0, items);
|
||||||
// gets det names
|
// gets det names
|
||||||
for (int i = 0; i < comboDetector->count(); ++i) {
|
for (int i = 0; i < comboDetector->count(); ++i) {
|
||||||
QList<QTreeWidgetItem *> childItems;
|
QList<QTreeWidgetItem *> childItems;
|
||||||
childItems.append(new QTreeWidgetItem(
|
childItems.append(new QTreeWidgetItem(
|
||||||
(QTreeWidget *)0,
|
(QTreeWidget *)nullptr,
|
||||||
QStringList(QString("Half Module (%1)")
|
QStringList(QString("Half Module (%1)")
|
||||||
.arg(comboDetector->itemText(i)))));
|
.arg(comboDetector->itemText(i)))));
|
||||||
treeDet->topLevelItem(i * 2)->insertChildren(0, childItems);
|
treeDet->topLevelItem(i * 2)->insertChildren(0, childItems);
|
||||||
@ -133,7 +133,7 @@ void qTabDebugging::GetInfo() {
|
|||||||
// gets det names
|
// gets det names
|
||||||
for (int i = 0; i < comboDetector->count(); ++i)
|
for (int i = 0; i < comboDetector->count(); ++i)
|
||||||
items.append(new QTreeWidgetItem(
|
items.append(new QTreeWidgetItem(
|
||||||
(QTreeWidget *)0,
|
(QTreeWidget *)nullptr,
|
||||||
QStringList(
|
QStringList(
|
||||||
QString("Module (%1)").arg(comboDetector->itemText(i)))));
|
QString("Module (%1)").arg(comboDetector->itemText(i)))));
|
||||||
treeDet->insertTopLevelItems(0, items);
|
treeDet->insertTopLevelItems(0, items);
|
||||||
|
@ -802,7 +802,7 @@ void qTabMeasurement::Enable(bool enable) {
|
|||||||
|
|
||||||
// shortcut each time, else it doesnt work a second time
|
// shortcut each time, else it doesnt work a second time
|
||||||
btnStart->setShortcut(QApplication::translate(
|
btnStart->setShortcut(QApplication::translate(
|
||||||
"TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8));
|
"TabMeasurementObject", "Shift+Space", nullptr, QApplication::UnicodeUTF8));
|
||||||
}
|
}
|
||||||
|
|
||||||
void qTabMeasurement::Refresh() {
|
void qTabMeasurement::Refresh() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user