Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
Structure3DRenderPipeline.hpp
Go to the documentation of this file.
1
9
10#pragma once
11
13#include "render3d/Camera3D.hpp"
16#include "render3d/Scene3D.hpp"
17#include <slint.h>
18
19#include <atomic>
20#include <condition_variable>
21#include <cstdint>
22#include <functional>
23#include <memory>
24#include <mutex>
25#include <string>
26#include <thread>
27
28namespace correlation::app {
29
36 std::shared_ptr<render3d::Scene3D> scene;
37 bool is_active{false};
38 bool render_bonds{true};
39 bool render_wireframe{true};
40 bool depth_cueing{true};
41 bool ssao_enabled{true};
42 bool is_interacting{false};
43
44 // GPU Halo Highlight configuration
45 bool gpu_halos_enabled{false};
47 float phase_min_threshold{0.46F};
48 float phase_max_threshold{0.58F};
49 float phase_halo_ratio{2.70F};
51 std::array<float, 4> phase_halo_color{1.0F, 0.84F, 0.0F, 1.0F};
54};
55
62public:
63 using FrameDispatchedCallback = std::function<void(const slint::Image &)>;
64
72 std::shared_ptr<std::atomic<bool>> alive = nullptr,
73 std::unique_ptr<render3d::IRenderEngine> engine = nullptr);
74
79
84
90
96
102 void updateSnapshot(const RenderPipelineSnapshot &snapshot, bool immediate = false);
103
108 void requestRender(bool immediate = false);
109
114 [[nodiscard]] render3d::ViewportDimensions dimensions() const noexcept;
115
120 [[nodiscard]] bool isActive() const noexcept;
121
126 void setActive(bool active) noexcept;
127
132 [[nodiscard]] std::string backendName() const;
133
138 [[nodiscard]] std::string deviceName() const;
139
144 [[nodiscard]] bool isHardwareAccelerated() const noexcept;
145
153 [[nodiscard]] static std::vector<std::uint8_t>
155 const render3d::ViewportDimensions &dims,
156 const render3d::RgbaColor &bg_color);
157
158private:
159 void renderLoop();
160 void dispatchFrame(const std::uint8_t *pixel_data, std::uint32_t width, std::uint32_t height);
161
163 std::shared_ptr<std::atomic<bool>> alive_;
164 render3d::ViewportDimensions viewport_dims_{.width = 800, .height = 600};
166 std::unique_ptr<render3d::IRenderEngine> engine_;
167
168 mutable std::mutex mutex_;
169 std::condition_variable cv_;
171 bool render_pending_{false};
172 bool reinit_pending_{false};
173 std::atomic<bool> stop_worker_{false};
174 std::jthread render_worker_;
175};
176
177} // namespace correlation::app
Orbit and arcball camera model for interactive 3D molecular visualization.
Common interface for 3D molecular visualization render engines.
Dynamic level-of-detail (LOD) policy controller for atomic 3D rendering.
Data types, descriptor enums, crystal presets, and telemetry models for Phase Search.
Scene graph and geometric instances (atoms, bonds, lattice lines) for 3D visualization.
Structure3DRenderPipeline(FrameDispatchedCallback callback, std::shared_ptr< std::atomic< bool > > alive=nullptr, std::unique_ptr< render3d::IRenderEngine > engine=nullptr)
Constructs pipeline and starts background rendering worker thread.
Definition Structure3DRenderPipeline.cpp:17
std::string deviceName() const
Human-readable name of the active rendering device (GPU or CPU).
Definition Structure3DRenderPipeline.cpp:106
Structure3DRenderPipeline(const Structure3DRenderPipeline &)=delete
std::atomic< bool > stop_worker_
Definition Structure3DRenderPipeline.hpp:173
render3d::ViewportDimensions viewport_dims_
Definition Structure3DRenderPipeline.hpp:164
void dispatchFrame(const std::uint8_t *pixel_data, std::uint32_t width, std::uint32_t height)
Definition Structure3DRenderPipeline.cpp:143
std::shared_ptr< std::atomic< bool > > alive_
Definition Structure3DRenderPipeline.hpp:163
std::mutex mutex_
Definition Structure3DRenderPipeline.hpp:168
RenderPipelineSnapshot current_snapshot_
Definition Structure3DRenderPipeline.hpp:170
std::function< void(const slint::Image &)> FrameDispatchedCallback
Definition Structure3DRenderPipeline.hpp:63
void renderLoop()
Definition Structure3DRenderPipeline.cpp:162
static std::vector< std::uint8_t > renderSnapshotOffscreen(const RenderPipelineSnapshot &snapshot, const render3d::ViewportDimensions &dims, const render3d::RgbaColor &bg_color)
Renders a high-resolution offscreen snapshot without disturbing the live viewport.
Definition Structure3DRenderPipeline.cpp:115
void updateSnapshot(const RenderPipelineSnapshot &snapshot, bool immediate=false)
Updates active render parameters and triggers an asynchronous frame redraw.
Definition Structure3DRenderPipeline.cpp:61
render3d::ViewportDimensions dimensions() const noexcept
Current viewport pixel dimensions.
Definition Structure3DRenderPipeline.cpp:79
bool reinit_pending_
Definition Structure3DRenderPipeline.hpp:172
Structure3DRenderPipeline & operator=(Structure3DRenderPipeline &&)=delete
~Structure3DRenderPipeline()
Destructor. Signals stop condition and joins worker thread safely.
Definition Structure3DRenderPipeline.cpp:31
bool render_pending_
Definition Structure3DRenderPipeline.hpp:171
Structure3DRenderPipeline & operator=(const Structure3DRenderPipeline &)=delete
std::unique_ptr< render3d::IRenderEngine > engine_
Definition Structure3DRenderPipeline.hpp:166
bool isHardwareAccelerated() const noexcept
Checks whether the active rendering backend is GPU-accelerated.
Definition Structure3DRenderPipeline.cpp:110
std::string backendName() const
Human-readable name of the active rendering backend.
Definition Structure3DRenderPipeline.cpp:102
std::condition_variable cv_
Definition Structure3DRenderPipeline.hpp:169
bool isActive() const noexcept
Checks if the pipeline viewport is currently active.
Definition Structure3DRenderPipeline.cpp:84
FrameDispatchedCallback callback_
Definition Structure3DRenderPipeline.hpp:162
void resize(const render3d::ViewportDimensions &dimensions)
Resizes the underlying framebuffer and viewport.
Definition Structure3DRenderPipeline.cpp:52
Structure3DRenderPipeline(Structure3DRenderPipeline &&)=delete
void initialize(const render3d::ViewportDimensions &dimensions)
Initializes the rendering engine and framebuffer with dimensions.
Definition Structure3DRenderPipeline.cpp:42
void setActive(bool active) noexcept
Sets viewport active status.
Definition Structure3DRenderPipeline.cpp:89
render3d::LodController lod_controller_
Definition Structure3DRenderPipeline.hpp:165
std::jthread render_worker_
Definition Structure3DRenderPipeline.hpp:174
void requestRender(bool immediate=false)
Schedules an asynchronous 3D frame redraw with currently stored parameters.
Definition Structure3DRenderPipeline.cpp:71
Manages camera positioning, orbit rotations, panning, zooming, and view-projection matrices.
Definition Camera3D.hpp:29
Evaluates active LOD policies based on atom count and camera interaction state.
Definition LodController.hpp:40
Definition AppController.hpp:27
PhaseDescriptor
Bond-orientational order parameter descriptors available for phase filtering.
Definition PhaseSearchTypes.hpp:23
@ Q6Bar
Lechner-Dellago averaged q̄₆ (primary crystal symmetry descriptor).
Definition PhaseSearchTypes.hpp:24
Definition Camera3D.hpp:14
Thread-safe capture of parameters required to render a 3D structure frame.
Definition Structure3DRenderPipeline.hpp:34
bool is_interacting
True during active user orbit/pan drag.
Definition Structure3DRenderPipeline.hpp:42
bool gpu_halos_enabled
Definition Structure3DRenderPipeline.hpp:45
bool is_active
Viewport active visibility flag.
Definition Structure3DRenderPipeline.hpp:37
bool depth_cueing
Atmospheric depth cueing toggle.
Definition Structure3DRenderPipeline.hpp:40
bool phase_hide_non_matching
Definition Structure3DRenderPipeline.hpp:53
std::array< float, 4 > phase_halo_color
Definition Structure3DRenderPipeline.hpp:51
bool ssao_enabled
Screen-space ambient occlusion toggle.
Definition Structure3DRenderPipeline.hpp:41
bool phase_dim_non_matching
Definition Structure3DRenderPipeline.hpp:52
render3d::Camera3D camera
Camera viewing transform snapshot.
Definition Structure3DRenderPipeline.hpp:35
float phase_max_threshold
Definition Structure3DRenderPipeline.hpp:48
bool render_bonds
Covalent bond rendering toggle.
Definition Structure3DRenderPipeline.hpp:38
float phase_halo_ratio
Definition Structure3DRenderPipeline.hpp:49
PhaseDescriptor phase_descriptor
Definition Structure3DRenderPipeline.hpp:46
bool render_wireframe
Unit cell wireframe toggle.
Definition Structure3DRenderPipeline.hpp:39
float phase_halo_intensity
Definition Structure3DRenderPipeline.hpp:50
float phase_min_threshold
Definition Structure3DRenderPipeline.hpp:47
std::shared_ptr< render3d::Scene3D > scene
Molecular scene geometry to render.
Definition Structure3DRenderPipeline.hpp:36
Width and height in pixels for the rendering viewport.
Definition IRenderEngine.hpp:26