From c17924a7424581b90f3bca4f64e15626c334fdff Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Fri, 12 May 2017 21:39:05 +0200 Subject: [PATCH 1/3] moved all the xml-files into the resources. This make it much easier to handle if musrWiz is not locally installed. --- src/musredit_qt5/musrWiz/PAdmin.cpp | 116 ++++++++++++++++++--------- src/musredit_qt5/musrWiz/PAdmin.h | 2 +- src/musredit_qt5/musrWiz/musrWiz.pro | 30 ------- src/musredit_qt5/musrWiz/musrWiz.qrc | 4 + 4 files changed, 82 insertions(+), 70 deletions(-) diff --git a/src/musredit_qt5/musrWiz/PAdmin.cpp b/src/musredit_qt5/musrWiz/PAdmin.cpp index e9e27101..d6ec9d73 100644 --- a/src/musredit_qt5/musrWiz/PAdmin.cpp +++ b/src/musredit_qt5/musrWiz/PAdmin.cpp @@ -888,7 +888,6 @@ bool PMusrWizDefaultXMLParser::fatalError( const QXmlParseException & exception PAdmin::PAdmin() : QObject() { QString path, fln, pathFln; - bool found = false; int count = 0; fValid = true; @@ -900,51 +899,30 @@ PAdmin::PAdmin() : QObject() // 2nd: check $HOME/.musrfit/musrWiz/musrWiz.xml path = std::getenv("HOME"); pathFln = path + "/.musrfit/musrWiz/musrWiz.xml"; - if (QFile::exists(pathFln)) { - found = true; - } - } else { - found = true; - } - if (found) { if (loadMusrWizDefault(pathFln)) { QMessageBox::warning(0, "WARNING", "Couldn't find musrWiz.xml file."); } } // load musrfit funcs - found = false; // 1st: check local directory pathFln = QString("./musrfit_funcs.xml"); if (!QFile::exists(pathFln)) { // 2nd: check $HOME/.musrfit/musrWiz/musrfit_funcs.xml path = std::getenv("HOME"); pathFln = path + "/.musrfit/musrWiz/musrfit_funcs.xml"; - if (QFile::exists(pathFln)) { - found = true; + if (loadMusrfitFunc(pathFln)) { + fValid = false; + QMessageBox::critical(0, "FATAL ERROR", "Couldn't find any musrfit function definitions."); + return; } - } else { - found = true; - } - if (!found) { - fValid = false; - QMessageBox::critical(0, "FATAL ERROR", "Couldn't find musrfit_funcs.xml."); - return; - } - if (loadMusrfitFunc(pathFln)) { - fValid = false; - QMessageBox::critical(0, "FATAL ERROR", "Couldn't find any musrfit function definitions."); - return; } // load instrument definitions - found = false; - QStringList instStr; instStr << "psi" << "triumf" << "isis" << "jparc"; for (int i=0; iicons/musrWiz-22x22-dark.svg icons/musrWiz-32x32.svg icons/musrWiz-32x32-dark.svg + musrWiz.xml + func_defs/musrfit_funcs.xml + instrument_defs/instrument_def_psi.xml + instrument_defs/instrument_def_isis.xml From 3840b86efc18cc3aab1413889872ac09907db238 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Sat, 13 May 2017 09:48:58 +0200 Subject: [PATCH 2/3] moved musredit_startup.xml.in to the qt internal resources. This is more flexible than the previous version. --- src/musredit_qt5/musredit/PAdmin.cpp | 305 +++--------------- src/musredit_qt5/musredit/musredit.qrc | 1 + .../musredit/musredit_startup.xml.in | 260 +++++++++++++++ 3 files changed, 300 insertions(+), 266 deletions(-) create mode 100644 src/musredit_qt5/musredit/musredit_startup.xml.in diff --git a/src/musredit_qt5/musredit/PAdmin.cpp b/src/musredit_qt5/musredit/PAdmin.cpp index 28c13341..fe17816c 100644 --- a/src/musredit_qt5/musredit/PAdmin.cpp +++ b/src/musredit_qt5/musredit/PAdmin.cpp @@ -38,6 +38,7 @@ using namespace std; #include #include #include +#include #include "musrfit-info.h" #include "PAdmin.h" @@ -671,7 +672,7 @@ PAdmin::PAdmin() : QObject() path = procEnv.value("ROOTSYS", ""); pathFln = path + "/bin/" + fln; if (!QFile::exists(pathFln)) { - // 5th: not found anyware hence create it + // 5th: not found anywhere hence create it path = procEnv.value("HOME", ""); pathFln = path + "/.musrfit/musredit/" + fln; createMusreditStartupFile(); @@ -1000,280 +1001,52 @@ void PAdmin::createMusreditStartupFile() // create default musredit_startup.xml file in $HOME/.musrfit/musredit pathName += "/musredit_startup.xml"; + + // get the default musredit_startup.xml.in from the internal resources + QFile fres(":/musredit_startup.xml.in"); + if (!fres.exists()) { + QString msg = QString("Neither couldn't find nor create musredit_startup.xml. Things are likely not to work."); + QMessageBox::critical(0, "ERROR", msg); + return; + } + + if (!fres.open(QIODevice::ReadOnly | QIODevice::Text)) { + QString msg = QString("Couldn't open internal resource file musredit_startup.xml.in. Things are likely not to work."); + QMessageBox::critical(0, "ERROR", msg); + return; + } + // text stream for fres + QTextStream fin(&fres); + + // musredit_startup.xml default file QFile file(pathName); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return; + // text stream for file QTextStream fout(&file); - fout << "" << endl; - fout << "" << endl; - fout << " " << endl; - fout << " This is handling default setting parameters for the musredit." << endl; - fout << " " << endl; - fout << " " << endl; - fout << " " << MUSRFIT_PREFIX << "/bin" << endl; - fout << " ./" << endl; - fout << " " << MUSRFIT_DOC_DIR << "/templates" << endl; - fout << " 3600" << endl; - fout << " n" << endl; - fout << " n" << endl; - fout << " n" << endl; - fout << " y" << endl; - fout << " n" << endl; - fout << " y" << endl; - fout << " n" << endl; - fout << " n" << endl; - fout << " y" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " " << MUSRFIT_DOC_DIR << "/examples/test-histo-PSI-BIN.msr" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " file://" << MUSRFIT_DOC_DIR << "/html/user/MUSR/MusrFit.html" << endl; - fout << " file://" << MUSRFIT_DOC_DIR << "/html/user/MUSR/MusrFit.html#TheTitle" << endl; - fout << " file://" << MUSRFIT_DOC_DIR << "/html/user/MUSR/MusrFit.html#TheFitparameterBlock" << endl; - fout << " file://" << MUSRFIT_DOC_DIR << "/html/user/MUSR/MusrFit.html#TheTheoryBlock" << endl; - fout << " file://" << MUSRFIT_DOC_DIR << "/html/user/MUSR/MusrFit.html#TheFunctionsBlock" << endl; - fout << " file://" << MUSRFIT_DOC_DIR << "/html/user/MUSR/MusrFit.html#TheRunBlock" << endl; - fout << " file://" << MUSRFIT_DOC_DIR << "/html/user/MUSR/MusrFit.html#TheCommandsBlock" << endl; - fout << " file://" << MUSRFIT_DOC_DIR << "/html/user/MUSR/MusrFit.html#TheFourierBlock" << endl; - fout << " file://" << MUSRFIT_DOC_DIR << "/html/user/MUSR/MusrFit.html#ThePlotBlock" << endl; - fout << " file://" << MUSRFIT_DOC_DIR << "/html/user/MUSR/MusrFit.html#TheStatisticBlock" << endl; - fout << " file://" << MUSRFIT_DOC_DIR << "/html/user/MUSR/Msr2Data.html" << endl; - fout << " file://" << MUSRFIT_DOC_DIR << "/html/user/MUSR/MusrFit.html#A_2.3_musrFT" << endl; - fout << " " << endl; - fout << " " << endl; -#ifdef Q_OS_MAC - fout << " Courier New" << endl; - fout << " 16" << endl; -#else - fout << " Monospace" << endl; - fout << " 12" << endl; -#endif - fout << " " << endl; - fout << " " << endl; - fout << " mue4" << endl; - fout << " psi" << endl; - fout << " root-npp" << endl; - fout << " y" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " y" << endl; - fout << " y" << endl; - fout << " n" << endl; - fout << " n" << endl; - fout << " n" << endl; - fout << " n" << endl; - fout << " y" << endl; - fout << " n" << endl; - fout << " n" << endl; - fout << " n" << endl; - fout << " n" << endl; - fout << " " << endl; - fout << " " << MUSRFIT_DOC_DIR << "/latex_images" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " asymmetry" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " asymmetry.png" << endl; - fout << " 1" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " simplExpo" << endl; - fout << " (rate)" << endl; - fout << " " << endl; - fout << " simpleExp.png" << endl; - fout << " 1" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " generExpo" << endl; - fout << " (rate exponent)" << endl; - fout << " " << endl; - fout << " generalExp.png" << endl; - fout << " 2" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " simpleGss" << endl; - fout << " (rate)" << endl; - fout << " " << endl; - fout << " simpleGauss.png" << endl; - fout << " 1" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " statGssKT" << endl; - fout << " (rate)" << endl; - fout << " " << endl; - fout << " statGssKT.png" << endl; - fout << " 1" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " statGssKTLF" << endl; - fout << " (frequency damping)" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " 2" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " dynGssKTLF" << endl; - fout << " (frequency damping hopping-rate)" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " 3" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " statExpKT" << endl; - fout << " (rate)" << endl; - fout << " " << endl; - fout << " statExpKT.png" << endl; - fout << " 1" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " statExpKTLF" << endl; - fout << " (frequency damping)" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " 2" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " dynExpKTLF" << endl; - fout << " (frequency damping hopping-rate)" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " 3" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " combiLGKT" << endl; - fout << " (lorentzRate gaussRate)" << endl; - fout << " " << endl; - fout << " combiLGKT.png" << endl; - fout << " 2" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " strKT" << endl; - fout << " (rate beta)" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " 2" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " spinGlass" << endl; - fout << " (rate hopping-rate order)" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " 3" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " rdAnisoHf" << endl; - fout << " (frequency rate)" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " 2" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " abragam" << endl; - fout << " (rate hopping-rate)" << endl; - fout << " " << endl; - fout << " abragam.png" << endl; - fout << " 2" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " TFieldCos" << endl; - fout << " (phase frequency)" << endl; - fout << " " << endl; - fout << " tfCos.png" << endl; - fout << " 2" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " internFld" << endl; - fout << " (fraction phase frequency Trate Lrate)" << endl; - fout << " " << endl; - fout << " internalField.png" << endl; - fout << " 5" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " internFldGK" << endl; - fout << " (fraction frequency Trate Lrate beta)" << endl; - fout << " " << endl; - fout << " internalFieldGK.png" << endl; - fout << " 5" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " internFldLL" << endl; - fout << " (fraction frequency Trate Lrate)" << endl; - fout << " " << endl; - fout << " internalFieldLL.png" << endl; - fout << " 4" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " bessel" << endl; - fout << " (phase frequency)" << endl; - fout << " " << endl; - fout << " bessel.png" << endl; - fout << " 2" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " internBsl" << endl; - fout << " (fraction phase frequency Trate Lrate)" << endl; - fout << " " << endl; - fout << " internalBessel.png" << endl; - fout << " 5" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " skewedGss" << endl; - fout << " (phase frequency rate_m rate_p)" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " 4" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " staticNKZF" << endl; - fout << " (damping_D0 R_b)" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " 2" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " staticNKTF" << endl; - fout << " (phase frequency damping_D0 R_b)" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " 4" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " dynamicNKZF" << endl; - fout << " (damping_D0 R_b nu_c)" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " 3" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " dynamicNKTF" << endl; - fout << " (phase frequency damping_D0 R_b nu_c)" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " 5" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " polynom" << endl; - fout << " (tshift p0 p1 ... pn)" << endl; - fout << " " << endl; - fout << " polynom.png" << endl; - fout << " 4" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " userFcn" << endl; - fout << " " << endl; - fout << " " << endl; - fout << " " << endl; - fout << " 0" << endl; - fout << " " << endl; - fout << " " << endl; - fout << "" << endl; + QString line; + while (!fin.atEnd()) { + line = fin.readLine(); + line.replace("@prefix@", MUSRFIT_PREFIX); + line.replace("@DOCDIR@", MUSRFIT_DOC_DIR); + if (line.startsWith("")) { // defaults: linux: Monospace, macOS: Courier New + if (QSysInfo::macVersion() != QSysInfo::MV_None) { + line.replace("Monospace", "Courier New"); + } + } + if (line.startsWith("")) { // defaults: linux: 12, macOS: 16 + if (QSysInfo::macVersion() != QSysInfo::MV_None) { + line.replace("12", "16"); + } + } + fout << line << endl; + } file.close(); + fres.close(); } //-------------------------------------------------------------------------- diff --git a/src/musredit_qt5/musredit/musredit.qrc b/src/musredit_qt5/musredit/musredit.qrc index 25d00e80..fb3adb66 100644 --- a/src/musredit_qt5/musredit/musredit.qrc +++ b/src/musredit_qt5/musredit/musredit.qrc @@ -63,5 +63,6 @@ latex_images/statExpKT.png latex_images/statGssKT.png latex_images/tfCos.png + musredit_startup.xml.in diff --git a/src/musredit_qt5/musredit/musredit_startup.xml.in b/src/musredit_qt5/musredit/musredit_startup.xml.in new file mode 100644 index 00000000..98bb0d84 --- /dev/null +++ b/src/musredit_qt5/musredit/musredit_startup.xml.in @@ -0,0 +1,260 @@ + + + + This is handling default setting parameters for the musredit. + + + @prefix@/bin + ./ + @DOCDIR@/templates + 3600 + n + n + n + y + n + y + n + n + y + + + @DOCDIR@/examples/test-histo-PSI-BIN.msr + + + file://@DOCDIR@/html/user/MUSR/MusrFit.html + file://@DOCDIR@/html/user/MUSR/MusrFit.html#TheTitle + file://@DOCDIR@/html/user/MUSR/MusrFit.html#TheFitparameterBlock + file://@DOCDIR@/html/user/MUSR/MusrFit.html#TheTheoryBlock + file://@DOCDIR@/html/user/MUSR/MusrFit.html#TheFunctionsBlock + file://@DOCDIR@/html/user/MUSR/MusrFit.html#TheRunBlock + file://@DOCDIR@/html/user/MUSR/MusrFit.html#TheCommandsBlock + file://@DOCDIR@/html/user/MUSR/MusrFit.html#TheFourierBlock + file://@DOCDIR@/html/user/MUSR/MusrFit.html#ThePlotBlock + file://@DOCDIR@/html/user/MUSR/MusrFit.html#TheStatisticBlock + file://@DOCDIR@/html/user/MUSR/Msr2Data.html + file://@DOCDIR@/html/user/MUSR/MusrFit.html#A_2.3_musrFT + + + Monospace + 12 + + + mue4 + psi + root-npp + y + + + y + y + n + n + n + n + y + n + n + n + n + + @DOCDIR@/latex_images + + + asymmetry + + + asymmetry.png + 1 + + + simplExpo + (rate) + + simpleExp.png + 1 + + + generExpo + (rate exponent) + + generalExp.png + 2 + + + simpleGss + (rate) + + simpleGauss.png + 1 + + + statGssKT + (rate) + + statGssKT.png + 1 + + + statGssKTLF + (frequency damping) + + + 2 + + + dynGssKTLF + (frequency damping hopping-rate) + + + 3 + + + statExpKT + (rate) + + statExpKT.png + 1 + + + statExpKTLF + (frequency damping) + + + 2 + + + dynExpKTLF + (frequency damping hopping-rate) + + + 3 + + + combiLGKT + (lorentzRate gaussRate) + + combiLGKT.png + 2 + + + strKT + (rate beta) + + + 2 + + + spinGlass + (rate hopping-rate order) + + + 3 + + + rdAnisoHf + (frequency rate) + + + 2 + + + abragam + (rate hopping-rate) + + abragam.png + 2 + + + TFieldCos + (phase frequency) + + tfCos.png + 2 + + + internFld + (fraction phase frequency Trate Lrate) + + internalField.png + 5 + + + internFldGK + (fraction frequency Trate Lrate beta) + + internalFieldGK.png + 5 + + + internFldLL + (fraction frequency Trate Lrate) + + internalFieldLL.png + 4 + + + bessel + (phase frequency) + + bessel.png + 2 + + + internBsl + (fraction phase frequency Trate Lrate) + + internalBessel.png + 5 + + + skewedGss + (phase frequency rate_m rate_p) + + + 4 + + + staticNKZF + (damping_D0 R_b) + + + 2 + + + staticNKTF + (phase frequency damping_D0 R_b) + + + 4 + + + dynamicNKZF + (damping_D0 R_b nu_c) + + + 3 + + + dynamicNKTF + (phase frequency damping_D0 R_b nu_c) + + + 5 + + + polynom + (tshift p0 p1 ... pn) + + polynom.png + 4 + + + userFcn + + + + 0 + + + From 2bc6e2a8cf3a39ef9968fc18615fe4116af0fc93 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Sat, 13 May 2017 15:02:40 +0200 Subject: [PATCH 3/3] small bug fix for macOS font size of musredit. --- src/musredit_qt5/musredit/PAdmin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/musredit_qt5/musredit/PAdmin.cpp b/src/musredit_qt5/musredit/PAdmin.cpp index fe17816c..19f5288d 100644 --- a/src/musredit_qt5/musredit/PAdmin.cpp +++ b/src/musredit_qt5/musredit/PAdmin.cpp @@ -1032,12 +1032,12 @@ void PAdmin::createMusreditStartupFile() line = fin.readLine(); line.replace("@prefix@", MUSRFIT_PREFIX); line.replace("@DOCDIR@", MUSRFIT_DOC_DIR); - if (line.startsWith("")) { // defaults: linux: Monospace, macOS: Courier New + if (line.contains("")) { // defaults: linux: Monospace, macOS: Courier New if (QSysInfo::macVersion() != QSysInfo::MV_None) { line.replace("Monospace", "Courier New"); } } - if (line.startsWith("")) { // defaults: linux: 12, macOS: 16 + if (line.contains("")) { // defaults: linux: 12, macOS: 16 if (QSysInfo::macVersion() != QSysInfo::MV_None) { line.replace("12", "16"); }