diff options
author | supermerill <merill@free.fr> | 2022-02-21 01:34:40 +0300 |
---|---|---|
committer | supermerill <merill@free.fr> | 2022-02-21 14:39:59 +0300 |
commit | 9cfc5d2f7d8f4849b501df332f0fdabba8654d71 (patch) | |
tree | 9bc599f0024b8faffcd3366937faf6c2e9372a1e /src | |
parent | dd468a5f4671b97b9eb3246cb3473239ee54197d (diff) |
Small Simple reorg & more scripted widget
- move Simple print settings to 2 tabs
- add seam position shortcut for corners & nearest (scripted widget, Simple & Advanced)
- add Wall thickness scripted widget
- fix scripted widgets bugs.
Diffstat (limited to 'src')
-rw-r--r-- | src/libslic3r/Config.cpp | 10 | ||||
-rw-r--r-- | src/libslic3r/PrintConfig.cpp | 9 | ||||
-rw-r--r-- | src/libslic3r/PrintConfig.hpp | 7 | ||||
-rw-r--r-- | src/slic3r/GUI/ScriptExecutor.cpp | 100 |
4 files changed, 99 insertions, 27 deletions
diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index 72afd3ec7..af0fd7c76 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -722,6 +722,8 @@ const ConfigOptionDef* ConfigBase::get_option_def(const t_config_option_key& opt if (def == nullptr) throw NoDefinitionException(opt_key); const ConfigOptionDef* opt_def = def->get(opt_key); + if(opt_def == nullptr && parent != nullptr) + opt_def = parent->get_option_def(opt_key); return opt_def; } @@ -747,7 +749,7 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex if (raw_opt->type() == coFloatOrPercent) { auto cofop = static_cast<const ConfigOptionFloatOrPercent*>(raw_opt); if (cofop->value == 0 && boost::ends_with(opt_key, "_extrusion_width")) { - return get_computed_value("extrusion_width"); + return this->get_computed_value("extrusion_width"); } if (!cofop->percent) return cofop->value; @@ -756,7 +758,7 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex if (raw_opt->type() == coPercent) { cast_opt = static_cast<const ConfigOptionPercent*>(raw_opt); } - const ConfigOptionDef* opt_def = get_option_def(opt_key); + const ConfigOptionDef* opt_def = this->get_option_def(opt_key); if (opt_def == nullptr) // maybe a placeholder? return cast_opt->get_abs_value(1); //if over no other key, it's most probably a simple % @@ -801,7 +803,7 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex if (!opt_fl_per->values[idx].percent) return opt_fl_per->values[idx].value; - const ConfigOptionDef* opt_def = get_option_def(opt_key); + const ConfigOptionDef* opt_def = this->get_option_def(opt_key); if (opt_def == nullptr) // maybe a placeholder? return opt_fl_per->get_abs_value(extruder_id, 1); if (opt_def->ratio_over.empty()) @@ -813,7 +815,7 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex } if (raw_opt->type() == coPercents) { const ConfigOptionPercents* opt_per = static_cast<const ConfigOptionPercents*>(raw_opt); - const ConfigOptionDef* opt_def = get_option_def(opt_key); + const ConfigOptionDef* opt_def = this->get_option_def(opt_key); if (opt_def == nullptr) // maybe a placeholder? return opt_per->get_abs_value(extruder_id, 1); if (opt_def->ratio_over.empty()) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 08d3a0c71..ca23d7715 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -989,7 +989,7 @@ void PrintConfigDef::init_fff_params() "each object before moving onto next one (and starting it from its bottom layer). " "This feature is useful to avoid the risk of ruined prints. " "Slic3r should warn and prevent you from extruder collisions, but beware."); - def->mode = comAdvancedE | comPrusa; + def->mode = comSimpleAE | comPrusa; def->set_default_value(new ConfigOptionBool(false)); def = this->add("complete_objects_one_skirt", coBool); @@ -1197,7 +1197,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->aliases = { "multiply_distance" }; def->min = 0; - def->mode = comSimpleAE | comPrusa; + def->mode = comExpert | comPrusa | comSuSi; def->set_default_value(new ConfigOptionFloat(6)); def = this->add("end_gcode", coString); @@ -4210,7 +4210,8 @@ void PrintConfigDef::init_fff_params() def->label = L("Seam position"); def->category = OptionCategory::perimeter; def->tooltip = L("Position of perimeters' starting points." - "\n "); + "\nCost-based option let you choose the angel and travel cost. A high angle cost will place the seam where it can be hidden by a corner" + ", the travel cost place the seam near the last position (often at the end of the previous infill)."); def->enum_keys_map = &ConfigOptionEnum<SeamPosition>::get_enum_values(); def->enum_values.push_back("cost"); def->enum_values.push_back("random"); @@ -5848,7 +5849,7 @@ void PrintConfigDef::init_milling_params() def->category = OptionCategory::milling; def->tooltip = L("If activated, at the end of each layer, the printer will switch to a milling head and mill the external perimeters." "\nYou should set the 'Milling extra XY size' to a value high enough to have enough plastic to mill. Also, be sure that your piece is firmly glued to the bed."); - def->mode = comSimpleAE | comSuSi; + def->mode = comAdvancedE | comSuSi; def->set_default_value(new ConfigOptionBool(false)); def = this->add("milling_extra_size", coFloatOrPercent); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index ea66fe45b..e141e8a2f 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -672,9 +672,11 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionPercent, external_perimeter_cut_corners)) ((ConfigOptionBool, exact_last_layer_height)) ((ConfigOptionFloatOrPercent, extrusion_width)) + ((ConfigOptionFloatOrPercent, extrusion_spacing)) ((ConfigOptionFloatOrPercent, first_layer_acceleration_over_raft)) ((ConfigOptionFloatOrPercent, first_layer_height)) ((ConfigOptionFloatOrPercent, first_layer_extrusion_width)) + ((ConfigOptionFloatOrPercent, first_layer_extrusion_spacing)) ((ConfigOptionFloat, first_layer_size_compensation)) /* elefant_foot_compensation */ ((ConfigOptionInt, first_layer_size_compensation_layers)) ((ConfigOptionFloatOrPercent, first_layer_speed_over_raft)) @@ -764,6 +766,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionBool, enforce_full_fill_volume)) ((ConfigOptionFloatOrPercent, external_infill_margin)) ((ConfigOptionFloatOrPercent, external_perimeter_extrusion_width)) + ((ConfigOptionFloatOrPercent, external_perimeter_extrusion_spacing)) ((ConfigOptionPercent, external_perimeter_overlap)) ((ConfigOptionFloatOrPercent, external_perimeter_speed)) ((ConfigOptionBool, external_perimeters_first)) @@ -798,6 +801,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionBool, hole_to_polyhole_twisted)) ((ConfigOptionInt, infill_extruder)) ((ConfigOptionFloatOrPercent, infill_extrusion_width)) + ((ConfigOptionFloatOrPercent, infill_extrusion_spacing)) ((ConfigOptionInt, infill_every_layers)) ((ConfigOptionFloatOrPercent, infill_overlap)) ((ConfigOptionFloatOrPercent, infill_speed)) @@ -831,6 +835,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionBool, perimeter_round_corners)) ((ConfigOptionInt, perimeter_extruder)) ((ConfigOptionFloatOrPercent, perimeter_extrusion_width)) + ((ConfigOptionFloatOrPercent, perimeter_extrusion_spacing)) ((ConfigOptionBool, perimeter_loop)) ((ConfigOptionEnum<SeamPosition>, perimeter_loop_seam)) ((ConfigOptionPercent, perimeter_overlap)) @@ -847,6 +852,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionFloat, solid_infill_below_area)) ((ConfigOptionInt, solid_infill_extruder)) ((ConfigOptionFloatOrPercent, solid_infill_extrusion_width)) + ((ConfigOptionFloatOrPercent, solid_infill_extrusion_spacing)) ((ConfigOptionInt, solid_infill_every_layers)) ((ConfigOptionFloatOrPercent, solid_infill_speed)) ((ConfigOptionPercent, solid_infill_overlap)) @@ -860,6 +866,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionFloatOrPercent, thin_walls_speed)) ((ConfigOptionEnum<InfillPattern>, top_fill_pattern)) ((ConfigOptionFloatOrPercent, top_infill_extrusion_width)) + ((ConfigOptionFloatOrPercent, top_infill_extrusion_spacing)) ((ConfigOptionInt, top_solid_layers)) ((ConfigOptionFloat, top_solid_min_thickness)) ((ConfigOptionFloatOrPercent, top_solid_infill_speed)) diff --git a/src/slic3r/GUI/ScriptExecutor.cpp b/src/slic3r/GUI/ScriptExecutor.cpp index 48f7ac924..5be7163a5 100644 --- a/src/slic3r/GUI/ScriptExecutor.cpp +++ b/src/slic3r/GUI/ScriptExecutor.cpp @@ -124,12 +124,29 @@ void as_set_int(std::string& key, int val) new_val->set_at(val, 0); conf.set_key_value(key, new_val); } else if (result.second->type() == ConfigOptionType::coEnum) { - const ConfigOptionDef* def = result.first->get_edited_preset().config.get_option_def(key); - if (val >= 0 && val < def->enum_values.size()) { - ConfigOption* copy = result.second->clone(); - copy->setInt(val); - conf.set_key_value(key, copy); - } + //const ConfigOptionDef* def = result.first->get_edited_preset().config.get_option_def(key); + //if (!def->enum_values.empty()) { + // std::string key = ""; + // for (const auto& entry : *def->enum_keys_map) { + // if (entry.second == val) { + // key = entry.first; + // } + // } + // int32_t value = -1; + // for (int i = 0; i < def->enum_values.size(); i++) { + // if (def->enum_values[i] == key) { + // value = i; + // break; + // } + // } + // if (value >= 0 && value < def->enum_values.size()) { + ConfigOption* copy = result.second->clone(); + copy->setInt(val); + conf.set_key_value(key, copy); + // return; + // } + //} + //BOOST_LOG_TRIVIAL(error) << "Error, can't access enum '" << key << "'"; } } float as_get_float(std::string& key) @@ -218,10 +235,7 @@ void as_get_string(std::string& key, std::string& val) } else if (opt->type() == ConfigOptionType::coStrings) { val = ((ConfigOptionStrings*)opt)->get_at(0); } else if (opt->type() == ConfigOptionType::coEnum) { - int idx = opt->getInt(); - const ConfigOptionDef* def = result.first->get_edited_preset().config.get_option_def(key); - if (idx >= 0 && idx < def->enum_values.size()) - val = def->enum_values[idx]; + val = opt->serialize(); } } void as_set_string(std::string& key, std::string& val) @@ -413,13 +427,60 @@ void as_set_custom_string(int preset, std::string& key, std::string& val) ////// others ////// -float as_get_computed_float(std::string& key) +class ConfigAdapter : public ConfigBase { - try { - return (float)wxGetApp().plater()->fff_print().full_print_config().get_computed_value(key, 0); +public: + const ConfigBase* real_storage; + ConfigAdapter(const ConfigBase* conf) : real_storage(conf) { this->parent = nullptr; } + ConfigAdapter(const ConfigBase* conf, const ConfigBase* conf_parent) : real_storage(conf) { this->parent = conf_parent; } + virtual ~ConfigAdapter() { if (this->parent != nullptr) delete parent; } + + virtual const ConfigDef* def() const override { return real_storage->def(); } + virtual ConfigOption* optptr(const t_config_option_key& opt_key, bool create = false) { return nullptr; } + virtual t_config_option_keys keys() const override { return real_storage->keys(); }; + + const ConfigOption* optptr(const t_config_option_key& opt_key) const override + { + const ConfigOption* opt = real_storage->optptr(opt_key); + //if not find, try with the parent config. + if (opt == nullptr && parent != nullptr) + opt = parent->optptr(opt_key); + return opt; } - catch (Exception e) { - BOOST_LOG_TRIVIAL(error) << "Error, can't compute option '" << key << "'"; + + +}; + +float as_get_computed_float(std::string& key) +{ + if (current_script->tech() == (PrinterTechnology::ptFFF)) { + ConfigAdapter fullconfig( + ¤t_script->tab()->m_preset_bundle->fff_prints.get_edited_preset().config, + new ConfigAdapter( + ¤t_script->tab()->m_preset_bundle->filaments.get_edited_preset().config, + new ConfigAdapter(¤t_script->tab()->m_preset_bundle->printers.get_edited_preset().config))); + try { + return (float)fullconfig.get_computed_value(key, 0); + //return (float)wxGetApp().plater()->fff_print().full_print_config().get_computed_value(key, 0); + } + catch (Exception e) { + BOOST_LOG_TRIVIAL(error) << "Error, can't compute fff option '" << key << "'"; + } + + } else { + ConfigAdapter fullconfig( + ¤t_script->tab()->m_preset_bundle->sla_prints.get_edited_preset().config, + new ConfigAdapter( + ¤t_script->tab()->m_preset_bundle->sla_materials.get_edited_preset().config, + new ConfigAdapter(¤t_script->tab()->m_preset_bundle->printers.get_edited_preset().config))); + try { + return (float)fullconfig.get_computed_value(key, 0); + //return (float)wxGetApp().plater()->fff_print().full_print_config().get_computed_value(key, 0); + } + catch (Exception e) { + BOOST_LOG_TRIVIAL(error) << "Error, can't compute sla option '" << key << "'"; + } + } return 0; } @@ -598,7 +659,7 @@ void ScriptContainer::call_script_function_set(const ConfigOptionDef& def, const case coPercent: case coPercents: case coFloat: - case coFloats: ctx->SetArgFloat(0, boost::any_cast<float>(value)); break; + case coFloats: ctx->SetArgFloat(0, (float)boost::any_cast<double>(value)); break; case coFloatOrPercent: case coFloatsOrPercents: { std::string flOrPercent = boost::any_cast<std::string>(value); @@ -616,8 +677,8 @@ void ScriptContainer::call_script_function_set(const ConfigOptionDef& def, const break; } case coPoint: - case coPoints: { ctx->SetArgFloat(0, boost::any_cast<float>(value)); ctx->SetArgFloat(1, boost::any_cast<float>(value)); break; } //FIXME - case coPoint3: { ctx->SetArgFloat(0, boost::any_cast<float>(value)); ctx->SetArgFloat(1, boost::any_cast<float>(value)); ctx->SetArgFloat(2, boost::any_cast<float>(value)); break; } + case coPoints: { ctx->SetArgFloat(0, (float)boost::any_cast<double>(value)); ctx->SetArgFloat(1, (float)boost::any_cast<double>(value)); break; } //FIXME + case coPoint3: { ctx->SetArgFloat(0, (float)boost::any_cast<double>(value)); ctx->SetArgFloat(1, (float)boost::any_cast<double>(value)); ctx->SetArgFloat(2, (float)boost::any_cast<double>(value)); break; } case coString: case coStrings: { str_arg = boost::any_cast<std::string>(value); @@ -781,12 +842,13 @@ boost::any ScriptContainer::call_script_function_get_value(const ConfigOptionDef if (ret_int >= 0 && ret_int < def.enum_values.size()) { ret_val = int32_t(ret_int); } else { + ret_val = int32_t(0); for (size_t i = 0; i < def.enum_values.size(); i++) { if (ret_str == def.enum_values[i]) ret_val = int32_t(i); } } - ret_val = int32_t(0); break; //Choice + break; //Choice } } if (m_need_refresh) { |