OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::SlicingPipelinePluginCapability Class Referenceabstract

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/plugin/pluginTypes/slicingPipeline/SlicingPipelinePluginCapability.hpp>

Inheritance diagram for Slic3r::SlicingPipelinePluginCapability:
Collaboration diagram for Slic3r::SlicingPipelinePluginCapability:

Public Member Functions

PluginCapabilityType get_type () const override
virtual ExecutionResult execute (SlicingPipelineContext &ctx)=0
virtual std::string get_name () const =0
virtual bool has_config_ui () const
virtual std::string get_config_ui () const
virtual nlohmann::json get_default_config () const
virtual void on_load ()
virtual void on_unload ()
virtual void on_cancelled ()
virtual void on_lifecycle_event (LifecycleEvent event, const LifecycleEventContext &ctx)
const std::string & name () const
PluginCapabilityType type () const
PluginCapabilityId identity () const
void set_resolved_identity (std::string name, PluginCapabilityType type)
bool is_enabled () const
void set_enabled (bool enabled)
bool config_ui_available () const
void set_config_ui_available (bool available)
void set_audit_plugin_key (std::string key)
const std::string & audit_plugin_key () const
void increment () const
void decrement () const
int ref_count () const

Static Public Member Functions

static void RegisterBindings (pybind11::module_ &module)

Private Attributes

std::string m_name
PluginCapabilityType m_type = PluginCapabilityType::Unknown
std::atomic< bool > m_enabled {true}
bool m_config_ui_available = false
std::string m_audit_plugin_key
std::atomic< int > m_refs {0}

Detailed Description

Member Function Documentation

◆ audit_plugin_key()

const std::string & Slic3r::PluginCapabilityInterface::audit_plugin_key ( ) const
inlineinherited
211{ return m_audit_plugin_key; }
std::string m_audit_plugin_key
Definition PythonPluginInterface.hpp:222

References m_audit_plugin_key.

Referenced by Slic3r::PyPrinterAgentPluginCapabilityTrampoline::log_failure().

Here is the caller graph for this function:

◆ config_ui_available()

bool Slic3r::PluginCapabilityInterface::config_ui_available ( ) const
inlineinherited
205{ return m_config_ui_available; }
bool m_config_ui_available
Definition PythonPluginInterface.hpp:221

References m_config_ui_available.

◆ decrement()

void Slic3r::PluginCapabilityInterface::decrement ( ) const
inlineinherited
214{ m_refs.fetch_sub(1, std::memory_order_acq_rel); }
std::atomic< int > m_refs
Definition PythonPluginInterface.hpp:224

References m_refs.

◆ execute()

virtual ExecutionResult Slic3r::SlicingPipelinePluginCapability::execute ( SlicingPipelineContext & ctx)
pure virtual

Implemented in Slic3r::PySlicingPipelinePluginCapabilityTrampoline.

References Slic3r::module().

Referenced by RegisterBindings().

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

◆ get_config_ui()

virtual std::string Slic3r::PluginCapabilityInterface::get_config_ui ( ) const
inlinevirtualinherited

◆ get_default_config()

virtual nlohmann::json Slic3r::PluginCapabilityInterface::get_default_config ( ) const
inlinevirtualinherited

◆ get_name()

virtual std::string Slic3r::PluginCapabilityInterface::get_name ( ) const
pure virtualinherited

◆ get_type()

PluginCapabilityType Slic3r::SlicingPipelinePluginCapability::get_type ( ) const
inlineoverridevirtual

Reimplemented from Slic3r::PluginCapabilityInterface.

@ SlicingPipeline
Definition PythonPluginInterface.hpp:17

References Slic3r::SlicingPipeline.

Referenced by RegisterBindings().

Here is the caller graph for this function:

◆ has_config_ui()

virtual bool Slic3r::PluginCapabilityInterface::has_config_ui ( ) const
inlinevirtualinherited

◆ identity()

PluginCapabilityId Slic3r::PluginCapabilityInterface::identity ( ) const
inlineinherited
189{ return {m_type, m_name, m_audit_plugin_key}; }
std::string m_name
Definition PythonPluginInterface.hpp:218
PluginCapabilityType m_type
Definition PythonPluginInterface.hpp:219

References m_audit_plugin_key, m_name, and m_type.

Referenced by Slic3r::anonymous_namespace{PluginConfig.cpp}::capability_identity().

Here is the caller graph for this function:

◆ increment()

void Slic3r::PluginCapabilityInterface::increment ( ) const
inlineinherited
213{ m_refs.fetch_add(1, std::memory_order_acq_rel); }

References m_refs.

◆ is_enabled()

bool Slic3r::PluginCapabilityInterface::is_enabled ( ) const
inlineinherited
199{ return m_enabled.load(std::memory_order_acquire); }
std::atomic< bool > m_enabled
Definition PythonPluginInterface.hpp:220

References m_enabled.

◆ name()

const std::string & Slic3r::PluginCapabilityInterface::name ( ) const
inlineinherited
187{ return m_name; }

References m_name.

Referenced by Slic3r::PrinterAgentPluginCapability::RegisterBindings(), and set_resolved_identity().

Here is the caller graph for this function:

◆ on_cancelled()

◆ on_lifecycle_event()

virtual void Slic3r::PluginCapabilityInterface::on_lifecycle_event ( LifecycleEvent event,
const LifecycleEventContext & ctx )
inlinevirtualinherited

◆ on_load()

virtual void Slic3r::PluginCapabilityInterface::on_load ( )
inlinevirtualinherited

◆ on_unload()

virtual void Slic3r::PluginCapabilityInterface::on_unload ( )
inlinevirtualinherited

◆ ref_count()

int Slic3r::PluginCapabilityInterface::ref_count ( ) const
inlineinherited
215{ return m_refs.load(std::memory_order_acquire); }

References m_refs.

◆ RegisterBindings()

void Slic3r::SlicingPipelinePluginCapability::RegisterBindings ( pybind11::module_ & module)
static
18 {
19 auto slicing = module.def_submodule("slicing", "Slicing pipeline API (research/experimental).");
20
21 py::enum_<SlicingPipelineStepPlugin>(slicing, "Step")
22 .value("posSlice", SlicingPipelineStepPlugin::posSlice)
23 .value("posPerimeters", SlicingPipelineStepPlugin::posPerimeters)
24 .value("posEstimateCurledExtrusions", SlicingPipelineStepPlugin::posEstimateCurledExtrusions)
25 .value("posPrepareInfill", SlicingPipelineStepPlugin::posPrepareInfill) // after prepare_infill, before make_fills: editing fill_surfaces here CASCADES
26 .value("posInfill", SlicingPipelineStepPlugin::posInfill) // after make_fills: editing fill_surfaces here does NOT regenerate the fills
27 .value("posIroning", SlicingPipelineStepPlugin::posIroning)
28 .value("posContouring", SlicingPipelineStepPlugin::posContouring)
29 .value("posSupportMaterial", SlicingPipelineStepPlugin::posSupportMaterial)
30 .value("posDetectOverhangsForLift", SlicingPipelineStepPlugin::posDetectOverhangsForLift)
31 .value("posSimplifyPath", SlicingPipelineStepPlugin::posSimplifyPath) // covers all simplify sub-steps
32 .value("psWipeTower", SlicingPipelineStepPlugin::psWipeTower)
33 .value("psSkirtBrim", SlicingPipelineStepPlugin::psSkirtBrim)
34 // Post-process seam: fires in the GUI export path AFTER the classic post_process scripts, on the
35 // exported G-code file. Unlike every step above it is NOT fired by Print::process(): ctx.print and
36 // ctx.object are None; instead ctx.gcode_path / ctx.host / ctx.output_name are set and the plugin
37 // edits the file at ctx.gcode_path IN PLACE. May fire more than once per slice (file export and/or
38 // upload each fire once, on separate working copies) and its output is not reflected in the G-code
39 // preview (the viewer maps the pre-post-process file). ctx.config_value() still works.
40 .value("psGCodePostProcess", SlicingPipelineStepPlugin::psGCodePostProcess)
41 .export_values();
42
43 // The read-graph data model (Surface / ExPolygon / the extrusion tree / LayerRegion /
44 // Layer / PrintObject / Print) and the 2D-geometry mutators live in orca.host, registered
45 // by PluginHostSlicing.cpp. orca.slicing is workflow-only: Step, unscale, the context, and
46 // the capability base. See PluginHostSlicing.cpp for the mandatory reference-lifetime rule.
47
48 // Scaled integer coordinate -> millimeters. Reads the live SCALING_FACTOR at call
49 // time (1e-6 normal, 1e-5 for beds > 2147mm), so it is never cached.
50 slicing.def("unscale", [](coord_t v) { return unscale<double>(v); }, py::arg("coord"),
51 "Convert a scaled integer coordinate to millimeters (reads the live SCALING_FACTOR).");
52
53 py::class_<SlicingPipelineContext>(slicing, "SlicingPipelineContext")
54 .def_readonly("orca_version", &SlicingPipelineContext::orca_version)
55 .def_readonly("step", &SlicingPipelineContext::step)
56 .def_readonly("gcode_path", &SlicingPipelineContext::gcode_path,
57 "Path to the working G-code file, set ONLY at Step.psGCodePostProcess. Edit it in "
58 "place; empty at every other step.")
59 .def_readonly("host", &SlicingPipelineContext::host,
60 "Target host at Step.psGCodePostProcess (\"File\", \"OctoPrint\", ...); empty otherwise.")
61 .def_readonly("output_name", &SlicingPipelineContext::output_name,
62 "Final output G-code name at Step.psGCodePostProcess (mirrors SLIC3R_PP_OUTPUT_NAME); "
63 "empty otherwise.")
64 .def_property_readonly("print", [](const SlicingPipelineContext& ctx) -> py::object {
65 if (ctx.print == nullptr)
66 return py::none();
67 return py::cast(ctx.print, py::return_value_policy::reference);
68 }, "The orca.host.Print being sliced — the raw slicing graph, exactly what the "
69 "C++ pipeline walks. Valid only during the execute(ctx) call. For mesh access "
70 "use ctx.print.model() (the Print's snapshot), never orca.host.model().")
71 .def_property_readonly("object", [](const SlicingPipelineContext& ctx) -> py::object {
72 if (ctx.object == nullptr)
73 return py::none();
74 // The hook signature hands objects out as const; they are genuinely mutable
75 // (owned by the Print), so the const_cast is safe — done once here at the
76 // graph entry point so Python steps receive a mutable PrintObject.
77 return py::cast(const_cast<PrintObject*>(ctx.object), py::return_value_policy::reference);
78 }, "orca.host.PrintObject for object-scoped steps, or None for print-wide steps. "
79 "Valid only during the execute(ctx) call.")
80 .def("config_value", [](const SlicingPipelineContext& ctx, const std::string& key) -> py::object {
81 // In-pipeline steps read the live Print's full config; at psGCodePostProcess (print == null)
82 // fall back to the config the export path handed in.
83 if (ctx.print != nullptr)
84 return config_value_or_none(ctx.print->full_print_config(), key);
85 if (ctx.full_config != nullptr)
86 return config_value_or_none(*ctx.full_config, key);
87 return py::none();
88 }, py::arg("key"),
89 "serialized value of a resolved (full) print config option for this slice, or "
90 "None if absent. Shorthand for ctx.print.config_value(key).")
91 .def("cancelled", &SlicingPipelineContext::cancelled);
92
93 py::class_<SlicingPipelinePluginCapability, PluginCapabilityInterface,
94 PySlicingPipelinePluginCapabilityTrampoline,
95 std::shared_ptr<SlicingPipelinePluginCapability>>(slicing, "SlicingPipelineCapabilityBase")
96 .def(py::init<>())
99}
virtual ExecutionResult execute(SlicingPipelineContext &ctx)=0
PluginCapabilityType get_type() const override
Definition SlicingPipelinePluginCapability.hpp:37
int64_t coord_t
Definition libslic3r.h:48
pybind11::object config_value_or_none(const ConfigBase &config, const std::string &key)
Definition PluginBindingUtils.hpp:79
T unscale(Q v)
Definition libslic3r.h:138
@ posIroning
Definition Print.hpp:133
@ psWipeTower
Definition Print.hpp:134
@ posInfill
Definition Print.hpp:133
@ psGCodePostProcess
Definition Print.hpp:137
@ posDetectOverhangsForLift
Definition Print.hpp:134
@ posPerimeters
Definition Print.hpp:133
@ posEstimateCurledExtrusions
Definition Print.hpp:133
@ psSkirtBrim
Definition Print.hpp:134
@ posPrepareInfill
Definition Print.hpp:133
@ posSlice
Definition Print.hpp:133
@ posSimplifyPath
Definition Print.hpp:134
@ posSupportMaterial
Definition Print.hpp:134
@ posContouring
Definition Print.hpp:133
SlicingPipelineStepPlugin step
Definition SlicingPipelinePluginCapability.hpp:19
bool cancelled() const
Definition SlicingPipelinePluginCapability.cpp:16
std::string orca_version
Definition SlicingPipelinePluginCapability.hpp:18
std::string host
Definition SlicingPipelinePluginCapability.hpp:27
std::string gcode_path
Definition SlicingPipelinePluginCapability.hpp:26
std::string output_name
Definition SlicingPipelinePluginCapability.hpp:28

References Slic3r::SlicingPipelineContext::cancelled(), Slic3r::config_value_or_none(), execute(), Slic3r::SlicingPipelineContext::full_config, Slic3r::PrintBase::full_print_config(), Slic3r::SlicingPipelineContext::gcode_path, get_type(), Slic3r::SlicingPipelineContext::host, Slic3r::module(), Slic3r::SlicingPipelineContext::object, Slic3r::SlicingPipelineContext::orca_version, Slic3r::SlicingPipelineContext::output_name, Slic3r::posContouring, Slic3r::posDetectOverhangsForLift, Slic3r::posEstimateCurledExtrusions, Slic3r::posInfill, Slic3r::posIroning, Slic3r::posPerimeters, Slic3r::posPrepareInfill, Slic3r::posSimplifyPath, Slic3r::posSlice, Slic3r::posSupportMaterial, Slic3r::SlicingPipelineContext::print, Slic3r::psGCodePostProcess, Slic3r::psSkirtBrim, Slic3r::psWipeTower, Slic3r::SlicingPipelineContext::step, and Slic3r::unscale().

Referenced by Slic3r::bind_python_api().

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

◆ set_audit_plugin_key()

void Slic3r::PluginCapabilityInterface::set_audit_plugin_key ( std::string key)
inlineinherited
210{ m_audit_plugin_key = std::move(key); }

References m_audit_plugin_key.

◆ set_config_ui_available()

void Slic3r::PluginCapabilityInterface::set_config_ui_available ( bool available)
inlineinherited
206{ m_config_ui_available = available; }

References m_config_ui_available.

◆ set_enabled()

void Slic3r::PluginCapabilityInterface::set_enabled ( bool enabled)
inlineinherited
200{ m_enabled.store(enabled, std::memory_order_release); }

References m_enabled.

◆ set_resolved_identity()

void Slic3r::PluginCapabilityInterface::set_resolved_identity ( std::string name,
PluginCapabilityType type )
inlineinherited
191 {
192 m_name = std::move(name);
193 m_type = type;
194 }
PluginCapabilityType type() const
Definition PythonPluginInterface.hpp:188
const std::string & name() const
Definition PythonPluginInterface.hpp:187

References m_name, m_type, name(), and type().

Here is the call graph for this function:

◆ type()

PluginCapabilityType Slic3r::PluginCapabilityInterface::type ( ) const
inlineinherited
188{ return m_type; }

References m_type.

Referenced by set_resolved_identity().

Here is the caller graph for this function:

Member Data Documentation

◆ m_audit_plugin_key

std::string Slic3r::PluginCapabilityInterface::m_audit_plugin_key
privateinherited

◆ m_config_ui_available

bool Slic3r::PluginCapabilityInterface::m_config_ui_available = false
privateinherited

◆ m_enabled

std::atomic<bool> Slic3r::PluginCapabilityInterface::m_enabled {true}
privateinherited
220{true};

Referenced by is_enabled(), and set_enabled().

◆ m_name

std::string Slic3r::PluginCapabilityInterface::m_name
privateinherited

◆ m_refs

std::atomic<int> Slic3r::PluginCapabilityInterface::m_refs {0}
mutableprivateinherited
224{0};

Referenced by decrement(), increment(), and ref_count().

◆ m_type

PluginCapabilityType Slic3r::PluginCapabilityInterface::m_type = PluginCapabilityType::Unknown
privateinherited

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