52#include <QLatin1String>
57#include <QProcessEnvironment>
61#include "musrfit-info.h"
88 if (!file.open(QFile::ReadOnly | QFile::Text) || (file.size()==0)) {
90 QMessageBox::StandardButton ret = QMessageBox::warning(
nullptr,
"WARNING",
"The musredit_startup.xml is corrupted. Create a default one?", QMessageBox::Yes | QMessageBox::No);
91 if (ret == QMessageBox::Yes) {
92 fAdmin->createMusreditStartupFile();
114 fXml.setDevice(device);
116 bool expectChars =
false;
117 while (!
fXml.atEnd()) {
119 if (
fXml.isStartDocument()) {
121 }
else if (
fXml.isStartElement()) {
124 }
else if (
fXml.isCharacters() && expectChars) {
126 }
else if (
fXml.isEndElement()) {
129 }
else if (
fXml.isEndDocument()) {
133 if (
fXml.hasError()) {
135 msg = QString(
"%1 Line %2, column %3").arg(
fXml.errorString()).arg(
fXml.lineNumber()).arg(
fXml.columnNumber());
136 QMessageBox::critical(
nullptr,
"ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
173 QString qName =
fXml.name().toString();
175 if (qName ==
"timeout") {
177 }
else if (qName ==
"font_name") {
179 }
else if (qName ==
"font_size") {
181 }
else if (qName ==
"exec_path") {
183 }
else if (qName ==
"default_save_path") {
185 }
else if (qName ==
"title_from_data_file") {
187 }
else if (qName ==
"musrview_show_fourier") {
189 }
else if (qName ==
"musrview_show_avg") {
191 }
else if (qName ==
"musrview_show_one_to_one") {
193 }
else if (qName ==
"enable_musrt0") {
195 }
else if (qName ==
"ignore_theme_auto_detection") {
197 }
else if (qName ==
"dark_theme_icons_menu") {
199 }
else if (qName ==
"dark_theme_icons_toolbar") {
201 }
else if (qName ==
"edit_w") {
203 }
else if (qName ==
"edit_h") {
205 }
else if (qName ==
"keep_minuit2_output") {
207 }
else if (qName ==
"dump_ascii") {
209 }
else if (qName ==
"dump_root") {
211 }
else if (qName ==
"estimate_n0") {
213 }
else if (qName ==
"yaml_out") {
215 }
else if (qName ==
"use_no_of_threads") {
217 }
else if (qName ==
"chisq_per_run_block") {
219 }
else if (qName ==
"path_file_name") {
221 }
else if (qName ==
"beamline") {
223 }
else if (qName ==
"institute") {
225 }
else if (qName ==
"file_format") {
227 }
else if (qName ==
"lifetime_correction") {
229 }
else if (qName ==
"musr_web_main") {
231 }
else if (qName ==
"musr_web_title") {
233 }
else if (qName ==
"musr_web_parameters") {
235 }
else if (qName ==
"musr_web_theory") {
237 }
else if (qName ==
"musr_web_functions") {
239 }
else if (qName ==
"musr_web_run") {
241 }
else if (qName ==
"musr_web_command") {
243 }
else if (qName ==
"musr_web_fourier") {
245 }
else if (qName ==
"musr_web_plot") {
247 }
else if (qName ==
"musr_web_statistic") {
249 }
else if (qName ==
"musr_web_msr2data") {
251 }
else if (qName ==
"musr_web_musrFT") {
253 }
else if (qName ==
"chain_fit") {
255 }
else if (qName ==
"write_data_header") {
257 }
else if (qName ==
"ignore_data_header_info") {
259 }
else if (qName ==
"keep_minuit2_output") {
261 }
else if (qName ==
"write_column_data") {
263 }
else if (qName ==
"recreate_data_file") {
265 }
else if (qName ==
"open_file_after_fitting") {
267 }
else if (qName ==
"create_msr_file_only") {
269 }
else if (qName ==
"fit_only") {
271 }
else if (qName ==
"global") {
273 }
else if (qName ==
"global_plus") {
275 }
else if (qName ==
"func_pixmap_path") {
277 }
else if (qName ==
"func") {
287 }
else if (qName ==
"name") {
289 }
else if (qName ==
"comment") {
291 }
else if (qName ==
"label") {
293 }
else if (qName ==
"pixmap") {
295 }
else if (qName ==
"params") {
316 QString qName =
fXml.name().toString();
318 if (qName ==
"func") {
342 QString str =
fXml.text().toString();
352 ival = QString(str.toLatin1()).trimmed().toInt(&ok);
357 fAdmin->setFontName(QString(str.toLatin1()).trimmed());
360 ival = QString(str.toLatin1()).trimmed().toInt(&ok);
362 fAdmin->setFontSize(ival);
365 fAdmin->setExecPath(QString(str.toLatin1()).trimmed());
368 fAdmin->setDefaultSavePath(QString(str.toLatin1()).trimmed());
375 fAdmin->setTitleFromDataFileFlag(flag);
382 fAdmin->setMusrviewShowFourierFlag(flag);
389 fAdmin->setMusrviewShowAvgFlag(flag);
396 fAdmin->setMusrviewShowOneToOneFlag(flag);
403 fAdmin->setEnableMusrT0Flag(flag);
410 fAdmin->setIgnoreThemeAutoDetection(flag);
417 fAdmin->setDarkThemeIconsMenuFlag(flag);
424 fAdmin->setDarkThemeIconsToolbarFlag(flag);
427 ival = QString(str.toLatin1()).trimmed().toInt(&ok);
429 fAdmin->setEditWidth(ival);
432 ival = QString(str.toLatin1()).trimmed().toInt(&ok);
434 fAdmin->setEditHeight(ival);
441 fAdmin->fMsr2DataParam.keepMinuit2Output = flag;
442 fAdmin->setKeepMinuit2OutputFlag(flag);
449 fAdmin->setDumpAsciiFlag(flag);
456 fAdmin->setDumpRootFlag(flag);
463 fAdmin->fMsr2DataParam.estimateN0 = flag;
464 fAdmin->setEstimateN0Flag(flag);
471 fAdmin->fMsr2DataParam.yamlOut = flag;
472 fAdmin->setYamlOutFlag(flag);
475 ival = QString(str.toLatin1()).trimmed().toInt(&ok);
477 fAdmin->setNoOfThreadsToBeUsed(ival);
484 fAdmin->fMsr2DataParam.perRunBlockChisq = flag;
485 fAdmin->setChisqPerRunBlockFlag(flag);
488 fAdmin->addRecentFile(QString(str.toLatin1()).trimmed());
491 fAdmin->setBeamline(QString(str.toLatin1()).trimmed());
494 fAdmin->setInstitute(QString(str.toLatin1()).trimmed());
497 fAdmin->setFileFormat(QString(str.toLatin1()).trimmed());
504 fAdmin->setLifetimeCorrectionFlag(flag);
507 fAdmin->setHelpUrl(
"main", str);
510 fAdmin->setHelpUrl(
"title", str);
513 fAdmin->setHelpUrl(
"parameters", str);
516 fAdmin->setHelpUrl(
"theory", str);
519 fAdmin->setHelpUrl(
"functions", str);
522 fAdmin->setHelpUrl(
"run", str);
525 fAdmin->setHelpUrl(
"command", str);
528 fAdmin->setHelpUrl(
"fourier", str);
531 fAdmin->setHelpUrl(
"plot", str);
534 fAdmin->setHelpUrl(
"statistic", str);
537 fAdmin->setHelpUrl(
"msr2data", str);
540 fAdmin->setHelpUrl(
"musrFT", str);
547 fAdmin->fMsr2DataParam.chainFit = flag;
554 fAdmin->fMsr2DataParam.writeDbHeader = flag;
561 fAdmin->fMsr2DataParam.ignoreDataHeaderInfo = flag;
568 fAdmin->fMsr2DataParam.writeColumnData = flag;
575 fAdmin->fMsr2DataParam.recreateDbFile = flag;
582 fAdmin->fMsr2DataParam.openFilesAfterFitting = flag;
589 fAdmin->fMsr2DataParam.createMsrFileOnly = flag;
596 fAdmin->fMsr2DataParam.fitOnly = flag;
603 fAdmin->fMsr2DataParam.global = flag;
610 fAdmin->fMsr2DataParam.globalPlus = flag;
613 fAdmin->setTheoFuncPixmapPath(QString(str.toLatin1()).trimmed());
623 fTheoryItem.name = QString(str.toLatin1()).trimmed();
626 fTheoryItem.comment = QString(str.toLatin1()).trimmed();
629 fTheoryItem.label = QString(str.toLatin1()).trimmed();
632 fTheoryItem.pixmapName = QString(str.toLatin1()).trimmed();
664 if (
fAdmin->getExecPath().indexOf(
'$') >= 0) {
670 if (
fAdmin->getDefaultSavePath().indexOf(
'$') >= 0) {
673 fAdmin->setDefaultSavePath(str);
676 if (
fAdmin->getTheoFuncPixmapPath().indexOf(
'$') >=0) {
679 fAdmin->setTheoFuncPixmapPath(str);
702 std::cout <<
"debug> +++++++++++++++++++++++" << std::endl;
703 std::cout <<
"debug> general:" << std::endl;
704 std::cout <<
"debug> exec_path : " <<
fAdmin->getExecPath().toLatin1().data() << std::endl;
705 std::cout <<
"debug> default_save_path : " <<
fAdmin->getDefaultSavePath().toLatin1().data() << std::endl;
706 std::cout <<
"debug> timeout : " <<
fAdmin->getTimeout() << std::endl;
707 std::cout <<
"debug> keep_minuit2_output : " <<
fAdmin->getKeepMinuit2OutputFlag() << std::endl;
708 std::cout <<
"debug> dump_ascii : " <<
fAdmin->getDumpAsciiFlag() << std::endl;
709 std::cout <<
"debug> dump_root : " <<
fAdmin->getDumpRootFlag() << std::endl;
710 std::cout <<
"debug> title_from_data_file : " <<
fAdmin->getTitleFromDataFileFlag() << std::endl;
711 std::cout <<
"debug> chisq_per_run_block : " <<
fAdmin->getChisqPerRunBlockFlag() << std::endl;
712 std::cout <<
"debug> estimate_n0 : " <<
fAdmin->getEstimateN0Flag() << std::endl;
713 std::cout <<
"debug> yaml_out : " <<
fAdmin->getYamlOutFlag() << std::endl;
714 std::cout <<
"debug> musrview_show_fourier : " <<
fAdmin->getMusrviewShowFourierFlag() << std::endl;
715 std::cout <<
"debug> musrview_show_avg : " <<
fAdmin->getMusrviewShowAvgFlag() << std::endl;
716 std::cout <<
"debug> enable_musrt0 : " <<
fAdmin->getEnableMusrT0Flag() << std::endl;
717 std::cout <<
"debug> ignore_theme_auto_detection : " <<
fAdmin->getIgnoreThemeAutoDetection() << std::endl;
718 std::cout <<
"debug> dark_theme_icons_menu : " <<
fAdmin->getDarkThemeIconsMenuFlag() << std::endl;
719 std::cout <<
"debug> dark_theme_icons_toolbar : " <<
fAdmin->getDarkThemeIconsToolbarFlag() << std::endl;
720 std::cout <<
"debug> edit_w : " <<
fAdmin->getEditWidth() << std::endl;
721 std::cout <<
"debug> edit_h : " <<
fAdmin->getEditHeight() << std::endl;
722 std::cout <<
"debug> +++++++++++++++++++++++" << std::endl;
723 std::cout <<
"debug> recent_files:" << std::endl;
724 for (
int i=0; i<
fAdmin->getNumRecentFiles(); i++) {
725 std::cout <<
"debug> recent_file " << i <<
":" <<
fAdmin->getRecentFile(i).toLatin1().data() << std::endl;
727 std::cout <<
"debug> +++++++++++++++++++++++" << std::endl;
728 std::cout <<
"debug> help_section:" << std::endl;
729 std::cout <<
"debug> musr_web_main : " <<
fAdmin->getHelpUrl(
"main").toLatin1().data() << std::endl;
730 std::cout <<
"debug> musr_web_title : " <<
fAdmin->getHelpUrl(
"title").toLatin1().data() << std::endl;
731 std::cout <<
"debug> musr_web_parameters : " <<
fAdmin->getHelpUrl(
"parameters").toLatin1().data() << std::endl;
732 std::cout <<
"debug> musr_web_theory : " <<
fAdmin->getHelpUrl(
"theory").toLatin1().data() << std::endl;
733 std::cout <<
"debug> musr_web_functions : " <<
fAdmin->getHelpUrl(
"functions").toLatin1().data() << std::endl;
734 std::cout <<
"debug> musr_web_run : " <<
fAdmin->getHelpUrl(
"run").toLatin1().data() << std::endl;
735 std::cout <<
"debug> musr_web_command : " <<
fAdmin->getHelpUrl(
"command").toLatin1().data() << std::endl;
736 std::cout <<
"debug> musr_web_fourier : " <<
fAdmin->getHelpUrl(
"fourier").toLatin1().data() << std::endl;
737 std::cout <<
"debug> musr_web_plot : " <<
fAdmin->getHelpUrl(
"plot").toLatin1().data() << std::endl;
738 std::cout <<
"debug> musr_web_statistic : " <<
fAdmin->getHelpUrl(
"statistic").toLatin1().data() << std::endl;
739 std::cout <<
"debug> musr_web_msr2data : " <<
fAdmin->getHelpUrl(
"msr2data").toLatin1().data() << std::endl;
740 std::cout <<
"debug> musr_web_musrFT : " <<
fAdmin->getHelpUrl(
"musrFT").toLatin1().data() << std::endl;
741 std::cout <<
"debug> +++++++++++++++++++++++" << std::endl;
742 std::cout <<
"debug> font_section:" << std::endl;
743 std::cout <<
"debug> font_name : " <<
fAdmin->getFontName().toLatin1().data() << std::endl;
744 std::cout <<
"debug> font_size : " <<
fAdmin->getFontSize() << std::endl;
745 std::cout <<
"debug> +++++++++++++++++++++++" << std::endl;
746 std::cout <<
"debug> msr_file_defaults:" << std::endl;
747 std::cout <<
"debug> beamline : " <<
fAdmin->getBeamline().toLatin1().data() << std::endl;
748 std::cout <<
"debug> institute : " <<
fAdmin->getInstitute().toLatin1().data() << std::endl;
749 std::cout <<
"debug> file_format : " <<
fAdmin->getFileFormat().toLatin1().data() << std::endl;
750 std::cout <<
"debug> lifetime_correction : " <<
fAdmin->getLifetimeCorrectionFlag() << std::endl;
751 std::cout <<
"debug> +++++++++++++++++++++++" << std::endl;
752 std::cout <<
"debug> msr2data_defaults:" << std::endl;
753 std::cout <<
"debug> chain_fit : " <<
fAdmin->getMsr2DataParam().chainFit << std::endl;
754 std::cout <<
"debug> write_data_header : " <<
fAdmin->getMsr2DataParam().writeDbHeader << std::endl;
755 std::cout <<
"debug> ignore_data_header_info : " <<
fAdmin->getMsr2DataParam().ignoreDataHeaderInfo << std::endl;
756 std::cout <<
"debug> keep_minuit2_output : " <<
fAdmin->getMsr2DataParam().keepMinuit2Output << std::endl;
757 std::cout <<
"debug> write_column_data : " <<
fAdmin->getMsr2DataParam().writeColumnData << std::endl;
758 std::cout <<
"debug> recreate_data_file : " <<
fAdmin->getMsr2DataParam().recreateDbFile << std::endl;
759 std::cout <<
"debug> open_file_after_fitting : " <<
fAdmin->getMsr2DataParam().openFilesAfterFitting << std::endl;
760 std::cout <<
"debug> create_msr_file_only : " <<
fAdmin->getMsr2DataParam().createMsrFileOnly << std::endl;
761 std::cout <<
"debug> fit_only : " <<
fAdmin->getMsr2DataParam().fitOnly << std::endl;
762 std::cout <<
"debug> global : " <<
fAdmin->getMsr2DataParam().global << std::endl;
763 std::cout <<
"debug> global_plus : " <<
fAdmin->getMsr2DataParam().globalPlus << std::endl;
764 std::cout <<
"debug> +++++++++++++++++++++++" << std::endl;
765 std::cout <<
"debug> theory_functions:" << std::endl;
766 std::cout <<
"debug> func_pixmap_path : " <<
fAdmin->getTheoFuncPixmapPath().toLatin1().data() << std::endl;
767 std::cout <<
"debug> #theory : " <<
fAdmin->getTheoryCounts() << std::endl;
769 for (
unsigned int i=0; i<
fAdmin->getTheoryCounts(); i++) {
770 theo =
fAdmin->getTheoryItem(i);
771 std::cout <<
"debug> -------" << std::endl;
772 std::cout <<
"debug> name : " << theo->
name.toLatin1().data() << std::endl;
773 std::cout <<
"debug> comment : " << theo->
comment.toLatin1().data() << std::endl;
774 std::cout <<
"debug> label : " << theo->
label.toLatin1().data() << std::endl;
775 std::cout <<
"debug> pixmapName : " << theo->
pixmapName.toLatin1().data() << std::endl;
776 std::cout <<
"debug> params : " << theo->
params << std::endl;
802 QProcessEnvironment procEnv = QProcessEnvironment::systemEnvironment();
804 QStringList list = str.split(
"/");
806 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
808 if (token.contains(
"$")) {
810 if (!procEnv.contains(token)) {
811 msg = QString(
"Couldn't find '%1'. Some things might not work properly").arg(token);
812 QMessageBox::warning(
nullptr,
"WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
816 path = procEnv.value(token,
"");
817 if (path.isEmpty()) {
818 msg = QString(
"Couldn't expand '%1'. Some things might not work properly").arg(token);
819 QMessageBox::warning(
nullptr,
"WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
825 newStr +=
"/" + token;
877 QString path = QDir::currentPath();
878 QString fln = QString(
"musredit_startup.xml");
879 QString pathFln = path + fln;
880 QProcessEnvironment procEnv = QProcessEnvironment::systemEnvironment();
881 if (!QFile::exists(pathFln)) {
883 path = QDir::homePath();
884 pathFln = path +
"/.musrfit/musredit/" + fln;
885 if (!QFile::exists(pathFln)) {
887 path = procEnv.value(
"MUSRFITPATH",
"");
888 pathFln = path +
"/" + fln;
889 if (!QFile::exists(pathFln)) {
891 path = procEnv.value(
"ROOTSYS",
"");
892 pathFln = path +
"/bin/" + fln;
893 if (!QFile::exists(pathFln)) {
895 path = procEnv.value(
"HOME",
"");
896 pathFln = path +
"/.musrfit/musredit/" + fln;
910 if (!info.isExecutable())
911 QMessageBox::critical(
nullptr,
"ERROR",
"musrfit found but not recognized as executable.\nPlease check!");
913 QMessageBox::critical(
nullptr,
"ERROR",
"musrfit not found.\nHave you set the necessary system variables properly?\nPlease check the manual.\nBefore you can use musrfit, this needs to be fixed.");
917 bool sysVarMissing =
false;
918 QString msg(
"Missing System Variables:\n");
919 path = procEnv.value(
"ROOTSYS",
"");
920 if (path.isEmpty()) {
921 msg +=
"> ROOTSYS\n";
922 sysVarMissing =
true;
924 path = procEnv.value(
"MUSRFITPATH",
"");
925 if (path.isEmpty()) {
926 msg +=
"> MUSRFITPATH\n";
927 sysVarMissing =
true;
930 msg +=
"Please set this/these system variables.";
931 QMessageBox::warning(
nullptr,
"WARNING", msg);
980 if (idx > (
unsigned int)
fTheory.size())
1041 if (QFile::exists(fln)) {
1044 QMessageBox::critical(
nullptr,
"ERROR",
1045 "Error parsing musredit_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",
1046 QMessageBox::Ok, QMessageBox::NoButton);
1050 QMessageBox::critical(
nullptr,
"ERROR",
1051 "Couldn't find the musredit_startup.xml settings file.\nProbably a few things will not work porperly.\nPlease fix this first.",
1052 QMessageBox::Ok, QMessageBox::NoButton);
1080 QString fln = QString(
"./musredit_startup.xml");
1081 if (!QFile::exists(fln))
1084 if (QFile::exists(fln)) {
1085 QVector<QString> data;
1087 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
1088 std::cerr << std::endl <<
">> PAdmin::savePrefs: **ERROR** Cannot open " << fln.toLatin1().data() <<
" for reading." << std::endl;
1091 QTextStream fin(&file);
1092 while (!fin.atEnd()) {
1093 data.push_back(fin.readLine());
1098 for (
int i=0; i<data.size(); i++) {
1099 if (data[i].contains(
"<timeout>") && data[i].contains(
"</timeout>")) {
1100 data[i] =
" <timeout>" + QString(
"%1").arg(
fTimeout) +
"</timeout>";
1102 if (data[i].contains(
"<keep_minuit2_output>") && data[i].contains(
"</keep_minuit2_output>")) {
1104 data[i] =
" <keep_minuit2_output>y</keep_minuit2_output>";
1106 data[i] =
" <keep_minuit2_output>n</keep_minuit2_output>";
1108 if (data[i].contains(
"<dump_ascii>") && data[i].contains(
"</dump_ascii>")) {
1110 data[i] =
" <dump_ascii>y</dump_ascii>";
1112 data[i] =
" <dump_ascii>n</dump_ascii>";
1114 if (data[i].contains(
"<dump_root>") && data[i].contains(
"</dump_root>")) {
1116 data[i] =
" <dump_root>y</dump_root>";
1118 data[i] =
" <dump_root>n</dump_root>";
1120 if (data[i].contains(
"<title_from_data_file>") && data[i].contains(
"</title_from_data_file>")) {
1122 data[i] =
" <title_from_data_file>y</title_from_data_file>";
1124 data[i] =
" <title_from_data_file>n</title_from_data_file>";
1126 if (data[i].contains(
"<chisq_per_run_block>") && data[i].contains(
"</chisq_per_run_block>")) {
1128 data[i] =
" <chisq_per_run_block>y</chisq_per_run_block>";
1130 data[i] =
" <chisq_per_run_block>n</chisq_per_run_block>";
1132 if (data[i].contains(
"<estimate_n0>") && data[i].contains(
"</estimate_n0>")) {
1134 data[i] =
" <estimate_n0>y</estimate_n0>";
1136 data[i] =
" <estimate_n0>n</estimate_n0>";
1138 if (data[i].contains(
"<yaml_out>") && data[i].contains(
"</yaml_out>")) {
1140 data[i] =
" <yaml_out>y</yaml_out>";
1142 data[i] =
" <yaml_out>n</yaml_out>";
1144 if (data[i].contains(
"<use_no_of_threads>") && data[i].contains(
"</use_no_of_threads>")) {
1145 data[i] =
" <use_no_of_threads>" + QString(
"%1").arg(
fNoOfThreadsToBeUsed) +
"</use_no_of_threads>";
1147 if (data[i].contains(
"<musrview_show_fourier>") && data[i].contains(
"</musrview_show_fourier>")) {
1149 data[i] =
" <musrview_show_fourier>y</musrview_show_fourier>";
1151 data[i] =
" <musrview_show_fourier>n</musrview_show_fourier>";
1153 if (data[i].contains(
"<musrview_show_avg>") && data[i].contains(
"</musrview_show_avg>")) {
1155 data[i] =
" <musrview_show_avg>y</musrview_show_avg>";
1157 data[i] =
" <musrview_show_avg>n</musrview_show_avg>";
1159 if (data[i].contains(
"<enable_musrt0>") && data[i].contains(
"</enable_musrt0>")) {
1161 data[i] =
" <enable_musrt0>y</enable_musrt0>";
1163 data[i] =
" <enable_musrt0>n</enable_musrt0>";
1165 if (data[i].contains(
"<ignore_theme_auto_detection>")) {
1167 data[i] =
" <ignore_theme_auto_detection>y</ignore_theme_auto_detection>";
1169 data[i] =
" <ignore_theme_auto_detection>n</ignore_theme_auto_detection>";
1171 if (data[i].contains(
"<dark_theme_icons_menu>") && data[i].contains(
"</dark_theme_icons_menu>")) {
1173 data[i] =
" <dark_theme_icons_menu>y</dark_theme_icons_menu>";
1175 data[i] =
" <dark_theme_icons_menu>n</dark_theme_icons_menu>";
1177 if (data[i].contains(
"<dark_theme_icons_toolbar>") && data[i].contains(
"</dark_theme_icons_toolbar>")) {
1179 data[i] =
" <dark_theme_icons_toolbar>y</dark_theme_icons_toolbar>";
1181 data[i] =
" <dark_theme_icons_toolbar>n</dark_theme_icons_toolbar>";
1183 if (data[i].contains(
"<font_name>") && data[i].contains(
"</font_name>")) {
1184 data[i] = QString(
" <font_name>%1</font_name>").arg(
fFontName);
1186 if (data[i].contains(
"<font_size>") && data[i].contains(
"</font_size>")) {
1187 data[i] = QString(
" <font_size>%1</font_size>").arg(
fFontSize);
1192 file.setFileName(pref_fln);
1193 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1194 std::cerr << std::endl <<
">> PAdmin::savePrefs: **ERROR** Cannot open " << pref_fln.toLatin1().data() <<
" for writing." << std::endl;
1197 fin.setDevice(&file);
1198 for (
int i=0; i<data.size(); i++) {
1199 fin << data[i] << Qt::endl;
1203 QString msg(
"Failed to write musredit_startup.xml. Neither a local nor a global copy found.");
1204 QMessageBox::warning(
nullptr,
"WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
1256 QString fln = QString(
"./musredit_startup.xml");
1257 if (!QFile::exists(fln))
1260 if (QFile::exists(fln)) {
1261 QVector<QString> data;
1263 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
1264 std::cerr << std::endl <<
">> PAdmin::saveRecentFile: **ERROR** Cannot open " << fln.toLatin1().data() <<
" for reading." << std::endl;
1267 QTextStream fin(&file);
1268 while (!fin.atEnd()) {
1269 data.push_back(fin.readLine());
1274 for (QVector<QString>::iterator it = data.begin(); it != data.end(); ++it) {
1275 if (it->contains(
"<path_file_name>")) {
1276 it = data.erase(it);
1283 for (i=0; i<data.size(); i++) {
1284 if (data[i].contains(
"<recent_files>"))
1288 if (i == data.size()) {
1289 std::cerr << std::endl <<
">> PAdmin::saveRecentFile: **ERROR** " << fln.toLatin1().data() <<
" seems to be corrupt." << std::endl;
1294 str =
" <path_file_name>" +
fRecentFile[j] +
"</path_file_name>";
1295 data.insert(i++, str);
1298 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1299 std::cerr << std::endl <<
">> PAdmin::saveRecentFile: **ERROR** Cannot open " << fln.toLatin1().data() <<
" for reading." << std::endl;
1302 fin.setDevice(&file);
1303 for (
int i=0; i<data.size(); i++) {
1304 fin << data[i] << Qt::endl;
1308 QString msg(
"Failed to write musredit_startup.xml. Neither a local nor a global copy found.");
1309 QMessageBox::warning(
nullptr,
"WARNING", msg, QMessageBox::Ok, QMessageBox::NoButton);
1331 QProcessEnvironment procEnv = QProcessEnvironment::systemEnvironment();
1332 QString pathName = procEnv.value(
"HOME",
"");
1333 pathName +=
"/.musrfit/musredit";
1337 if (!dir.exists()) {
1339 dir.mkpath(pathName);
1343 pathName +=
"/musredit_startup.xml";
1346 QFile fres(
":/musredit_startup.xml.in");
1347 if (!fres.exists()) {
1348 QString msg = QString(
"Neither couldn't find nor create musredit_startup.xml. Things are likely not to work.");
1349 QMessageBox::critical(
nullptr,
"ERROR", msg);
1353 if (!fres.open(QIODevice::ReadOnly | QIODevice::Text)) {
1354 QString msg = QString(
"Couldn't open internal resource file musredit_startup.xml.in. Things are likely not to work.");
1355 QMessageBox::critical(
nullptr,
"ERROR", msg);
1359 QTextStream fin(&fres);
1362 QFile file(pathName);
1364 if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
1368 QTextStream fout(&file);
1371 while (!fin.atEnd()) {
1372 line = fin.readLine();
1373 line.replace(
"@prefix@", MUSRFIT_PREFIX);
1374 line.replace(
"@DOCDIR@", MUSRFIT_DOC_DIR);
1375 if (line.contains(
"<font_name>")) {
1376 if (QSysInfo::productType().contains(
"osx")) {
1377 line.replace(
"Monospace",
"Courier New");
1380 if (line.contains(
"<font_size>")) {
1381 if (QSysInfo::productType().contains(
"osx")) {
1382 line.replace(
"12",
"16");
1385 fout << line << Qt::endl;
Administration and configuration management for musredit.
PTheory fTheoryItem
Temporary storage for theory function data during parsing.
bool startDocument()
Handler called at the beginning of XML document parsing.
bool parse(QIODevice *device)
Parse the XML configuration file.
bool fValid
Flag indicating whether XML parsing completed successfully.
void dump()
Dump all configuration values to stdout for debugging.
virtual bool isValid()
Check if the XML file was parsed successfully.
PAdminXMLParser(const QString &fln, PAdmin *)
Constructs an XML parser for the musredit configuration file.
bool endDocument()
Handler called at the end of XML document parsing.
PAdmin * fAdmin
Pointer to the PAdmin object being populated with configuration data.
bool startElement()
Handler called when an XML start element is encountered.
QString expandPath(const QString &)
Expand environment variables in a path string.
bool endElement()
Handler called when an XML end element is encountered.
QXmlStreamReader fXml
Qt XML stream reader for parsing the configuration file.
bool fFunc
Flag indicating parser is inside a <func> element block.
@ eIgnoreThemeAutoDetection
EAdminKeyWords fKeyWord
Current XML element being processed.
bool characters()
Handler for XML character data (element content).
Central administration class for musredit configuration management.
QString getHelpUrl(QString tag)
Get the help URL for a specific documentation section.
bool fDumpRoot
If true, musrfit creates ROOT dump files (for debugging).
bool fChisqPreRunBlock
If true, write per-run-block chi-square values to msr-file.
QVector< PTheory > fTheory
Collection of theory functions available in the Theory menu.
PAdmin()
Constructs the PAdmin object and loads configuration.
QString fFontName
Editor font family name (default: Monospace on Linux, Courier New on macOS).
bool fEstimateN0
If true, estimate N0 parameter for single histogram fits.
friend class PAdminXMLParser
Allow XML parser to access protected setters.
int fFontSize
Editor font size in points (default: 11 on Linux, 16 on macOS).
PTheory * getTheoryItem(const unsigned int idx)
Get a theory function definition by index.
PMsr2DataParam fMsr2DataParam
Default parameter values for msr2data tool integration.
int loadPrefs(QString fln)
Load configuration from an XML file.
void saveRecentFiles()
Save recent file list to configuration file.
bool fDarkThemeIconsToolbar
If true, use dark theme icons in the toolbar.
bool fDarkThemeIconsMenu
If true, use dark theme icons in application menus.
bool fTitleFromDataFile
If true, extract msr-file title from the data file header.
bool fIgnoreThemeAutoDetection
If true, ignore OS theme detection and use manual icon settings.
bool fEnableMusrT0
If true, musrT0 tool is enabled in musredit (default: yes).
int savePrefs(QString pref_fln)
Save current configuration to an XML file.
bool fMusrviewShowAvg
If true, musrview shows run-averaged data; if false, shows individual runs.
bool fMusrviewShowFourier
If true, musrview shows Fourier transform at startup instead of time-domain data.
bool fKeepMinuit2Output
If true, preserve MINUIT2.OUTPUT and MINUIT2.root files after fitting.
int fTimeout
Timeout for musrfit processes in seconds (default: 1 hour).
void addRecentFile(const QString str)
Add a file to the recent files list.
QString getRecentFile(int idx)
Get a recent file path by index.
int fNoOfThreadsToBeUsed
number of threads to be used
bool fYamlOut
If true, write MINUIT2 output additionally as <msr-file>.yaml.
void createMusreditStartupFile()
Create default musredit_startup.xml in user's home directory.
QVector< QString > fRecentFile
Ring buffer of recently opened file paths (max MAX_RECENT_FILES entries).
QString fExecPath
Directory containing musrfit executables (musrfit, musrview, etc.).
void setHelpUrl(const QString tag, const QString url)
Set the help URL for a documentation section.
QString fPrefPathName
Full path to the active musredit_startup.xml configuration file.
bool fDumpAscii
If true, musrfit creates ASCII dump files (for debugging).
QMap< QString, QString > fHelpUrl
Maps section tags (e.g., "theory", "parameters") to help URLs.
#define MAX_RECENT_FILES
Maximum number of recently opened files to track.
Structure holding information about a musrfit theory function.
QString name
Internal function name used in msr files (e.g., "asymmetry", "simplExpo").
QString comment
Human-readable description of the theory function.
QString label
Short label for GUI menus and buttons.
int params
Number of parameters required by this theory function.
QString pixmapName
Filename of the pixmap image showing the mathematical formula.