added mlog2db dialog and handling

This commit is contained in:
nemu 2009-03-08 13:19:49 +00:00
parent dc70607474
commit cff9b40b07
6 changed files with 886 additions and 4 deletions

View File

@ -0,0 +1,103 @@
/****************************************************************************
PMlog2DbDialog.cpp
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. *
***************************************************************************/
#include <qlineedit.h>
#include <qvalidator.h>
#include <qmessagebox.h>
#include <qtextedit.h>
#include <qcheckbox.h>
#include "PMlog2DbDialog.h"
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
PMlog2DbDialog::PMlog2DbDialog(const bool keepMinuit2Output)
{
fRunTag = -1;
fFirst_lineEdit->setValidator( new QIntValidator(fFirst_lineEdit) );
fLast_lineEdit->setValidator( new QIntValidator(fLast_lineEdit) );
fTemplateRunNumber_lineEdit->setValidator( new QIntValidator(fTemplateRunNumber_lineEdit) );
fKeepMinuit2Output_checkBox->setChecked(keepMinuit2Output);
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
void PMlog2DbDialog::runFirstLastEntered()
{
fRunTag = 0;
if (!fRunList_lineEdit->text().isEmpty())
fRunList_lineEdit->clear();
if (!fRunListFileName_lineEdit->text().isEmpty())
fRunListFileName_lineEdit->clear();
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
void PMlog2DbDialog::runListEntered()
{
fRunTag = 1;
if (!fFirst_lineEdit->text().isEmpty())
fFirst_lineEdit->clear();
if (!fLast_lineEdit->text().isEmpty())
fLast_lineEdit->clear();
if (!fRunListFileName_lineEdit->text().isEmpty())
fRunListFileName_lineEdit->clear();
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
void PMlog2DbDialog::runListFileNameEntered()
{
fRunTag = 2;
if (!fFirst_lineEdit->text().isEmpty())
fFirst_lineEdit->clear();
if (!fLast_lineEdit->text().isEmpty())
fLast_lineEdit->clear();
if (!fRunList_lineEdit->text().isEmpty())
fRunList_lineEdit->clear();
}
//----------------------------------------------------------------------------------------------------
// END
//----------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,63 @@
/****************************************************************************
PMlog2DbDialog.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 _PMLOG2DBDIALOG_H_
#define _PMLOG2DBDIALOG_H_
#include "forms/PMlog2DbDialogBase.h"
class PMlog2DbDialog : public PMlog2DbDialogBase
{
public:
PMlog2DbDialog(const bool keepMinuit2Output);
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(); }
public slots:
void runFirstLastEntered();
void runListEntered();
void runListFileNameEntered();
private:
int fRunTag; // -1 = not valid, 0 = first last, 1 = run list, 2 = run list file name
};
#endif // _PMLOG2DBDIALOG_H_

View File

@ -29,6 +29,9 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <iostream>
using namespace std;
#include <qtextedit.h>
#include <qaction.h>
#include <qmenubar.h>
@ -58,6 +61,7 @@
#include "PPrefsDialog.h"
#include "PGetDefaultDialog.h"
#include "forms/PMusrGuiAbout.h"
#include "PMlog2DbDialog.h"
//----------------------------------------------------------------------------------------------------
/**
@ -338,6 +342,40 @@ void PTextEdit::doConnections( PSubTextEdit *e )
connect( e, SIGNAL( textChanged() ), this, SLOT( textChanged() ));
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
bool PTextEdit::validRunList(const QString runList)
{
bool success = true;
int i = 0;
QString subStr;
bool done = false;
int val;
bool ok;
while (!done) {
subStr = runList.section(' ', i, i);
if (subStr.isEmpty()) {
done = true;
continue;
}
i++;
val = subStr.toInt(&ok);
if (!ok) {
done = true;
success = false;
}
}
if (i == 0) { // no token found
success = false;
}
return success;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
@ -806,9 +844,142 @@ void PTextEdit::musrMlog2Db()
if ( !currentEditor() )
return;
QMessageBox::information( this, "musrMlog2Db",
"Will call mlog2db.\n"
"NOT IMPLEMENTED YET :-(" );
PMlog2DbDialog *dlg = new PMlog2DbDialog(fKeepMinuit2Output);
if (dlg->exec() == QDialog::Accepted) {
QString first, last;
QString runList;
QString runListFileName;
QFileInfo fi;
QString str;
int i, end;
// analyze parameters
switch (dlg->getRunTag()) {
case -1: // not valid
QMessageBox::critical(this, "**ERROR**",
"No valid run list input found :-(\nCannot do anything.",
QMessageBox::Ok, QMessageBox::NoButton);
return;
break;
case 0: // first last
first = dlg->getFirstRunNo();
last = dlg->getLastRunNo();
if (first.isEmpty() || last.isEmpty()) {
QMessageBox::critical(this, "**ERROR**",
"If you choose the first/last option,\nfirst AND last needs to be provided.",
QMessageBox::Ok, QMessageBox::NoButton);
return;
}
break;
case 1: // run list
runList = dlg->getRunList();
if (!validRunList(runList)) {
QMessageBox::critical(this, "**ERROR**",
"Invalid Run List!\nThe run list needs to be a space separated list of run numbers.",
QMessageBox::Ok, QMessageBox::NoButton);
return;
}
break;
case 2: // run list file name
runListFileName = dlg->getRunListFileName();
fi = runListFileName;
if (!fi.exists()) {
str = QString("Run List File '%1' doesn't exist.").arg(runListFileName);
QMessageBox::critical(this, "**ERROR**",
str, QMessageBox::Ok, QMessageBox::NoButton);
return;
}
break;
default: // never should reach this point
QMessageBox::critical(this, "**ERROR**",
"No idea how you could reach this point.\nPlease contact the developers.",
QMessageBox::Ok, QMessageBox::NoButton);
return;
break;
}
// form command
QValueVector<QString> cmd;
str = fAdmin->getExecPath() + "/mlog2db";
cmd.append(str);
// run list argument
switch (dlg->getRunTag()) {
case 0:
cmd.append(first);
cmd.append(last);
break;
case 1:
end = 0;
while (!runList.section(' ', end, end).isEmpty()) {
end++;
}
// first element
if (end == 1) {
str = "[" + runList.section(' ', 0, 0) + "]";
} else {
str = "[" + runList.section(' ', 0, 0);
cmd.append(str);
// middle elements
for (i=1; i<end-1; i++) {
cmd.append(runList.section(' ', i, i));
}
// last element
str = runList.section(' ', end-1, end-1) + "]";
cmd.append(str);
}
break;
case 2:
cmd.append(runListFileName);
break;
default:
break;
}
// file extension
str = dlg->getExtension();
if (str.isEmpty())
cmd.append("");
else
cmd.append(str);
// options
// no header flag?
if (!dlg->getWriteDbHeaderFlag())
cmd.append("noheader");
// no summary flag?
if (!dlg->getSummaryFilePresentFlag())
cmd.append("nosummary");
// template run no
if (!dlg->getTemplateRunNo().isEmpty()) {
str = "fit-" + dlg->getTemplateRunNo();
cmd.append(str);
}
// keep minuit2 output
if (dlg->getMinuit2OutputFlag()) {
fKeepMinuit2Output = dlg->getMinuit2OutputFlag();
cmd.append("-k");
}
// DB output wished
if (!dlg->getDbOutputFileName().isEmpty()) {
str = "-o" + dlg->getDbOutputFileName();
cmd.append(str);
}
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

@ -59,6 +59,7 @@ private:
void load( const QString &f );
PSubTextEdit *currentEditor() const;
void doConnections( PSubTextEdit *e );
bool validRunList(const QString runList);
private slots:
void fileNew();

View File

@ -0,0 +1,541 @@
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>PMlog2DbDialogBase</class>
<widget class="QDialog">
<property name="name">
<cstring>PMlog2DbDialogBase</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>604</width>
<height>576</height>
</rect>
</property>
<property name="caption">
<string>mlog2db input</string>
</property>
<property name="icon">
<pixmap>image0</pixmap>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<property name="modal">
<bool>true</bool>
</property>
<widget class="QGroupBox">
<property name="name">
<cstring>fRunList_groupBox</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>580</width>
<height>150</height>
</rect>
</property>
<property name="title">
<string>run list input</string>
</property>
<widget class="QLabel">
<property name="name">
<cstring>fFirst_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>33</y>
<width>40</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>First</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>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fLast_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>180</x>
<y>33</y>
<width>40</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Last</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fLast_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>220</x>
<y>30</y>
<width>100</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fRunList_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Run List</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fOr2_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>540</x>
<y>70</y>
<width>29</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>&lt;b&gt;OR&lt;/b&gt;</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fOr1_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>540</x>
<y>30</y>
<width>30</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>&lt;b&gt;OR&lt;/b&gt;</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fRunListFileName_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>113</y>
<width>130</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Run List File Name</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fRunListFileName_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>150</x>
<y>110</y>
<width>370</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fRunList_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>70</y>
<width>440</width>
<height>24</height>
</rect>
</property>
</widget>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>Layout1</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>530</y>
<width>580</width>
<height>33</height>
</rect>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="QPushButton">
<property name="name">
<cstring>fHelp_button</cstring>
</property>
<property name="text">
<string>&amp;Help</string>
</property>
<property name="accel">
<string>F1</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
<spacer>
<property name="name">
<cstring>Horizontal Spacing2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QPushButton">
<property name="name">
<cstring>fOk_button</cstring>
</property>
<property name="text">
<string>&amp;OK</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>fCancel_button</cstring>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</hbox>
</widget>
<widget class="QGroupBox">
<property name="name">
<cstring>fExtension_groupBox</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>170</y>
<width>580</width>
<height>65</height>
</rect>
</property>
<property name="title">
<string>msr file extension</string>
</property>
<widget class="QLabel">
<property name="name">
<cstring>fExtension_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Extension</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fExtension_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>170</x>
<y>27</y>
<width>140</width>
<height>24</height>
</rect>
</property>
</widget>
</widget>
<widget class="QGroupBox">
<property name="name">
<cstring>fTemplateRunInput_groupBox</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>250</y>
<width>580</width>
<height>65</height>
</rect>
</property>
<property name="title">
<string>template run input</string>
</property>
<widget class="QLabel">
<property name="name">
<cstring>fTemplateRunNumber_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>150</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Template Run Number</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fTemplateRunNumber_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>170</x>
<y>27</y>
<width>140</width>
<height>24</height>
</rect>
</property>
</widget>
</widget>
<widget class="QGroupBox">
<property name="name">
<cstring>fDbOutputFileName_groupBox</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>325</y>
<width>580</width>
<height>65</height>
</rect>
</property>
<property name="title">
<string>DB output file name</string>
</property>
<widget class="QLineEdit">
<property name="name">
<cstring>fDbOutputFileName_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>170</x>
<y>25</y>
<width>350</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fDbOutputFileName_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>150</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>DB Output File Name</string>
</property>
</widget>
</widget>
<widget class="QGroupBox">
<property name="name">
<cstring>fOptions_groupBox</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>400</y>
<width>581</width>
<height>110</height>
</rect>
</property>
<property name="title">
<string>options</string>
</property>
<widget class="QCheckBox">
<property name="name">
<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>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>fNoHeader_checkBox</cstring>
</property>
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>150</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>Write DB Header</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>fSummaryPresent_checkBox</cstring>
</property>
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>180</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>Summary Files Present</string>
</property>
</widget>
</widget>
</widget>
<images>
<image name="image0">
<data format="PNG" length="228">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000000ab49444154388dbd93510ec420084421e9a9e0fc702dfbc5c6b580a8db9d9fa68a30be4e5154201313b7fe5d5490899b3dc77a51410080cb3b181547eb36a8dfbba243a72a39b69a151325c73bb77a383e6df869fc1663048029e3adc6b31c7b22e2a613035f8c7f89e57f393679034704199265c6d419c9386fa5a2f2f1b6525151c97174fd0c4b39157670c410adbba9c886a90a967e90d31c1b8e078a951c7b0a51ac3aae6000783115376b3ca3338719d7820000000049454e44ae426082</data>
</image>
</images>
<connections>
<connection>
<sender>fOk_button</sender>
<signal>clicked()</signal>
<receiver>PMlog2DbDialogBase</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>fCancel_button</sender>
<signal>clicked()</signal>
<receiver>PMlog2DbDialogBase</receiver>
<slot>reject()</slot>
</connection>
<connection>
<sender>fFirst_lineEdit</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>PMlog2DbDialogBase</receiver>
<slot>runFirstLastEntered()</slot>
</connection>
<connection>
<sender>fLast_lineEdit</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>PMlog2DbDialogBase</receiver>
<slot>runFirstLastEntered()</slot>
</connection>
<connection>
<sender>fRunList_lineEdit</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>PMlog2DbDialogBase</receiver>
<slot>runListEntered()</slot>
</connection>
<connection>
<sender>fRunListFileName_lineEdit</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>PMlog2DbDialogBase</receiver>
<slot>runListFileNameEntered()</slot>
</connection>
</connections>
<tabstops>
<tabstop>fFirst_lineEdit</tabstop>
<tabstop>fLast_lineEdit</tabstop>
<tabstop>fRunList_lineEdit</tabstop>
<tabstop>fRunListFileName_lineEdit</tabstop>
<tabstop>fExtension_lineEdit</tabstop>
<tabstop>fTemplateRunNumber_lineEdit</tabstop>
<tabstop>fDbOutputFileName_lineEdit</tabstop>
<tabstop>fNoHeader_checkBox</tabstop>
<tabstop>fSummaryPresent_checkBox</tabstop>
<tabstop>fKeepMinuit2Output_checkBox</tabstop>
<tabstop>fOk_button</tabstop>
<tabstop>fCancel_button</tabstop>
<tabstop>fHelp_button</tabstop>
</tabstops>
<slots>
<slot>runFirstLastEntered()</slot>
<slot>runListEntered()</slot>
<slot>runListFileNameEntered()</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>

View File

@ -21,6 +21,7 @@ HEADERS = PTextEdit.h \
PGetDefaultDialog.h \
PGetParameterDialog.h \
PGetFourierDialog.h \
PMlog2DbDialog.h \
PGetPlotDialog.h
SOURCES = PTextEdit.cpp \
@ -32,6 +33,7 @@ SOURCES = PTextEdit.cpp \
PGetParameterDialog.cpp \
PGetFourierDialog.cpp \
PGetPlotDialog.cpp \
PMlog2DbDialog.cpp \
main.cpp
FORMS = forms/PGetDefaultDialogBase.ui \
@ -40,7 +42,8 @@ FORMS = forms/PGetDefaultDialogBase.ui \
forms/PGetTitleDialog.ui \
forms/PGetParameterDialogBase.ui \
forms/PGetFourierDialogBase.ui \
forms/PGetPlotDialogBase.ui
forms/PGetPlotDialogBase.ui \
forms/PMlog2DbDialogBase.ui
IMAGES = images/editcopy.xpm \
images/editcut.xpm \