Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer

This commit is contained in:
maliakal_d 2020-03-10 15:59:35 +01:00
commit 1d2f4a8af0
9 changed files with 49 additions and 69 deletions

View File

@ -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 {

View File

@ -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) {

View File

@ -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);
}

View File

@ -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<double> 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<double> cs1(0);
QVector<double> lcs1(0);
cs1.append(0.);
cs1.append(0.34);
cs1.append(0.61);
cs1.append(0.84);
cs1.append(1.);
QVector<double> 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<double> 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();

View File

@ -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))) {

View File

@ -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 dont 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<sls::Detector>(multiID);
@ -213,8 +212,8 @@ void qDetectorMain::SetUpDetector(const std::string fName, int multiID) {
tabMessages = sls::make_unique<qTabMessages>(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("<nobr>Start up configuration failed to load. The "
"following file does not exist:</nobr><br><nobr>") +
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(
"<nobr>Start up configuration failed to load. The following "
"file is not a recognized file format:</nobr><br><nobr>") +
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")

View File

@ -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);

View File

@ -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<QTreeWidgetItem *> 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);

View File

@ -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() {