diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index a42c4c5a7..d0c815c6c 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -7,6 +7,7 @@ #include "SupportMaterial.hpp" #include "GCode/WipeTowerPrusaMM.hpp" #include +#include #include #include @@ -19,7 +20,9 @@ void Print::clear_objects() { for (int i = int(this->objects.size())-1; i >= 0; --i) this->delete_object(i); - this->clear_regions(); + for (PrintRegion *region : this->regions) + delete region; + this->regions.clear(); } void Print::delete_object(size_t idx) @@ -31,7 +34,7 @@ void Print::delete_object(size_t idx) // TODO: purge unused regions } -void Print::reload_object(size_t idx) +void Print::reload_object(size_t /* idx */) { /* TODO: this method should check whether the per-object config and per-material configs have changed in such a way that regions need to be rearranged or we can just apply @@ -59,13 +62,6 @@ bool Print::reload_model_instances() return invalidated; } -void Print::clear_regions() -{ - for (PrintRegion *region : this->regions) - delete region; - this->regions.clear(); -} - PrintRegion* Print::add_region() { regions.push_back(new PrintRegion(this)); @@ -79,10 +75,91 @@ bool Print::invalidate_state_by_config_options(const std::vector steps_ignore; + if (steps_ignore.empty()) { + steps_ignore.insert("avoid_crossing_perimeters"); + steps_ignore.insert("bed_shape"); + steps_ignore.insert("bed_temperature"); + steps_ignore.insert("before_layer_gcode"); + steps_ignore.insert("bridge_acceleration"); + steps_ignore.insert("bridge_fan_speed"); + steps_ignore.insert("cooling"); + steps_ignore.insert("default_acceleration"); + steps_ignore.insert("deretract_speed"); + steps_ignore.insert("disable_fan_first_layers"); + steps_ignore.insert("duplicate_distance"); + steps_ignore.insert("end_gcode"); + steps_ignore.insert("extrusion_axis"); + steps_ignore.insert("extruder_clearance_height"); + steps_ignore.insert("extruder_clearance_radius"); + steps_ignore.insert("extruder_colour"); + steps_ignore.insert("extruder_offset"); + steps_ignore.insert("extrusion_multiplier"); + steps_ignore.insert("fan_always_on"); + steps_ignore.insert("fan_below_layer_time"); + steps_ignore.insert("filament_colour"); + steps_ignore.insert("filament_diameter"); + steps_ignore.insert("filament_density"); + steps_ignore.insert("filament_notes"); + steps_ignore.insert("filament_cost"); + steps_ignore.insert("filament_max_volumetric_speed"); + steps_ignore.insert("first_layer_acceleration"); + steps_ignore.insert("first_layer_bed_temperature"); + steps_ignore.insert("first_layer_speed"); + steps_ignore.insert("gcode_comments"); + steps_ignore.insert("gcode_flavor"); + steps_ignore.insert("infill_acceleration"); + steps_ignore.insert("infill_first"); + steps_ignore.insert("layer_gcode"); + steps_ignore.insert("min_fan_speed"); + steps_ignore.insert("max_fan_speed"); + steps_ignore.insert("min_print_speed"); + steps_ignore.insert("max_print_speed"); + steps_ignore.insert("max_volumetric_speed"); + steps_ignore.insert("max_volumetric_extrusion_rate_slope_positive"); + steps_ignore.insert("max_volumetric_extrusion_rate_slope_negative"); + steps_ignore.insert("notes"); + steps_ignore.insert("only_retract_when_crossing_perimeters"); + steps_ignore.insert("output_filename_format"); + steps_ignore.insert("perimeter_acceleration"); + steps_ignore.insert("post_process"); + steps_ignore.insert("printer_notes"); + steps_ignore.insert("retract_before_travel"); + steps_ignore.insert("retract_before_wipe"); + steps_ignore.insert("retract_layer_change"); + steps_ignore.insert("retract_length"); + steps_ignore.insert("retract_length_toolchange"); + steps_ignore.insert("retract_lift"); + steps_ignore.insert("retract_lift_above"); + steps_ignore.insert("retract_lift_below"); + steps_ignore.insert("retract_restart_extra"); + steps_ignore.insert("retract_restart_extra_toolchange"); + steps_ignore.insert("retract_speed"); + steps_ignore.insert("slowdown_below_layer_time"); + steps_ignore.insert("standby_temperature_delta"); + steps_ignore.insert("start_gcode"); + steps_ignore.insert("toolchange_gcode"); + steps_ignore.insert("threads"); + steps_ignore.insert("travel_speed"); + steps_ignore.insert("use_firmware_retraction"); + steps_ignore.insert("use_relative_e_distances"); + steps_ignore.insert("use_volumetric_e"); + steps_ignore.insert("set_and_wait_temperatures"); + steps_ignore.insert("variable_layer_height"); + steps_ignore.insert("wipe"); + } + std::vector steps; std::vector osteps; + bool invalidated = false; for (const t_config_option_key &opt_key : opt_keys) { - if ( opt_key == "skirts" + if (steps_ignore.find(opt_key) != steps_ignore.end()) { + // These options only affect G-code export or they are just notes without influence on the generated G-code, + // so there is nothing to invalidate. + } else if ( + opt_key == "skirts" || opt_key == "skirt_height" || opt_key == "skirt_distance" || opt_key == "min_skirt_length" @@ -91,12 +168,14 @@ bool Print::invalidate_state_by_config_options(const std::vectorinvalidate_all_steps(); + invalidated |= this->invalidate_all_steps(); + // Continue with the other opt_keys to possibly invalidate any object specific steps. } } - - bool invalidated = false; + sort_remove_duplicates(steps); for (PrintStep step : steps) invalidated |= this->invalidate_step(step); @@ -198,6 +220,7 @@ bool Print::invalidate_step(PrintStep step) { bool invalidated = this->state.invalidate(step); // Propagate to dependent steps. + //FIXME Why should skirt invalidate brim? Shouldn't it be vice versa? if (step == psSkirt) invalidated |= this->state.invalidate(psBrim); return invalidated; diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp index c54ff847f..af4c0e28c 100644 --- a/xs/src/libslic3r/Print.hpp +++ b/xs/src/libslic3r/Print.hpp @@ -252,7 +252,6 @@ public: PrintRegion* add_region(); // methods for handling state - bool invalidate_state_by_config_options(const std::vector &opt_keys); bool invalidate_step(PrintStep step); bool invalidate_all_steps() { return this->state.invalidate_all(); } bool step_done(PrintObjectStep step) const; @@ -294,7 +293,7 @@ public: std::string output_filepath(const std::string &path); private: - void clear_regions(); + bool invalidate_state_by_config_options(const std::vector &opt_keys); PrintRegionConfig _region_config_from_model_volume(const ModelVolume &volume); }; diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 0ef715288..a4c7b39da 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -162,7 +162,7 @@ class StaticPrintConfig : public PrintConfigBase, public StaticConfig // This object is mapped to Perl as Slic3r::Config::PrintObject. class PrintObjectConfig : public virtual StaticPrintConfig { - public: +public: ConfigOptionBool clip_multipart_objects; ConfigOptionBool dont_support_bridges; ConfigOptionFloatOrPercent extrusion_width; @@ -555,7 +555,7 @@ public: class HostConfig : public virtual StaticPrintConfig { - public: +public: ConfigOptionString octoprint_host; ConfigOptionString octoprint_apikey; ConfigOptionString serial_port; diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index 990f41a36..6ecbe7910 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -137,7 +137,7 @@ bool PrintObject::invalidate_state_by_config_options(const std::vector steps; for (const t_config_option_key &opt_key : opt_keys) { - if (opt_key == "perimeters" + if ( opt_key == "perimeters" || opt_key == "extra_perimeters" || opt_key == "gap_fill_speed" || opt_key == "overhangs" @@ -147,25 +147,29 @@ bool PrintObject::invalidate_state_by_config_options(const std::vectorreset_layer_height_profile(); } - else if (opt_key == "clip_multipart_objects" + else if ( + opt_key == "clip_multipart_objects" || opt_key == "xy_size_compensation") { steps.emplace_back(posSlice); - } else if (opt_key == "support_material" + } else if ( + opt_key == "support_material" || opt_key == "support_material_angle" + || opt_key == "support_material_buildplate_only" + || opt_key == "support_material_contact_distance" + || opt_key == "support_material_enforce_layers" || opt_key == "support_material_extruder" || opt_key == "support_material_extrusion_width" || opt_key == "support_material_interface_layers" || opt_key == "support_material_interface_contact_loops" || opt_key == "support_material_interface_extruder" || opt_key == "support_material_interface_spacing" - || opt_key == "support_material_interface_speed" - || opt_key == "support_material_buildplate_only" || opt_key == "support_material_pattern" || opt_key == "support_material_xy_spacing" || opt_key == "support_material_spacing" @@ -175,7 +179,8 @@ bool PrintObject::invalidate_state_by_config_options(const std::vectorinvalidate_step(posPrepareInfill) || this->_print->invalidate_step(psSkirt) || - this->_print->invalidate_step(psBrim) || - this->_print->invalidate_step(psWipeTower); + this->_print->invalidate_step(psBrim); } else if (step == posPrepareInfill) { invalidated |= this->invalidate_step(posInfill); } else if (step == posInfill) { invalidated |= this->_print->invalidate_step(psSkirt) || - this->_print->invalidate_step(psBrim) || - this->_print->invalidate_step(psWipeTower); + this->_print->invalidate_step(psBrim); } else if (step == posSlice) { invalidated |= - this->invalidate_step(posPerimeters) || - this->invalidate_step(posSupportMaterial) || - this->_print->invalidate_step(psWipeTower); + this->invalidate_step(posPerimeters) || + this->invalidate_step(posSupportMaterial); } else if (step == posSupportMaterial) { invalidated |= - this->_print->invalidate_step(psSkirt) || - this->_print->invalidate_step(psBrim) || - this->_print->invalidate_step(psWipeTower); + this->_print->invalidate_step(psSkirt) || + this->_print->invalidate_step(psBrim); } + // Wipe tower depends on the ordering of extruders, which in turn depends on everything. + invalidated |= this->_print->invalidate_step(psWipeTower); return invalidated; }