mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-06 09:37:55 +00:00
G-code post-processing is now a step of the slicing-pipeline plugin rather than a separate capability type. One capability class can transform slices at the geometry seams AND edit the final G-code, behind a single picker/option. - Add SlicingPipelineStepPlugin::psGCodePostProcess (bound as orca.slicing.Step.psGCodePostProcess). Unlike the geometry steps it fires from the GUI export path in PostProcessor.cpp, not from Print::process(): ctx.print/ctx.object are None and the plugin edits the file at ctx.gcode_path in place. It may run more than once per slice (file export and/or upload) and its output is not shown in the preview. - Extend SlicingPipelineContext with gcode_path/host/output_name and a C++-only full_config; config_value() falls back to it when there is no live Print. - PostProcessor.cpp dispatches SlicingPipelinePluginCapability at psGCodePostProcess, driven by the existing slicing_pipeline_plugin option. - The exported G-code lives outside data_dir(), so the plugin audit sandbox would block the write; the trampoline's audit setup grants ctx.gcode_path's folder as a scoped allowed root, gated on a non-empty gcode_path so the geometry-step hooks gain no extra filesystem access. BREAKING CHANGE: the separate G-code post-processing capability type is removed. - orca.gcode.GCodePluginCapabilityBase and orca.PluginType.PostProcessing are gone; post-processing plugins migrate to orca.slicing.SlicingPipelineCapabilityBase + Step.psGCodePostProcess (and gain ctx.params / ctx.config_value()). - The post_process_plugin config option is removed; use slicing_pipeline_plugin. Presets carrying the old key degrade to the standard unknown-key warning. - Manifest type = "post-processing" now maps to Unknown (advisory only; the loader dispatches on the C++ get_type()). Also repairs two latent build breaks the branch carried: stale Step enum value usages in test_slicing_pipeline_hook.cpp and a reference to the removed ConfigOptionDef::PluginType::None in Tab::on_value_change (now is_plugin_backed()). Adds the orca_gcode_stamp sample plugin and a psGCodePostProcess binding test.
41 lines
2.0 KiB
C++
41 lines
2.0 KiB
C++
#ifndef slic3r_GUI_PostProcessor_hpp_
|
|
#define slic3r_GUI_PostProcessor_hpp_
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
|
|
#include "libslic3r/libslic3r.h"
|
|
#include "libslic3r/PrintConfig.hpp"
|
|
|
|
namespace Slic3r {
|
|
|
|
// Run post-processing scripts (the "post_process" option) and/or the slicing-pipeline plugins'
|
|
// Step.psGCodePostProcess seam (the "slicing_pipeline_plugin" option) if defined. Lives in the GUI
|
|
// layer because plugins are executed through the embedded-Python PluginManager, which libslic3r must
|
|
// not depend on.
|
|
// Returns true if a script or plugin was executed.
|
|
// Returns false if neither a post-processing script nor plugin was defined.
|
|
// Throws an exception on error.
|
|
// host is one of "File", "PrusaLink", "Repetier", "SL1Host", "OctoPrint", "FlashAir", "Duet", "AstroBox" ...
|
|
// If make_copy, then a temp file will be created for src_path by adding a ".pp" suffix and src_path will be updated.
|
|
// In that case the caller is responsible to delete the temp file created. Scripts and plugins always
|
|
// run on this working copy so they never touch the original G-code the viewer keeps memory-mapped
|
|
// (a writable open of the mapped file fails on Windows with a sharing violation).
|
|
// output_name is the final name of the G-code on SD card or when uploaded to PrusaLink or OctoPrint.
|
|
// If uploading to PrusaLink or OctoPrint, then the file will be renamed to output_name first on the target host.
|
|
// The post-processing script may change the output_name.
|
|
extern bool run_post_process_scripts(
|
|
std::string& src_path, bool make_copy, const std::string& host, std::string& output_name, const DynamicPrintConfig& config);
|
|
|
|
inline bool run_post_process_scripts(std::string& src_path, const DynamicPrintConfig& config)
|
|
{
|
|
std::string src_path_name = src_path;
|
|
return run_post_process_scripts(src_path, false, "File", src_path_name, config);
|
|
}
|
|
|
|
// BBS
|
|
extern void gcode_add_line_number(const std::string& path, const DynamicPrintConfig& config);
|
|
} // namespace Slic3r
|
|
|
|
#endif /* slic3r_GUI_PostProcessor_hpp_ */
|