changed gui handling to msr<->mlog swapping

This commit is contained in:
nemu
2009-03-14 12:33:55 +00:00
parent 3c04fa2675
commit e427a55283
10 changed files with 114 additions and 87 deletions

View File

@ -80,10 +80,6 @@ bool PAdminXMLParser::startElement( const QString&, const QString&,
fKeyWord = eFileFormat; fKeyWord = eFileFormat;
} else if (qName == "msr_default_file_path") { } else if (qName == "msr_default_file_path") {
fKeyWord = eMsrDefaultFilePath; fKeyWord = eMsrDefaultFilePath;
} else if (qName == "show_mlog") {
fKeyWord = eShowMlog;
} else if (qName == "open_mlog_after_fit") {
fKeyWord = eOpenMlogAfterFit;
} }
return true; return true;
@ -127,18 +123,6 @@ bool PAdminXMLParser::characters(const QString& str)
case eMsrDefaultFilePath: case eMsrDefaultFilePath:
fAdmin->setMsrDefaultFilePath(QString(str.ascii()).stripWhiteSpace()); fAdmin->setMsrDefaultFilePath(QString(str.ascii()).stripWhiteSpace());
break; break;
case eShowMlog:
if (str == "n")
fAdmin->setShowMlog(false);
else
fAdmin->setShowMlog(true);
break;
case eOpenMlogAfterFit:
if (str == "n")
fAdmin->setOpenMlogAfterFit(false);
else
fAdmin->setOpenMlogAfterFit(true);
break;
default: default:
break; break;
} }
@ -172,9 +156,6 @@ PAdmin::PAdmin()
fInstitute = QString(""); fInstitute = QString("");
fFileFormat = QString(""); fFileFormat = QString("");
fShowMlog = true;
fOpenMlogAfterFit = true;
// XML Parser part // XML Parser part
QString path = getenv("MUSRFITPATH"); QString path = getenv("MUSRFITPATH");
if (path.isEmpty()) if (path.isEmpty())

View File

@ -47,7 +47,7 @@ class PAdminXMLParser : public QXmlDefaultHandler
private: private:
enum EAdminKeyWords {eEmpty, eExecPath, eDefaultSavePath, eBeamline, eInstitute, eFileFormat, enum EAdminKeyWords {eEmpty, eExecPath, eDefaultSavePath, eBeamline, eInstitute, eFileFormat,
eMsrDefaultFilePath, eShowMlog, eOpenMlogAfterFit}; eMsrDefaultFilePath};
bool startDocument(); bool startDocument();
bool startElement( const QString&, const QString&, const QString& , bool startElement( const QString&, const QString&, const QString& ,
@ -74,8 +74,6 @@ class PAdmin
QString getInstitute() { return fInstitute; } QString getInstitute() { return fInstitute; }
QString getFileFormat() { return fFileFormat; } QString getFileFormat() { return fFileFormat; }
QString getMsrDefaultFilePath() { return fMsrDefaultFilePath; } QString getMsrDefaultFilePath() { return fMsrDefaultFilePath; }
bool getShowMlog() { return fShowMlog; }
bool getOpenMlogAfterFit() { return fOpenMlogAfterFit; }
protected: protected:
void setExecPath(const QString str) { fExecPath = str; } void setExecPath(const QString str) { fExecPath = str; }
@ -84,8 +82,6 @@ class PAdmin
void setInstitute(const QString str) { fInstitute = str; } void setInstitute(const QString str) { fInstitute = str; }
void setFileFormat(const QString str) { fFileFormat = str; } void setFileFormat(const QString str) { fFileFormat = str; }
void setMsrDefaultFilePath(const QString str) { fMsrDefaultFilePath = str; } void setMsrDefaultFilePath(const QString str) { fMsrDefaultFilePath = str; }
void setShowMlog(const bool flag) { fShowMlog = flag; }
void setOpenMlogAfterFit(const bool flag) { fOpenMlogAfterFit = flag; }
private: private:
friend class PAdminXMLParser; friend class PAdminXMLParser;
@ -98,8 +94,6 @@ class PAdmin
QString fFileFormat; QString fFileFormat;
QString fMsrDefaultFilePath; QString fMsrDefaultFilePath;
bool fShowMlog;
bool fOpenMlogAfterFit;
}; };
#endif // _PADMIN_H_ #endif // _PADMIN_H_

View File

@ -35,18 +35,13 @@
/** /**
* <p> * <p>
*/ */
PPrefsDialog::PPrefsDialog(const bool keep_mn2_output, const bool open_mlog_after_fit, const int dump_tag) PPrefsDialog::PPrefsDialog(const bool keep_mn2_output, const int dump_tag)
{ {
if (keep_mn2_output) if (keep_mn2_output)
fKeepMn2Output_checkBox->setChecked(true); fKeepMn2Output_checkBox->setChecked(true);
else else
fKeepMn2Output_checkBox->setChecked(false); fKeepMn2Output_checkBox->setChecked(false);
if (open_mlog_after_fit)
fOpenMlogAfterFit_checkBox->setChecked(true);
else
fOpenMlogAfterFit_checkBox->setChecked(false);
if (dump_tag == 1) { if (dump_tag == 1) {
fDumpAscii_checkBox->setChecked(true); fDumpAscii_checkBox->setChecked(true);
fDumpRoot_checkBox->setChecked(false); fDumpRoot_checkBox->setChecked(false);

View File

@ -39,10 +39,9 @@
class PPrefsDialog : public PPrefsDialogBase class PPrefsDialog : public PPrefsDialogBase
{ {
public: public:
PPrefsDialog(const bool keep_mn2_output, const bool open_mlog_after_fit, const int dump_tag); PPrefsDialog(const bool keep_mn2_output, const int dump_tag);
bool keepMinuit2Output() { return fKeepMn2Output_checkBox->isChecked(); } bool keepMinuit2Output() { return fKeepMn2Output_checkBox->isChecked(); }
bool openMlogAfterFit() { return fOpenMlogAfterFit_checkBox->isChecked(); }
int getDump(); int getDump();
public slots: public slots:

View File

@ -103,8 +103,6 @@ PTextEdit::PTextEdit( QWidget *parent, const char *name )
{ {
fAdmin = new PAdmin(); fAdmin = new PAdmin();
fShowMlog = fAdmin->getShowMlog();
fOpenMlogAfterFit = fAdmin->getOpenMlogAfterFit();
fKeepMinuit2Output = false; fKeepMinuit2Output = false;
fDump = 0; // 0 = no dump, 1 = ascii dump, 2 = root dump fDump = 0; // 0 = no dump, 1 = ascii dump, 2 = root dump
@ -272,6 +270,11 @@ void PTextEdit::setupMusrActions()
a->addTo( tb ); a->addTo( tb );
a->addTo( menu ); a->addTo( menu );
a = new QAction( QPixmap::fromMimeSource( "musrswap.xpm" ), tr( "&Swap Msr <-> Mlog" ), ALT + Key_S, this, "musrSwapMsrMlog" );
connect( a, SIGNAL( activated() ), this, SLOT( musrSwapMsrMlog() ) );
a->addTo( tb );
a->addTo( menu );
a = new QAction( QPixmap::fromMimeSource( "musrmlog2db.xpm" ), tr( "&Mlog2dB" ), ALT + Key_M, this, "musrMlog2Db" ); a = new QAction( QPixmap::fromMimeSource( "musrmlog2db.xpm" ), tr( "&Mlog2dB" ), ALT + Key_M, this, "musrMlog2Db" );
connect( a, SIGNAL( activated() ), this, SLOT( musrMlog2Db() ) ); connect( a, SIGNAL( activated() ), this, SLOT( musrMlog2Db() ) );
a->addTo( tb ); a->addTo( tb );
@ -293,17 +296,6 @@ void PTextEdit::setupMusrActions()
connect( a, SIGNAL( activated() ), this, SLOT( musrPrefs() ) ); connect( a, SIGNAL( activated() ), this, SLOT( musrPrefs() ) );
a->addTo( tb ); a->addTo( tb );
a->addTo( menu ); a->addTo( menu );
fComboShowMlog = new QComboBox( TRUE, tb );
fComboShowMlog->setEditable(false);
fComboShowMlog->insertItem("view mlog");
fComboShowMlog->insertItem("view msr");
connect( fComboShowMlog, SIGNAL( activated( const QString & ) ),
this, SLOT( musrShowMlog( const QString & ) ) );
if (fShowMlog)
fComboShowMlog->setCurrentItem(0);
else
fComboShowMlog->setCurrentItem(1);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -870,6 +862,8 @@ void PTextEdit::musrFit()
fitOutputHandler.setModal(true); fitOutputHandler.setModal(true);
fitOutputHandler.exec(); fitOutputHandler.exec();
musrSwapMsrMlog();
/*
if (fOpenMlogAfterFit) { if (fOpenMlogAfterFit) {
// get current file name and replace the msr-extension through mlog // get current file name and replace the msr-extension through mlog
str = fTabWidget->label(fTabWidget->currentPageIndex()); str = fTabWidget->label(fTabWidget->currentPageIndex());
@ -888,6 +882,7 @@ void PTextEdit::musrFit()
// open mlog files // open mlog files
load(str); load(str);
} }
*/
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -1059,11 +1054,6 @@ void PTextEdit::musrView()
cmd = str + " "; cmd = str + " ";
str = *fFilenames.find( currentEditor() ); str = *fFilenames.find( currentEditor() );
if (fShowMlog) {
int idx = str.find(".msr");
if (idx > 0)
str.replace(idx, 4, ".mlog");
}
cmd += str + " &"; cmd += str + " &";
system(cmd.latin1()); system(cmd.latin1());
@ -1089,11 +1079,10 @@ void PTextEdit::musrT0()
*/ */
void PTextEdit::musrPrefs() void PTextEdit::musrPrefs()
{ {
PPrefsDialog *dlg = new PPrefsDialog(fKeepMinuit2Output, fOpenMlogAfterFit, fDump); PPrefsDialog *dlg = new PPrefsDialog(fKeepMinuit2Output, fDump);
if (dlg->exec() == QDialog::Accepted) { if (dlg->exec() == QDialog::Accepted) {
fKeepMinuit2Output = dlg->keepMinuit2Output(); fKeepMinuit2Output = dlg->keepMinuit2Output();
fOpenMlogAfterFit = dlg->openMlogAfterFit();
fDump = dlg->getDump(); fDump = dlg->getDump();
} }
} }
@ -1102,12 +1091,74 @@ void PTextEdit::musrPrefs()
/** /**
* <p> * <p>
*/ */
void PTextEdit::musrShowMlog( const QString &str ) void PTextEdit::musrSwapMsrMlog()
{ {
if (str.find("mlog") > 0) if ( !currentEditor() )
fShowMlog = true; return;
else
fShowMlog = false; // get current file name
QString currentFileName = *fFilenames.find( currentEditor() );
QString swapFileName;
QString tempFileName = QString("__swap__.msr");
// check if it is a msr-, mlog-, or another file
int idx;
if ((idx = currentFileName.find(".msr")) > 0) { // msr-file
swapFileName = currentFileName;
swapFileName.replace(idx, 5, ".mlog");
} else if ((idx = currentFileName.find(".mlog")) > 0) { // mlog-file
swapFileName = currentFileName;
swapFileName.replace(idx, 5, ".msr ").stripWhiteSpace();
} else { // neither a msr- nor a mlog-file
QMessageBox::information( this, "musrSwapMsrMlog",
"This is neither a msr- nor a mlog-file, hence nothing to be swapped.\n",
QMessageBox::Ok );
return;
}
// check if the swapFile exists
if (!QFile::exists(swapFileName)) {
QString msg = "swap file '" + swapFileName + "' doesn't exist.\nCannot swap anything.";
QMessageBox::warning( this, "musrSwapMsrMlog",
msg, QMessageBox::Ok, QMessageBox::NoButton );
return;
}
// check if the file needs to be saved
if (fTabWidget->label(fTabWidget->currentPageIndex()).find("*") > 0) { // needs to be saved first
fileSave();
}
// swap files
QString cmd;
cmd = QString("cp ") + currentFileName + QString(" ") + tempFileName;
system(cmd.latin1());
cmd = QString("cp ") + swapFileName + QString(" ") + currentFileName;
system(cmd.latin1());
cmd = QString("cp ") + tempFileName + QString(" ") + swapFileName;
system(cmd.latin1());
cmd = QString("rm ") + tempFileName;
system(cmd.latin1());
// reload current file
fileClose();
load(currentFileName);
// check if swap file is open as well, and if yes, reload it
idx = -1;
for (int i=0; i<fTabWidget->count(); i++) {
if (fTabWidget->label(i).find(swapFileName) >= 0) {
idx = i;
break;
}
}
if (idx >= 0) { // swap file is open
int currentIdx = fTabWidget->currentPageIndex();
fTabWidget->setCurrentPage(idx);
fileClose();
load(swapFileName);
fTabWidget->setCurrentPage(currentIdx);
}
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------

View File

@ -88,7 +88,7 @@ private slots:
void musrView(); void musrView();
void musrT0(); void musrT0();
void musrPrefs(); void musrPrefs();
void musrShowMlog( const QString &str ); void musrSwapMsrMlog();
void helpContents(); void helpContents();
void helpAboutQt(); void helpAboutQt();
@ -100,16 +100,12 @@ private slots:
private: private:
PAdmin *fAdmin; PAdmin *fAdmin;
bool fShowMlog;
bool fOpenMlogAfterFit;
bool fKeepMinuit2Output; bool fKeepMinuit2Output;
int fDump; int fDump;
QComboBox *fComboFont; QComboBox *fComboFont;
QComboBox *fComboSize; QComboBox *fComboSize;
QComboBox *fComboShowMlog;
QTabWidget *fTabWidget; QTabWidget *fTabWidget;
QMap<PSubTextEdit*, QString> fFilenames; QMap<PSubTextEdit*, QString> fFilenames;
}; };

View File

@ -9,7 +9,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>541</width> <width>541</width>
<height>206</height> <height>184</height>
</rect> </rect>
</property> </property>
<property name="caption"> <property name="caption">
@ -33,7 +33,7 @@
<x>10</x> <x>10</x>
<y>20</y> <y>20</y>
<width>520</width> <width>520</width>
<height>130</height> <height>110</height>
</rect> </rect>
</property> </property>
<widget class="QWidget"> <widget class="QWidget">
@ -100,22 +100,6 @@
<string>will generate a ROOT dump file after the fit with the data and the theory</string> <string>will generate a ROOT dump file after the fit with the data and the theory</string>
</property> </property>
</widget> </widget>
<widget class="QCheckBox">
<property name="name">
<cstring>fOpenMlogAfterFit_checkBox</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>140</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>open mlog after fit</string>
</property>
</widget>
</widget> </widget>
</widget> </widget>
<widget class="QLayoutWidget"> <widget class="QLayoutWidget">
@ -125,7 +109,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>160</y> <y>140</y>
<width>520</width> <width>520</width>
<height>33</height> <height>33</height>
</rect> </rect>
@ -207,7 +191,7 @@
</widget> </widget>
<images> <images>
<image name="image0"> <image name="image0">
<data format="PNG" length="270">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000000d549444154388db594510e84200c44a78653d1f34faf853fd66d2a2aa8fb1222697068cb80d0884cadda7c6e46392c1860c9010da2bd8d4629f1670140a3200869d536ad8a2d63cfc805bc7c338ac766b33eb4c279dadb5be1b72c5ab5c5d2f3028fcda6bff042f40dd2f3f119355477c7708fdd15a3eef8ecf0f2868f847bb733332c1c9d43a344f15e9bca51e25a3cde52493736d3e2d85cb27ff36861d0081ad18b15607b783a785cabb67d4da7bf5e890070f34eb5c245cee2c4cfebc533ca593e211ee2652bdef0bfd7ed4bb1e8f5a947688615932a98c849f587290000000049454e44ae426082</data> <data format="PNG" length="411">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000016249444154388d95544dae86200c9c1a169e471217707e5890d4f3b830e95b687d15e51349889982fd19a6252e0c6c001cb06e2b4637629abde0584b61aacf7bf0b06eebc5e88d5360b74fc18b9ed7f75bd82908210a01e0c204e33c8628029c99e8fd373ca853009023c3a530290d1a619abdf464aa7818dd682b3f232f8569ddd6cb594fa6578eab9f2f0f5105ede57888214ace692f3d33d591951602be719c72a2d18dc839512b93737de0989e74dcc2d3eca557d7371db7b0364daf3a865eceded41142949b8e7b38b32b86288fe7371d77bcb66d1ace4ceadcce9669f6a2f79dcdf0edbb1426752200c874ec8da6c37e6e2e0cfbadb798cd99c18571b11546ca090ed807cf85db23b2da6388a27ab7034a39d54a08403afc383c7514dab8a5e3a530a5431d4b667200e0c37f16e968efa70adede40a7e414bc3875663b4833d44a6adc548f59832dd3ce865fb8a9fbdaf1178e7f656ea724a59cba75fce5fb0774073f42f0dd40cc0000000049454e44ae426082</data>
</image> </image>
</images> </images>
<connections> <connections>

View File

@ -0,0 +1,28 @@
/* XPM */
static char * musrswap_xpm[] = {
"22 22 3 1",
" c None",
". c #000000",
"+ c #FF0000",
".. .. .... .... ",
".. .. . . . . ",
". . . . . . . ",
". ... . ... . . ",
". . . .. .... ",
". . . . . ",
". . . . . . ",
". . .+.. . . ",
" +++ ",
" +++++ ",
" ++ + ++ ",
" + ",
" ++ + ++ ",
" +++++ ",
".. .. .+++... ... ",
".. .. . +.. .. .. ..",
". . . . . . . . .",
". ... . . . . . ",
". . . . . . . ...",
". . . . . . .",
". . . .. .. .. ..",
". . ....... ... "};

View File

@ -64,4 +64,5 @@ IMAGES = images/editcopy.xpm \
images/musrmlog2db.xpm \ images/musrmlog2db.xpm \
images/musrview.xpm \ images/musrview.xpm \
images/musrt0.xpm \ images/musrt0.xpm \
images/musrprefs.xpm images/musrprefs.xpm \
images/musrswap.xpm

View File

@ -8,8 +8,6 @@
<exec_path>/home/nemu/analysis/bin</exec_path> <exec_path>/home/nemu/analysis/bin</exec_path>
<default_save_path>/mnt/home/nemu/analysis</default_save_path> <default_save_path>/mnt/home/nemu/analysis</default_save_path>
<msr_default_file_path>/home/nemu/analysis/musrfit/src/musrgui</msr_default_file_path> <msr_default_file_path>/home/nemu/analysis/musrfit/src/musrgui</msr_default_file_path>
<show_mlog>y</show_mlog>
<open_mlog_after_fit>y</open_mlog_after_fit>
</general> </general>
<msr_file_defaults> <msr_file_defaults>
<beamline>mue4</beamline> <beamline>mue4</beamline>