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>
*/
PMlog2DbDialog::PMlog2DbDialog(const bool keepMinuit2Output)
PMlog2DbDialog::PMlog2DbDialog(PMlog2DbDataSet *mlog2DbDataSet) : fMlog2DbDataSet(mlog2DbDataSet)
{
QString str;
fRunTag = -1;
fFirst_lineEdit->setValidator( new QIntValidator(fFirst_lineEdit) );
fLast_lineEdit->setValidator( new QIntValidator(fLast_lineEdit) );
fTemplateRunNumber_lineEdit->setValidator( new QIntValidator(fTemplateRunNumber_lineEdit) );
if (fMlog2DbDataSet->firstRun != -1) {
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_
#define _PMLOG2DBDIALOG_H_
#include "musrgui.h"
#include "forms/PMlog2DbDialogBase.h"
class PMlog2DbDialog : public PMlog2DbDialogBase
{
public:
PMlog2DbDialog(const bool keepMinuit2Output);
PMlog2DbDialog(PMlog2DbDataSet *mlog2DbDataSet);
int getRunTag() { return fRunTag; }
QString getFirstRunNo() { return fFirst_lineEdit->text(); }
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(); }
virtual int getRunTag() { return fRunTag; }
virtual PMlog2DbDataSet* getMlog2DbDataSet();
public slots:
void runFirstLastEntered();
@ -58,6 +50,7 @@ class PMlog2DbDialog : public PMlog2DbDialogBase
private:
int fRunTag; // -1 = not valid, 0 = first last, 1 = run list, 2 = run list file name
PMlog2DbDataSet *fMlog2DbDataSet;
};
#endif // _PMLOG2DBDIALOG_H_

View File

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

View File

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

View File

@ -103,6 +103,8 @@ PTextEdit::PTextEdit( QWidget *parent, const char *name )
{
fAdmin = new PAdmin();
fMlog2DbDataSet = 0;
fKeepMinuit2Output = false;
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>
@ -926,26 +940,6 @@ void PTextEdit::musrFit()
fitOutputHandler.exec();
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() )
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) {
QString first, last;
@ -967,6 +978,8 @@ void PTextEdit::musrMlog2Db()
QString str;
int i, end;
fMlog2DbDataSet = dlg->getMlog2DbDataSet();
// analyze parameters
switch (dlg->getRunTag()) {
case -1: // not valid
@ -976,8 +989,8 @@ void PTextEdit::musrMlog2Db()
return;
break;
case 0: // first last
first = dlg->getFirstRunNo();
last = dlg->getLastRunNo();
first = QString("%1").arg(fMlog2DbDataSet->firstRun);
last = QString("%1").arg(fMlog2DbDataSet->lastRun);
if (first.isEmpty() || last.isEmpty()) {
QMessageBox::critical(this, "**ERROR**",
"If you choose the first/last option,\nfirst AND last needs to be provided.",
@ -986,7 +999,7 @@ void PTextEdit::musrMlog2Db()
}
break;
case 1: // run list
runList = dlg->getRunList();
runList = fMlog2DbDataSet->runList;
if (!validRunList(runList)) {
QMessageBox::critical(this, "**ERROR**",
"Invalid Run List!\nThe run list needs to be a space separated list of run numbers.",
@ -995,7 +1008,7 @@ void PTextEdit::musrMlog2Db()
}
break;
case 2: // run list file name
runListFileName = dlg->getRunListFileName();
runListFileName = fMlog2DbDataSet->runListFileName;
fi = runListFileName;
if (!fi.exists()) {
str = QString("Run List File '%1' doesn't exist.").arg(runListFileName);
@ -1051,7 +1064,7 @@ void PTextEdit::musrMlog2Db()
}
// file extension
str = dlg->getExtension();
str = fMlog2DbDataSet->msrFileExtension;
if (str.isEmpty())
cmd.append("");
else
@ -1060,31 +1073,56 @@ void PTextEdit::musrMlog2Db()
// options
// no header flag?
if (!dlg->getWriteDbHeaderFlag())
if (!fMlog2DbDataSet->writeDbHeader)
cmd.append("noheader");
// no summary flag?
if (!dlg->getSummaryFilePresentFlag())
if (!fMlog2DbDataSet->summaryFilePresent)
cmd.append("nosummary");
// template run no
if (!dlg->getTemplateRunNo().isEmpty()) {
str = "fit-" + dlg->getTemplateRunNo();
if (fMlog2DbDataSet->templateRunNo != -1) {
str = QString("%1").arg(fMlog2DbDataSet->templateRunNo);
str = "fit-" + str;
cmd.append(str);
}
// keep minuit2 output
if (dlg->getMinuit2OutputFlag()) {
fKeepMinuit2Output = dlg->getMinuit2OutputFlag();
if (fMlog2DbDataSet->keepMinuit2Output) {
cmd.append("-k");
}
// DB output wished
if (!dlg->getDbOutputFileName().isEmpty()) {
str = "-o" + dlg->getDbOutputFileName();
if (!fMlog2DbDataSet->dbOutputFileName.isEmpty()) {
str = "-o" + fMlog2DbDataSet->dbOutputFileName;
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);
fitOutputHandler.setModal(true);
fitOutputHandler.exec();

View File

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

View File

@ -135,22 +135,6 @@
<string>Run List File Name</string>
</property>
</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">
<property name="name">
<cstring>fLast_lineEdit</cstring>
@ -167,6 +151,22 @@
<string>last run no, .e.g. 275</string>
</property>
</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">
<property name="name">
<cstring>fRunList_lineEdit</cstring>
@ -447,7 +447,26 @@
</property>
<widget class="QCheckBox">
<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 name="geometry">
<rect>
@ -485,21 +504,40 @@
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>fKeepMinuit2Output_checkBox</cstring>
<cstring>fWriteColumnData_checkBox</cstring>
</property>
<property name="geometry">
<rect>
<x>20</x>
<y>70</y>
<width>170</width>
<x>230</x>
<y>30</y>
<width>150</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>Keep Minuit2 Output</string>
<string>Write Column Data</string>
</property>
<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>
</widget>
</widget>
@ -555,7 +593,7 @@
<tabstop>fExtension_lineEdit</tabstop>
<tabstop>fTemplateRunNumber_lineEdit</tabstop>
<tabstop>fDbOutputFileName_lineEdit</tabstop>
<tabstop>fNoHeader_checkBox</tabstop>
<tabstop>fWriteDbHeader_checkBox</tabstop>
<tabstop>fSummaryPresent_checkBox</tabstop>
<tabstop>fKeepMinuit2Output_checkBox</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 \
debug
HEADERS = PTextEdit.h \
HEADERS = musrgui.h \
PTextEdit.h \
PSubTextEdit.h \
PAdmin.h \
PFitOutputHandler.h \