Hopefully a fix of

"Layer editing does not trigger reslicing with Background Processing enabled"
https://github.com/prusa3d/Slic3r/issues/293
This commit is contained in:
bubnikv 2017-06-09 13:27:35 +02:00
parent 6ce832e439
commit 958c6553e7
5 changed files with 19 additions and 20 deletions

View File

@ -319,6 +319,7 @@ sub _variable_layer_thickness_action {
if ($self->{layer_height_edit_last_object_id} != -1) {
# Mark the volume as modified, so Print will pick its layer height profile? Where to mark it?
# Start a timer to refresh the print? schedule_background_process() ?
# The PrintObject::adjust_layer_height_profile() call adjusts the profile of its associated ModelObject, it does not modify the profile of the PrintObject itself.
$self->{print}->get_object($self->{layer_height_edit_last_object_id})->adjust_layer_height_profile(
$self->{layer_height_edit_last_z},
$self->{layer_height_edit_strength},

View File

@ -116,8 +116,7 @@ sub new {
});
$self->{canvas3D}->set_on_model_update(sub {
if ($Slic3r::GUI::Settings->{_}{background_processing}) {
$self->{apply_config_timer}->Stop if defined $self->{apply_config_timer};
$self->async_apply_config();
$self->schedule_background_process;
} else {
# Hide the print info box, it is no more valid.
$self->{"print_info_box_show"}->(0);

View File

@ -214,8 +214,11 @@ if (@ARGV) { # slicing from command line
output_file => $opt{output},
);
# This is delegated to C++ PrintObject::apply_config().
$sprint->apply_config($config);
$sprint->set_model($model);
# Do the apply_config once again to validate the layer height profiles at all the newly added PrintObjects.
$sprint->apply_config($config);
if ($opt{export_svg}) {
$sprint->export_svg;

View File

@ -397,6 +397,16 @@ bool Print::apply_config(DynamicPrintConfig config)
PrintObjectConfig new_config = this->default_object_config;
// we override the new config with object-specific options
normalize_and_apply_config(new_config, object->model_object()->config);
// Force a refresh of a variable layer height profile at the PrintObject if it is not valid.
if (! object->layer_height_profile_valid) {
// The layer_height_profile is not valid for some reason (updated by the user or invalidated due to some option change).
// Invalidate the slicing step, which in turn invalidates everything.
object->invalidate_step(posSlice);
// Following line sets the layer_height_profile_valid flag.
object->update_layer_height_profile();
// Trigger recalculation.
invalidated = true;
}
// check whether the new config is different from the current one
t_config_option_keys diff = object->config.diff(new_config);
object->config.apply(new_config, diff, true);
@ -475,22 +485,6 @@ exit_for_rearrange_regions:
this->objects.back()->update_layer_height_profile();
}
invalidated = true;
} else {
// Check validity of the layer height profiles.
for (PrintObject *object : this->objects) {
if (! object->layer_height_profile_valid) {
// The layer_height_profile is not valid for some reason (updated by the user or invalidated due to some option change).
// Start slicing of this object from scratch.
object->invalidate_all_steps();
// Following line sets the layer_height_profile_valid flag.
object->update_layer_height_profile();
invalidated = true;
} else if (! step_done(posSlice)) {
// Update layer_height_profile from the main thread as it may pull the data from the associated ModelObject.
// Only update if the slicing was not finished yet.
object->update_layer_height_profile();
}
}
}
return invalidated;
@ -585,11 +579,13 @@ std::string Print::validate() const
return "The Wipe Tower is only supported for multiple objects if they are printed with the same support_material_contact_distance";
if (! equal_layering(slicing_params, slicing_params0))
return "The Wipe Tower is only supported for multiple objects if they are sliced equally.";
bool was_layer_height_profile_valid = object->layer_height_profile_valid;
object->update_layer_height_profile();
object->layer_height_profile_valid = was_layer_height_profile_valid;
for (size_t i = 1; i < object->layer_height_profile.size(); i += 2)
if (object->layer_height_profile[i-1] > slicing_params.object_print_z_min + EPSILON &&
std::abs(object->layer_height_profile[i] - object->config.layer_height) > EPSILON)
return "The Wipe Tower is currently only supported with constant Z layer spacing. Layer editing is not allowed.";
return "The Wipe Tower is currently only supported with constant Z layer spacing. Layer editing is not allowed.";
}
}

View File

@ -263,6 +263,7 @@ bool PrintObject::invalidate_step(PrintObjectStep step)
} else if (step == posSlice) {
invalidated |= this->invalidate_step(posPerimeters);
invalidated |= this->invalidate_step(posSupportMaterial);
invalidated |= this->_print->invalidate_step(psWipeTower);
} else if (step == posSupportMaterial) {
invalidated |= this->_print->invalidate_step(psSkirt);
invalidated |= this->_print->invalidate_step(psBrim);
@ -1079,7 +1080,6 @@ void PrintObject::_slice()
{
this->clear_layers();
// Object layers (pairs of bottom/top Z coordinate), without the raft.
this->update_layer_height_profile();
std::vector<coordf_t> object_layers = generate_object_layers(slicing_params, this->layer_height_profile);
// Reserve object layers for the raft. Last layer of the raft is the contact layer.
int id = int(slicing_params.raft_layers());