musredit 1.0.0
Loading...
Searching...
No Matches
PGetSingleHistoRunBlockDialog.cpp
Go to the documentation of this file.
1/****************************************************************************
2
3 PGetSingleHistoRunBlockDialog.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 <QCheckBox>
47#include <QMessageBox>
48#include <QDesktopServices>
49#include <QUrl>
50
52
53//----------------------------------------------------------------------------------------------------
72 const bool lifetimeCorrection) : fHelpUrl(helpUrl)
73{
74 setupUi(this);
75
76 setModal(true);
77
78 fForwardHistoNo_lineEdit->setValidator( new QIntValidator(fForwardHistoNo_lineEdit) );
79 fNorm_lineEdit->setValidator( new QIntValidator(fNorm_lineEdit) );
80 fDataStart_lineEdit->setValidator( new QIntValidator(fDataStart_lineEdit) );
81 fDataEnd_lineEdit->setValidator( new QIntValidator(fDataEnd_lineEdit) );
82 fBackgroundFix_lineEdit->setValidator( new QDoubleValidator(fBackgroundFix_lineEdit) );
83 fBackgroundFit_lineEdit->setValidator( new QIntValidator(fBackgroundFit_lineEdit) );
84 fBackgroundStart_lineEdit->setValidator( new QIntValidator(fBackgroundStart_lineEdit) );
85 fBackgroundEnd_lineEdit->setValidator( new QIntValidator(fBackgroundEnd_lineEdit) );
86 fFitRangeStart_lineEdit->setValidator( new QDoubleValidator(fFitRangeStart_lineEdit) );
87 fFitRangeEnd_lineEdit->setValidator( new QDoubleValidator(fFitRangeEnd_lineEdit) );
88 fPacking_lineEdit->setValidator( new QIntValidator(fPacking_lineEdit) );
89 fT0_lineEdit->setValidator( new QIntValidator(fT0_lineEdit) );
90 fLifetime_lineEdit->setValidator( new QIntValidator(fLifetime_lineEdit) );
91 fLifetimeCorrection_checkBox->setChecked(lifetimeCorrection);
92}
93
94//----------------------------------------------------------------------------------------------------
106{
107 QString str="";
108
109 str = "RUN " + fRunFileName_lineEdit->text() + " ";
110 str += fBeamline_lineEdit->text().toUpper() + " ";
111 str += fInstitute_comboBox->currentText() + " ";
112 str += fFileFormat_comboBox->currentText() + " (name beamline institute data-file-format)\n";
113
114 return str;
115}
116
117//----------------------------------------------------------------------------------------------------
131{
132 QString str = fMap_lineEdit->text().trimmed().remove(" ");
133
134 // check if potentially proper map line
135 for (int i=0; i<str.length(); i++) {
136 if (!str[i].isDigit()) {
137 valid = false;
138 break;
139 }
140 }
141
142 str = "map " + fMap_lineEdit->text() + "\n";
143
144 return str;
145}
146
147//----------------------------------------------------------------------------------------------------
161{
162 QString str="";
163
164 if (fDataStart_lineEdit->text().isEmpty() || fDataEnd_lineEdit->text().isEmpty()) {
165 valid = false;
166 } else {
167 str = "data ";
168 str += fDataStart_lineEdit->text() + " ";
169 str += fDataEnd_lineEdit->text() + "\n";
170 valid = true;
171 }
172
173 return str;
174}
175
176//----------------------------------------------------------------------------------------------------
197{
198 QString str="";
199
200 valid = true;
201
202 // check that either backgr.fix or background is given, but not both
203 if (fBackgroundStart_lineEdit->text().isEmpty() && fBackgroundEnd_lineEdit->text().isEmpty() &&
204 fBackgroundFix_lineEdit->text().isEmpty() &&
205 fBackgroundFit_lineEdit->text().isEmpty()) {
206 valid = false;
207 str = "background 0 10\n";
208 } else {
209 if (!fBackgroundStart_lineEdit->text().isEmpty()) { // assume the rest is given, not fool prove but ...
210 str = "background ";
211 str += fBackgroundStart_lineEdit->text() + " ";
212 str += fBackgroundEnd_lineEdit->text() + "\n";
213 }
214 if (!fBackgroundFix_lineEdit->text().isEmpty()) {
215 str = "backgr.fix ";
216 str += fBackgroundFix_lineEdit->text() + "\n";
217 }
218 if (!fBackgroundFit_lineEdit->text().isEmpty()) {
219 str = "backgr.fit ";
220 str += fBackgroundFit_lineEdit->text() + "\n";
221 }
222 }
223
224 return str;
225}
226
227//----------------------------------------------------------------------------------------------------
241{
242 QString str="";
243
244 if (fFitRangeStart_lineEdit->text().isEmpty() || fFitRangeEnd_lineEdit->text().isEmpty()) {
245 str += "fit 0.0 10.0\n";
246 valid = false;
247 } else {
248 str += "fit ";
249 str += fFitRangeStart_lineEdit->text() + " ";
250 str += fFitRangeEnd_lineEdit->text() + "\n";
251 valid = true;
252 }
253
254 return str;
255}
256
257//----------------------------------------------------------------------------------------------------
271{
272 QString str="";
273
274 if (fPacking_lineEdit->text().isEmpty()) {
275 present = false;
276 str += "packing 1\n";
277 } else {
278 present = true;
279 str += "packing " + fPacking_lineEdit->text() + "\n\n";
280 }
281
282 return str;
283}
284
285//----------------------------------------------------------------------------------------------------
298{
299 QString str="";
300
301 if (!fT0_lineEdit->text().isEmpty()) {
302 str = "t0 ";
303 str += fT0_lineEdit->text() + "\n";
304 present = true;
305 } else {
306 present = false;
307 }
308
309 return str;
310}
311
312//----------------------------------------------------------------------------------------------------
326{
327 QString str="";
328
329 if (!fLifetime_lineEdit->text().isEmpty()) {
330 str = "lifetime ";
331 str += fLifetime_lineEdit->text() + "\n";
332 present = true;
333 } else {
334 present = false;
335 }
336
337 return str;
338}
339
340//----------------------------------------------------------------------------------------------------
353{
354 QString str="";
355
356 if (fLifetimeCorrection_checkBox->isChecked()) {
357 str = "lifetimecorrection\n";
358 present = true;
359 } else {
360 present = false;
361 }
362
363 return str;
364}
365
366//----------------------------------------------------------------------------------------------------
375{
376 if (fHelpUrl.isEmpty()) {
377 QMessageBox::information(this, "INFO", "Will eventually show a help window");
378 } else {
379 bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
380 if (!ok) {
381 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);
382 QMessageBox::critical( nullptr, tr("FATAL ERROR"), msg, QMessageBox::Close );
383 }
384 }
385}
386
387//----------------------------------------------------------------------------------------------------
388// END
389//----------------------------------------------------------------------------------------------------
Dialog for creating single histogram RUN blocks in msr files.
QString getFitRange(bool &valid)
Generates the fit range specification for the single histogram block.
QString fHelpUrl
URL to the online documentation for single histogram RUN blocks.
QString getPacking(bool &present)
Generates the packing (rebinning) specification for the single histogram block.
QString getMap(bool &valid)
Generates the parameter map line for the single histogram block.
QString getData(bool &valid)
Generates the data range specification for the single histogram block.
QString getT0(bool &present)
Generates the T0 (time zero) specification for the single histogram block.
PGetSingleHistoRunBlockDialog(const QString helpUrl="", const bool lifetimeCorrection=true)
Constructs the single histogram RUN block dialog.
QString getBackground(bool &valid)
Generates the background specification for the single histogram block.
void helpContent()
Opens the online help for single histogram RUN blocks.
QString getRunHeaderInfo()
Generates the RUN header line for the single histogram block.
QString getMuonLifetimeParam(bool &present)
Generates the muon lifetime parameter line for the single histogram block.
QString getLifetimeCorrection(bool &present)
Generates the lifetime correction flag for the single histogram block.