added PGetNonMusrRunBlockDialog

This commit is contained in:
nemu 2009-03-19 15:29:21 +00:00
parent d3be43ff70
commit d4d47c3990
6 changed files with 756 additions and 2 deletions

View File

@ -0,0 +1,153 @@
/****************************************************************************
PGetNonMusrRunBlockDialog.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 <qcombobox.h>
#include <qmessagebox.h>
#include "PGetNonMusrRunBlockDialog.h"
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
PGetNonMusrRunBlockDialog::PGetNonMusrRunBlockDialog(const QString help, QWidget *parent, const char *name,
bool modal, WFlags f) :
PGetNonMusrRunBlockDialogBase(parent, name, modal, f),
fHelp(help)
{
fFitRangeStart_lineEdit->setValidator( new QDoubleValidator(fFitRangeStart_lineEdit) );
fFitRangeEnd_lineEdit->setValidator( new QDoubleValidator(fFitRangeEnd_lineEdit) );
int idx = -1;
for (int i=0; i<fFileFormat_comboBox->count(); i++) {
if (fFileFormat_comboBox->text(i) == "DB") {
idx = i;
break;
}
}
if (idx >= 0) {
fFileFormat_comboBox->setCurrentItem(idx);
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
QString PGetNonMusrRunBlockDialog::getRunHeaderInfo()
{
QString str;
str = "RUN " + fRunFileName_lineEdit->text() + " ";
str += fBeamline_lineEdit->text().upper() + " ";
str += fInstitute_comboBox->currentText() + " ";
str += fFileFormat_comboBox->currentText() + " (name beamline institute data-file-format)\n";
return str;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
QString PGetNonMusrRunBlockDialog::getMap(bool &valid)
{
QString str = fMap_lineEdit->text().stripWhiteSpace().remove(" ");
// check if potentially proper map line
for (unsigned int i=0; i<str.length(); i++) {
if (!str[i].isDigit()) {
valid = false;
break;
}
}
str = "map " + fMap_lineEdit->text() + "\n";
return str;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
QString PGetNonMusrRunBlockDialog::getXYData(bool &valid)
{
QString str = "";
if (fXData_lineEdit->text().isEmpty() || fYData_lineEdit->text().isEmpty()) {
valid = false;
} else {
str = "xy-data ";
str += fXData_lineEdit->text() + " ";
str += fYData_lineEdit->text() + "\n";
valid = true;
}
return str;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
QString PGetNonMusrRunBlockDialog::getFitRange(bool &valid)
{
QString str = "";
if (fFitRangeStart_lineEdit->text().isEmpty() || fFitRangeEnd_lineEdit->text().isEmpty()) {
str += "fit 0.0 10.0\n";
valid = false;
} else {
str += "fit ";
str += fFitRangeStart_lineEdit->text() + " ";
str += fFitRangeEnd_lineEdit->text() + "\n";
valid = true;
}
return str;
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
void PGetNonMusrRunBlockDialog::helpContents()
{
QMessageBox::information(this, "helpContents",
fHelp, QMessageBox::Ok);
}
//----------------------------------------------------------------------------------------------------
// END
//----------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,55 @@
/****************************************************************************
PGetNonMusrRunBlockDialog.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 _PGETNONMUSRRUNBLOCKDIALOG_H_
#define _PGETNONMUSRRUNBLOCKDIALOG_H_
#include "forms/PGetNonMusrRunBlockDialogBase.h"
class PGetNonMusrRunBlockDialog : public PGetNonMusrRunBlockDialogBase
{
public:
PGetNonMusrRunBlockDialog(const QString help = "", QWidget * parent = 0, const char * name = 0,
bool modal = FALSE, WFlags f = 0);
QString getRunHeaderInfo();
QString getMap(bool &valid);
QString getXYData(bool &valid);
QString getFitRange(bool &valid);
private slots:
void helpContents();
private:
QString fHelp;
};
#endif // _PGETNONMUSRRUNBLOCKDIALOG_H_

View File

@ -41,6 +41,7 @@
#include "PGetParameterDialog.h"
#include "PGetAsymmetryRunBlockDialog.h"
#include "PGetSingleHistoRunBlockDialog.h"
#include "PGetNonMusrRunBlockDialog.h"
#include "PGetFourierDialog.h"
#include "PGetPlotDialog.h"
@ -352,7 +353,7 @@ void PSubTextEdit::insertSingleHistRunBlock()
QMessageBox::Ok, QMessageBox::NoButton);
}
// insert Asymmetry Run Block at the current cursor position
// insert Single Histogram Run Block at the current cursor position
insert(str);
}
}
@ -363,6 +364,55 @@ void PSubTextEdit::insertSingleHistRunBlock()
*/
void PSubTextEdit::insertNonMusrRunBlock()
{
PGetNonMusrRunBlockDialog *dlg = new PGetNonMusrRunBlockDialog(fHelp);
if (dlg->exec() == QDialog::Accepted) {
QString str, workStr;
bool valid = true;
// check if there is already a run block present, necessary because of the '####' line
// STILL MISSING
// add run line
str += dlg->getRunHeaderInfo();
// add fittype
str += "fittype 8 (non musr fit)\n";
// add map
workStr = dlg->getMap(valid);
if (valid) {
str += workStr;
} else {
QMessageBox::critical(this, "**ERROR**",
"Given map not valid, will add a default map line",
QMessageBox::Ok, QMessageBox::NoButton);
str += "map 0 0 0 0 0 0 0 0 0 0\n";
}
// add xy-data
workStr = dlg->getXYData(valid);
if (valid) {
str += workStr;
} else {
QMessageBox::critical(this, "**ERROR**",
"Not all xy-data entries are present.Fix is needed!\nWill not set anything!",
QMessageBox::Ok, QMessageBox::NoButton);
}
// add fit range
workStr = dlg->getFitRange(valid);
str += workStr;
if (!valid) {
QMessageBox::critical(this, "**ERROR**",
"No valid fit range is given.Fix is needed!\nWill add a default one!",
QMessageBox::Ok, QMessageBox::NoButton);
}
// add packing
str += "packing 1\n";
// insert NonMusr Run Block at the current cursor position
insert(str);
}
}
//----------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,493 @@
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>PGetNonMusrRunBlockDialogBase</class>
<widget class="QDialog">
<property name="name">
<cstring>PGetNonMusrRunBlockDialogBase</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>483</width>
<height>319</height>
</rect>
</property>
<property name="caption">
<string>Get NonMusr Run Block Parameters</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>fRunHeader_groupBox</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>460</width>
<height>120</height>
</rect>
</property>
<property name="title">
<string>Run Header Info</string>
</property>
<widget class="QLabel">
<property name="name">
<cstring>fRunFileName_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>24</y>
<width>96</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Run File Name</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fBeamline_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>53</y>
<width>70</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Beamline</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fInstitute_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>83</y>
<width>60</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Institute</string>
</property>
</widget>
<widget class="QComboBox">
<item>
<property name="text">
<string>PSI</string>
</property>
</item>
<item>
<property name="text">
<string>RAL</string>
</property>
</item>
<item>
<property name="text">
<string>TRIUMF</string>
</property>
</item>
<item>
<property name="text">
<string>JPARC</string>
</property>
</item>
<property name="name">
<cstring>fInstitute_comboBox</cstring>
</property>
<property name="geometry">
<rect>
<x>112</x>
<y>80</y>
<width>99</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fFileFormat_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>270</x>
<y>83</y>
<width>80</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>File Format</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fRunFileName_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>110</x>
<y>20</y>
<width>340</width>
<height>24</height>
</rect>
</property>
<property name="toolTip" stdset="0">
<string>e.g. 2007/lem07_his_0147</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fBeamline_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>110</x>
<y>50</y>
<width>140</width>
<height>24</height>
</rect>
</property>
<property name="toolTip" stdset="0">
<string>e.g. mue4</string>
</property>
</widget>
<widget class="QComboBox">
<item>
<property name="text">
<string>NeXuS</string>
</property>
</item>
<item>
<property name="text">
<string>ROOT-NPP</string>
</property>
</item>
<item>
<property name="text">
<string>ROOT-PPC</string>
</property>
</item>
<item>
<property name="text">
<string>PSIBIN</string>
</property>
</item>
<item>
<property name="text">
<string>MUD</string>
</property>
</item>
<item>
<property name="text">
<string>WKM</string>
</property>
</item>
<item>
<property name="text">
<string>ASCII</string>
</property>
</item>
<item>
<property name="text">
<string>DB</string>
</property>
</item>
<property name="name">
<cstring>fFileFormat_comboBox</cstring>
</property>
<property name="geometry">
<rect>
<x>350</x>
<y>80</y>
<width>99</width>
<height>24</height>
</rect>
</property>
</widget>
</widget>
<widget class="QGroupBox">
<property name="name">
<cstring>fRequiredEntries_groupBox</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>135</y>
<width>460</width>
<height>120</height>
</rect>
</property>
<property name="title">
<string>Required Entries</string>
</property>
<widget class="QLabel">
<property name="name">
<cstring>fMap_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>23</y>
<width>50</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Map</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fMap_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>70</x>
<y>20</y>
<width>380</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>0 0 0 0 0 0 0 0 0 0</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fXYData_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>xy-Data</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fXData_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>140</x>
<y>50</y>
<width>70</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fFitRangeStart_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>140</x>
<y>80</y>
<width>70</width>
<height>24</height>
</rect>
</property>
<property name="toolTip" stdset="0">
<string>start in (us)</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fFitRangeEnd_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>220</x>
<y>80</y>
<width>70</width>
<height>24</height>
</rect>
</property>
<property name="toolTip" stdset="0">
<string>end in (us)</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fYData_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>220</x>
<y>50</y>
<width>70</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fFitRange_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Fit Range</string>
</property>
</widget>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>Layout1</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>270</y>
<width>460</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>
<images>
<image name="image0">
<data format="PNG" length="270">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000000d549444154388db594510e84200c44a78653d1f34faf853fd66d2a2aa8fb1222697068cb80d0884cadda7c6e46392c1860c9010da2bd8d4629f1670140a3200869d536ad8a2d63cfc805bc7c338ac766b33eb4c279dadb5be1b72c5ab5c5d2f3028fcda6bff042f40dd2f3f119355477c7708fdd15a3eef8ecf0f2868f847bb733332c1c9d43a344f15e9bca51e25a3cde52493736d3e2d85cb27ff36861d0081ad18b15607b783a785cabb67d4da7bf5e890070f34eb5c245cee2c4cfebc533ca593e211ee2652bdef0bfd7ed4bb1e8f5a947688615932a98c849f587290000000049454e44ae426082</data>
</image>
</images>
<connections>
<connection>
<sender>fOk_button</sender>
<signal>clicked()</signal>
<receiver>PGetNonMusrRunBlockDialogBase</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>fCancel_button</sender>
<signal>clicked()</signal>
<receiver>PGetNonMusrRunBlockDialogBase</receiver>
<slot>reject()</slot>
</connection>
<connection>
<sender>fHelp_button</sender>
<signal>clicked()</signal>
<receiver>PGetNonMusrRunBlockDialogBase</receiver>
<slot>helpContents()</slot>
</connection>
</connections>
<tabstops>
<tabstop>fRunFileName_lineEdit</tabstop>
<tabstop>fBeamline_lineEdit</tabstop>
<tabstop>fInstitute_comboBox</tabstop>
<tabstop>fFileFormat_comboBox</tabstop>
<tabstop>fMap_lineEdit</tabstop>
<tabstop>fXData_lineEdit</tabstop>
<tabstop>fYData_lineEdit</tabstop>
<tabstop>fFitRangeStart_lineEdit</tabstop>
<tabstop>fFitRangeEnd_lineEdit</tabstop>
<tabstop>fOk_button</tabstop>
<tabstop>fCancel_button</tabstop>
<tabstop>fHelp_button</tabstop>
</tabstops>
<slots>
<slot access="private">helpContents()</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>

View File

@ -22,6 +22,7 @@ HEADERS = PTextEdit.h \
PGetParameterDialog.h \
PGetAsymmetryRunBlockDialog.h \
PGetSingleHistoRunBlockDialog.h \
PGetNonMusrRunBlockDialog.h \
PGetFourierDialog.h \
PMlog2DbDialog.h \
PGetPlotDialog.h
@ -35,6 +36,7 @@ SOURCES = PTextEdit.cpp \
PGetParameterDialog.cpp \
PGetAsymmetryRunBlockDialog.cpp \
PGetSingleHistoRunBlockDialog.cpp \
PGetNonMusrRunBlockDialog.cpp \
PGetFourierDialog.cpp \
PGetPlotDialog.cpp \
PMlog2DbDialog.cpp \
@ -47,6 +49,7 @@ FORMS = forms/PGetDefaultDialogBase.ui \
forms/PGetParameterDialogBase.ui \
forms/PGetAsymmetryRunBlockDialogBase.ui \
forms/PGetSingleHistoRunBlockDialogBase.ui \
forms/PGetNonMusrRunBlockDialogBase.ui \
forms/PGetFourierDialogBase.ui \
forms/PGetPlotDialogBase.ui \
forms/PMlog2DbDialogBase.ui

View File

@ -17,7 +17,7 @@
</msr_file_defaults>
<help_section>
<help_main>
For a detailed description of the aim and structure of a msr-file see &lt;b&gt;http://wiki.intranet.psi.ch.&lt;/b&gt;
For a detailed description of the aim and structure of a msr-file see &lt;b&gt;https://wiki.intranet.psi.ch/MUSR/MusrFit&lt;/b&gt;
Starting with &gt;= Qt4.2 this will be linked automatically but until then ...; sorry ;-)
</help_main>
</help_section>