diff --git a/resources/ui_layout/extruder.ui b/resources/ui_layout/extruder.ui index 4cd972220..d4a3a7a56 100644 --- a/resources/ui_layout/extruder.ui +++ b/resources/ui_layout/extruder.ui @@ -34,6 +34,7 @@ group:Retraction wipe setting:idx:wipe_speed setting:idx:retract_before_wipe setting:idx:wipe_extra_perimeter + setting:idx:seam_gap group:Retraction when tool is disabled (advanced settings for multi-extruder setups) setting:idx:retract_length_toolchange setting:idx:retract_restart_extra_toolchange diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index f2e58488c..254c02204 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -159,7 +159,7 @@ public: }; // Type of a configuration value. -enum ConfigOptionType { +enum ConfigOptionType : uint16_t{ coVectorType = 0x4000, coNone = 0, // single float @@ -1113,7 +1113,7 @@ struct FloatOrPercent private: friend class cereal::access; - template void serialize(Archive & ar) { ar(this->flags); ar(this->value); ar(this->percent); } + template void serialize(Archive & ar) {ar(this->value); ar(this->percent); } }; inline bool operator==(const FloatOrPercent &l, const FloatOrPercent &r) @@ -1717,6 +1717,7 @@ public: case coFloats: { auto opt = new ConfigOptionFloatsNullable(); archive(*opt); opt->set_is_extruder_size(this->is_vector_extruder); return opt; } case coInts: { auto opt = new ConfigOptionIntsNullable(); archive(*opt); opt->set_is_extruder_size(this->is_vector_extruder); return opt; } case coPercents: { auto opt = new ConfigOptionPercentsNullable();archive(*opt); opt->set_is_extruder_size(this->is_vector_extruder); return opt; } + case coFloatsOrPercents:{ auto opt = new ConfigOptionFloatsOrPercentsNullable();archive(*opt); opt->set_is_extruder_size(this->is_vector_extruder); return opt; } case coBools: { auto opt = new ConfigOptionBoolsNullable(); archive(*opt); opt->set_is_extruder_size(this->is_vector_extruder); return opt; } default: throw ConfigurationError(std::string("ConfigOptionDef::load_option_from_archive(): Unknown nullable option type for option ") + this->opt_key); } @@ -1731,6 +1732,7 @@ public: case coPercent: { auto opt = new ConfigOptionPercent(); archive(*opt); return opt; } case coPercents: { auto opt = new ConfigOptionPercents(); archive(*opt); opt->set_is_extruder_size(this->is_vector_extruder); return opt; } case coFloatOrPercent: { auto opt = new ConfigOptionFloatOrPercent(); archive(*opt); return opt; } + case coFloatsOrPercents:{ auto opt = new ConfigOptionFloatsOrPercents();archive(*opt); opt->set_is_extruder_size(this->is_vector_extruder); return opt; } case coPoint: { auto opt = new ConfigOptionPoint(); archive(*opt); return opt; } case coPoints: { auto opt = new ConfigOptionPoints(); archive(*opt); opt->set_is_extruder_size(this->is_vector_extruder); return opt; } case coPoint3: { auto opt = new ConfigOptionPoint3(); archive(*opt); return opt; } @@ -1748,6 +1750,7 @@ public: case coFloats: archive(*static_cast(opt)); break; case coInts: archive(*static_cast(opt)); break; case coPercents: archive(*static_cast(opt));break; + case coFloatsOrPercents:archive(*static_cast(opt));break; case coBools: archive(*static_cast(opt)); break; default: throw ConfigurationError(std::string("ConfigOptionDef::save_option_to_archive(): Unknown nullable option type for option ") + this->opt_key); } @@ -1762,6 +1765,7 @@ public: case coPercent: archive(*static_cast(opt)); break; case coPercents: archive(*static_cast(opt)); break; case coFloatOrPercent: archive(*static_cast(opt)); break; + case coFloatsOrPercents:archive(*static_cast(opt));break; case coPoint: archive(*static_cast(opt)); break; case coPoints: archive(*static_cast(opt)); break; case coPoint3: archive(*static_cast(opt)); break; diff --git a/src/libslic3r/Fill/Fill.cpp b/src/libslic3r/Fill/Fill.cpp index cd4cfc248..4f5c839da 100644 --- a/src/libslic3r/Fill/Fill.cpp +++ b/src/libslic3r/Fill/Fill.cpp @@ -422,14 +422,15 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive: // Maximum length of the perimeter segment linking two infill lines. f->link_max_length = (coord_t)scale_(link_max_length); - // Used by the concentric infill pattern to clip the loops to create extrusion paths. - f->loop_clipping = coord_t(scale_(surface_fill.params.flow.nozzle_diameter) * LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER); //give the overlap size to let the infill do his overlap //add overlap if at least one perimeter const LayerRegion* layerm = this->m_regions[surface_fill.region_id]; const float perimeter_spacing = layerm->flow(frPerimeter).spacing(); + // Used by the concentric infill pattern to clip the loops to create extrusion paths. + f->loop_clipping = scale_t(layerm->region()->config().get_computed_value("seam_gap", surface_fill.params.extruder - 1) * surface_fill.params.flow.nozzle_diameter); + // apply half spacing using this flow's own spacing and generate infill //FillParams params; //params.density = float(0.01 * surface_fill.params.density); diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 7f9a28fd0..cf534732d 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -513,7 +513,7 @@ std::vector GCode::collect_layers_to_print(const PrintObjec //FIXME should we use the printing extruders instead? double gap_over_supports = object.config().support_material_contact_distance_top; // FIXME should we test object.config().support_material_synchronize_layers ? IN prusa code, the support layers are synchronized with object layers iff soluble supports. - assert(!object.config().support_material || gap_over_supports != 0. || object.config().support_material_synchronize_layers); + //assert(!object.config().support_material || gap_over_supports != 0. || object.config().support_material_synchronize_layers); if (gap_over_supports != 0.) { gap_over_supports = std::max(0., gap_over_supports); // Not a soluble support, @@ -2870,9 +2870,9 @@ std::string GCode::extrude_loop_vase(const ExtrusionLoop &original_loop, const s // clip the path to avoid the extruder to get exactly on the first point of the loop; // if polyline was shorter than the clipping distance we'd get a null polyline, so // we discard it in that case - double clip_length = m_enable_loop_clipping ? - scale_(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter,0)) * LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER : - 0; + double clip_length = 0; + if (m_enable_loop_clipping && m_writer.tool_is_extruder()) + clip_length = m_config.seam_gap.get_abs_value(m_writer.tool()->id(), scale_(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0))); // get paths ExtrusionPaths paths; @@ -3187,9 +3187,9 @@ std::string GCode::extrude_loop(const ExtrusionLoop &original_loop, const std::s // clip the path to avoid the extruder to get exactly on the first point of the loop; // if polyline was shorter than the clipping distance we'd get a null polyline, so // we discard it in that case - double clip_length = m_enable_loop_clipping ? - scale_(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter,0)) * LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER : - 0; + double clip_length = 0; + if (m_enable_loop_clipping && m_writer.tool_is_extruder()) + clip_length = m_config.seam_gap.get_abs_value(m_writer.tool()->id(), scale_(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0))); // get paths ExtrusionPaths paths; diff --git a/src/libslic3r/PlaceholderParser.cpp b/src/libslic3r/PlaceholderParser.cpp index 00f199e02..1d12c0b05 100644 --- a/src/libslic3r/PlaceholderParser.cpp +++ b/src/libslic3r/PlaceholderParser.cpp @@ -902,6 +902,13 @@ namespace client break; } else ctx->throw_exception("Unknown scalar variable type", opt.it_range); + case coFloatsOrPercents: + opt_def = print_config_def.get(opt_key); + if (opt_def->is_vector_extruder) { + output.set_d(ctx->get_computed_value(opt_key)); + break; + } else + ctx->throw_exception("Unknown scalar variable type", opt.it_range); case coStrings: opt_def = print_config_def.get(opt_key); if (opt_def->is_vector_extruder) { @@ -942,6 +949,7 @@ namespace client case coInts: output.set_i(static_cast(opt.opt)->values[idx]); break; case coStrings: output.set_s(static_cast(opt.opt)->values[idx]); break; case coPercents: output.set_d(static_cast(opt.opt)->values[idx]); break; + case coFloatsOrPercents: output.set_d(static_cast(opt.opt)->values[idx].value); break; case coPoints: output.set_s(to_string(static_cast(opt.opt)->values[idx])); break; case coBools: output.set_b(static_cast(opt.opt)->values[idx] != 0); break; default: diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 9f9e8b1e9..b9c50bbae 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -688,7 +688,9 @@ const std::vector& Preset::filament_options() "external_perimeter_fan_speed", // Retract overrides "filament_retract_length", "filament_retract_lift", "filament_retract_lift_above", "filament_retract_lift_below", "filament_retract_speed", "filament_deretract_speed", "filament_retract_restart_extra", "filament_retract_before_travel", - "filament_retract_layer_change", "filament_wipe", "filament_wipe_speed", "filament_wipe_extra_perimeter", "filament_retract_before_wipe", + "filament_retract_layer_change", "filament_retract_before_wipe", + "filament_seam_gap", + "filament_wipe", "filament_wipe_extra_perimeter", "filament_wipe_speed", // Profile compatibility "filament_vendor", "compatible_prints", "compatible_prints_condition", "compatible_printers", "compatible_printers_condition", "inherits" //merill adds @@ -1465,6 +1467,7 @@ inline t_config_option_keys deep_diff(const ConfigBase &config_this, const Confi case coFloats: add_correct_opts_to_diff(opt_key, diff, config_other, config_this); break; case coStrings: add_correct_opts_to_diff(opt_key, diff, config_other, config_this); break; case coPercents:add_correct_opts_to_diff(opt_key, diff, config_other, config_this); break; + case coFloatsOrPercents:add_correct_opts_to_diff(opt_key, diff, config_other, config_this); break; case coPoints: add_correct_opts_to_diff(opt_key, diff, config_other, config_this); break; default: diff.emplace_back(opt_key); break; } diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 4e6ffc3cd..b5ed48309 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3425,6 +3425,17 @@ void PrintConfigDef::init_fff_params() def->mode = comExpert; def->set_default_value(new ConfigOptionPercent(100)); + def = this->add("seam_gap", coFloatsOrPercents); + def->label = L("Seam gap"); + def->category = OptionCategory::extruders; + def->tooltip = L("To avoid visible seam, the extrusion can be stoppped a bit before the end of the loop." + "\nCan be a mm or a % of the current extruder diameter."); + def->sidetext = L("mm or %"); + def->min = 0; + def->mode = comExpert; + def->is_vector_extruder = true; + def->set_default_value(new ConfigOptionFloatsOrPercents{ FloatOrPercent{15,true} }); + #if 0 def = this->add("seam_preferred_direction", coFloat); // def->gui_type = "slider"; @@ -4657,7 +4668,9 @@ void PrintConfigDef::init_fff_params() // bools "retract_layer_change", "wipe", // percents - "retract_before_wipe"}) { + "retract_before_wipe", + // floatsOrPercents + "seam_gap"}) { auto it_opt = options.find(opt_key); assert(it_opt != options.end()); def = this->add_nullable(std::string("filament_") + opt_key, it_opt->second.type); @@ -4669,6 +4682,7 @@ void PrintConfigDef::init_fff_params() switch (def->type) { case coFloats : def->set_default_value(new ConfigOptionFloatsNullable (static_cast(it_opt->second.default_value.get())->values)); break; case coPercents : def->set_default_value(new ConfigOptionPercentsNullable(static_cast(it_opt->second.default_value.get())->values)); break; + case coFloatsOrPercents : def->set_default_value(new ConfigOptionFloatsOrPercentsNullable(static_cast(it_opt->second.default_value.get())->values)); break; case coBools : def->set_default_value(new ConfigOptionBoolsNullable (static_cast(it_opt->second.default_value.get())->values)); break; default: assert(false); } @@ -4679,32 +4693,33 @@ void PrintConfigDef::init_extruder_option_keys() { // ConfigOptionFloats, ConfigOptionPercents, ConfigOptionBools, ConfigOptionStrings m_extruder_option_keys = { - "nozzle_diameter", - "min_layer_height", - "max_layer_height", + "extruder_colour", "extruder_offset", "extruder_fan_offset", "extruder_temperature_offset", - "tool_name", + "default_filament_profile", + "deretract_speed", + "max_layer_height", + "min_layer_height", + "nozzle_diameter", + "retract_before_travel", + "retract_before_wipe", + "retract_layer_change", "retract_length", + "retract_length_toolchange", "retract_lift", "retract_lift_above", "retract_lift_below", "retract_lift_first_layer", "retract_lift_top", - "retract_speed", - "deretract_speed", - "retract_before_wipe", "retract_restart_extra", - "retract_before_travel", + "retract_restart_extra_toolchange", + "retract_speed", + "seam_gap", + "tool_name", "wipe", "wipe_extra_perimeter", "wipe_speed", - "retract_layer_change", - "retract_length_toolchange", - "retract_restart_extra_toolchange", - "extruder_colour", - "default_filament_profile" }; m_extruder_retract_keys = { @@ -4718,6 +4733,7 @@ void PrintConfigDef::init_extruder_option_keys() "retract_lift_below", "retract_restart_extra", "retract_speed", + "seam_gap", "wipe", "wipe_extra_perimeter", "wipe_speed", @@ -5779,6 +5795,7 @@ std::unordered_set prusa_export_to_remove_keys = { "retract_lift_first_layer", "retract_lift_top", "seam_angle_cost", +"seam_gap", "seam_travel_cost", "skirt_brim", "skirt_distance_from_brim", @@ -6632,6 +6649,13 @@ std::string FullPrintConfig::validate() break; } break; + case coFloatsOrPercents: + for (FloatOrPercent v : static_cast*>(opt)->values) + if (v.value < optdef->min || v.value > optdef->max) { + out_of_range = true; + break; + } + break; case coInt: { auto *iopt = static_cast(opt); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index f80b009c8..b5827e6e9 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1349,6 +1349,7 @@ public: ConfigOptionInt skirt_height; ConfigOptionFloatOrPercent skirt_extrusion_width; ConfigOptionBool draft_shield; + ConfigOptionFloatsOrPercents seam_gap; ConfigOptionInt skirts; ConfigOptionInts slowdown_below_layer_time; ConfigOptionBool spiral_vase; @@ -1445,6 +1446,7 @@ protected: OPT_PTR(resolution); OPT_PTR(retract_before_travel); OPT_PTR(retract_layer_change); + OPT_PTR(seam_gap); OPT_PTR(skirt_brim); OPT_PTR(skirt_distance); OPT_PTR(skirt_distance_from_brim); diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 146d4761f..d320b0c5d 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -851,8 +851,9 @@ namespace Slic3r { || opt_key == "infill_connection_solid" || opt_key == "infill_connection_top" || opt_key == "infill_connection_bottom" + || opt_key == "seam_gap" || opt_key == "top_infill_extrusion_spacing" - || opt_key == "top_infill_extrusion_width") { + || opt_key == "top_infill_extrusion_width" ) { steps.emplace_back(posInfill); } else if ( opt_key == "bridge_angle" diff --git a/src/libslic3r/libslic3r.h b/src/libslic3r/libslic3r.h index 1c5057687..3b4f34264 100644 --- a/src/libslic3r/libslic3r.h +++ b/src/libslic3r/libslic3r.h @@ -64,7 +64,7 @@ static constexpr coord_t SCALED_RESOLUTION = coord_t(0.0125 * UNSCALING_FACTOR); #define POLY_SIDES 24 #define PI 3.141592653589793238 // When extruding a closed loop, the loop is interrupted and shortened a bit to reduce the seam. -static constexpr double LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER = 0.15; +//static constexpr double LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER = 0.15; now seam_gap // Maximum perimeter length for the loop to apply the small perimeter speed. //#define SMALL_PERIMETER_LENGTH ((6.5 / SCALING_FACTOR) * 2 * PI) static constexpr double INSET_OVERLAP_TOLERANCE = 0.4; diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index edb81c843..cbc49c29e 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -95,6 +95,7 @@ void Field::PostInitialize() { case coPercents: case coFloats: + case coFloatsOrPercents: case coStrings: case coBools: case coPoints: @@ -296,12 +297,15 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true break; } case coString: case coStrings: + m_value = std::string(str.ToUTF8().data()); + break; + case coFloatsOrPercents: case coFloatOrPercent: { - if (m_opt.type == coFloatOrPercent && !str.IsEmpty() && str.Last() != '%') + if (!str.IsEmpty() && str.Last() != '%') { double val = 0.; - // Replace the first occurence of comma in decimal number. - str.Replace(",", ".", false); + // Replace the first occurence of comma in decimal number. + str.Replace(",", ".", false); // remove space and "mm" substring, if any exists str.Replace(" ", "", true); @@ -328,8 +332,8 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true if (m_opt.min > val) val = m_opt.min; set_value(double_to_string(val, m_opt.precision), true); } else if (((m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max) || - (m_opt.sidetext.rfind("mm ") != std::string::npos && val > 1)) && - (m_value.empty() || std::string(str.ToUTF8().data()) != boost::any_cast(m_value))) + (m_opt.sidetext.rfind("mm ") != std::string::npos && val > 1)) && + (m_value.empty() || std::string(str.ToUTF8().data()) != boost::any_cast(m_value))) { // exceptions if (std::set{"infill_anchor", "infill_anchor_max", "avoid_crossing_perimeters_max_detour"}.count(m_opt.opt_key) > 0) { @@ -338,9 +342,9 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true } if (m_opt.opt_key.find("extrusion_width") != std::string::npos || m_opt.opt_key.find("extrusion_spacing") != std::string::npos) { const DynamicPrintConfig& printer_config = wxGetApp().preset_bundle->printers.get_edited_preset().config; - const std::vector &nozzle_diameters = printer_config.option("nozzle_diameter")->values; + const std::vector& nozzle_diameters = printer_config.option("nozzle_diameter")->values; double nozzle_diameter = 0; - for(double diameter : nozzle_diameters) + for (double diameter : nozzle_diameters) nozzle_diameter = std::max(nozzle_diameter, diameter); if (val < nozzle_diameter * 10) { m_value = std::string(str.ToUTF8().data()); @@ -360,19 +364,18 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true const wxString msg_text = from_u8((boost::format(_utf8(L("Do you mean %s%% instead of %s %s?\n" "Select YES if you want to change this value to %s%%, \n" "or NO if you are sure that %s %s is a correct value."))) % stVal % stVal % sidetext % stVal % stVal % sidetext).str()); - wxMessageDialog dialog(m_parent, msg_text, _(L("Parameter validation")) + ": " + m_opt_id , wxICON_WARNING | wxYES | wxNO); + wxMessageDialog dialog(m_parent, msg_text, _(L("Parameter validation")) + ": " + m_opt_id, wxICON_WARNING | wxYES | wxNO); if ((!infill_anchors || val > 100) && dialog.ShowModal() == wxID_YES) { set_value(from_u8((boost::format("%s%%") % stVal).str()), false/*true*/); str += "%%"; - } - else - set_value(stVal, false); // it's no needed but can be helpful, when inputted value contained "," instead of "." + } else + set_value(stVal, false); // it's no needed but can be helpful, when inputted value contained "," instead of "." } } } - + m_value = std::string(str.ToUTF8().data()); - break; + break; } case coPoints: { std::vector out_values; @@ -454,13 +457,13 @@ void TextCtrl::BUILD() { wxString text_value = wxString(""); switch (m_opt.type) { - case coFloatOrPercent: - { - text_value = double_to_string(m_opt.default_value->getFloat(), m_opt.precision); - if (m_opt.get_default_value()->percent) - text_value += "%"; - break; - } + case coFloatOrPercent: + { + text_value = double_to_string(m_opt.default_value->getFloat(), m_opt.precision); + if (m_opt.get_default_value()->percent) + text_value += "%"; + break; + } case coPercent: { text_value = double_to_string(m_opt.default_value->getFloat(), m_opt.precision); @@ -480,6 +483,14 @@ void TextCtrl::BUILD() { m_last_meaningful_value = text_value; break; } + case coFloatsOrPercents: + { + const ConfigOptionFloatsOrPercents* cofop = m_opt.get_default_value(); + text_value = double_to_string(cofop->get_at(m_opt_idx).value, m_opt.precision); + if (cofop->get_at(m_opt_idx).percent) + text_value += "%"; + break; + } case coString: text_value = m_opt.get_default_value()->value; break; @@ -605,6 +616,7 @@ bool TextCtrl::value_was_changed() case coString: case coStrings: case coFloatOrPercent: + case coFloatsOrPercents: return boost::any_cast(m_value) != boost::any_cast(val); default: return true; diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index f810f3e2e..5b1b156d6 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -107,7 +107,7 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt } switch (config.def()->get(opt_key)->type) { - case coFloatOrPercent:{ + case coFloatOrPercent: { std::string str = boost::any_cast(value); bool percent = false; if (str.back() == '%') { @@ -116,7 +116,18 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt } double val = stod(str); config.set_key_value(opt_key, new ConfigOptionFloatOrPercent(val, percent)); - break;} + break; } + case coFloatsOrPercents: { + std::string str = boost::any_cast(value); + bool percent = false; + if (str.back() == '%') { + str.pop_back(); + percent = true; + } + double val = stod(str); + ConfigOptionFloatsOrPercents* vec_new = new ConfigOptionFloatsOrPercents{ boost::any_cast(FloatOrPercent{val, percent}) }; + config.option(opt_key)->set_at(vec_new, opt_index, opt_index); + break; } case coPercent: config.set_key_value(opt_key, new ConfigOptionPercent(boost::any_cast(value))); break; diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 7035f8f5c..609760b21 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -47,7 +47,8 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co case coFloat: case coFloats: case coPercent: - case coPercents: + case coPercents: + case coFloatsOrPercents: case coString: case coStrings: m_fields.emplace(id, std::move(TextCtrl::Create(this->ctrl_parent(), opt, id))); @@ -860,6 +861,18 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config ret = double_to_string(val, opt->precision); } } break; + case coFloatsOrPercents: { + if (config.option(opt_key)->is_nil()) + ret = _(L("N/A")); + else { + FloatOrPercent float_percent = config.option(opt_key)->get_at(idx); + text_value = double_to_string(float_percent.value, opt->precision); + if (float_percent.percent) + text_value += "%"; + ret = text_value; + } + } + break; case coBools: ret = config.option(opt_key)->values[idx]; break; @@ -884,6 +897,16 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config ret = text_value; break; } + case coFloatsOrPercents:{ + const ConfigOptionFloatsOrPercents &value = *config.option(opt_key); + + text_value = double_to_string(value.get_at(idx).value, opt->precision); + if (value.get_at(idx).percent) + text_value += "%"; + + ret = text_value; + break; + } case coPercent:{ double val = config.option(opt_key)->value; text_value = double_to_string(val, opt->precision); diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index e9ad959ae..48025cf4e 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -63,6 +63,16 @@ void change_opt_key(std::string& opt_key, DynamicPrintConfig* config, int& cnt) opt_key += "#" + std::to_string(0); } +void change_opt_keyFoP(std::string& opt_key, DynamicPrintConfig* config, int& cnt) +{ + ConfigOptionFloatsOrPercents* opt_cur = static_cast(config->option(opt_key)); + cnt = opt_cur->values.size(); + return; + + if (opt_cur->values.size() > 0) + opt_key += "#" + std::to_string(0); +} + void OptionsSearcher::append_options(DynamicPrintConfig* config, Preset::Type type, ConfigOptionMode mode) { auto emplace = [this, type](const std::string opt_key, const wxString& label) @@ -102,6 +112,8 @@ void OptionsSearcher::append_options(DynamicPrintConfig* config, Preset::Type ty case coFloats: change_opt_key(opt_key, config, cnt); break; case coStrings: change_opt_key(opt_key, config, cnt); break; case coPercents:change_opt_key(opt_key, config, cnt); break; + //case coFloatsOrPercents:change_opt_key(opt_key, config, cnt); break; + case coFloatsOrPercents:change_opt_keyFoP(opt_key, config, cnt); break; case coPoints: change_opt_key(opt_key, config, cnt); break; default: break; } diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index ad382cb5b..cff39bf6d 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -724,6 +724,7 @@ void TabPrinter::init_options_list() case coFloats: add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; case coStrings: add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; case coPercents:add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; + case coFloatsOrPercents:add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; case coPoints: add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; default: m_options_list.emplace(opt_key, m_opt_status_value); break; } @@ -776,6 +777,7 @@ void TabSLAMaterial::init_options_list() case coFloats: add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; case coStrings: add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; case coPercents:add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; + case coFloatsOrPercents:add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; case coPoints: add_correct_opts_to_options_list(opt_key, m_options_list, this, m_opt_status_value); break; default: m_options_list.emplace(opt_key, m_opt_status_value); break; } @@ -2286,7 +2288,8 @@ void TabFilament::add_filament_overrides_page() const int extruder_idx = 0; // #ys_FIXME - for (const std::string opt_key : { "filament_retract_length", + for (const std::string opt_key : { "filament_retract_before_wipe", + "filament_retract_length", "filament_retract_lift", "filament_retract_lift_above", "filament_retract_lift_below", @@ -2295,10 +2298,10 @@ void TabFilament::add_filament_overrides_page() "filament_retract_restart_extra", "filament_retract_before_travel", "filament_retract_layer_change", + "filament_seam_gap", "filament_wipe", "filament_wipe_speed", - "filament_wipe_extra_perimeter", - "filament_retract_before_wipe" + "filament_wipe_extra_perimeter" }) append_single_option_line(opt_key, extruder_idx); } @@ -2314,7 +2317,8 @@ void TabFilament::update_filament_overrides_page() return; ConfigOptionsGroupShp optgroup = *og_it; - std::vector opt_keys = { "filament_retract_length", + std::vector opt_keys = { "filament_retract_before_wipe", + "filament_retract_length", "filament_retract_lift", "filament_retract_lift_above", "filament_retract_lift_below", @@ -2323,10 +2327,10 @@ void TabFilament::update_filament_overrides_page() "filament_retract_restart_extra", "filament_retract_before_travel", "filament_retract_layer_change", + "filament_seam_gap", "filament_wipe", "filament_wipe_speed", - "filament_wipe_extra_perimeter", - "filament_retract_before_wipe" + "filament_wipe_extra_perimeter" }; const int extruder_idx = 0; // #ys_FIXME diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index f04d422f9..a45eaf1a0 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -942,6 +942,12 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig& out = double_to_string(float_percent->value, opt->precision) + (float_percent->percent ? "%" : ""); return out; } + case coFloatsOrPercents: { + const ConfigOptionFloatsOrPercents* floats_percents = config.opt(opt_key); + if (floats_percents) + out = double_to_string(floats_percents->get_at(opt_idx).value, opt->precision) + (floats_percents->get_at(opt_idx).percent ? "%" : ""); + return out; + } case coEnum: { if (opt_key == "top_fill_pattern" || opt_key == "bottom_fill_pattern" ||