musredit 1.0.0
Loading...
Searching...
No Matches
PGetNonMusrRunBlockDialog.cpp
Go to the documentation of this file.
1/****************************************************************************
2
3 PGetNonMusrRunBlockDialog.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//----------------------------------------------------------------------------------------------------
68{
69 setupUi(this);
70
71 setModal(true);
72
73 fFitRangeStart_lineEdit->setValidator( new QDoubleValidator(fFitRangeStart_lineEdit) );
74 fFitRangeEnd_lineEdit->setValidator( new QDoubleValidator(fFitRangeEnd_lineEdit) );
75
76 int idx = -1;
77 for (int i=0; i<fFileFormat_comboBox->count(); i++) {
78 if (fFileFormat_comboBox->itemText(i) == "DB") {
79 idx = i;
80 break;
81 }
82 }
83 if (idx >= 0) {
84 fFileFormat_comboBox->setCurrentIndex(idx);
85 }
86}
87
88//----------------------------------------------------------------------------------------------------
100{
101 QString str;
102
103 str = "RUN " + fRunFileName_lineEdit->text() + " ";
104 str += fBeamline_lineEdit->text().toUpper() + " ";
105 str += fInstitute_comboBox->currentText() + " ";
106 str += fFileFormat_comboBox->currentText() + " (name beamline institute data-file-format)\n";
107
108 return str;
109}
110
111//----------------------------------------------------------------------------------------------------
125{
126 QString str = fMap_lineEdit->text().trimmed().remove(" ");
127
128 // check if potentially proper map line
129 for (int i=0; i<str.length(); i++) {
130 if (!str[i].isDigit()) {
131 valid = false;
132 break;
133 }
134 }
135
136 str = "map " + fMap_lineEdit->text() + "\n";
137
138 return str;
139}
140
141//----------------------------------------------------------------------------------------------------
156{
157 QString str = "";
158
159 if (fXData_lineEdit->text().isEmpty() || fYData_lineEdit->text().isEmpty()) {
160 valid = false;
161 } else {
162 str = "xy-data ";
163 str += fXData_lineEdit->text() + " ";
164 str += fYData_lineEdit->text() + "\n";
165 valid = true;
166 }
167
168 return str;
169}
170
171//----------------------------------------------------------------------------------------------------
186{
187 QString str = "";
188
189 if (fFitRangeStart_lineEdit->text().isEmpty() || fFitRangeEnd_lineEdit->text().isEmpty()) {
190 str += "fit 0.0 10.0\n";
191 valid = false;
192 } else {
193 str += "fit ";
194 str += fFitRangeStart_lineEdit->text() + " ";
195 str += fFitRangeEnd_lineEdit->text() + "\n";
196 valid = true;
197 }
198
199 return str;
200}
201
202//----------------------------------------------------------------------------------------------------
211{
212 if (fHelpUrl.isEmpty()) {
213 QMessageBox::information(this, "INFO", "Will eventually show a help window");
214 } else {
215 bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
216 if (!ok) {
217 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);
218 QMessageBox::critical( nullptr, tr("FATAL ERROR"), msg, QMessageBox::Close );
219 }
220 }
221}
222
223//----------------------------------------------------------------------------------------------------
224// END
225//----------------------------------------------------------------------------------------------------
Dialog for creating non-muSR RUN blocks in msr files.
PGetNonMusrRunBlockDialog(const QString helpUrl="")
Constructs the non-muSR RUN block dialog.
QString getXYData(bool &valid)
Generates the xy-data specification line.
QString fHelpUrl
URL to the online documentation for non-muSR RUN blocks.
QString getMap(bool &valid)
Generates the parameter map line.
QString getFitRange(bool &valid)
Generates the fit range specification line.
QString getRunHeaderInfo()
Generates the RUN header line.
void helpContent()
Opens the online help for non-muSR RUN blocks.