diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index f63b97aae..3c5b62ce0 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1950,6 +1950,39 @@ void Print::_make_wipe_tower() for (const auto extruder_id : layer_tools.extruders) { if ((first_layer && extruder_id == m_wipe_tower_data.tool_ordering.all_extruders().back()) || extruder_id != current_extruder_id) { double volume_to_wipe = wipe_volumes[current_extruder_id][extruder_id]; // total volume to wipe after this toolchange + + if (m_config.wipe_advanced) { + volume_to_wipe = m_config.wipe_advanced_nozzle_melted_volume; + float pigmentBef = m_config.filament_wipe_advanced_pigment.get_at(current_extruder_id); + float pigmentAft = m_config.filament_wipe_advanced_pigment.get_at(extruder_id); + if (m_config.wipe_advanced_algo.value == waLinear) { + volume_to_wipe += m_config.wipe_advanced_multiplier.value * (pigmentBef - pigmentAft); + std::cout << "advanced wiping (lin) "; + std::cout << current_extruder_id << " -> " << extruder_id << " will use " << volume_to_wipe << " mm3\n"; + std::cout << " calculus : " << m_config.wipe_advanced_nozzle_melted_volume << " + " << m_config.wipe_advanced_multiplier.value + << " * ( " << pigmentBef << " - " << pigmentAft << " )\n"; + std::cout << " = " << m_config.wipe_advanced_nozzle_melted_volume << " + " << (m_config.wipe_advanced_multiplier.value* (pigmentBef - pigmentAft)) << "\n"; + } else if (m_config.wipe_advanced_algo.value == waQuadra) { + volume_to_wipe += m_config.wipe_advanced_multiplier.value * (pigmentBef - pigmentAft) + + m_config.wipe_advanced_multiplier.value * (pigmentBef - pigmentAft) * (pigmentBef - pigmentAft) * (pigmentBef - pigmentAft); + std::cout << "advanced wiping (quadra) "; + std::cout << current_extruder_id << " -> " << extruder_id << " will use " << volume_to_wipe << " mm3\n"; + std::cout << " calculus : " << m_config.wipe_advanced_nozzle_melted_volume << " + " << m_config.wipe_advanced_multiplier.value + << " * ( " << pigmentBef << " - " << pigmentAft << " ) + " << m_config.wipe_advanced_multiplier.value + << " * ( " << pigmentBef << " - " << pigmentAft << " ) ^3 \n"; + std::cout << " = " << m_config.wipe_advanced_nozzle_melted_volume << " + " << (m_config.wipe_advanced_multiplier.value* (pigmentBef - pigmentAft)) + << " + " << (m_config.wipe_advanced_multiplier.value*(pigmentBef - pigmentAft)*(pigmentBef - pigmentAft)*(pigmentBef - pigmentAft))<<"\n"; + } else if (m_config.wipe_advanced_algo.value == waHyper) { + volume_to_wipe += m_config.wipe_advanced_multiplier.value * (0.5 + pigmentBef) / (0.5 + pigmentAft); + std::cout << "advanced wiping (hyper) "; + std::cout << current_extruder_id << " -> " << extruder_id << " will use " << volume_to_wipe << " mm3\n"; + std::cout << " calculus : " << m_config.wipe_advanced_nozzle_melted_volume << " + " << m_config.wipe_advanced_multiplier.value + << " * ( 0.5 + " << pigmentBef << " ) / ( 0.5 + " << pigmentAft << " )\n"; + std::cout << " = " << m_config.wipe_advanced_nozzle_melted_volume << " + " << (m_config.wipe_advanced_multiplier.value * (0.5 + pigmentBef) / (0.5 + pigmentAft)) << "\n"; + } + } + //filament_wipe_advanced_pigment + // Not all of that can be used for infill purging: volume_to_wipe -= m_config.filament_minimal_purge_on_wipe_tower.get_at(extruder_id); diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index e1ee2c38a..915800c17 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1771,7 +1771,8 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Minimum detail resolution, used to simplify the input file for speeding up " "the slicing job and reducing memory usage. High-resolution models often carry " "more detail than printers can render. Set to zero to disable any simplification " - "and use full resolution from input."); + "and use full resolution from input. " + "\nNote: slic3r simplify the geometry with a treshold of 0.0125mm and has an internal resolution of 0.0001mm."); def->sidetext = L("mm"); def->cli = "resolution=f"; def->min = 0; @@ -2420,7 +2421,8 @@ void PrintConfigDef::init_fff_params() def = this->add("thin_walls_min_width", coFloatOrPercent); def->label = L("min width"); def->category = L("Layers and Perimeters"); - def->tooltip = L("Minimum width for the extrusion to be extruded (widths lower than the nozzle diameter will be over-extruded at the nozzle diameter). Can be percent of the nozzle size."); + def->tooltip = L("Minimum width for the extrusion to be extruded (widths lower than the nozzle diameter will be over-extruded at the nozzle diameter)." + "Can be percent of the nozzle size. The default behavior of slic3r and slic3rPE is with a 33% value. Put 100% to avoid any sort of over-extrusion."); def->cli = "thin-walls-min-width=s"; def->mode = comExpert; def->min = 0; @@ -2567,6 +2569,57 @@ void PrintConfigDef::init_fff_params() 140.f, 140.f, 140.f, 0.f, 140.f, 140.f, 140.f, 140.f, 140.f, 0.f }; + + def = this->add("wipe_advanced", coBool); + def->label = L("Enable advanced wiping volume"); + def->tooltip = L("Allow slic3r to compute the purge volume via smart computations. Use the pigment% of each filament and following parameters"); + def->cli = "wipe-advanced!"; + def->mode = comExpert; + def->default_value = new ConfigOptionBool(false); + + def = this->add("wipe_advanced_nozzle_melted_volume", coFloat); + def->label = L("Nozzle volume"); + def->tooltip = L("The volume of melted plastic inside your nozlle. Used by 'advanced wiping'."); + def->sidetext = L("mm3"); + def->cli = "wipe-advanced-volume=f"; + def->mode = comExpert; + def->default_value = new ConfigOptionFloat(120); + + def = this->add("filament_wipe_advanced_pigment", coFloats); + def->label = L("Pigment percentage"); + def->tooltip = L("The pigment % for this filament (bewteen 0 and 1, 1=100%). 0 for translucent/natural, 0.2-0.5 for white and 1 for black."); + def->cli = "wipe-advanced-pigment=f@"; + def->mode = comExpert; + def->min = 0; + def->max = 1; + def->default_value = new ConfigOptionFloats{ 0.5 }; + + def = this->add("wipe_advanced_multiplier", coFloat); + def->label = L("Multiplier"); + def->tooltip = L("The volume multiplier used to compute the final volume to extrude by the algorithm."); + def->sidetext = L("mm3"); + def->cli = "wipe-advanced-mult=f"; + def->mode = comExpert; + def->default_value = new ConfigOptionFloat(60); + + + def = this->add("wipe_advanced_algo", coEnum); + def->label = L("Algorithm"); + def->tooltip = L("Algo for the advanced wipe.\n" + "Linear : volume = nozzle + volume_mult * (pigmentBefore-pigmentAfter)\n" + "Quadratic: volume = nozzle + volume_mult * (pigmentBefore-pigmentAfter)+ volume_mult * (pigmentBefore-pigmentAfter)^3\n" + "Hyperbola: volume = nozzle + volume_mult * (0.5+pigmentBefore) / (0.5+pigmentAfter)"); + def->cli = "wipe-advanced-algo=s"; + def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); + def->enum_values.push_back("linear"); + def->enum_values.push_back("quadra"); + def->enum_values.push_back("expo"); + def->enum_labels.push_back(L("Linear")); + def->enum_labels.push_back(L("Quadratric")); + def->enum_labels.push_back(L("Hyperbola")); + def->mode = comExpert; + def->default_value = new ConfigOptionEnum(waLinear); + def = this->add("wipe_tower_x", coFloat); def->label = L("X"); def->tooltip = L("X coordinate of the left front corner of a wipe tower"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 07229b5de..15ffc1f51 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -32,6 +32,13 @@ enum PrinterTechnology ptSLA, }; + +enum WipeAlgo { + waLinear, + waQuadra, + waHyper, +}; + enum GCodeFlavor { gcfRepRap, gcfRepetier, gcfTeacup, gcfMakerWare, gcfMarlin, gcfSailfish, gcfMach3, gcfMachinekit, gcfSmoothie, gcfNoExtrusion, @@ -87,6 +94,16 @@ template<> inline const t_config_enum_values& ConfigOptionEnum inline const t_config_enum_values& ConfigOptionEnum::get_enum_values() { + static t_config_enum_values keys_map; + if (keys_map.empty()) { + keys_map["linear"] = waLinear; + keys_map["quadra"] = waQuadra; + keys_map["expo"] = waHyper; + } + return keys_map; +} + template<> inline const t_config_enum_values& ConfigOptionEnum::get_enum_values() { static t_config_enum_values keys_map; if (keys_map.empty()) { @@ -697,6 +714,7 @@ public: ConfigOptionInts filament_cooling_moves; ConfigOptionFloats filament_cooling_initial_speed; ConfigOptionFloats filament_minimal_purge_on_wipe_tower; + ConfigOptionFloats filament_wipe_advanced_pigment; ConfigOptionFloats filament_cooling_final_speed; ConfigOptionStrings filament_ramming_parameters; ConfigOptionBool gcode_comments; @@ -736,6 +754,10 @@ public: ConfigOptionBool remaining_times; ConfigOptionBool silent_mode; ConfigOptionFloat extra_loading_move; + ConfigOptionBool wipe_advanced; + ConfigOptionFloat wipe_advanced_nozzle_melted_volume; + ConfigOptionFloat wipe_advanced_multiplier; + ConfigOptionEnum wipe_advanced_algo; std::string get_extrusion_axis() const { @@ -770,6 +792,7 @@ protected: OPT_PTR(filament_cooling_moves); OPT_PTR(filament_cooling_initial_speed); OPT_PTR(filament_minimal_purge_on_wipe_tower); + OPT_PTR(filament_wipe_advanced_pigment); OPT_PTR(filament_cooling_final_speed); OPT_PTR(filament_ramming_parameters); OPT_PTR(gcode_comments); @@ -809,6 +832,10 @@ protected: OPT_PTR(remaining_times); OPT_PTR(silent_mode); OPT_PTR(extra_loading_move); + OPT_PTR(wipe_advanced); + OPT_PTR(wipe_advanced_nozzle_melted_volume); + OPT_PTR(wipe_advanced_multiplier); + OPT_PTR(wipe_advanced_algo); } }; diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index f3d33cc49..7a7f61c2b 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -755,6 +755,8 @@ boost::any& Choice::get_value() m_value = static_cast(ret_enum); else if (m_opt_id.compare("infill_dense_algo") == 0) m_value = static_cast(ret_enum); + else if (m_opt_id.compare("wipe_advanced_algo") == 0) + m_value = static_cast(ret_enum); else if (m_opt_id.compare("support_material_contact_distance_type") == 0) m_value = static_cast(ret_enum); else if (m_opt_id.compare("display_orientation") == 0) diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index 64854f4b7..298e1e067 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -200,6 +200,8 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); else if (opt_key.compare("infill_dense_algo") == 0) config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); + else if (opt_key.compare("wipe_advanced_algo") == 0) + config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); else if (opt_key.compare("support_material_contact_distance_type") == 0) config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); else if (opt_key.compare("display_orientation") == 0) diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 233189eb2..9861285e4 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -324,15 +324,15 @@ void MainFrame::init_menubar() if (m_plater != nullptr) { editMenu = new wxMenu(); - wxMenuItem* item_select_all = append_menu_item(editMenu, wxID_ANY, _(L("&Select all")) + "\tCtrl+A", _(L("Selects all objects")), - [this](wxCommandEvent&) { m_plater->select_all(); }, ""); + // wxMenuItem* item_select_all = append_menu_item(editMenu, wxID_ANY, _(L("&Select all")) + "\tCtrl+A", _(L("Selects all objects")), + // [this](wxCommandEvent&) { std::cout<<"select all plater?\n"; m_plater->select_all(); }, ""); editMenu->AppendSeparator(); wxMenuItem* item_delete_sel = append_menu_item(editMenu, wxID_ANY, _(L("&Delete selected")) + "\tDel", _(L("Deletes the current selection")), [this](wxCommandEvent&) { m_plater->remove_selected(); }, ""); wxMenuItem* item_delete_all = append_menu_item(editMenu, wxID_ANY, _(L("Delete &all")) + "\tCtrl+Del", _(L("Deletes all objects")), [this](wxCommandEvent&) { m_plater->reset(); }, ""); - Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_select()); }, item_select_all->GetId()); + // Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_select()); }, item_select_all->GetId()); Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_delete()); }, item_delete_sel->GetId()); Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_delete_all()); }, item_delete_all->GetId()); } @@ -414,6 +414,8 @@ void MainFrame::init_menubar() { append_menu_item(helpMenu, wxID_ANY, _(L("Slic3r++ Releases")), _(L("Open the slic3r++ releases page in your browser")), [this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://github.com/supermerill/slic3r/releases"); }); + append_menu_item(helpMenu, wxID_ANY, _(L("Slic3r++ wiki")), _(L("Open the slic3r++ wiki in your browser")), + [this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://github.com/supermerill/slic3r/wiki"); }); append_menu_item(helpMenu, wxID_ANY, _(L("Slic3r++ website")), _(L("Open the slic3r++ website in your browser")), [this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://github.com/supermerill/slic3r"); }); append_menu_item(helpMenu, wxID_ANY, _(L("Prusa Edition website")), _(L("Open the Prusa Edition website in your browser")), @@ -432,7 +434,7 @@ void MainFrame::init_menubar() append_menu_item(helpMenu, wxID_ANY, _(L("Show &Configuration Folder")), _(L("Show user configuration folder (datadir)")), [this](wxCommandEvent&) { Slic3r::GUI::desktop_open_datadir_folder(); }); append_menu_item(helpMenu, wxID_ANY, _(L("Report an Issue")), _(L("Report an issue on Slic3r++")), - [this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://github.com/prusa3d/supermerill/issues/new"); }); + [this](wxCommandEvent&) { wxLaunchDefaultBrowser("http://github.com/supermerill/Slic3r/issues/new"); }); append_menu_item(helpMenu, wxID_ANY, _(L("&About Slic3r")), _(L("Show about dialog")), [this](wxCommandEvent&) { Slic3r::GUI::about(); }); helpMenu->AppendSeparator(); diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 19db473d6..a2bd4c77c 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -557,6 +557,9 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config else if (opt_key.compare("infill_dense_algo") == 0){ ret = static_cast(config.option>(opt_key)->value); } + else if (opt_key.compare("wipe_advanced_algo") == 0){ + ret = static_cast(config.option>(opt_key)->value); + } else if (opt_key.compare("support_material_contact_distance_type") == 0){ ret = static_cast(config.option>(opt_key)->value); } diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index 1c3cbbb15..9660c6b1e 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -376,6 +376,7 @@ const std::vector& Preset::filament_options() "min_print_speed", "start_filament_gcode", "end_filament_gcode", "compatible_prints", "compatible_prints_condition", "compatible_printers", "compatible_printers_condition", "inherits" + , "filament_wipe_advanced_pigment" }; return s_opts; } @@ -393,6 +394,10 @@ const std::vector& Preset::printer_options() "between_objects_gcode", "printer_vendor", "printer_model", "printer_variant", "printer_notes", "cooling_tube_retraction", "cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "max_print_height", "default_print_profile", "inherits", + "wipe_advanced", + "wipe_advanced_nozzle_melted_volume", + "wipe_advanced_multiplier", + "wipe_advanced_algo", "remaining_times", "silent_mode", "machine_max_acceleration_extruding", "machine_max_acceleration_retracting", "machine_max_acceleration_x", "machine_max_acceleration_y", "machine_max_acceleration_z", "machine_max_acceleration_e", "machine_max_feedrate_x", "machine_max_feedrate_y", "machine_max_feedrate_z", "machine_max_feedrate_e", diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 2d06ae72b..7e3d24914 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1547,6 +1547,7 @@ void TabFilament::build() optgroup->append_single_option_line("filament_cooling_initial_speed"); optgroup->append_single_option_line("filament_cooling_final_speed"); optgroup->append_single_option_line("filament_minimal_purge_on_wipe_tower"); + optgroup->append_single_option_line("filament_wipe_advanced_pigment"); line = optgroup->create_single_option_line("filament_ramming_parameters");// { _(L("Ramming")), "" }; line.widget = [this](wxWindow* parent) { @@ -1562,7 +1563,7 @@ void TabFilament::build() })); return sizer; }; - optgroup->append_line(line); + optgroup->append_line(line); page = add_options_page(_(L("Custom G-code")), "cog.png"); @@ -2206,6 +2207,11 @@ void TabPrinter::build_extruder_pages() optgroup->append_single_option_line("parking_pos_retraction"); optgroup->append_single_option_line("extra_loading_move"); optgroup->append_single_option_line("high_current_on_filament_swap"); + optgroup = page->new_optgroup(_(L("Advanced wipe tower purge volume calculs"))); + optgroup->append_single_option_line("wipe_advanced"); + optgroup->append_single_option_line("wipe_advanced_nozzle_melted_volume"); + optgroup->append_single_option_line("wipe_advanced_multiplier"); + optgroup->append_single_option_line("wipe_advanced_algo"); m_pages.insert(m_pages.end() - n_after_single_extruder_MM, page); m_has_single_extruder_MM_page = true; } @@ -2405,6 +2411,10 @@ void TabPrinter::update_fff() (have_multiple_extruders && toolchange_retraction); } + bool have_advanced_wipe_volume = m_config->opt_bool("wipe_advanced"); + for (auto el : { "wipe_advanced_nozzle_melted_volume", "wipe_advanced_multiplier", "wipe_advanced_algo" }) + get_field(el)->toggle(have_advanced_wipe_volume); + Thaw(); }