Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
PlotController.hpp
Go to the documentation of this file.
1
8
9#pragma once
10
19#include <slint.h>
20
21#include <functional>
22#include <string>
23#include <vector>
24
25class AppWindow;
26
27namespace correlation::app {
28
31
37 int id{0};
38 std::string curve_name;
44 std::optional<real_t> coordination_number;
47 std::string color_hex{"#0072b2"};
48};
49
50struct PlotSize {
51 float width;
52 float height;
53};
54
60public:
67 PlotController(::AppWindow &window, AnalysisDispatcher &dispatcher,
68 const ProgramOptions &options);
69
74
78 void populatePlotList();
79
88 void handleMouseMove(float mouse_x, float mouse_y, bool hover, float width, float height);
89
95 void requestPlotUpdate(int index, bool immediate = false);
96
102 void syncPlotListForActiveTab(int tab);
103
107 [[nodiscard]] std::span<const std::string> availablePlotKeys() const noexcept {
109 }
110
114 void handleSavePlot();
115
120
124 void handlePinRun();
125
130
135 void handlePlotResized(PlotSize size);
136
142 void handleToggleCurveVisibility(int curve_id, bool visible);
143
148 void handleToggleAllCurves(bool visible);
149
154 void handleFilterCurves(const slint::SharedString &filter_text);
155
160
165 void handleToggleDifferencePlot(bool show_difference);
166
172 void handleSetCurveColor(int curve_id, const slint::SharedString &color_hex);
173
181 void handleZoomRect(float start_x, float start_y, float end_x, float end_y);
182
188 void handlePan(float delta_x, float delta_y);
189
196 void handleWheelZoom(float mouse_x, float mouse_y, float delta);
197
201 void handleResetZoom();
202
209 void handleAddMarkerAt(float click_x, float click_y, bool is_vertical);
210
215 void handleAddMarker(bool is_vertical);
216
220 void handleClearMarkers();
221
225 void resetPlotState() noexcept;
226
231
236 [[nodiscard]] correlation::plotters::PlotConfig buildPlotConfigFromUI();
237
242
247 void handleSetCurveWidth(const slint::SharedString &width_str);
248
256
261 void setTrajectoryLoader(const TrajectoryLoader *loader) noexcept { trajectory_loader_ = loader; }
262
268 void handleTagPeakAt(float click_x, float click_y);
269
275 void handleTagPeakRange(float start_x, float end_x);
276
281 void handleRemoveTaggedPeak(int idx);
282
287
292
297
301 [[nodiscard]] std::span<const TaggedPeakData> getTaggedPeaks() const noexcept {
302 return tagged_peaks_;
303 }
304
308 [[nodiscard]] float getLastPlotWidth() const noexcept { return last_plot_width_; }
309
313 [[nodiscard]] float getLastPlotHeight() const noexcept { return last_plot_height_; }
314
321
325 void setOnPlotGeometryChanged(std::function<void(float, float)> callback) {
326 on_plot_geometry_changed_ = std::move(callback);
327 }
328
329private:
330 ::AppWindow &window_;
333
335
340
341 std::vector<std::string> available_plot_keys_;
342
343 float last_mouse_x_ = -1.0F;
344 float last_mouse_y_ = -1.0F;
345 bool mouse_hover_ = false;
346 float last_plot_width_ = 0.0F;
347 float last_plot_height_ = 0.0F;
348
351 void applyDualViewOverlay(RenderTask &task, const std::string &name,
352 std::size_t current_frame) const;
353
354 std::function<void(float, float)> on_plot_geometry_changed_;
355
358 std::string last_table_key_;
359 std::size_t last_table_frame_{std::numeric_limits<std::size_t>::max()};
361 std::shared_ptr<std::atomic<bool>> alive_{std::make_shared<std::atomic<bool>>(true)};
362 std::unordered_map<int, correlation::plotters::MetricPlotSettings> metric_settings_;
363
364 void syncMetricSettingsToUI(int index);
365 void syncSettingsTo3DHUD(int index, const correlation::plotters::MetricPlotSettings &settings);
366 void notifyRadialHover(std::string_view plot_name, std::optional<double> data_x) const;
367
368 std::vector<TaggedPeakData> tagged_peaks_;
371
376 void syncZoomLimitsToSettings(int current_idx);
377};
378
379} // namespace correlation::app
Service coordinating correlation analysis execution and file export.
Configuration structures and defaults for application analysis.
Coordinates native file dialog, multi-dataset packaging, and background plot export.
Management and formatting of user reference marker guidelines on plots.
Background asynchronous rendering pipeline and caching for plot visualization.
Manages curve visibility, custom colors, pinned runs, and toggle models for plots.
Viewport navigation, coordinate projection, and zoom state management.
Facade header for zero-dependency SVG plotter.
Dispatches analysis workflows to CorrelationEngine, handles cancellation, and exports data.
Definition AnalysisDispatcher.hpp:32
void handleExportTaggedPeaks()
Exports tagged peaks to CSV.
Definition PlotController.cpp:1445
void handleSavePlot()
Handles saving the current plot to file (SVG/PDF).
Definition PlotController.cpp:804
PlotExportManager export_manager_
Definition PlotController.hpp:339
const TrajectoryLoader * trajectory_loader_
Definition PlotController.hpp:370
float getLastPlotHeight() const noexcept
Returns the last cached plot canvas height.
Definition PlotController.hpp:313
void handlePinRun()
Pins the current analysis run for comparison overlay.
Definition PlotController.cpp:867
void handleClearTaggedPeaks()
Clears all tagged peak annotations.
Definition PlotController.cpp:1439
void resetPlotState() noexcept
Resets all plot series state (visibility overrides, custom colors, pinned runs).
Definition PlotController.cpp:1070
std::function< void(float, float)> on_plot_geometry_changed_
Definition PlotController.hpp:354
Structure3DController * structure_3d_controller_
Definition PlotController.hpp:356
void handleApplyAxisSettings()
Applies manual axis range, ticks, and scaling from the floating popover.
Definition PlotController.cpp:1260
void handleInvertCurveVisibility()
Handles inverting visibility of tracked curves (scoped to filter if active).
Definition PlotController.cpp:920
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.
Definition PlotController.cpp:552
float getLastPlotWidth() const noexcept
Returns the last cached plot canvas width.
Definition PlotController.hpp:308
void updateTaggedPeakPixels()
Recomputes screen projection coordinates for all tagged peaks.
Definition PlotController.cpp:1473
::AppWindow & window_
Definition PlotController.hpp:330
PlotMarkerManager marker_manager_
Definition PlotController.hpp:337
~PlotController()
Destructor. Joins render worker thread before destruction.
Definition PlotController.cpp:331
std::size_t last_table_frame_
Definition PlotController.hpp:359
void handleResetZoom()
Resets zoom to full dataset auto bounds.
Definition PlotController.cpp:996
std::vector< std::string > available_plot_keys_
Definition PlotController.hpp:341
float last_plot_height_
Definition PlotController.hpp:347
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.
Definition PlotController.cpp:1035
void requestPlotUpdate(int index, bool immediate=false)
Schedules or immediately triggers a plot redraw for the specified plot index.
Definition PlotController.cpp:623
float last_plot_width_
Definition PlotController.hpp:346
void handlePan(float delta_x, float delta_y)
Handles continuous panning by screen pixel displacement.
Definition PlotController.cpp:956
void handleResetAxisSettings()
Resets axis limits, ticks, and scaling to automatic dataset extents.
Definition PlotController.cpp:1293
AnalysisDispatcher & dispatcher_
Definition PlotController.hpp:331
void applyDualViewOverlay(RenderTask &task, const std::string &name, std::size_t current_frame) const
Definition PlotController.cpp:729
std::vector< TaggedPeakData > tagged_peaks_
Definition PlotController.hpp:368
void handleToggleCurveVisibility(int curve_id, bool visible)
Handles toggling curve visibility from the Slint preview checklist.
Definition PlotController.cpp:892
int active_plot_index_
Definition PlotController.hpp:357
void syncMetricSettingsToUI(int index)
Definition PlotController.cpp:1096
void updateCurveToggleItems(const correlation::analysis::Histogram *hist)
Definition PlotController.cpp:798
void handleSetCurveColor(int curve_id, const slint::SharedString &color_hex)
Handles setting a custom color for a curve.
Definition PlotController.cpp:790
void handleAddMarker(bool is_vertical)
Adds a reference line (vertical for X, horizontal for Y) at current cursor position.
Definition PlotController.cpp:1057
void setOnPlotGeometryChanged(std::function< void(float, float)> callback)
Registers a callback invoked whenever plot canvas dimensions change.
Definition PlotController.hpp:325
void handleTagPeakAt(float click_x, float click_y)
Detects and tags the peak near clicked screen coordinates.
Definition PlotController.cpp:1319
void handleZoomRect(float start_x, float start_y, float end_x, float end_y)
Handles box zoom to a specified screen bounding rectangle.
Definition PlotController.cpp:936
void handleSetCurveWidth(const slint::SharedString &width_str)
Sets custom curve line width from the styling popover.
Definition PlotController.cpp:1305
void handleFilterCurves(const slint::SharedString &filter_text)
Handles real-time curve name filtering from the curve sidebar.
Definition PlotController.cpp:908
std::unordered_map< int, correlation::plotters::MetricPlotSettings > metric_settings_
Definition PlotController.hpp:362
PlotRenderPipeline pipeline_
Definition PlotController.hpp:338
void setStructure3DController(Structure3DController *s3d) noexcept
Connects reference to Structure3DController to synchronize distribution limits.
Definition PlotController.hpp:253
std::string last_table_key_
Definition PlotController.hpp:358
std::shared_ptr< std::atomic< bool > > alive_
Definition PlotController.hpp:361
PlotController(::AppWindow &window, AnalysisDispatcher &dispatcher, const ProgramOptions &options)
Constructs the PlotController with injected dispatcher and options.
Definition PlotController.cpp:323
void syncZoomLimitsToSettings(int current_idx)
Synchronizes active zoom viewport limits to metric plot settings and UI.
Definition PlotController.cpp:1015
correlation::plotters::PlotConfig buildPlotConfigFromUI()
Constructs the consolidated plot rendering configuration from active UI state.
Definition PlotController.cpp:349
std::span< const std::string > availablePlotKeys() const noexcept
Returns active plot key names.
Definition PlotController.hpp:107
int next_peak_id_
Definition PlotController.hpp:369
PlotViewportNavigator viewport_navigator_
Definition PlotController.hpp:336
PlotSeriesManager series_manager_
Definition PlotController.hpp:334
int last_table_tab_
Definition PlotController.hpp:360
float last_mouse_x_
Definition PlotController.hpp:343
void handleClearMarkers()
Clears all user reference markers.
Definition PlotController.cpp:1061
void handleClearPinnedRuns()
Clears all pinned comparison overlay runs.
Definition PlotController.cpp:882
void handleToggleAllCurves(bool visible)
Handles bulk toggling all curves visible or hidden.
Definition PlotController.cpp:900
void handlePlotResized(PlotSize size)
Handles plot resized callback from UI layout changes.
Definition PlotController.cpp:333
void updateTableData(const correlation::analysis::Histogram *hist)
Definition PlotController.cpp:784
void handleCopyPlotToClipboard()
Copies SVG vector markup of the active plot to the system clipboard.
Definition PlotController.cpp:826
void handleTagPeakRange(float start_x, float end_x)
Integrates and tags peak within screen coordinate range [start_x, end_x].
Definition PlotController.cpp:1376
const ProgramOptions & options_
Definition PlotController.hpp:332
void handleToggleDifferencePlot(bool show_difference)
Handles toggling overlaid absolute difference curve Y_diff rendering.
Definition PlotController.cpp:928
bool mouse_hover_
Definition PlotController.hpp:345
void populatePlotList()
Populates available plot names into the UI dropdown list.
Definition PlotController.cpp:541
correlation::plotters::PlotConfig getActivePlotConfig()
Builds and returns the active plot configuration from current UI state.
Definition PlotController.hpp:318
float last_mouse_y_
Definition PlotController.hpp:344
void handleWheelZoom(float mouse_x, float mouse_y, float delta)
Handles mouse wheel zooming centered around the mouse cursor.
Definition PlotController.cpp:976
void notifyRadialHover(std::string_view plot_name, std::optional< double > data_x) const
Definition PlotController.cpp:607
void syncPlotListForActiveTab(int tab)
Synchronizes the dropdown plot items and available keys according to active tab. In Dual View mode (t...
Definition PlotController.cpp:522
std::span< const TaggedPeakData > getTaggedPeaks() const noexcept
Returns a read-only view of active tagged peaks.
Definition PlotController.hpp:301
void handleRemoveTaggedPeak(int idx)
Removes a tagged peak by its identifier.
Definition PlotController.cpp:1434
void syncSettingsTo3DHUD(int index, const correlation::plotters::MetricPlotSettings &settings)
Definition PlotController.cpp:1132
void setTrajectoryLoader(const TrajectoryLoader *loader) noexcept
Associates TrajectoryLoader for density calculations in CN integration.
Definition PlotController.hpp:261
Coordinates OS native save dialogs, comparison datasets formatting, and export I/O.
Definition PlotExportManager.hpp:30
Stores and formats vertical (+X) and horizontal (+Y) reference inspection markers.
Definition PlotMarkerManager.hpp:22
Manages background SVG rasterization/generation worker thread, task queue, and caching.
Definition PlotRenderPipeline.hpp:49
Manages curve visibility, custom palette colors, pinned comparison runs, and Slint toggle models.
Definition PlotSeriesManager.hpp:39
Manages 2D plot coordinate space, active zoom window, and interactive pan/zoom transitions.
Definition PlotViewportNavigator.hpp:35
Coordinates 3D orbit interactions, scene streaming, and asynchronous off-thread rendering.
Definition Structure3DController.hpp:57
Manages loading of structure/trajectory files and provides atomic/cell metadata.
Definition TrajectoryLoader.hpp:34
Definition AppController.hpp:27
Definition ColormapService.hpp:18
Definition AnalysisTypes.hpp:11
double real_t
Definition Precision.hpp:18
Container for a single calculated distribution function.
Definition DistributionFunctions.hpp:226
Definition PlotController.hpp:50
float width
Definition PlotController.hpp:51
float height
Definition PlotController.hpp:52
Encapsulates all configurable options for the application.
Definition AppOptions.hpp:122
Self-contained payload consumed by the background SVG render worker.
Definition PlotRenderPipeline.hpp:32
Internal representation of a user-tagged or auto-detected peak with integration metrics.
Definition PlotController.hpp:36
std::string curve_name
Definition PlotController.hpp:38
real_t peak_height
Definition PlotController.hpp:42
std::optional< real_t > coordination_number
Definition PlotController.hpp:44
std::string color_hex
Definition PlotController.hpp:47
real_t r_max
Definition PlotController.hpp:41
real_t centroid
Definition PlotController.hpp:46
real_t r_peak
Definition PlotController.hpp:39
real_t fwhm
Definition PlotController.hpp:45
real_t r_min
Definition PlotController.hpp:40
real_t area
Definition PlotController.hpp:43
User-configured axis limits, ticks, and scaling for a specific plot metric.
Definition PlotTypes.hpp:156
Theme and layout configuration for the plot.
Definition PlotTypes.hpp:42