Merge upstream/main and refine exclusion-volume configuration UI

This commit is contained in:
Harry Loud committed 2026-10-09 18:27:44 +01:00
commit 2c0ce5c38b
4547 files changed
+2646026 -2483438

No files matched your search

+568 -68
View File
@@ -1,7 +1,12 @@
#include "PrintConfig.hpp"
#include "CommonDefs.hpp"
#include "Point.hpp"
#include "Polygon.hpp"
#include "PrintConfigConstants.hpp"
#include "BeltTransform.hpp"
#include "ClipperUtils.hpp"
#include "Config.hpp"
#include "Geometry.hpp"
#include "FilamentMixer.hpp"
#include "MaterialType.hpp"
#include "I18N.hpp"
@@ -13,6 +18,22 @@
#include <cctype>
#include <cmath>
#include <iterator>
#include "enum_bitmask.hpp"
#include <numeric>
#include <cstddef>
#include <cassert>
#include <map>
#include <boost/algorithm/string/classification.hpp>
#include <cstdlib>
#include "libslic3r.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/constants.hpp>
#include <limits>
#include <memory>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/tuple/to_seq.hpp>
#include <cstdint>
#include <set>
#include <optional>
#include <boost/algorithm/string.hpp>
@@ -25,6 +46,11 @@
#include <boost/log/trivial.hpp>
#include <boost/thread.hpp>
#include <float.h>
#include <string>
#include <vector>
#include <utility>
#include <sstream>
#include <unordered_map>
namespace {
std::set<std::string> SplitStringAndRemoveDuplicateElement(const std::string &str, const std::string &separator)
@@ -113,6 +139,15 @@ size_t get_extruder_index(const GCodeConfig& config, unsigned int filament_id)
return 0;
}
double nozzle_diameter_for_filament(const PrintConfig& config, int filament_id, bool is_bbl_printer)
{
int extruder = filament_id;
if (is_bbl_printer && config.nozzle_diameter.size() > 1 &&
filament_id >= 1 && static_cast<size_t>(filament_id - 1) < config.filament_map.size())
extruder = config.filament_map.get_at(filament_id - 1);
return config.nozzle_diameter.get_at(extruder - 1);
}
// Orca: input shaping values types by flavor
std::vector<std::string> get_shaper_type_values_for_flavor(GCodeFlavor flavor)
@@ -333,6 +368,26 @@ static t_config_enum_values s_keys_map_SurfaceFillOrder{
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(SurfaceFillOrder)
//Orca
static t_config_enum_values s_keys_map_TpmsAdaptiveMode{
{ "disabled", int(TpmsAdaptiveMode::Disabled) },
{ "distance_warp", int(TpmsAdaptiveMode::DistanceWarp) },
{ "smooth_blend", int(TpmsAdaptiveMode::SmoothBlend) },
{ "stepped_shells", int(TpmsAdaptiveMode::SteppedShells) },
{ "lobes", int(TpmsAdaptiveMode::Lobes) },
{ "normal_z", int(TpmsAdaptiveMode::NormalZ) },
{ "normal_y", int(TpmsAdaptiveMode::NormalY) },
{ "normal_x", int(TpmsAdaptiveMode::NormalX) },
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(TpmsAdaptiveMode)
static t_config_enum_values s_keys_map_TpmsAdaptiveGradient{
{ "linear", int(TpmsAdaptiveGradient::Linear) },
{ "quadratic", int(TpmsAdaptiveGradient::Quadratic) },
{ "exponential", int(TpmsAdaptiveGradient::Exponential) },
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(TpmsAdaptiveGradient)
//BBS
static t_config_enum_values s_keys_map_PrintSequence {
{ "by layer", int(PrintSequence::ByLayer) },
@@ -355,6 +410,27 @@ static t_config_enum_values s_keys_map_SlicingMode {
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(SlicingMode)
static t_config_enum_values s_keys_map_BeltRotationAxis {
{ "none", int(BeltRotationAxis::None) },
{ "x", int(BeltRotationAxis::X) },
{ "y", int(BeltRotationAxis::Y) },
{ "z", int(BeltRotationAxis::Z) },
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(BeltRotationAxis)
static t_config_enum_values s_keys_map_RemapAxis {
{ "pos_x", int(RemapAxis::PosX) },
{ "pos_y", int(RemapAxis::PosY) },
{ "pos_z", int(RemapAxis::PosZ) },
{ "neg_x", int(RemapAxis::NegX) },
{ "neg_y", int(RemapAxis::NegY) },
{ "neg_z", int(RemapAxis::NegZ) },
{ "rev_x", int(RemapAxis::RevX) },
{ "rev_y", int(RemapAxis::RevY) },
{ "rev_z", int(RemapAxis::RevZ) },
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(RemapAxis)
static t_config_enum_values s_keys_map_SupportMaterialPattern {
{ "rectilinear", smpRectilinear },
{ "rectilinear-grid", smpRectilinearGrid },
@@ -471,6 +547,7 @@ static const t_config_enum_values s_keys_map_BrimType = {
{"auto_brim", btAutoBrim}, // BBS
{"brim_ears", btEar}, // Orca
{"painted", btPainted}, // BBS
{"leading_edge_only", btLeadingEdgeOnly}, // belt printers
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(BrimType)
@@ -685,19 +762,46 @@ std::string get_extruder_variant_string(ExtruderType extruder_type, NozzleVolume
return variant_string;
}
int find_variant_index(const std::string& variant, int variant_id_1based, const std::vector<std::string>& variant_list, const std::vector<int>& variant_ids_1based)
{
const int count = int(variant_list.empty() ? variant_ids_1based.size() : variant_list.size());
if (count == 0)
return 0;
auto same_id = [&](int index) {
return variant_id_1based < 0 || variant_ids_1based.empty() || (index < int(variant_ids_1based.size()) && variant_ids_1based[index] == variant_id_1based);
};
for (int index = 0; index < int(variant_list.size()); ++index)
if (variant_list[index] == variant && same_id(index))
return index;
// Without this variant, use the id's own first variant (usually Standard), not variant index 0,
// which belongs to the first filament or extruder.
for (int index = 0; index < count; ++index)
if (same_id(index))
return index;
return -1;
}
std::vector<int> map_variant_indices(const std::vector<std::string>& variants, const std::vector<int>& ids,
const std::vector<std::string>& from_variants, const std::vector<int>& from_ids)
{
const size_t count = variants.empty() ? ids.size() : variants.size();
std::vector<int> variant_index(count);
for (size_t index = 0; index < count; ++index) {
if (!ids.empty() && index >= ids.size()) {
variant_index[index] = -1;
continue;
}
variant_index[index] = find_variant_index(index < variants.size() ? variants[index] : std::string(),
ids.empty() ? -1 : ids[index], from_variants, from_ids);
}
return variant_index;
}
int get_config_index_base(NozzleVolumeType volume_type, ExtruderType extruder_type, int variant_id_1based, const std::vector<std::string>& variant_list, const std::vector<int>& variant_ids_1based)
{
assert(variant_list.size() == variant_ids_1based.size());
std::string extruder_variant = get_extruder_variant_string(extruder_type, volume_type);
for (int index = 0; index < int(variant_list.size()); ++index) {
if (extruder_variant == variant_list[index] && variant_ids_1based[index] == variant_id_1based) { return index; }
}
// Without this variant, use the id's own first variant (usually Standard), not variant index 0,
// which belongs to the first filament or extruder.
for (int index = 0; index < int(variant_list.size()); ++index) {
if (variant_ids_1based[index] == variant_id_1based) { return index; }
}
return 0;
const int index = find_variant_index(get_extruder_variant_string(extruder_type, volume_type), variant_id_1based, variant_list, variant_ids_1based);
return std::max(index, 0);
}
std::set<NozzleVolumeType> get_extruder_supported_nozzle_volume_types(const DynamicPrintConfig &printer_config, int extruder_id)
@@ -915,27 +1019,27 @@ void PrintConfigDef::init_common_params()
//BBS: add "bed_exclude_area"
def = this->add("bed_exclude_area", coPoints);
def->label = L("Excluded bed area (legacy)");
def->label = L("Excluded bed area");
def->tooltip = L("Unprintable area in XY plane. For example, X1 Series printers use the front left corner to cut filament during filament change. "
"The area is expressed as a polygon in the format \"XxY, XxY, ...\". Legacy areas constrain model placement, "
"but do not check or reroute machine travel. Configure exclusion volumes below for full collision checking.");
"The area is expressed as a polygon in the format \"XxY, XxY, ...\". It constrains material and model placement, "
"but allows machine travel. Configure toolhead collision volumes separately for G-code checking and travel avoidance.");
def->mode = comAdvanced;
def->gui_type = ConfigOptionDef::GUIType::one_string;
def->set_default_value(new ConfigOptionPoints{ Vec2d(0, 0) });
def = this->add("bed_exclude_volumes", coString);
def->label = L("Exclusion volumes");
def->label = L("Toolhead collision volumes");
def->tooltip = L("Collision volumes used for model and generated-material exclusion, G-code checking, and travel avoidance. "
"Use \"XxY, XxY, ...\" for a full-height polygon or \"ZMIN..ZMAX;XxY, XxY, ...\" for a Z-limited volume. "
"Separate multiple volumes with \"|\". These volumes are additional to any legacy excluded bed area. "
"Separate multiple volumes with \"|\". These volumes are additional to the excluded bed area. "
"Automatic arrangement conservatively uses the bounding box of a non-convex volume.");
def->mode = comAdvanced;
def->gui_type = ConfigOptionDef::GUIType::one_string;
def->set_default_value(new ConfigOptionString());
def = this->add("bed_exclude_volume_mode", coEnum);
def->label = L("Exclusion volume behaviour");
def->tooltip = L("Choose whether all nozzles use the same exclusion volumes, derive toolhead-relative volumes from each nozzle's XY offset, or configure independent volumes for every extruder. In individual mode, configure the volumes on each Extruder page.");
def->label = L("Collision volume behaviour");
def->tooltip = L("Choose whether all nozzles use the same exclusion volumes, derive toolhead-relative volumes from each nozzle's XY offset, or configure independent volumes for every extruder. In individual mode, select each extruder on the Extruder page to configure its volumes.");
def->enum_keys_map = &ConfigOptionEnum<BedExcludeVolumeMode>::get_enum_values();
def->enum_values = { "shared", "toolhead_offset", "per_extruder" };
def->enum_labels = { L("Shared"), L("Toolhead-relative (nozzle offsets)"), L("Individual per extruder") };
@@ -943,7 +1047,7 @@ void PrintConfigDef::init_common_params()
def->set_default_value(new ConfigOptionEnum<BedExcludeVolumeMode>(BedExcludeVolumeMode::Shared));
def = this->add("extruder_bed_exclude_volumes", coStrings);
def->label = L("Extruder exclusion volumes");
def->label = L("Extruder collision volumes");
def->tooltip = L("Collision volumes used only by this extruder in individual mode. Use the same polygon and optional Z-range format as the shared exclusion volumes. Leave empty for no exclusion volumes on this extruder. Automatic arrangement conservatively uses the bounding box of a non-convex volume.");
def->mode = comAdvanced;
def->gui_type = ConfigOptionDef::GUIType::one_string;
@@ -1923,6 +2027,45 @@ void PrintConfigDef::init_fff_params()
def->mode = comSimple;
def->set_default_value(new ConfigOptionFloat(0.));
def = this->add("leading_brim_length", coFloat);
def->label = L("Leading brim length");
def->category = L("Support");
def->tooltip = L("Belt printers only. Extends the brim AHEAD of the object along the belt, on "
"every downhill-facing edge of its contact area - both the object's first "
"contact with the belt and any island that lands later. This apron is laid "
"onto the belt before the object reaches it, so the leading edge has "
"something already stuck down to hold on to.\n\n"
"Measured on the belt surface, and added on top of Brim width: the brim "
"reaches Brim-object gap + Leading brim length + Brim width ahead of the "
"object. Set Brim-object gap to 0, or the apron will not touch the object it "
"is meant to anchor.\n\n"
"On a tilted belt each layer lays one strip of the brim, so the thickness of "
"the resulting brim sheet is set by flow rather than by layer height. Use "
"Brim flow ratio to tune it.\n\n"
"Set to 0 to disable.");
def->sidetext = L("mm"); // millimeters, CIS languages need translation
def->min = 0;
def->max = 100;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0.));
def = this->add("extra_brim_width", coFloat);
def->label = L("Extra brim width");
def->category = L("Support");
def->tooltip = L("Belt printers only. Widens the brim SIDEWAYS, across the belt, without "
"extending it further ahead of or behind the object. Use it when a part needs "
"more grip along its length than Brim width alone gives.\n\n"
"Measured on the belt surface, and added on top of Brim width: the brim "
"reaches Brim-object gap + Brim width + Extra brim width to either side of "
"the object. To extend the brim ahead of the object instead, use Leading brim "
"length.\n\n"
"Set to 0 to disable.");
def->sidetext = L("mm"); // millimeters, CIS languages need translation
def->min = 0;
def->max = 100;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0.));
def = this->add("brim_type", coEnum);
def->label = L("Brim type");
def->category = L("Support");
@@ -1936,6 +2079,7 @@ void PrintConfigDef::init_fff_params()
def->enum_values.emplace_back("inner_only");
def->enum_values.emplace_back("outer_and_inner");
def->enum_values.emplace_back("no_brim");
def->enum_values.emplace_back("leading_edge_only");
def->enum_labels.emplace_back(L("Auto"));
def->enum_labels.emplace_back(L("Mouse ear"));
def->enum_labels.emplace_back(L("Painted"));
@@ -1943,6 +2087,7 @@ void PrintConfigDef::init_fff_params()
def->enum_labels.emplace_back(L("Inner brim only"));
def->enum_labels.emplace_back(L("Outer and inner brim"));
def->enum_labels.emplace_back(L("No-brim"));
def->enum_labels.emplace_back(L("Leading edge only"));
def->mode = comSimple;
def->set_default_value(new ConfigOptionEnum<BrimType>(btAutoBrim));
@@ -3533,6 +3678,73 @@ void PrintConfigDef::init_fff_params()
def->max = 10; // Maximum number of lines for infill pattern
def->set_default_value(new ConfigOptionInt(1));
def = this->add("tpms_adaptive", coEnum);
def->label = L("Adaptive density (experimental)");
def->category = L("Strength");
def->tooltip = L("Grades the Gyroid and TPMS infill inside the object: its cells grow from the surface of the "
"object towards its center. The sparse infill density is used at the surface and the interior "
"density at the center.\n"
"Distance warp, Smooth blend and Stepped shells follow the distance to the nearest surface, "
"including the top and bottom, with the interior density at the point farthest from it:\n"
" - Distance warp: one continuous pattern, stretched and sheared where the distance changes "
"across directions, as in plates and long parts.\n"
" - Smooth blend: the patterns of neighbouring densities blended into each other, with small "
"loops where they meet.\n"
" - Stepped shells: shells of the regular pattern at densities about 1.5 times apart, their "
"lines joined along the shell boundaries.\n"
" - Lobes: follows the 3D shape of the object, including its top and bottom. Every lobe, a part "
"joined to the rest by a narrower neck, is graded towards its own center.\n"
" - Normal Z, Y or X: follows the sections of the object normal to that axis, so the density "
"does not change along it.");
def->enum_keys_map = &ConfigOptionEnum<TpmsAdaptiveMode>::get_enum_values();
def->enum_values.push_back("disabled");
def->enum_values.push_back("distance_warp");
def->enum_values.push_back("smooth_blend");
def->enum_values.push_back("stepped_shells");
def->enum_values.push_back("lobes");
def->enum_values.push_back("normal_z");
def->enum_values.push_back("normal_y");
def->enum_values.push_back("normal_x");
def->enum_labels.push_back(L("Disabled"));
def->enum_labels.push_back(L("Distance warp"));
def->enum_labels.push_back(L("Smooth blend"));
def->enum_labels.push_back(L("Stepped shells"));
def->enum_labels.push_back(L("Lobes"));
def->enum_labels.push_back(L("Normal Z"));
def->enum_labels.push_back(L("Normal Y"));
def->enum_labels.push_back(L("Normal X"));
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnum<TpmsAdaptiveMode>(TpmsAdaptiveMode::Disabled));
def = this->add("tpms_interior_density", coPercent);
def->label = L("Interior density");
def->category = L("Strength");
def->tooltip = L("Density of the adaptive infill at the center of the object.");
def->sidetext = "%";
def->min = 1;
def->max = 100;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionPercent(5));
def = this->add("tpms_adaptive_gradient", coEnum);
def->label = L("Adaptive gradient");
def->category = L("Strength");
def->tooltip = L("How the density changes from the surface to the center of the object.\n"
"Linear: the density changes at a constant rate.\n"
"Quadratic: the density stays close to the sparse infill density near the surface and "
"changes faster towards the center.\n"
"Exponential: the density changes quickly just below the surface and levels off towards "
"the center.");
def->enum_keys_map = &ConfigOptionEnum<TpmsAdaptiveGradient>::get_enum_values();
def->enum_values.push_back("linear");
def->enum_values.push_back("quadratic");
def->enum_values.push_back("exponential");
def->enum_labels.push_back(L("Linear"));
def->enum_labels.push_back(L("Quadratic"));
def->enum_labels.push_back(L("Exponential"));
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionEnum<TpmsAdaptiveGradient>(TpmsAdaptiveGradient::Linear));
// Z-buckling bias optimization (experimental). Tightens the gyroid wave along the Z
// (vertical) axis at low infill density to shorten the effective column length under
// Z-axis compression. Filament use at the same `sparse_infill_density` setting is
@@ -4561,6 +4773,13 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("infill_complete_top", coBool);
def->label = L("Fill pattern tops");
def->category = L("Strength");
def->tooltip = L("Choose this option if you want to completely fill in the tops of the infill pattern");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(false));
// Orca: max layer height for combined infill
def = this->add("infill_combination_max_layer_height", coFloatOrPercent);
def->label = L("Infill combination - Max layer height");
@@ -5288,7 +5507,7 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionEnum<InputShaperType>(InputShaperType::Default));
def = this->add("input_shaping_freq_x", coFloat);
def->label = L("X");
def->label = L_CONTEXT("X", "Axis");
def->tooltip = L("Resonant frequency for the X axis input shaper.\nZero will use the firmware frequency.\nTo disable input shaping, use the Disable type.\nRRF: X and Y values are equal.");
def->sidetext = L("Hz"); // Hertz, CIS languages need translation
def->min = 0;
@@ -5297,7 +5516,7 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionFloat(0));
def = this->add("input_shaping_freq_y", coFloat);
def->label = L("Y");
def->label = L_CONTEXT("Y", "Axis");
def->tooltip = L("Resonant frequency for the Y axis input shaper.\nZero will use the firmware frequency.\nTo disable input shaping, use the Disable type.");
def->sidetext = L("Hz"); // Hertz, CIS languages need translation
def->min = 0;
@@ -5306,7 +5525,7 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionFloat(0));
def = this->add("input_shaping_damp_x", coFloat);
def->label = L("X");
def->label = L_CONTEXT("X", "Axis");
def->tooltip = L("Damping ratio for the X axis input shaper.\nZero will use the firmware damping ratio.\nTo disable input shaping, use the Disable type.\nRRF: X and Y values are equal.");
def->min = 0;
def->max = 1;
@@ -5314,7 +5533,7 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionFloat(0.1));
def = this->add("input_shaping_damp_y", coFloat);
def->label = L("Y");
def->label = L_CONTEXT("Y", "Axis");
def->tooltip = L("Damping ratio for the Y axis input shaper.\nZero will use the firmware damping ratio.\nTo disable input shaping, use the Disable type.");
def->min = 0;
def->max = 1;
@@ -7242,6 +7461,166 @@ void PrintConfigDef::init_fff_params()
def->mode = comSimple;
def->set_default_value(new ConfigOptionFloatOrPercent(50., true));
def = this->add("build_plate_tilt_x", coFloat);
def->label = L("Build plate tilt X");
def->category = L("Support");
def->tooltip = L("Tilt angle of the build plate along the X axis. "
"A positive value tilts the plate so the +X side is higher, shifting gravity toward -X and increasing overhangs on the +X side. "
"A negative value tilts the -X side higher. Set to 0 for no X-axis tilt. "
"In belt printer mode, this is automatically synced to the belt angle.");
def->sidetext = u8"\u00B0";
def->min = -89;
def->max = 89;
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0.));
def = this->add("build_plate_tilt_y", coFloat);
def->label = L("Build plate tilt Y");
def->category = L("Support");
def->tooltip = L("Tilt angle of the build plate along the Y axis. "
"A positive value tilts the plate so the +Y side is higher, shifting gravity toward -Y and increasing overhangs on the +Y side. "
"A negative value tilts the -Y side higher. Set to 0 for no Y-axis tilt.");
def->sidetext = u8"\u00B0";
def->min = -89;
def->max = 89;
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0.));
def = this->add("belt_printer", coBool);
def->label = L("Enable belt printing");
def->category = L("Printable space");
def->tooltip = L("Enable belt printer mode. Belt printers use a conveyor belt as the build surface, "
"tilted at an angle (typically 45 degrees). The slicer will rotate the slicing plane "
"and transform G-code coordinates for the tilted build surface.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("belt_printer_infinite_y", coBool);
def->label = L("Infinite Y axis");
def->category = L("Printable space");
def->tooltip = L("Enable infinite Y axis for belt printers. "
"When enabled, the Y axis build volume limit is effectively removed, "
"allowing objects of any length to be printed along the belt direction.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(true));
// Mesh rotation applied before slicing — the sole mesh-side belt transform AND
// the single source of truth for the physical belt tilt (bed rendering, support
// gravity tilt and bed-exclusion projection all derive their angle from this).
def = this->add("belt_slice_rotation", coEnum);
def->label = L("Belt tilt axis");
def->category = L("Printable space");
def->tooltip = L("Axis the mesh is rotated about before slicing. This is the belt "
"printer's tilt: an isometric (no distortion) rotation that also "
"drives bed rendering and support gravity tilt, and that the g-code "
"back-transform inverts before the machine-frame shear/scale and remap. "
"X is the typical gantry tilt (belt travels along Y).");
def->enum_keys_map = &ConfigOptionEnum<BeltRotationAxis>::get_enum_values();
def->enum_values = {"none", "x", "y", "z"};
def->enum_labels = {L("None"), L("X"), L("Y"), L("Z")};
def->mode = comDevelop;
def->set_default_value(new ConfigOptionEnum<BeltRotationAxis>(BeltRotationAxis::X));
def = this->add("belt_slice_rotation_angle", coFloat);
def->label = L("Belt tilt angle");
def->category = L("Printable space");
def->tooltip = L("Tilt angle of the belt surface, in degrees. Most belt printers use "
"45°. Positive values rotate counter-clockwise looking down the "
"positive tilt axis; the magnitude is also the physical belt tilt "
"used for bed rendering and support gravity.");
def->sidetext = L("°");
def->min = -180.;
def->max = 180.;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(45.));
def = this->add("belt_frame_tilt_decouple", coBool);
def->label = L("Decouple machine-frame tilt");
def->category = L("Printable space");
def->tooltip = L("Expert override: set the machine-frame (g-code shear/scale) tilt angle "
"independently of the pre-slice rotation angle. When disabled, the "
"machine-frame transform is derived from the belt tilt angle, so a single "
"angle drives both stages. Enable only to compensate for a machine whose "
"physical gantry tilt differs from the slicing rotation.");
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("belt_frame_tilt_angle", coFloat);
def->label = L("Machine-frame tilt angle");
def->category = L("Printable space");
def->tooltip = L("Tilt angle (degrees) used to derive the machine-frame shear (cot) and "
"scale (1/|sin|) applied to G-code. Only used when 'Decouple machine-frame "
"tilt' is enabled; otherwise the belt tilt angle is used.");
def->sidetext = L("°");
def->min = -89.9;
def->max = 89.9;
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(45.));
// G-code axis remap with sign. Each field is its own row in the settings tab. The
// labels and tooltips are literals in L() so they are extracted for translation.
auto add_belt_remap = [this](const char *key, const std::string &label, const std::string &tooltip,
RemapAxis default_axis, ConfigOptionMode mode) {
auto def = this->add(key, coEnum);
def->label = label;
def->category = L("Printable space");
def->tooltip = tooltip;
def->enum_keys_map = &ConfigOptionEnum<RemapAxis>::get_enum_values();
def->enum_values = {"pos_x", "pos_y", "pos_z", "neg_x", "neg_y", "neg_z", "rev_x", "rev_y", "rev_z"};
def->enum_labels = {L("+X"), L("+Y"), L("+Z"), L("-X"), L("-Y"), L("-Z"), L("Rev X"), L("Rev Y"), L("Rev Z")};
def->mode = mode; // Visibility may also be gated by toggle_line in Tab.cpp
def->set_default_value(new ConfigOptionEnum<RemapAxis>(default_axis));
};
add_belt_remap("gcode_remap_x", L("G-code remap X"),
L("Which slicing axis maps to machine X in G-code output. Applied AFTER slicing, during G-code generation."),
RemapAxis::PosX, comDevelop);
add_belt_remap("gcode_remap_y", L("G-code remap Y"),
L("Which slicing axis maps to machine Y in G-code output. Applied AFTER slicing, during G-code generation."),
RemapAxis::PosY, comDevelop);
add_belt_remap("gcode_remap_z", L("G-code remap Z"),
L("Which slicing axis maps to machine Z in G-code output. Applied AFTER slicing, during G-code generation."),
RemapAxis::PosZ, comDevelop);
// The machine-frame G-code transform (shear + scale) is no longer configured
// by per-axis keys: it is derived from the belt tilt (belt_slice_rotation axis
// + angle, or belt_frame_tilt_angle when decoupled) in MachineFrameTransform.
// Belt support floor debug controls
def = this->add("belt_support_floor_offset", coFloat);
def->label = L("Support Floor Z offset");
def->category = L("Printable space");
def->tooltip = L("Shifts the computed belt floor up or down (mm). Negative values lower the floor, allowing more supports to survive. Use this to diagnose belt floor formula issues.");
def->sidetext = L("mm");
def->min = -500;
def->max = 500;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0));
def = this->add("enable_belt_purge_tower", coBool);
def->label = L("Enable belt purge tower");
def->category = L("Multimaterial");
def->tooltip = L("Belt-printer replacement for the wipe/prime tower. When enabled on a belt "
"printer, a purge prism is automatically generated next to the printed parts "
"and filament-change purging is routed into it (the classic wipe tower cannot "
"be used on belt printers because its G-code bypasses the belt transform). "
"Only available on belt printers.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("belt_purge_tower_width", coFloat);
def->label = L("Belt purge tower width");
def->category = L("Printable space");
def->tooltip = L("Width (machine X, across the belt) of the purge prism that is automatically "
"generated on belt printers when the belt purge tower is enabled and multiple "
"filaments are used. Filament-change purging is routed into this prism's "
"extrusions instead of a classic wipe tower. Its height is computed "
"automatically from the worst-case purge volume per layer: a wider prism "
"results in a shorter one.");
def->sidetext = L("mm");
def->min = 1.;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(35.));
def = this->add("tree_support_branch_angle", coFloat);
def->label = L("Tree support branch angle");
def->category = L("Support");
@@ -7582,8 +7961,8 @@ void PrintConfigDef::init_fff_params()
"whole assembly. Parts that touch or overlap are treated as one body and share a center; separate parts "
"(or distinct 3D objects) each get their own.\n"
"Useful when an assembly groups several objects that should each keep a consistent, self-centered infill.\n"
"Affects line and grid patterns and rotation-template infills.\n"
"Patterns locked to global coordinates (Gyroid, Honeycomb, TPMS, ...) are unaffected.");
"Adaptive Cubic and Support Cubic always center each part on itself, and Lightning infill is generated for "
"the whole object and is unaffected.");
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(false));
@@ -7895,6 +8274,16 @@ void PrintConfigDef::init_fff_params()
"It will not take effect unless the prime tower is enabled.");
def->set_default_value(new ConfigOptionBool(false));
// Internal marker (not shown in any settings tab): identifies the auto-generated
// belt purge prism so it can be updated/removed by the auto-manager and aligned
// to the object layer grid by the backend. Persisted to 3mf like any per-object key.
def = this->add("belt_purge_tower_object", coBool);
def->category = L("Flush options");
def->label = L("Belt purge tower object");
def->tooltip = L("Marks the auto-generated belt purge prism. Managed automatically; do not set manually.");
def->mode = comDevelop;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("wipe_tower_bridging", coFloat);
def->label = L("Maximal bridging distance");
def->tooltip = L("Maximal distance between supports on sparse infill sections.");
@@ -8517,14 +8906,14 @@ void PrintConfigDef::init_sla_params()
def = this->add("display_pixels_x", coInt);
//def->full_label = L("");
def->label = ("X");
def->label = L_CONTEXT("X", "Axis");
//def->tooltip = L("");
def->min = 100;
def->set_default_value(new ConfigOptionInt(2560));
def = this->add("display_pixels_y", coInt);
//def->full_label = L("");
def->label = ("Y");
def->label = L_CONTEXT("Y", "Axis");
//def->tooltip = L("");
def->min = 100;
def->set_default_value(new ConfigOptionInt(1440));
@@ -9379,6 +9768,13 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
"smooth_coefficient", "overhang_totally_speed", "silent_mode",
"overhang_speed_classic",
"anisotropic_surfaces", // superseded by top_surface_fill_order / bottom_surface_fill_order
// Belt printer keys retired before the first release: the global-mode and
// back-transform switches are presumed on, and the pre-slice axis remap, the
// support Z offset mode, the support floor mode (always on) and the first-layer
// plane evaluator were removed.
"belt_slice_rotation_global", "preslice_remap_x", "preslice_remap_y", "preslice_remap_z", "preslice_remap_global",
"belt_support_z_offset_mode", "first_layer_plane", "first_layer_plane_offset",
"belt_preslice_global", "gcode_back_transform", "belt_support_floor_mode", "first_layer_plane_thickness",
};
if (ignore.find(opt_key) != ignore.end()) {
@@ -9444,6 +9840,10 @@ void PrintConfigDef::handle_legacy_composite(DynamicPrintConfig &config)
}
config.set_key_value("wiping_volumes_use_custom_matrix", new ConfigOptionBool(custom));
}
// Orca: a config saved before a key joined filament_options_with_variant stores it once per filament
// rather than once per filament variant, and one exported by an older CLI may store a single value.
normalize_filament_values_to_variants(config);
}
const PrintConfigDef print_config_def;
@@ -9546,6 +9946,23 @@ std::set<std::string> filament_options_with_variant = {
"filament_ironing_spacing",
"filament_ironing_inset",
"filament_ironing_speed",
// Orca: pressure advance
"enable_pressure_advance",
"pressure_advance",
"adaptive_pressure_advance",
"adaptive_pressure_advance_model",
"adaptive_pressure_advance_overhangs",
"adaptive_pressure_advance_bridges",
// Orca: cooling fans, multi-tool ramming and recommended nozzle temperature range
"fan_min_speed",
"fan_max_speed",
"additional_cooling_fan_speed",
"filament_minimal_purge_on_wipe_tower",
"filament_multitool_ramming",
"filament_multitool_ramming_volume",
"filament_multitool_ramming_flow",
"nozzle_temperature_range_low",
"nozzle_temperature_range_high",
"activate_air_filtration",
"activate_air_filtration_during_print",
"activate_air_filtration_on_completion",
@@ -9990,6 +10407,13 @@ static void extend_extruder_variant(DynamicPrintConfig& config, const unsigned i
printer_extruder_variant_opt->values.insert(printer_extruder_variant_opt->values.end(), variants_list.begin(), variants_list.end());
}
}
// 3. Size the machine limits to the rebuilt variants, padded with their first value like the other variant keys.
// They are not extruder option keys, so the resize loop in set_num_extruders skips them.
const auto &defaults = FullPrintConfig::defaults();
for (const std::string &key : printer_options_with_variant_2)
if (auto *opt = config.option<ConfigOptionFloats>(key))
opt->resize(config.get_parameter_size(key, num_extruders), defaults.option(key));
}
void DynamicPrintConfig::set_num_extruders(unsigned int num_extruders)
@@ -10754,6 +11178,65 @@ void set_variant_override(ConfigOptionVectorBase &target, const ConfigOptionVect
target.set_to_index(&source, indices, stride);
}
void normalize_filament_values_to_variants(DynamicPrintConfig &config)
{
const auto *self_index = config.option<ConfigOptionInts>("filament_self_index");
if (self_index == nullptr || self_index->empty())
return;
const int filament_count = *std::max_element(self_index->values.begin(), self_index->values.end());
if (filament_count <= 0 || size_t(filament_count) >= self_index->size())
return;
// The values are one per filament, without variant strings, or a single value for all of them. The
// variant strings do not change today's mapping; they are passed so a rule that reads them applies here too.
const auto *variants = config.option<ConfigOptionStrings>("filament_extruder_variant");
const std::vector<std::string> variant_list = variants && variants->size() == self_index->size() ? variants->values : std::vector<std::string>();
std::vector<int> filament_ids(filament_count);
std::iota(filament_ids.begin(), filament_ids.end(), 1);
const std::vector<int> from_filaments = map_variant_indices(variant_list, self_index->values, {}, filament_ids);
const std::vector<int> from_single = map_variant_indices(variant_list, self_index->values, {}, {});
for (const std::string &key : filament_options_with_variant) {
auto *opt = dynamic_cast<ConfigOptionVectorBase *>(config.option(key));
if (opt == nullptr || (opt->size() != size_t(filament_count) && opt->size() != 1))
continue;
const std::vector<int> &variant_index = opt->size() == size_t(filament_count) ? from_filaments : from_single;
std::unique_ptr<ConfigOption> source(opt->clone());
// -1 and a single-value source both resolve to the first value through get_at()
for (size_t variant = 0; variant < self_index->size(); ++variant)
opt->set_at(source.get(), variant, variant_index[variant]);
}
}
void set_filament_dev_options(DynamicPrintConfig &config, const std::vector<const DynamicPrintConfig *> &filament_configs)
{
for (const std::string &key : filament_dev_options) {
if (std::none_of(filament_configs.begin(), filament_configs.end(), [&key](const DynamicPrintConfig *filament) { return filament->has(key); }))
continue;
const ConfigOption *default_value = print_config_def.get(key)->default_value.get();
auto *dst = static_cast<ConfigOptionVectorBase *>(config.option(key, true));
dst->clear();
for (const DynamicPrintConfig *filament : filament_configs) {
const auto *src = static_cast<const ConfigOptionVectorBase *>(filament->has(key) ? filament->option(key) : default_value);
if (!src->empty())
dst->append(src);
}
}
}
void resize_mixed_filament_metadata(DynamicPrintConfig &config, size_t old_slot_count, size_t new_slot_count)
{
auto resize = [old_slot_count, new_slot_count](auto *opt) {
opt->values.resize(std::min(old_slot_count, opt->values.size()));
opt->values.resize(new_slot_count);
};
resize(config.option<ConfigOptionBools>("filament_is_mixed", true));
resize(config.option<ConfigOptionStrings>("filament_mixed_components", true));
resize(config.option<ConfigOptionStrings>("filament_mixed_sublayer_ratios", true));
resize(config.option<ConfigOptionBools>("filament_mixed_gradient", true));
resize(config.option<ConfigOptionStrings>("filament_mixed_gradient_range", true));
resize(config.option<ConfigOptionStrings>("filament_mixed_gradient_curve", true));
resize(config.option<ConfigOptionBools>("filament_mixed_gradient_per_part", true));
}
//used for object/region config
//use the smallest of multiple to single
@@ -11452,12 +11935,18 @@ void DynamicPrintConfig::update_non_diff_values_to_base_config(DynamicPrintConfi
int cur_variant_count = cur_extruder_variants.size();
int target_variant_count = target_extruder_variants.size();
// A base variant this config does not list (the base gained it after the config was saved, or the
// config lists none) takes this config's first variant of the same extruder, as a user preset's
// values do in update_diff_values_to_child_config. Left unmatched, the base's value would silently
// replace the user's.
variant_index.resize(target_variant_count, -1);
if (cur_variant_count == 0) {
// Defensive: target_variant_count may be 0 if the preset doesn't carry extruder_variant_name.
// In that case keep variant_index empty and let the downstream size checks produce a useful error.
if (!variant_index.empty())
variant_index[0] = 0;
// This config's one value belongs to the extruder of the base's first variant.
variant_index = map_variant_indices(target_extruder_variants, target_extruder_ids, {},
target_extruder_ids.empty() ? std::vector<int>() : std::vector<int>{target_extruder_ids[0]});
}
else if ((cur_extruder_ids.size() > 0) && cur_variant_count != cur_extruder_ids.size()){
//should not happen
@@ -11470,18 +11959,7 @@ void DynamicPrintConfig::update_non_diff_values_to_base_config(DynamicPrintConfi
%extruder_variant_name %target_variant_count %extruder_id_name %target_extruder_ids.size();
}
else {
for (int i = 0; i < target_variant_count; i++)
{
for (int j = 0; j < cur_variant_count; j++)
{
if ((target_extruder_variants[i] == cur_extruder_variants[j])
&&(target_extruder_ids.empty() || (target_extruder_ids[i] == cur_extruder_ids[j])))
{
variant_index[i] = j;
break;
}
}
}
variant_index = map_variant_indices(target_extruder_variants, target_extruder_ids, cur_extruder_variants, cur_extruder_ids);
}
for (auto& opt : keys) {
@@ -11506,6 +11984,13 @@ void DynamicPrintConfig::update_non_diff_values_to_base_config(DynamicPrintConfi
if (cur_variant_count > target_variant_count)
continue;
// The variant lists are the base's layout itself, which every other value is
// carried onto: a variant this config lacks keeps its own name and id.
if (opt == extruder_id_name || opt == extruder_variant_name) {
opt_src->set(opt_target);
continue;
}
int stride = 1;
if (key_set2.find(opt) != key_set2.end())
stride = 2;
@@ -11584,8 +12069,14 @@ void DynamicPrintConfig::update_diff_values_to_child_config(DynamicPrintConfig&
else
variant_index.resize(1, 0);
// A parent variant the child does not list (the parent gained it after the child was saved, or the
// child lists none) takes the child's first variant of the same extruder, as slicing does.
// Left unmatched, the parent's value would silently replace the user's.
if (target_variant_count == 0) {
variant_index[0] = 0;
// The child's one value belongs to the extruder of the parent's first variant.
if (cur_variant_count > 0)
variant_index = map_variant_indices(cur_extruder_variants, cur_extruder_ids, {},
cur_extruder_ids.empty() ? std::vector<int>() : std::vector<int>{cur_extruder_ids[0]});
}
else if ((cur_extruder_ids.size() > 0) && cur_variant_count != cur_extruder_ids.size()){
//should not happen
@@ -11597,19 +12088,8 @@ void DynamicPrintConfig::update_diff_values_to_child_config(DynamicPrintConfig&
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" size of %1% = %2%, not equal to size of %3% = %4%")
%extruder_variant_name %target_variant_count %extruder_id_name %target_extruder_ids.size();
}
else {
for (int i = 0; i < cur_variant_count; i++)
{
for (int j = 0; j < target_variant_count; j++)
{
if ((cur_extruder_variants[i] == target_extruder_variants[j])
&&(cur_extruder_ids.empty() || (cur_extruder_ids[i] == target_extruder_ids[j])))
{
variant_index[i] = j;
break;
}
}
}
else if (cur_variant_count > 0) {
variant_index = map_variant_indices(cur_extruder_variants, cur_extruder_ids, target_extruder_variants, target_extruder_ids);
}
const t_config_option_keys &keys = new_config.keys();
@@ -11989,6 +12469,21 @@ PRINT_CONFIG_CACHE_INITIALIZE((
SLAMaterialConfig, SLAPrintConfig, SLAPrintObjectConfig, SLAPrinterConfig, SLAFullPrintConfig))
static int print_config_static_initialized = print_config_static_initializer();
// The same set() calls ConfigBase::apply_only() makes, without looking every key up by name. Out of line so the
// option list is expanded for this once, not in every file that includes PrintConfig.hpp.
#define PRINT_CONFIG_APPLY_TO_DEFINITION(r, data, CLASS_NAME) \
bool CLASS_NAME::apply_to(ConfigBase &target) const \
{ \
auto *dst = dynamic_cast<CLASS_NAME*>(&target); \
if (dst == nullptr) \
return false; \
visit_option_pairs(*dst, *this, [](const char*, ConfigOption &a, const ConfigOption &b) { a.set(&b); return true; }); \
return true; \
}
BOOST_PP_SEQ_FOR_EACH(PRINT_CONFIG_APPLY_TO_DEFINITION, _, (PrintObjectConfig)(PrintRegionConfig)(MachineEnvelopeConfig)(GCodeConfig)
(SLAMaterialConfig)(SLAPrintConfig)(SLAPrintObjectConfig)(SLAPrinterConfig))
#undef PRINT_CONFIG_APPLY_TO_DEFINITION
//BBS: remove unused command currently
CLIActionsConfigDef::CLIActionsConfigDef()
{
@@ -12626,6 +13121,7 @@ OtherSlicingStatesConfigDef::OtherSlicingStatesConfigDef()
new_def("initial_no_support_extruder", coInt, "Initial no support extruder", "Zero-based index of the first extruder used for printing without support. Same as initial_no_support_tool.");
new_def("in_head_wrap_detect_zone", coBool, "In head wrap detect zone", "Indicates if the first layer overlaps with the head wrap zone.");
new_def("curr_bed_type", coString, "Current bed type", "Name of the currently selected bed plate type (e.g. 'Textured PEI Plate', 'Smooth High Temp Plate').");
}
PrintStatisticsConfigDef::PrintStatisticsConfigDef()
@@ -12890,7 +13386,7 @@ CustomGcodeSpecificConfigDef::CustomGcodeSpecificConfigDef()
// Common Defs
def = this->add("layer_num", coInt);
def->label = L("Layer number");
def->tooltip = L("Index of the current layer. One-based (i.e. first layer is number 1).");
def->tooltip = L("Index of the current layer. Zero-based (i.e. first layer is number 0), except in extrusion role change G-code, where it is one-based.");
def = this->add("layer_z", coFloat);
def->label = L("Layer Z");
@@ -13434,21 +13930,15 @@ bool is_valid_bed_exclude_volumes_string(const std::string &value, const double
std::string legacy_bed_exclude_area_to_volumes(const Pointfs &points)
{
// The legacy option has always interpreted each consecutive group of four
// points as a separate rectangular keep-out. Preserve that meaning instead
// of joining several rectangles into one invalid concave polygon.
if (points.size() < 4 || points.size() % 4 != 0)
// Copy the polygon as resolved by get_bed_excluded_regions(). Inferring
// four-point groups would change the shape of non-rectangular bed areas.
if (points.size() < 3)
return {};
if (std::any_of(points.begin(), points.end(), [](const Vec2d &point) { return !point.allFinite(); }))
return {};
std::string result;
for (size_t offset = 0; offset < points.size(); offset += 4) {
const Pointfs rectangle(points.begin() + offset, points.begin() + offset + 4);
const std::string serialized = ConfigOptionPoints(rectangle).serialize();
if (!result.empty())
result += '|';
result += serialized;
}
return result;
const std::string definition = ConfigOptionPoints(points).serialize();
return is_valid_bed_exclude_volumes_string(definition, std::numeric_limits<double>::max()) ? definition : std::string{};
}
void append_bed_exclude_volumes(DynamicPrintConfig &config, const std::string &definition)
@@ -13520,7 +14010,17 @@ Polygons get_bed_excluded_area(const PrintConfig& cfg)
if (region.z_max <= EPSILON)
continue;
excluded_polygons.emplace_back(region.polygon);
Polygon polygon = region.polygon;
if (cfg.belt_printer.value && !region.is_collision_volume()) {
// Preserve upstream's projection of material keep-outs on the belt surface.
const auto tilt = BeltTransformPipeline::physical_tilt(
cfg.belt_slice_rotation.value, cfg.belt_slice_rotation_angle.value);
const double cos_x = std::cos(Geometry::deg2rad(tilt.tilt_x_deg));
const double cos_y = std::cos(Geometry::deg2rad(tilt.tilt_y_deg));
for (Point &point : polygon.points)
point = Point(scale_(unscale<double>(point.x()) * cos_y), scale_(unscale<double>(point.y()) * cos_x));
}
excluded_polygons.emplace_back(std::move(polygon));
}
return excluded_polygons;