mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-16 11:17:51 -06:00
Bugfix: skirt and brim were not recalculated when objects where just moved in plater
This commit is contained in:
parent
a5787cfb04
commit
334086d605
7 changed files with 37 additions and 27 deletions
|
@ -89,7 +89,17 @@ sub new {
|
||||||
$menu->Destroy;
|
$menu->Destroy;
|
||||||
});
|
});
|
||||||
$self->{canvas}->on_instance_moved(sub {
|
$self->{canvas}->on_instance_moved(sub {
|
||||||
|
my ($obj_idx, $instance_idx) = @_;
|
||||||
|
|
||||||
$self->update;
|
$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
|
# Initialize 3D preview canvas
|
||||||
|
@ -736,6 +746,7 @@ sub arrange {
|
||||||
my $bb = Slic3r::Geometry::BoundingBoxf->new_from_points($self->{config}->bed_shape);
|
my $bb = Slic3r::Geometry::BoundingBoxf->new_from_points($self->{config}->bed_shape);
|
||||||
eval {
|
eval {
|
||||||
$self->{model}->arrange_objects($self->GetFrame->config->min_object_distance, $bb);
|
$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
|
# 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
|
# when parts don't fit in print bed
|
||||||
|
@ -1128,15 +1139,6 @@ sub update {
|
||||||
$self->{model}->center_instances_around_point($self->bed_centerf);
|
$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->{canvas}->Refresh;
|
||||||
$self->{canvas3D}->update if $self->{canvas3D};
|
$self->{canvas3D}->update if $self->{canvas3D};
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,7 @@ sub mouse_event {
|
||||||
}
|
}
|
||||||
$self->Refresh;
|
$self->Refresh;
|
||||||
} elsif ($event->ButtonUp(&Wx::wxMOUSE_BTN_LEFT)) {
|
} elsif ($event->ButtonUp(&Wx::wxMOUSE_BTN_LEFT)) {
|
||||||
$self->{on_instance_moved}->();
|
$self->{on_instance_moved}->(@{ $self->{drag_object} });
|
||||||
$self->Refresh;
|
$self->Refresh;
|
||||||
$self->{drag_start_pos} = undef;
|
$self->{drag_start_pos} = undef;
|
||||||
$self->{drag_object} = undef;
|
$self->{drag_object} = undef;
|
||||||
|
|
|
@ -37,19 +37,19 @@ sub add_copy {
|
||||||
my ($self, $x, $y) = @_;
|
my ($self, $x, $y) = @_;
|
||||||
my @copies = @{$self->copies};
|
my @copies = @{$self->copies};
|
||||||
push @copies, Slic3r::Point->new_scale($x, $y);
|
push @copies, Slic3r::Point->new_scale($x, $y);
|
||||||
$self->set_copies(\@copies);
|
return $self->set_copies(\@copies);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub delete_last_copy {
|
sub delete_last_copy {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
my @copies = $self->copies;
|
my @copies = $self->copies;
|
||||||
pop @copies;
|
pop @copies;
|
||||||
$self->set_copies(\@copies);
|
return $self->set_copies(\@copies);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub delete_all_copies {
|
sub delete_all_copies {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
$self->set_copies([]);
|
return $self->set_copies([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
# this is the *total* layer count (including support layers)
|
# this is the *total* layer count (including support layers)
|
||||||
|
|
|
@ -351,15 +351,6 @@ Print::add_model_object(ModelObject* model_object, int idx)
|
||||||
? this->set_new_object(idx, model_object, bb)
|
? this->set_new_object(idx, model_object, bb)
|
||||||
: this->add_object(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) {
|
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();
|
size_t volume_id = v_i - model_object->volumes.begin();
|
||||||
|
|
|
@ -103,7 +103,8 @@ class PrintObject
|
||||||
ModelObject* model_object();
|
ModelObject* model_object();
|
||||||
|
|
||||||
Points copies() const;
|
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
|
// adds region_id, too, if necessary
|
||||||
void add_region_volume(int region_id, int volume_id);
|
void add_region_volume(int region_id, int volume_id);
|
||||||
|
|
|
@ -26,6 +26,9 @@ PrintObject::PrintObject(Print* print, ModelObject* model_object, const Bounding
|
||||||
Pointf3 size = modobj_bbox.size();
|
Pointf3 size = modobj_bbox.size();
|
||||||
this->size = Point3(scale_(size.x), scale_(size.y), scale_(size.z));
|
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()
|
PrintObject::~PrintObject()
|
||||||
|
@ -50,7 +53,7 @@ PrintObject::copies() const
|
||||||
return this->_copies;
|
return this->_copies;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
PrintObject::set_copies(const Points &points)
|
PrintObject::set_copies(const Points &points)
|
||||||
{
|
{
|
||||||
this->_copies = points;
|
this->_copies = points;
|
||||||
|
@ -69,8 +72,20 @@ PrintObject::set_copies(const Points &points)
|
||||||
this->_shifted_copies.push_back(copy);
|
this->_shifted_copies.push_back(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->_print->invalidate_step(psSkirt);
|
bool invalidated = false;
|
||||||
this->_print->invalidate_step(psBrim);
|
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
|
void
|
||||||
|
|
|
@ -74,7 +74,8 @@ _constant()
|
||||||
void set_shifted_copies(Points value)
|
void set_shifted_copies(Points value)
|
||||||
%code%{ THIS->_shifted_copies = 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)
|
void set_layer_height_ranges(t_layer_height_ranges layer_height_ranges)
|
||||||
%code%{ THIS->layer_height_ranges = layer_height_ranges; %};
|
%code%{ THIS->layer_height_ranges = layer_height_ranges; %};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue