3. API Reference¶
The following sections provide detailed API documentation for the main classes in LAMMPS-GUI. Documentation is generated from Doxygen comments in the source code.
3.1. Main Window¶
3.1.1. LammpsGui Class¶
-
class LammpsGui : public QMainWindow¶
Main application window for LAMMPS-GUI.
LammpsGui is the central component of the LAMMPS-GUI application, serving as the main window that coordinates all other components. It manages:
The code editor for LAMMPS input scripts with syntax highlighting
File operations (open, save, recent files)
LAMMPS simulation execution and control
Visualization windows (images, charts, log output)
Application preferences and settings
Tutorial wizard for interactive LAMMPS learning
The class integrates with Qt’s main window framework and provides menu actions, toolbars, and status bar components. It uses a LammpsWrapper to interface with the LAMMPS library and LammpsRunner to execute simulations in a separate thread.
See also
CodeEditor for the text editor component
See also
ChartWindow for the charts window component
See also
LogWindow for the log output window component
See also
ImageViewer for the snapshot image window component
See also
SlideShow for the slide show viewer window component
See also
Preferences for the preferences window component
See also
LammpsRunner for simulation execution in a separate thread
See also
LammpsWrapper for LAMMPS library interface
Public Functions
-
LammpsGui(QWidget *parent = nullptr, const QString &filename = QString(), int width = 0, int height = 0)¶
Construct the main application window.
Initializes the main window, sets up the UI components, loads preferences, initializes the LAMMPS library, and optionally opens a file if provided.
- Parameters:
parent – Parent widget (typically nullptr for main window)
filename – Optional file to open on startup
width – Optional main editor window width override
height – Optional main editor window height override
-
~LammpsGui() override¶
Destructor.
Cleans up resources including dynamically created widgets and LAMMPS instances.
-
LammpsGui() = delete¶
Public Slots
-
void quit()¶
Quit the application.
-
void stopRun()¶
Stop a running LAMMPS simulation.
-
inline void runBuffer()¶
Run LAMMPS with content from editor buffer.
Protected Functions
-
void openFile(const QString &filename)¶
Open a file in the editor.
-
void viewFile(const QString &filename)¶
Open a file in a read-only viewer dialog.
-
void inspectFile(const QString &filename)¶
Open a file for inspection (data files, etc.)
-
void writeFile(const QString &filename)¶
Write current editor content to a file.
-
void updateRecents(const QString &filename = "")¶
Update the recent files list.
-
void clearVariables()¶
Clear the list of index-style variables.
-
void updateVariables()¶
Update variables in LAMMPS from the variables list.
-
void doRun(bool use_buffer)¶
Execute a LAMMPS simulation.
- Parameters:
use_buffer – If true, runs from editor buffer; if false, saves and runs from file
-
void startLammps()¶
Initialize and start a new LAMMPS instance.
-
void runDone()¶
Handle completion of a LAMMPS run.
-
void setDocver()¶
Set the documentation version string for help links.
-
void autoSave()¶
Perform an auto-save of the current file.
-
void setFont(const QFont &newfont)¶
Update the editor font.
- Parameters:
newfont – The font to apply to the editor
-
QWizardPage *tutorialIntro(int collection, int ntutorial, const QString &infotext)¶
Create an introduction page for a tutorial.
- Parameters:
collection – Tutorial collection index
ntutorial – Tutorial number within the collection
infotext – Information text to display
- Returns:
Wizard page with tutorial introduction
-
QWizardPage *tutorialDirectory(int collection, int ntutorial)¶
Create a directory selection page for a tutorial.
- Parameters:
collection – Tutorial collection index
ntutorial – Tutorial number within the collection
- Returns:
Wizard page for tutorial directory selection
-
void setupTutorial(int collection, int tutno, const QString &dir, bool purgedir, bool getsolution, bool openwebpage)¶
Set up files and resources for a tutorial.
- Parameters:
collection – Tutorial collection index
tutno – Tutorial number within the collection
dir – Directory to create files in
purgedir – Whether to clean the directory first
getsolution – Whether to include solution files
openwebpage – Whether to open the tutorial web page
-
void purgeInspectList()¶
Clean up the inspect file dialog list.
-
bool eventFilter(QObject *watched, QEvent *event) override¶
Event filter for handling special events.
- Parameters:
watched – Object being watched
event – Event to filter
- Returns:
true if event was handled
3.1.2. TutorialWizard Class¶
-
class TutorialWizard : public QWizard¶
Wizard dialog for interactive LAMMPS tutorials.
TutorialWizard provides a step-by-step wizard interface for setting up and running LAMMPS tutorials. It guides users through directory selection, file preparation, and launching tutorial exercises.
Public Functions
-
TutorialWizard(int collection, int ntutorial, LammpsGui *lammpsgui, QWidget *parent = nullptr)¶
Construct a tutorial wizard.
- Parameters:
collection – Tutorial collection index
ntutorial – Tutorial number within the collection
lammpsgui – Pointer to LammpsGui for sending signals
parent – Parent widget
-
void accept() override¶
Accept the wizard and set up the tutorial.
Called when the user completes the wizard. Sets up tutorial files and opens the tutorial in the main window.
-
TutorialWizard(int collection, int ntutorial, LammpsGui *lammpsgui, QWidget *parent = nullptr)¶
3.1.3. Tutorial Collections¶
The TutorialCollection struct (src/tutorials.h) is the single source of
truth for the tutorial collections offered in the Tutorials menu. Each entry
describes one independently hosted collection (its files repository, web pages,
per-tutorial titles and blurbs, and how much of it is released). The menu and
the TutorialWizard consume the table through the
tutorialCollections() and tutorialCollection() accessors. See
Adding or updating a tutorial collection for how to add or update a tutorial or a whole collection.
-
struct TutorialCollection¶
Metadata for one collection of LAMMPS-GUI tutorials.
LAMMPS-GUI ships support for multiple, independently hosted tutorial collections (e.g. the molecular soft-matter set and the materials-science set). Each collection is a numbered series of tutorials laid out identically — one
files/tutorial<N>/folder per tutorial with a.manifestand an optionalsolution/subfolder — so the only thing that varies between collections is this metadata. The single source of truth is the table in tutorials.cpp, consumed by the Tutorials menu and the TutorialWizard.Public Functions
-
inline int count() const¶
Number of tutorials in this collection.
-
inline QString logoFor(int n) const¶
Logo resource for tutorial
n(1-based); resolves a “%1” pattern.
Public Members
-
QString key¶
stable identifier, e.g. “molecular”, “matsci”
-
QString name¶
display name for the menu and wizard
-
QString dirPrefix¶
working-directory folder prefix (e.g. “tutorial”)
-
QString author¶
short author/attribution line for the intro page
-
QString filesUrl¶
raw files base, “…tutorial%1/%2” (number, filename)
-
QString filesRepoUrl¶
human-facing repository URL shown on the intro page
-
QString webUrl¶
per-tutorial web page pattern, “…%1/%2.html” (number, slug)
-
QString siteUrl¶
collection landing page (fallback web page)
-
QString logo¶
logo resource; may contain “%1” for per-tutorial logos
-
bool published¶
true once the whole collection is released (hides the teaser label)
-
QString status¶
menu label for an unpublished collection (“coming soon”, “planned”)
-
inline int count() const¶
-
const QList<TutorialCollection> &tutorialCollections()¶
The available tutorial collections, in display order.
-
const TutorialCollection &tutorialCollection(int index)¶
Collection at
index, clamped to a valid entry (0 if out of range)
3.2. Editor Components¶
3.2.1. CodeEditor Class¶
-
class CodeEditor : public QPlainTextEdit¶
Custom text editor with LAMMPS syntax support and auto-completion.
The CodeEditor class extends QPlainTextEdit to provide specialized features for editing LAMMPS input scripts:
Line numbers in a margin area
Syntax highlighting via Highlighter
Context-aware auto-completion for LAMMPS commands
Automatic indentation and formatting
Context menu with LAMMPS-specific help
Line highlighting for error visualization
Public Functions
-
CodeEditor(QWidget *parent = nullptr)¶
Constructor.
- Parameters:
parent – Parent widget (typically the main window)
-
~CodeEditor() override¶
Destructor.
-
CodeEditor() = delete¶
-
CodeEditor(const CodeEditor&) = delete¶
-
CodeEditor(CodeEditor&&) = delete¶
-
CodeEditor &operator=(const CodeEditor&) = delete¶
-
CodeEditor &operator=(CodeEditor&&) = delete¶
-
void lineNumberAreaPaintEvent(QPaintEvent *event)¶
Paint line numbers in the line number area.
- Parameters:
event – Paint event to handle
-
int lineNumberAreaWidth()¶
Calculate width needed for line number area.
- Returns:
Width in pixels
-
void setFont(const QFont &newfont)¶
Set editor font.
- Parameters:
newfont – Font to use for editor text
-
void setCursor(int block)¶
Set cursor to specific text block.
- Parameters:
block – Block number (line number) to position cursor
-
void setHighlight(int block, bool error)¶
Highlight a specific line (used for error indication)
- Parameters:
block – Block number to highlight
error – true for error highlight, false to clear
-
inline void setReformatOnReturn(bool flag)¶
Enable/disable automatic reformatting on Enter key.
- Parameters:
flag – true to enable, false to disable
-
inline void setAutoComplete(bool flag)¶
Enable/disable automatic completion popup.
- Parameters:
flag – true to enable, false to disable
-
QString reformatLine(const QString &line)¶
Reformat a line with proper indentation.
- Parameters:
line – Line to reformat
- Returns:
Reformatted line
-
void setCommandList(const QStringList &words)¶
Set word list for LAMMPS command completion.
- Parameters:
words – List of command names
-
void setFixList(const QStringList &words)¶
Set word list for fix style completion.
- Parameters:
words – List of fix style names
-
void setComputeList(const QStringList &words)¶
Set word list for compute style completion.
- Parameters:
words – List of compute style names
-
void setDumpList(const QStringList &words)¶
Set word list for dump style completion.
- Parameters:
words – List of dump style names
-
void setAtomList(const QStringList &words)¶
Set word list for atom style completion.
- Parameters:
words – List of atom style names
-
void setPairList(const QStringList &words)¶
Set word list for pair style completion.
- Parameters:
words – List of pair style names
-
void setBondList(const QStringList &words)¶
Set word list for bond style completion.
- Parameters:
words – List of bond style names
-
void setAngleList(const QStringList &words)¶
Set word list for angle style completion.
- Parameters:
words – List of angle style names
-
void setDihedralList(const QStringList &words)¶
Set word list for dihedral style completion.
- Parameters:
words – List of dihedral style names
-
void setImproperList(const QStringList &words)¶
Set word list for improper style completion.
- Parameters:
words – List of improper style names
-
void setKspaceList(const QStringList &words)¶
Set word list for kspace style completion.
- Parameters:
words – List of kspace style names
-
void setRegionList(const QStringList &words)¶
Set word list for region style completion.
- Parameters:
words – List of region style names
-
void setIntegrateList(const QStringList &words)¶
Set word list for integration style completion.
- Parameters:
words – List of integration style names
-
void setMinimizeList(const QStringList &words)¶
Set word list for minimization style completion.
- Parameters:
words – List of minimization style names
-
void setVariableList(const QStringList &words)¶
Set word list for variable style completion.
- Parameters:
words – List of variable style names
-
void setUnitsList(const QStringList &words)¶
Set word list for units style completion.
- Parameters:
words – List of units style names
-
void setExtraList(const QStringList &words)¶
Set extra word list for completion.
- Parameters:
words – List of extra words
-
void setGroupList()¶
Update group ID list from current LAMMPS instance.
-
void setVarNameList()¶
Update variable name list from current LAMMPS instance.
-
void setComputeIDList()¶
Update compute ID list from current LAMMPS instance.
-
void setFixIDList()¶
Update fix ID list from current LAMMPS instance.
-
void setFileList()¶
Update file list from current directory.
Public Static Attributes
-
static constexpr int NO_HIGHLIGHT = 1 << 30¶
Constant for disabled highlighting.
Protected Functions
-
void resizeEvent(QResizeEvent *event) override¶
Handle resize events to update line number area.
- Parameters:
event – The resize event
-
bool canInsertFromMimeData(const QMimeData *source) const override¶
Check if MIME data can be inserted (for drag-and-drop)
- Parameters:
source – The MIME data to check
- Returns:
true if data can be inserted
-
void dragEnterEvent(QDragEnterEvent *event) override¶
Handle drag enter events.
- Parameters:
event – The drag enter event
-
void dragLeaveEvent(QDragLeaveEvent *event) override¶
Handle drag leave events.
- Parameters:
event – The drag leave event
-
void dropEvent(QDropEvent *event) override¶
Handle drop events.
- Parameters:
event – The drop event
-
void contextMenuEvent(QContextMenuEvent *event) override¶
Handle context menu events.
- Parameters:
event – The context menu event
-
void keyPressEvent(QKeyEvent *event) override¶
Handle key press events (for auto-completion and formatting)
- Parameters:
event – The key event
-
void setDocver()¶
Set LAMMPS documentation version for help links.
3.2.2. LineNumberArea Class¶
-
class LineNumberArea : public QWidget¶
Widget displaying line numbers alongside the code editor.
This widget is placed in the margin of the CodeEditor to show line numbers. All painting is delegated back to the CodeEditor class.
Public Functions
-
inline explicit LineNumberArea(CodeEditor *editor)¶
Constructor.
- Parameters:
editor – Pointer to the associated CodeEditor
-
~LineNumberArea() override = default¶
Destructor.
-
LineNumberArea() = delete¶
-
LineNumberArea(const LineNumberArea&) = delete¶
-
LineNumberArea(LineNumberArea&&) = delete¶
-
LineNumberArea &operator=(const LineNumberArea&) = delete¶
-
LineNumberArea &operator=(LineNumberArea&&) = delete¶
-
inline QSize sizeHint() const override¶
Get the ideal size for the line number area.
- Returns:
QSize with width from editor, height 0 (fills available height)
Protected Functions
-
inline void paintEvent(QPaintEvent *event) override¶
Paint event handler - delegates to CodeEditor.
- Parameters:
event – The paint event
-
inline explicit LineNumberArea(CodeEditor *editor)¶
3.2.3. Highlighter Class¶
-
class Highlighter : public QSyntaxHighlighter¶
Syntax highlighter for LAMMPS input scripts.
This class extends QSyntaxHighlighter to provide syntax highlighting for LAMMPS input files in the CodeEditor. It categorizes and styles commands, keywords, variables, numbers, strings, and comments.
Public Functions
-
explicit Highlighter(QTextDocument *parent = nullptr)¶
Constructor.
- Parameters:
parent – Parent text document to highlight
-
~Highlighter() override = default¶
Destructor.
-
Highlighter() = delete¶
-
Highlighter(const Highlighter&) = delete¶
-
Highlighter(Highlighter&&) = delete¶
-
Highlighter &operator=(const Highlighter&) = delete¶
-
Highlighter &operator=(Highlighter&&) = delete¶
Protected Functions
-
void highlightBlock(const QString &text) override¶
Highlight a single block (line) of text.
- Parameters:
text – The text to highlight
-
explicit Highlighter(QTextDocument *parent = nullptr)¶
3.3. LAMMPS Interface¶
3.3.1. LammpsWrapper Class¶
-
class LammpsWrapper¶
C++ wrapper for the LAMMPS C library interface.
This class provides a C++-oriented interface to the LAMMPS library, routing all library calls through a unified API. It manages the LAMMPS instance and handles dynamic loading of the library when the application is built in plugin mode.
Public Types
-
enum StyleConst¶
Constants for variable styles.
Values:
-
enumerator EQUAL_STYLE¶
-
enumerator ATOM_STYLE¶
-
enumerator VECTOR_STYLE¶
-
enumerator STRING_STYLE¶
-
enumerator EQUAL_STYLE¶
Public Functions
-
LammpsWrapper()¶
Constructor - initializes wrapper.
-
~LammpsWrapper() = default¶
Destructor (defaulted)
Does not close an open LAMMPS instance. Callers must invoke close() explicitly before destroying the wrapper.
-
LammpsWrapper(const LammpsWrapper&) = delete¶
-
LammpsWrapper(LammpsWrapper&&) = delete¶
-
LammpsWrapper &operator=(const LammpsWrapper&) = delete¶
-
LammpsWrapper &operator=(LammpsWrapper&&) = delete¶
-
void open(int nargs, char **args)¶
Create a new LAMMPS instance.
- Parameters:
nargs – Number of command-line arguments
args – Command-line arguments array
-
void close()¶
Close the LAMMPS instance.
-
void finalize()¶
Finalize MPI (if used) and close LAMMPS.
-
void file(const char *fname)¶
Process commands from a LAMMPS input file.
- Parameters:
fname – Filename as C-style string
-
inline void file(const QString &fname)¶
Process commands from a LAMMPS input file This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
fname – Filename as Qt-style QString
-
inline void file(const std::string &fname)¶
Process commands from a LAMMPS input file This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
fname – Filename as C++-style std::string
-
void command(const char *cmd)¶
Execute a single LAMMPS command.
- Parameters:
cmd – Command string as C-style string
-
inline void command(const QString &cmd)¶
Execute a single LAMMPS command This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
cmd – Command string as Qt-style QString
-
inline void command(const std::string &cmd)¶
Execute a single LAMMPS command This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
cmd – Command string as C++-style std::string
-
void commandsString(const char *cmd)¶
Execute multiple LAMMPS commands from a string.
- Parameters:
cmd – Commands string with newlines as C-style string
-
inline void commandsString(const QString &cmd)¶
Execute multiple LAMMPS commands from a string This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
cmd – Commands string with newlines as Qt-style QString
-
inline void commandsString(const std::string &cmd)¶
Execute multiple LAMMPS commands from a string This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
cmd – Commands string with newlines as C++-style std::string
-
void forceTimeout()¶
Force a timeout condition in LAMMPS.
-
int version()¶
Get LAMMPS version number.
- Returns:
Version number as integer (YYYYMMDD format)
-
int extractSetting(const char *keyword)¶
Extract a global setting from LAMMPS.
- Parameters:
keyword – Setting name to extract
- Returns:
Integer value of the setting
-
void *extractGlobal(const char *keyword)¶
Extract a pointer to global data from LAMMPS.
- Parameters:
keyword – Name of global data to extract
- Returns:
Pointer to the data
-
void *extractPair(const char *keyword)¶
Extract pair style data from LAMMPS.
- Parameters:
keyword – Name of pair data to extract
- Returns:
Pointer to the pair data cast to a void pointer
-
void *extractAtom(const char *keyword)¶
Extract atom data from LAMMPS.
- Parameters:
keyword – Name of atom data to extract
- Returns:
Pointer to the atom data cast to void pointer
-
void *extractCompute(const char *id, int style, int type)¶
Extract data from a compute from LAMMPS.
- Parameters:
id – compute id to extract
style – style of data to extract
type – type of data to extract
- Returns:
data cast to a void pointer.
-
inline void *extractCompute(const QString &id, int style, int type)¶
Extract data from a compute from LAMMPS This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
id – compute id as a QString
style – style of data to extract
type – type of data to extract
-
void *extractFix(const char *id, int style, int type, int nrow, int ncol)¶
Extract data from a fix from LAMMPS.
- Parameters:
id – fix id to extract
style – style of data to extract
type – type of data to extract
nrow – row index (only for global)
ncol – column index (only for global)
- Returns:
data cast to a void pointer. Must be freed for global elements
-
inline void *extractFix(const QString &id, int style, int type, int nrow, int ncol)¶
Extract data from a fix from LAMMPS This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
id – fix id as a QString
style – style of data to extract
type – type of data to extract
nrow – row index (only for global)
ncol – column index (only for global)
-
double extractVariable(const char *keyword)¶
Extract a variable value from LAMMPS.
- Parameters:
keyword – Variable name to extract
- Returns:
Value of the variable as double
-
int extractVariableDatatype(const char *keyword)¶
Extract style of a variable from LAMMPS.
- Parameters:
keyword – Variable name to extract
- Returns:
Value type of variable as integer
-
inline int extractVariableDatatype(const QString &keyword)¶
Extract style of a variable from LAMMPS This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
keyword – variable name as a QString
-
int hasId(const char *idtype, const char *id)¶
Check if a compute/fix/variable ID exists.
- Parameters:
idtype – Type of ID (“compute”, “fix”, “variable”)
id – The ID to check
- Returns:
1 if exists, 0 otherwise
-
int idCount(const char *idtype)¶
Get count of IDs of a specific type.
- Parameters:
idtype – Type of ID (“compute”, “fix”, “variable”, “group”)
- Returns:
Number of IDs of that type
-
QString idName(const char *idtype, int idx)¶
Get the name of an ID by index.
- Parameters:
idtype – Type of ID (“compute”, “fix”, “variable”, “group”, …)
idx – Index of the ID
- Returns:
The ID name, or an empty string on error
-
int styleCount(const char *keyword)¶
Get count of styles of a specific type.
- Parameters:
keyword – Type of style (“compute”, “fix”, “pair”, etc.)
- Returns:
Number of available styles
-
QString styleName(const char *keyword, int idx)¶
Get the name of a style by index.
- Parameters:
keyword – Type of style (“command”, “pair”, “fix”, …)
idx – Index of the style
- Returns:
The style name, or an empty string on error
-
QString variableInfo(int idx)¶
Get the name of a variable by index.
- Parameters:
idx – Variable index
- Returns:
The variable name, or an empty string on error
-
double getThermo(const char *keyword)¶
Get current value of a thermodynamic quantity.
- Parameters:
keyword – Thermo keyword
- Returns:
Value of the thermo quantity
-
void *lastThermo(const char *keyword, int idx)¶
Get a specific value from last thermo output.
- Parameters:
keyword – Thermo keyword
idx – Index for vector quantities
- Returns:
Pointer to the value
-
template<typename T>
inline T lastThermoAs(const char *keyword, int idx)¶ Typed read of a cached last-thermo value.
- Template Parameters:
T – scalar type the thermo value points to (int, int64_t, double)
- Parameters:
keyword – Thermo keyword (“step”, “num”, “type”, “data”, …)
idx – Index for vector quantities
- Returns:
The dereferenced value, or a value-initialized T if the query returns null
-
inline QString lastThermoString(const char *keyword, int idx)¶
Read a string-valued cached last-thermo entry.
- Parameters:
keyword – Thermo keyword that returns text (e.g. “keyword”, “imagename”)
idx – Index for vector quantities
- Returns:
The value as a QString (empty if unavailable)
-
inline bool isOpen() const¶
Check if LAMMPS instance is open.
- Returns:
true if LAMMPS is initialized, false otherwise
-
bool isRunning()¶
Check if LAMMPS is currently executing a run.
- Returns:
true if running, false otherwise
-
bool hasError() const¶
Check if LAMMPS has encountered an error.
- Returns:
true if error occurred, false otherwise
-
int getLastErrorMessage(char *errorbuf, int buflen)¶
Get the last error message from LAMMPS.
- Parameters:
errorbuf – Buffer to store error message
buflen – Length of buffer
- Returns:
Error type code
-
QString lastErrorMessage()¶
Get the last error message from LAMMPS as a string.
Convenience wrapper around getLastErrorMessage() that manages the character buffer internally. Retrieving the message also clears the pending error state in LAMMPS.
- Returns:
The error text, or an empty string if no error is pending
-
bool configAccelerator(const char *package, const char *category, const char *setting) const¶
Check if an accelerator package is available.
- Parameters:
package – Package name
category – Category name
setting – Setting name
- Returns:
true if available, false otherwise
-
bool configHasPackage(const char *pkg) const¶
Check if a package is included in LAMMPS build.
- Parameters:
pkg – Package name
- Returns:
true if included, false otherwise
-
bool configHasCurlSupport() const¶
Check if LAMMPS was built with CURL support.
- Returns:
true if CURL is available, false otherwise
-
bool configHasOmpSupport() const¶
Check if LAMMPS was built with OpenMP support.
- Returns:
true if OpenMP is available, false otherwise
-
bool configHasPngSupport() const¶
Check if LAMMPS was compiled with PNG format image support.
- Returns:
true if PNG image format support is available, false if not
-
bool configHasJpegSupport() const¶
Check if LAMMPS was compiled with JPEG format image support.
- Returns:
true if JPEG image format support is available, false if not
-
bool hasGpuDevice() const¶
Check if GPU device is available for GPU package.
- Returns:
true if GPU device found, false otherwise
-
inline bool loadLib(const QString &fname)¶
Load LAMMPS shared library (plugin mode)
- Parameters:
fname – Library filename (QString version)
- Returns:
true on success, false on failure
-
bool loadLib(const char *lammpslib)¶
Load LAMMPS shared library (plugin mode)
- Parameters:
lammpslib – Library filename (C-string version)
- Returns:
true on success, false on failure
-
bool hasPlugin() const¶
Check if running in plugin mode.
- Returns:
true if plugin mode enabled, false if linked mode
-
enum StyleConst¶
3.3.2. LammpsRunner Class¶
-
class LammpsRunner : public QThread¶
Worker thread for executing LAMMPS simulations.
This class runs LAMMPS simulations in a background thread to maintain UI responsiveness during long calculations. It executes either a LAMMPS command string or a full input file and emits a signal upon completion.
Input is passed using std::string, ensuring clean ownership transfer.
Public Functions
-
explicit LammpsRunner(QObject *parent = nullptr)¶
Constructor.
- Parameters:
parent – Parent QObject
-
~LammpsRunner() override = default¶
Destructor.
-
LammpsRunner() = delete¶
-
LammpsRunner(const LammpsRunner&) = delete¶
-
LammpsRunner(LammpsRunner&&) = delete¶
-
LammpsRunner &operator=(const LammpsRunner&) = delete¶
-
LammpsRunner &operator=(LammpsRunner&&) = delete¶
-
void setupRun(LammpsWrapper *_lammps, std::string _input, std::string _file = {})¶
Prepare the runner thread with LAMMPS instance and commands.
Sets up the runner with the LAMMPS instance and input. Clears any previous LAMMPS state with the “clear” command. Either input or file should be provided, not both.
- Parameters:
_lammps – Pointer to LammpsWrapper instance
_input – String of LAMMPS commands to execute (can be empty)
_file – Input file path to execute (can be empty)
Signals
-
void resultReady()¶
Signal emitted when LAMMPS execution completes.
Protected Functions
-
void run() override¶
Thread execution function - runs LAMMPS commands or input file.
This function executes in the worker thread. It processes either a string of LAMMPS commands or an input file, then signals completion.
-
explicit LammpsRunner(QObject *parent = nullptr)¶
3.4. Visualization Components¶
3.4.1. ChartWindow Class¶
-
class ChartWindow : public QWidget¶
Window for displaying and managing multiple time-series charts.
ChartWindow provides a GUI for displaying and manipulating multiple charts showing time-series data from LAMMPS simulations (thermodynamic output). It supports features like data smoothing, normalization, zoom/pan, and export to various formats (PNG, CSV, YAML, DAT).
Public Functions
-
explicit ChartWindow(const QString &filename, LammpsGui *lammpsgui = nullptr, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
filename – Path to the log file containing the data
lammpsgui – Pointer to LammpsGui for sending signals (optional; nullptr for a standalone window with no live simulation)
parent – Parent widget
-
inline int numCharts() const¶
Get the number of charts currently displayed.
- Returns:
Number of charts
-
inline bool hasTitle(const QString &title, int index) const¶
Check if a chart at given index has the specified title.
- Parameters:
title – Title to check
index – Chart index
- Returns:
true if chart has the title, false otherwise
-
int getStep() const¶
Get the current simulation step number.
- Returns:
Current step
-
void resetCharts()¶
Reset all charts to initial state.
-
void resetZoom()¶
Manually update chart display zoom status.
This is needed at an end of a run when the run finishes too quickly and the regular chart update has not yet triggered.
-
void addChart(const QString &title, int index)¶
Add a new chart to the window.
- Parameters:
title – Chart title (thermodynamic property name)
index – Chart index
-
void addData(int step, double data, int index)¶
Add a data point to a chart.
- Parameters:
step – Simulation step number
data – Data value
index – Chart index
-
void setUnits(const QString &_units)¶
Set the units displayed for thermodynamic quantities.
- Parameters:
_units – Units string (e.g., “real”, “metal”, “lj”)
-
void setNorm(bool norm)¶
Enable/disable data normalization.
- Parameters:
norm – true to normalize data, false otherwise
-
void setRangeEnabled(bool enabled)¶
Enable/Disable range sliders.
- Parameters:
enabled – true to enable sliders and false to disable them
-
void loadData(const PlotData &data, int xcol, const QList<int> &ycols)¶
Populate the window from an external data table (file plotting)
Replaces any existing charts; each selected y column becomes a chart titled by its column name, with the x axis labeled by the x column. Unlike the live thermo feed this loads all rows in one shot.
- Parameters:
data – Parsed column data
xcol – Index of the column to use as the shared x axis
ycols – Indices of the columns to plot, one chart each
Protected Functions
-
void closeEvent(QCloseEvent *event) override¶
Handle window close event.
- Parameters:
event – Close event
-
bool eventFilter(QObject *watched, QEvent *event) override¶
Event filter for keyboard shortcuts.
- Parameters:
watched – Object being watched
event – Event to filter
- Returns:
true if event handled, false otherwise
-
explicit ChartWindow(const QString &filename, LammpsGui *lammpsgui = nullptr, QWidget *parent = nullptr)¶
3.4.2. ChartViewer Class¶
-
class ChartViewer : public QWidget¶
Individual chart viewer for displaying a single time-series.
ChartViewer displays a single thermodynamic property as a function of simulation time. It owns the neutral PlotSeries data objects and renders them with a PlotWidget, supporting both raw and smoothed data display, interactive zoom/pan, and data export.
See also
Public Functions
-
explicit ChartViewer(QWidget *parent = nullptr)¶
Constructor — creates the renderer; no column is bound yet.
- Parameters:
parent – Parent widget
-
~ChartViewer() override¶
Destructor.
-
ChartViewer(const ChartViewer&) = delete¶
-
ChartViewer(ChartViewer&&) = delete¶
-
ChartViewer &operator=(const ChartViewer&) = delete¶
-
ChartViewer &operator=(ChartViewer&&) = delete¶
-
void setColumn(ChartColumn *c)¶
Bind this view to a column (or nullptr) and render it.
Unregisters the previous column’s series from the shared plot and (re)attaches and draws
c, restoring its Y-axis label. The column is owned by ChartWindow, not by the viewer.
-
inline ChartColumn *boundColumn() const¶
The column currently bound to this view (may be nullptr)
-
void addPoint(double x, double y)¶
Append an (x, y) data point to the chart.
The point is appended only if
xis greater than the last appended x; this keeps the live thermo feed monotonic in the step number.- Parameters:
x – X value (e.g. the simulation step, or an arbitrary abscissa)
y – Y value
-
QRectF getMinMax() const¶
Get the min/max bounds of the data.
- Returns:
Rectangle containing data bounds
-
void setXAxisRange(double min, double max)¶
Set the displayed X-axis range (used by the range sliders)
-
void setYAxisRange(double min, double max)¶
Set the displayed Y-axis range (used by the range sliders)
-
void resetZoom()¶
Reset zoom to show all data.
-
void smoothParam(bool _doRaw, bool _doSmooth, int _window, int _order)¶
Set smoothing parameters.
- Parameters:
_doRaw – Show raw data series
_doSmooth – Show smoothed data series
_window – Smoothing window size
_order – Polynomial order for Savitzky-Golay
-
void updateSmooth()¶
Recalculate and update smoothed data.
-
inline int getIndex() const¶
Get chart index.
- Returns:
Index of this chart
-
inline int getCount() const¶
Get number of data points.
- Returns:
Number of points in series
-
QString getName() const¶
Get the series (data column) name.
This is the per-column identifier (e.g. the thermo keyword), distinct from the shared plot title returned by getTLabel(). Used for data-export column headers.
- Returns:
The property/column name this chart was created with
-
inline double getStep(int index) const¶
Get step number at given index.
- Parameters:
index – Data point index
- Returns:
Step number (X value)
-
inline double getData(int index) const¶
Get data value at given index.
- Parameters:
index – Data point index
- Returns:
Data value (Y value)
-
void setTLabel(const QString &tlabel)¶
Set chart title.
- Parameters:
tlabel – New title
-
void setYLabel(const QString &ylabel)¶
Set Y-axis label.
- Parameters:
ylabel – New Y-axis label
-
void setXLabel(const QString &xlabel)¶
Set the X-axis label.
- Parameters:
xlabel – New X-axis label
-
void setXLabelFormat(const QString &fmt)¶
Set the X-axis tick label format.
Call after setXLabel() when the x-axis carries non-integer data (e.g. lattice constants from a Plot Data file). The thermo live-feed path leaves the default integer format in place.
- Parameters:
fmt – printf-style format string (e.g. “%.6g” for floating-point, “%d” for integer steps)
-
void setPoints(const QList<QPointF> &points)¶
Replace all chart data with the given points in one shot.
Bulk loader for file plotting; bypasses the monotonic-x guard and the throttled live-update path used by addPoint().
- Parameters:
points – New (x, y) data points
-
void addOverlaySeries(const QList<QPointF> &pts, const QString &name, const QColor &color)¶
Add an overlay data series from a second file.
Overlay series are always shown in full (no smoothing); they are included in the axis range calculation.
- Parameters:
pts – (x, y) data points
name – Series name (shown as a tooltip / legend entry)
color – Line color
-
void clearOverlaySeries()¶
Remove all overlay series added via addOverlaySeries()
-
inline int overlaySeriesCount() const¶
Number of overlay series currently displayed.
-
void setReferenceLines(const QList<RefLine> &lines)¶
Set vertical reference lines (replaces any existing set)
Each line spans the full data y-range and is updated on every zoom reset. Lines are identified by their position (x), label (series name), and color.
- Parameters:
lines – List of reference line descriptors
-
void clearVerticalLines()¶
Remove all vertical reference lines.
-
void setLegendPos(LegendPos pos)¶
Set the in-plot legend placement (corner, or off)
-
void setRefLabelStyle(double pointSize, double distance, bool boxed)¶
Set the window-wide reference-label style (font size, gap, boxed)
-
void setDisplayStyle(ChartDisplayMode mode, const QColor &color, qreal width, qreal pointSize)¶
Set how the raw data series is displayed.
- Parameters:
mode – Lines, points, or both
color – Series color (invalid color falls back to the theme default)
width – Line width (used for the line and lines+points modes)
pointSize – Marker diameter (used for the points and lines+points modes)
-
inline ChartDisplayMode displayMode() const¶
Current display mode.
-
inline QColor displayColor() const¶
Current series color (may be invalid, meaning the theme default)
-
inline qreal displayWidth() const¶
Current line width.
-
inline qreal displayPointSize() const¶
Current marker diameter.
-
void setSmoothStyle(ChartDisplayMode mode, const QColor &color, qreal width, qreal pointSize)¶
Set how the processed (smoothed) data series is displayed.
- Parameters:
mode – Lines, points, or both
color – Series color (invalid color falls back to the theme default)
width – Line width (used for the line and lines+points modes)
pointSize – Marker diameter (used for the points and lines+points modes)
-
inline ChartDisplayMode smoothMode() const¶
Current processed-series display mode.
-
inline QColor smoothColor() const¶
Current processed-series color (may be invalid, meaning the theme default)
-
inline qreal smoothWidth() const¶
Current processed-series line width.
-
inline qreal smoothPointSize() const¶
Current processed-series marker diameter.
-
void setFitCurve(const QList<QPointF> &points, const QString &name = QString(), bool eosFit = false)¶
Overlay a fit curve on the chart.
- Parameters:
points – Curve points (x, y) drawn as an overlay line; created on the first call and replaced on subsequent calls
name – Optional series name for the overlay (e.g. the fitted expression or a user label); shown wherever series names are surfaced
eosFit – When true the curve is treated as an EOS fit: its visibility follows the doSmooth flag (hidden in Raw mode, visible in Smoothed/Both mode) and it replaces the Savitzky-Golay series while active.
-
inline bool isEosFit() const¶
True when the current fit overlay is a Birch-Murnaghan EOS fit.
-
QString getTLabel() const¶
Get current chart title.
- Returns:
Chart title
-
QString getXLabel() const¶
Get X-axis label.
- Returns:
X-axis label
-
QString getYLabel() const¶
Get Y-axis label.
- Returns:
Y-axis label
-
explicit ChartViewer(QWidget *parent = nullptr)¶
3.4.3. PlotWidget Class¶
Native QWidget + QPainter 2D line/scatter chart renderer
(src/plotwidget.h). It is the sole chart backend; ChartViewer feeds it
neutral PlotSeries / PlotAxis model objects plus the Qt-free
axis-layout helpers from plotaxismath – no Qt Charts, Graphs, or QML.
-
class PlotWidget : public QWidget¶
QPainter-based renderer for the neutral chart model.
Series objects are referenced, not owned: the caller owns each PlotSeries and registers / unregisters it here, then calls update() after changing its data or style.
Public Functions
-
explicit PlotWidget(QWidget *parent = nullptr)¶
Constructor.
- Parameters:
parent – Parent widget
-
void setTitle(const QString &title)¶
Set the chart title (drawn centered at the top)
-
QString title() const¶
Get the chart title.
-
void setXTitle(const QString &title)¶
Set the X-axis title.
-
QString xTitle() const¶
Get the X-axis title.
-
void setYTitle(const QString &title)¶
Set the Y-axis title.
-
QString yTitle() const¶
Get the Y-axis title.
-
void setXRange(double min, double max)¶
Set the displayed X-axis range.
-
void setYRange(double min, double max)¶
Set the displayed Y-axis range.
-
void setXLabelFormat(const QString &fmt)¶
Set the printf-style tick label format of the X-axis.
-
void setYLabelFormat(const QString &fmt)¶
Set the printf-style tick label format of the Y-axis.
-
void setGrid(bool major, bool minor)¶
Toggle major and minor gridline visibility on both axes.
-
void setLegendPos(LegendPos pos)¶
Place a legend in one of the plot corners (or turn it off)
The legend lists each visible, named data series (raw / processed / fit / overlays); reference lines and unnamed marker-only mirrors are excluded.
-
inline LegendPos legendPos() const¶
Current legend placement.
-
void setRefLabelStyle(double pointSize, double distance, bool boxed)¶
Style applied to all reference-line labels.
The per-line label position along the line comes from each reference series’ RefAnchor; this sets the window-wide font/offset/box appearance.
- Parameters:
pointSize – Label font point size (<= 0 keeps the default size)
distance – Perpendicular gap between the label and its line, in px
boxed – Draw a frame + opaque background behind each label
-
void addSeries(const PlotSeries *series)¶
Register a series for drawing (non-owning; ignored if already present)
- Parameters:
series – Series owned by the caller
-
void removeSeries(const PlotSeries *series)¶
Remove a previously registered series (does not delete it)
-
bool hasSeries(const PlotSeries *series) const¶
Whether a series is currently registered.
-
void clearSeries()¶
Unregister all series (does not delete them)
-
QImage renderToImage(const QSize &size) const¶
Render the chart into a freshly allocated image.
- Parameters:
size – Pixel size of the returned image
- Returns:
The rendered image (white background)
-
explicit PlotWidget(QWidget *parent = nullptr)¶
3.4.4. Chart Model and Axis Math¶
Neutral chart model value types (src/plotseries.h) consumed by
PlotWidget, and the Qt-free axis-layout helpers (src/plotaxismath.h:
nice-number ticks, tick values, and printf-style label formatting).
Enums
-
enum class PlotSeriesType¶
Whether a PlotSeries is drawn as a connected line or as markers.
Values:
-
enumerator Line¶
-
enumerator Scatter¶
-
enumerator Line¶
-
struct PlotSeries¶
- #include <plotseries.h>
One data series in the neutral chart model.
Carries the points plus the minimal styling the native renderer needs.
Public Functions
-
inline void append(double x, double y)¶
Append one (x, y) point.
-
inline void replace(const QList<QPointF> &p)¶
Replace all points.
-
inline int count() const¶
Number of points.
-
inline QPointF at(int i) const¶
Point at index i.
-
inline void setVisible(bool v)¶
Set visibility.
-
inline bool isVisible() const¶
Whether the series is visible.
-
inline void clear()¶
Remove all points.
Public Members
-
PlotSeriesType type = PlotSeriesType::Line¶
line vs. scatter rendering
-
QList<QPointF> points¶
data points in axis coordinates
-
QColor color = Qt::black¶
line / marker color
-
qreal width = 1.0¶
line width (Line series)
-
Qt::PenStyle style = Qt::SolidLine¶
line style, e.g. dashed reference lines
-
qreal markerSize = 8.0¶
marker diameter (Scatter series)
-
QString name¶
series label (for a future legend)
-
bool visible = true¶
whether the series is drawn
-
bool isReference = false¶
draw as a labeled reference line
-
QString refLabel¶
text drawn next to a reference line
-
inline void append(double x, double y)¶
-
struct PlotAxis¶
- #include <plotseries.h>
One linear value axis in the neutral chart model.
Public Members
-
double min = 0.0¶
lower end of the displayed range
-
double max = 1.0¶
upper end of the displayed range
-
QString title¶
axis title
-
QString labelFormat = QStringLiteral("%g")¶
printf-style tick label format
-
int subTicks = 4¶
minor subdivisions between major ticks
-
bool gridVisible = true¶
draw major gridlines
-
bool minorGridVisible = true¶
draw minor gridlines
-
double min = 0.0¶
-
namespace PlotAxisMath¶
3.4.5. ImageViewer Class¶
-
class ImageViewer : public QDialog¶
Dialog for viewing and manipulating LAMMPS snapshot images.
This class provides an image viewer dialog for displaying LAMMPS snapshots created by the
dump imagecommand. It allows interactive manipulation of visualization parameters such as zoom, rotation, atom size, coloring, and rendering options. Changes can be applied to regenerate the image using the LAMMPS library interface.dump-image command preparation used by createImage()
Gather widget state and LAMMPS-derived data into a DumpImageParams snapshot
dialog row builders/readers used by the *Settings() slots
Build one compute/fix table row per map entry (shared by fixSettings)
Public Functions
-
explicit ImageViewer(const QString &fileName, LammpsWrapper *lammps, LammpsGui *lammpsgui, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
fileName – Path to the image file to display
lammps – Pointer to LammpsWrapper for regenerating images
lammpsgui – Pointer to LammpsGui for sending signals
parent – Parent widget
-
~ImageViewer() override¶
Destructor.
-
ImageViewer() = delete¶
-
ImageViewer(const ImageViewer&) = delete¶
-
ImageViewer(ImageViewer&&) = delete¶
-
ImageViewer &operator=(const ImageViewer&) = delete¶
-
ImageViewer &operator=(ImageViewer&&) = delete¶
-
void createImage()¶
Generate image using current settings.
Constructs and executes a LAMMPS dump image command with current visualization parameters and updates the displayed image.
Protected Functions
-
bool eventFilter(QObject *watched, QEvent *event) override¶
Intercept Alt-keystrokes.
-
explicit ImageViewer(const QString &fileName, LammpsWrapper *lammps, LammpsGui *lammpsgui, QWidget *parent = nullptr)¶
3.4.6. Dump Image Command Builder¶
The DumpImageParams struct and the buildDumpImageCommand() free
function (src/dumpimage.h) form a GUI-free, unit-testable core that
assembles the LAMMPS write_dump ... image ... command from a snapshot of
the viewer state. ImageViewer populates the struct (resolving all LAMMPS
queries up front) and then calls the pure builder.
-
struct DumpImageParams¶
Pre-resolved inputs for assembling a LAMMPS
dump imagecommand.ImageViewer::createImage()populates this struct from its widget state and from a set of LAMMPS library queries (atom/setting/global data) before the image is rendered. All LAMMPS-derived values are captured here as plain data so that buildDumpImageCommand() can run as a pure function — it never touches the GUI or a live LAMMPS instance and is therefore unit-testable on its own.The
computes/fixes/regionsmaps hold non-owning pointers to ImageInfo and RegionInfo objects owned elsewhere (by ImageViewer at runtime, or by the test fixture in unit tests); they only need to outlive the call.Public Members
-
QString group¶
atom group to render
-
QString dumpfile¶
full path of the temporary
.ppmoutput file
-
bool atomcustom¶
use custom atom color/diameter properties
-
bool useelements¶
element data available (color/diameter by element)
-
bool usediameter¶
per-atom diameter (radius) attribute available
-
bool usesigma¶
Lennard-Jones sigma usable as atom radius.
-
bool showatoms¶
draw atoms
-
QString atomcolor¶
custom atom color property
-
QString atomdiam¶
custom atom diameter property
-
double vdwfactor¶
van der Waals radius scaling factor
-
double atomSize¶
explicit atom size (radius)
-
QString elements¶
pre-built
element <X> <Y> ...argument string
-
QString adiams¶
pre-built
adiam <i> <d> ...argument string
-
bool showbodies¶
draw body particles
-
int body_flag¶
LAMMPS body_flag setting.
-
QString bodycolor¶
body color property
-
double bodydiam¶
body diameter
-
int bodyflag¶
body draw flag (triangle, cylinder, or both)
-
bool showlines¶
draw line particles
-
int line_flag¶
LAMMPS line_flag setting.
-
QString linecolor¶
line color property
-
double linediam¶
line diameter
-
bool showtris¶
draw triangle particles
-
int tri_flag¶
LAMMPS tri_flag setting.
-
QString tricolor¶
triangle color property
-
int triflag¶
triangle draw flag (triangle, cylinder, or both)
-
double tridiam¶
triangle diameter
-
bool showellipsoids¶
draw ellipsoid particles
-
int ellipsoid_flag¶
LAMMPS ellipsoid_flag setting.
-
QString ellipsoidcolor¶
ellipsoid color property
-
int ellipsoidflag¶
ellipsoid draw flag (triangle or cylinder)
-
int ellipsoidlevel¶
ellipsoid refinement level
-
double ellipsoiddiam¶
ellipsoid diameter
-
int nbondtypes¶
number of bond types
-
int bond_flag¶
LAMMPS bond_flag setting.
-
bool showbonds¶
draw bonds
-
QString bondcolor¶
bond color property (or “c_<id>” when bondbyvalue)
-
bool bondbyvalue¶
color bonds by a per-bond compute value (emit bmap)
-
QString bonddiam¶
bond diameter property
-
bool autobond¶
derive bonds from a distance cutoff
-
bool haspairstyle¶
a pair style other than “none” is defined
-
double bondcutoff¶
autobond distance cutoff
-
int xsize¶
rendered image width in pixels
-
int ysize¶
rendered image height in pixels
-
double zoom¶
zoom level
-
double shinyfactor¶
shininess / specular factor
-
bool antialias¶
enable full-scene antialiasing
-
int dimension¶
system dimension (2 or 3)
-
int hrot¶
horizontal rotation angle
-
int vrot¶
vertical rotation angle
-
bool usessao¶
enable screen-space ambient occlusion
-
double ssaoval¶
SSAO strength.
-
bool showbox¶
draw simulation box
-
double boxdiam¶
box edge diameter
-
bool showsubbox¶
draw subdomain boxes
-
double subboxdiam¶
subbox edge diameter
-
bool showaxes¶
draw coordinate axes
-
QString axesloc¶
axes location
-
double axeslen¶
axes length
-
double axesdiam¶
axes diameter
-
double xcenter¶
view center x coordinate
-
double ycenter¶
view center y coordinate
-
double zcenter¶
view center z coordinate
-
int ntypes¶
number of atom types
-
QList<QPair<QString, QColor>> color_list¶
per-type atom color table
-
QString boxcolor¶
box / subbox color
-
QString backcolor¶
lower background color
-
QString backcolor2¶
upper background color
-
bool usegradient¶
draw a vertical gradient
-
double axestrans¶
axes transparency
-
double boxtrans¶
box / subbox transparency
-
double atomtrans¶
atom transparency
-
double bondtrans¶
bond transparency
-
double ambientlight¶
ambient light setting
-
double keylight¶
key light setting
-
double filllight¶
fill light setting
-
double backlight¶
back light setting
-
int version¶
LAMMPS version (date) id.
-
QString colormap¶
name of the selected atom color map
-
QString mapmin¶
minimum-value choice for the atom color map
-
QString mapmax¶
maximum-value choice for the atom color map
-
bool revcolormap¶
reverse (mirror) the atom color map
-
QString bondcolormap¶
name of the selected bond color map
-
QString bondmapmin¶
minimum-value choice for the bond color map
-
QString bondmapmax¶
maximum-value choice for the bond color map
-
bool revbondcolormap¶
reverse (mirror) the bond color map
-
std::map<std::string, RegionInfo*> regions¶
per-region display settings
-
QString group¶
-
DumpImageCommand buildDumpImageCommand(const DumpImageParams &p)¶
Assemble the render and dump_modify argument strings for a dump image.
Pure function: depends only on
p, performs no I/O and no LAMMPS calls, and is therefore exercised directly by the unit tests.- Parameters:
p – Fully populated parameter struct (no GUI or LAMMPS access required)
- Returns:
The two argument strings (see DumpImageCommand)
3.4.7. Color Maps¶
The dump-image color maps are defined once, as a table of ColorMapDef
entries in src/colormaps.cpp. Both the command builder
(appendColorMapArgs() in src/dumpimage.cpp) and the settings-dialog
preview swatches (addColorMapItems() in src/imageviewersettings.cpp)
consume this single source of truth, so they cannot drift apart. See
Adding or modifying a color map for how to add or modify a map.
Functions
-
const ColorMapDef &colorMapDef(const QString &name)¶
Look up a color-map definition by name.
- Parameters:
name – color-map name (e.g. “Viridis”); unknown names fall back to “BWR”
- Returns:
reference to the (statically stored) definition
-
const QStringList &colorMapNames()¶
The selectable color-map names, in display order.
- Returns:
reference to the (statically stored) ordered name list
-
struct ColorMapStop¶
- #include <colormaps.h>
A single color stop of a dump-image color map.
A stop is either a LAMMPS named color (name non-empty, used verbatim in the generated command and resolved with QColor for the preview) or an explicit RGB color (name empty, r / g / b used). Storing the RGB as floats keeps the generated command identical to the values LAMMPS renders and lets the preview use the very same numbers via QColor::fromRgbF(). pos is the stop position in [0,1] and is only meaningful for continuous maps (the first stop maps to the
minvalue, the last tomax).
-
struct ColorMapDef¶
- #include <colormaps.h>
Definition of a named dump-image color map.
This is the single source of truth shared by the command builder (
appendColorMapArgs()in dumpimage.cpp, which emitsdump_modify amap/bmap) and the settings-dialog preview swatches (addColorMapItems()in imageviewersettings.cpp), so the swatch a user picks matches what LAMMPS renders.Public Members
-
bool continuous¶
true: interpolated (
cf); false: discrete sequence (sa)
-
QList<ColorMapStop> stops¶
ordered color stops
-
bool continuous¶
3.4.8. SlideShow Class¶
-
class SlideShow : public QDialog¶
Slideshow viewer for displaying sequences of images.
SlideShow provides a dialog for viewing and navigating through sequences of images, typically from LAMMPS dump image commands. It supports manual navigation (first/prev/next/last), automatic playback with configurable timing, looping, and zoom controls. Images can be exported as a movie file.
Public Functions
-
explicit SlideShow(const QString &fileName, LammpsGui *lammpsgui = nullptr, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
fileName – Path to first image file
lammpsgui – Pointer to LammpsGui for sending signals (optional; nullptr for a standalone viewer with no live simulation)
parent – Parent widget
-
~SlideShow() override = default¶
Destructor.
-
SlideShow() = delete¶
-
void addImage(const QString &filename)¶
Add an image to the slideshow sequence.
- Parameters:
filename – Path to image file to add
-
void clear()¶
Clear all images from slideshow.
-
explicit SlideShow(const QString &fileName, LammpsGui *lammpsgui = nullptr, QWidget *parent = nullptr)¶
3.5. Dialog Components¶
3.5.1. FindAndReplace Class¶
-
class FindAndReplace : public QDialog¶
Find and Replace dialog for the code editor.
FindAndReplace provides a dialog for searching and replacing text in the CodeEditor. It supports case-sensitive/insensitive search, whole word matching, text wrapping, and batch replace operations. The dialog is non-modal so users can continue editing while searching.
Public Functions
-
explicit FindAndReplace(CodeEditor *_editor, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
_editor – Pointer to the CodeEditor to search in
parent – Parent widget
-
~FindAndReplace() override = default¶
Destructor.
-
FindAndReplace() = delete¶
-
FindAndReplace(const FindAndReplace&) = delete¶
-
FindAndReplace(FindAndReplace&&) = delete¶
-
FindAndReplace &operator=(const FindAndReplace&) = delete¶
-
FindAndReplace &operator=(FindAndReplace&&) = delete¶
-
explicit FindAndReplace(CodeEditor *_editor, QWidget *parent = nullptr)¶
3.5.2. SetVariables Class¶
-
class SetVariables : public QDialog¶
Dialog for editing LAMMPS index-style variable definitions.
SetVariables provides a dialog for managing name-value pairs that will be used as index-style variables in LAMMPS input scripts. Users can add, delete, and edit variable definitions. The dialog supports variable substitution using ${varname} syntax.
Public Functions
-
explicit SetVariables(QList<QPair<QString, QString>> &vars, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
vars – Reference to list of variable name-value pairs (modified in place)
parent – Parent widget
-
~SetVariables() override = default¶
Destructor.
-
SetVariables() = delete¶
-
SetVariables(const SetVariables&) = delete¶
-
SetVariables(SetVariables&&) = delete¶
-
SetVariables &operator=(const SetVariables&) = delete¶
-
SetVariables &operator=(SetVariables&&) = delete¶
-
explicit SetVariables(QList<QPair<QString, QString>> &vars, QWidget *parent = nullptr)¶
3.5.3. PlotDataDialog Class¶
-
class PlotDataDialog : public QDialog¶
Dialog to choose which columns of a PlotData to plot.
Presents the parsed columns of an external data file and lets the user select which columns to plot on the y-axis via checkboxes. The first unselected (unchecked) column is automatically used as the shared x-axis. A small preview of the first rows is shown to help identify column content.
A “Compute column” section at the bottom lets the user add derived columns from expressions that reference the existing column names as variables (e.g.
nfcc/ntotorload_eV_per_Ang*1.602176634). The column’s first-row value is also available undercolname_first.Public Functions
-
explicit PlotDataDialog(const PlotData &data, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
data – Parsed column data to choose from (stored as a working copy)
parent – Parent widget
-
~PlotDataDialog() override = default¶
-
PlotDataDialog() = delete¶
-
PlotDataDialog(const PlotDataDialog&) = delete¶
-
PlotDataDialog(PlotDataDialog&&) = delete¶
-
PlotDataDialog &operator=(const PlotDataDialog&) = delete¶
-
PlotDataDialog &operator=(PlotDataDialog&&) = delete¶
-
int xColumn() const¶
Index of the column used as the x-axis.
Returns the index of the first unchecked (unselected) column. Falls back to 0 if all columns are checked. Indices refer to buildData() columns.
- Returns:
Column index
-
QList<int> yColumns() const¶
Indices of the columns selected to plot on the y-axis.
Indices refer to buildData() columns.
- Returns:
List of column indices (all checked columns)
-
QStringList columnNames() const¶
User-edited column names (may differ from the original parsed names)
Each entry corresponds to a column by index in buildData().
- Returns:
List of column name strings, one per column
-
PlotData buildData() const¶
Return the working data with renames and derived columns applied.
Includes any columns added via the “Compute column” section and applies the user’s name edits. Use this in place of calling renameColumns() on the original data.
- Returns:
Updated PlotData ready for plotting
-
explicit PlotDataDialog(const PlotData &data, QWidget *parent = nullptr)¶
3.5.4. Preferences Class¶
-
class Preferences : public QDialog¶
Preferences/Settings dialog for LAMMPS-GUI.
This dialog provides a tabbed interface for configuring various aspects of LAMMPS-GUI including:
General settings (LAMMPS library path, plugins, etc.)
Accelerator package settings
Image viewer defaults
Editor appearance and behavior
Chart viewer settings
Settings are persisted using QSettings and loaded on startup.
Public Functions
-
explicit Preferences(LammpsWrapper *lammps, LammpsGui *lammpsgui, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
lammps – Pointer to LammpsWrapper for querying LAMMPS configuration
lammpsgui – Pointer to LammpsGui for sending signals
parent – Parent widget
-
~Preferences() override¶
Destructor - saves settings on close.
-
Preferences() = delete¶
-
Preferences(const Preferences&) = delete¶
-
Preferences(Preferences&&) = delete¶
-
Preferences &operator=(const Preferences&) = delete¶
-
Preferences &operator=(Preferences&&) = delete¶
-
inline void setRelaunch(bool val)¶
Set flag indicating application needs restart.
Some settings require restarting the application to take effect.
- Parameters:
val – true if restart needed, false otherwise
3.5.5. GeneralTab Class¶
-
class GeneralTab : public QWidget¶
Preferences Tab for General LAMMPS-GUI Settings.
Public Functions
-
explicit GeneralTab(QSettings *settings, LammpsWrapper *lammps, LammpsGui *lammpsgui, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
settings – Pointer to QSettings for storing preferences
lammps – Pointer to LammpsWrapper for querying LAMMPS configuration
lammpsgui – Pointer to LammpsGui for sending signals
parent – Parent widget
-
explicit GeneralTab(QSettings *settings, LammpsWrapper *lammps, LammpsGui *lammpsgui, QWidget *parent = nullptr)¶
3.5.6. AcceleratorTab Class¶
-
class AcceleratorTab : public QWidget¶
Preferences Tab for LAMMPS Accelerator settings.
Public Types
Public Functions
-
explicit AcceleratorTab(QSettings *settings, LammpsWrapper *lammps, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
settings – Pointer to QSettings for storing preferences
lammps – Pointer to LammpsWrapper for querying available accelerator packages
parent – Parent widget
-
explicit AcceleratorTab(QSettings *settings, LammpsWrapper *lammps, QWidget *parent = nullptr)¶
3.5.7. SnapshotTab Class¶
-
class SnapshotTab : public QWidget¶
Preferences Tab for Snapshot Viewer Settings.
Public Functions
-
explicit SnapshotTab(QSettings *settings, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
settings – Pointer to QSettings for storing preferences
parent – Parent widget
-
explicit SnapshotTab(QSettings *settings, QWidget *parent = nullptr)¶
3.5.8. EditorTab Class¶
-
class EditorTab : public QWidget¶
Preferences Tab for LAMMPS-GUI Editor Settings.
Public Functions
-
explicit EditorTab(QSettings *settings, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
settings – Pointer to QSettings for storing preferences
parent – Parent widget
-
explicit EditorTab(QSettings *settings, QWidget *parent = nullptr)¶
3.5.9. ChartsTab Class¶
-
class ChartsTab : public QWidget¶
Preferences Tab for LAMMPS-GUI Charts Viewer Settings.
Public Functions
-
explicit ChartsTab(QSettings *settings, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
settings – Pointer to QSettings for storing preferences
parent – Parent widget
-
explicit ChartsTab(QSettings *settings, QWidget *parent = nullptr)¶
3.5.10. AboutDialog Class¶
-
class AboutDialog : public QDialog¶
Custom About dialog for LAMMPS-GUI.
AboutDialog displays version information, LAMMPS configuration details, and available styles in scrollable text areas. The dialog automatically scrolls down when the content exceeds the visible area, pauses at the bottom, and then returns back to the top. When style information is available, the dialog allocates 2/3 of the combined scroll area space to the configuration information text and 1/3 to the style information text.
The style information text uses the configured fixed-width font from the QSettings keys “monofamily” and “monosize” while the rest uses the application’s default (variable width) font.
Public Functions
-
AboutDialog(const QString &version, const QString &info, const QString &details, int minwidth, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
version – Version information text displayed at the top
info – LAMMPS configuration info displayed in a scroll area
details – Style information displayed in a scroll area with fixed-width font
minwidth – minimum width of dialog
parent – Parent widget
-
~AboutDialog() override = default¶
-
AboutDialog() = delete¶
-
AboutDialog(const AboutDialog&) = delete¶
-
AboutDialog(AboutDialog&&) = delete¶
-
AboutDialog &operator=(const AboutDialog&) = delete¶
-
AboutDialog &operator=(AboutDialog&&) = delete¶
Protected Functions
-
void showEvent(QShowEvent *event) override¶
Event handler for widget show events; implements the auto-scroll functionality.
- Parameters:
event – The show event
-
AboutDialog(const QString &version, const QString &info, const QString &details, int minwidth, QWidget *parent = nullptr)¶
3.6. Utility Components¶
3.6.1. URLDownloader Class¶
-
class URLDownloader¶
Utility class for downloading files over HTTPS.
URLDownloader provides a synchronous interface for downloading files from HTTPS URLs. It respects the “https_proxy” preference setting (or the https_proxy environment variable) when configured.
See also
Preferences for the proxy setting
Public Functions
-
explicit URLDownloader(QWidget *parent = nullptr)¶
Construct a new URLDownloader.
- Parameters:
parent – Optional parent widget for progress dialogs
-
~URLDownloader()¶
Destructor.
-
URLDownloader(const URLDownloader&) = delete¶
-
URLDownloader(URLDownloader&&) = delete¶
-
URLDownloader &operator=(const URLDownloader&) = delete¶
-
URLDownloader &operator=(URLDownloader&&) = delete¶
-
bool download(const QString &url, const QString &file, bool showDialog = false)¶
Download a file from the given HTTPS URL to a local file.
Performs a synchronous (blocking) download of the resource at
url, writing the result to the local filefile. Respects the configured HTTPS proxy setting. Optionally display a dialog with the downloaded URL and the location of the downloaded file.- Parameters:
url – The HTTPS URL to download from
file – The local file path to write to
showDialog – Display a dialog with the downloaded URL and target file location while downloading
- Returns:
true if the download completed successfully, false otherwise
-
bool checkNetwork()¶
Check if a website can be accessed over the network.
Attempts an HTTP HEAD request to www.lammps.org to verify that the network is reachable.
- Returns:
true if the site can be reached, false otherwise
-
inline QString errorString() const¶
Return the last error message.
- Returns:
Human-readable error description or empty string
-
QByteArray fetchRawContent(const QString &url)¶
Fetch raw content from a given HTTPS URL.
Performs a synchronous (blocking) GET request to the given URL and returns the response body as a QByteArray.
- Parameters:
url – The HTTPS URL to fetch from
- Returns:
Response body or empty QByteArray on error
-
QString getRemoteChecksum(const QString &url)¶
Return the remote SHA-256 checksum for a given URL.
Fetches the SHA256SUMS file from the same remote directory as the resource at
url, and returns the expected hex-hash for the resource’s filename.- Parameters:
url – The HTTPS URL of the resource
- Returns:
Hex-hash string or empty string if not found or on error
Public Static Functions
-
static QString getLocalChecksum(const QString &file)¶
Compute the local SHA-256 checksum for a given file.
- Parameters:
file – The local file path
- Returns:
Hex-hash string or empty string on error
-
explicit URLDownloader(QWidget *parent = nullptr)¶
3.6.2. FileViewer Class¶
-
class FileViewer : public QPlainTextEdit¶
Read-only text viewer for displaying file contents.
FileViewer provides a simple read-only text window for viewing file contents. It’s used in the context menu of the code editor to view files referenced in LAMMPS input scripts (data files, potential files, etc.). The viewer supports keyboard shortcuts for closing and stopping the simulation.
Public Functions
-
explicit FileViewer(const QString &filename, LammpsGui *lammpsgui, const QString &title = "", QWidget *parent = nullptr)¶
Constructor.
- Parameters:
filename – Path to file to display
lammpsgui – Pointer to LammpsGui for sending signals
title – Window title (defaults to filename if empty)
parent – Parent widget
-
~FileViewer() override = default¶
Destructor.
-
FileViewer() = delete¶
-
FileViewer(const FileViewer&) = delete¶
-
FileViewer(FileViewer&&) = delete¶
-
FileViewer &operator=(const FileViewer&) = delete¶
-
FileViewer &operator=(FileViewer&&) = delete¶
Protected Functions
-
bool eventFilter(QObject *watched, QEvent *event) override¶
Event filter for keyboard shortcuts.
- Parameters:
watched – Object being watched
event – Event to filter
- Returns:
true if event handled, false otherwise
-
explicit FileViewer(const QString &filename, LammpsGui *lammpsgui, const QString &title = "", QWidget *parent = nullptr)¶
3.6.3. LogWindow Class¶
-
class LogWindow : public QPlainTextEdit¶
Text viewer for LAMMPS log output with warning/error detection.
LogWindow specializes QPlainTextEdit for LAMMPS log viewing. It highlights warnings and errors, detects embedded YAML data for extraction, provides navigation between warnings, and makes error URLs clickable.
Public Functions
-
LogWindow(const QString &filename, LammpsGui *lammpsgui, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
filename – Path to log file to display
lammpsgui – Pointer to LammpsGui for sending signals
parent – Parent widget
-
~LogWindow() override¶
Destructor.
-
LogWindow() = delete¶
Protected Functions
-
void closeEvent(QCloseEvent *event) override¶
Handle window close event.
- Parameters:
event – Close event
-
void mouseDoubleClickEvent(QMouseEvent *event) override¶
Handle double-click to open URLs.
- Parameters:
event – Mouse event
-
void contextMenuEvent(QContextMenuEvent *event) override¶
Show context menu with log-specific actions.
- Parameters:
event – Context menu event
-
bool eventFilter(QObject *watched, QEvent *event) override¶
Event filter for keyboard shortcuts.
- Parameters:
watched – Object being watched
event – Event to filter
- Returns:
true if event handled, false otherwise
-
bool checkYaml()¶
Check if log contains embedded YAML data.
- Returns:
true if YAML data detected, false otherwise
-
LogWindow(const QString &filename, LammpsGui *lammpsgui, QWidget *parent = nullptr)¶
3.6.4. FlagWarnings Class¶
-
class FlagWarnings : public QSyntaxHighlighter¶
Syntax highlighter for LAMMPS warning and error messages.
FlagWarnings extends QSyntaxHighlighter to detect and highlight warning and error messages in LAMMPS log output. It also detects and highlights URLs, enabling easy navigation and documentation access. The class maintains a count of warnings and updates a summary label.
Public Functions
-
explicit FlagWarnings(QLabel *label = nullptr, QTextDocument *parent = nullptr)¶
Constructor.
- Parameters:
label – Optional label to display warning count summary
parent – Text document to apply highlighting to
-
~FlagWarnings() override = default¶
Destructor.
-
FlagWarnings() = delete¶
-
FlagWarnings(const FlagWarnings&) = delete¶
-
FlagWarnings(FlagWarnings&&) = delete¶
-
FlagWarnings &operator=(const FlagWarnings&) = delete¶
-
FlagWarnings &operator=(FlagWarnings&&) = delete¶
-
inline int getNWarnings() const¶
Get the current number of warnings detected.
- Returns:
Number of warnings found in the document
Protected Functions
-
void highlightBlock(const QString &text) override¶
Highlight a single block (line) of text.
Searches for warning/error patterns and URLs, applies formatting, and updates warning count.
- Parameters:
text – Text to highlight
-
explicit FlagWarnings(QLabel *label = nullptr, QTextDocument *parent = nullptr)¶
3.6.5. ImageInfo Class¶
-
class ImageInfo¶
Store settings for displaying graphics from a fix or compute in a LAMMPS snapshot image.
Public Functions
-
ImageInfo() = delete¶
-
inline ImageInfo(bool _enabled, const QString &_style, int _colorstyle, const QString &_color, double _opacity, double _flag1, double _flag2)¶
Custom constructor
Public Members
-
bool enabled¶
display graphics if true
-
QString style¶
name of style
-
int colorstyle¶
color style for graphics: TYPE, ELEMENT, CONSTANT
-
QString color¶
custom color of graphics objects for style == CONSTANT
-
double opacity¶
opacity of graphics objects for style == CONSTANT
-
double flag1¶
Flag #1 for graphics.
-
double flag2¶
Flag #2 for graphics.
-
ImageInfo() = delete¶
3.6.6. RegionInfo Class¶
-
class RegionInfo¶
Store settings for displaying a region in a LAMMPS snapshot image.
Public Functions
-
RegionInfo() = delete¶
-
inline RegionInfo(bool _enabled, int _style, const QString &_color, double _diameter, double _opacity, int _npoints)¶
Custom constructor
Public Members
-
bool enabled¶
display region if true
-
int style¶
style of region object: FRAME, FILLED, TRANSPARENT, or POINTS
-
QString color¶
color of region display
-
double diameter¶
diameter value for POINTS and FRAME
-
double opacity¶
opacity for TRANSPARENT
-
int npoints¶
number of points to be used for POINTS style region display
-
RegionInfo() = delete¶
3.6.7. StdCapture Class¶
-
class StdCapture¶
Capture stdout output to a string buffer.
This class provides functionality to redirect and capture standard output (stdout) into a string buffer. Used to capture output from LAMMPS library calls for display in the GUI.
Public Functions
-
StdCapture()¶
Constructor - initializes capture buffers.
-
StdCapture(const StdCapture&) = delete¶
-
StdCapture(StdCapture&&) = delete¶
-
StdCapture &operator=(const StdCapture&) = delete¶
-
StdCapture &operator=(StdCapture&&) = delete¶
-
virtual ~StdCapture()¶
Destructor - restores stdout and frees buffers.
-
void beginCapture()¶
Start capturing stdout.
Redirects stdout to an internal pipe for capture
-
bool endCapture()¶
Stop capturing stdout and restore original stdout.
- Returns:
true if capture was active, false otherwise
-
std::string getCapture()¶
Get all captured output and clear the buffer.
- Returns:
String containing all captured output
-
std::string getChunk()¶
Get a chunk of captured output without clearing.
- Returns:
String containing new output since last getChunk call
-
double getBufferUse() const¶
Get the buffer usage as a fraction of max buffer size.
- Returns:
Value between 0.0 and 1.0 indicating buffer fullness
-
StdCapture()¶
3.6.8. Qt Helper Widgets¶
-
class QHline : public QFrame¶
Horizontal line widget for visual separation.
Provides a simple horizontal line widget for grouping UI elements in forms or dialogs.
Public Functions
-
QHline(QWidget *parent = nullptr)¶
Constructor.
- Parameters:
parent – Parent widget
-
QHline(QWidget *parent = nullptr)¶
-
class QColorCompleter : public QCompleter¶
Auto-completer for color name inputs.
Provides auto-completion for color names in text fields, suggesting valid color names for use with the LAMMPS dump image command.
Public Functions
-
QColorCompleter(QWidget *parent = nullptr)¶
Constructor.
- Parameters:
parent – Parent widget
-
QColorCompleter(QWidget *parent = nullptr)¶
-
class QColorValidator : public QValidator¶
Validator for color name inputs.
Ensures color inputs are valid color names or hex codes. Provides fix-up functionality for common typos.
Public Functions
-
QColorValidator(QWidget *parent = nullptr)¶
Constructor.
- Parameters:
parent – Parent widget
-
void fixup(QString &input) const override¶
Attempt to fix invalid color input.
- Parameters:
input – String to fix (modified in place)
-
QValidator::State validate(QString &input, int &pos) const override¶
Validate color input string.
- Parameters:
input – String to validate
pos – Cursor position (unused)
- Returns:
Validation state (Invalid, Intermediate, Acceptable)
-
QColorValidator(QWidget *parent = nullptr)¶
-
class RangeSlider : public QSlider¶
Custom Qt Widget implementing a variant of QSlider that has two instead of one handle.
Public Functions
-
RangeSlider(Qt::Orientation ot = Qt::Horizontal, QWidget *parent = nullptr)¶
Constructor.
Copyright Hoyoung Lee (2024-07-14).
This software is a computer program whose purpose is to provide “Qt widget of range slider with two handles”.
This software is governed by the CeCILL-A license under French law and abiding by the rules of distribution of free software. You can use, modify and/or redistribute the software under the terms of the CeCILL-A license as circulated by CEA, CNRS and INRIA at the following URL: “http://www.cecill.info”.
As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software’s author, the holder of the economic rights, and the successive licensors have only limited liability.
In this respect, the user’s attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software’s suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security.
The fact that you are presently reading this means that you have had knowledge of the CeCILL-A license and that you accept its terms.
- Parameters:
ot – Slider orientation (default: Horizontal)
parent – Parent widget
-
inline int low() const¶
Return the rangeslider’s current low handle value.
-
inline void setLow(int low_limit)¶
Set the rangeslider’s current low handle value.
-
inline int high() const¶
Return the rangeslider’s current high handle value.
-
inline void setHigh(int high_limit)¶
Set the rangeslider’s current high handle value.
Signals
-
void sliderMoved(int, int)¶
This signal is emitted when sliderDown is true and one of the two sliders moves.
Protected Functions
-
void paintEvent(QPaintEvent *ev) override¶
handle paint event
-
void mousePressEvent(QMouseEvent *ev) override¶
handle mouse press event
-
void mouseMoveEvent(QMouseEvent *ev) override¶
handle mouse move event
-
inline int pick(QPoint const &pt) const¶
Extract the relevant coordinate from a point based on slider orientation.
-
int pixelPosToRangeValue(int pos)¶
Convert a pixel position along the slider to a range value.
Protected Attributes
-
int lowLimit¶
position of rangeslider’s lower handle
-
int highLimit¶
position of rangeslider’s upper handle
-
QStyle::SubControl pressed_control¶
currently pressed sub-control (handle)
-
int tick_interval¶
interval between tick marks
-
QSlider::TickPosition tick_position¶
position of tick marks relative to slider
-
QStyle::SubControl hover_control¶
sub-control currently under the mouse cursor
-
int click_offset¶
offset from handle center to click position
-
int active_slider¶
index of the currently active slider handle
-
RangeSlider(Qt::Orientation ot = Qt::Horizontal, QWidget *parent = nullptr)¶
-
class RangeBandSlider : public QSlider¶
Horizontal QSlider that colors an active sub-range of its track.
RangeBandSlider behaves like an ordinary horizontal QSlider for selecting the current value (e.g. an image index), but paints its track in two colors: values inside the active [low, high] range use the “active” color, while values outside it (the skipped images) use the “skipped” color. The handle is still drawn by the platform style, so it keeps its native appearance. The active range is expressed in the same units as the slider value and is updated with setActiveRange().
Public Functions
-
inline explicit RangeBandSlider(QWidget *parent = nullptr)¶
Constructor.
- Parameters:
parent – Parent widget (optional)
-
~RangeBandSlider() override = default¶
Destructor.
-
RangeBandSlider(const RangeBandSlider&) = delete¶
-
RangeBandSlider(RangeBandSlider&&) = delete¶
-
RangeBandSlider &operator=(const RangeBandSlider&) = delete¶
-
RangeBandSlider &operator=(RangeBandSlider&&) = delete¶
-
void setActiveRange(int low, int high)¶
Set the active value range to highlight.
- Parameters:
low – First in-range value (inclusive, in slider value units)
high – Last in-range value (inclusive, in slider value units)
Protected Functions
-
void paintEvent(QPaintEvent *event) override¶
Paint a two-color track plus the native handle.
- Parameters:
event – The paint event (unused)
-
inline explicit RangeBandSlider(QWidget *parent = nullptr)¶
-
class VerticalLabel : public QWidget¶
Widget displaying text rotated 90 degrees counter-clockwise.
Renders text vertically, optimized for y-axis titles in charts where horizontal space is limited.
Public Functions
-
explicit VerticalLabel(const QString &text, QWidget *parent = nullptr)¶
Constructor.
- Parameters:
text – Text to display
parent – Parent widget
-
void setText(const QString &text)¶
Update the displayed text.
- Parameters:
text – New text to display
-
QString text() const¶
Get the displayed text.
- Returns:
Current text
Protected Functions
-
void paintEvent(QPaintEvent *event) override¶
event handler for requests to draw all or parts of the custom widget
-
QSize sizeHint() const override¶
return the recommended size for the widget
-
QSize minimumSizeHint() const override¶
return the recommended minimum size for the widget
-
explicit VerticalLabel(const QString &text, QWidget *parent = nullptr)¶
3.6.9. StdoutSilencer Class¶
-
class StdoutSilencer¶
RAII guard that silences stdout for the duration of its scope.
Calls silenceStdout() on construction and restoreStdout() on destruction, so stdout is restored on every exit path from the enclosing scope, including early returns and exceptions. Use in place of manual silenceStdout() / restoreStdout() pairs.
Note
Not thread-safe. Must only be used from the main thread.
Public Functions
-
inline StdoutSilencer()¶
-
inline ~StdoutSilencer()¶
-
StdoutSilencer(const StdoutSilencer&) = delete¶
-
StdoutSilencer(StdoutSilencer&&) = delete¶
-
StdoutSilencer &operator=(const StdoutSilencer&) = delete¶
-
StdoutSilencer &operator=(StdoutSilencer&&) = delete¶
-
inline StdoutSilencer()¶
3.6.10. PlotData and File Parsers¶
Column-oriented numeric data model (src/plotdata.h) and the parsers for
external data files (whitespace/.dat, CSV, LAMMPS YAML, and JSON) used to
plot data from files.
Functions
-
PlotData parsePlotCsv(const QString &text, QString *error = nullptr)¶
Parse comma-separated values into a PlotData.
The first line is treated as a header of column names unless every field parses as a number, in which case generic names are generated and the line is treated as data.
- Parameters:
text – File contents
error – Optional out-parameter set to a message on failure
- Returns:
Parsed table (empty on failure)
-
PlotData parsePlotWhitespace(const QString &text, QString *error = nullptr)¶
Parse whitespace-separated columns (gnuplot / LAMMPS
.dat) into a PlotData.Lines beginning with
#are comments; the last comment line before the data is used for column names if its field count matches the data.- Parameters:
text – File contents
error – Optional out-parameter set to a message on failure
- Returns:
Parsed table (empty on failure)
-
PlotData parsePlotYaml(const QString &text, QString *error = nullptr)¶
Parse the LAMMPS thermo YAML form (
keywords:+data:) into a PlotData.- Parameters:
text – File contents
error – Optional out-parameter set to a message on failure
- Returns:
Parsed table (empty on failure)
-
PlotData parsePlotJson(const QByteArray &bytes, QString *error = nullptr)¶
Parse JSON into a PlotData.
Supports two simple shapes only: an array of equally long numeric rows (
[[...],[...]], generic column names) and an object mapping names to numeric arrays ({"a":[...],"b":[...]}).- Parameters:
bytes – File contents
error – Optional out-parameter set to a message on failure
- Returns:
Parsed table (empty on failure)
-
PlotData loadPlotData(const QString &filename, QString *error = nullptr)¶
Load a file into a PlotData, choosing the parser by file extension.
- Parameters:
filename – Path to the data file (.csv, .yaml/.yml, .json, else whitespace)
error – Optional out-parameter set to a message on failure
- Returns:
Parsed table (empty on failure)
-
QString writePlotCsv(const PlotData &data)¶
Format a PlotData as comma-separated values.
Round-trips through parsePlotCsv().
- Parameters:
data – Table to format
- Returns:
CSV text: a header row of column names, then one row per data point
-
QString writePlotDat(const PlotData &data, const QString &source = QString())¶
Format a PlotData as whitespace-separated columns (gnuplot style)
- Parameters:
data – Table to format
source – Optional description placed in the leading comment line
- Returns:
Text with a
#comment header carrying the column names, then the numeric columns; round-trips through parsePlotWhitespace()
-
class PlotData¶
- #include <plotdata.h>
Column-oriented table of named numeric columns.
Holds a set of equally long columns of doubles, each with a name, plus an optional units string. It is the GUI-free data model shared by the file parsers and the chart window when plotting external data.
Public Functions
-
PlotData() = default¶
-
~PlotData() = default¶
-
inline int columnCount() const¶
Number of columns.
-
inline int rowCount() const¶
Number of rows (length of the columns; 0 if empty)
-
inline bool isEmpty() const¶
True if there are no columns or no rows.
-
inline const QString &columnName(int c) const¶
Name of a column.
- Parameters:
c – Column index
- Returns:
Column name
-
inline const QStringList &columnNames() const¶
All column names.
-
inline const std::vector<double> &column(int c) const¶
Read access to a column’s values.
- Parameters:
c – Column index
- Returns:
Reference to the column data
-
inline const QString &units() const¶
Optional units string (e.g. the LAMMPS unit system); may be empty.
-
inline void setUnits(const QString &u)¶
Set the optional units string.
- Parameters:
u – Units string
-
void setColumnNames(const QStringList &columnNames)¶
Reset the table to a fresh set of (empty) named columns.
- Parameters:
columnNames – Names of the columns to create
-
void renameColumns(const QStringList &newNames)¶
Rename columns in place without clearing data.
- Parameters:
newNames – New names; length must match columnCount() (extra entries are ignored)
-
bool appendRow(const std::vector<double> &row)¶
Append one row of values, one per column.
- Parameters:
row – Values to append (size must equal columnCount())
- Returns:
true on success, false if the size does not match
-
void addColumn(const QString &name, std::vector<double> data)¶
Append a complete named column.
Used by the column-wise parsers (e.g. JSON object-of-arrays).
- Parameters:
name – Column name
data – Column values
-
void clear()¶
Remove all columns and data.
-
PlotData() = default¶
3.6.11. Least-Squares Toolkit¶
Self-contained (Qt-free) dense linear-algebra and least-squares routines
(src/leastsquares.h) used by the chart smoothing and reusable for
polynomial and equation-of-state fits.
Typedefs
-
using float_vect = std::vector<double>¶
Dense vector of doubles used by the least-squares routines
-
using int_vect = std::vector<int>¶
Dense vector of ints used for LU pivot bookkeeping
Functions
-
float_mat transpose(const float_mat &a)¶
Return the transpose of a matrix.
Return the transpose of a matrix.
- Parameters:
a – Input matrix
- Returns:
Transposed matrix
-
float_mat operator*(const float_mat &a, const float_mat &b)¶
Matrix-matrix multiplication.
Matrix-matrix multiplication.
- Parameters:
a – Left operand
b – Right operand (must have as many rows as
ahas columns)
- Returns:
Product matrix
-
float_mat lin_solve(const float_mat &A, const float_mat &a)¶
Solve the linear system A*X = a via in-place LU decomposition.
Setting
ato the identity matrix yields the inverse ofA.Solve the linear system A*X = a via in-place LU decomposition.
- Parameters:
A – Coefficient matrix
a – Right-hand side(s); each column is an independent system
- Returns:
Solution matrix X with the same shape as
a
-
float_mat invert(const float_mat &A)¶
Invert a square matrix using LU decomposition.
Invert a square matrix using LU decomposition.
- Parameters:
A – Square matrix to invert
- Returns:
Inverse of
A
-
float_vect sg_smooth(const float_vect &v, std::size_t width, int deg)¶
Smooth a data vector with a Savitzky-Golay filter.
Fits a polynomial of degree
degto a sliding window of width 2*width+1 by least squares; non-symmetric windows are used near the borders.Smooth a data vector with a Savitzky-Golay filter.
This method means fitting a polynome of degree ‘deg’ to a sliding window of width 2w+1 throughout the data. The needed coefficients are generated dynamically by doing a least squares fit on a “symmetric” unit vector of size 2w+1, e.g. for w=2 b=(0,0,1,0,0). evaluating the polynome yields the sg-coefficients. at the border non symmectric vectors b are used.
- Parameters:
v – Input samples (assumed equally spaced)
width – Half-window size; the filter window spans 2*width+1 points
deg – Polynomial degree fitted in each window (0 = moving average)
- Returns:
Smoothed vector with the same length as
v
-
class float_mat : public std::vector<float_vect>¶
- #include <leastsquares.h>
Simple dense matrix of doubles backed by a vector of rows.
Elements are indexed [row][column] with 0-based indices (C style). Because the storage is row-major, iterating over rows is cheaper than over columns. Used as the working type for the LU solver, matrix inverse, and the Savitzky-Golay coefficient generation.
Public Functions
-
float_mat() = delete¶
-
~float_mat() = default¶
-
float_mat(std::size_t rows, std::size_t cols, double def = 0.0)¶
Construct a rows x cols matrix filled with a default value.
- Parameters:
rows – Number of rows
cols – Number of columns
def – Initial value for every element (default 0.0)
-
float_mat(const float_vect &v)¶
Construct a single-row matrix from a vector.
- Parameters:
v – Row contents
-
inline std::size_t nr_rows() const¶
Number of rows.
-
inline std::size_t nr_cols() const¶
Number of columns (size of the first row)
-
float_mat() = delete¶
3.6.12. Post-Processing Analyses¶
Self-contained (Qt-free) post-processing analyses (src/analysis.h) used
by the chart post-processing dialog.
Functions
-
std::vector<double> autocorrelation(const std::vector<double> &y, int maxlag)¶
Normalized autocorrelation function (ACF) of a data series.
Uses the standard biased estimator \( \mathrm{ACF}(k) = \frac{\sum_{i=0}^{N-1-k}(y_i-\bar y)(y_{i+k}-\bar y)} {\sum_{i=0}^{N-1}(y_i-\bar y)^2} \).
- Parameters:
y – Input samples (assumed equally spaced)
maxlag – Largest lag to compute; values <= 0 or >= y.size() are clamped to y.size()-1
- Returns:
ACF values for lags 0..maxlag (length maxlag+1), normalized so that the lag-0 value is 1; an empty vector if the input has fewer than two samples or zero variance (a constant series)
3.6.13. Curve Fitting¶
Linear-least-squares curve fits (src/fitting.h) – polynomial and
4-parameter Birch-Murnaghan equation of state – built on the leastsquares
toolkit and used by the chart post-processing dialog.
Functions
-
PolynomialFit polynomialFit(const std::vector<double> &x, const std::vector<double> &y, int degree)¶
Least-squares polynomial fit of y(x)
- Parameters:
x – Abscissa values
y – Ordinate values (same length as
x)degree – Polynomial degree (>= 0)
- Returns:
Fit result; ok is false if the sizes mismatch or there are fewer than degree+1 points
-
double evalPolynomial(const std::vector<double> &coeffs, double x)¶
Evaluate a polynomial at a point.
- Parameters:
coeffs – Coefficients c0..cn (y = sum_k c_k x^k)
x – Evaluation point
- Returns:
Polynomial value
-
EosFit birchMurnaghanFit(const std::vector<double> &v, const std::vector<double> &e)¶
4-parameter Birch-Murnaghan EOS fit of energy versus volume
- Parameters:
v – Volumes (must be positive)
e – Energies (same length as
v)
- Returns:
Fit result; ok is false if the sizes mismatch, there are fewer than four points, a volume is non-positive, or no physical minimum exists
-
struct PolynomialFit¶
- #include <fitting.h>
Result of a least-squares polynomial fit.
-
struct EosFit¶
- #include <fitting.h>
Result of a 4-parameter Birch-Murnaghan equation-of-state fit.
The fitted model is the linear-in-coefficients form \( E(V) = a + b\,V^{-2/3} + c\,V^{-4/3} + d\,V^{-2} \), from which the physical quantities are derived.
Public Members
-
double a = 0.0¶
constant coefficient
-
double b = 0.0¶
coefficient of V^(-2/3)
-
double c = 0.0¶
coefficient of V^(-4/3)
-
double d = 0.0¶
coefficient of V^(-2)
-
double v0 = 0.0¶
equilibrium volume
-
double e0 = 0.0¶
equilibrium energy
-
double b0 = 0.0¶
bulk modulus (in energy/volume units)
-
double b0prime = 0.0¶
pressure derivative of the bulk modulus
-
double rms = 0.0¶
root-mean-square residual
-
bool ok = false¶
true if the fit succeeded and a minimum was found
-
double a = 0.0¶
3.6.14. Nonlinear Least Squares¶
Compact, self-contained (Qt-free) Levenberg-Marquardt solver
(src/levmar.h) for nonlinear least-squares fits. The model is supplied as a
residual/Jacobian callback, so the core is independent of how the model is
expressed; it is driven by the custom-fit code with LeptonMini expressions and
their symbolic derivatives, and solves the damped normal equations with the
leastsquares LU solver.
Typedefs
-
using LevmarModel = std::function<bool(const std::vector<double> ¶ms, std::vector<double> &residuals, std::vector<std::vector<double>> &jacobian)>¶
Callback evaluating residuals and the Jacobian at a parameter vector.
Given the current
params(length n), it must fillresiduals(length m) with model(x_i) - y_i andjacobian(m rows of n columns) with d model(x_i) / d p_j. Returning false signals an evaluation failure (e.g. a domain error) for that parameter vector; the solver treats the trial step as rejected rather than aborting.
Functions
-
LevmarResult levmarFit(int numResiduals, int numParams, const std::vector<double> &initial, const LevmarModel &model, int maxIterations = 200, double tolerance = 1.0e-12)¶
Levenberg-Marquardt nonlinear least-squares minimization.
- Parameters:
numResiduals – Number of data points m (must be >= numParams)
numParams – Number of free parameters n (> 0)
initial – Initial parameter guess (length numParams)
model – Residual/Jacobian callback
maxIterations – Maximum number of outer iterations
tolerance – Relative cost-change convergence threshold
- Returns:
Fit result; ok is false (with a message) on bad dimensions or a failed initial evaluation
-
struct LevmarResult¶
- #include <levmar.h>
Result of a Levenberg-Marquardt nonlinear least-squares fit.
Public Members
-
std::vector<double> params¶
fitted parameter values (empty on failure)
-
double rms = 0.0¶
root-mean-square residual at the solution
-
int iterations = 0¶
number of outer iterations performed
-
bool ok = false¶
true if the fit ran to a usable solution
-
std::string message¶
human-readable status/diagnostic
-
std::vector<double> params¶
3.6.15. Custom-Function Evaluation and Fitting¶
Evaluation and nonlinear fitting of user-supplied mathematical expressions
(src/customfunc.h) via the vendored LeptonMini parser, used for
custom-function plotting and custom curve fits in the chart post-processing
dialog. The fit builds its Jacobian from LeptonMini’s analytic derivatives and
minimizes with the Levenberg-Marquardt solver.
Functions
-
CustomCurve evalCustomCurve(const QString &expression, double xmin, double xmax, int nsamples, const QString &variable = QStringLiteral("x"))¶
Parse and evaluate a single-variable expression over an x range.
Parses
expressionwith the vendored LeptonMini parser, optimizes it, and evaluates it atnsamples+ 1 equally spaced points spanning [xmin,xmax]. Points whose value is not finite (NaN/inf) are omitted.- Parameters:
expression – Math expression in the variable
variable(LeptonMini syntax)xmin – Lower bound of the sampling range
xmax – Upper bound of the sampling range
nsamples – Number of sub-intervals (clamped to >= 1); nsamples+1 points
variable – Name of the independent variable in
expression(default “x”)
- Returns:
Curve result; on a parse/evaluation error CustomCurve::ok is false and CustomCurve::error describes the problem
-
CustomFit fitCustomCurve(const QString &expression, const QList<FitParam> &initialParams, const std::vector<double> &xdata, const std::vector<double> &ydata, double xmin, double xmax, int nsamples, const QString &variable = QStringLiteral("x"))¶
Nonlinear least-squares fit of a custom expression to (x, y) data.
Fits
expression— a function of the independent variablevariableand the named parameters ininitialParams— to the data (xdata,ydata) by Levenberg-Marquardt. The Jacobian is built from analytic derivatives of the expression with respect to each parameter (via LeptonMini’s symbolic differentiation). On success the fitted model is sampled atnsamples+ 1 points over [xmin,xmax] for overlaying on the chart.- Parameters:
expression – Math expression in
variableand the parameter namesinitialParams – Parameters with their initial guesses (at least one)
xdata – Independent-variable data
ydata – Dependent-variable data (same length as
xdata)xmin – Lower bound for sampling the fitted curve
xmax – Upper bound for sampling the fitted curve
nsamples – Number of sub-intervals (clamped to >= 1); nsamples+1 points
variable – Name of the independent variable (default “x”)
- Returns:
Fit result; on a parse/dimension/evaluation error CustomFit::ok is false and CustomFit::error describes the problem
-
class CompiledExpression¶
- #include <customfunc.h>
A parsed and compiled LeptonMini expression with QString error reporting.
Confines the LeptonMini (std::string) parsing boundary to one translation unit, the way LammpsWrapper confines the LAMMPS C API. Construct from a QString expression, check isValid / error, then call evaluate repeatedly with a name -> value variable map. evaluate propagates the LeptonMini exception thrown for an unbound variable, so callers that may reference variables not present in the map should evaluate inside a try block.
Public Functions
-
explicit CompiledExpression(const QString &expression)¶
Parse, optimize, and compile
expression(a LeptonMini string)
-
~CompiledExpression()¶
-
CompiledExpression() = delete¶
-
CompiledExpression(const CompiledExpression&) = delete¶
-
CompiledExpression(CompiledExpression&&) = delete¶
-
CompiledExpression &operator=(const CompiledExpression&) = delete¶
-
CompiledExpression &operator=(CompiledExpression&&) = delete¶
-
inline bool isValid() const¶
True if the expression parsed and compiled successfully.
-
double evaluate(const std::map<std::string, double> &variables) const¶
Evaluate with the given variable bindings (may throw on unbound vars)
Private Members
-
std::unique_ptr<LeptonMini::ExpressionProgram> program¶
compiled program (null if invalid)
-
bool valid = false¶
parse/compile succeeded
-
QString errorMsg¶
parse error (empty when valid)
-
explicit CompiledExpression(const QString &expression)¶
-
struct CustomCurve¶
- #include <customfunc.h>
Result of sampling a custom expression over an x range.
-
struct FitParam¶
- #include <customfunc.h>
A named nonlinear-fit parameter.
Carries the initial guess on input to fitCustomCurve and the fitted value on output.
-
struct CustomFit¶
- #include <customfunc.h>
Result of a nonlinear least-squares fit of a custom expression.
-
namespace LeptonMini¶
3.6.16. Helper Functions¶
Functions
-
int dateCompare(const QString &one, const QString &two)¶
Compare two date strings in LAMMPS “DD MMM YYYY” format (e.g. “22 Jul 2025”)
- Parameters:
one – First date string
two – Second date string
- Returns:
-1 if one < two, 0 if equal, 1 if one > two
-
std::vector<std::string> splitLine(const std::string &text)¶
Split a string into words while respecting quotes.
- Parameters:
text – The string to split
- Returns:
Vector of words extracted from the string
-
QStringList splitLine(const QString &text)¶
Split a string into words while respecting quotes This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
text – The string to split
- Returns:
List of words extracted from the string
-
void information(QWidget *parent, const QString &title, const QString &text1, const QString &text2 = QString())¶
Provide standardized information dialog.
- Parameters:
parent – Pointer to parent widget
title – Information dialog title
text1 – Information message part 1
text2 – Information message part 2 (optional)
-
void critical(QWidget *parent, const QString &title, const QString &text1, const QString &text2 = QString())¶
Provide standardized critical error dialog.
- Parameters:
parent – Pointer to parent widget
title – Error dialog title
text1 – Error message summary
text2 – Detailed error message (optional)
-
void warning(QWidget *parent, const QString &title, const QString &text1, const QString &text2 = QString())¶
Provide standardized custom warning dialog.
- Parameters:
parent – Pointer to parent widget
title – Warning dialog title
text1 – Warning message summary
text2 – Detailed warning message (optional)
-
QString getLammpsLibName()¶
Provide platform specific name of a LAMMPS shared library.
- Returns:
String with the filename or an empty string if compiled without plugin support
-
QString getLammpsDownloadUrl()¶
Provide platform specific URL for downloading a LAMMPS shared library.
- Returns:
String with the URL or an empty string if compiled without plugin support
-
void exportImage(QWidget *parent, QImage *image, const QString &title)¶
Save image directly or convert with ImageMagick.
- Parameters:
parent – Pointer to parent widget
image – Pointer to image class
title – Warning dialog title if failed
-
bool hasExe(const QString &exe)¶
Check if an executable is in the system PATH.
- Parameters:
exe – The executable name to search for
- Returns:
true if executable is found in PATH, false otherwise
-
bool isImageFile(const QString &filename)¶
Check whether a file is (likely) an image.
Recognizes the formats Qt can decode plus common ImageMagick-only formats (e.g. tga, eps, sgi) so callers can route them through a conversion step.
- Parameters:
filename – Path to the file
- Returns:
true if the extension is a known image type, or the file exists and QImageReader recognizes its contents as an image
-
bool isRestartFile(const QString &filename)¶
Check whether a file is a LAMMPS binary restart file.
- Parameters:
filename – Path to the file
- Returns:
true if the file exists and begins with the LAMMPS restart magic string
-
bool looksLikeBinaryFile(const QString &filename)¶
Heuristic check whether a file is binary rather than text.
Null bytes are essentially absent from text (ASCII, UTF-8, Latin-1) but ubiquitous in binary formats (IEEE floats, packed integers, padding). This is the same heuristic used by git, grep, and the POSIX file utility. Returns false for files that cannot be opened (callers handle that separately).
- Parameters:
filename – Path to the file
- Returns:
true if the first 8 KB of the file contains a null byte
-
void relaunchApplication()¶
Re-exec the current LAMMPS-GUI process in place (e.g. to reload the plugin)
Replaces the running process with a fresh launch of the same executable. On success it does not return; it returns only if the re-exec failed, so callers must handle that case (typically warn and/or exit).
-
void purgeDirectory(const QString &dir)¶
Recursively delete all files in a directory.
- Parameters:
dir – The directory to purge
-
bool isLightTheme()¶
Determine if the current Qt theme is light or dark.
- Returns:
true if light theme, false if dark theme
-
int showUnsavedChangesDialog(QWidget *parent, const QString &filename, const QString &question)¶
Show a standardized “unsaved changes” confirmation dialog.
Provides a consistent confirmation dialog used whenever the user may lose unsaved changes (opening a new file, quitting, running LAMMPS, etc.).
- Parameters:
parent – Pointer to the parent widget
filename – Name of the file with unsaved changes
question – Informative text explaining the context (e.g. “save before opening?”)
- Returns:
QMessageBox::Yes, QMessageBox::No, or QMessageBox::Cancel
-
void silenceStdout()¶
Silence stdout by redirecting it to the null device.
Redirects stdout to /dev/null (Unix) or NUL: (Windows) to suppress all output. Does nothing if StdCapture is currently active or if stdout is already silenced.
Note
Not thread-safe. Must only be called from the main thread.
-
void restoreStdout()¶
Restore stdout after it was silenced.
Restores the original stdout file descriptor that was saved by silenceStdout(). Does nothing if stdout is not currently silenced.
Note
Not thread-safe. Must only be called from the main thread.
-
bool isStdoutSilenced()¶
Check if stdout is currently silenced.
- Returns:
true if silenceStdout() is active, false otherwise
-
void notifyCaptureState(bool active)¶
Notify the silence/restore system about StdCapture state changes.
Called by StdCapture to indicate whether it is actively capturing output. While capture is active, silenceStdout() becomes a no-op to avoid interfering with the capture pipe.
- Parameters:
active – true when StdCapture starts capturing, false when it stops
-
template<typename Recv, typename Func>
QAction *addMenuAction(QMenu *menu, const QString &text, const QString &icon, Recv *receiver, Func slot)¶ Append an action with an optional icon and a triggered() handler to a menu.
Collapses the recurring “addAction() + setIcon() + connect()” idiom used when building context menus and tool menus across the widget classes.
- Parameters:
menu – Menu to append the new action to
text – Action label text
icon – Resource path for the action icon (empty for no icon)
receiver – Object that owns the slot/callable
slot – Member function pointer or callable invoked on trigger
- Returns:
The created action, for any further configuration by the caller (e.g. setData())