Fix get_computed_value

supermerill/SuperSlicer#1877
This commit is contained in:
supermerill 2021-11-16 21:50:21 +01:00
parent d020d048e9
commit 8226e4608b
2 changed files with 10 additions and 4 deletions

View File

@ -710,7 +710,7 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex
//FIXME there are some ratio_over chains, which end with empty ratio_with.
// For example, XXX_extrusion_width parameters are not handled by get_abs_value correctly.
if (!opt_def->ratio_over.empty() && opt_def->ratio_over != "depends")
return cast_opt->get_abs_value(this->get_computed_value(opt_def->ratio_over));
return cast_opt->get_abs_value(this->get_computed_value(opt_def->ratio_over, extruder_id));
std::stringstream ss; ss << "ConfigBase::get_abs_value(): " << opt_key << " has no valid ratio_over to compute of";
throw ConfigurationError(ss.str());

View File

@ -80,7 +80,13 @@ void CalibrationBridgeDialog::create_geometry(std::string setting_to_test, bool
assert(objs_idx.size() == nb_items);
const DynamicPrintConfig* print_config = this->gui_app->get_tab(Preset::TYPE_FFF_PRINT)->get_config();
const DynamicPrintConfig* filament_config = this->gui_app->get_tab(Preset::TYPE_FFF_FILAMENT)->get_config();
const DynamicPrintConfig* printer_config = this->gui_app->get_tab(Preset::TYPE_PRINTER)->get_config();
DynamicPrintConfig full_print_config;
full_print_config.apply(*print_config);
full_print_config.apply(*filament_config);
full_print_config.apply(*printer_config);
full_print_config.set_key_value("extruder_id", new ConfigOptionInt(0));
/// --- scale ---
// model is created for a 0.4 nozzle, scale xy with nozzle size.
@ -144,14 +150,14 @@ void CalibrationBridgeDialog::create_geometry(std::string setting_to_test, bool
//model.objects[objs_idx[i]]->config.set_key_value("top_fill_pattern", new ConfigOptionEnum<InfillPattern>(ipSmooth)); /not needed
model.objects[objs_idx[i]]->config.set_key_value("ironing", new ConfigOptionBool(false)); // not needed, and it slow down things.
}
/// if first ayer height is excatly at the wrong value, the text isn't drawed. Fix that by switching the first layer height just a little bit.
double first_layer_height = print_config->get_computed_value("first_layer_height", 0);
/// if first ayer height is excactly at the wrong value, the text isn't drawed. Fix that by switching the first layer height just a little bit.
double first_layer_height = full_print_config.get_computed_value("first_layer_height", 0);
double layer_height = nozzle_diameter * 0.5;
if (layer_height > 0.01 && (int(first_layer_height * 100) % int(layer_height * 100)) == int(layer_height * 50)) {
double z_step = printer_config->option<ConfigOptionFloat>("z_step")->value;
if (z_step == 0)
z_step = 0.1;
double max_height = printer_config->get_computed_value("max_layer_height",0);
double max_height = full_print_config.get_computed_value("max_layer_height",0);
if (max_height > first_layer_height + z_step)
for (size_t i = 0; i < nb_items; i++)
model.objects[objs_idx[i]]->config.set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(first_layer_height + z_step, false));