mupp 1.1.0
Loading...
Searching...
No Matches
mupp.cpp File Reference

Implementation of mupp (muon parameter plotter) main application. More...

#include <iostream>
#include <QObject>
#include <QScopedPointer>
#include <QApplication>
#include <QCoreApplication>
#include <QFile>
#include <QString>
#include <QStringList>
#include <QVector>
#include <QTextStream>
#include <QTimer>
#include "mupp_version.h"
#include "PmuppScript.h"
#include "PmuppGui.h"
Include dependency graph for mupp.cpp:

Go to the source code of this file.

Functions

void mupp_script_syntax ()
 Displays the mupp script syntax help to stdout.
 
void mupp_syntax ()
 Displays the mupp application syntax and usage help to stdout.
 
int mupp_script_read (const char *fln, QStringList &list)
 Reads a mupp script file and parses its content into a string list.
 
bool mupp_bash_variable_exists (const QString str)
 Checks if a bash environment variable exists and is non-empty.
 
int mupp_script_syntax_check (QStringList &list)
 Validates the syntax of mupp script commands.
 
QCoreApplication * createApplication (int &argc, char *argv[], bool gui)
 Factory function to create the appropriate Qt application object.
 
int main (int argc, char *argv[])
 Main entry point of the mupp application.
 

Detailed Description

Implementation of mupp (muon parameter plotter) main application.

mupp is a tool for plotting muon spin spectroscopy (muSR) fit parameters as a function of various experimental conditions (temperature, field, etc.). The application supports both GUI and script-based modes. It can handle parameter files in db, dat, and msr formats, allowing users to visualize trends in fit parameters across multiple runs.

The main functionality includes:

  • Loading and parsing parameter files (db, dat, msr)
  • Interactive GUI for data selection and visualization
  • Script-based batch processing for automated plotting
  • Export of plots in various formats (pdf, png, svg, etc.)
  • Generation of ROOT macros for further analysis

Definition in file mupp.cpp.

Function Documentation

◆ createApplication()

QCoreApplication * createApplication ( int & argc,
char * argv[],
bool gui )

Factory function to create the appropriate Qt application object.

This function selects and creates the proper Qt application class based on whether GUI or console mode is required. It creates a QApplication instance for GUI mode (which supports widgets and graphics) or a QCoreApplication instance for script/console mode (which is lighter and has no GUI support).

Parameters
argcreference to the argument count from main()
argvargument vector from main() containing command-line arguments
guiif true, a GUI application (QApplication) is created; if false, a console application (QCoreApplication) is created
Returns
pointer to the created Qt application object (either QApplication or QCoreApplication depending on the gui parameter)
See also
main()

Definition at line 567 of file mupp.cpp.

◆ main()

int main ( int argc,
char * argv[] )

Main entry point of the mupp application.

mupp (muon parameter plotter) is an application designed to visualize muSR fit parameters from db-files, dat-files, or msr-files. The typical use case is plotting fit parameters as a function of experimental conditions such as temperature, pressure, magnetic field, energy, etc.

The application supports two operational modes:

  • GUI mode: Interactive graphical interface for data exploration, parameter selection, and plot generation
  • Script mode: Batch processing using script files for automated plotting and analysis

Command-line usage:

mupp [OPTIONS] [[--path <fit-param-path>] <fit-param-file-names>]

Processing flow:

  1. Parse command-line arguments
  2. Handle help (-h, –help) and version (-v, –version) requests
  3. Process script mode (-s, –script) or file list mode
  4. Create appropriate Qt application (GUI or console)
  5. Initialize either PmuppGui or PmuppScript
  6. Enter Qt event loop
Parameters
argcargument count from the command line
argvargument vector containing command-line arguments
Returns
0 on successful execution, negative values on error: -1: file or script errors, invalid arguments
See also
PmuppGui, PmuppScript, createApplication()

Definition at line 611 of file mupp.cpp.

◆ mupp_bash_variable_exists()

bool mupp_bash_variable_exists ( const QString str)

Checks if a bash environment variable exists and is non-empty.

This function verifies the existence of a bash environment variable by querying the system environment. The variable name can be specified with or without the leading '$' symbol, as it will be removed internally.

Parameters
strname of the bash variable to be checked (with or without '$' prefix)
Returns
true if the bash variable exists and has a non-empty value, false otherwise
See also
mupp_script_syntax_check()

Definition at line 251 of file mupp.cpp.

◆ mupp_script_read()

int mupp_script_read ( const char * fln,
QStringList & list )

Reads a mupp script file and parses its content into a string list.

This function reads a mupp script file line by line, processes each line by:

  • Removing leading and trailing whitespace
  • Skipping empty lines
  • Skipping comment lines (starting with '#', '', or '//')
  • Removing trailing comments from command lines
  • Adding valid command lines to the output list
Parameters
flnthe mupp script file name (path) to be read
listreference to QStringList that will contain the parsed script commands
Returns
0 on success, -1 if the file cannot be opened
See also
mupp_script_syntax_check(), mupp_script_syntax()

Definition at line 170 of file mupp.cpp.

◆ mupp_script_syntax()

void mupp_script_syntax ( )

Displays the mupp script syntax help to stdout.

This function prints detailed information about the mupp script commands, including available commands, their syntax, and descriptions. The script commands allow for batch processing and automated plotting of parameter data without user interaction.

See also
mupp_syntax(), mupp_script_read(), mupp_script_syntax_check()

Definition at line 80 of file mupp.cpp.

◆ mupp_script_syntax_check()

int mupp_script_syntax_check ( QStringList & list)

Validates the syntax of mupp script commands.

This function performs comprehensive validation of mupp script commands, including:

  • Verification of command syntax and required parameters
  • Validation of file paths and bash environment variables
  • Checking file extensions for plot and macro outputs
  • Ensuring variable definitions are properly linked to collections
  • Verifying collection indices are within valid ranges

The function tracks defined variables and ensures they are properly linked to collections before use. It also validates that all collections referenced in the script have been loaded.

Parameters
listreference to QStringList containing the parsed mupp script commands
Returns
0 on success, negative values indicating different types of errors: -1: general syntax error -2: invalid file extension or empty bash variable -3: unrecognized command or collection out of range -4: no data loaded or internal consistency error -5: variable not defined before linking
See also
mupp_script_read(), mupp_bash_variable_exists()

Definition at line 291 of file mupp.cpp.

◆ mupp_syntax()

void mupp_syntax ( )

Displays the mupp application syntax and usage help to stdout.

This function prints the complete usage information for the mupp application, including command-line options, file path specifications, and supported file formats. It also calls mupp_script_syntax() to display script-specific help.

Command-line options include:

  • Help and version information
  • Script mode execution
  • File path and file name specifications
See also
mupp_script_syntax()

Definition at line 137 of file mupp.cpp.