Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
correlation::app::FileIOHandler Class Reference

Manages open/save file dialogs and background file loading. More...

#include <FileIOHandler.hpp>

Collaboration diagram for correlation::app::FileIOHandler:

Public Member Functions

 FileIOHandler (::AppWindow &window, TrajectoryLoader &loader, AnalysisDispatcher &dispatcher, ProgramOptions &options, AppController &controller)
 Constructs the FileIOHandler with injected services.
 ~FileIOHandler ()
 Destructor. Ensures background threads are joined.
void handleBrowseFile ()
 Displays file open dialog asynchronously and triggers background loading of selected structure/trajectory file.
void handleReloadFile ()
 Reloads the currently loaded structure/trajectory file from disk asynchronously.
void handleWriteFiles ()
 Displays file save dialog asynchronously and exports active structural data.
void handleExportStructure ()
 Displays file save dialog asynchronously and exports/converts the active structure to POSCAR, CELL, CIF, or CAR format.
void startLoadingTrajectory (const std::string &filepath, std::function< void(bool)> on_complete=nullptr)
 Initiates asynchronous trajectory loading on the background worker thread.
void startLoadingTrajectories (const std::vector< std::string > &filepaths, std::function< void(bool)> on_complete=nullptr)
 Initiates asynchronous trajectory loading for multiple files on the background worker thread.
void updateBoxDiagnostics (const core::Cell *cell)
 Updates simulation cell diagnostics (volume, dimensions, density) on the UI.
void updateBoxDiagnosticsForFrame (size_t frame_index)
 Updates simulation cell diagnostics on the UI for a specific trajectory frame.
void handleRenameElement (const std::string &old_symbol, const std::string &new_symbol)
 Renames an element species across the loaded trajectory and refreshes UI models.

Private Member Functions

void refreshAtomCountsUI ()
 Populates UI AtomCount vector model with species counts, CPK colors, and unknown flags.
void onTrajectoryLoadSuccess (const std::string &filepath)
 Updates UI components and analysis options after successful trajectory loading.
void updateFileMetadata (const std::string &filepath)
 Updates loaded file metadata (basename, frame counts, atom counts) on the UI.
void updateStructure3DView ()
 Updates 3D structure/trajectory view with loaded cell or trajectory.
void executeWriteFiles (const std::string &filepath)
 Executes export of active structural datasets based on the selected file path extension.

Private Attributes

::AppWindow & window_
TrajectoryLoader & loader_
AnalysisDispatcher & dispatcher_
ProgramOptions & options_
AppController & controller_
std::shared_ptr< std::atomic< bool > > alive_
 Lifetime guard for queued UI callbacks.
std::jthread dialog_thread_
 Background worker thread for native file dialogs.
std::jthread load_thread_
 Background thread for loading files without blocking UI.
std::vector< std::string > loaded_filepaths_
 Active single or multi-file trajectory paths.
std::atomic< bool > dialog_active_
 Concurrency guard preventing duplicate dialog launches.

Detailed Description

Manages open/save file dialogs and background file loading.

Constructor & Destructor Documentation

◆ FileIOHandler()

correlation::app::FileIOHandler::FileIOHandler ( ::AppWindow & window,
TrajectoryLoader & loader,
AnalysisDispatcher & dispatcher,
ProgramOptions & options,
AppController & controller )

Constructs the FileIOHandler with injected services.

Parameters
[in,out]windowReference to the UI window.
[in,out]loaderReference to the trajectory loader.
[in,out]dispatcherReference to the analysis dispatcher.
[in,out]optionsReference to program options.
[in,out]controllerReference to the main AppController.

◆ ~FileIOHandler()

correlation::app::FileIOHandler::~FileIOHandler ( )

Destructor. Ensures background threads are joined.

Member Function Documentation

◆ executeWriteFiles()

void correlation::app::FileIOHandler::executeWriteFiles ( const std::string & filepath)
private

Executes export of active structural datasets based on the selected file path extension.

Parameters
[in]filepathAbsolute base path for writing files.

◆ handleBrowseFile()

void correlation::app::FileIOHandler::handleBrowseFile ( )

Displays file open dialog asynchronously and triggers background loading of selected structure/trajectory file.

Here is the call graph for this function:

◆ handleExportStructure()

void correlation::app::FileIOHandler::handleExportStructure ( )

Displays file save dialog asynchronously and exports/converts the active structure to POSCAR, CELL, CIF, or CAR format.

Here is the call graph for this function:

◆ handleReloadFile()

void correlation::app::FileIOHandler::handleReloadFile ( )

Reloads the currently loaded structure/trajectory file from disk asynchronously.

Here is the call graph for this function:

◆ handleRenameElement()

void correlation::app::FileIOHandler::handleRenameElement ( const std::string & old_symbol,
const std::string & new_symbol )

Renames an element species across the loaded trajectory and refreshes UI models.

Parameters
[in]old_symbolExisting element symbol (e.g., "1").
[in]new_symbolReplacement element symbol (e.g., "Cu").
Here is the call graph for this function:

◆ handleWriteFiles()

void correlation::app::FileIOHandler::handleWriteFiles ( )

Displays file save dialog asynchronously and exports active structural data.

◆ onTrajectoryLoadSuccess()

void correlation::app::FileIOHandler::onTrajectoryLoadSuccess ( const std::string & filepath)
private

Updates UI components and analysis options after successful trajectory loading.

Parameters
[in]filepathPath to the loaded structure or trajectory file.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ refreshAtomCountsUI()

void correlation::app::FileIOHandler::refreshAtomCountsUI ( )
private

Populates UI AtomCount vector model with species counts, CPK colors, and unknown flags.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startLoadingTrajectories()

void correlation::app::FileIOHandler::startLoadingTrajectories ( const std::vector< std::string > & filepaths,
std::function< void(bool)> on_complete = nullptr )

Initiates asynchronous trajectory loading for multiple files on the background worker thread.

Parameters
[in]filepathsCollection of paths to trajectory files.
[in]on_completeOptional callback invoked on event loop when loading finishes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ startLoadingTrajectory()

void correlation::app::FileIOHandler::startLoadingTrajectory ( const std::string & filepath,
std::function< void(bool)> on_complete = nullptr )

Initiates asynchronous trajectory loading on the background worker thread.

Parameters
[in]filepathAbsolute path to structure or trajectory file.
[in]on_completeOptional callback invoked on event loop when loading finishes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateBoxDiagnostics()

void correlation::app::FileIOHandler::updateBoxDiagnostics ( const core::Cell * cell)

Updates simulation cell diagnostics (volume, dimensions, density) on the UI.

Parameters
[in]cellPointer to the simulation cell, or nullptr if unavailable.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateBoxDiagnosticsForFrame()

void correlation::app::FileIOHandler::updateBoxDiagnosticsForFrame ( size_t frame_index)

Updates simulation cell diagnostics on the UI for a specific trajectory frame.

Parameters
[in]frame_indexZero-based trajectory frame index.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateFileMetadata()

void correlation::app::FileIOHandler::updateFileMetadata ( const std::string & filepath)
private

Updates loaded file metadata (basename, frame counts, atom counts) on the UI.

Parameters
[in]filepathPath to the loaded structure or trajectory file.
Here is the caller graph for this function:

◆ updateStructure3DView()

void correlation::app::FileIOHandler::updateStructure3DView ( )
private

Updates 3D structure/trajectory view with loaded cell or trajectory.

Here is the caller graph for this function:

Member Data Documentation

◆ alive_

std::shared_ptr<std::atomic<bool> > correlation::app::FileIOHandler::alive_
private
Initial value:
{
std::make_shared<std::atomic<bool>>(true)}

Lifetime guard for queued UI callbacks.

◆ controller_

AppController& correlation::app::FileIOHandler::controller_
private

◆ dialog_active_

std::atomic<bool> correlation::app::FileIOHandler::dialog_active_
private
Initial value:
{
false}

Concurrency guard preventing duplicate dialog launches.

◆ dialog_thread_

std::jthread correlation::app::FileIOHandler::dialog_thread_
private

Background worker thread for native file dialogs.

◆ dispatcher_

AnalysisDispatcher& correlation::app::FileIOHandler::dispatcher_
private

◆ load_thread_

std::jthread correlation::app::FileIOHandler::load_thread_
private

Background thread for loading files without blocking UI.

◆ loaded_filepaths_

std::vector<std::string> correlation::app::FileIOHandler::loaded_filepaths_
private

Active single or multi-file trajectory paths.

◆ loader_

TrajectoryLoader& correlation::app::FileIOHandler::loader_
private

◆ options_

ProgramOptions& correlation::app::FileIOHandler::options_
private

◆ window_

::AppWindow& correlation::app::FileIOHandler::window_
private

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