MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / setupPythonBridge

Method setupPythonBridge

src/visualizer/visualizer_impl.cpp:193–558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191 }
192
193 void VisualizerImpl::setupPythonBridge() {
194 python::set_visualizer(this);
195 callback_cleanup_.add([] { python::set_visualizer(nullptr); });
196 python::set_trainer_manager(trainer_manager_.get());
197 callback_cleanup_.add([] { python::set_trainer_manager(nullptr); });
198 python::set_parameter_manager(parameter_manager_.get());
199 callback_cleanup_.add([] { python::set_parameter_manager(nullptr); });
200 python::set_rendering_manager(rendering_manager_.get());
201 callback_cleanup_.add([] { python::set_rendering_manager(nullptr); });
202 python::set_editor_context(&editor_context_);
203 callback_cleanup_.add([] { python::set_editor_context(nullptr); });
204 python::set_operator_callbacks(&editor_context_);
205 callback_cleanup_.add([] { python::set_operator_callbacks(nullptr); });
206 python::set_gui_manager(gui_manager_.get());
207 callback_cleanup_.add([] { python::set_gui_manager(nullptr); });
208 python::set_main_loop_wake_callback(&wakeEventLoopViaServices);
209 callback_cleanup_.add([] { python::set_main_loop_wake_callback(nullptr); });
210 core::reactive::Store::set_wake_callback(&wakeEventLoopViaServices);
211 callback_cleanup_.add([] { core::reactive::Store::set_wake_callback(nullptr); });
212 python::set_scene_generation_callback([](const uint64_t generation) {
213 app_store().scene_generation.set(generation);
214 });
215 callback_cleanup_.add([] { python::set_scene_generation_callback(nullptr); });
216 app_store().scene_generation.set(python::get_scene_generation());
217 auto active_tool_poll_cache_token = std::make_shared<core::reactive::SubscriptionToken>(
218 app_store().active_tool.subscribe([](const std::string&) {
219 gui::PanelRegistry::instance().invalidate_poll_cache();
220 }));
221 callback_cleanup_.add([active_tool_poll_cache_token] {
222 active_tool_poll_cache_token->reset();
223 });
224 python::set_mesh2splat_callbacks(
225 [](std::shared_ptr<core::MeshData> mesh, std::string name, core::Mesh2SplatOptions opts) {
226 auto* gm = python::get_gui_manager();
227 if (!gm)
228 return;
229 gm->asyncTasks().startMesh2Splat(std::move(mesh), name, opts);
230 },
231 []() -> bool {
232 auto* gm = python::get_gui_manager();
233 return gm && gm->asyncTasks().isMesh2SplatActive();
234 },
235 []() -> float {
236 auto* gm = python::get_gui_manager();
237 return gm ? gm->asyncTasks().getMesh2SplatProgress() : 0.0f;
238 },
239 []() -> std::string {
240 auto* gm = python::get_gui_manager();
241 return gm ? gm->asyncTasks().getMesh2SplatStage() : std::string{};
242 },
243 []() -> std::string {
244 auto* gm = python::get_gui_manager();
245 return gm ? gm->asyncTasks().getMesh2SplatError() : std::string{};
246 });
247 callback_cleanup_.add([] { python::set_mesh2splat_callbacks(nullptr, nullptr, nullptr, nullptr, nullptr); });
248 python::set_splat_simplify_callbacks(
249 [](std::string name, core::SplatSimplifyOptions opts) {
250 auto* gm = python::get_gui_manager();

Callers

nothing calls this directly

Calls 15

set_visualizerFunction · 0.85
set_trainer_managerFunction · 0.85
set_parameter_managerFunction · 0.85
set_rendering_managerFunction · 0.85
set_editor_contextFunction · 0.85
set_operator_callbacksFunction · 0.85
set_gui_managerFunction · 0.85
get_scene_generationFunction · 0.85
instanceFunction · 0.85
set_mesh2splat_callbacksFunction · 0.85

Tested by

no test coverage detected