musredit 1.0.0
Loading...
Searching...
No Matches
PGetAsymmetryRunBlockDialog.cpp
Go to the documentation of this file.
1/****************************************************************************
2
3 PGetAsymmetryRunBlockDialog.cpp
4
5 Author: Andreas Suter
6 e-mail: andreas.suter@psi.ch
7
8*****************************************************************************/
9
10/***************************************************************************
11 * Copyright (C) 2009-2026 by Andreas Suter *
12 * andreas.suter@psi.ch *
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
18 * *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 * GNU General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program; if not, write to the *
26 * Free Software Foundation, Inc., *
27 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28 ***************************************************************************/
29
42
43#include <QLineEdit>
44#include <QValidator>
45#include <QComboBox>
46#include <QMessageBox>
47#include <QDesktopServices>
48#include <QUrl>
49
51
52
53//----------------------------------------------------------------------------------------------------
67{
68 setupUi(this);
69
70 setModal(true);
71
72 fForwardHistoNo_lineEdit->setValidator( new QIntValidator(fForwardHistoNo_lineEdit) );
73 fBackwardHistoNo_lineEdit->setValidator( new QIntValidator(fBackwardHistoNo_lineEdit) );
74 fDataForwardStart_lineEdit->setValidator( new QIntValidator(fDataForwardStart_lineEdit) );
75 fDataForwardEnd_lineEdit->setValidator( new QIntValidator(fDataForwardEnd_lineEdit) );
76 fDataBackwardStart_lineEdit->setValidator( new QIntValidator(fDataBackwardStart_lineEdit) );
77 fDataBackwardEnd_lineEdit->setValidator( new QIntValidator(fDataBackwardEnd_lineEdit) );
78 fBackgroundForwardStart_lineEdit->setValidator( new QIntValidator(fBackgroundForwardStart_lineEdit) );
79 fBackgroundForwardEnd_lineEdit->setValidator( new QIntValidator(fBackgroundForwardEnd_lineEdit) );
80 fBackgroundBackwardStart_lineEdit->setValidator( new QIntValidator(fBackgroundBackwardStart_lineEdit) );
81 fBackgroundBackwardEnd_lineEdit->setValidator( new QIntValidator(fBackgroundBackwardEnd_lineEdit) );
82 fBackgroundForwardFix_lineEdit->setValidator( new QDoubleValidator(fBackgroundForwardFix_lineEdit) );
83 fBackgroundBackwardFix_lineEdit->setValidator( new QDoubleValidator(fBackgroundBackwardFix_lineEdit) );
84 fFitRangeStart_lineEdit->setValidator( new QDoubleValidator(fFitRangeStart_lineEdit) );
85 fFitRangeEnd_lineEdit->setValidator( new QDoubleValidator(fFitRangeEnd_lineEdit) );
86 fPacking_lineEdit->setValidator( new QIntValidator(fPacking_lineEdit) );
87 fAlpha_lineEdit->setValidator( new QIntValidator(fAlpha_lineEdit) );
88 fBeta_lineEdit->setValidator( new QIntValidator(fBeta_lineEdit) );
89 fT0Forward_lineEdit->setValidator( new QIntValidator(fT0Forward_lineEdit) );
90 fT0Backward_lineEdit->setValidator( new QIntValidator(fT0Backward_lineEdit) );
91}
92
93//----------------------------------------------------------------------------------------------------
105{
106 QString str;
107
108 str = "RUN " + fRunFileName_lineEdit->text() + " ";
109 str += fBeamline_lineEdit->text().toUpper() + " ";
110 str += fInstitute_comboBox->currentText() + " ";
111 str += fFileFormat_comboBox->currentText() + " (name beamline institute data-file-format)\n";
112
113 return str;
114}
115
116//----------------------------------------------------------------------------------------------------
130{
131 QString str = "alpha " + fAlpha_lineEdit->text() + "\n";
132
133 if (str.isEmpty())
134 present = false;
135 else
136 present = true;
137
138 return str;
139}
140
141//----------------------------------------------------------------------------------------------------
155{
156 QString str = "beta " + fBeta_lineEdit->text() + "\n";
157
158 if (str.isEmpty())
159 present = false;
160 else
161 present = true;
162
163 return str;
164}
165
166//----------------------------------------------------------------------------------------------------
180{
181 QString str = fMap_lineEdit->text().trimmed().remove(" ");
182
183 // check if potentially proper map line
184 for (int i=0; i<str.length(); i++) {
185 if (!str[i].isDigit()) {
186 valid = false;
187 break;
188 }
189 }
190
191 str = "map " + fMap_lineEdit->text() + "\n";
192
193 return str;
194}
195
196//----------------------------------------------------------------------------------------------------
214{
215 QString str = "";
216
217 valid = true;
218
219 // check that either backgr.fix or background is given, but not both
220 if (fBackgroundForwardStart_lineEdit->text().isEmpty() && fBackgroundForwardEnd_lineEdit->text().isEmpty() &&
221 fBackgroundBackwardStart_lineEdit->text().isEmpty() && fBackgroundBackwardEnd_lineEdit->text().isEmpty() &&
222 fBackgroundForwardFix_lineEdit->text().isEmpty() && fBackgroundBackwardFix_lineEdit->text().isEmpty()) {
223 valid = false;
224 str = "background 0 10 0 10\n";
225 } else {
226 if (!fBackgroundForwardStart_lineEdit->text().isEmpty()) { // assume the rest is given, not fool prove but ...
227 str = "background ";
228 str += fBackgroundForwardStart_lineEdit->text() + " ";
229 str += fBackgroundForwardEnd_lineEdit->text() + " ";
230 str += fBackgroundBackwardStart_lineEdit->text() + " ";
231 str += fBackgroundBackwardEnd_lineEdit->text() + "\n";
232 }
233 if (!fBackgroundForwardFix_lineEdit->text().isEmpty()) { // assume the rest is given, not fool prove but ...
234 str = "backgr.fix ";
235 str += fBackgroundForwardFix_lineEdit->text() + " ";
236 str += fBackgroundBackwardFix_lineEdit->text() + "\n";
237 }
238 }
239
240 return str;
241}
242
243//----------------------------------------------------------------------------------------------------
258{
259 QString str = "";
260
261 if (fDataForwardStart_lineEdit->text().isEmpty() || fDataForwardEnd_lineEdit->text().isEmpty() ||
262 fDataBackwardStart_lineEdit->text().isEmpty() || fDataBackwardEnd_lineEdit->text().isEmpty()) {
263 valid = false;
264 } else {
265 str = "data ";
266 str += fDataForwardStart_lineEdit->text() + " ";
267 str += fDataForwardEnd_lineEdit->text() + " ";
268 str += fDataBackwardStart_lineEdit->text() + " ";
269 str += fDataBackwardEnd_lineEdit->text() + "\n";
270 valid = true;
271 }
272
273 return str;
274}
275
276//----------------------------------------------------------------------------------------------------
289{
290 QString str = "";
291
292 if (!fT0Forward_lineEdit->text().isEmpty() && !fT0Forward_lineEdit->text().isEmpty()) {
293 str = "t0 ";
294 str += fT0Forward_lineEdit->text() + " ";
295 str += fT0Backward_lineEdit->text() + "\n";
296 present = true;
297 } else {
298 present = false;
299 }
300
301 return str;
302}
303
304//----------------------------------------------------------------------------------------------------
317{
318 QString str = "";
319
320 if (fFitRangeStart_lineEdit->text().isEmpty() || fFitRangeEnd_lineEdit->text().isEmpty()) {
321 str += "fit 0.0 10.0\n";
322 valid = false;
323 } else {
324 str += "fit ";
325 str += fFitRangeStart_lineEdit->text() + " ";
326 str += fFitRangeEnd_lineEdit->text() + "\n";
327 valid = true;
328 }
329
330 return str;
331}
332
333//----------------------------------------------------------------------------------------------------
347{
348 QString str = "";
349
350 if (fPacking_lineEdit->text().isEmpty()) {
351 present = false;
352 str += "packing 1\n";
353 } else {
354 present = true;
355 str += "packing " + fPacking_lineEdit->text() + "\n\n";
356 }
357
358 return str;
359}
360
361//----------------------------------------------------------------------------------------------------
370{
371 if (fHelpUrl.isEmpty()) {
372 QMessageBox::information(this, "INFO", "Will eventually show a help window");
373 } else {
374 bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
375 if (!ok) {
376 QString msg = QString("<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(fHelpUrl);
377 QMessageBox::critical( nullptr, tr("FATAL ERROR"), msg, QMessageBox::Close );
378 }
379 }
380}
381
382//----------------------------------------------------------------------------------------------------
383// END
384//----------------------------------------------------------------------------------------------------
Dialog for creating asymmetry RUN blocks in msr files.
QString getBetaParameter(bool &present)
Generates the beta parameter line for the asymmetry block.
QString getRunHeaderInfo()
Generates the RUN header line for the asymmetry block.
QString getFitRange(bool &valid)
Generates the fit range specification for the asymmetry block.
QString getMap(bool &valid)
Generates the parameter map line for the asymmetry block.
QString getData(bool &valid)
Generates the data range specification for the asymmetry block.
PGetAsymmetryRunBlockDialog(const QString helpUrl)
Constructs the asymmetry RUN block dialog.
QString getBackground(bool &valid)
Generates the background specification for the asymmetry block.
void helpContent()
Opens the online help for asymmetry RUN blocks.
QString getT0(bool &present)
Generates the T0 (time zero) specification for the asymmetry block.
QString fHelpUrl
URL to the online documentation for asymmetry RUN blocks.
QString getPacking(bool &present)
Generates the packing (rebinning) specification for the asymmetry block.
QString getAlphaParameter(bool &present)
Generates the alpha parameter line for the asymmetry block.