musrStep 1.0.0
Loading...
Searching...
No Matches
PMusrStep.h
Go to the documentation of this file.
1/***************************************************************************
2
3 PMusrStep.h
4
5 Author: Andreas Suter
6 e-mail: andreas.suter@psi.ch
7
8***************************************************************************/
9
10/***************************************************************************
11 * Copyright (C) 2007-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
40
41#ifndef _PMUSRSTEP_H_
42#define _PMUSRSTEP_H_
43
44#include <memory>
45
46#include <QDialog>
47#include <QWidget>
48#include <QVector>
49#include <QPushButton>
50#include <QTableWidget>
51#include <QLabel>
52#include <QCheckBox>
53#include <QLineEdit>
54
62struct PParam {
63 QString number;
64 QString name;
65 QString value;
66 QString step;
67 QString posErr;
68 QString boundLow;
69 QString boundHigh;
70};
71
72//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
84class PModSelect : public QDialog
85{
86 Q_OBJECT
87
88 public:
93 PModSelect(QWidget *parent=Q_NULLPTR);
94
95 signals:
104 void scale(bool automatic, double factor, bool absVal);
105
106 private slots:
113 void absoluteValueStateChanged(int ival);
114
120 void scaleAuto();
121
127 void getFactor();
128
129 private:
130 std::unique_ptr<QCheckBox> fAbsVal;
131 std::unique_ptr<QLabel> fFactorLabel;
132 std::unique_ptr<QLineEdit> fFactorLineEdit;
133 std::unique_ptr<QPushButton> fScaleByFactor;
134 std::unique_ptr<QPushButton> fScaleAutomatic;
135 std::unique_ptr<QPushButton> fCancel;
136};
137
138//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
155class PMusrStep : public QDialog
156{
157 Q_OBJECT
158
159 public:
167 PMusrStep(const char *fln, QWidget *parent=Q_NULLPTR);
168
174 bool isValid() { return fValid; }
175
176 private slots:
184 void handleCellChanged(int row, int column);
185
191 void checkSpecific();
192
197 void checkAll();
198
202 void unCheckAll();
203
209 void modifyAuto();
210
214 void modifyChecked();
215
219 void saveAndQuit();
220
228 void handleModSelect(bool automatic, double factor, bool absVal);
229
230 private:
231 QString fMsrFileName;
232 bool fValid;
233
234 QVector<PParam> fParamVec;
235
236 std::unique_ptr<QLabel> fTitleLabel;
237 std::unique_ptr<QTableWidget> fParamTable;
238 std::unique_ptr<QPushButton> fCheckSpecific;
239 std::unique_ptr<QPushButton> fCheckAll;
240 std::unique_ptr<QPushButton> fUnCheckAll;
241 std::unique_ptr<QPushButton> fModifyAuto;
242 std::unique_ptr<QPushButton> fModifySelected;
243 std::unique_ptr<QPushButton> fSave;
244 std::unique_ptr<QPushButton> fCancel;
245
247
252 void initParam(PParam &param);
253
266 double lookupTable(const QString str, bool &absVal);
267
275 QString adoptStep(const QString str, double factor, bool absVal);
276
283 int readMsrFile();
284
292 int writeMsrFile();
293
300 QString getLine(QByteArray &data, int &idx);
301
309 QString updateParamLine(const QString str);
310};
311
312#endif // _PMUSRSTEP_H_
Dialog for selecting modification options for parameter step sizes.
Definition PMusrStep.h:85
void scaleAuto()
Slot that triggers automatic scaling of selected parameters.
Definition PMusrStep.cpp:138
std::unique_ptr< QPushButton > fCancel
Button to cancel the dialog.
Definition PMusrStep.h:135
std::unique_ptr< QPushButton > fScaleByFactor
Button to apply factor scaling.
Definition PMusrStep.h:133
std::unique_ptr< QCheckBox > fAbsVal
Checkbox for absolute value mode.
Definition PMusrStep.h:130
std::unique_ptr< QLineEdit > fFactorLineEdit
Input field for the scaling factor.
Definition PMusrStep.h:132
void absoluteValueStateChanged(int ival)
Slot called when the absolute value checkbox state changes.
Definition PMusrStep.cpp:120
std::unique_ptr< QLabel > fFactorLabel
Label for the factor input field.
Definition PMusrStep.h:131
std::unique_ptr< QPushButton > fScaleAutomatic
Button to apply automatic scaling.
Definition PMusrStep.h:134
PModSelect(QWidget *parent=Q_NULLPTR)
Constructor for PModSelect dialog.
Definition PMusrStep.cpp:72
void getFactor()
Slot that applies the user-specified factor to selected parameters.
Definition PMusrStep.cpp:151
void scale(bool automatic, double factor, bool absVal)
Signal emitted when user selects a scaling operation.
std::unique_ptr< QPushButton > fUnCheckAll
Button to deselect all parameters.
Definition PMusrStep.h:240
void initParam(PParam &param)
Initializes a PParam structure with empty strings.
Definition PMusrStep.cpp:471
std::unique_ptr< QTableWidget > fParamTable
Table widget for parameter display.
Definition PMusrStep.h:237
int writeMsrFile()
Writes the modified parameters back to the msr-file.
Definition PMusrStep.cpp:637
QString fMsrFileName
Path to the currently open msr-file.
Definition PMusrStep.h:231
QString updateParamLine(const QString str)
Reconstructs a parameter line with updated values.
Definition PMusrStep.cpp:728
std::unique_ptr< QLabel > fTitleLabel
Label displaying the file name.
Definition PMusrStep.h:236
std::unique_ptr< QPushButton > fModifySelected
Button to modify selected parameters.
Definition PMusrStep.h:242
void unCheckAll()
Slot that deselects all parameters.
Definition PMusrStep.cpp:383
void modifyAuto()
Slot that applies automatic step modification to all non-fixed parameters.
Definition PMusrStep.cpp:397
QString adoptStep(const QString str, double factor, bool absVal)
Calculates the new step value based on the current value and factor.
Definition PMusrStep.cpp:540
std::unique_ptr< QPushButton > fCancel
Button to cancel without saving.
Definition PMusrStep.h:244
QString getLine(QByteArray &data, int &idx)
Extracts a single line from a byte array.
Definition PMusrStep.cpp:699
std::unique_ptr< QPushButton > fCheckSpecific
Button to select by template.
Definition PMusrStep.h:238
PModSelect * fModSelect
Pointer to the modification options dialog.
Definition PMusrStep.h:246
std::unique_ptr< QPushButton > fSave
Button to save and quit.
Definition PMusrStep.h:243
void handleModSelect(bool automatic, double factor, bool absVal)
Slot that handles the selection made in the PModSelect dialog.
Definition PMusrStep.cpp:436
std::unique_ptr< QPushButton > fModifyAuto
Button for automatic modification.
Definition PMusrStep.h:241
void checkSpecific()
Slot that allows selection of parameters by name template.
Definition PMusrStep.cpp:343
bool isValid()
Checks if the dialog was initialized successfully.
Definition PMusrStep.h:174
void modifyChecked()
Slot that opens the PModSelect dialog for checked parameters.
Definition PMusrStep.cpp:420
PMusrStep(const char *fln, QWidget *parent=Q_NULLPTR)
Constructor for PMusrStep dialog.
Definition PMusrStep.cpp:178
void saveAndQuit()
Slot that saves the modified msr-file and closes the dialog.
Definition PMusrStep.cpp:457
void handleCellChanged(int row, int column)
Slot called when a table cell value changes.
Definition PMusrStep.cpp:314
double lookupTable(const QString str, bool &absVal)
Determines the appropriate step size factor based on parameter name.
Definition PMusrStep.cpp:500
int readMsrFile()
Reads and parses the FITPARAMETER block from the msr-file.
Definition PMusrStep.cpp:570
bool fValid
Flag indicating successful initialization.
Definition PMusrStep.h:232
std::unique_ptr< QPushButton > fCheckAll
Button to select all parameters.
Definition PMusrStep.h:239
QVector< PParam > fParamVec
Vector storing all fit parameters.
Definition PMusrStep.h:234
void checkAll()
Slot that selects all non-fixed parameters.
Definition PMusrStep.cpp:367
Structure representing a single fit parameter from an msr-file.
Definition PMusrStep.h:62
QString posErr
Positive error estimate.
Definition PMusrStep.h:67
QString boundHigh
Upper boundary constraint (optional)
Definition PMusrStep.h:69
QString name
Parameter name identifier.
Definition PMusrStep.h:64
QString number
Parameter number (index) in the msr-file.
Definition PMusrStep.h:63
QString value
Current parameter value.
Definition PMusrStep.h:65
QString step
Step size for the fit (0 means fixed parameter)
Definition PMusrStep.h:66
QString boundLow
Lower boundary constraint (optional)
Definition PMusrStep.h:68