musredit 1.0.0
Loading...
Searching...
No Matches
PGetTheoryBlockDialog Class Reference

Dialog for creating THEORY blocks in msr files. More...

#include <PGetTheoryBlockDialog.h>

Inheritance diagram for PGetTheoryBlockDialog:
Collaboration diagram for PGetTheoryBlockDialog:

Public Member Functions

 PGetTheoryBlockDialog (PAdmin *admin=0, const QString helpUrl="")
 Constructs a dialog for creating THEORY blocks.
 
QString getTheoryBlock ()
 Returns the complete theory block text.
 

Private Slots

QString getTheoFuncString ()
 Generates the theory function string for the selected function.
 
void addPlus ()
 Adds the selected function followed by a '+' operator.
 
void addMultiply ()
 Adds the selected function (multiplication with next line).
 
void helpContent ()
 Opens the online help for THEORY blocks.
 

Private Attributes

PAdminfAdmin
 Pointer to the administration object for accessing theory function definitions.
 
QString fHelpUrl
 URL to the online documentation for THEORY blocks.
 

Detailed Description

Dialog for creating THEORY blocks in msr files.

This dialog allows users to build theory function expressions by selecting from a list of available theory functions. Functions can be combined using addition (+) or multiplication (*) operators. The dialog displays LaTeX-rendered equation icons for visual function identification.

Available Theory Functions:
Theory functions are loaded from the XML configuration file and include:
  • Asymmetry functions (asymmetry, simpleGss, simpleLor, etc.)
  • Relaxation functions (expLF, stretchedExp, etc.)
  • Oscillation functions (TFieldCos, internFld, etc.)
  • User-defined functions (userFcn)
Theory Block Syntax:
Functions on the same line are multiplied; functions preceded by '+' are added:
THEORY
asymmetry 1
simpleGss 2 (rate)
+
asymmetry 3
simpleLor 4 (rate)
This represents: A1 * Gss(t) + A2 * Lor(t)
Parameter Numbering:
Each function line includes placeholder parameter numbers (1, 2, 3...) that should be replaced with actual parameter references from the FITPARAMETER block or map indices.
See also
PAdmin For loading and managing theory function definitions
PTheory For the structure holding individual theory function data

Definition at line 91 of file PGetTheoryBlockDialog.h.

Constructor & Destructor Documentation

◆ PGetTheoryBlockDialog()

PGetTheoryBlockDialog::PGetTheoryBlockDialog ( PAdmin * admin = 0,
const QString helpUrl = "" )

Constructs a dialog for creating THEORY blocks.

Constructor - Initializes the THEORY block dialog.

Initializes the dialog with available theory functions from the administration object. Sets up the combo box with function names and LaTeX equation icons loaded from embedded resources. The dialog is configured as modal to ensure user interaction completion.

Parameters
adminPointer to the PAdmin object containing theory function definitions loaded from the XML configuration file. If nullptr, the dialog will not function properly.
helpUrlURL string pointing to online documentation for THEORY blocks. If empty, help button will show a placeholder message.
See also
PAdmin::getTheoryCounts() For retrieving number of available functions
PAdmin::getTheoryItem() For accessing individual theory function data

Sets up the user interface and populates the theory function combo box with all available theory functions from the administration object. Each function is displayed with its label and, if available, a LaTeX-rendered equation icon.

The combo box icon size is set to 250x20 pixels to accommodate LaTeX equation images. Icons are loaded from embedded Qt resources (:/latex_images/) based on the pixmap name specified in each theory function definition.

The dialog is configured as modal, requiring user interaction before returning control to the parent window.

Parameters
adminPointer to the PAdmin administration object containing theory function definitions loaded from musrfit_startup.xml. Must not be nullptr for proper operation.
helpUrlURL string for the online help documentation. If empty, help button will display a placeholder message instead of opening a web browser.
Note
The dialog assumes fAdmin is valid and contains at least one theory function. No validation is performed on the admin pointer.
See also
PAdmin::getTheoryCounts() Returns the number of available theory functions
PAdmin::getTheoryItem() Retrieves a specific theory function definition
PTheory Structure containing function name, parameters, label, and pixmap name

Definition at line 84 of file PGetTheoryBlockDialog.cpp.

Member Function Documentation

◆ addMultiply

void PGetTheoryBlockDialog::addMultiply ( )
privateslot

Adds the selected function (multiplication with next line).

Adds the current theory function for multiplication.

Appends the currently selected theory function to the text editor on a new line. In musrfit theory blocks, functions on consecutive lines (without a '+' separator) are multiplied together. This is the default operation for combining functions like asymmetry with relaxation.

Example result in editor:

asymmetry 1
simpleGss 2 (rate)

Represents: A1 * Gss(t)

Note
Connected to the "Multiply" button click signal in the UI.
See also
addPlus() For additive combination

Retrieves the formatted string for the currently selected theory function and appends it to the theory block text editor on a new line. In musrfit theory block syntax, functions on consecutive lines (without a '+' separator between them) are implicitly multiplied together.

This creates multiplicative terms in the fit model. For example:

asymmetry 1
simpleGss 2 (rate)
TFieldCos 3 4 (phase frequency)

Represents: A1 * Gss(t) * cos(ωt + φ)

Note
In the code comment "newline == '*'" refers to the implicit multiplication semantics: a newline without '+' means multiply.
This slot is connected to the "Multiply" button in the UI (fMultiply_pushButton).
See also
getTheoFuncString() Generates the theory function string
addPlus() For additive combination of functions

Definition at line 222 of file PGetTheoryBlockDialog.cpp.

◆ addPlus

void PGetTheoryBlockDialog::addPlus ( )
privateslot

Adds the selected function followed by a '+' operator.

Adds the current theory function followed by a '+' operator.

Appends the currently selected theory function to the text editor, followed by a '+' character on a new line. This indicates that the next function should be added (summed) rather than multiplied. In musrfit theory blocks, the '+' operator creates additive terms in the fit function.

Example result in editor:

asymmetry 1
simpleGss 2 (rate)
+
Note
Connected to the "Plus" button click signal in the UI.
See also
addMultiply() For multiplicative combination

Retrieves the formatted string for the currently selected theory function and appends it to the theory block text editor, followed by a newline and a '+' character. The '+' indicates that the next function should be added (summed) rather than multiplied with the current function.

This creates additive terms in the fit model. For example:

asymmetry 1
simpleGss 2 (rate)
+
asymmetry 3
simpleLor 4 (rate)

Represents: A1*Gss(t) + A2*Lor(t)

Note
This slot is connected to the "Plus" button in the UI (fPlus_pushButton).
See also
getTheoFuncString() Generates the theory function string
addMultiply() For multiplicative combination of functions

Definition at line 192 of file PGetTheoryBlockDialog.cpp.

◆ getTheoFuncString

QString PGetTheoryBlockDialog::getTheoFuncString ( )
privateslot

Generates the theory function string for the selected function.

Generates the formatted theory function string for the selected function.

Constructs a formatted string for the currently selected theory function from the combo box. The string includes:

  • Function name (e.g., "asymmetry", "simpleGss")
  • For userFcn: library and function names (e.g., "libMyLibrary.so TMyFunction")
  • Sequential parameter placeholders (1, 2, 3, ...)
  • Function comment describing parameters

Example output: "simpleGss 1 2 (phase frequency)"

Returns
QString containing the formatted theory function line. Returns "????" if no valid theory item is found at the current index.
See also
PTheory For the structure defining theory function properties

Constructs a complete theory function line suitable for insertion into an msr file THEORY block. The format depends on the function type:

For standard functions:

functionName 1 2 3 ... (comment)

For user-defined functions (userFcn):

userFcn libMyLibrary.so TMyFunction 1 2 ... (comment)

The parameter numbers (1, 2, 3, ...) are placeholders that should be replaced with actual FITPARAMETER indices or map references before the msr file is used for fitting.

Returns
QString containing the formatted theory function line with:
  • Function name
  • Library and function names (for userFcn only)
  • Sequential parameter placeholders (1 to params count)
  • Parameter comment from theory definition Returns "????" if the theory item cannot be retrieved (invalid index).
Note
This is a private slot method typically called by addPlus() and addMultiply().
See also
PTheory::name Function name as defined in XML
PTheory::params Number of parameters required by the function
PTheory::comment Descriptive text explaining the parameters
addPlus() Uses this method to add functions with addition
addMultiply() Uses this method to add functions with multiplication

Definition at line 145 of file PGetTheoryBlockDialog.cpp.

◆ getTheoryBlock()

QString PGetTheoryBlockDialog::getTheoryBlock ( )
inline

Returns the complete theory block text.

Retrieves all theory function expressions entered by the user through the dialog interface. The returned string is formatted according to musrfit msr file specifications and is ready for direct insertion into the THEORY section of an msr file.

Returns
QString containing all theory function lines, with proper formatting including function names, parameter placeholders, comments, and operators ('+' for addition, newline for multiplication).
Note
The returned string should be parsed and parameter numbers replaced with actual FITPARAMETER references before saving to file.

Definition at line 130 of file PGetTheoryBlockDialog.h.

◆ helpContent

void PGetTheoryBlockDialog::helpContent ( )
privateslot

Opens the online help for THEORY blocks.

Opens online help documentation for THEORY blocks.

Attempts to open the help URL in the system's default web browser using QDesktopServices. If the URL is empty, displays a placeholder information message. If the browser cannot be opened, shows an error dialog with the URL for manual access.

The help documentation typically covers:

  • Available theory functions and their parameters
  • Syntax for combining functions
  • Examples of common theory block patterns
Note
Connected to the help button click signal in the UI.
See also
PGetTheoryBlockDialog::PGetTheoryBlockDialog() Where helpUrl is set

Attempts to open the help URL in the user's default web browser using QDesktopServices::openUrl(). The help typically provides comprehensive documentation on:

  • Available theory functions and their physical meanings
  • Parameter descriptions for each function
  • Syntax rules for combining functions
  • Examples of common theory block patterns for µSR data analysis

Error handling:

  • If fHelpUrl is empty: displays an information dialog with a placeholder message
  • If the browser fails to open: displays a critical error dialog with the URL formatted as a clickable hyperlink for manual access
Note
The URL is parsed in TolerantMode to handle various URL formats gracefully.
This slot is connected to the help button in the UI.
See also
PGetTheoryBlockDialog::PGetTheoryBlockDialog() Where fHelpUrl is initialized

Definition at line 250 of file PGetTheoryBlockDialog.cpp.

Member Data Documentation

◆ fAdmin

PAdmin* PGetTheoryBlockDialog::fAdmin
private

Pointer to the administration object for accessing theory function definitions.

Definition at line 214 of file PGetTheoryBlockDialog.h.

◆ fHelpUrl

QString PGetTheoryBlockDialog::fHelpUrl
private

URL to the online documentation for THEORY blocks.

Definition at line 215 of file PGetTheoryBlockDialog.h.


The documentation for this class was generated from the following files: