mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
Toolchanger: fix an issue that wall_filament/sparse_infill_filament/solid_infill_filament didn't always work
This commit is contained in:
parent
aaaa4f884e
commit
83c50b2ad1
4 changed files with 46 additions and 11 deletions
|
@ -62,6 +62,19 @@ public:
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
bool has_perimeters() const
|
||||||
|
{
|
||||||
|
return std::any_of(entities.begin(), entities.end(), [](const ExtrusionEntity* ee) { return is_perimeter(ee->role()); });
|
||||||
|
}
|
||||||
|
bool has_infill() const
|
||||||
|
{
|
||||||
|
return std::any_of(entities.begin(), entities.end(), [](const ExtrusionEntity* ee) { return is_infill(ee->role()); });
|
||||||
|
}
|
||||||
|
bool has_solid_infill() const
|
||||||
|
{
|
||||||
|
return std::any_of(entities.begin(), entities.end(), [](const ExtrusionEntity* ee) { return is_solid_infill(ee->role()); });
|
||||||
|
}
|
||||||
|
|
||||||
bool can_sort() const override { return !this->no_sort; }
|
bool can_sort() const override { return !this->no_sort; }
|
||||||
bool can_reverse() const override
|
bool can_reverse() const override
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include "ExtrusionEntity.hpp"
|
||||||
#include "Print.hpp"
|
#include "Print.hpp"
|
||||||
#include "ToolOrdering.hpp"
|
#include "ToolOrdering.hpp"
|
||||||
#include "Layer.hpp"
|
#include "Layer.hpp"
|
||||||
|
@ -171,12 +172,25 @@ unsigned int LayerTools::extruder(const ExtrusionEntityCollection &extrusions, c
|
||||||
assert(region.config().sparse_infill_filament.value > 0);
|
assert(region.config().sparse_infill_filament.value > 0);
|
||||||
assert(region.config().solid_infill_filament.value > 0);
|
assert(region.config().solid_infill_filament.value > 0);
|
||||||
// 1 based extruder ID.
|
// 1 based extruder ID.
|
||||||
unsigned int extruder = ((this->extruder_override == 0) ?
|
unsigned int extruder = 1;
|
||||||
(is_infill(extrusions.role()) ?
|
|
||||||
(is_solid_infill(extrusions.entities.front()->role()) ? region.config().solid_infill_filament : region.config().sparse_infill_filament) :
|
if (this->extruder_override == 0) {
|
||||||
region.config().wall_filament.value) :
|
if (extrusions.has_infill()) {
|
||||||
this->extruder_override);
|
if (extrusions.has_solid_infill()) {
|
||||||
return (extruder == 0) ? 0 : extruder - 1;
|
extruder = region.config().solid_infill_filament;
|
||||||
|
} else {
|
||||||
|
extruder = region.config().sparse_infill_filament;
|
||||||
|
}
|
||||||
|
} else if (extrusions.has_perimeters()) {
|
||||||
|
extruder = region.config().wall_filament.value;
|
||||||
|
} else {
|
||||||
|
extruder = this->extruder_override;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
extruder = this->extruder_override;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (extruder == 0) ? 0 : extruder - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double calc_max_layer_height(const PrintConfig &config, double max_object_layer_height)
|
static double calc_max_layer_height(const PrintConfig &config, double max_object_layer_height)
|
||||||
|
|
|
@ -2275,7 +2275,7 @@ DynamicPrintConfig PresetBundle::full_fff_config() const
|
||||||
//BBS: add logic for settings check between different system presets
|
//BBS: add logic for settings check between different system presets
|
||||||
out.erase("different_settings_to_system");
|
out.erase("different_settings_to_system");
|
||||||
|
|
||||||
static const char *keys[] = { "support_filament", "support_interface_filament" };
|
static const char* keys[] = {"support_filament", "support_interface_filament", "wipe_tower_filament"};
|
||||||
for (size_t i = 0; i < sizeof(keys) / sizeof(keys[0]); ++ i) {
|
for (size_t i = 0; i < sizeof(keys) / sizeof(keys[0]); ++ i) {
|
||||||
std::string key = std::string(keys[i]);
|
std::string key = std::string(keys[i]);
|
||||||
auto *opt = dynamic_cast<ConfigOptionInt*>(out.option(key, false));
|
auto *opt = dynamic_cast<ConfigOptionInt*>(out.option(key, false));
|
||||||
|
@ -2283,6 +2283,14 @@ DynamicPrintConfig PresetBundle::full_fff_config() const
|
||||||
opt->value = boost::algorithm::clamp<int>(opt->value, 0, int(num_filaments));
|
opt->value = boost::algorithm::clamp<int>(opt->value, 0, int(num_filaments));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* keys_1based[] = {"wall_filament", "sparse_infill_filament", "solid_infill_filament"};
|
||||||
|
for (size_t i = 0; i < sizeof(keys_1based) / sizeof(keys_1based[0]); ++ i) {
|
||||||
|
std::string key = std::string(keys_1based[i]);
|
||||||
|
auto *opt = dynamic_cast<ConfigOptionInt*>(out.option(key, false));
|
||||||
|
assert(opt != nullptr);
|
||||||
|
if(opt->value < 1 || opt->value > int(num_filaments))
|
||||||
|
opt->value = 1;
|
||||||
|
}
|
||||||
out.option<ConfigOptionString >("print_settings_id", true)->value = this->prints.get_selected_preset_name();
|
out.option<ConfigOptionString >("print_settings_id", true)->value = this->prints.get_selected_preset_name();
|
||||||
out.option<ConfigOptionStrings>("filament_settings_id", true)->values = this->filament_presets;
|
out.option<ConfigOptionStrings>("filament_settings_id", true)->values = this->filament_presets;
|
||||||
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset_name();
|
out.option<ConfigOptionString >("printer_settings_id", true)->value = this->printers.get_selected_preset_name();
|
||||||
|
|
|
@ -2887,11 +2887,11 @@ static void apply_to_print_region_config(PrintRegionConfig &out, const DynamicPr
|
||||||
// 1) Copy the "extruder key to sparse_infill_filament and wall_filament.
|
// 1) Copy the "extruder key to sparse_infill_filament and wall_filament.
|
||||||
auto *opt_extruder = in.opt<ConfigOptionInt>(key_extruder);
|
auto *opt_extruder = in.opt<ConfigOptionInt>(key_extruder);
|
||||||
if (opt_extruder)
|
if (opt_extruder)
|
||||||
if (int extruder = opt_extruder->value; extruder != 1) {
|
if (int extruder = opt_extruder->value; extruder != 0) {
|
||||||
// Not a default extruder.
|
// Not a default extruder.
|
||||||
out.sparse_infill_filament .value = extruder;
|
out.sparse_infill_filament.value = extruder;
|
||||||
out.solid_infill_filament.value = extruder;
|
out.solid_infill_filament.value = extruder;
|
||||||
out.wall_filament .value = extruder;
|
out.wall_filament.value = extruder;
|
||||||
}
|
}
|
||||||
// 2) Copy the rest of the values.
|
// 2) Copy the rest of the values.
|
||||||
for (auto it = in.cbegin(); it != in.cend(); ++ it)
|
for (auto it = in.cbegin(); it != in.cend(); ++ it)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue