diff --git a/src/musrgui/PGetAsymmetryRunBlockDialog.cpp b/src/musrgui/PGetAsymmetryRunBlockDialog.cpp new file mode 100644 index 00000000..311280e7 --- /dev/null +++ b/src/musrgui/PGetAsymmetryRunBlockDialog.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** + + PGetAsymmetryRunBlockDialog.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 "PGetAsymmetryRunBlockDialog.h" + +//---------------------------------------------------------------------------------------------------- +/** + *

+ */ +PGetAsymmetryRunBlockDialog::PGetAsymmetryRunBlockDialog() +{ + fForward_lineEdit->setValidator( new QIntValidator(fForward_lineEdit) ); + fBackward_lineEdit->setValidator( new QIntValidator(fBackward_lineEdit) ); + fDataForwardStart_lineEdit->setValidator( new QIntValidator(fDataForwardStart_lineEdit) ); + fDataForwardEnd_lineEdit->setValidator( new QIntValidator(fDataForwardEnd_lineEdit) ); + fDataBackwardStart_lineEdit->setValidator( new QIntValidator(fDataBackwardStart_lineEdit) ); + fDataBackwardEnd_lineEdit->setValidator( new QIntValidator(fDataBackwardEnd_lineEdit) ); + fBackgroundForwardStart_lineEdit->setValidator( new QIntValidator(fBackgroundForwardStart_lineEdit) ); + fBackgroundForwardEnd_lineEdit->setValidator( new QIntValidator(fBackgroundForwardEnd_lineEdit) ); + fBackgroundBackwardStart_lineEdit->setValidator( new QIntValidator(fBackgroundBackwardStart_lineEdit) ); + fBackgroundBackwardEnd_lineEdit->setValidator( new QIntValidator(fBackgroundBackwardEnd_lineEdit) ); + fBackgroundForwardFix_lineEdit->setValidator( new QDoubleValidator(fBackgroundForwardFix_lineEdit) ); + fBackgroundBackwardFix_lineEdit->setValidator( new QDoubleValidator(fBackgroundBackwardFix_lineEdit) ); + fFitRangeStart_lineEdit->setValidator( new QDoubleValidator(fFitRangeStart_lineEdit) ); + fFitRangeEnd_lineEdit->setValidator( new QDoubleValidator(fFitRangeEnd_lineEdit) ); + fPacking_lineEdit->setValidator( new QIntValidator(fPacking_lineEdit) ); + fAlpha_lineEdit->setValidator( new QIntValidator(fAlpha_lineEdit) ); + fBeta_lineEdit->setValidator( new QIntValidator(fBeta_lineEdit) ); + fT0Forward_lineEdit->setValidator( new QIntValidator(fT0Forward_lineEdit) ); + fT0Backward_lineEdit->setValidator( new QIntValidator(fT0Backward_lineEdit) ); +} + +//---------------------------------------------------------------------------------------------------- +// END +//---------------------------------------------------------------------------------------------------- diff --git a/src/musrgui/PGetAsymmetryRunBlockDialog.h b/src/musrgui/PGetAsymmetryRunBlockDialog.h new file mode 100644 index 00000000..4a0316ed --- /dev/null +++ b/src/musrgui/PGetAsymmetryRunBlockDialog.h @@ -0,0 +1,43 @@ +/**************************************************************************** + + PGetAsymmetryRunBlockDialog.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 _PGETASYMMETRYRUNBLOCKDIALOG_H_ +#define _PGETASYMMETRYRUNBLOCKDIALOG_H_ + +#include "forms/PGetAsymmetryRunBlockDialogBase.h" + +class PGetAsymmetryRunBlockDialog : public PGetAsymmetryRunBlockDialogBase +{ + public: + PGetAsymmetryRunBlockDialog(); +}; + +#endif // _PGETASYMMETRYRUNBLOCKDIALOG_H_ diff --git a/src/musrgui/PSubTextEdit.cpp b/src/musrgui/PSubTextEdit.cpp index dfb6de3a..752b2947 100644 --- a/src/musrgui/PSubTextEdit.cpp +++ b/src/musrgui/PSubTextEdit.cpp @@ -33,10 +33,13 @@ #include #include #include +#include +#include #include "PSubTextEdit.h" #include "forms/PGetTitleDialog.h" #include "PGetParameterDialog.h" +#include "PGetAsymmetryRunBlockDialog.h" #include "PGetFourierDialog.h" #include "PGetPlotDialog.h" @@ -155,6 +158,111 @@ void PSubTextEdit::insertFunctionBlock() */ void PSubTextEdit::insertAsymRunBlock() { + PGetAsymmetryRunBlockDialog *dlg = new PGetAsymmetryRunBlockDialog(); + if (dlg->exec() == QDialog::Accepted) { + QString str, workStr; + // check if there is already a run block present, necessary because of the '####' line + // STILL MISSING + + // add run line + str += "RUN " + dlg->fRunFileName_lineEdit->text() + " "; + str += dlg->fBeamline_lineEdit->text().upper() + " "; + str += dlg->fInstitute_comboBox->currentText() + " "; + str += dlg->fFileFormat_comboBox->currentText() + " (name beamline institute data-file-format)\n"; + + // add fittype + str += "fittype 2 (asymmetry fit)\n"; + + // add alpha if present + workStr = dlg->fAlpha_lineEdit->text(); + if (!workStr.isEmpty()) { + str += "alpha " + workStr + "\n"; + } + + // add beta if present + workStr = dlg->fBeta_lineEdit->text(); + if (!workStr.isEmpty()) { + str += "beta " + workStr + "\n"; + } + + // add map + str += "map " + dlg->fMap_lineEdit->text() + "\n"; + + // add forward + str += "forward " + dlg->fForward_lineEdit->text() + "\n"; + + // add backward + str += "backward " + dlg->fBackward_lineEdit->text() + "\n"; + + // check that either background or background.fix is given + if (dlg->fBackgroundForwardStart_lineEdit->text().isEmpty() && dlg->fBackgroundForwardEnd_lineEdit->text().isEmpty() && + dlg->fBackgroundBackwardStart_lineEdit->text().isEmpty() && dlg->fBackgroundBackwardEnd_lineEdit->text().isEmpty() && + dlg->fBackgroundForwardFix_lineEdit->text().isEmpty() && dlg->fBackgroundBackwardFix_lineEdit->text().isEmpty()) { + QMessageBox::critical(this, "**ERROR**", + "Either Background or Background.Fix is needed!\nWill set Background to 0..10, please correct!", + QMessageBox::Ok, QMessageBox::NoButton); + str += "background 0 10 0 10\n"; + } else { + if (!dlg->fBackgroundForwardStart_lineEdit->text().isEmpty()) { // assume the rest is given, not fool prove but ... + str += "background "; + str += dlg->fBackgroundForwardStart_lineEdit->text() + " "; + str += dlg->fBackgroundForwardEnd_lineEdit->text() + " "; + str += dlg->fBackgroundBackwardStart_lineEdit->text() + " "; + str += dlg->fBackgroundBackwardEnd_lineEdit->text() + "\n"; + } + if (!dlg->fBackgroundForwardFix_lineEdit->text().isEmpty()) { // assume the rest is given, not fool prove but ... + str += "backgr.fix "; + str += dlg->fBackgroundForwardFix_lineEdit->text() + " "; + str += dlg->fBackgroundBackwardFix_lineEdit->text() + "\n"; + } + } + + // add data + if (dlg->fDataForwardStart_lineEdit->text().isEmpty() || dlg->fDataForwardEnd_lineEdit->text().isEmpty() || + dlg->fDataBackwardStart_lineEdit->text().isEmpty() || dlg->fDataBackwardEnd_lineEdit->text().isEmpty()) { + QMessageBox::critical(this, "**ERROR**", + "Not all Data entries are present.Fix is needed!\nWill not set anything!", + QMessageBox::Ok, QMessageBox::NoButton); + } else { + str += "data "; + str += dlg->fDataForwardStart_lineEdit->text() + " "; + str += dlg->fDataForwardEnd_lineEdit->text() + " "; + str += dlg->fDataBackwardStart_lineEdit->text() + " "; + str += dlg->fDataBackwardEnd_lineEdit->text() + "\n"; + } + + // add t0 if present + if (!dlg->fT0Forward_lineEdit->text().isEmpty() && !dlg->fT0Forward_lineEdit->text().isEmpty()) { + str += "t0 "; + str += dlg->fT0Forward_lineEdit->text() + " "; + str += dlg->fT0Backward_lineEdit->text() + "\n"; + } + + // add fit range + if (dlg->fFitRangeStart_lineEdit->text().isEmpty() || dlg->fFitRangeEnd_lineEdit->text().isEmpty()) { + QMessageBox::critical(this, "**ERROR**", + "No valid fit range is given.Fix is needed!\nWill add a default one!", + QMessageBox::Ok, QMessageBox::NoButton); + str += "fit 0.0 10.0\n"; + } else { + str += "fit "; + str += dlg->fFitRangeStart_lineEdit->text() + " "; + str += dlg->fFitRangeEnd_lineEdit->text() + "\n"; + } + + // add packing + if (dlg->fPacking_lineEdit->text().isEmpty()) { + QMessageBox::critical(this, "**ERROR**", + "No valid packing/binning is given.Fix is needed!\nWill add a default one!", + QMessageBox::Ok, QMessageBox::NoButton); + str += "packing 1\n"; + } else { + str += "packing " + dlg->fPacking_lineEdit->text() + "\n\n"; + } + + // insert Asymmetry Run Block at the current cursor position + insert(str); + } } //---------------------------------------------------------------------------------------------------- diff --git a/src/musrgui/forms/PGetAsymmetryRunBlockDialogBase.ui b/src/musrgui/forms/PGetAsymmetryRunBlockDialogBase.ui new file mode 100644 index 00000000..36107b2e --- /dev/null +++ b/src/musrgui/forms/PGetAsymmetryRunBlockDialogBase.ui @@ -0,0 +1,837 @@ + +PGetAsymmetryRunBlockDialogBase + + + PGetAsymmetryRunBlockDialogBase + + + + 0 + 0 + 483 + 527 + + + + Get Asymmetry Run Block Parameters + + + true + + + true + + + + fRunHeader_groupBox + + + + 10 + 10 + 460 + 120 + + + + Run Header Info + + + + fRunFileName_textLabel + + + + 10 + 24 + 96 + 20 + + + + Run File Name + + + + + fBeamline_lineEdit + + + + 110 + 50 + 140 + 24 + + + + + + fBeamline_textLabel + + + + 10 + 53 + 70 + 20 + + + + Beamline + + + + + fInstitute_textLabel + + + + 10 + 83 + 60 + 20 + + + + Institute + + + + + + PSI + + + + + RAL + + + + + TRIUMF + + + + + JPARC + + + + fInstitute_comboBox + + + + 112 + 80 + 99 + 24 + + + + + + fRunFileName_lineEdit + + + + 110 + 20 + 340 + 24 + + + + + + + NeXuS + + + + + ROOT-NPP + + + + + ROOT-PPC + + + + + PSIBIN + + + + + MUD + + + + + WKM + + + + + ASCII + + + + + DB + + + + fFileFormat_comboBox + + + + 350 + 80 + 99 + 24 + + + + + + fFileFormat_textLabel + + + + 270 + 83 + 80 + 20 + + + + File Format + + + + + + fOptionalEntries_groupBox + + + + 10 + 380 + 460 + 90 + + + + Optional Entries + + + + fAplha_textLabel + + + + 10 + 23 + 125 + 20 + + + + Alpha (default = 1) + + + + + fT0_textLabel + + + + 10 + 53 + 201 + 20 + + + + t0 (requiered if not in data file) + + + + + fT0Backward_lineEdit + + + + 300 + 50 + 70 + 24 + + + + + + fBeta_textLabel + + + + 220 + 23 + 118 + 20 + + + + Beta (default = 1) + + + + + fBeta_lineEdit + + + + 350 + 20 + 70 + 24 + + + + + + fAlpha_lineEdit + + + + 140 + 20 + 70 + 24 + + + + + + fT0Forward_lineEdit + + + + 220 + 50 + 70 + 24 + + + + + + + Layout1 + + + + 10 + 480 + 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 + + + + + + + fRequiredEntries_groupBox + + + + 10 + 135 + 460 + 240 + + + + Required Entries + + + + fMap_textLabel + + + + 10 + 23 + 50 + 20 + + + + Map + + + + + fForward_textLabel + + + + 10 + 53 + 113 + 20 + + + + Forward Histo No + + + + + fDataRange_textLabel + + + + 10 + 83 + 79 + 20 + + + + Data Range + + + + + fBackward_textLabel + + + + 210 + 53 + 116 + 20 + + + + Backward Hist No + + + + + fFitRange_textLabel + + + + 10 + 173 + 71 + 20 + + + + Fit Range + + + + + fPacking_textLabel + + + + 10 + 203 + 110 + 20 + + + + Packing/Binning + + + + + fFitRangeEnd_lineEdit + + + + 220 + 170 + 70 + 24 + + + + + + fForward_lineEdit + + + + 140 + 50 + 50 + 24 + + + + + + + + + fFitRangeStart_lineEdit + + + + 140 + 170 + 70 + 24 + + + + + + fPacking_lineEdit + + + + 140 + 200 + 70 + 24 + + + + + + fBackward_lineEdit + + + + 340 + 50 + 50 + 24 + + + + + + fMap_lineEdit + + + + 70 + 20 + 380 + 24 + + + + 0 0 0 0 0 0 0 0 0 0 + + + + + fBackgroundBackwardStart_lineEdit + + + + 300 + 140 + 70 + 24 + + + + + + fBackgroundForwardEnd_lineEdit + + + + 220 + 140 + 70 + 24 + + + + + + fBackgroundForwardStart_lineEdit + + + + 140 + 140 + 70 + 24 + + + + + + fBackground_textLabel + + + + 10 + 143 + 123 + 20 + + + + Background Range + + + + + fBackgroundBackwardEnd_lineEdit + + + + 380 + 140 + 70 + 24 + + + + + + fBackgroundFix_textLabel + + + + 10 + 110 + 110 + 21 + + + + Background Fix + + + + + fOr_textLabel + + + + 300 + 110 + 30 + 21 + + + + <b>OR</b> + + + + + fBackgroundForwardFix_lineEdit + + + + 140 + 110 + 70 + 24 + + + + + + fBackgroundBackwardFix_lineEdit + + + + 220 + 110 + 70 + 24 + + + + + + fDataForwardStart_lineEdit + + + + 140 + 80 + 70 + 24 + + + + + + fDataForwardEnd_lineEdit + + + + 220 + 80 + 70 + 24 + + + + + + fDataBackwardStart_lineEdit + + + + 300 + 80 + 70 + 24 + + + + + + fDataBackwardEnd_lineEdit + + + + 380 + 80 + 70 + 24 + + + + + + + + fOk_button + clicked() + PGetAsymmetryRunBlockDialogBase + accept() + + + fCancel_button + clicked() + PGetAsymmetryRunBlockDialogBase + reject() + + + + fRunFileName_lineEdit + fBeamline_lineEdit + fInstitute_comboBox + fFileFormat_comboBox + fMap_lineEdit + fForward_lineEdit + fBackward_lineEdit + fDataForwardStart_lineEdit + fDataForwardEnd_lineEdit + fDataBackwardStart_lineEdit + fDataBackwardEnd_lineEdit + fBackgroundForwardFix_lineEdit + fBackgroundBackwardFix_lineEdit + fBackgroundForwardStart_lineEdit + fBackgroundForwardEnd_lineEdit + fBackgroundBackwardStart_lineEdit + fBackgroundBackwardEnd_lineEdit + fFitRangeStart_lineEdit + fFitRangeEnd_lineEdit + fPacking_lineEdit + fAlpha_lineEdit + fBeta_lineEdit + fT0Forward_lineEdit + fT0Backward_lineEdit + fOk_button + fCancel_button + fHelp_button + + + diff --git a/src/musrgui/musrgui.pro b/src/musrgui/musrgui.pro index a83ba4f3..3f6065e0 100644 --- a/src/musrgui/musrgui.pro +++ b/src/musrgui/musrgui.pro @@ -20,6 +20,7 @@ HEADERS = PTextEdit.h \ PPrefsDialog.h \ PGetDefaultDialog.h \ PGetParameterDialog.h \ + PGetAsymmetryRunBlockDialog.h \ PGetFourierDialog.h \ PMlog2DbDialog.h \ PGetPlotDialog.h @@ -31,6 +32,7 @@ SOURCES = PTextEdit.cpp \ PPrefsDialog.cpp \ PGetDefaultDialog.cpp \ PGetParameterDialog.cpp \ + PGetAsymmetryRunBlockDialog.cpp \ PGetFourierDialog.cpp \ PGetPlotDialog.cpp \ PMlog2DbDialog.cpp \ @@ -41,6 +43,7 @@ FORMS = forms/PGetDefaultDialogBase.ui \ forms/PPrefsDialogBase.ui \ forms/PGetTitleDialog.ui \ forms/PGetParameterDialogBase.ui \ + forms/PGetAsymmetryRunBlockDialogBase.ui \ forms/PGetFourierDialogBase.ui \ forms/PGetPlotDialogBase.ui \ forms/PMlog2DbDialogBase.ui