mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 02:07:54 -06:00
FIX: fix the print config status not correct issue
the print object updating is behind the .normalize_fdm which will cause some issue in corner cases Change-Id: I57e9e7aa2acff81b89aedd95ffc7a7effb76cc6b
This commit is contained in:
parent
5fa771c6cb
commit
dbcdc876ac
3 changed files with 166 additions and 19 deletions
|
@ -1021,7 +1021,16 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
||||||
new_full_config.option("printer_settings_id", true);
|
new_full_config.option("printer_settings_id", true);
|
||||||
// BBS
|
// BBS
|
||||||
int used_filaments = this->extruders().size();
|
int used_filaments = this->extruders().size();
|
||||||
new_full_config.normalize_fdm(used_filaments);
|
//new_full_config.normalize_fdm(used_filaments);
|
||||||
|
new_full_config.normalize_fdm_1();
|
||||||
|
t_config_option_keys changed_keys = new_full_config.normalize_fdm_2(used_filaments);
|
||||||
|
if (changed_keys.size() > 0) {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got changed_keys, size=%1%")%changed_keys.size();
|
||||||
|
for (int i = 0; i < changed_keys.size(); i++)
|
||||||
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", i=%1%, key=%2%")%i %changed_keys[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Find modified keys of the various configs. Resolve overrides extruder retract values by filament profiles.
|
// Find modified keys of the various configs. Resolve overrides extruder retract values by filament profiles.
|
||||||
DynamicPrintConfig filament_overrides;
|
DynamicPrintConfig filament_overrides;
|
||||||
|
@ -1075,7 +1084,8 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
||||||
m_default_object_config.apply_only(new_full_config, object_diff, true);
|
m_default_object_config.apply_only(new_full_config, object_diff, true);
|
||||||
// Handle changes to regions config defaults
|
// Handle changes to regions config defaults
|
||||||
m_default_region_config.apply_only(new_full_config, region_diff, true);
|
m_default_region_config.apply_only(new_full_config, region_diff, true);
|
||||||
m_full_print_config = std::move(new_full_config);
|
//m_full_print_config = std::move(new_full_config);
|
||||||
|
m_full_print_config = new_full_config;
|
||||||
if (num_extruders != m_config.filament_diameter.size()) {
|
if (num_extruders != m_config.filament_diameter.size()) {
|
||||||
num_extruders = m_config.filament_diameter.size();
|
num_extruders = m_config.filament_diameter.size();
|
||||||
num_extruders_changed = true;
|
num_extruders_changed = true;
|
||||||
|
@ -1397,6 +1407,44 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//BBS: check the config again
|
||||||
|
int new_used_filaments = this->extruders().size();
|
||||||
|
t_config_option_keys new_changed_keys = new_full_config.normalize_fdm_2(new_used_filaments);
|
||||||
|
if (new_changed_keys.size() > 0) {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got new_changed_keys, size=%1%")%new_changed_keys.size();
|
||||||
|
for (int i = 0; i < new_changed_keys.size(); i++)
|
||||||
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", i=%1%, key=%2%")%i %new_changed_keys[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
update_apply_status(false);
|
||||||
|
|
||||||
|
// The following call may stop the background processing.
|
||||||
|
update_apply_status(this->invalidate_state_by_config_options(new_full_config, new_changed_keys));
|
||||||
|
|
||||||
|
update_apply_status(this->invalidate_step(psGCodeExport));
|
||||||
|
|
||||||
|
if (full_config_diff.empty()) {
|
||||||
|
//BBS: previous empty
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" %1%: full_config_diff previous empty, need to apply now.")%__LINE__;
|
||||||
|
|
||||||
|
m_placeholder_parser.clear_config();
|
||||||
|
// Set the profile aliases for the PrintBase::output_filename()
|
||||||
|
m_placeholder_parser.set("print_preset", new_full_config.option("print_settings_id")->clone());
|
||||||
|
m_placeholder_parser.set("filament_preset", new_full_config.option("filament_settings_id")->clone());
|
||||||
|
m_placeholder_parser.set("printer_preset", new_full_config.option("printer_settings_id")->clone());
|
||||||
|
|
||||||
|
//m_placeholder_parser.apply_config(filament_overrides);
|
||||||
|
}
|
||||||
|
// It is also safe to change m_config now after this->invalidate_state_by_config_options() call.
|
||||||
|
m_config.apply_only(new_full_config, new_changed_keys, true);
|
||||||
|
// Handle changes to object config defaults
|
||||||
|
m_default_object_config.apply_only(new_full_config, new_changed_keys, true);
|
||||||
|
// Handle changes to regions config defaults
|
||||||
|
m_default_region_config.apply_only(new_full_config, new_changed_keys, true);
|
||||||
|
m_full_print_config = std::move(new_full_config);
|
||||||
|
}
|
||||||
|
|
||||||
// All regions now have distinct settings.
|
// All regions now have distinct settings.
|
||||||
// Check whether applying the new region config defaults we would get different regions,
|
// Check whether applying the new region config defaults we would get different regions,
|
||||||
// update regions or create regions from scratch.
|
// update regions or create regions from scratch.
|
||||||
|
|
|
@ -3834,6 +3834,102 @@ void DynamicPrintConfig::normalize_fdm(int used_filaments)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//BBS:divide normalize_fdm to 2 steps and call them one by one in Print::Apply
|
||||||
|
void DynamicPrintConfig::normalize_fdm_1()
|
||||||
|
{
|
||||||
|
if (this->has("extruder")) {
|
||||||
|
int extruder = this->option("extruder")->getInt();
|
||||||
|
this->erase("extruder");
|
||||||
|
if (extruder != 0) {
|
||||||
|
if (!this->has("sparse_infill_filament"))
|
||||||
|
this->option("sparse_infill_filament", true)->setInt(extruder);
|
||||||
|
if (!this->has("wall_filament"))
|
||||||
|
this->option("wall_filament", true)->setInt(extruder);
|
||||||
|
// Don't propagate the current extruder to support.
|
||||||
|
// For non-soluble supports, the default "0" extruder means to use the active extruder,
|
||||||
|
// for soluble supports one certainly does not want to set the extruder to non-soluble.
|
||||||
|
// if (!this->has("support_filament"))
|
||||||
|
// this->option("support_filament", true)->setInt(extruder);
|
||||||
|
// if (!this->has("support_interface_filament"))
|
||||||
|
// this->option("support_interface_filament", true)->setInt(extruder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this->has("solid_infill_filament") && this->has("sparse_infill_filament"))
|
||||||
|
this->option("solid_infill_filament", true)->setInt(this->option("sparse_infill_filament")->getInt());
|
||||||
|
|
||||||
|
if (this->has("spiral_mode") && this->opt<ConfigOptionBool>("spiral_mode", true)->value) {
|
||||||
|
{
|
||||||
|
// this should be actually done only on the spiral layers instead of all
|
||||||
|
auto* opt = this->opt<ConfigOptionBools>("retract_when_changing_layer", true);
|
||||||
|
opt->values.assign(opt->values.size(), false); // set all values to false
|
||||||
|
// Disable retract on layer change also for filament overrides.
|
||||||
|
auto* opt_n = this->opt<ConfigOptionBoolsNullable>("filament_retract_when_changing_layer", true);
|
||||||
|
opt_n->values.assign(opt_n->values.size(), false); // Set all values to false.
|
||||||
|
}
|
||||||
|
{
|
||||||
|
this->opt<ConfigOptionInt>("wall_loops", true)->value = 1;
|
||||||
|
this->opt<ConfigOptionInt>("top_shell_layers", true)->value = 0;
|
||||||
|
this->opt<ConfigOptionPercent>("sparse_infill_density", true)->value = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto *opt_gcode_resolution = this->opt<ConfigOptionFloat>("resolution", false); opt_gcode_resolution)
|
||||||
|
// Resolution will be above 1um.
|
||||||
|
opt_gcode_resolution->value = std::max(opt_gcode_resolution->value, 0.001);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
t_config_option_keys DynamicPrintConfig::normalize_fdm_2(int used_filaments)
|
||||||
|
{
|
||||||
|
t_config_option_keys changed_keys;
|
||||||
|
ConfigOptionBool* ept_opt = this->option<ConfigOptionBool>("enable_prime_tower");
|
||||||
|
if (used_filaments > 0 && ept_opt != nullptr) {
|
||||||
|
ConfigOptionBool* islh_opt = this->option<ConfigOptionBool>("independent_support_layer_height", true);
|
||||||
|
ConfigOptionBool* alh_opt = this->option<ConfigOptionBool>("adaptive_layer_height");
|
||||||
|
ConfigOptionEnum<PrintSequence>* ps_opt = this->option<ConfigOptionEnum<PrintSequence>>("print_sequence");
|
||||||
|
|
||||||
|
ConfigOptionEnum<TimelapseType>* timelapse_opt = this->option<ConfigOptionEnum<TimelapseType>>("timelapse_type");
|
||||||
|
bool is_smooth_timelapse = timelapse_opt != nullptr && timelapse_opt->value == TimelapseType::tlSmooth;
|
||||||
|
if (!is_smooth_timelapse && (used_filaments == 1 || ps_opt->value == PrintSequence::ByObject)) {
|
||||||
|
if (ept_opt->value) {
|
||||||
|
ept_opt->value = false;
|
||||||
|
changed_keys.push_back("enable_prime_tower");
|
||||||
|
}
|
||||||
|
//ept_opt->value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ept_opt->value) {
|
||||||
|
if (islh_opt) {
|
||||||
|
if (islh_opt->value) {
|
||||||
|
islh_opt->value = false;
|
||||||
|
changed_keys.push_back("independent_support_layer_height");
|
||||||
|
}
|
||||||
|
//islh_opt->value = false;
|
||||||
|
}
|
||||||
|
if (alh_opt) {
|
||||||
|
if (alh_opt->value) {
|
||||||
|
alh_opt->value = false;
|
||||||
|
changed_keys.push_back("adaptive_layer_height");
|
||||||
|
}
|
||||||
|
//alh_opt->value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (islh_opt) {
|
||||||
|
if (!islh_opt->value) {
|
||||||
|
islh_opt->value = true;
|
||||||
|
changed_keys.push_back("independent_support_layer_height");
|
||||||
|
}
|
||||||
|
//islh_opt->value = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return changed_keys;
|
||||||
|
}
|
||||||
|
|
||||||
void handle_legacy_sla(DynamicPrintConfig &config)
|
void handle_legacy_sla(DynamicPrintConfig &config)
|
||||||
{
|
{
|
||||||
for (std::string corr : {"relative_correction", "material_correction"}) {
|
for (std::string corr : {"relative_correction", "material_correction"}) {
|
||||||
|
|
|
@ -340,6 +340,9 @@ public:
|
||||||
const ConfigDef* def() const override { return &print_config_def; }
|
const ConfigDef* def() const override { return &print_config_def; }
|
||||||
|
|
||||||
void normalize_fdm(int used_filaments = 0);
|
void normalize_fdm(int used_filaments = 0);
|
||||||
|
void normalize_fdm_1();
|
||||||
|
//return the changed param set
|
||||||
|
t_config_option_keys normalize_fdm_2(int used_filaments = 0);
|
||||||
|
|
||||||
void set_num_extruders(unsigned int num_extruders);
|
void set_num_extruders(unsigned int num_extruders);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue