mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-24 17:26:47 +00:00
feat: initial draft of lifecycle events API for plugins
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "libslic3r/Config.hpp"
|
||||
#include "libslic3r/Exception.hpp"
|
||||
#include "libslic3r/LifecycleEvents.hpp"
|
||||
#include "libslic3r/Print.hpp"
|
||||
#include "libslic3r_version.h"
|
||||
|
||||
@@ -46,6 +47,16 @@ void install_capability_resolver()
|
||||
});
|
||||
}
|
||||
|
||||
// Global libslic3r-side seam (Slic3r::fire_lifecycle_event, in libslic3r/LifecycleEvents.hpp):
|
||||
// broadcasts to every loaded, enabled capability regardless of type, unlike the SlicingPipeline
|
||||
// hook below which only targets picker-selected SlicingPipeline capabilities.
|
||||
void install_lifecycle_event_hook()
|
||||
{
|
||||
set_lifecycle_hook_fn([](LifecycleEvent event, const LifecycleEventContext& ctx) {
|
||||
PluginManager::instance().dispatch_lifecycle_event(event, ctx);
|
||||
});
|
||||
}
|
||||
|
||||
// Print::process() fires this hook at each pipeline seam on the slicing worker
|
||||
// thread; here we run the picker-selected SlicingPipeline capabilities. Per
|
||||
// capability we acquire the GIL, honor cancellation, and convert a plugin
|
||||
@@ -122,12 +133,14 @@ void install()
|
||||
{
|
||||
install_capability_resolver();
|
||||
install_slicing_pipeline_hook();
|
||||
install_lifecycle_event_hook();
|
||||
}
|
||||
|
||||
void uninstall()
|
||||
{
|
||||
ConfigBase::set_resolve_capability_fn(nullptr);
|
||||
Print::set_slicing_pipeline_hook_fn(nullptr);
|
||||
set_lifecycle_hook_fn(nullptr);
|
||||
}
|
||||
|
||||
} // namespace Slic3r::plugin_hooks
|
||||
|
||||
Reference in New Issue
Block a user