#include "mainwindow.h" #include "ui_mainwindow.h" #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); m_path = qApp->applicationDirPath() + "/Spectrum/"; qDebug() << m_path; } MainWindow::~MainWindow() { delete ui; } void MainWindow::Process() { QTime time; time.start(); SpecSetup setup; PHDFile* phd = new PHDFile(); /* JPP37_001-20151029-002300.PHD.ims _CMX13_001-20160312_0623_S.PHD _CNX20_003-20160313_0223_S.PHD PAP50_001-20151027-090100.PHD.ims KWP40_001-20151027-200326.PHD.txt */ LoadFile(phd, m_path + "CNX22_001-20110411_2225_Q_FULL_1803.PHD"); //LoadFile(phd, m_path + "PTE09Ref.Sample-006.Rms"); if(phd->header.system_type.contains('G')) { setup.ECutAnalysis_Low = 12; } GammaAnalyALG alg(setup); if(phd->header.system_type.contains('P')) setup.bUpdateCal = true; alg.SetBaseInfo(phd->Spectrum.counts, phd->Spectrum.begin_channel, phd->Spectrum.num_g_channel); alg.SetCalData(phd->EnerKD, phd->ResoKD, phd->EffiKD, phd->TotEKD); alg.Process(phd->msgInfo.data_type.at(0), phd->certificate.g_energy.toStdVector()); /* //获取所有的 pat 信息 stdvec2 out_pat = alg.getPAT(); stdvec Centroid = out_pat.at(i_Centroid); stdvec NetArea = out_pat[i_NetArea]; //获取 pat 中某项信息 stdvec Centroid2 = alg.getPatInfo(i_Centroid); stdvec NetArea2 = alg.getPatInfo(i_NetArea); // 其他能获取的信息参照 GammaAnalyAlgLib.h 文件中 PeakIndex 枚举类 //获取所有的谱基线信息 stdvec2 out_baseInfo = alg.getBaseInfo(); stdvec BaseLine = out_baseInfo.at(s_BaseLine); stdvec Steps = out_baseInfo[s_Steps]; //获取某项谱基线信息 stdvec BaseLine2 = alg.getBaseInfo(s_BaseLine); stdvec Steps2 = alg.getBaseInfo(s_Steps); // 其他能获取的信息参照 GammaAnalyAlgLib.h 文件中 SpecBaseIdx 枚举类 */ /* **********************************刻度拟合*********************************************** */ /*stdvec pEner = alg.calFitPara(Cal_Energy, phd->EnerKD); stdvec pReso = alg.calFitPara(Cal_Resolution, phd->ResoKD); stdvec pEffi = alg.calFitPara(Cal_Efficiency, phd->EffiKD); stdvec pTotE = alg.calFitPara(Cal_Tot_efficiency, phd->TotEKD);*/ /* **********************************刻度更新*********************************************** */ /*if(phd->header.system_type.contains('P')) { QChar dataType = phd->msgInfo.data_type.at(0); alg.calUpdate(dataType, phd->certificate.g_energy.toStdVector(), true, true, true); }*/ /* **********************************寻峰*********************************************** */ /*alg.PeakSearch(); */ /* **********************************基线优化*********************************************** */ /*alg.baseImprove(setup.BaseImprovePSS); */ /* **********************************净面积拟合*********************************************** */ /*vec t_idx = alg.dmps(QStringList("NetAreaFree"))(0); uvec idx = arma::find(t_idx), ep; idx.print("idx = "); alg.fitPeakFull(idx, ep, ep, ep); */ SetState(IsCalibFitting, IsNull); SetState(IsPeakSearching, IsCalibFitting); SetState(IsBaseImproving, IsPeakSearching); SetState(IsNetAreaFitting, IsBaseImproving); SetState(IsNull, IsNetAreaFitting); ui->label_time->setText(QString::number(time.elapsed())); } void MainWindow::SetState(AnalyStep doing, AnalyStep done) { QString style_doing = "background-color: yellow; font: 13pt \"Arial Rounded MT Bold\";"; QString style_done = "background-color: green; font: 13pt \"Arial Rounded MT Bold\";"; switch(doing) { case IsCalibFitting: ui->label_CF->setStyleSheet(style_doing); break; case IsPeakSearching: ui->label_PS->setStyleSheet(style_doing); break; case IsBaseImproving: ui->label_BI->setStyleSheet(style_doing); break; case IsNetAreaFitting: ui->label_NA->setStyleSheet(style_doing); break; default: break; } switch(done) { case IsCalibFitting: ui->label_CF->setStyleSheet(style_done); break; case IsPeakSearching: ui->label_PS->setStyleSheet(style_done); break; case IsBaseImproving: ui->label_BI->setStyleSheet(style_done); break; case IsNetAreaFitting: ui->label_NA->setStyleSheet(style_done); break; default: break; } } void MainWindow::LoadFile(PHDFile* phd, QString filename) { RadionuclideMessage sample_data; sample_data.AnalysePHD_File(filename); phd->msgInfo = sample_data.GetMessageInfo(); QString block_name = QLatin1String("#Header"); QVariant header = sample_data.GetBlockData(block_name); if (!header.isNull()) { phd->header = header.value(); } block_name = QLatin1String("#Comment"); QVariant comment = sample_data.GetBlockData(block_name); if(!comment.isNull()) { phd->totalCmt = comment.value(); } block_name = QLatin1String("#Collection"); QVariant collection = sample_data.GetBlockData(block_name); if (!collection.isNull()) { phd->collect = collection.value(); } block_name = QLatin1String("#Acquisition"); QVariant acquisition = sample_data.GetBlockData(block_name); if (!acquisition.isNull()) { phd->acq = acquisition.value(); } block_name = QLatin1String("#Processing"); QVariant process = sample_data.GetBlockData(block_name); if (!process.isNull()) { phd->process = process.value(); } block_name = QLatin1String("#Calibration"); QVariant calibra = sample_data.GetBlockData(block_name); if (!calibra.isNull()) { phd->calibration = calibra.value(); } block_name = QLatin1String(""); QVariant certify = sample_data.GetBlockData(block_name); if(!certify.isNull()) { phd->certificate = certify.value(); } block_name = QLatin1String("#g_Spectrum"); phd->Spectrum = sample_data.GetBlockData(block_name).value(); for(int i=0; i<3; i++) { phd->EnerKD[i].clear(); phd->ResoKD[i].clear(); phd->EffiKD[i].clear(); phd->TotEKD[i].clear(); } block_name = QLatin1String("#g_Energy"); G_EnergyBlock Energy = sample_data.GetBlockData(block_name).value(); phd->EnerKD[0] = Energy.g_energy.toStdVector(); phd->EnerKD[1] = Energy.centroid_channel.toStdVector(); phd->EnerKD[2] = Energy.uncertainty.toStdVector(); block_name = QLatin1String("#g_Resolution"); G_ResolutionBlock Resolution = sample_data.GetBlockData(block_name).value(); phd->ResoKD[0] = Resolution.g_energy.toStdVector(); phd->ResoKD[1] = Resolution.FWHM.toStdVector(); phd->ResoKD[2] = Resolution.uncertainty.toStdVector(); block_name = QLatin1String("#g_Efficiency"); G_EfficiencyBlock Efficiency = sample_data.GetBlockData(block_name).value(); phd->EffiKD[0] = Efficiency.g_energy.toStdVector(); phd->EffiKD[1] = Efficiency.efficiency.toStdVector(); phd->EffiKD[2] = Efficiency.uncertainty.toStdVector(); block_name = QLatin1String("#TotalEff"); TotaleffBlock Tot_Eff = sample_data.GetBlockData(block_name).value(); phd->TotEKD[0] = Tot_Eff.g_energy.toStdVector(); phd->TotEKD[1] = Tot_Eff.total_efficiency.toStdVector(); phd->TotEKD[2] = Tot_Eff.uncertainty.toStdVector(); } void MainWindow::on_pushButton_clicked() { Process(); }