Skip to content

Commit

Permalink
Merge branch 'merill-merge'
Browse files Browse the repository at this point in the history
  • Loading branch information
remi durand committed Jun 25, 2021
2 parents cf03815 + ba04b3e commit 49300aa
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 104 deletions.
180 changes: 95 additions & 85 deletions resources/localization/fr/Slic3r.po

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/libslic3r/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,14 +469,15 @@ void ConfigBase::apply_only(const ConfigBase &other, const t_config_option_keys
}

// this will *ignore* options not present in both configs
t_config_option_keys ConfigBase::diff(const ConfigBase &other) const
t_config_option_keys ConfigBase::diff(const ConfigBase &other, bool even_phony /*=true*/) const
{
t_config_option_keys diff;
for (const t_config_option_key &opt_key : this->keys()) {
const ConfigOption *this_opt = this->option(opt_key);
const ConfigOption *other_opt = other.option(opt_key);
//dirty if both exist, they aren't both phony and value is different
if (this_opt != nullptr && other_opt != nullptr && !(this_opt->is_phony() && other_opt->is_phony())
if (this_opt != nullptr && other_opt != nullptr
&& (even_phony || !(this_opt->is_phony() && other_opt->is_phony()))
&& ((*this_opt != *other_opt) || (this_opt->is_phony() != other_opt->is_phony())))
diff.emplace_back(opt_key);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1886,7 +1886,7 @@ class ConfigBase : public ConfigOptionResolver
// or this ConfigBase is of a StaticConfig type and it does not support some of the keys, and ignore_nonexistent is not set.
void apply_only(const ConfigBase &other, const t_config_option_keys &keys, bool ignore_nonexistent = false);
bool equals(const ConfigBase &other) const { return this->keys().size() == other.keys().size() && this->diff(other).empty(); }
t_config_option_keys diff(const ConfigBase &other) const;
t_config_option_keys diff(const ConfigBase &other, bool even_phony = true) const;
t_config_option_keys equal(const ConfigBase &other) const;
std::string opt_serialize(const t_config_option_key &opt_key) const;

Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Fill/FillBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void Fill::fill_surface_extrusion(const Surface *surface, const FillParams &para

coord_t Fill::_line_spacing_for_density(float density) const
{
return coord_t(scale_(this->get_spacing()) / density);
return scale_(this->get_spacing() / density);
}

//FIXME: add recent improvmeent from perimetergenerator: avoid thick gapfill
Expand Down
13 changes: 9 additions & 4 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
for (LayerToPrint &ltp : layers_to_print) {
std::vector<LayerToPrint> lrs;
lrs.emplace_back(std::move(ltp));
this->process_layer(file, print, print.m_print_statistics, lrs, tool_ordering.tools_for_layer(ltp.print_z() + print.config().z_offset), nullptr, *print_object_instance_sequential_active - object.instances().data());
this->process_layer(file, print, print.m_print_statistics, lrs, tool_ordering.tools_for_layer(ltp.print_z()), nullptr, *print_object_instance_sequential_active - object.instances().data());
print.throw_if_canceled();
}
#ifdef HAS_PRESSURE_EQUALIZER
Expand Down Expand Up @@ -1905,6 +1905,7 @@ std::vector<GCode::InstanceToPrint> GCode::sort_print_object_instances(
}

std::string GCode::emit_custom_gcode_per_print_z(
GCode &gcodegen,
const CustomGCode::Item *custom_gcode,
// ID of the first extruder printing this layer.
uint16_t first_extruder_id,
Expand Down Expand Up @@ -1966,6 +1967,10 @@ std::string GCode::emit_custom_gcode_per_print_z(
} else {
gcode += print.config().color_change_gcode;//ColorChangeCode;
gcode += "\n";
//FIXME Tell G-code writer that M600 filled the extruder, thus the G-code writer shall reset the extruder to unretracted state after
// return from M600. Thus the G-code generated by the following line is ignored.
// see GH issue #6362
gcodegen.writer().unretract();
}
} else {
if (gcode_type == CustomGCode::PausePrint) // Pause print
Expand Down Expand Up @@ -2186,7 +2191,7 @@ void GCode::process_layer(

if (single_object_instance_idx == size_t(-1)) {
// Normal (non-sequential) print.
gcode += this->emit_custom_gcode_per_print_z(layer_tools.custom_gcode, first_extruder_id, print, print_stat);
gcode += this->emit_custom_gcode_per_print_z(*this, layer_tools.custom_gcode, first_extruder_id, print, print_stat);
}
// Extrude skirt at the print_z of the raft layers and normal object layers
// not at the print_z of the interlaced support material layers.
Expand Down Expand Up @@ -4059,7 +4064,7 @@ std::string GCode::set_extruder(uint16_t extruder_id, double print_z, bool no_to
}
if (!no_toolchange) {
gcode+=toolchange(extruder_id, print_z);
}
}else m_writer.toolchange(extruder_id);
return gcode;
}

Expand Down Expand Up @@ -4094,7 +4099,7 @@ std::string GCode::set_extruder(uint16_t extruder_id, double print_z, bool no_to

if (!no_toolchange) {
gcode += toolchange(extruder_id, print_z);
}
}else m_writer.toolchange(extruder_id);

// Set the temperature if the wipe tower didn't (not needed for non-single extruder MM)
// supermerill change: try to set the good temp, because the wipe tower don't use the gcode writer and so can write wrong stuff.
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/GCode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class GCode : ExtrusionVisitorConst {
static void append_full_config(const Print& print, std::string& str);

// called by porcess_layer, do the color change / custom gcode
std::string emit_custom_gcode_per_print_z(const CustomGCode::Item* custom_gcode, uint16_t first_extruder_id, const Print& print, PrintStatistics& stats);
std::string emit_custom_gcode_per_print_z(GCode& gcodegen, const CustomGCode::Item* custom_gcode, uint16_t first_extruder_id, const Print& print, PrintStatistics& stats);

// Object and support extrusions of the same PrintObject at the same print_z.
// public, so that it could be accessed by free helper functions from GCode.cpp
Expand Down
11 changes: 6 additions & 5 deletions src/libslic3r/Preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1391,14 +1391,15 @@ void add_correct_opts_to_diff(const std::string &opt_key, t_config_option_keys&
}

// Use deep_diff to correct return of changed options, considering individual options for each extruder.
inline t_config_option_keys deep_diff(const ConfigBase &config_this, const ConfigBase &config_other)
inline t_config_option_keys deep_diff(const ConfigBase &config_this, const ConfigBase &config_other, bool ignore_phony)
{
t_config_option_keys diff;
for (const t_config_option_key &opt_key : config_this.keys()) {
const ConfigOption *this_opt = config_this.option(opt_key);
const ConfigOption *other_opt = config_other.option(opt_key);
//dirty if both exist, they aren't both phony and value is different
if (this_opt != nullptr && other_opt != nullptr && !(this_opt->is_phony() && other_opt->is_phony())
if (this_opt != nullptr && other_opt != nullptr
&& (ignore_phony || !(this_opt->is_phony() && other_opt->is_phony()))
&& ((*this_opt != *other_opt) || (this_opt->is_phony() != other_opt->is_phony())))
{
if (opt_key == "bed_shape" || opt_key == "compatible_prints" || opt_key == "compatible_printers") {
Expand All @@ -1425,13 +1426,13 @@ inline t_config_option_keys deep_diff(const ConfigBase &config_this, const Confi
return diff;
}

std::vector<std::string> PresetCollection::dirty_options(const Preset *edited, const Preset *reference, const bool deep_compare /*= false*/)
std::vector<std::string> PresetCollection::dirty_options(const Preset *edited, const Preset *reference, const bool deep_compare /*= false*/, const bool ignore_phony)
{
std::vector<std::string> changed;
if (edited != nullptr && reference != nullptr) {
changed = deep_compare ?
deep_diff(edited->config, reference->config) :
reference->config.diff(edited->config);
deep_diff(edited->config, reference->config, ignore_phony) :
reference->config.diff(edited->config, ignore_phony);
// The "compatible_printers" option key is handled differently from the others:
// It is not mandatory. If the key is missing, it means it is compatible with any printer.
// If the key exists and it is empty, it means it is compatible with no printer.
Expand Down
5 changes: 3 additions & 2 deletions src/libslic3r/Preset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,9 @@ class PresetCollection
// Compare the content of get_selected_preset() with get_edited_preset() configs, return true if they differ.
bool current_is_dirty() const { return ! this->current_dirty_options().empty(); }
// Compare the content of get_selected_preset() with get_edited_preset() configs, return the list of keys where they differ.
// Note that it won't take into account phony settings. Because current_dirty_options() is only used to see if the preset need to be saved.
std::vector<std::string> current_dirty_options(const bool deep_compare = false) const
{ return dirty_options(&this->get_edited_preset(), &this->get_selected_preset(), deep_compare); }
{ return dirty_options(&this->get_edited_preset(), &this->get_selected_preset(), deep_compare, false); }
// Compare the content of get_selected_preset() with get_edited_preset() configs, return the list of keys where they differ.
std::vector<std::string> current_different_from_parent_options(const bool deep_compare = false) const
{ return dirty_options(&this->get_edited_preset(), this->get_selected_preset_parent(), deep_compare); }
Expand Down Expand Up @@ -518,7 +519,7 @@ class PresetCollection

size_t update_compatible_internal(const PresetWithVendorProfile &active_printer, const PresetWithVendorProfile *active_print, PresetSelectCompatibleType unselect_if_incompatible);

static std::vector<std::string> dirty_options(const Preset *edited, const Preset *reference, const bool is_printer_type = false);
static std::vector<std::string> dirty_options(const Preset *edited, const Preset *reference, const bool deep_compare = false, const bool ignore_phony = true);

// Type of this PresetCollection: TYPE_PRINT, TYPE_FILAMENT or TYPE_PRINTER.
Preset::Type m_type;
Expand Down
1 change: 0 additions & 1 deletion src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5382,7 +5382,6 @@ void PrintConfigDef::to_prusa(t_config_option_key& opt_key, std::string& value,
"chamber_temperature",
"complete_objects_one_skirt",
"complete_objects_sort",
"top_fill_pattern",
"solid_fill_pattern",
"enforce_full_fill_volume",
"external_infill_margin",
Expand Down
7 changes: 7 additions & 0 deletions src/libslic3r/PrintObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ namespace Slic3r {
|| opt_key == "overhangs_width"
|| opt_key == "overhangs_reverse"
|| opt_key == "overhangs_reverse_threshold"
|| opt_key == "perimeter_extrusion_spacing"
|| opt_key == "perimeter_extrusion_width"
|| opt_key == "infill_overlap"
|| opt_key == "thin_perimeters"
Expand All @@ -695,6 +696,8 @@ namespace Slic3r {
|| opt_key == "external_perimeters_first"
|| opt_key == "external_perimeters_hole"
|| opt_key == "external_perimeters_nothole"
|| opt_key == "external_perimeter_extrusion_spacing"
|| opt_key == "external_perimeter_extrusion_width"
|| opt_key == "external_perimeters_vase"
|| opt_key == "perimeter_loop"
|| opt_key == "perimeter_loop_seam") {
Expand Down Expand Up @@ -763,6 +766,7 @@ namespace Slic3r {
|| opt_key == "fill_density"
|| opt_key == "interface_shells"
|| opt_key == "infill_extruder"
|| opt_key == "infill_extrusion_spacing"
|| opt_key == "infill_extrusion_width"
|| opt_key == "infill_every_layers"
|| opt_key == "infill_dense"
Expand Down Expand Up @@ -793,6 +797,7 @@ namespace Slic3r {
|| opt_key == "infill_connection_solid"
|| opt_key == "infill_connection_top"
|| opt_key == "infill_connection_bottom"
|| opt_key == "top_infill_extrusion_spacing"
|| opt_key == "top_infill_extrusion_width") {
steps.emplace_back(posInfill);
} else if (
Expand All @@ -804,6 +809,7 @@ namespace Slic3r {
|| opt_key == "no_perimeter_unsupported_algo"
|| opt_key == "perimeters"
|| opt_key == "perimeter_overlap"
|| opt_key == "solid_infill_extrusion_spacing"
|| opt_key == "solid_infill_extrusion_width") {
steps.emplace_back(posPerimeters);
steps.emplace_back(posPrepareInfill);
Expand All @@ -813,6 +819,7 @@ namespace Slic3r {
steps.emplace_back(posPerimeters);
steps.emplace_back(posSupportMaterial);
} else if (opt_key == "bridge_flow_ratio"
|| opt_key == "first_layer_extrusion_spacing"
|| opt_key == "first_layer_extrusion_width") {
//if (m_config.support_material_contact_distance > 0.) {
// Only invalidate due to bridging if bridging is enabled.
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/GUI_Preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ wxBoxSizer* Preview::create_layers_slider_sizer()
Info custom_gcode_per_print_z = m_layers_slider->GetTicksValues();
//remove z-shift from gcode output
const float z_shift = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_float("z_offset");
if (can_display_gcode() && z_shift != 0) {
if (can_display_gcode() && z_shift != 0 && ForceState::ForceExtrusions != current_force_state) {
for (CustomGCode::Item& tick : custom_gcode_per_print_z.gcodes) {
tick.print_z -= z_shift;
}
Expand Down Expand Up @@ -751,7 +751,7 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee
{
//add z-shift from gcode output
const float z_shift = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_float("z_offset");
if (can_display_gcode() && z_shift != 0) {
if (can_display_gcode() && z_shift != 0 && ForceState::ForceExtrusions != current_force_state) {
for (CustomGCode::Item& tick : ticks_info_from_model.gcodes) {
tick.print_z += z_shift;
}
Expand Down

0 comments on commit 49300aa

Please sign in to comment.