From d4d47c3990057129302f24419fc518c41ab258a1 Mon Sep 17 00:00:00 2001 From: nemu Date: Thu, 19 Mar 2009 15:29:21 +0000 Subject: [PATCH] added PGetNonMusrRunBlockDialog --- src/musrgui/PGetNonMusrRunBlockDialog.cpp | 153 ++++++ src/musrgui/PGetNonMusrRunBlockDialog.h | 55 ++ src/musrgui/PSubTextEdit.cpp | 52 +- .../forms/PGetNonMusrRunBlockDialogBase.ui | 493 ++++++++++++++++++ src/musrgui/musrgui.pro | 3 + src/musrgui/musrgui_startup.xml | 2 +- 6 files changed, 756 insertions(+), 2 deletions(-) create mode 100644 src/musrgui/PGetNonMusrRunBlockDialog.cpp create mode 100644 src/musrgui/PGetNonMusrRunBlockDialog.h create mode 100644 src/musrgui/forms/PGetNonMusrRunBlockDialogBase.ui diff --git a/src/musrgui/PGetNonMusrRunBlockDialog.cpp b/src/musrgui/PGetNonMusrRunBlockDialog.cpp new file mode 100644 index 00000000..660fb365 --- /dev/null +++ b/src/musrgui/PGetNonMusrRunBlockDialog.cpp @@ -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 +#include +#include +#include + +#include "PGetNonMusrRunBlockDialog.h" + +//---------------------------------------------------------------------------------------------------- +/** + *

+ */ +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; icount(); i++) { + if (fFileFormat_comboBox->text(i) == "DB") { + idx = i; + break; + } + } + if (idx >= 0) { + fFileFormat_comboBox->setCurrentItem(idx); + } +} + +//---------------------------------------------------------------------------------------------------- +/** + *

+ */ +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; +} + +//---------------------------------------------------------------------------------------------------- +/** + *

+ */ +QString PGetNonMusrRunBlockDialog::getMap(bool &valid) +{ + QString str = fMap_lineEdit->text().stripWhiteSpace().remove(" "); + + // check if potentially proper map line + for (unsigned int i=0; itext() + "\n"; + + return str; +} + +//---------------------------------------------------------------------------------------------------- +/** + *

+ */ +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; +} + +//---------------------------------------------------------------------------------------------------- +/** + *

+ */ +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; +} + +//---------------------------------------------------------------------------------------------------- +/** + *

+ */ +void PGetNonMusrRunBlockDialog::helpContents() +{ + QMessageBox::information(this, "helpContents", + fHelp, QMessageBox::Ok); +} + +//---------------------------------------------------------------------------------------------------- +// END +//---------------------------------------------------------------------------------------------------- diff --git a/src/musrgui/PGetNonMusrRunBlockDialog.h b/src/musrgui/PGetNonMusrRunBlockDialog.h new file mode 100644 index 00000000..abac55be --- /dev/null +++ b/src/musrgui/PGetNonMusrRunBlockDialog.h @@ -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_ diff --git a/src/musrgui/PSubTextEdit.cpp b/src/musrgui/PSubTextEdit.cpp index aee1124d..967a3834 100644 --- a/src/musrgui/PSubTextEdit.cpp +++ b/src/musrgui/PSubTextEdit.cpp @@ -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); + } } //---------------------------------------------------------------------------------------------------- diff --git a/src/musrgui/forms/PGetNonMusrRunBlockDialogBase.ui b/src/musrgui/forms/PGetNonMusrRunBlockDialogBase.ui new file mode 100644 index 00000000..c2cac932 --- /dev/null +++ b/src/musrgui/forms/PGetNonMusrRunBlockDialogBase.ui @@ -0,0 +1,493 @@ + +PGetNonMusrRunBlockDialogBase + + + PGetNonMusrRunBlockDialogBase + + + + 0 + 0 + 483 + 319 + + + + Get NonMusr Run Block Parameters + + + image0 + + + true + + + true + + + + fRunHeader_groupBox + + + + 10 + 10 + 460 + 120 + + + + Run Header Info + + + + fRunFileName_textLabel + + + + 10 + 24 + 96 + 20 + + + + Run File Name + + + + + fBeamline_textLabel + + + + 10 + 53 + 70 + 20 + + + + Beamline + + + + + fInstitute_textLabel + + + + 10 + 83 + 60 + 20 + + + + Institute + + + + + + PSI + + + + + RAL + + + + + TRIUMF + + + + + JPARC + + + + fInstitute_comboBox + + + + 112 + 80 + 99 + 24 + + + + + + fFileFormat_textLabel + + + + 270 + 83 + 80 + 20 + + + + File Format + + + + + fRunFileName_lineEdit + + + + 110 + 20 + 340 + 24 + + + + e.g. 2007/lem07_his_0147 + + + + + fBeamline_lineEdit + + + + 110 + 50 + 140 + 24 + + + + e.g. mue4 + + + + + + NeXuS + + + + + ROOT-NPP + + + + + ROOT-PPC + + + + + PSIBIN + + + + + MUD + + + + + WKM + + + + + ASCII + + + + + DB + + + + fFileFormat_comboBox + + + + 350 + 80 + 99 + 24 + + + + + + + fRequiredEntries_groupBox + + + + 10 + 135 + 460 + 120 + + + + Required Entries + + + + fMap_textLabel + + + + 10 + 23 + 50 + 20 + + + + Map + + + + + fMap_lineEdit + + + + 70 + 20 + 380 + 24 + + + + 0 0 0 0 0 0 0 0 0 0 + + + + + fXYData_textLabel + + + + 10 + 50 + 71 + 20 + + + + xy-Data + + + + + fXData_lineEdit + + + + 140 + 50 + 70 + 24 + + + + + + fFitRangeStart_lineEdit + + + + 140 + 80 + 70 + 24 + + + + start in (us) + + + + + fFitRangeEnd_lineEdit + + + + 220 + 80 + 70 + 24 + + + + end in (us) + + + + + fYData_lineEdit + + + + 220 + 50 + 70 + 24 + + + + + + fFitRange_textLabel + + + + 10 + 80 + 71 + 20 + + + + Fit Range + + + + + + Layout1 + + + + 10 + 270 + 460 + 33 + + + + + unnamed + + + 0 + + + 6 + + + + fHelp_button + + + &Help + + + F1 + + + true + + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + fOk_button + + + &OK + + + + + + true + + + true + + + + + fCancel_button + + + &Cancel + + + + + + true + + + + + + + + 89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000000d549444154388db594510e84200c44a78653d1f34faf853fd66d2a2aa8fb1222697068cb80d0884cadda7c6e46392c1860c9010da2bd8d4629f1670140a3200869d536ad8a2d63cfc805bc7c338ac766b33eb4c279dadb5be1b72c5ab5c5d2f3028fcda6bff042f40dd2f3f119355477c7708fdd15a3eef8ecf0f2868f847bb733332c1c9d43a344f15e9bca51e25a3cde52493736d3e2d85cb27ff36861d0081ad18b15607b783a785cabb67d4da7bf5e890070f34eb5c245cee2c4cfebc533ca593e211ee2652bdef0bfd7ed4bb1e8f5a947688615932a98c849f587290000000049454e44ae426082 + + + + + fOk_button + clicked() + PGetNonMusrRunBlockDialogBase + accept() + + + fCancel_button + clicked() + PGetNonMusrRunBlockDialogBase + reject() + + + fHelp_button + clicked() + PGetNonMusrRunBlockDialogBase + helpContents() + + + + fRunFileName_lineEdit + fBeamline_lineEdit + fInstitute_comboBox + fFileFormat_comboBox + fMap_lineEdit + fXData_lineEdit + fYData_lineEdit + fFitRangeStart_lineEdit + fFitRangeEnd_lineEdit + fOk_button + fCancel_button + fHelp_button + + + helpContents() + + + diff --git a/src/musrgui/musrgui.pro b/src/musrgui/musrgui.pro index 0728ef39..afc02748 100644 --- a/src/musrgui/musrgui.pro +++ b/src/musrgui/musrgui.pro @@ -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 diff --git a/src/musrgui/musrgui_startup.xml b/src/musrgui/musrgui_startup.xml index 5f409175..eef68207 100644 --- a/src/musrgui/musrgui_startup.xml +++ b/src/musrgui/musrgui_startup.xml @@ -17,7 +17,7 @@ - For a detailed description of the aim and structure of a msr-file see <b>http://wiki.intranet.psi.ch.</b> + For a detailed description of the aim and structure of a msr-file see <b>https://wiki.intranet.psi.ch/MUSR/MusrFit</b> Starting with >= Qt4.2 this will be linked automatically but until then ...; sorry ;-)