musredit 1.0.0
Loading...
Searching...
No Matches
PGetFourierBlockDialog.cpp
Go to the documentation of this file.
1/****************************************************************************
2
3 PGetFourierBlockDialog.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
43
44#include <QObject>
45#include <QComboBox>
46#include <QValidator>
47#include <QLineEdit>
48#include <QPushButton>
49#include <QMessageBox>
50#include <QDesktopServices>
51#include <QUrl>
52
54
55//----------------------------------------------------------------------------------------------------
73{
74 setupUi(this);
75
76 setModal(true);
77
78 fFourierBlock = "";
79 fFourierPower_lineEdit->setValidator( new QIntValidator(fFourierPower_lineEdit) );
80 fPhaseCorrectionRangeLow_lineEdit->setValidator( new QDoubleValidator(fPhaseCorrectionRangeLow_lineEdit) );
81 fPhaseCorrectionRangeUp_lineEdit->setValidator( new QDoubleValidator(fPhaseCorrectionRangeUp_lineEdit) );
82 fRangeLow_lineEdit->setValidator( new QDoubleValidator(fRangeLow_lineEdit) );
83 fRangeUp_lineEdit->setValidator( new QDoubleValidator(fRangeUp_lineEdit) );
84
85 connect( fPhase_lineEdit, SIGNAL( lostFocus() ), this, SLOT( checkPhaseParameter() ) );
86}
87
88//----------------------------------------------------------------------------------------------------
105{
106 QString str = fPhase_lineEdit->text();
107
108 if (str.isEmpty())
109 return;
110
111 bool ok;
112 int ival;
113
114 ival = str.toInt(&ok);
115 if (!ok) { // i.e. the phase entry is not a number. Check for parXX
116 str = str.trimmed();
117 if (str.startsWith("par")) { //
118 str.remove("par");
119 ival = str.toInt(&ok);
120 if (!ok) {
121 fPhase_lineEdit->clear();
122 QMessageBox::critical(this, "ERROR",
123 "Allowed phase entries are either a parameter number,\n or an parXX entry, where XX is a parameter number",
124 QMessageBox::Ok, QMessageBox::NoButton);
125 fPhase_lineEdit->setFocus();
126 }
127 } else { // neither a parXX nor a number
128 fPhase_lineEdit->clear();
129 QMessageBox::critical(this, "ERROR",
130 "Allowed phase entries are either a parameter number,\n or an parXX entry, where XX is a parameter number",
131 QMessageBox::Ok, QMessageBox::NoButton);
132 fPhase_lineEdit->setFocus();
133 }
134 }
135}
136
137//----------------------------------------------------------------------------------------------------
164{
165 fFourierBlock = "###############################################################\n";
166 fFourierBlock += "FOURIER\n";
167 fFourierBlock += "units " + fUnits_comboBox->currentText() + "\n";
168 QString str = fFourierPower_lineEdit->text();
169 if (!str.isEmpty())
170 fFourierBlock += "fourier_power " + str + "\n";
171 fFourierBlock += "apodization " + fApodization_comboBox->currentText() + "\n";
172 fFourierBlock += "plot " + fPlot_comboBox->currentText() + "\n";
173 str = fPhase_lineEdit->text();
174 if (!str.isEmpty())
175 fFourierBlock += "phase " + str + "\n";
176 if (!fPhaseCorrectionRangeLow_lineEdit->text().isEmpty() && !fPhaseCorrectionRangeUp_lineEdit->text().isEmpty()) {
177 fFourierBlock += "range_for_phase_correction " + fPhaseCorrectionRangeLow_lineEdit->text() + " " +
178 fPhaseCorrectionRangeUp_lineEdit->text() + "\n";
179 }
180 if (!fRangeLow_lineEdit->text().isEmpty() && !fRangeUp_lineEdit->text().isEmpty()) {
181 fFourierBlock += "range " + fRangeLow_lineEdit->text() + " " + fRangeUp_lineEdit->text() + "\n";
182 }
183}
184
185//----------------------------------------------------------------------------------------------------
194{
195 if (fHelpUrl.isEmpty()) {
196 QMessageBox::information(this, "INFO", "Will eventually show a help window");
197 } else {
198 bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
199 if (!ok) {
200 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);
201 QMessageBox::critical( nullptr, tr("FATAL ERROR"), msg, QMessageBox::Close );
202 }
203 }
204}
205
206//----------------------------------------------------------------------------------------------------
207// END
208//----------------------------------------------------------------------------------------------------
Dialog for creating FOURIER blocks in msr files.
PGetFourierBlockDialog(const QString helpUrl)
Constructs the FOURIER block dialog.
void helpContent()
Opens the online help for FOURIER blocks.
void fillFourierBlock()
Builds the FOURIER block string from dialog inputs.
void checkPhaseParameter()
Validates the phase parameter input.
QString fHelpUrl
URL to the online documentation for FOURIER blocks.
QString fFourierBlock
Generated msr-file FOURIER block string.