Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
FileIOHandler.hpp
Go to the documentation of this file.
1
8
9#pragma once
10
14#include <atomic>
15#include <functional>
16#include <memory>
17#include <string>
18#include <thread>
19
20class AppWindow;
21
22namespace correlation::app {
23
24class AppController;
25
31public:
40 FileIOHandler(::AppWindow &window, TrajectoryLoader &loader, AnalysisDispatcher &dispatcher,
41 ProgramOptions &options, AppController &controller);
42
47
52 void handleBrowseFile();
53
57 void handleReloadFile();
58
62 void handleWriteFiles();
63
69
75 void startLoadingTrajectory(const std::string &filepath,
76 std::function<void(bool)> on_complete = nullptr);
77
84 void startLoadingTrajectories(const std::vector<std::string> &filepaths,
85 std::function<void(bool)> on_complete = nullptr);
86
91 void updateBoxDiagnostics(const core::Cell *cell);
92
97 void updateBoxDiagnosticsForFrame(size_t frame_index);
98
104 void handleRenameElement(const std::string &old_symbol, const std::string &new_symbol);
105
106private:
110 void refreshAtomCountsUI();
115 void onTrajectoryLoadSuccess(const std::string &filepath);
116
121 void updateFileMetadata(const std::string &filepath);
122
127
132 void executeWriteFiles(const std::string &filepath);
133
134 ::AppWindow &window_;
139
140 std::shared_ptr<std::atomic<bool>> alive_{
141 std::make_shared<std::atomic<bool>>(true)};
142 std::jthread dialog_thread_;
143 std::jthread load_thread_;
144 std::vector<std::string> loaded_filepaths_;
145 std::atomic<bool> dialog_active_{
146 false};
147};
148
149} // namespace correlation::app
Service coordinating correlation analysis execution and file export.
Configuration structures and defaults for application analysis.
Service responsible for loading trajectories and extracting structural metadata.
Dispatches analysis workflows to CorrelationEngine, handles cancellation, and exports data.
Definition AnalysisDispatcher.hpp:32
Controller class for the application orchestrating services and UI.
Definition AppController.hpp:44
std::shared_ptr< std::atomic< bool > > alive_
Lifetime guard for queued UI callbacks.
Definition FileIOHandler.hpp:140
::AppWindow & window_
Definition FileIOHandler.hpp:134
FileIOHandler(::AppWindow &window, TrajectoryLoader &loader, AnalysisDispatcher &dispatcher, ProgramOptions &options, AppController &controller)
Constructs the FileIOHandler with injected services.
Definition FileIOHandler.cpp:26
void refreshAtomCountsUI()
Populates UI AtomCount vector model with species counts, CPK colors, and unknown flags.
Definition FileIOHandler.cpp:369
AppController & controller_
Definition FileIOHandler.hpp:138
AnalysisDispatcher & dispatcher_
Definition FileIOHandler.hpp:136
void handleWriteFiles()
Displays file save dialog asynchronously and exports active structural data.
Definition FileIOHandler.cpp:92
std::vector< std::string > loaded_filepaths_
Active single or multi-file trajectory paths.
Definition FileIOHandler.hpp:144
void updateBoxDiagnosticsForFrame(size_t frame_index)
Updates simulation cell diagnostics on the UI for a specific trajectory frame.
Definition FileIOHandler.cpp:492
std::atomic< bool > dialog_active_
Concurrency guard preventing duplicate dialog launches.
Definition FileIOHandler.hpp:145
void startLoadingTrajectory(const std::string &filepath, std::function< void(bool)> on_complete=nullptr)
Initiates asynchronous trajectory loading on the background worker thread.
Definition FileIOHandler.cpp:238
void onTrajectoryLoadSuccess(const std::string &filepath)
Updates UI components and analysis options after successful trajectory loading.
Definition FileIOHandler.cpp:420
void handleReloadFile()
Reloads the currently loaded structure/trajectory file from disk asynchronously.
Definition FileIOHandler.cpp:469
void handleExportStructure()
Displays file save dialog asynchronously and exports/converts the active structure to POSCAR,...
Definition FileIOHandler.cpp:171
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.
Definition FileIOHandler.cpp:297
void updateStructure3DView()
Updates 3D structure/trajectory view with loaded cell or trajectory.
Definition FileIOHandler.cpp:480
void handleRenameElement(const std::string &old_symbol, const std::string &new_symbol)
Renames an element species across the loaded trajectory and refreshes UI models.
Definition FileIOHandler.cpp:385
ProgramOptions & options_
Definition FileIOHandler.hpp:137
~FileIOHandler()
Destructor. Ensures background threads are joined.
Definition FileIOHandler.cpp:32
std::jthread load_thread_
Background thread for loading files without blocking UI.
Definition FileIOHandler.hpp:143
void executeWriteFiles(const std::string &filepath)
Executes export of active structural datasets based on the selected file path extension.
Definition FileIOHandler.cpp:79
std::jthread dialog_thread_
Background worker thread for native file dialogs.
Definition FileIOHandler.hpp:142
void updateFileMetadata(const std::string &filepath)
Updates loaded file metadata (basename, frame counts, atom counts) on the UI.
Definition FileIOHandler.cpp:531
void updateBoxDiagnostics(const core::Cell *cell)
Updates simulation cell diagnostics (volume, dimensions, density) on the UI.
Definition FileIOHandler.cpp:502
TrajectoryLoader & loader_
Definition FileIOHandler.hpp:135
void handleBrowseFile()
Displays file open dialog asynchronously and triggers background loading of selected structure/trajec...
Definition FileIOHandler.cpp:542
Manages loading of structure/trajectory files and provides atomic/cell metadata.
Definition TrajectoryLoader.hpp:34
Represents the simulation cell (periodic box).
Definition Cell.hpp:30
Definition AppController.hpp:27
Encapsulates all configurable options for the application.
Definition AppOptions.hpp:122