mupp 1.1.0
Loading...
Searching...
No Matches
PmuppScript.h
Go to the documentation of this file.
1/***************************************************************************
2
3 PmuppScript.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
60
61#ifndef _PMUPPSCRIPT_H_
62#define _PMUPPSCRIPT_H_
63
64#include <memory>
65
66#include <QString>
67#include <QStringList>
68
69#include "PmuppAdmin.h"
70#include "Pmupp.h"
71#include "PVarHandler.h"
72
73//----------------------------------------------------------------------------
83 int collIdx;
84 QString xLabel;
85 QVector<QString> yLabel;
86};
87
88//----------------------------------------------------------------------------
117class PmuppScript : public QObject
118{
119 Q_OBJECT
120
121 public:
126 PmuppScript(QStringList script);
127
132 void setLoadPath(const QString cmd);
133
138 QString getLoadPath() { return fLoadPath; }
139
144 void setSavePath(const QString cmd);
145
150 QString getSavePath() { return fSavePath; }
151
157 int loadCollection(const QString str);
158
164 int select(const QString str);
165
170 int selectAll();
171
177 int addX(const QString str);
178
184 int addY(const QString str);
185
191 int plot(const QString str);
192
199 int macro(const QString str, const QString plotFln="");
200
209 int var_cmd(const QString str, int script_idx = -1);
210
211 public slots:
221 int executeScript();
222
223 signals:
227 void finished();
228
229 private:
230 std::unique_ptr<PmuppAdmin> fAdmin;
231 QStringList fScript;
232 std::unique_ptr<PParamDataHandler> fParamDataHandler;
234
236 QVector<PmuppPlotEntry> fPlotInfo;
237
238 bool fNorm;
239 QString fLoadPath;
240 QString fSavePath;
241
242 QVector<PVarHandler> fVarHandler;
243
250 bool foundLabel(PmuppCollection *coll, const QString label);
251
257 bool foundVariable(const QString var);
258
264 int getVarIndex(const QString var);
265
272 void minMax(QVector<double> dvec, double &min, double &max);
273
279 QString getNicerLabel(const QString label);
280
286 int getCollectionIndex(const QString var_name);
287
295 QString getPythonBlock(int start_idx = -1);
296};
297
298#endif // _PMUPPSCRIPT_H_
Administration and configuration management for mupp application.
Core data structures and handler classes for mupp parameter management.
Represents a collection of related experimental runs.
Definition Pmupp.h:234
PmuppPlotEntry fPlotEntry
single plot configuration (for specific selection)
QString fSavePath
directory path for saving output files
void setSavePath(const QString cmd)
Sets the save path for output files.
int getCollectionIndex(const QString var_name)
Gets the collection index associated with a variable.
QVector< PmuppPlotEntry > fPlotInfo
vector of all plot configurations (for all selections)
int select(const QString str)
Selects a specific collection for plotting.
int fSelected
selection state: -2=none, -1=all, >=0=specific index
QString getPythonBlock(int start_idx=-1)
Returns the verbatim <python> ... </python> block of the script.
int addX(const QString str)
Adds a parameter to the X-axis.
std::unique_ptr< PmuppAdmin > fAdmin
administration object for configuration
QString fLoadPath
directory path for loading input data files
QString getSavePath()
Gets the current save path.
PmuppScript(QStringList script)
Constructor. Initializes the script interpreter.
QString getNicerLabel(const QString label)
Converts parameter labels to prettier ROOT format.
int addY(const QString str)
Adds one or more parameters to the Y-axis.
void minMax(QVector< double > dvec, double &min, double &max)
Finds minimum and maximum values in a data vector.
void setLoadPath(const QString cmd)
Sets the load path for input data files.
int macro(const QString str, const QString plotFln="")
Generates a ROOT macro for plotting.
QString getLoadPath()
Gets the current load path.
int executeScript()
Executes all script commands sequentially.
int plot(const QString str)
Creates a plot file by generating and executing a ROOT macro.
QVector< PVarHandler > fVarHandler
vector of variable expression handlers
int selectAll()
Selects all loaded collections for plotting.
int var_cmd(const QString str, int script_idx=-1)
Processes a variable definition command.
QStringList fScript
list of script commands to execute
bool foundLabel(PmuppCollection *coll, const QString label)
Checks if a parameter label exists in a collection.
int loadCollection(const QString str)
Loads a data collection from file.
void finished()
Signal emitted when script execution completes.
int getVarIndex(const QString var)
Gets the index of a variable in the handler vector.
std::unique_ptr< PParamDataHandler > fParamDataHandler
handler for parameter data collections
bool foundVariable(const QString var)
Checks if a variable is defined in the variable handler.
bool fNorm
normalization flag (true = normalize Y-data to max value)
Data structure for plot configuration.
Definition PmuppScript.h:82
QString xLabel
X-axis parameter label (independent variable)
Definition PmuppScript.h:84
QVector< QString > yLabel
vector of Y-axis parameter labels (dependent variables)
Definition PmuppScript.h:85
int collIdx
index of the data collection to plot
Definition PmuppScript.h:83