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

Manages plot rendering, caching, interactions, and exports. More...

#include <PlotController.hpp>

Collaboration diagram for correlation::app::PlotController:

Public Member Functions

 PlotController (::AppWindow &window, AnalysisDispatcher &dispatcher, const ProgramOptions &options)
 Constructs the PlotController with injected dispatcher and options.
 ~PlotController ()
 Destructor. Joins render worker thread before destruction.
void populatePlotList ()
 Populates available plot names into the UI dropdown list.
void handleMouseMove (float mouse_x, float mouse_y, bool hover, float width, float height)
 Handles mouse movement and hover tooltip calculation on the plot canvas.
void requestPlotUpdate (int index, bool immediate=false)
 Schedules or immediately triggers a plot redraw for the specified plot index.
void syncPlotListForActiveTab (int tab)
 Synchronizes the dropdown plot items and available keys according to active tab. In Dual View mode (tab 2), restricts selections to g(r), S(Q), PAD, and 2D Phase Heatmap.
std::span< const std::string > availablePlotKeys () const noexcept
 Returns active plot key names.
void handleSavePlot ()
 Handles saving the current plot to file (SVG/PDF).
void handleCopyPlotToClipboard ()
 Copies SVG vector markup of the active plot to the system clipboard.
void handlePinRun ()
 Pins the current analysis run for comparison overlay.
void handleClearPinnedRuns ()
 Clears all pinned comparison overlay runs.
void handlePlotResized (PlotSize size)
 Handles plot resized callback from UI layout changes.
void handleToggleCurveVisibility (int curve_id, bool visible)
 Handles toggling curve visibility from the Slint preview checklist.
void handleToggleAllCurves (bool visible)
 Handles bulk toggling all curves visible or hidden.
void handleFilterCurves (const slint::SharedString &filter_text)
 Handles real-time curve name filtering from the curve sidebar.
void handleInvertCurveVisibility ()
 Handles inverting visibility of tracked curves (scoped to filter if active).
void handleToggleDifferencePlot (bool show_difference)
 Handles toggling overlaid absolute difference curve Y_diff rendering.
void handleSetCurveColor (int curve_id, const slint::SharedString &color_hex)
 Handles setting a custom color for a curve.
void handleZoomRect (float start_x, float start_y, float end_x, float end_y)
 Handles box zoom to a specified screen bounding rectangle.
void handlePan (float delta_x, float delta_y)
 Handles continuous panning by screen pixel displacement.
void handleWheelZoom (float mouse_x, float mouse_y, float delta)
 Handles mouse wheel zooming centered around the mouse cursor.
void handleResetZoom ()
 Resets zoom to full dataset auto bounds.
void handleAddMarkerAt (float click_x, float click_y, bool is_vertical)
 Adds a reference line (vertical for X, horizontal for Y) at clicked screen coordinates.
void handleAddMarker (bool is_vertical)
 Adds a reference line (vertical for X, horizontal for Y) at current cursor position.
void handleClearMarkers ()
 Clears all user reference markers.
void resetPlotState () noexcept
 Resets all plot series state (visibility overrides, custom colors, pinned runs).
void handleApplyAxisSettings ()
 Applies manual axis range, ticks, and scaling from the floating popover.
correlation::plotters::PlotConfig buildPlotConfigFromUI ()
 Constructs the consolidated plot rendering configuration from active UI state.
void handleResetAxisSettings ()
 Resets axis limits, ticks, and scaling to automatic dataset extents.
void handleSetCurveWidth (const slint::SharedString &width_str)
 Sets custom curve line width from the styling popover.
void setStructure3DController (Structure3DController *s3d) noexcept
 Connects reference to Structure3DController to synchronize distribution limits.
void setTrajectoryLoader (const TrajectoryLoader *loader) noexcept
 Associates TrajectoryLoader for density calculations in CN integration.
void handleTagPeakAt (float click_x, float click_y)
 Detects and tags the peak near clicked screen coordinates.
void handleTagPeakRange (float start_x, float end_x)
 Integrates and tags peak within screen coordinate range [start_x, end_x].
void handleRemoveTaggedPeak (int idx)
 Removes a tagged peak by its identifier.
void handleClearTaggedPeaks ()
 Clears all tagged peak annotations.
void handleExportTaggedPeaks ()
 Exports tagged peaks to CSV.
void updateTaggedPeakPixels ()
 Recomputes screen projection coordinates for all tagged peaks.
std::span< const TaggedPeakData > getTaggedPeaks () const noexcept
 Returns a read-only view of active tagged peaks.
float getLastPlotWidth () const noexcept
 Returns the last cached plot canvas width.
float getLastPlotHeight () const noexcept
 Returns the last cached plot canvas height.
correlation::plotters::PlotConfig getActivePlotConfig ()
 Builds and returns the active plot configuration from current UI state.
void setOnPlotGeometryChanged (std::function< void(float, float)> callback)
 Registers a callback invoked whenever plot canvas dimensions change.

Private Member Functions

void updateTableData (const correlation::analysis::Histogram *hist)
void updateCurveToggleItems (const correlation::analysis::Histogram *hist)
void applyDualViewOverlay (RenderTask &task, const std::string &name, std::size_t current_frame) const
void syncMetricSettingsToUI (int index)
void syncSettingsTo3DHUD (int index, const correlation::plotters::MetricPlotSettings &settings)
void notifyRadialHover (std::string_view plot_name, std::optional< double > data_x) const
void syncZoomLimitsToSettings (int current_idx)
 Synchronizes active zoom viewport limits to metric plot settings and UI.

Private Attributes

::AppWindow & window_
AnalysisDispatcher & dispatcher_
const ProgramOptions & options_
PlotSeriesManager series_manager_
PlotViewportNavigator viewport_navigator_
PlotMarkerManager marker_manager_
PlotRenderPipeline pipeline_
PlotExportManager export_manager_
std::vector< std::string > available_plot_keys_
float last_mouse_x_ = -1.0F
float last_mouse_y_ = -1.0F
bool mouse_hover_ = false
float last_plot_width_ = 0.0F
float last_plot_height_ = 0.0F
std::function< void(float, float)> on_plot_geometry_changed_
Structure3DController * structure_3d_controller_ {nullptr}
int active_plot_index_ {-1}
std::string last_table_key_
std::size_t last_table_frame_ {std::numeric_limits<std::size_t>::max()}
int last_table_tab_ {-1}
std::shared_ptr< std::atomic< bool > > alive_ {std::make_shared<std::atomic<bool>>(true)}
std::unordered_map< int, correlation::plotters::MetricPlotSettings > metric_settings_
std::vector< TaggedPeakData > tagged_peaks_
int next_peak_id_ {1}
const TrajectoryLoader * trajectory_loader_ {nullptr}

Detailed Description

Manages plot rendering, caching, interactions, and exports.

Constructor & Destructor Documentation

◆ PlotController()

correlation::app::PlotController::PlotController ( ::AppWindow & window,
AnalysisDispatcher & dispatcher,
const ProgramOptions & options )

Constructs the PlotController with injected dispatcher and options.

Parameters
[in,out]windowReference to the UI window.
[in,out]dispatcherReference to the analysis dispatcher.
[in]optionsReference to program options.
Here is the call graph for this function:

◆ ~PlotController()

correlation::app::PlotController::~PlotController ( )

Destructor. Joins render worker thread before destruction.

Member Function Documentation

◆ applyDualViewOverlay()

void correlation::app::PlotController::applyDualViewOverlay ( RenderTask & task,
const std::string & name,
std::size_t current_frame ) const
private
Here is the caller graph for this function:

◆ availablePlotKeys()

std::span< const std::string > correlation::app::PlotController::availablePlotKeys ( ) const
inlinenodiscardnoexcept

Returns active plot key names.

◆ buildPlotConfigFromUI()

correlation::plotters::PlotConfig correlation::app::PlotController::buildPlotConfigFromUI ( )
nodiscard

Constructs the consolidated plot rendering configuration from active UI state.

Returns
PlotConfig populated from active window settings, palettes, and axis overrides.
Here is the caller graph for this function:

◆ getActivePlotConfig()

correlation::plotters::PlotConfig correlation::app::PlotController::getActivePlotConfig ( )
inlinenodiscard

Builds and returns the active plot configuration from current UI state.

Here is the call graph for this function:

◆ getLastPlotHeight()

float correlation::app::PlotController::getLastPlotHeight ( ) const
inlinenodiscardnoexcept

Returns the last cached plot canvas height.

◆ getLastPlotWidth()

float correlation::app::PlotController::getLastPlotWidth ( ) const
inlinenodiscardnoexcept

Returns the last cached plot canvas width.

◆ getTaggedPeaks()

std::span< const TaggedPeakData > correlation::app::PlotController::getTaggedPeaks ( ) const
inlinenodiscardnoexcept

Returns a read-only view of active tagged peaks.

◆ handleAddMarker()

void correlation::app::PlotController::handleAddMarker ( bool is_vertical)

Adds a reference line (vertical for X, horizontal for Y) at current cursor position.

Parameters
[in]is_verticalTrue for vertical X marker, false for horizontal Y marker.
Here is the call graph for this function:

◆ handleAddMarkerAt()

void correlation::app::PlotController::handleAddMarkerAt ( float click_x,
float click_y,
bool is_vertical )

Adds a reference line (vertical for X, horizontal for Y) at clicked screen coordinates.

Parameters
[in]click_xScreen X coordinate of the click.
[in]click_yScreen Y coordinate of the click.
[in]is_verticalTrue for vertical X marker, false for horizontal Y marker.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleApplyAxisSettings()

void correlation::app::PlotController::handleApplyAxisSettings ( )

Applies manual axis range, ticks, and scaling from the floating popover.

Here is the call graph for this function:

◆ handleClearMarkers()

void correlation::app::PlotController::handleClearMarkers ( )

Clears all user reference markers.

Here is the call graph for this function:

◆ handleClearPinnedRuns()

void correlation::app::PlotController::handleClearPinnedRuns ( )

Clears all pinned comparison overlay runs.

Here is the call graph for this function:

◆ handleClearTaggedPeaks()

void correlation::app::PlotController::handleClearTaggedPeaks ( )

Clears all tagged peak annotations.

Here is the call graph for this function:

◆ handleCopyPlotToClipboard()

void correlation::app::PlotController::handleCopyPlotToClipboard ( )

Copies SVG vector markup of the active plot to the system clipboard.

Here is the call graph for this function:

◆ handleExportTaggedPeaks()

void correlation::app::PlotController::handleExportTaggedPeaks ( )

Exports tagged peaks to CSV.

◆ handleFilterCurves()

void correlation::app::PlotController::handleFilterCurves ( const slint::SharedString & filter_text)

Handles real-time curve name filtering from the curve sidebar.

Parameters
[in]filter_textSubstring query to filter visible curve items.
Here is the call graph for this function:

◆ handleInvertCurveVisibility()

void correlation::app::PlotController::handleInvertCurveVisibility ( )

Handles inverting visibility of tracked curves (scoped to filter if active).

Here is the call graph for this function:

◆ handleMouseMove()

void correlation::app::PlotController::handleMouseMove ( float mouse_x,
float mouse_y,
bool hover,
float width,
float height )

Handles mouse movement and hover tooltip calculation on the plot canvas.

Parameters
[in]mouse_xMouse X coordinate on canvas.
[in]mouse_yMouse Y coordinate on canvas.
[in]hoverFlag indicating active mouse hover state.
[in]widthCanvas layout width.
[in]heightCanvas layout height.
Here is the call graph for this function:

◆ handlePan()

void correlation::app::PlotController::handlePan ( float delta_x,
float delta_y )

Handles continuous panning by screen pixel displacement.

Parameters
[in]delta_xScreen horizontal delta in pixels.
[in]delta_yScreen vertical delta in pixels.
Here is the call graph for this function:

◆ handlePinRun()

void correlation::app::PlotController::handlePinRun ( )

Pins the current analysis run for comparison overlay.

Here is the call graph for this function:

◆ handlePlotResized()

void correlation::app::PlotController::handlePlotResized ( PlotSize size)

Handles plot resized callback from UI layout changes.

Parameters
[in]sizeNew plot container dimensions.
Here is the call graph for this function:

◆ handleRemoveTaggedPeak()

void correlation::app::PlotController::handleRemoveTaggedPeak ( int idx)

Removes a tagged peak by its identifier.

Parameters
[in]idPeak identifier.
Here is the call graph for this function:

◆ handleResetAxisSettings()

void correlation::app::PlotController::handleResetAxisSettings ( )

Resets axis limits, ticks, and scaling to automatic dataset extents.

Here is the call graph for this function:

◆ handleResetZoom()

void correlation::app::PlotController::handleResetZoom ( )

Resets zoom to full dataset auto bounds.

Here is the call graph for this function:

◆ handleSavePlot()

void correlation::app::PlotController::handleSavePlot ( )

Handles saving the current plot to file (SVG/PDF).

Here is the call graph for this function:

◆ handleSetCurveColor()

void correlation::app::PlotController::handleSetCurveColor ( int curve_id,
const slint::SharedString & color_hex )

Handles setting a custom color for a curve.

Parameters
[in]curve_idCurve identifier index.
[in]color_hexCustom hex color string.
Here is the call graph for this function:

◆ handleSetCurveWidth()

void correlation::app::PlotController::handleSetCurveWidth ( const slint::SharedString & width_str)

Sets custom curve line width from the styling popover.

Parameters
[in]width_strStroke line width string in pixels.
Here is the call graph for this function:

◆ handleTagPeakAt()

void correlation::app::PlotController::handleTagPeakAt ( float click_x,
float click_y )

Detects and tags the peak near clicked screen coordinates.

Parameters
[in]click_xScreen horizontal pixel coordinate.
[in]click_yScreen vertical pixel coordinate.
Here is the call graph for this function:

◆ handleTagPeakRange()

void correlation::app::PlotController::handleTagPeakRange ( float start_x,
float end_x )

Integrates and tags peak within screen coordinate range [start_x, end_x].

Parameters
[in]start_xStarting screen pixel coordinate.
[in]end_xEnding screen pixel coordinate.
Here is the call graph for this function:

◆ handleToggleAllCurves()

void correlation::app::PlotController::handleToggleAllCurves ( bool visible)

Handles bulk toggling all curves visible or hidden.

Parameters
[in]visibleTarget visibility state for all curves.
Here is the call graph for this function:

◆ handleToggleCurveVisibility()

void correlation::app::PlotController::handleToggleCurveVisibility ( int curve_id,
bool visible )

Handles toggling curve visibility from the Slint preview checklist.

Parameters
[in]curve_idCurve identifier index.
[in]visibleTarget visibility state.
Here is the call graph for this function:

◆ handleToggleDifferencePlot()

void correlation::app::PlotController::handleToggleDifferencePlot ( bool show_difference)

Handles toggling overlaid absolute difference curve Y_diff rendering.

Parameters
[in]show_differenceTarget visibility state for Y_diff.
Here is the call graph for this function:

◆ handleWheelZoom()

void correlation::app::PlotController::handleWheelZoom ( float mouse_x,
float mouse_y,
float delta )

Handles mouse wheel zooming centered around the mouse cursor.

Parameters
[in]mouse_xScreen cursor X coordinate.
[in]mouse_yScreen cursor Y coordinate.
[in]deltaMouse wheel vertical displacement delta.
Here is the call graph for this function:

◆ handleZoomRect()

void correlation::app::PlotController::handleZoomRect ( float start_x,
float start_y,
float end_x,
float end_y )

Handles box zoom to a specified screen bounding rectangle.

Parameters
[in]start_xStarting screen X coordinate.
[in]start_yStarting screen Y coordinate.
[in]end_xEnding screen X coordinate.
[in]end_yEnding screen Y coordinate.
Here is the call graph for this function:

◆ notifyRadialHover()

void correlation::app::PlotController::notifyRadialHover ( std::string_view plot_name,
std::optional< double > data_x ) const
private
Here is the caller graph for this function:

◆ populatePlotList()

void correlation::app::PlotController::populatePlotList ( )

Populates available plot names into the UI dropdown list.

Here is the call graph for this function:

◆ requestPlotUpdate()

void correlation::app::PlotController::requestPlotUpdate ( int index,
bool immediate = false )

Schedules or immediately triggers a plot redraw for the specified plot index.

Parameters
[in]indexTarget plot selection index.
[in]immediateIf true, skips debounce timer and updates immediately.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetPlotState()

void correlation::app::PlotController::resetPlotState ( )
noexcept

Resets all plot series state (visibility overrides, custom colors, pinned runs).

Here is the call graph for this function:

◆ setOnPlotGeometryChanged()

void correlation::app::PlotController::setOnPlotGeometryChanged ( std::function< void(float, float)> callback)
inline

Registers a callback invoked whenever plot canvas dimensions change.

◆ setStructure3DController()

void correlation::app::PlotController::setStructure3DController ( Structure3DController * s3d)
inlinenoexcept

Connects reference to Structure3DController to synchronize distribution limits.

Parameters
[in]s3dPointer to Structure3DController.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTrajectoryLoader()

void correlation::app::PlotController::setTrajectoryLoader ( const TrajectoryLoader * loader)
inlinenoexcept

Associates TrajectoryLoader for density calculations in CN integration.

Parameters
[in]loaderPointer to active TrajectoryLoader.

◆ syncMetricSettingsToUI()

void correlation::app::PlotController::syncMetricSettingsToUI ( int index)
private
Here is the caller graph for this function:

◆ syncPlotListForActiveTab()

void correlation::app::PlotController::syncPlotListForActiveTab ( int tab)

Synchronizes the dropdown plot items and available keys according to active tab. In Dual View mode (tab 2), restricts selections to g(r), S(Q), PAD, and 2D Phase Heatmap.

Parameters
[in]tabActive tab index.
Here is the caller graph for this function:

◆ syncSettingsTo3DHUD()

void correlation::app::PlotController::syncSettingsTo3DHUD ( int index,
const correlation::plotters::MetricPlotSettings & settings )
private
Here is the caller graph for this function:

◆ syncZoomLimitsToSettings()

void correlation::app::PlotController::syncZoomLimitsToSettings ( int current_idx)
private

Synchronizes active zoom viewport limits to metric plot settings and UI.

Parameters
[in]current_idxTarget metric plot selection index.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateCurveToggleItems()

void correlation::app::PlotController::updateCurveToggleItems ( const correlation::analysis::Histogram * hist)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateTableData()

void correlation::app::PlotController::updateTableData ( const correlation::analysis::Histogram * hist)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateTaggedPeakPixels()

void correlation::app::PlotController::updateTaggedPeakPixels ( )

Recomputes screen projection coordinates for all tagged peaks.

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

Member Data Documentation

◆ active_plot_index_

int correlation::app::PlotController::active_plot_index_ {-1}
private

◆ alive_

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

◆ available_plot_keys_

std::vector<std::string> correlation::app::PlotController::available_plot_keys_
private

◆ dispatcher_

AnalysisDispatcher& correlation::app::PlotController::dispatcher_
private

◆ export_manager_

PlotExportManager correlation::app::PlotController::export_manager_
private

◆ last_mouse_x_

float correlation::app::PlotController::last_mouse_x_ = -1.0F
private

◆ last_mouse_y_

float correlation::app::PlotController::last_mouse_y_ = -1.0F
private

◆ last_plot_height_

float correlation::app::PlotController::last_plot_height_ = 0.0F
private

◆ last_plot_width_

float correlation::app::PlotController::last_plot_width_ = 0.0F
private

◆ last_table_frame_

std::size_t correlation::app::PlotController::last_table_frame_ {std::numeric_limits<std::size_t>::max()}
private

◆ last_table_key_

std::string correlation::app::PlotController::last_table_key_
private

◆ last_table_tab_

int correlation::app::PlotController::last_table_tab_ {-1}
private

◆ marker_manager_

PlotMarkerManager correlation::app::PlotController::marker_manager_
private

◆ metric_settings_

std::unordered_map<int, correlation::plotters::MetricPlotSettings> correlation::app::PlotController::metric_settings_
private

◆ mouse_hover_

bool correlation::app::PlotController::mouse_hover_ = false
private

◆ next_peak_id_

int correlation::app::PlotController::next_peak_id_ {1}
private

◆ on_plot_geometry_changed_

std::function<void(float, float)> correlation::app::PlotController::on_plot_geometry_changed_
private

◆ options_

const ProgramOptions& correlation::app::PlotController::options_
private

◆ pipeline_

PlotRenderPipeline correlation::app::PlotController::pipeline_
private

◆ series_manager_

PlotSeriesManager correlation::app::PlotController::series_manager_
private

◆ structure_3d_controller_

Structure3DController* correlation::app::PlotController::structure_3d_controller_ {nullptr}
private

◆ tagged_peaks_

std::vector<TaggedPeakData> correlation::app::PlotController::tagged_peaks_
private

◆ trajectory_loader_

const TrajectoryLoader* correlation::app::PlotController::trajectory_loader_ {nullptr}
private

◆ viewport_navigator_

PlotViewportNavigator correlation::app::PlotController::viewport_navigator_
private

◆ window_

::AppWindow& correlation::app::PlotController::window_
private

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