added muSR data run header information dump to musredit
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
|
||||
changes since 0.11.0
|
||||
===================================
|
||||
NEW 2012-05-25 musredit: added a dump muSR data header file information.
|
||||
NEW 2012-05-22 added spin rotation angle to the LEM MusrRoot file.
|
||||
NEW 2012-05-12 added dump_header. This is a little program which dumps the
|
||||
header information of a given muSR data file onto the standard
|
||||
|
158
src/musredit/PDumpOutputHandler.cpp
Normal file
158
src/musredit/PDumpOutputHandler.cpp
Normal file
@ -0,0 +1,158 @@
|
||||
/****************************************************************************
|
||||
|
||||
PDumpOutputHandler.cpp
|
||||
|
||||
Author: Andreas Suter
|
||||
e-mail: andreas.suter@psi.ch
|
||||
|
||||
$Id$
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2012 by Andreas Suter *
|
||||
* andreas.suter@psi.ch *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
#include "PDumpOutputHandler.h"
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Sets up the dump output handler GUI and starts the actual dump_header command
|
||||
*
|
||||
* \param cmd command string vector. From this the actual dump_header command will be generated and executed.
|
||||
*/
|
||||
PDumpOutputHandler::PDumpOutputHandler(QVector<QString> &cmd)
|
||||
{
|
||||
if (cmd.empty())
|
||||
return;
|
||||
|
||||
// Layout
|
||||
fVbox = new QVBoxLayout( this );
|
||||
fOutput = new QTextEdit();
|
||||
fVbox->addWidget(fOutput);
|
||||
fOutput->setMinimumSize(600, 755);
|
||||
fOutput->setReadOnly(true);
|
||||
connect( fOutput, SIGNAL( destroyed() ), this, SLOT( quitButtonPressed() ) );
|
||||
fQuitButton = new QPushButton( tr("Quit") );
|
||||
fVbox->addWidget(fQuitButton);
|
||||
connect( fQuitButton, SIGNAL( clicked() ), this, SLOT( quitButtonPressed() ) );
|
||||
resize( 600, 800 );
|
||||
fQuitButton->setFocus();
|
||||
|
||||
// QProcess related code
|
||||
fProc = new QProcess( this );
|
||||
|
||||
// fProc->setWorkingDirectory(workingDirectory);
|
||||
|
||||
// Set up the command and arguments.
|
||||
QString program = cmd[0];
|
||||
QStringList arguments;
|
||||
for (int i=1; i<cmd.size(); i++)
|
||||
arguments << cmd[i];
|
||||
|
||||
connect( fProc, SIGNAL( readyReadStandardOutput() ), this, SLOT( readFromStdOut() ) );
|
||||
connect( fProc, SIGNAL( readyReadStandardError() ), this, SLOT( readFromStdErr() ) );
|
||||
// connect( fProc, SIGNAL( finished(int, QProcess::ExitStatus) ), this, SLOT( processDone(int, QProcess::ExitStatus) ) );
|
||||
|
||||
fProc->start(program, arguments);
|
||||
if ( !fProc->waitForStarted() ) {
|
||||
// error handling
|
||||
QString msg(tr("Could not execute the output command: ")+cmd[0]);
|
||||
QMessageBox::critical( 0,
|
||||
tr("Fatal error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
done(0);
|
||||
}
|
||||
fProcPID = fProc->pid();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Destructor. Checks if the a dump_header is still running and if yes try to kill it.
|
||||
*/
|
||||
PDumpOutputHandler::~PDumpOutputHandler()
|
||||
{
|
||||
if (fProc->state() == QProcess::Running) {
|
||||
fProc->terminate();
|
||||
if (!fProc->waitForFinished()) {
|
||||
qDebug() << "fProc still running, will call kill." << endl;
|
||||
fProc->kill();
|
||||
}
|
||||
fProc->waitForFinished();
|
||||
}
|
||||
if (fProc->state() == QProcess::Running) {
|
||||
QString cmd = "kill -9 "+ fProcPID;
|
||||
QString msg = "fProc still running even after Qt kill, will try system kill cmd: "+cmd;
|
||||
qDebug() << msg << endl;
|
||||
system(cmd.toLatin1());
|
||||
}
|
||||
if (fProc) {
|
||||
delete fProc;
|
||||
fProc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Captures the standard output and adds it to the output text edit.
|
||||
*/
|
||||
void PDumpOutputHandler::readFromStdOut()
|
||||
{
|
||||
// Read and process the data.
|
||||
// Bear in mind that the data might be output in chunks.
|
||||
fOutput->append( fProc->readAllStandardOutput() );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Captures the standard error and adds it to the output text edit.
|
||||
*/
|
||||
void PDumpOutputHandler::readFromStdErr()
|
||||
{
|
||||
// Read and process the data.
|
||||
// Bear in mind that the data might be output in chunks.
|
||||
fOutput->append( fProc->readAllStandardError() );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>If the quit button is pressed while the dump_header is still running, try to terminate dump_header, if this
|
||||
* does not work, try to kill dump_header.
|
||||
*/
|
||||
void PDumpOutputHandler::quitButtonPressed()
|
||||
{
|
||||
// if the fitting is still taking place, kill it
|
||||
if (fProc->state() == QProcess::Running) {
|
||||
fProc->terminate();
|
||||
if (!fProc->waitForFinished()) {
|
||||
fProc->kill();
|
||||
}
|
||||
}
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// END
|
||||
//----------------------------------------------------------------------------------------------------
|
74
src/musredit/PDumpOutputHandler.h
Normal file
74
src/musredit/PDumpOutputHandler.h
Normal file
@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
|
||||
PDumpOutputHandler.h
|
||||
|
||||
Author: Andreas Suter
|
||||
e-mail: andreas.suter@psi.ch
|
||||
|
||||
$Id$
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2012 by Andreas Suter *
|
||||
* andreas.suter@psi.ch *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _PDUMPOUTPUTHANDLER_H_
|
||||
#define _PDUMPOUTPUTHANDLER_H_
|
||||
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include <QDialog>
|
||||
#include <QVBoxLayout>
|
||||
#include <QTextEdit>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
#include <QVector>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>This class is the capturing the output of musrfit and displays it in a dialog so
|
||||
* the user has the chance to follow the fitting process, warnings, error messages of
|
||||
* musrfit.
|
||||
*/
|
||||
class PDumpOutputHandler : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PDumpOutputHandler(QVector<QString> &cmd);
|
||||
virtual ~PDumpOutputHandler();
|
||||
|
||||
private slots:
|
||||
virtual void readFromStdOut();
|
||||
virtual void readFromStdErr();
|
||||
virtual void quitButtonPressed();
|
||||
|
||||
private:
|
||||
Q_PID fProcPID; ///< keeps the process PID
|
||||
QProcess *fProc; ///< pointer to the dump_header process
|
||||
|
||||
QVBoxLayout *fVbox; ///< pointer to the dialog layout manager
|
||||
QTextEdit *fOutput; ///< the captured dump_header output is written (read only) into this text edit object.
|
||||
QPushButton *fQuitButton; ///< quit button
|
||||
};
|
||||
|
||||
#endif // _PDUMPOUTPUTHANDLER_H_
|
@ -68,6 +68,7 @@ using namespace std;
|
||||
#include "PReplaceDialog.h"
|
||||
#include "PReplaceConfirmationDialog.h"
|
||||
#include "PFitOutputHandler.h"
|
||||
#include "PDumpOutputHandler.h"
|
||||
#include "PPrefsDialog.h"
|
||||
#include "PGetDefaultDialog.h"
|
||||
#include "PMusrEditAbout.h"
|
||||
@ -551,6 +552,15 @@ void PTextEdit::setupMusrActions()
|
||||
connect( a, SIGNAL( triggered() ), this, SLOT( musrPrefs() ) );
|
||||
tb->addAction(a);
|
||||
menu->addAction(a);
|
||||
|
||||
menu->addSeparator();
|
||||
tb->addSeparator();
|
||||
|
||||
a = new QAction( QIcon( QPixmap(":/images/musrdump.xpm")), tr( "&Dump Header"), this);
|
||||
a->setStatusTip( tr("Dumps muSR File Header Information") );
|
||||
connect( a, SIGNAL(triggered()), this, SLOT(musrDump()));
|
||||
tb->addAction(a);
|
||||
menu->addAction(a);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -2207,6 +2217,25 @@ void PTextEdit::musrSwapMsrMlog()
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Dumps the run header information of a selected muSR data file.
|
||||
*/
|
||||
void PTextEdit::musrDump()
|
||||
{
|
||||
// select a muSR data filename
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Select muSR Data File"), "./", tr("muSR Data Files (*.root *.bin *.msr *.nxs)"));
|
||||
|
||||
QVector<QString> cmd;
|
||||
QString str = fAdmin->getExecPath() + "/dump_header";
|
||||
cmd.append(str);
|
||||
cmd.append(fileName);
|
||||
|
||||
PDumpOutputHandler dumpOutputHandler(cmd);
|
||||
dumpOutputHandler.setModal(false);
|
||||
dumpOutputHandler.exec();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Starts the help content browser.
|
||||
|
@ -124,6 +124,7 @@ private slots:
|
||||
void musrT0();
|
||||
void musrPrefs();
|
||||
void musrSwapMsrMlog();
|
||||
void musrDump();
|
||||
|
||||
void helpContents();
|
||||
void helpAboutQt();
|
||||
|
28
src/musredit/images/musrdump.xpm
Normal file
28
src/musredit/images/musrdump.xpm
Normal file
@ -0,0 +1,28 @@
|
||||
/* XPM */
|
||||
static char * musrdump_xpm[] = {
|
||||
"22 22 3 1",
|
||||
" c None",
|
||||
". c #0000FF",
|
||||
"+ c #000000",
|
||||
"... . . . . ... ",
|
||||
". . . . .. .. . .",
|
||||
". . . . . . . . .",
|
||||
". . . . . . . . .",
|
||||
". . . . . . ... ",
|
||||
". . . . . . . ",
|
||||
"... ... . . . ",
|
||||
" ",
|
||||
" ",
|
||||
"+++ ",
|
||||
" ++++ ",
|
||||
" + ",
|
||||
" ++++ ",
|
||||
" + ",
|
||||
" ++++ ",
|
||||
" + + ",
|
||||
" + +++++ ",
|
||||
" + +++ ",
|
||||
" ++++ + ",
|
||||
" +++ +++ ",
|
||||
" + ++++ ",
|
||||
" +++ + "};
|
@ -81,6 +81,7 @@ HEADERS = musredit.h \
|
||||
PReplaceDialog.h \
|
||||
PReplaceConfirmationDialog.h \
|
||||
PFitOutputHandler.h \
|
||||
PDumpOutputHandler.h \
|
||||
PPrefsDialog.h \
|
||||
PGetDefaultDialog.h \
|
||||
PGetTitleBlockDialog.h \
|
||||
@ -103,6 +104,7 @@ SOURCES = PHelp.cpp \
|
||||
PReplaceDialog.cpp \
|
||||
PReplaceConfirmationDialog.cpp \
|
||||
PFitOutputHandler.cpp \
|
||||
PDumpOutputHandler.cpp \
|
||||
PPrefsDialog.cpp \
|
||||
PGetDefaultDialog.cpp \
|
||||
PGetTitleBlockDialog.cpp \
|
||||
|
@ -22,6 +22,7 @@
|
||||
<file>images/musrswap.xpm</file>
|
||||
<file>images/musrt0.xpm</file>
|
||||
<file>images/musrview.xpm</file>
|
||||
<file>images/musrdump.xpm</file>
|
||||
<file>latex_images/abragam.png</file>
|
||||
<file>latex_images/asymmetry.png</file>
|
||||
<file>latex_images/bessel.png</file>
|
||||
|
Reference in New Issue
Block a user