After opening the adaptive layer dialog, trigger reslicing only if necessary

This commit is contained in:
Florens Wasserfall 2017-04-18 08:44:18 +02:00
parent 5eab886069
commit 614f4d9ca4
3 changed files with 7 additions and 13 deletions

View File

@ -92,8 +92,7 @@ sub new {
# object already processed? # object already processed?
wxTheApp->CallAfter(sub { wxTheApp->CallAfter(sub {
if (!$plater->{processed}) { if (!$plater->{processed}) {
$object->layer_height_spline->suppressUpdate(); $self->_trigger_slicing(0); # trigger processing without invalidating STEP_SLICE to keep current height distribution
$self->_trigger_slicing;
}else{ }else{
$self->{preview3D}->reload_print($obj_idx); $self->{preview3D}->reload_print($obj_idx);
$self->{preview3D}->canvas->zoom_to_volumes; $self->{preview3D}->canvas->zoom_to_volumes;
@ -200,7 +199,8 @@ sub reload_preview {
# Trigger background slicing at the plater # Trigger background slicing at the plater
sub _trigger_slicing { sub _trigger_slicing {
my ($self) = @_; my ($self, $invalidate) = @_;
$invalidate //= 1;
my $object = $self->{plater}->{print}->get_object($self->{obj_idx}); my $object = $self->{plater}->{print}->get_object($self->{obj_idx});
$self->{model_object}->set_layer_height_spline($self->{object}->layer_height_spline); # push modified spline object to model_object $self->{model_object}->set_layer_height_spline($self->{object}->layer_height_spline); # push modified spline object to model_object
$self->{model_object}->layer_height_spline->updateRequired; # make sure the model_object spline requires update $self->{model_object}->layer_height_spline->updateRequired; # make sure the model_object spline requires update
@ -212,10 +212,10 @@ sub _trigger_slicing {
$self->{plater}->statusbar->SetStatusText("Slicing cancelled"); $self->{plater}->statusbar->SetStatusText("Slicing cancelled");
$self->{plater}->preview_notebook->SetSelection(0); $self->{plater}->preview_notebook->SetSelection(0);
}); });
$object->invalidate_step(STEP_SLICE); $object->invalidate_step(STEP_SLICE) if($invalidate);
$self->{plater}->start_background_process; $self->{plater}->start_background_process;
}else{ }else{
$object->invalidate_step(STEP_SLICE); $object->invalidate_step(STEP_SLICE) if($invalidate);
$self->{plater}->schedule_background_process; $self->{plater}->schedule_background_process;
} }
} }

View File

@ -515,8 +515,6 @@ ModelObject::add_instance()
{ {
ModelInstance* i = new ModelInstance(this); ModelInstance* i = new ModelInstance(this);
this->instances.push_back(i); this->instances.push_back(i);
this->invalidate_bounding_box();
this->layer_height_spline.setObjectHeight(this->raw_bounding_box().size().z);
return i; return i;
} }
@ -525,8 +523,6 @@ ModelObject::add_instance(const ModelInstance &other)
{ {
ModelInstance* i = new ModelInstance(this, other); ModelInstance* i = new ModelInstance(this, other);
this->instances.push_back(i); this->instances.push_back(i);
this->invalidate_bounding_box();
this->layer_height_spline.setObjectHeight(this->raw_bounding_box().size().z);
return i; return i;
} }
@ -536,10 +532,6 @@ ModelObject::delete_instance(size_t idx)
ModelInstancePtrs::iterator i = this->instances.begin() + idx; ModelInstancePtrs::iterator i = this->instances.begin() + idx;
delete *i; delete *i;
this->instances.erase(i); this->instances.erase(i);
if(!this->instances.empty()) {
this->layer_height_spline.setObjectHeight(this->raw_bounding_box().size().z);
}
this->invalidate_bounding_box();
} }
void void

View File

@ -580,6 +580,8 @@ std::vector<coordf_t> PrintObject::generate_object_layers(coordf_t first_layer_h
coordf_t print_z = first_layer_height; coordf_t print_z = first_layer_height;
coordf_t height = first_layer_height; coordf_t height = first_layer_height;
// Update object size at the spline object to define upper border
this->layer_height_spline.setObjectHeight(unscale(this->size.z));
if(!this->layer_height_spline.updateRequired()) { // layer heights are already generated, just update layers from spline if(!this->layer_height_spline.updateRequired()) { // layer heights are already generated, just update layers from spline
// we don't need to respect first layer here, it's correctly provided by the spline object // we don't need to respect first layer here, it's correctly provided by the spline object
result = this->layer_height_spline.getInterpolatedLayers(); result = this->layer_height_spline.getInterpolatedLayers();