adopted to the new features in musrview and some additional little improvements.

This commit is contained in:
suter_a 2016-12-18 10:41:34 +01:00
parent 5d80c342e0
commit 265fe18f36
12 changed files with 133 additions and 30 deletions

View File

@ -87,6 +87,8 @@ bool PAdminXMLParser::startElement( const QString&, const QString&,
fKeyWord = eTitleFromDataFile;
} else if (qName == "musrview_show_fourier") {
fKeyWord = eMusrviewShowFourier;
} else if (qName == "musrview_show_avg") {
fKeyWord = eMusrviewShowAvg;
} else if (qName == "enable_musrt0") {
fKeyWord = eEnableMusrT0;
} else if (qName == "keep_minuit2_output") {
@ -251,6 +253,13 @@ bool PAdminXMLParser::characters(const QString& str)
flag = false;
fAdmin->setMusrviewShowFourierFlag(flag);
break;
case eMusrviewShowAvg:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->setMusrviewShowAvgFlag(flag);
break;
case eEnableMusrT0:
if (str == "y")
flag = true;
@ -614,6 +623,7 @@ PAdmin::PAdmin() : QObject()
fFileFormat = QString("");
fMusrviewShowFourier = false;
fMusrviewShowAvg = false;
fTitleFromDataFile = false;
fEnableMusrT0 = false;
@ -837,6 +847,12 @@ int PAdmin::savePrefs(QString pref_fln)
else
data[i] = " <musrview_show_fourier>n</musrview_show_fourier>";
}
if (data[i].contains("<musrview_show_avg>") && data[i].contains("</musrview_show_avg>")) {
if (fMusrviewShowAvg)
data[i] = " <musrview_show_avg>y</musrview_show_avg>";
else
data[i] = " <musrview_show_avg>n</musrview_show_avg>";
}
if (data[i].contains("<enable_musrt0>") && data[i].contains("</enable_musrt0>")) {
if (fEnableMusrT0)
data[i] = " <enable_musrt0>y</enable_musrt0>";

View File

@ -69,7 +69,8 @@ class PAdminXMLParser : public QXmlDefaultHandler
private:
enum EAdminKeyWords {eEmpty, eTimeout, eKeepMinuit2Output, eDumpAscii, eDumpRoot,
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0, eMusrviewShowFourier, eEnableMusrT0,
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0,
eMusrviewShowFourier, eMusrviewShowAvg, eEnableMusrT0,
eFontName, eFontSize, eExecPath, eDefaultSavePath,
eRecentFile, eBeamline, eInstitute, eFileFormat, eLifetimeCorrection, eMsrDefaultFilePath,
eTheoFuncPixmapPath, eFunc, eFuncName, eFuncComment, eFuncLabel,
@ -119,6 +120,7 @@ class PAdmin : public QObject
QString getDefaultSavePath() { return fDefaultSavePath; }
bool getTitleFromDataFileFlag() { return fTitleFromDataFile; }
bool getMusrviewShowFourierFlag() { return fMusrviewShowFourier; }
bool getMusrviewShowAvgFlag() { return fMusrviewShowAvg; }
bool getEnableMusrT0Flag() { return fEnableMusrT0; }
bool getKeepMinuit2OutputFlag() { return fKeepMinuit2Output; }
bool getDumpAsciiFlag() { return fDumpAscii; }
@ -142,6 +144,7 @@ class PAdmin : public QObject
void setTimeout(const int ival) { fTimeout = ival; }
void setTitleFromDataFileFlag(const bool flag) { fTitleFromDataFile = flag; }
void setMusrviewShowFourierFlag(const bool flag) { fMusrviewShowFourier = flag; }
void setMusrviewShowAvgFlag(const bool flag) { fMusrviewShowAvg = flag; }
void setEnableMusrT0Flag(const bool flag) { fEnableMusrT0 = flag; }
void setKeepMinuit2OutputFlag(const bool flag) { fKeepMinuit2Output = flag; }
void setDumpAsciiFlag(const bool flag) { fDumpAscii = flag; }
@ -185,6 +188,7 @@ class PAdmin : public QObject
QVector<QString> fRecentFile; ///< keep vector of recent path-file names
bool fMusrviewShowFourier; ///< flag indicating if musrview should show at startup data (=false) or Fourier of data (=true).
bool fMusrviewShowAvg; ///< flag indicating if musrview should show at startup averaged (=true) or original (=false) data/Fourier.
bool fKeepMinuit2Output; ///< flag indicating if the Minuit2 output shall be kept (default: no)
bool fDumpAscii; ///< flag indicating if musrfit shall make an ascii-dump file (for debugging purposes, default: no).
bool fDumpRoot; ///< flag indicating if musrfit shall make an root-dump file (for debugging purposes, default: no).

View File

@ -62,6 +62,7 @@ PPrefsDialog::PPrefsDialog(PAdmin *admin) : fAdmin(admin)
fPerRunBlockChisq_checkBox->setChecked(fAdmin->getChisqPerRunBlockFlag());
fEstimateN0_checkBox->setChecked(fAdmin->getEstimateN0Flag());
fFourier_checkBox->setChecked(fAdmin->getMusrviewShowFourierFlag());
fAvg_checkBox->setChecked(fAdmin->getMusrviewShowAvgFlag());
fTimeout_lineEdit->setText(QString("%1").arg(fAdmin->getTimeout()));
fTimeout_lineEdit->setValidator(new QIntValidator(fTimeout_lineEdit));

View File

@ -47,6 +47,7 @@ class PPrefsDialog : public QDialog, private Ui::PPrefsDialog
PPrefsDialog(PAdmin *admin);
bool getMusrviewShowFourierFlag() { return fFourier_checkBox->isChecked(); }
bool getMusrviewShowAvgFlag() { return fAvg_checkBox->isChecked(); }
bool getKeepMinuit2OutputFlag() { return fKeepMn2Output_checkBox->isChecked(); }
bool getTitleFromDataFileFlag() { return fTitleFromData_checkBox->isChecked(); }
bool getEnableMusrT0Flag() { return fEnableMusrT0_checkBox->isChecked(); }

View File

@ -1699,6 +1699,12 @@ void PTextEdit::musrCalcChisq()
if ( !currentEditor() )
return;
int result = 0;
if (fAdmin->getEstimateN0Flag())
result = QMessageBox::question(this, "Estimate N0 active",
"Do you wish a chisq/mlh evaluation with an automatic N0 estimate?",
QMessageBox::Yes, QMessageBox::No);
QString tabLabel = fTabWidget->tabText(fTabWidget->currentIndex());
if (tabLabel == "noname") {
QMessageBox::critical(this, "**ERROR**", "For a fit a real msr-file is needed.");
@ -1716,8 +1722,8 @@ void PTextEdit::musrCalcChisq()
cmd.append(str);
cmd.append(QFileInfo(*fFilenames.find( currentEditor())).fileName() );
cmd.append("--chisq-only");
if (fAdmin->getEstimateN0Flag() && (result == QMessageBox::Yes))
cmd.append("--estimateN0");
cmd.append("no");
PFitOutputHandler fitOutputHandler(QFileInfo(*fFilenames.find( currentEditor() )).absolutePath(), cmd);
fitOutputHandler.setModal(true);
fitOutputHandler.exec();
@ -1770,19 +1776,11 @@ void PTextEdit::musrFit()
// check estimate N0 flag
if (fAdmin->getEstimateN0Flag()) {
cmd.append("--estimateN0");
cmd.append("yes");
} else {
cmd.append("--estimateN0");
cmd.append("no");
}
// check per-run-block-chisq flag
if (fAdmin->getChisqPerRunBlockFlag()) {
cmd.append("--per-run-block-chisq");
cmd.append("yes");
} else {
cmd.append("--per-run-block-chisq");
cmd.append("no");
}
// add timeout
@ -2203,6 +2201,8 @@ void PTextEdit::musrView()
cmd += str + "\" --timeout " + numStr;
if (fAdmin->getMusrviewShowFourierFlag())
cmd += " -f ";
if (fAdmin->getMusrviewShowAvgFlag())
cmd += " -a ";
cmd += " &";
int status=system(cmd.toLatin1());

View File

@ -33,7 +33,7 @@
<item>
<widget class="QTabWidget" name="fTabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="fGeneral_tab">
<attribute name="title">
@ -175,6 +175,19 @@
<string>start with Fourier</string>
</property>
</widget>
<widget class="QCheckBox" name="fAvg_checkBox">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>261</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>start with averaged data/Fourier</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="fMusrt0_tab">
<attribute name="title">

View File

@ -37,6 +37,8 @@ using namespace std;
#include <QTextStream>
#include <QVector>
#include <QProcessEnvironment>
#include "PAdmin.h"
//--------------------------------------------------------------------------
@ -87,6 +89,8 @@ bool PAdminXMLParser::startElement( const QString&, const QString&,
fKeyWord = eTitleFromDataFile;
} else if (qName == "musrview_show_fourier") {
fKeyWord = eMusrviewShowFourier;
} else if (qName == "musrview_show_avg") {
fKeyWord = eMusrviewShowAvg;
} else if (qName == "enable_musrt0") {
fKeyWord = eEnableMusrT0;
} else if (qName == "keep_minuit2_output") {
@ -251,6 +255,13 @@ bool PAdminXMLParser::characters(const QString& str)
flag = false;
fAdmin->setMusrviewShowFourierFlag(flag);
break;
case eMusrviewShowAvg:
if (str == "y")
flag = true;
else
flag = false;
fAdmin->setMusrviewShowAvgFlag(flag);
break;
case eEnableMusrT0:
if (str == "y")
flag = true;
@ -567,13 +578,21 @@ QString PAdminXMLParser::expandPath(const QString &str)
QString msg;
QString newStr="";
QProcessEnvironment procEnv = QProcessEnvironment::systemEnvironment();
QStringList list = str.split("/");
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
token = *it;
if (token.contains("$")) {
token.remove('$');
path = std::getenv(token.toLatin1());
if (!procEnv.contains(token)) {
msg = QString("Couldn't find '%1'. Some things might not work properly").arg(token);
QMessageBox::warning(0, "**WARNING**", msg, QMessageBox::Ok, QMessageBox::NoButton);
newStr = "";
break;
}
path = procEnv.value(token, "");
if (path.isEmpty()) {
msg = QString("Couldn't expand '%1'. Some things might not work properly").arg(token);
QMessageBox::warning(0, "**WARNING**", msg, QMessageBox::Ok, QMessageBox::NoButton);
@ -614,6 +633,7 @@ PAdmin::PAdmin() : QObject()
fFileFormat = QString("");
fMusrviewShowFourier = false;
fMusrviewShowAvg = false;
fTitleFromDataFile = false;
fEnableMusrT0 = false;
@ -646,17 +666,18 @@ PAdmin::PAdmin() : QObject()
QString path = QString("./");
QString fln = QString("musredit_startup.xml");
QString pathFln = path + fln;
QProcessEnvironment procEnv = QProcessEnvironment::systemEnvironment();
if (!QFile::exists(pathFln)) {
// 2nd: check $HOME/.musrfit/musredit/musredit_startup.xml
path = std::getenv("HOME");
path = procEnv.value("HOME", "");
pathFln = path + "/.musrfit/musredit/" + fln;
if (!QFile::exists(pathFln)) {
// 3rd: check $MUSRFITPATH/musredit_startup.xml
path = std::getenv("MUSRFITPATH");
path = procEnv.value("MUSRFITPATH", "");
pathFln = path + "/" + fln;
if (!QFile::exists(pathFln)) {
// 4th: check $ROOTSYS/bin/musredit_startup.xml
path = std::getenv("ROOTSYS");
path = procEnv.value("ROOTSYS", "");
pathFln = path + "/bin/" + fln;
}
}
@ -837,12 +858,24 @@ int PAdmin::savePrefs(QString pref_fln)
else
data[i] = " <musrview_show_fourier>n</musrview_show_fourier>";
}
if (data[i].contains("<musrview_show_avg>") && data[i].contains("</musrview_show_avg>")) {
if (fMusrviewShowAvg)
data[i] = " <musrview_show_avg>y</musrview_show_avg>";
else
data[i] = " <musrview_show_avg>n</musrview_show_avg>";
}
if (data[i].contains("<enable_musrt0>") && data[i].contains("</enable_musrt0>")) {
if (fEnableMusrT0)
data[i] = " <enable_musrt0>y</enable_musrt0>";
else
data[i] = " <enable_musrt0>n</enable_musrt0>";
}
if (data[i].contains("<font_name>") && data[i].contains("</font_name>")) {
data[i] = QString(" <font_name>%1</font_name>").arg(fFontName);
}
if (data[i].contains("<font_size>") && data[i].contains("</font_size>")) {
data[i] = QString(" <font_size>%1</font_size>").arg(fFontSize);
}
}
// write prefs

View File

@ -69,7 +69,8 @@ class PAdminXMLParser : public QXmlDefaultHandler
private:
enum EAdminKeyWords {eEmpty, eTimeout, eKeepMinuit2Output, eDumpAscii, eDumpRoot,
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0, eMusrviewShowFourier, eEnableMusrT0,
eTitleFromDataFile, eChisqPreRunBlock, eEstimateN0,
eMusrviewShowFourier, eMusrviewShowAvg, eEnableMusrT0,
eFontName, eFontSize, eExecPath, eDefaultSavePath,
eRecentFile, eBeamline, eInstitute, eFileFormat, eLifetimeCorrection, eMsrDefaultFilePath,
eTheoFuncPixmapPath, eFunc, eFuncName, eFuncComment, eFuncLabel,
@ -119,6 +120,7 @@ class PAdmin : public QObject
QString getDefaultSavePath() { return fDefaultSavePath; }
bool getTitleFromDataFileFlag() { return fTitleFromDataFile; }
bool getMusrviewShowFourierFlag() { return fMusrviewShowFourier; }
bool getMusrviewShowAvgFlag() { return fMusrviewShowAvg; }
bool getEnableMusrT0Flag() { return fEnableMusrT0; }
bool getKeepMinuit2OutputFlag() { return fKeepMinuit2Output; }
bool getDumpAsciiFlag() { return fDumpAscii; }
@ -142,6 +144,7 @@ class PAdmin : public QObject
void setTimeout(const int ival) { fTimeout = ival; }
void setTitleFromDataFileFlag(const bool flag) { fTitleFromDataFile = flag; }
void setMusrviewShowFourierFlag(const bool flag) { fMusrviewShowFourier = flag; }
void setMusrviewShowAvgFlag(const bool flag) { fMusrviewShowAvg = flag; }
void setEnableMusrT0Flag(const bool flag) { fEnableMusrT0 = flag; }
void setKeepMinuit2OutputFlag(const bool flag) { fKeepMinuit2Output = flag; }
void setDumpAsciiFlag(const bool flag) { fDumpAscii = flag; }
@ -185,6 +188,7 @@ class PAdmin : public QObject
QVector<QString> fRecentFile; ///< keep vector of recent path-file names
bool fMusrviewShowFourier; ///< flag indicating if musrview should show at startup data (=false) or Fourier of data (=true).
bool fMusrviewShowAvg; ///< flag indicating if musrview should show at startup averaged (=true) or original (=false) data/Fourier.
bool fKeepMinuit2Output; ///< flag indicating if the Minuit2 output shall be kept (default: no)
bool fDumpAscii; ///< flag indicating if musrfit shall make an ascii-dump file (for debugging purposes, default: no).
bool fDumpRoot; ///< flag indicating if musrfit shall make an root-dump file (for debugging purposes, default: no).

View File

@ -62,6 +62,7 @@ PPrefsDialog::PPrefsDialog(PAdmin *admin) : fAdmin(admin)
fPerRunBlockChisq_checkBox->setChecked(fAdmin->getChisqPerRunBlockFlag());
fEstimateN0_checkBox->setChecked(fAdmin->getEstimateN0Flag());
fFourier_checkBox->setChecked(fAdmin->getMusrviewShowFourierFlag());
fAvg_checkBox->setChecked(fAdmin->getMusrviewShowAvgFlag());
fTimeout_lineEdit->setText(QString("%1").arg(fAdmin->getTimeout()));
fTimeout_lineEdit->setValidator(new QIntValidator(fTimeout_lineEdit));

View File

@ -47,6 +47,7 @@ class PPrefsDialog : public QDialog, private Ui::PPrefsDialog
PPrefsDialog(PAdmin *admin);
bool getMusrviewShowFourierFlag() { return fFourier_checkBox->isChecked(); }
bool getMusrviewShowAvgFlag() { return fAvg_checkBox->isChecked(); }
bool getKeepMinuit2OutputFlag() { return fKeepMn2Output_checkBox->isChecked(); }
bool getTitleFromDataFileFlag() { return fTitleFromData_checkBox->isChecked(); }
bool getEnableMusrT0Flag() { return fEnableMusrT0_checkBox->isChecked(); }

View File

@ -848,6 +848,13 @@ void PTextEdit::fileOpen()
++it;
}
// in case there is a 1st empty tab "noname", remove it
if (fTabWidget->tabText(0) == "noname") { // has to be the first, otherwise do nothing
fFileSystemWatcher->removePath("noname");
delete fTabWidget->widget(0);
}
}
//----------------------------------------------------------------------------------------------------
@ -879,6 +886,13 @@ void PTextEdit::fileOpenRecent()
else
fileReload();
}
// in case there is a 1st empty tab "noname", remove it
if (fTabWidget->tabText(0) == "noname") { // has to be the first, otherwise do nothing
fFileSystemWatcher->removePath("noname");
delete fTabWidget->widget(0);
}
}
//----------------------------------------------------------------------------------------------------
@ -1699,6 +1713,11 @@ void PTextEdit::musrCalcChisq()
if ( !currentEditor() )
return;
int result = 0;
if (fAdmin->getEstimateN0Flag())
result = QMessageBox::question(this, "Estimate N0 active",
"Do you wish a chisq/mlh evaluation with an automatic N0 estimate?");
QString tabLabel = fTabWidget->tabText(fTabWidget->currentIndex());
if (tabLabel == "noname") {
QMessageBox::critical(this, "**ERROR**", "For a fit a real msr-file is needed.");
@ -1716,8 +1735,8 @@ void PTextEdit::musrCalcChisq()
cmd.append(str);
cmd.append(QFileInfo(*fFilenames.find( currentEditor())).fileName() );
cmd.append("--chisq-only");
if (fAdmin->getEstimateN0Flag() && (result == QMessageBox::Yes))
cmd.append("--estimateN0");
cmd.append("no");
PFitOutputHandler fitOutputHandler(QFileInfo(*fFilenames.find( currentEditor() )).absolutePath(), cmd);
fitOutputHandler.setModal(true);
fitOutputHandler.exec();
@ -1770,19 +1789,11 @@ void PTextEdit::musrFit()
// check estimate N0 flag
if (fAdmin->getEstimateN0Flag()) {
cmd.append("--estimateN0");
cmd.append("yes");
} else {
cmd.append("--estimateN0");
cmd.append("no");
}
// check per-run-block-chisq flag
if (fAdmin->getChisqPerRunBlockFlag()) {
cmd.append("--per-run-block-chisq");
cmd.append("yes");
} else {
cmd.append("--per-run-block-chisq");
cmd.append("no");
}
// add timeout
@ -2205,6 +2216,10 @@ void PTextEdit::musrView()
if (fAdmin->getMusrviewShowFourierFlag())
arg << "-f";
// start with averaged data/Fourier?
if (fAdmin->getMusrviewShowAvgFlag())
arg << "-a";
QProcess *proc = new QProcess(this);
// make sure that the system environment variables are properly set
@ -2333,6 +2348,7 @@ void PTextEdit::musrPrefs()
if (dlg->exec() == QDialog::Accepted) {
fAdmin->setMusrviewShowFourierFlag(dlg->getMusrviewShowFourierFlag());
fAdmin->setMusrviewShowAvgFlag(dlg->getMusrviewShowAvgFlag());
fAdmin->setKeepMinuit2OutputFlag(dlg->getKeepMinuit2OutputFlag());
fAdmin->setTitleFromDataFileFlag(dlg->getTitleFromDataFileFlag());
fAdmin->setEnableMusrT0Flag(dlg->getEnableMusrT0Flag());

View File

@ -17,7 +17,7 @@
<string>Preferences</string>
</property>
<property name="windowIcon">
<iconset resource="../musredit.qrc">
<iconset>
<normaloff>:/images/musrfit.xpm</normaloff>:/images/musrfit.xpm</iconset>
</property>
<widget class="QWidget" name="layoutWidget">
@ -175,6 +175,19 @@
<string>start with Fourier</string>
</property>
</widget>
<widget class="QCheckBox" name="fAvg_checkBox">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>231</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>start with averaged data/Fourier</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="fMusrt0_tab">
<attribute name="title">