add a user interface option to export data from a msr-file view (single- or multiple files).
This commit is contained in:
@ -62,6 +62,8 @@
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QRegExp>
|
||||
#include <QElapsedTimer>
|
||||
#include <QThread>
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>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", "<b>In the pipeline</b>.\nIt might take a couple of seconds to complete everything.");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Calls musrt0 <msr-file>.
|
||||
|
Reference in New Issue
Block a user