Bugfix: skirt and brim were not recalculated when objects where just moved in plater

This commit is contained in:
Alessandro Ranellucci 2014-11-12 23:28:42 +01:00
parent a5787cfb04
commit 334086d605
7 changed files with 37 additions and 27 deletions

View File

@ -89,7 +89,17 @@ sub new {
$menu->Destroy;
});
$self->{canvas}->on_instance_moved(sub {
my ($obj_idx, $instance_idx) = @_;
$self->update;
$self->pause_background_process;
my $invalidated = $self->{print}->objects->[$obj_idx]->reload_model_instances();
if ($invalidated) {
$self->schedule_background_process;
} else {
$self->resume_background_process;
}
});
# Initialize 3D preview canvas
@ -736,6 +746,7 @@ sub arrange {
my $bb = Slic3r::Geometry::BoundingBoxf->new_from_points($self->{config}->bed_shape);
eval {
$self->{model}->arrange_objects($self->GetFrame->config->min_object_distance, $bb);
$_->reload_model_instances for @{$self->{print}->objects};
};
# ignore arrange failures on purpose: user has visual feedback and we don't need to warn him
# when parts don't fit in print bed
@ -1128,15 +1139,6 @@ sub update {
$self->{model}->center_instances_around_point($self->bed_centerf);
}
# sync model and print object instances
for my $obj_idx (0..$#{$self->{objects}}) {
my $model_object = $self->{model}->objects->[$obj_idx];
my $print_object = $self->{print}->objects->[$obj_idx];
$print_object->delete_all_copies;
$print_object->add_copy(@{$_->offset}) for @{$model_object->instances};
}
$self->{canvas}->Refresh;
$self->{canvas3D}->update if $self->{canvas3D};
}

View File

@ -209,7 +209,7 @@ sub mouse_event {
}
$self->Refresh;
} elsif ($event->ButtonUp(&Wx::wxMOUSE_BTN_LEFT)) {
$self->{on_instance_moved}->();
$self->{on_instance_moved}->(@{ $self->{drag_object} });
$self->Refresh;
$self->{drag_start_pos} = undef;
$self->{drag_object} = undef;

View File

@ -37,19 +37,19 @@ sub add_copy {
my ($self, $x, $y) = @_;
my @copies = @{$self->copies};
push @copies, Slic3r::Point->new_scale($x, $y);
$self->set_copies(\@copies);
return $self->set_copies(\@copies);
}
sub delete_last_copy {
my ($self) = @_;
my @copies = $self->copies;
pop @copies;
$self->set_copies(\@copies);
return $self->set_copies(\@copies);
}
sub delete_all_copies {
my ($self) = @_;
$self->set_copies([]);
return $self->set_copies([]);
}
# this is the *total* layer count (including support layers)

View File

@ -351,15 +351,6 @@ Print::add_model_object(ModelObject* model_object, int idx)
? this->set_new_object(idx, model_object, bb)
: this->add_object(model_object, bb);
}
{
Points copies;
for (ModelInstancePtrs::const_iterator i = model_object->instances.begin(); i != model_object->instances.end(); ++i) {
copies.push_back(Point::new_scale((*i)->offset.x, (*i)->offset.y));
}
o->set_copies(copies);
}
o->layer_height_ranges = model_object->layer_height_ranges;
for (ModelVolumePtrs::const_iterator v_i = model_object->volumes.begin(); v_i != model_object->volumes.end(); ++v_i) {
size_t volume_id = v_i - model_object->volumes.begin();

View File

@ -103,7 +103,8 @@ class PrintObject
ModelObject* model_object();
Points copies() const;
void set_copies(const Points &points);
bool set_copies(const Points &points);
bool reload_model_instances();
// adds region_id, too, if necessary
void add_region_volume(int region_id, int volume_id);

View File

@ -26,6 +26,9 @@ PrintObject::PrintObject(Print* print, ModelObject* model_object, const Bounding
Pointf3 size = modobj_bbox.size();
this->size = Point3(scale_(size.x), scale_(size.y), scale_(size.z));
}
this->reload_model_instances();
this->layer_height_ranges = model_object->layer_height_ranges;
}
PrintObject::~PrintObject()
@ -50,7 +53,7 @@ PrintObject::copies() const
return this->_copies;
}
void
bool
PrintObject::set_copies(const Points &points)
{
this->_copies = points;
@ -69,8 +72,20 @@ PrintObject::set_copies(const Points &points)
this->_shifted_copies.push_back(copy);
}
this->_print->invalidate_step(psSkirt);
this->_print->invalidate_step(psBrim);
bool invalidated = false;
if (this->_print->invalidate_step(psSkirt)) invalidated = true;
if (this->_print->invalidate_step(psBrim)) invalidated = true;
return invalidated;
}
bool
PrintObject::reload_model_instances()
{
Points copies;
for (ModelInstancePtrs::const_iterator i = this->_model_object->instances.begin(); i != this->_model_object->instances.end(); ++i) {
copies.push_back(Point::new_scale((*i)->offset.x, (*i)->offset.y));
}
return this->set_copies(copies);
}
void

View File

@ -74,7 +74,8 @@ _constant()
void set_shifted_copies(Points value)
%code%{ THIS->_shifted_copies = value; %};
void set_copies(Points copies);
bool set_copies(Points copies);
bool reload_model_instances();
void set_layer_height_ranges(t_layer_height_ranges layer_height_ranges)
%code%{ THIS->layer_height_ranges = layer_height_ranges; %};