diff --git a/src/musrgui/PAdmin.cpp b/src/musrgui/PAdmin.cpp index 987ce5af..46305472 100644 --- a/src/musrgui/PAdmin.cpp +++ b/src/musrgui/PAdmin.cpp @@ -80,10 +80,6 @@ bool PAdminXMLParser::startElement( const QString&, const QString&, fKeyWord = eFileFormat; } else if (qName == "msr_default_file_path") { fKeyWord = eMsrDefaultFilePath; - } else if (qName == "show_mlog") { - fKeyWord = eShowMlog; - } else if (qName == "open_mlog_after_fit") { - fKeyWord = eOpenMlogAfterFit; } return true; @@ -127,18 +123,6 @@ bool PAdminXMLParser::characters(const QString& str) case eMsrDefaultFilePath: fAdmin->setMsrDefaultFilePath(QString(str.ascii()).stripWhiteSpace()); 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: break; } @@ -172,9 +156,6 @@ PAdmin::PAdmin() fInstitute = QString(""); fFileFormat = QString(""); - fShowMlog = true; - fOpenMlogAfterFit = true; - // XML Parser part QString path = getenv("MUSRFITPATH"); if (path.isEmpty()) diff --git a/src/musrgui/PAdmin.h b/src/musrgui/PAdmin.h index 54762508..71c67190 100644 --- a/src/musrgui/PAdmin.h +++ b/src/musrgui/PAdmin.h @@ -47,7 +47,7 @@ class PAdminXMLParser : public QXmlDefaultHandler private: enum EAdminKeyWords {eEmpty, eExecPath, eDefaultSavePath, eBeamline, eInstitute, eFileFormat, - eMsrDefaultFilePath, eShowMlog, eOpenMlogAfterFit}; + eMsrDefaultFilePath}; bool startDocument(); bool startElement( const QString&, const QString&, const QString& , @@ -74,8 +74,6 @@ class PAdmin QString getInstitute() { return fInstitute; } QString getFileFormat() { return fFileFormat; } QString getMsrDefaultFilePath() { return fMsrDefaultFilePath; } - bool getShowMlog() { return fShowMlog; } - bool getOpenMlogAfterFit() { return fOpenMlogAfterFit; } protected: void setExecPath(const QString str) { fExecPath = str; } @@ -84,8 +82,6 @@ class PAdmin void setInstitute(const QString str) { fInstitute = str; } void setFileFormat(const QString str) { fFileFormat = str; } void setMsrDefaultFilePath(const QString str) { fMsrDefaultFilePath = str; } - void setShowMlog(const bool flag) { fShowMlog = flag; } - void setOpenMlogAfterFit(const bool flag) { fOpenMlogAfterFit = flag; } private: friend class PAdminXMLParser; @@ -98,8 +94,6 @@ class PAdmin QString fFileFormat; QString fMsrDefaultFilePath; - bool fShowMlog; - bool fOpenMlogAfterFit; }; #endif // _PADMIN_H_ diff --git a/src/musrgui/PPrefsDialog.cpp b/src/musrgui/PPrefsDialog.cpp index b7b9cb80..a473e173 100644 --- a/src/musrgui/PPrefsDialog.cpp +++ b/src/musrgui/PPrefsDialog.cpp @@ -35,18 +35,13 @@ /** *

*/ -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) fKeepMn2Output_checkBox->setChecked(true); else fKeepMn2Output_checkBox->setChecked(false); - if (open_mlog_after_fit) - fOpenMlogAfterFit_checkBox->setChecked(true); - else - fOpenMlogAfterFit_checkBox->setChecked(false); - if (dump_tag == 1) { fDumpAscii_checkBox->setChecked(true); fDumpRoot_checkBox->setChecked(false); diff --git a/src/musrgui/PPrefsDialog.h b/src/musrgui/PPrefsDialog.h index bb1671e3..0b67289d 100644 --- a/src/musrgui/PPrefsDialog.h +++ b/src/musrgui/PPrefsDialog.h @@ -39,10 +39,9 @@ class PPrefsDialog : public PPrefsDialogBase { 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 openMlogAfterFit() { return fOpenMlogAfterFit_checkBox->isChecked(); } int getDump(); public slots: diff --git a/src/musrgui/PTextEdit.cpp b/src/musrgui/PTextEdit.cpp index 19683a40..d7a4f739 100644 --- a/src/musrgui/PTextEdit.cpp +++ b/src/musrgui/PTextEdit.cpp @@ -103,8 +103,6 @@ PTextEdit::PTextEdit( QWidget *parent, const char *name ) { fAdmin = new PAdmin(); - fShowMlog = fAdmin->getShowMlog(); - fOpenMlogAfterFit = fAdmin->getOpenMlogAfterFit(); fKeepMinuit2Output = false; fDump = 0; // 0 = no dump, 1 = ascii dump, 2 = root dump @@ -272,6 +270,11 @@ void PTextEdit::setupMusrActions() a->addTo( tb ); 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" ); connect( a, SIGNAL( activated() ), this, SLOT( musrMlog2Db() ) ); a->addTo( tb ); @@ -293,17 +296,6 @@ void PTextEdit::setupMusrActions() connect( a, SIGNAL( activated() ), this, SLOT( musrPrefs() ) ); a->addTo( tb ); 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.exec(); + musrSwapMsrMlog(); +/* if (fOpenMlogAfterFit) { // get current file name and replace the msr-extension through mlog str = fTabWidget->label(fTabWidget->currentPageIndex()); @@ -888,6 +882,7 @@ void PTextEdit::musrFit() // open mlog files load(str); } +*/ } //---------------------------------------------------------------------------------------------------- @@ -1059,11 +1054,6 @@ void PTextEdit::musrView() cmd = str + " "; str = *fFilenames.find( currentEditor() ); - if (fShowMlog) { - int idx = str.find(".msr"); - if (idx > 0) - str.replace(idx, 4, ".mlog"); - } cmd += str + " &"; system(cmd.latin1()); @@ -1089,11 +1079,10 @@ void PTextEdit::musrT0() */ void PTextEdit::musrPrefs() { - PPrefsDialog *dlg = new PPrefsDialog(fKeepMinuit2Output, fOpenMlogAfterFit, fDump); + PPrefsDialog *dlg = new PPrefsDialog(fKeepMinuit2Output, fDump); if (dlg->exec() == QDialog::Accepted) { fKeepMinuit2Output = dlg->keepMinuit2Output(); - fOpenMlogAfterFit = dlg->openMlogAfterFit(); fDump = dlg->getDump(); } } @@ -1102,12 +1091,74 @@ void PTextEdit::musrPrefs() /** *

*/ -void PTextEdit::musrShowMlog( const QString &str ) +void PTextEdit::musrSwapMsrMlog() { - if (str.find("mlog") > 0) - fShowMlog = true; - else - fShowMlog = false; + if ( !currentEditor() ) + return; + + // 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; icount(); 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); + } } //---------------------------------------------------------------------------------------------------- diff --git a/src/musrgui/PTextEdit.h b/src/musrgui/PTextEdit.h index 026eaf9f..fc5805cb 100644 --- a/src/musrgui/PTextEdit.h +++ b/src/musrgui/PTextEdit.h @@ -88,7 +88,7 @@ private slots: void musrView(); void musrT0(); void musrPrefs(); - void musrShowMlog( const QString &str ); + void musrSwapMsrMlog(); void helpContents(); void helpAboutQt(); @@ -100,16 +100,12 @@ private slots: private: PAdmin *fAdmin; - bool fShowMlog; - bool fOpenMlogAfterFit; bool fKeepMinuit2Output; int fDump; QComboBox *fComboFont; QComboBox *fComboSize; - QComboBox *fComboShowMlog; - QTabWidget *fTabWidget; QMap fFilenames; }; diff --git a/src/musrgui/forms/PPrefsDialogBase.ui b/src/musrgui/forms/PPrefsDialogBase.ui index 67bb5eb9..0fa59247 100644 --- a/src/musrgui/forms/PPrefsDialogBase.ui +++ b/src/musrgui/forms/PPrefsDialogBase.ui @@ -9,7 +9,7 @@ 0 0 541 - 206 + 184 @@ -33,7 +33,7 @@ 10 20 520 - 130 + 110 @@ -100,22 +100,6 @@ will generate a ROOT dump file after the fit with the data and the theory - - - fOpenMlogAfterFit_checkBox - - - - 10 - 70 - 140 - 22 - - - - open mlog after fit - - @@ -125,7 +109,7 @@ 10 - 160 + 140 520 33 @@ -207,7 +191,7 @@ - 89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000000d549444154388db594510e84200c44a78653d1f34faf853fd66d2a2aa8fb1222697068cb80d0884cadda7c6e46392c1860c9010da2bd8d4629f1670140a3200869d536ad8a2d63cfc805bc7c338ac766b33eb4c279dadb5be1b72c5ab5c5d2f3028fcda6bff042f40dd2f3f119355477c7708fdd15a3eef8ecf0f2868f847bb733332c1c9d43a344f15e9bca51e25a3cde52493736d3e2d85cb27ff36861d0081ad18b15607b783a785cabb67d4da7bf5e890070f34eb5c245cee2c4cfebc533ca593e211ee2652bdef0bfd7ed4bb1e8f5a947688615932a98c849f587290000000049454e44ae426082 + 89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000016249444154388d95544dae86200c9c1a169e471217707e5890d4f3b830e95b687d15e51349889982fd19a6252e0c6c001cb06e2b4637629abde0584b61aacf7bf0b06eebc5e88d5360b74fc18b9ed7f75bd82908210a01e0c204e33c8628029c99e8fd373ca853009023c3a530290d1a619abdf464aa7818dd682b3f232f8569ddd6cb594fa6578eab9f2f0f5105ede57888214ace692f3d33d591951602be719c72a2d18dc839512b93737de0989e74dcc2d3eca557d7371db7b0364daf3a865eceded41142949b8e7b38b32b86288fe7371d77bcb66d1ace4ceadcce9669f6a2f79dcdf0edbb1426752200c874ec8da6c37e6e2e0cfbadb798cd99c18571b11546ca090ed807cf85db23b2da6388a27ab7034a39d54a08403afc383c7514dab8a5e3a530a5431d4b667200e0c37f16e968efa70adede40a7e414bc3875663b4833d44a6adc548f59832dd3ce865fb8a9fbdaf1178e7f656ea724a59cba75fce5fb0774073f42f0dd40cc0000000049454e44ae426082 diff --git a/src/musrgui/images/musrswap.xpm b/src/musrgui/images/musrswap.xpm new file mode 100644 index 00000000..b95e4e9f --- /dev/null +++ b/src/musrgui/images/musrswap.xpm @@ -0,0 +1,28 @@ +/* XPM */ +static char * musrswap_xpm[] = { +"22 22 3 1", +" c None", +". c #000000", +"+ c #FF0000", +".. .. .... .... ", +".. .. . . . . ", +". . . . . . . ", +". ... . ... . . ", +". . . .. .... ", +". . . . . ", +". . . . . . ", +". . .+.. . . ", +" +++ ", +" +++++ ", +" ++ + ++ ", +" + ", +" ++ + ++ ", +" +++++ ", +".. .. .+++... ... ", +".. .. . +.. .. .. ..", +". . . . . . . . .", +". ... . . . . . ", +". . . . . . . ...", +". . . . . . .", +". . . .. .. .. ..", +". . ....... ... "}; diff --git a/src/musrgui/musrgui.pro b/src/musrgui/musrgui.pro index 3f6065e0..c37ed290 100644 --- a/src/musrgui/musrgui.pro +++ b/src/musrgui/musrgui.pro @@ -64,4 +64,5 @@ IMAGES = images/editcopy.xpm \ images/musrmlog2db.xpm \ images/musrview.xpm \ images/musrt0.xpm \ - images/musrprefs.xpm + images/musrprefs.xpm \ + images/musrswap.xpm diff --git a/src/musrgui/musrgui_startup.xml b/src/musrgui/musrgui_startup.xml index 94589f2b..1e438ed1 100644 --- a/src/musrgui/musrgui_startup.xml +++ b/src/musrgui/musrgui_startup.xml @@ -8,8 +8,6 @@ /home/nemu/analysis/bin /mnt/home/nemu/analysis /home/nemu/analysis/musrfit/src/musrgui - y - y mue4