diff --git a/CMakeLists.txt b/CMakeLists.txt index b4594c21..de00f5af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # - musrfit cmake_minimum_required(VERSION 3.17) -project(musrfit VERSION 1.9.7 LANGUAGES C CXX) +project(musrfit VERSION 1.9.8 LANGUAGES C CXX) #--- musrfit specific options ------------------------------------------------- option(nexus "build optional NeXus support. Needed for ISIS" OFF) diff --git a/ChangeLog b/ChangeLog index eef5a5d7..7c8c59a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,11 @@ or https://bitbucket.org/muonspin/musrfit/commits/all +Release of V1.9.8, 2025/03/24 +============================= + +add a user interface option to export data from a msr-file view (single- or multiple files). + Release of V1.9.7, 2025/01/18 ============================= diff --git a/src/musredit_qt5/musredit/PTextEdit.cpp b/src/musredit_qt5/musredit/PTextEdit.cpp index 781fed98..b42d0300 100644 --- a/src/musredit_qt5/musredit/PTextEdit.cpp +++ b/src/musredit_qt5/musredit/PTextEdit.cpp @@ -62,6 +62,8 @@ #include #include #include +#include +#include #include @@ -830,6 +832,25 @@ void PTextEdit::setupMusrActions() tb->addAction(a); fActions["mupp-tb"] = a; + // musrView2dat + if (fDarkMenuIcon) + iconName = QString(":/icons/musrview2dat-dark.svg"); + else + iconName = QString(":/icons/musrview2dat-plain.svg"); + a = new QAction( QIcon( QPixmap(iconName) ), tr( "View2Dat" ), this ); + a->setStatusTip( tr("export musrview data") ); + connect( a, SIGNAL( triggered() ), this, SLOT( musrView2Dat() ) ); + menu->addAction(a); + fActions["musrview2dat"] = a; + + if (!fDarkToolBarIcon) { // tool bar icon is not dark, even though the theme is (ubuntu) + iconName = QString(":/icons/musrview2dat-plain.svg"); + a = new QAction( QIcon( QPixmap(iconName) ), tr( "View2Dat" ), this ); + connect( a, SIGNAL( triggered() ), this, SLOT( musrView2Dat() ) ); + } + tb->addAction(a); + fActions["musrview2dat-tb"] = a; + menu->addSeparator(); tb->addSeparator(); @@ -2616,6 +2637,66 @@ void PTextEdit::musrView() } } +//---------------------------------------------------------------------------------------------------- +/** + *

Exports the view data of a collection of msr-files to a dat-file. + */ +void PTextEdit::musrView2Dat() +{ + QStringList flns = QFileDialog::getOpenFileNames( this, tr("Open msr-/mlog-File"), + fLastDirInUse, + tr( "msr-Files (*.msr)" )); + if (flns.isEmpty()) + return; + + QString cmd = fAdmin->getExecPath() + "/musrview"; + QString workDir = QFileInfo(*fFilenames.find( currentEditor() )).absolutePath(); + QStringList arg; + + for (auto it : flns) { + std::cout << it.toLatin1().data() << std::endl; + arg.clear(); + arg << it; + + // start with Fourier? + if (fAdmin->getMusrviewShowFourierFlag()) + arg << "-f"; + + // start with averaged data/Fourier? + if (fAdmin->getMusrviewShowAvgFlag()) + arg << "-a"; + + // check if theory shall only be calculated at the data points + if (fAdmin->getMusrviewShowOneToOneFlag()) + arg << "-1"; + + arg << "--ascii"; + + QProcess proc; + // make sure that the system environment variables are properly set + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); +#if defined(Q_OS_DARWIN) + env.insert("DYLD_LIBRARY_PATH", env.value("ROOTSYS") + "/lib:/usr/local/lib:" + env.value("DYLD_LIBRARY_PATH")); +#else + env.insert("LD_LIBRARY_PATH", env.value("ROOTSYS") + "/lib:" + env.value("LD_LIBRARY_PATH")); +#endif + proc.setProgram(cmd); + proc.setProcessEnvironment(env); + proc.setArguments(arg); + proc.setWorkingDirectory(workDir); + if (!proc.startDetached()) { + QString msg = QString("musrview failed. Possible reasons:\n"); + msg += QString("* corrupted msr-file.\n"); + msg += QString("* cannot read data-file.\n"); + msg += QString("* many more things can go wrong.\n"); + msg += QString("Please check!"); + QMessageBox::critical(nullptr, tr("FATAL ERROR"), msg, QMessageBox::Close); + } + } + + QMessageBox::information(this, "INFO", "In the pipeline.\nIt might take a couple of seconds to complete everything."); +} + //---------------------------------------------------------------------------------------------------- /** *

Calls musrt0 . diff --git a/src/musredit_qt5/musredit/PTextEdit.h b/src/musredit_qt5/musredit/PTextEdit.h index 335f2fd6..7502984e 100644 --- a/src/musredit_qt5/musredit/PTextEdit.h +++ b/src/musredit_qt5/musredit/PTextEdit.h @@ -141,6 +141,7 @@ private slots: void musrFit(); void musrMsr2Data(); void musrView(); + void musrView2Dat(); void musrT0(); void musrFT(); void musrPrefs(); diff --git a/src/musredit_qt5/musredit/icons/musrview2dat-dark.svg b/src/musredit_qt5/musredit/icons/musrview2dat-dark.svg new file mode 100644 index 00000000..87bdda9e --- /dev/null +++ b/src/musredit_qt5/musredit/icons/musrview2dat-dark.svg @@ -0,0 +1,248 @@ + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/musredit_qt5/musredit/icons/musrview2dat-plain.svg b/src/musredit_qt5/musredit/icons/musrview2dat-plain.svg new file mode 100644 index 00000000..88315c22 --- /dev/null +++ b/src/musredit_qt5/musredit/icons/musrview2dat-plain.svg @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/musredit_qt5/musredit/musredit.qrc b/src/musredit_qt5/musredit/musredit.qrc index fe4de151..5022c1ab 100644 --- a/src/musredit_qt5/musredit/musredit.qrc +++ b/src/musredit_qt5/musredit/musredit.qrc @@ -46,6 +46,8 @@ icons/musrt0-dark.svg icons/musrview-plain.svg icons/musrview-dark.svg + icons/musrview2dat-plain.svg + icons/musrview2dat-dark.svg icons/musrFT-plain.svg icons/musrFT-dark.svg icons/musrdump-plain.svg