mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-04 22:20:39 +08:00
Only reload the selected object and not all the objects of the input file. #3786
This commit is contained in:
parent
ddad7ce25f
commit
8560655372
@ -632,7 +632,7 @@ sub add_tin {
|
|||||||
|
|
||||||
sub load_file {
|
sub load_file {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($input_file) = @_;
|
my ($input_file, $obj_idx) = @_;
|
||||||
|
|
||||||
$Slic3r::GUI::Settings->{recent}{skein_directory} = dirname($input_file);
|
$Slic3r::GUI::Settings->{recent}{skein_directory} = dirname($input_file);
|
||||||
wxTheApp->save_settings;
|
wxTheApp->save_settings;
|
||||||
@ -657,7 +657,19 @@ sub load_file {
|
|||||||
$model->convert_multipart_object;
|
$model->convert_multipart_object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined $obj_idx) {
|
||||||
|
return () if $obj_idx >= $model->objects_count;
|
||||||
|
@obj_idx = $self->load_model_objects($model->get_object($obj_idx));
|
||||||
|
} else {
|
||||||
@obj_idx = $self->load_model_objects(@{$model->objects});
|
@obj_idx = $self->load_model_objects(@{$model->objects});
|
||||||
|
}
|
||||||
|
|
||||||
|
my $i = 0;
|
||||||
|
foreach my $obj_idx (@obj_idx) {
|
||||||
|
$self->{objects}[$obj_idx]->input_file($input_file);
|
||||||
|
$self->{objects}[$obj_idx]->input_file_obj_idx($i++);
|
||||||
|
}
|
||||||
$self->statusbar->SetStatusText("Loaded " . basename($input_file));
|
$self->statusbar->SetStatusText("Loaded " . basename($input_file));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1488,13 +1500,14 @@ sub reload_from_disk {
|
|||||||
my ($obj_idx, $object) = $self->selected_object;
|
my ($obj_idx, $object) = $self->selected_object;
|
||||||
return if !defined $obj_idx;
|
return if !defined $obj_idx;
|
||||||
|
|
||||||
my $model_object = $self->{model}->objects->[$obj_idx];
|
return if !$object->input_file
|
||||||
return if !$model_object->input_file
|
|| !-e $object->input_file;
|
||||||
|| !-e $model_object->input_file;
|
|
||||||
|
|
||||||
my @new_obj_idx = $self->load_file($model_object->input_file);
|
# Only reload the selected object and not all objects from the input file.
|
||||||
|
my @new_obj_idx = $self->load_file($object->input_file, $object->input_file_obj_idx);
|
||||||
return if !@new_obj_idx;
|
return if !@new_obj_idx;
|
||||||
|
|
||||||
|
my $model_object = $self->{model}->objects->[$obj_idx];
|
||||||
foreach my $new_obj_idx (@new_obj_idx) {
|
foreach my $new_obj_idx (@new_obj_idx) {
|
||||||
my $o = $self->{model}->objects->[$new_obj_idx];
|
my $o = $self->{model}->objects->[$new_obj_idx];
|
||||||
$o->clear_instances;
|
$o->clear_instances;
|
||||||
@ -1509,6 +1522,8 @@ sub reload_from_disk {
|
|||||||
|
|
||||||
$self->remove($obj_idx);
|
$self->remove($obj_idx);
|
||||||
|
|
||||||
|
# TODO: refresh object list which contains wrong count and scale
|
||||||
|
|
||||||
# Trigger thumbnail generation again, because the remove() method altered
|
# Trigger thumbnail generation again, because the remove() method altered
|
||||||
# object indexes before background thumbnail generation called its completion
|
# object indexes before background thumbnail generation called its completion
|
||||||
# event, so the on_thumbnail_made callback is called with the wrong $obj_idx.
|
# event, so the on_thumbnail_made callback is called with the wrong $obj_idx.
|
||||||
@ -2127,6 +2142,8 @@ use List::Util qw(first);
|
|||||||
use Slic3r::Geometry qw(X Y Z MIN MAX deg2rad);
|
use Slic3r::Geometry qw(X Y Z MIN MAX deg2rad);
|
||||||
|
|
||||||
has 'name' => (is => 'rw', required => 1);
|
has 'name' => (is => 'rw', required => 1);
|
||||||
|
has 'input_file' => (is => 'rw');
|
||||||
|
has 'input_file_obj_idx' => (is => 'rw');
|
||||||
has 'thumbnail' => (is => 'rw'); # ExPolygon::Collection in scaled model units with no transforms
|
has 'thumbnail' => (is => 'rw'); # ExPolygon::Collection in scaled model units with no transforms
|
||||||
has 'transformed_thumbnail' => (is => 'rw');
|
has 'transformed_thumbnail' => (is => 'rw');
|
||||||
has 'instance_thumbnails' => (is => 'ro', default => sub { [] }); # array of ExPolygon::Collection objects, each one representing the actual placed thumbnail of each instance in pixel units
|
has 'instance_thumbnails' => (is => 'ro', default => sub { [] }); # array of ExPolygon::Collection objects, each one representing the actual placed thumbnail of each instance in pixel units
|
||||||
|
@ -92,9 +92,8 @@ Model::delete_object(size_t idx)
|
|||||||
void
|
void
|
||||||
Model::clear_objects()
|
Model::clear_objects()
|
||||||
{
|
{
|
||||||
// int instead of size_t because it can be -1 when vector is empty
|
while (!this->objects.empty())
|
||||||
for (int i = this->objects.size()-1; i >= 0; --i)
|
this->delete_object(0);
|
||||||
this->delete_object(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -467,9 +466,8 @@ ModelObject::delete_volume(size_t idx)
|
|||||||
void
|
void
|
||||||
ModelObject::clear_volumes()
|
ModelObject::clear_volumes()
|
||||||
{
|
{
|
||||||
// int instead of size_t because it can be -1 when vector is empty
|
while (!this->volumes.empty())
|
||||||
for (int i = this->volumes.size()-1; i >= 0; --i)
|
this->delete_volume(0);
|
||||||
this->delete_volume(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelInstance*
|
ModelInstance*
|
||||||
@ -508,8 +506,8 @@ ModelObject::delete_last_instance()
|
|||||||
void
|
void
|
||||||
ModelObject::clear_instances()
|
ModelObject::clear_instances()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < this->instances.size(); ++i)
|
while (!this->instances.empty())
|
||||||
this->delete_instance(i);
|
this->delete_last_instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
// this returns the bounding box of the *transformed* instances
|
// this returns the bounding box of the *transformed* instances
|
||||||
|
Loading…
x
Reference in New Issue
Block a user