bugs fix on SingleSpectrum 2D historgram not loading saved setting
This commit is contained in:
parent
106fe3f155
commit
d0133cc864
|
@ -338,6 +338,9 @@ inline void Histogram2D::Rebin(int xbin, double xmin, double xmax, int ybin, do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rescaleAxes();
|
||||||
|
UpdatePlot();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Histogram2D::RebinY(int ybin, double ymin, double ymax){
|
inline void Histogram2D::RebinY(int ybin, double ymin, double ymax){
|
||||||
|
@ -593,7 +596,7 @@ inline void Histogram2D::rightMouseClickRebin(){
|
||||||
lineEditX[i] = new QLineEdit(&dialog);
|
lineEditX[i] = new QLineEdit(&dialog);
|
||||||
layout.addRow(nameListX[i] + " : ", lineEditX[i]);
|
layout.addRow(nameListX[i] + " : ", lineEditX[i]);
|
||||||
}
|
}
|
||||||
lineEditX[0]->setText(QString::number(xBin));
|
lineEditX[0]->setText(QString::number(xBin-2));
|
||||||
lineEditX[1]->setText(QString::number(xMin));
|
lineEditX[1]->setText(QString::number(xMin));
|
||||||
lineEditX[2]->setText(QString::number(xMax));
|
lineEditX[2]->setText(QString::number(xMax));
|
||||||
|
|
||||||
|
@ -603,7 +606,7 @@ inline void Histogram2D::rightMouseClickRebin(){
|
||||||
lineEditY[i] = new QLineEdit(&dialog);
|
lineEditY[i] = new QLineEdit(&dialog);
|
||||||
layout.addRow(nameListY[i] + " : ", lineEditY[i]);
|
layout.addRow(nameListY[i] + " : ", lineEditY[i]);
|
||||||
}
|
}
|
||||||
lineEditY[0]->setText(QString::number(yBin));
|
lineEditY[0]->setText(QString::number(yBin-2));
|
||||||
lineEditY[1]->setText(QString::number(yMin));
|
lineEditY[1]->setText(QString::number(yMin));
|
||||||
lineEditY[2]->setText(QString::number(yMax));
|
lineEditY[2]->setText(QString::number(yMax));
|
||||||
|
|
||||||
|
@ -666,8 +669,6 @@ inline void Histogram2D::rightMouseClickRebin(){
|
||||||
if( dialog.exec() == QDialog::Accepted ){
|
if( dialog.exec() == QDialog::Accepted ){
|
||||||
isBusy = true;
|
isBusy = true;
|
||||||
Rebin((int)number[0][0], number[1][0], number[2][0], (int)number[0][1], number[1][1], number[2][1]);
|
Rebin((int)number[0][0], number[1][0], number[2][0], (int)number[0][1], number[1][1], number[2][1]);
|
||||||
rescaleAxes();
|
|
||||||
UpdatePlot();
|
|
||||||
isBusy = false;
|
isBusy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
|
||||||
DebugPrint("%s", "SingleSpectra");
|
DebugPrint("%s", "SingleSpectra");
|
||||||
this->digi = digi;
|
this->digi = digi;
|
||||||
this->nDigi = nDigi;
|
this->nDigi = nDigi;
|
||||||
this->rawDataPath = rawDataPath;
|
this->settingPath = rawDataPath + "/HistogramSettings.txt";
|
||||||
|
|
||||||
maxFillTimeinMilliSec = 1000;
|
maxFillTimeinMilliSec = 1000;
|
||||||
maxFillTimePerDigi = maxFillTimeinMilliSec/nDigi;
|
maxFillTimePerDigi = maxFillTimeinMilliSec/nDigi;
|
||||||
|
@ -169,6 +169,9 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
|
||||||
chkIsFillHistogram->setChecked(false);
|
chkIsFillHistogram->setChecked(false);
|
||||||
fillHistograms = false;
|
fillHistograms = false;
|
||||||
|
|
||||||
|
QLabel * lbSettingPath = new QLabel( settingPath , this);
|
||||||
|
ctrlLayout->addWidget(lbSettingPath, 1, 0, 1, 8);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{//^========================
|
{//^========================
|
||||||
|
@ -361,37 +364,53 @@ void SingleSpectra::FillHistograms(){
|
||||||
|
|
||||||
void SingleSpectra::SaveSetting(){
|
void SingleSpectra::SaveSetting(){
|
||||||
DebugPrint("%s", "SingleSpectra");
|
DebugPrint("%s", "SingleSpectra");
|
||||||
QFile file(rawDataPath + "/singleSpectraSetting.txt");
|
|
||||||
|
|
||||||
file.open(QIODevice::Text | QIODevice::WriteOnly);
|
QFile file(settingPath );
|
||||||
|
|
||||||
for( unsigned int i = 0; i < nDigi; i++){
|
if (!file.exists()) {
|
||||||
file.write(("======= " + QString::number(digi[i]->GetSerialNumber()) + "\n").toStdString().c_str());
|
// If the file does not exist, create it
|
||||||
for( int ch = 0; ch < digi[i]->GetNumInputCh() ; ch++){
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
QString a = QString::number(ch).rightJustified(2, ' ');
|
qWarning() << "Could not create file" << settingPath;
|
||||||
QString b = QString::number(hist[i][ch]->GetNBin()).rightJustified(6, ' ');
|
} else {
|
||||||
QString c = QString::number(hist[i][ch]->GetXMin()).rightJustified(6, ' ');
|
qDebug() << "File" << settingPath << "created successfully";
|
||||||
QString d = QString::number(hist[i][ch]->GetXMax()).rightJustified(6, ' ');
|
file.close();
|
||||||
file.write( QString("%1 %2 %3 %4\n").arg(a).arg(b).arg(c).arg(d).toStdString().c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString a = QString::number(digi[i]->GetNumInputCh()).rightJustified(2, ' ');
|
|
||||||
QString b = QString::number(hist2D[i]->GetXNBin()).rightJustified(6, ' ');
|
|
||||||
QString c = QString::number(hist2D[i]->GetXMin()).rightJustified(6, ' ');
|
|
||||||
QString d = QString::number(hist2D[i]->GetXMax()).rightJustified(6, ' ');
|
|
||||||
QString e = QString::number(hist2D[i]->GetYNBin()).rightJustified(6, ' ');
|
|
||||||
QString f = QString::number(hist2D[i]->GetYMin()).rightJustified(6, ' ');
|
|
||||||
QString g = QString::number(hist2D[i]->GetYMax()).rightJustified(6, ' ');
|
|
||||||
file.write( QString("%1 %2 %3 %4 %5 %6 %7\n").arg(a).arg(b).arg(c).arg(d).arg(e).arg(f).arg(g).toStdString().c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file.write("//========== End of file\n");
|
if( file.open(QIODevice::Text | QIODevice::WriteOnly) ){
|
||||||
file.close();
|
|
||||||
|
for( unsigned int i = 0; i < nDigi; i++){
|
||||||
|
file.write(("======= " + QString::number(digi[i]->GetSerialNumber()) + "\n").toStdString().c_str());
|
||||||
|
for( int ch = 0; ch < digi[i]->GetNumInputCh() ; ch++){
|
||||||
|
QString a = QString::number(ch).rightJustified(2, ' ');
|
||||||
|
QString b = QString::number(hist[i][ch]->GetNBin()).rightJustified(6, ' ');
|
||||||
|
QString c = QString::number(hist[i][ch]->GetXMin()).rightJustified(6, ' ');
|
||||||
|
QString d = QString::number(hist[i][ch]->GetXMax()).rightJustified(6, ' ');
|
||||||
|
file.write( QString("%1 %2 %3 %4\n").arg(a).arg(b).arg(c).arg(d).toStdString().c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString a = QString::number(digi[i]->GetNumInputCh()).rightJustified(2, ' ');
|
||||||
|
QString b = QString::number(hist2D[i]->GetXNBin()-2).rightJustified(6, ' ');
|
||||||
|
QString c = QString::number(hist2D[i]->GetXMin()).rightJustified(6, ' ');
|
||||||
|
QString d = QString::number(hist2D[i]->GetXMax()).rightJustified(6, ' ');
|
||||||
|
QString e = QString::number(hist2D[i]->GetYNBin()-2).rightJustified(6, ' ');
|
||||||
|
QString f = QString::number(hist2D[i]->GetYMin()).rightJustified(6, ' ');
|
||||||
|
QString g = QString::number(hist2D[i]->GetYMax()).rightJustified(6, ' ');
|
||||||
|
file.write( QString("%1 %2 %3 %4 %5 %6 %7\n").arg(a).arg(b).arg(c).arg(d).arg(e).arg(f).arg(g).toStdString().c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
file.write("##========== End of file\n");
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
}else{
|
||||||
|
printf("%s|cannot open HistogramSettings.txt\n", __func__);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleSpectra::LoadSetting(){
|
void SingleSpectra::LoadSetting(){
|
||||||
DebugPrint("%s", "SingleSpectra");
|
DebugPrint("%s", "SingleSpectra");
|
||||||
QFile file(rawDataPath + "/singleSpectraSetting.txt");
|
|
||||||
|
QFile file(settingPath);
|
||||||
|
|
||||||
if( file.open(QIODevice::Text | QIODevice::ReadOnly) ){
|
if( file.open(QIODevice::Text | QIODevice::ReadOnly) ){
|
||||||
|
|
||||||
|
@ -402,7 +421,7 @@ void SingleSpectra::LoadSetting(){
|
||||||
int digiID = -1;
|
int digiID = -1;
|
||||||
|
|
||||||
while ( !line.isNull() ){
|
while ( !line.isNull() ){
|
||||||
if( line.contains("//========== ") ) break;
|
if( line.contains("##========== ") ) break;
|
||||||
if( line.contains("//") ) continue;
|
if( line.contains("//") ) continue;
|
||||||
if( line.contains("======= ") ){
|
if( line.contains("======= ") ){
|
||||||
digiSN = line.mid(7).toInt();
|
digiSN = line.mid(7).toInt();
|
||||||
|
@ -422,21 +441,21 @@ void SingleSpectra::LoadSetting(){
|
||||||
|
|
||||||
QStringList list = line.split(QRegularExpression("\\s+"));
|
QStringList list = line.split(QRegularExpression("\\s+"));
|
||||||
list.removeAll("");
|
list.removeAll("");
|
||||||
if( list.count() != 4 ) {
|
// if( list.count() != 4 ) {
|
||||||
line = in.readLine();
|
// line = in.readLine();
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
QVector<int> data;
|
QVector<float> data;
|
||||||
for( int i = 0; i < list.count(); i++){
|
for( int i = 0; i < list.count(); i++){
|
||||||
data.push_back(list[i].toInt());
|
data.push_back(list[i].toFloat());
|
||||||
}
|
}
|
||||||
|
|
||||||
if( 0 <= data[0] && data[0] < digi[digiID]->GetNumInputCh() ){
|
if( 0 <= data[0] && data[0] < digi[digiID]->GetNumInputCh() ){
|
||||||
hist[digiID][data[0]]->Rebin(data[1], data[2], data[3]);
|
hist[digiID][int(data[0])]->Rebin(data[1], data[2], data[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( data[0] == digi[digiID]->GetNumInputCh() && data.size() == 7 ){
|
if( int(data[0]) == digi[digiID]->GetNumInputCh() && data.size() == 7 ){
|
||||||
hist2D[digiID]->Rebin(data[1], data[2], data[3], data[4], data[5], data[6]);
|
hist2D[digiID]->Rebin(int(data[1]), data[2], data[3], int(data[4]), data[5], data[6]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -446,6 +465,8 @@ void SingleSpectra::LoadSetting(){
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
printf("%s|cannot open HistogramSettings.txt\n", __func__);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ private:
|
||||||
|
|
||||||
bool fillHistograms;
|
bool fillHistograms;
|
||||||
|
|
||||||
QString rawDataPath;
|
QString settingPath;
|
||||||
|
|
||||||
unsigned short maxFillTimeinMilliSec;
|
unsigned short maxFillTimeinMilliSec;
|
||||||
unsigned short maxFillTimePerDigi;
|
unsigned short maxFillTimePerDigi;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user