added the additional mlog2db switches. Still a lot of testing needed ;-)

This commit is contained in:
nemu 2009-04-09 08:10:42 +00:00
parent 5a1b94bc10
commit 9eeac3de9c
9 changed files with 274 additions and 78 deletions

View File

@ -41,15 +41,85 @@
/** /**
* <p> * <p>
*/ */
PMlog2DbDialog::PMlog2DbDialog(const bool keepMinuit2Output) PMlog2DbDialog::PMlog2DbDialog(PMlog2DbDataSet *mlog2DbDataSet) : fMlog2DbDataSet(mlog2DbDataSet)
{ {
QString str;
fRunTag = -1; fRunTag = -1;
fFirst_lineEdit->setValidator( new QIntValidator(fFirst_lineEdit) ); fFirst_lineEdit->setValidator( new QIntValidator(fFirst_lineEdit) );
fLast_lineEdit->setValidator( new QIntValidator(fLast_lineEdit) ); if (fMlog2DbDataSet->firstRun != -1) {
fTemplateRunNumber_lineEdit->setValidator( new QIntValidator(fTemplateRunNumber_lineEdit) ); str = QString("%1").arg(fMlog2DbDataSet->firstRun);
fFirst_lineEdit->setText(str);
}
fKeepMinuit2Output_checkBox->setChecked(keepMinuit2Output); fLast_lineEdit->setValidator( new QIntValidator(fLast_lineEdit) );
if (fMlog2DbDataSet->lastRun != -1) {
str = QString("%1").arg(fMlog2DbDataSet->lastRun);
fLast_lineEdit->setText(str);
}
if (!fMlog2DbDataSet->runListFileName.isEmpty()) {
fRunListFileName_lineEdit->setText(fMlog2DbDataSet->runListFileName);
}
if (!fMlog2DbDataSet->runList.isEmpty()) {
fRunList_lineEdit->setText(fMlog2DbDataSet->runList);
}
if (!fMlog2DbDataSet->msrFileExtension.isEmpty()) {
fExtension_lineEdit->setText(fMlog2DbDataSet->msrFileExtension);
}
fTemplateRunNumber_lineEdit->setValidator( new QIntValidator(fTemplateRunNumber_lineEdit) );
if (fMlog2DbDataSet->templateRunNo != -1) {
str = QString("%1").arg(fMlog2DbDataSet->templateRunNo);
fTemplateRunNumber_lineEdit->setText(str);
}
if (!fMlog2DbDataSet->dbOutputFileName.isEmpty()) {
fDbOutputFileName_lineEdit->setText(fMlog2DbDataSet->dbOutputFileName);
}
fWriteDbHeader_checkBox->setChecked(fMlog2DbDataSet->writeDbHeader);
fSummaryPresent_checkBox->setChecked(fMlog2DbDataSet->summaryFilePresent);
fKeepMinuit2Output_checkBox->setChecked(fMlog2DbDataSet->keepMinuit2Output);
fWriteColumnData_checkBox->setChecked(fMlog2DbDataSet->writeColumnData);
fRecreateDbFile_checkBox->setChecked(fMlog2DbDataSet->recreateDbFile);
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
PMlog2DbDataSet* PMlog2DbDialog::getMlog2DbDataSet()
{
if (fFirst_lineEdit->text().isEmpty()) {
fMlog2DbDataSet->firstRun = -1;
} else {
fMlog2DbDataSet->firstRun = fFirst_lineEdit->text().toInt();
}
if (fLast_lineEdit->text().isEmpty()) {
fMlog2DbDataSet->lastRun = -1;
} else {
fMlog2DbDataSet->lastRun = fLast_lineEdit->text().toInt();
}
fMlog2DbDataSet->runList = fRunList_lineEdit->text();
fMlog2DbDataSet->runListFileName = fRunListFileName_lineEdit->text();
fMlog2DbDataSet->msrFileExtension = fExtension_lineEdit->text();
if (fTemplateRunNumber_lineEdit->text().isEmpty()) {
fMlog2DbDataSet->templateRunNo = -1;
} else {
fMlog2DbDataSet->templateRunNo = fTemplateRunNumber_lineEdit->text().toInt();
}
fMlog2DbDataSet->dbOutputFileName = fDbOutputFileName_lineEdit->text();
fMlog2DbDataSet->writeDbHeader = fWriteDbHeader_checkBox->isChecked();
fMlog2DbDataSet->summaryFilePresent = fSummaryPresent_checkBox->isChecked();
fMlog2DbDataSet->keepMinuit2Output = fKeepMinuit2Output_checkBox->isChecked();
fMlog2DbDataSet->writeColumnData = fWriteColumnData_checkBox->isChecked();
fMlog2DbDataSet->recreateDbFile = fRecreateDbFile_checkBox->isChecked();
return fMlog2DbDataSet;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------

View File

@ -32,24 +32,16 @@
#ifndef _PMLOG2DBDIALOG_H_ #ifndef _PMLOG2DBDIALOG_H_
#define _PMLOG2DBDIALOG_H_ #define _PMLOG2DBDIALOG_H_
#include "musrgui.h"
#include "forms/PMlog2DbDialogBase.h" #include "forms/PMlog2DbDialogBase.h"
class PMlog2DbDialog : public PMlog2DbDialogBase class PMlog2DbDialog : public PMlog2DbDialogBase
{ {
public: public:
PMlog2DbDialog(const bool keepMinuit2Output); PMlog2DbDialog(PMlog2DbDataSet *mlog2DbDataSet);
int getRunTag() { return fRunTag; } virtual int getRunTag() { return fRunTag; }
QString getFirstRunNo() { return fFirst_lineEdit->text(); } virtual PMlog2DbDataSet* getMlog2DbDataSet();
QString getLastRunNo() { return fLast_lineEdit->text(); }
QString getRunList() { return fRunList_lineEdit->text(); }
QString getRunListFileName() { return fRunListFileName_lineEdit->text(); }
QString getExtension() { return fExtension_lineEdit->text(); }
QString getTemplateRunNo() { return fTemplateRunNumber_lineEdit->text(); }
QString getDbOutputFileName() { return fDbOutputFileName_lineEdit->text(); }
bool getWriteDbHeaderFlag() { return fNoHeader_checkBox->isChecked(); }
bool getSummaryFilePresentFlag() { return fSummaryPresent_checkBox->isChecked(); }
bool getMinuit2OutputFlag() { return fKeepMinuit2Output_checkBox->isChecked(); }
public slots: public slots:
void runFirstLastEntered(); void runFirstLastEntered();
@ -58,6 +50,7 @@ class PMlog2DbDialog : public PMlog2DbDialogBase
private: private:
int fRunTag; // -1 = not valid, 0 = first last, 1 = run list, 2 = run list file name int fRunTag; // -1 = not valid, 0 = first last, 1 = run list, 2 = run list file name
PMlog2DbDataSet *fMlog2DbDataSet;
}; };
#endif // _PMLOG2DBDIALOG_H_ #endif // _PMLOG2DBDIALOG_H_

View File

@ -167,7 +167,7 @@ void PSubTextEdit::insertTheoryFunction(int idx)
int index = idx - 300; int index = idx - 300;
if (index >= fAdmin->getTheoryCounts()) if (index >= (int)fAdmin->getTheoryCounts())
return; return;
QString str = "????"; QString str = "????";

View File

@ -62,7 +62,6 @@ class PSubTextEdit : public QTextEdit
private: private:
PAdmin *fAdmin; PAdmin *fAdmin;
}; };
#endif // _PSUBTEXTEDIT_H_ #endif // _PSUBTEXTEDIT_H_

View File

@ -103,6 +103,8 @@ PTextEdit::PTextEdit( QWidget *parent, const char *name )
{ {
fAdmin = new PAdmin(); fAdmin = new PAdmin();
fMlog2DbDataSet = 0;
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
@ -130,6 +132,18 @@ PTextEdit::PTextEdit( QWidget *parent, const char *name )
} }
} }
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
PTextEdit::~PTextEdit()
{
if (fMlog2DbDataSet) {
delete fMlog2DbDataSet;
fMlog2DbDataSet = 0;
}
}
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
/** /**
* <p> * <p>
@ -926,26 +940,6 @@ void PTextEdit::musrFit()
fitOutputHandler.exec(); fitOutputHandler.exec();
musrSwapMsrMlog(); musrSwapMsrMlog();
/*
if (fOpenMlogAfterFit) {
// get current file name and replace the msr-extension through mlog
str = fTabWidget->label(fTabWidget->currentPageIndex());
int idx = str.find(".msr");
if (idx > 0) {
str.replace(idx, 4, ".mlog");
}
// check if mlog-file is already open, and if yes close it
for (int i=0; i<fTabWidget->count(); i++) {
if (fTabWidget->label(i).find(str) >= 0) {
delete fTabWidget->page(i);
}
}
// open mlog files
load(str);
}
*/
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -957,7 +951,24 @@ void PTextEdit::musrMlog2Db()
if ( !currentEditor() ) if ( !currentEditor() )
return; return;
PMlog2DbDialog *dlg = new PMlog2DbDialog(fKeepMinuit2Output); if (fMlog2DbDataSet == 0) {
fMlog2DbDataSet = new PMlog2DbDataSet();
// init fMlog2DbDataSet
fMlog2DbDataSet->firstRun = -1;
fMlog2DbDataSet->lastRun = -1;
fMlog2DbDataSet->runList = QString("");
fMlog2DbDataSet->runListFileName = QString("");
fMlog2DbDataSet->msrFileExtension = QString("");
fMlog2DbDataSet->templateRunNo = -1;
fMlog2DbDataSet->dbOutputFileName = QString("");
fMlog2DbDataSet->writeDbHeader = false;
fMlog2DbDataSet->summaryFilePresent = false;
fMlog2DbDataSet->keepMinuit2Output = fKeepMinuit2Output;
fMlog2DbDataSet->writeColumnData = false;
fMlog2DbDataSet->recreateDbFile = false;
}
PMlog2DbDialog *dlg = new PMlog2DbDialog(fMlog2DbDataSet);
if (dlg->exec() == QDialog::Accepted) { if (dlg->exec() == QDialog::Accepted) {
QString first, last; QString first, last;
@ -967,6 +978,8 @@ void PTextEdit::musrMlog2Db()
QString str; QString str;
int i, end; int i, end;
fMlog2DbDataSet = dlg->getMlog2DbDataSet();
// analyze parameters // analyze parameters
switch (dlg->getRunTag()) { switch (dlg->getRunTag()) {
case -1: // not valid case -1: // not valid
@ -976,8 +989,8 @@ void PTextEdit::musrMlog2Db()
return; return;
break; break;
case 0: // first last case 0: // first last
first = dlg->getFirstRunNo(); first = QString("%1").arg(fMlog2DbDataSet->firstRun);
last = dlg->getLastRunNo(); last = QString("%1").arg(fMlog2DbDataSet->lastRun);
if (first.isEmpty() || last.isEmpty()) { if (first.isEmpty() || last.isEmpty()) {
QMessageBox::critical(this, "**ERROR**", QMessageBox::critical(this, "**ERROR**",
"If you choose the first/last option,\nfirst AND last needs to be provided.", "If you choose the first/last option,\nfirst AND last needs to be provided.",
@ -986,7 +999,7 @@ void PTextEdit::musrMlog2Db()
} }
break; break;
case 1: // run list case 1: // run list
runList = dlg->getRunList(); runList = fMlog2DbDataSet->runList;
if (!validRunList(runList)) { if (!validRunList(runList)) {
QMessageBox::critical(this, "**ERROR**", QMessageBox::critical(this, "**ERROR**",
"Invalid Run List!\nThe run list needs to be a space separated list of run numbers.", "Invalid Run List!\nThe run list needs to be a space separated list of run numbers.",
@ -995,7 +1008,7 @@ void PTextEdit::musrMlog2Db()
} }
break; break;
case 2: // run list file name case 2: // run list file name
runListFileName = dlg->getRunListFileName(); runListFileName = fMlog2DbDataSet->runListFileName;
fi = runListFileName; fi = runListFileName;
if (!fi.exists()) { if (!fi.exists()) {
str = QString("Run List File '%1' doesn't exist.").arg(runListFileName); str = QString("Run List File '%1' doesn't exist.").arg(runListFileName);
@ -1051,7 +1064,7 @@ void PTextEdit::musrMlog2Db()
} }
// file extension // file extension
str = dlg->getExtension(); str = fMlog2DbDataSet->msrFileExtension;
if (str.isEmpty()) if (str.isEmpty())
cmd.append(""); cmd.append("");
else else
@ -1060,31 +1073,56 @@ void PTextEdit::musrMlog2Db()
// options // options
// no header flag? // no header flag?
if (!dlg->getWriteDbHeaderFlag()) if (!fMlog2DbDataSet->writeDbHeader)
cmd.append("noheader"); cmd.append("noheader");
// no summary flag? // no summary flag?
if (!dlg->getSummaryFilePresentFlag()) if (!fMlog2DbDataSet->summaryFilePresent)
cmd.append("nosummary"); cmd.append("nosummary");
// template run no // template run no
if (!dlg->getTemplateRunNo().isEmpty()) { if (fMlog2DbDataSet->templateRunNo != -1) {
str = "fit-" + dlg->getTemplateRunNo(); str = QString("%1").arg(fMlog2DbDataSet->templateRunNo);
str = "fit-" + str;
cmd.append(str); cmd.append(str);
} }
// keep minuit2 output // keep minuit2 output
if (dlg->getMinuit2OutputFlag()) { if (fMlog2DbDataSet->keepMinuit2Output) {
fKeepMinuit2Output = dlg->getMinuit2OutputFlag();
cmd.append("-k"); cmd.append("-k");
} }
// DB output wished // DB output wished
if (!dlg->getDbOutputFileName().isEmpty()) { if (!fMlog2DbDataSet->dbOutputFileName.isEmpty()) {
str = "-o" + dlg->getDbOutputFileName(); str = "-o" + fMlog2DbDataSet->dbOutputFileName;
cmd.append(str); cmd.append(str);
} }
// write column data
if (fMlog2DbDataSet->writeColumnData) {
cmd.append("data");
}
// recreate db file
if (fMlog2DbDataSet->recreateDbFile) {
if (!QFile::remove(fMlog2DbDataSet->dbOutputFileName)) {
str = QString("Couldn't delete db-file '%1'. Will **NOT** proceed.").arg(fMlog2DbDataSet->dbOutputFileName);
QMessageBox::critical(this, "**ERROR**", str,
QMessageBox::Ok, QMessageBox::NoButton);
return;
}
}
// add the swap flag
cmd.append("-s");
/*
for (unsigned int i=0; i<cmd.size(); i++) {
cout << endl << ">> " << cmd[i].latin1();
}
cout << endl;
*/
PFitOutputHandler fitOutputHandler(cmd); PFitOutputHandler fitOutputHandler(cmd);
fitOutputHandler.setModal(true); fitOutputHandler.setModal(true);
fitOutputHandler.exec(); fitOutputHandler.exec();

View File

@ -35,6 +35,8 @@
#include <qmainwindow.h> #include <qmainwindow.h>
#include <qmap.h> #include <qmap.h>
#include "musrgui.h"
class PSubTextEdit; class PSubTextEdit;
class PAdmin; class PAdmin;
class QAction; class QAction;
@ -45,10 +47,11 @@ class QPopupMenu;
class PTextEdit : public QMainWindow class PTextEdit : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
PTextEdit( QWidget *parent = 0, const char *name = 0 ); PTextEdit( QWidget *parent = 0, const char *name = 0 );
virtual ~PTextEdit();
private: private:
void setupFileActions(); void setupFileActions();
@ -104,6 +107,8 @@ private:
bool fKeepMinuit2Output; bool fKeepMinuit2Output;
int fDump; int fDump;
PMlog2DbDataSet *fMlog2DbDataSet;
QComboBox *fComboFont; QComboBox *fComboFont;
QComboBox *fComboSize; QComboBox *fComboSize;

View File

@ -135,22 +135,6 @@
<string>Run List File Name</string> <string>Run List File Name</string>
</property> </property>
</widget> </widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fFirst_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>50</x>
<y>30</y>
<width>90</width>
<height>24</height>
</rect>
</property>
<property name="toolTip" stdset="0">
<string>first run no, e.g. 147</string>
</property>
</widget>
<widget class="QLineEdit"> <widget class="QLineEdit">
<property name="name"> <property name="name">
<cstring>fLast_lineEdit</cstring> <cstring>fLast_lineEdit</cstring>
@ -167,6 +151,22 @@
<string>last run no, .e.g. 275</string> <string>last run no, .e.g. 275</string>
</property> </property>
</widget> </widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fFirst_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>50</x>
<y>30</y>
<width>90</width>
<height>24</height>
</rect>
</property>
<property name="toolTip" stdset="0">
<string>first run no, e.g. 147</string>
</property>
</widget>
<widget class="QLineEdit"> <widget class="QLineEdit">
<property name="name"> <property name="name">
<cstring>fRunList_lineEdit</cstring> <cstring>fRunList_lineEdit</cstring>
@ -447,7 +447,26 @@
</property> </property>
<widget class="QCheckBox"> <widget class="QCheckBox">
<property name="name"> <property name="name">
<cstring>fNoHeader_checkBox</cstring> <cstring>fKeepMinuit2Output_checkBox</cstring>
</property>
<property name="geometry">
<rect>
<x>20</x>
<y>70</y>
<width>170</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>Keep Minuit2 Output</string>
</property>
<property name="toolTip" stdset="0">
<string>will keep the Minuit2 output files</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>fWriteDbHeader_checkBox</cstring>
</property> </property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
@ -485,21 +504,40 @@
</widget> </widget>
<widget class="QCheckBox"> <widget class="QCheckBox">
<property name="name"> <property name="name">
<cstring>fKeepMinuit2Output_checkBox</cstring> <cstring>fWriteColumnData_checkBox</cstring>
</property> </property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>230</x>
<y>70</y> <y>30</y>
<width>170</width> <width>150</width>
<height>22</height> <height>22</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>Keep Minuit2 Output</string> <string>Write Column Data</string>
</property> </property>
<property name="toolTip" stdset="0"> <property name="toolTip" stdset="0">
<string>will keep the Minuit2 output files</string> <string>will write the output data in column like format, to be read by gnuplot ...</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>fRecreateDbFile_checkBox</cstring>
</property>
<property name="geometry">
<rect>
<x>230</x>
<y>50</y>
<width>140</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>Recreate DB File</string>
</property>
<property name="toolTip" stdset="0">
<string>will recreate the db-file. Default (unchecked) will append data</string>
</property> </property>
</widget> </widget>
</widget> </widget>
@ -555,7 +593,7 @@
<tabstop>fExtension_lineEdit</tabstop> <tabstop>fExtension_lineEdit</tabstop>
<tabstop>fTemplateRunNumber_lineEdit</tabstop> <tabstop>fTemplateRunNumber_lineEdit</tabstop>
<tabstop>fDbOutputFileName_lineEdit</tabstop> <tabstop>fDbOutputFileName_lineEdit</tabstop>
<tabstop>fNoHeader_checkBox</tabstop> <tabstop>fWriteDbHeader_checkBox</tabstop>
<tabstop>fSummaryPresent_checkBox</tabstop> <tabstop>fSummaryPresent_checkBox</tabstop>
<tabstop>fKeepMinuit2Output_checkBox</tabstop> <tabstop>fKeepMinuit2Output_checkBox</tabstop>
<tabstop>fOk_button</tabstop> <tabstop>fOk_button</tabstop>

52
src/musrgui/musrgui.h Normal file
View File

@ -0,0 +1,52 @@
/****************************************************************************
musrgui.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2009 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 _MUSRGUI_H_
#define _MUSRGUI_H_
#include <qstring.h>
typedef struct {
int firstRun;
int lastRun;
QString runList;
QString runListFileName;
QString msrFileExtension;
int templateRunNo;
QString dbOutputFileName;
bool writeDbHeader;
bool summaryFilePresent;
bool keepMinuit2Output;
bool writeColumnData;
bool recreateDbFile;
} PMlog2DbDataSet;
#endif // _MUSRGUI_H_

View File

@ -13,7 +13,8 @@ CONFIG += qt \
warn_on \ warn_on \
debug debug
HEADERS = PTextEdit.h \ HEADERS = musrgui.h \
PTextEdit.h \
PSubTextEdit.h \ PSubTextEdit.h \
PAdmin.h \ PAdmin.h \
PFitOutputHandler.h \ PFitOutputHandler.h \