diff --git a/src/musrgui/PMlog2DbDialog.cpp b/src/musrgui/PMlog2DbDialog.cpp
index 1bb51909..504422c7 100644
--- a/src/musrgui/PMlog2DbDialog.cpp
+++ b/src/musrgui/PMlog2DbDialog.cpp
@@ -41,15 +41,85 @@
/**
*
*/
-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);
+}
+
+//----------------------------------------------------------------------------------------------------
+/**
+ *
+ */
+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;
}
//----------------------------------------------------------------------------------------------------
diff --git a/src/musrgui/PMlog2DbDialog.h b/src/musrgui/PMlog2DbDialog.h
index 6ffadde5..665e76c6 100644
--- a/src/musrgui/PMlog2DbDialog.h
+++ b/src/musrgui/PMlog2DbDialog.h
@@ -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_
diff --git a/src/musrgui/PSubTextEdit.cpp b/src/musrgui/PSubTextEdit.cpp
index 54d1610e..ebac4765 100644
--- a/src/musrgui/PSubTextEdit.cpp
+++ b/src/musrgui/PSubTextEdit.cpp
@@ -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 = "????";
diff --git a/src/musrgui/PSubTextEdit.h b/src/musrgui/PSubTextEdit.h
index 0391b52c..f4d33f72 100644
--- a/src/musrgui/PSubTextEdit.h
+++ b/src/musrgui/PSubTextEdit.h
@@ -62,7 +62,6 @@ class PSubTextEdit : public QTextEdit
private:
PAdmin *fAdmin;
-
};
#endif // _PSUBTEXTEDIT_H_
diff --git a/src/musrgui/PTextEdit.cpp b/src/musrgui/PTextEdit.cpp
index 68b64e75..2813bb2b 100644
--- a/src/musrgui/PTextEdit.cpp
+++ b/src/musrgui/PTextEdit.cpp
@@ -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 )
}
}
+//----------------------------------------------------------------------------------------------------
+/**
+ *
+ */
+PTextEdit::~PTextEdit()
+{
+ if (fMlog2DbDataSet) {
+ delete fMlog2DbDataSet;
+ fMlog2DbDataSet = 0;
+ }
+}
+
//----------------------------------------------------------------------------------------------------
/**
*
@@ -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; icount(); 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[i].latin1();
+}
+cout << endl;
+*/
+
PFitOutputHandler fitOutputHandler(cmd);
fitOutputHandler.setModal(true);
fitOutputHandler.exec();
diff --git a/src/musrgui/PTextEdit.h b/src/musrgui/PTextEdit.h
index da40ae6b..3472e238 100644
--- a/src/musrgui/PTextEdit.h
+++ b/src/musrgui/PTextEdit.h
@@ -35,6 +35,8 @@
#include
#include
+#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;
diff --git a/src/musrgui/forms/PMlog2DbDialogBase.ui b/src/musrgui/forms/PMlog2DbDialogBase.ui
index 211ef1a6..22b8a692 100644
--- a/src/musrgui/forms/PMlog2DbDialogBase.ui
+++ b/src/musrgui/forms/PMlog2DbDialogBase.ui
@@ -135,22 +135,6 @@
Run List File Name
-
-
- fFirst_lineEdit
-
-
-
- 50
- 30
- 90
- 24
-
-
-
- first run no, e.g. 147
-
-
fLast_lineEdit
@@ -167,6 +151,22 @@
last run no, .e.g. 275
+
+
+ fFirst_lineEdit
+
+
+
+ 50
+ 30
+ 90
+ 24
+
+
+
+ first run no, e.g. 147
+
+
fRunList_lineEdit
@@ -447,7 +447,26 @@
- fNoHeader_checkBox
+ fKeepMinuit2Output_checkBox
+
+
+
+ 20
+ 70
+ 170
+ 22
+
+
+
+ Keep Minuit2 Output
+
+
+ will keep the Minuit2 output files
+
+
+
+
+ fWriteDbHeader_checkBox
@@ -485,21 +504,40 @@
- fKeepMinuit2Output_checkBox
+ fWriteColumnData_checkBox
- 20
- 70
- 170
+ 230
+ 30
+ 150
22
- Keep Minuit2 Output
+ Write Column Data
- will keep the Minuit2 output files
+ will write the output data in column like format, to be read by gnuplot ...
+
+
+
+
+ fRecreateDbFile_checkBox
+
+
+
+ 230
+ 50
+ 140
+ 22
+
+
+
+ Recreate DB File
+
+
+ will recreate the db-file. Default (unchecked) will append data
@@ -555,7 +593,7 @@
fExtension_lineEdit
fTemplateRunNumber_lineEdit
fDbOutputFileName_lineEdit
- fNoHeader_checkBox
+ fWriteDbHeader_checkBox
fSummaryPresent_checkBox
fKeepMinuit2Output_checkBox
fOk_button
diff --git a/src/musrgui/musrgui.h b/src/musrgui/musrgui.h
new file mode 100644
index 00000000..6ea071a4
--- /dev/null
+++ b/src/musrgui/musrgui.h
@@ -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
+
+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_
diff --git a/src/musrgui/musrgui.pro b/src/musrgui/musrgui.pro
index a5f1e809..5c2a8732 100644
--- a/src/musrgui/musrgui.pro
+++ b/src/musrgui/musrgui.pro
@@ -13,7 +13,8 @@ CONFIG += qt \
warn_on \
debug
-HEADERS = PTextEdit.h \
+HEADERS = musrgui.h \
+ PTextEdit.h \
PSubTextEdit.h \
PAdmin.h \
PFitOutputHandler.h \