From 9a0100d6deb4748e778a2136d6f3150e88643aa7 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 9 Nov 2017 10:48:06 +0100 Subject: [PATCH] Initial definition of PresetHints C++ class and Perl binding, ported the cooling logic hints to C++. Removed Perl Flow::new_from_spacing bindings. Some Fill C++11 beautification. Fix of a support_material_1st_layer_flow, brim_flow and skirt_flow logic to use the extrusion_width if both first_layer_extrusion_width and support_material_extrusion_width are undefined. Documented the extrusion width logic in the config tooltips, including the default values. --- xs/CMakeLists.txt | 3 + xs/lib/Slic3r/XS.pm | 8 - xs/src/libslic3r/Fill/Fill.cpp | 7 +- xs/src/libslic3r/Flow.cpp | 3 +- xs/src/libslic3r/Flow.hpp | 3 + xs/src/libslic3r/Print.cpp | 10 +- xs/src/libslic3r/PrintConfig.cpp | 31 ++-- xs/src/perlglue.cpp | 1 + xs/src/slic3r/GUI/PresetHints.cpp | 254 ++++++++++++++++++++++++++++++ xs/src/slic3r/GUI/PresetHints.hpp | 25 +++ xs/xsp/Flow.xsp | 12 -- 11 files changed, 316 insertions(+), 41 deletions(-) create mode 100644 xs/src/slic3r/GUI/PresetHints.cpp create mode 100644 xs/src/slic3r/GUI/PresetHints.hpp diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index dac9993c3..07442f248 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -26,6 +26,7 @@ include_directories(${LIBDIR}/libslic3r) if(WIN32) # BOOST_ALL_NO_LIB: Avoid the automatic linking of Boost libraries on Windows. Rather rely on explicit linking. add_definitions(-D_USE_MATH_DEFINES -D_WIN32 -DBOOST_ALL_NO_LIB) + # -D_ITERATOR_DEBUG_LEVEL) endif() add_definitions(-DwxUSE_UNICODE -D_UNICODE -DUNICODE) @@ -172,6 +173,8 @@ add_library(libslic3r_gui STATIC ${LIBDIR}/slic3r/GUI/Preset.hpp ${LIBDIR}/slic3r/GUI/PresetBundle.cpp ${LIBDIR}/slic3r/GUI/PresetBundle.hpp + ${LIBDIR}/slic3r/GUI/PresetHints.cpp + ${LIBDIR}/slic3r/GUI/PresetHints.hpp ${LIBDIR}/slic3r/GUI/GUI.cpp ${LIBDIR}/slic3r/GUI/GUI.hpp ) diff --git a/xs/lib/Slic3r/XS.pm b/xs/lib/Slic3r/XS.pm index 0e995acf2..26c8befe2 100644 --- a/xs/lib/Slic3r/XS.pm +++ b/xs/lib/Slic3r/XS.pm @@ -179,14 +179,6 @@ sub new_from_width { ); } -sub new_from_spacing { - my ($class, %args) = @_; - - return $class->_new_from_spacing( - @args{qw(spacing nozzle_diameter layer_height bridge)}, - ); -} - package Slic3r::Surface; sub new { diff --git a/xs/src/libslic3r/Fill/Fill.cpp b/xs/src/libslic3r/Fill/Fill.cpp index ffae7fa5b..5333fcfec 100644 --- a/xs/src/libslic3r/Fill/Fill.cpp +++ b/xs/src/libslic3r/Fill/Fill.cpp @@ -149,8 +149,7 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out) // ); } - for (Surfaces::const_iterator surface_it = surfaces.begin(); surface_it != surfaces.end(); ++ surface_it) { - const Surface &surface = *surface_it; + for (const Surface &surface : surfaces) { if (surface.surface_type == stInternalVoid) continue; InfillPattern fill_pattern = layerm.region()->config.fill_pattern.value; @@ -262,10 +261,10 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out) // Unpacks the collection, creates multiple collections per path. // The path type could be ExtrusionPath, ExtrusionLoop or ExtrusionEntityCollection. // Why the paths are unpacked? - for (ExtrusionEntitiesPtr::iterator thin_fill = layerm.thin_fills.entities.begin(); thin_fill != layerm.thin_fills.entities.end(); ++ thin_fill) { + for (const ExtrusionEntity *thin_fill : layerm.thin_fills.entities) { ExtrusionEntityCollection &collection = *(new ExtrusionEntityCollection()); out.entities.push_back(&collection); - collection.entities.push_back((*thin_fill)->clone()); + collection.entities.push_back(thin_fill->clone()); } } diff --git a/xs/src/libslic3r/Flow.cpp b/xs/src/libslic3r/Flow.cpp index 25a44ea8f..c48452c2b 100644 --- a/xs/src/libslic3r/Flow.cpp +++ b/xs/src/libslic3r/Flow.cpp @@ -154,10 +154,11 @@ Flow support_material_flow(const PrintObject *object, float layer_height) Flow support_material_1st_layer_flow(const PrintObject *object, float layer_height) { + const auto &width = (object->print()->config.first_layer_extrusion_width.value > 0) ? object->print()->config.first_layer_extrusion_width : object->config.support_material_extrusion_width; return Flow::new_from_config_width( frSupportMaterial, // The width parameter accepted by new_from_config_width is of type ConfigOptionFloatOrPercent, the Flow class takes care of the percent to value substitution. - (object->print()->config.first_layer_extrusion_width.value > 0) ? object->print()->config.first_layer_extrusion_width : object->config.support_material_extrusion_width, + (width.value > 0) ? width : object->config.extrusion_width, float(object->print()->config.nozzle_diameter.get_at(object->config.support_material_extruder-1)), (layer_height > 0.f) ? layer_height : float(object->config.first_layer_height.get_abs_value(object->config.layer_height.value)), false); diff --git a/xs/src/libslic3r/Flow.hpp b/xs/src/libslic3r/Flow.hpp index a058cc8b7..516490b35 100644 --- a/xs/src/libslic3r/Flow.hpp +++ b/xs/src/libslic3r/Flow.hpp @@ -52,6 +52,9 @@ public: coord_t scaled_spacing(const Flow &other) const { return coord_t(scale_(this->spacing(other))); }; static Flow new_from_config_width(FlowRole role, const ConfigOptionFloatOrPercent &width, float nozzle_diameter, float height, float bridge_flow_ratio); + // Create a flow from the spacing of extrusion lines. + // This method is used exclusively to calculate new flow of 100% infill, where the extrusion width was allowed to scale + // to fit a region with integer number of lines. static Flow new_from_spacing(float spacing, float nozzle_diameter, float height, bool bridge); }; diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index 4b47deab2..4ad08192a 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -707,7 +707,10 @@ double Print::skirt_first_layer_height() const Flow Print::brim_flow() const { ConfigOptionFloatOrPercent width = this->config.first_layer_extrusion_width; - if (width.value == 0) width = this->regions.front()->config.perimeter_extrusion_width; + if (width.value == 0) + width = this->regions.front()->config.perimeter_extrusion_width; + if (width.value == 0) + width = this->objects.front()->config.extrusion_width; /* We currently use a random region's perimeter extruder. While this works for most cases, we should probably consider all of the perimeter @@ -726,7 +729,10 @@ Flow Print::brim_flow() const Flow Print::skirt_flow() const { ConfigOptionFloatOrPercent width = this->config.first_layer_extrusion_width; - if (width.value == 0) width = this->regions.front()->config.perimeter_extrusion_width; + if (width.value == 0) + width = this->regions.front()->config.perimeter_extrusion_width; + if (width.value == 0) + width = this->objects.front()->config.extrusion_width; /* We currently use a random object's support material extruder. While this works for most cases, we should probably consider all of the support material diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index e3bbb9eab..54d51c237 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -243,9 +243,8 @@ PrintConfigDef::PrintConfigDef() def->label = "External perimeters"; def->category = "Extrusion Width"; def->tooltip = "Set this to a non-zero value to set a manual extrusion width for external perimeters. " - "If left zero, an automatic value will be used that maximizes accuracy " - "of the external visible surfaces. If expressed as percentage (for example 200%) " - "it will be computed over layer height."; + "If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. " + "If expressed as percentage (for example 200%), it will be computed over layer height."; def->sidetext = "mm or % (leave 0 for default)"; def->cli = "external-perimeter-extrusion-width=s"; def->default_value = new ConfigOptionFloatOrPercent(0, false); @@ -352,9 +351,10 @@ PrintConfigDef::PrintConfigDef() def = this->add("extrusion_width", coFloatOrPercent); def->label = "Default extrusion width"; def->category = "Extrusion Width"; - def->tooltip = "Set this to a non-zero value to set a manual extrusion width. If left to zero, " - "Slic3r calculates a width automatically. If expressed as percentage (for example: 230%) " - "it will be computed over layer height."; + def->tooltip = "Set this to a non-zero value to allow a manual extrusion width. " + "If left to zero, Slic3r derives extrusion widths from the nozzle diameter " + "(see the tooltips for perimeter extrusion width, infill extrusion width etc). " + "If expressed as percentage (for example: 230%), it will be computed over layer height."; def->sidetext = "mm or % (leave 0 for auto)"; def->cli = "extrusion-width=s"; def->default_value = new ConfigOptionFloatOrPercent(0, false); @@ -567,7 +567,7 @@ PrintConfigDef::PrintConfigDef() def->tooltip = "Set this to a non-zero value to set a manual extrusion width for first layer. " "You can use this to force fatter extrudates for better adhesion. If expressed " "as percentage (for example 120%) it will be computed over first layer height. " - "If set to zero, it will use the Default Extrusion Width."; + "If set to zero, it will use the default extrusion width."; def->sidetext = "mm or % (leave 0 for default)"; def->cli = "first-layer-extrusion-width=s"; def->ratio_over = "first_layer_height"; @@ -681,6 +681,7 @@ PrintConfigDef::PrintConfigDef() def->label = "Infill"; def->category = "Extrusion Width"; def->tooltip = "Set this to a non-zero value to set a manual extrusion width for infill. " + "If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. " "You may want to use fatter extrudates to speed up the infill and make your parts stronger. " "If expressed as percentage (for example 90%) it will be computed over layer height."; def->sidetext = "mm or % (leave 0 for default)"; @@ -938,6 +939,7 @@ PrintConfigDef::PrintConfigDef() def->category = "Extrusion Width"; def->tooltip = "Set this to a non-zero value to set a manual extrusion width for perimeters. " "You may want to use thinner extrudates to get more accurate surfaces. " + "If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. " "If expressed as percentage (for example 200%) it will be computed over layer height."; def->sidetext = "mm or % (leave 0 for default)"; def->cli = "perimeter-extrusion-width=s"; @@ -1259,9 +1261,9 @@ PrintConfigDef::PrintConfigDef() def = this->add("solid_infill_extrusion_width", coFloatOrPercent); def->label = "Solid infill"; def->category = "Extrusion Width"; - def->tooltip = "Set this to a non-zero value to set a manual extrusion width for infill " - "for solid surfaces. If expressed as percentage (for example 90%) it will be computed " - "over layer height."; + def->tooltip = "Set this to a non-zero value to set a manual extrusion width for infill for solid surfaces. " + "If left zero, default extrusion width will be used if set, otherwise 1.125 x nozzle diameter will be used. " + "If expressed as percentage (for example 90%) it will be computed over layer height."; def->sidetext = "mm or % (leave 0 for default)"; def->cli = "solid-infill-extrusion-width=s"; def->default_value = new ConfigOptionFloatOrPercent(0, false); @@ -1422,6 +1424,7 @@ PrintConfigDef::PrintConfigDef() def->label = "Support material"; def->category = "Extrusion Width"; def->tooltip = "Set this to a non-zero value to set a manual extrusion width for support material. " + "If left zero, default extrusion width will be used if set, otherwise nozzle diameter will be used. " "If expressed as percentage (for example 90%) it will be computed over layer height."; def->sidetext = "mm or % (leave 0 for default)"; def->cli = "support-material-extrusion-width=s"; @@ -1580,10 +1583,10 @@ PrintConfigDef::PrintConfigDef() def = this->add("top_infill_extrusion_width", coFloatOrPercent); def->label = "Top solid infill"; def->category = "Extrusion Width"; - def->tooltip = "Set this to a non-zero value to set a manual extrusion width " - "for infill for top surfaces. You may want to use thinner extrudates " - "to fill all narrow regions and get a smoother finish. If expressed " - "as percentage (for example 90%) it will be computed over layer height."; + def->tooltip = "Set this to a non-zero value to set a manual extrusion width for infill for top surfaces. " + "You may want to use thinner extrudates to fill all narrow regions and get a smoother finish. " + "If left zero, default extrusion width will be used if set, otherwise nozzle diameter will be used. " + "If expressed as percentage (for example 90%) it will be computed over layer height."; def->sidetext = "mm or % (leave 0 for default)"; def->cli = "top-infill-extrusion-width=s"; def->default_value = new ConfigOptionFloatOrPercent(0, false); diff --git a/xs/src/perlglue.cpp b/xs/src/perlglue.cpp index fbc8df8d2..948fcfd93 100644 --- a/xs/src/perlglue.cpp +++ b/xs/src/perlglue.cpp @@ -61,6 +61,7 @@ REGISTER_CLASS(GLVolumeCollection, "GUI::_3DScene::GLVolume::Collection"); REGISTER_CLASS(Preset, "GUI::Preset"); REGISTER_CLASS(PresetCollection, "GUI::PresetCollection"); REGISTER_CLASS(PresetBundle, "GUI::PresetBundle"); +REGISTER_CLASS(PresetHints, "GUI::PresetHints"); SV* ConfigBase__as_hash(ConfigBase* THIS) { diff --git a/xs/src/slic3r/GUI/PresetHints.cpp b/xs/src/slic3r/GUI/PresetHints.cpp new file mode 100644 index 000000000..082286ede --- /dev/null +++ b/xs/src/slic3r/GUI/PresetHints.cpp @@ -0,0 +1,254 @@ +//#undef NDEBUGc +#include + +#include "PresetBundle.hpp" +#include "PresetHints.hpp" +#include "Flow.hpp" + +#include + +#include "../../libslic3r/libslic3r.h" + +namespace Slic3r { + +std::string PresetHints::cooling_description(const Preset &preset) +{ + std::string out; + char buf[4096]; + if (preset.config.opt_bool("cooling", 0)) { + int slowdown_below_layer_time = preset.config.opt_int("slowdown_below_layer_time", 0); + int min_fan_speed = preset.config.opt_int("min_fan_speed", 0); + int max_fan_speed = preset.config.opt_int("max_fan_speed", 0); + int min_print_speed = int(preset.config.opt_float("min_print_speed", 0) + 0.5); + int fan_below_layer_time = preset.config.opt_int("fan_below_layer_time", 0); + sprintf(buf, "If estimated layer time is below ~%ds, fan will run at %d%% and print speed will be reduced so that no less than %ds are spent on that layer (however, speed will never be reduced below %dmm/s).", + slowdown_below_layer_time, max_fan_speed, slowdown_below_layer_time, min_print_speed); + out += buf; + if (fan_below_layer_time > slowdown_below_layer_time) { + sprintf(buf, "\nIf estimated layer time is greater, but still below ~%ds, fan will run at a proportionally decreasing speed between %d%% and %d%%.", + fan_below_layer_time, max_fan_speed, min_fan_speed); + out += buf; + } + out += "\nDuring the other layers, fan "; + } else { + out = "Fan "; + } + if (preset.config.opt_bool("fan_always_on", 0)) { + int disable_fan_first_layers = preset.config.opt_int("disable_fan_first_layers", 0); + int min_fan_speed = preset.config.opt_int("min_fan_speed", 0); + sprintf(buf, "will always run at %d% ", min_fan_speed); + out += buf; + if (disable_fan_first_layers > 1) { + sprintf(buf, "except for the first %d layers", disable_fan_first_layers); + out += buf; + } + else if (disable_fan_first_layers == 1) + out += "except for the first layer"; + } else + out += "will be turned off."; + + return out; +} + +std::string PresetHints::maximum_volumetric_flow_description(const PresetBundle &preset_bundle) +{ + // Find out, to which nozzle index is the current filament profile assigned. + unsigned int idx_nozzle = 0; + for (; idx_nozzle < (unsigned int)preset_bundle.filaments.size(); ++ idx_nozzle) + if (preset_bundle.filament_presets[idx_nozzle] == preset_bundle.filaments.get_selected_preset().name) + break; + if (idx_nozzle == (unsigned int)preset_bundle.filaments.size()) + // The current filament preset is not active for any extruder. + idx_nozzle = (unsigned int)-1; + + const DynamicPrintConfig &print_config = preset_bundle.prints .get_edited_preset().config; + const DynamicPrintConfig &filament_config = preset_bundle.filaments.get_edited_preset().config; + const DynamicPrintConfig &printer_config = preset_bundle.printers .get_edited_preset().config; + + // Current printer values. + double nozzle_diameter = printer_config.opt_float("nozzle_diameter", idx_nozzle); + + // Print config values + double layer_height = print_config.get_abs_value("layer_height", nozzle_diameter); + double first_layer_height = print_config.get_abs_value("first_layer_height", layer_height); + double support_material_speed = print_config.opt_float("support_material_speed"); + double support_material_interface_speed = print_config.get_abs_value("support_material_interface_speed", support_material_speed); + double bridge_speed = print_config.opt_float("bridge_speed"); + double bridge_flow_ratio = print_config.opt_float("bridge_flow_ratio"); + double perimeter_speed = print_config.opt_float("perimeter_speed"); + double external_perimeter_speed = print_config.get_abs_value("external_perimeter_speed", perimeter_speed); + double gap_fill_speed = print_config.opt_float("gap_fill_speed"); + double infill_speed = print_config.opt_float("infill_speed"); + double small_perimeter_speed = print_config.get_abs_value("small_perimeter_speed", perimeter_speed); + double solid_infill_speed = print_config.get_abs_value("solid_infill_speed", infill_speed); + double top_solid_infill_speed = print_config.get_abs_value("top_solid_infill_speed", solid_infill_speed); + // Maximum print speed when auto-speed is enabled by setting any of the above speed values to zero. + double max_print_speed = print_config.opt_float("max_print_speed"); + // Maximum volumetric speed allowed for the print profile. + double max_volumetric_speed = print_config.opt_float("max_volumetric_speed"); + + const auto &extrusion_width = print_config.get_abs_value("extrusion_width"); + const auto &support_material_extrusion_width = *print_config.option("support_material_extrusion_width"); + const auto &external_perimeter_extrusion_width = *print_config.option("external_perimeter_extrusion_width"); + const auto &infill_extrusion_width = *print_config.option("infill_extrusion_width"); + const auto &solid_infill_extrusion_width = *print_config.option("solid_infill_extrusion_width"); + const auto &perimeter_extrusion_width = *print_config.option("perimeter_extrusion_width"); + const auto &top_infill_extrusion_width = *print_config.option("top_infill_extrusion_width"); + const auto &first_layer_extrusion_width = *print_config.option("first_layer_extrusion_width"); + + int perimeter_extruder = print_config.opt_int("perimeter_extruder"); + int infill_extruder = print_config.opt_int("infill_extruder"); + int solid_infill_extruder = print_config.opt_int("solid_infill_extruder"); + int support_material_extruder = print_config.opt_int("support_material_extruder"); + int support_material_interface_extruder = print_config.opt_int("support_material_interface_extruder"); + + // Current filament values + double filament_diameter = filament_config.opt_float("filament_diameter", 0); + double extrusion_multiplier = filament_config.opt_float("extrusion_multiplier", 0); + double filament_max_volumetric_speed = filament_config.opt_float("filament_max_volumetric_speed", 0); + + + auto external_perimeter_flow = Flow::new_from_config_width(frExternalPerimeter, external_perimeter_extrusion_width, (float)nozzle_diameter, (float)layer_height, 0); + auto perimeter_flow = Flow::new_from_config_width(frPerimeter, perimeter_extrusion_width, (float)nozzle_diameter, (float)layer_height, 0); + auto infill_flow = Flow::new_from_config_width(frInfill, infill_extrusion_width, (float)nozzle_diameter, (float)layer_height, 0); + auto solid_infill_flow = Flow::new_from_config_width(frInfill, solid_infill_extrusion_width, (float)nozzle_diameter, (float)layer_height, 0); + auto top_solid_infill_flow = Flow::new_from_config_width(frInfill, top_infill_extrusion_width, (float)nozzle_diameter, (float)layer_height, 0); +// auto support_material_flow = Flow::new_from_config_width(frSupportMaterial, , +// (float)nozzle_diameter, (float)layer_height, 0); + auto support_material_interface_flow = Flow::new_from_config_width(frSupportMaterialInterface, *print_config.option("support_material_extrusion_width"), + (float)nozzle_diameter, (float)layer_height, 0); + + std::string out; + out="Hu"; + return out; +} + +#if 0 +static create_flow(FlowRole role, ConfigOptionFloatOrPercent &width, double layer_height, bool bridge, bool first_layer, double width) const +{ + ConfigOptionFloatOrPercent config_width; + if (width != -1) { + // use the supplied custom width, if any + config_width.value = width; + config_width.percent = false; + } else { + // otherwise, get extrusion width from configuration + // (might be an absolute value, or a percent value, or zero for auto) + if (first_layer && this->_print->config.first_layer_extrusion_width.value > 0) { + config_width = this->_print->config.first_layer_extrusion_width; + } else if (role == frExternalPerimeter) { + config_width = this->config.external_perimeter_extrusion_width; + } else if (role == frPerimeter) { + config_width = this->config.perimeter_extrusion_width; + } else if (role == frInfill) { + config_width = this->config.infill_extrusion_width; + } else if (role == frSolidInfill) { + config_width = this->config.solid_infill_extrusion_width; + } else if (role == frTopSolidInfill) { + config_width = this->config.top_infill_extrusion_width; + } else { + CONFESS("Unknown role"); + } + } + if (config_width.value == 0) { + config_width = object.config.extrusion_width; + } + + // get the configured nozzle_diameter for the extruder associated + // to the flow role requested + size_t extruder = 0; // 1-based + if (role == frPerimeter || role == frExternalPerimeter) { + extruder = this->config.perimeter_extruder; + } else if (role == frInfill) { + extruder = this->config.infill_extruder; + } else if (role == frSolidInfill || role == frTopSolidInfill) { + extruder = this->config.solid_infill_extruder; + } else { + CONFESS("Unknown role $role"); + } + double nozzle_diameter = this->_print->config.nozzle_diameter.get_at(extruder-1); + + return Flow::new_from_config_width(role, config_width, nozzle_diameter, layer_height, bridge ? (float)this->config.bridge_flow_ratio : 0.0); +} + + if (first_layer && this->_print->config.first_layer_extrusion_width.value > 0) { + config_width = this->_print->config.first_layer_extrusion_width; + auto flow = Flow::new_from_config_width(frExternalPerimeter, const ConfigOptionFloatOrPercent &width, float nozzle_diameter, float height, float bridge_flow_ratio); + + + +Flow Print::skirt_flow() const +{ + ConfigOptionFloatOrPercent width = this->config.first_layer_extrusion_width; + if (width.value == 0) width = this->regions.front()->config.perimeter_extrusion_width; + + /* We currently use a random object's support material extruder. + While this works for most cases, we should probably consider all of the support material + extruders and take the one with, say, the smallest index; + The same logic should be applied to the code that selects the extruder during G-code + generation as well. */ + return Flow::new_from_config_width( + frPerimeter, + width, + this->config.nozzle_diameter.get_at(this->objects.front()->config.support_material_extruder-1), + this->skirt_first_layer_height(), + 0 + ); +} + +Flow Print::brim_flow() const +{ + ConfigOptionFloatOrPercent width = this->config.first_layer_extrusion_width; + if (width.value == 0) width = this->regions.front()->config.perimeter_extrusion_width; + + /* We currently use a random region's perimeter extruder. + While this works for most cases, we should probably consider all of the perimeter + extruders and take the one with, say, the smallest index. + The same logic should be applied to the code that selects the extruder during G-code + generation as well. */ + return Flow::new_from_config_width( + frPerimeter, + width, + this->config.nozzle_diameter.get_at(this->regions.front()->config.perimeter_extruder-1), + this->skirt_first_layer_height(), + 0 + ); +} + +Flow support_material_flow(const PrintObject *object, float layer_height) +{ + return Flow::new_from_config_width( + frSupportMaterial, + // The width parameter accepted by new_from_config_width is of type ConfigOptionFloatOrPercent, the Flow class takes care of the percent to value substitution. + (support_material_extrusion_width.value > 0) ? support_material_extrusion_width : extrusion_width, + // if object->config.support_material_extruder == 0 (which means to not trigger tool change, but use the current extruder instead), get_at will return the 0th component. + float(nozzle_diameter.get_at(support_material_extruder-1)), + (layer_height > 0.f) ? layer_height : float(layer_height.value), + false); +} + +Flow support_material_1st_layer_flow(const PrintObject *object, float layer_height) +{ + return Flow::new_from_config_width( + frSupportMaterial, + // The width parameter accepted by new_from_config_width is of type ConfigOptionFloatOrPercent, the Flow class takes care of the percent to value substitution. + (first_layer_extrusion_width.value > 0) ? first_layer_extrusion_width : support_material_extrusion_width, + float(nozzle_diameter.get_at(object->config.support_material_extruder-1)), + (layer_height > 0.f) ? layer_height : float(first_layer_height)), + false); +} + +Flow support_material_interface_flow(const PrintObject *object, float layer_height) +{ + return Flow::new_from_config_width( + frSupportMaterialInterface, + // The width parameter accepted by new_from_config_width is of type ConfigOptionFloatOrPercent, the Flow class takes care of the percent to value substitution. + (support_material_extrusion_width > 0) ? support_material_extrusion_width : extrusion_width, + // if object->config.support_material_interface_extruder == 0 (which means to not trigger tool change, but use the current extruder instead), get_at will return the 0th component. + float(nozzle_diameter.get_at(object->config.support_material_interface_extruder-1)), + layer_height, + false); +} +#endif + +}; // namespace Slic3r diff --git a/xs/src/slic3r/GUI/PresetHints.hpp b/xs/src/slic3r/GUI/PresetHints.hpp new file mode 100644 index 000000000..589cc2f98 --- /dev/null +++ b/xs/src/slic3r/GUI/PresetHints.hpp @@ -0,0 +1,25 @@ +#ifndef slic3r_PresetHints_hpp_ +#define slic3r_PresetHints_hpp_ + +#include + +#include "PresetBundle.hpp" + +namespace Slic3r { + +// GUI utility functions to produce hint messages from the current profile. +class PresetHints +{ +public: + // Produce a textual description of the cooling logic of a currently active filament. + static std::string cooling_description(const Preset &preset); + // Produce a textual description of the maximum flow achived for the current configuration + // (the current printer, filament and print settigns). + // This description will be useful for getting a gut feeling for the maximum volumetric + // print speed achievable with the extruder. + static std::string maximum_volumetric_flow_description(const PresetBundle &preset_bundle); +}; + +} // namespace Slic3r + +#endif /* slic3r_PresetHints_hpp_ */ diff --git a/xs/xsp/Flow.xsp b/xs/xsp/Flow.xsp index d09f0b351..d9b7a45c0 100644 --- a/xs/xsp/Flow.xsp +++ b/xs/xsp/Flow.xsp @@ -46,18 +46,6 @@ _new_from_width(CLASS, role, width, nozzle_diameter, height, bridge_flow_ratio) OUTPUT: RETVAL -Flow* -_new_from_spacing(CLASS, spacing, nozzle_diameter, height, bridge) - char* CLASS; - float spacing; - float nozzle_diameter; - float height; - bool bridge; - CODE: - RETVAL = new Flow(Flow::new_from_spacing(spacing, nozzle_diameter, height, bridge)); - OUTPUT: - RETVAL - %} };