Command for reloading an object from file. #1466

This commit is contained in:
Alessandro Ranellucci 2016-12-17 21:47:45 +01:00 committed by bubnikv
parent d02ee5cf80
commit 8174c05df4
3 changed files with 12 additions and 1 deletions

View File

@ -649,6 +649,7 @@ sub load_file {
my $model = eval { Slic3r::Model->read_from_file($input_file) }; my $model = eval { Slic3r::Model->read_from_file($input_file) };
Slic3r::GUI::show_error($self, $@) if $@; Slic3r::GUI::show_error($self, $@) if $@;
my @obj_idx = ();
if (defined $model) { if (defined $model) {
if ($model->looks_like_multipart_object) { if ($model->looks_like_multipart_object) {
my $dialog = Wx::MessageDialog->new($self, my $dialog = Wx::MessageDialog->new($self,
@ -660,11 +661,13 @@ sub load_file {
$model->convert_multipart_object; $model->convert_multipart_object;
} }
} }
$self->load_model_objects(@{$model->objects}); @obj_idx = $self->load_model_objects(@{$model->objects});
$self->statusbar->SetStatusText("Loaded " . basename($input_file)); $self->statusbar->SetStatusText("Loaded " . basename($input_file));
} }
$process_dialog->Destroy; $process_dialog->Destroy;
return @obj_idx;
} }
sub load_model_objects { sub load_model_objects {
@ -744,6 +747,8 @@ sub load_model_objects {
$self->object_list_changed; $self->object_list_changed;
$self->schedule_background_process; $self->schedule_background_process;
return @obj_idx;
} }
sub bed_centerf { sub bed_centerf {
@ -2048,6 +2053,9 @@ sub object_menu {
$self->object_settings_dialog; $self->object_settings_dialog;
}, undef, 'cog.png'); }, undef, 'cog.png');
$menu->AppendSeparator(); $menu->AppendSeparator();
$frame->_append_menu_item($menu, "Reload from Disk", 'Reload the selected file from Disk', sub {
$self->reload_from_disk;
}, undef, 'arrow_refresh.png');
$frame->_append_menu_item($menu, "Export object as STL…", 'Export this single object as STL file', sub { $frame->_append_menu_item($menu, "Export object as STL…", 'Export this single object as STL file', sub {
$self->export_object_stl; $self->export_object_stl;
}, undef, 'brick_go.png'); }, undef, 'brick_go.png');

BIN
var/arrow_refresh.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 B

View File

@ -662,6 +662,8 @@ ModelObject::cut(coordf_t z, Model* model) const
ModelObject* lower = model->add_object(*this); ModelObject* lower = model->add_object(*this);
upper->clear_volumes(); upper->clear_volumes();
lower->clear_volumes(); lower->clear_volumes();
upper->input_file = "";
lower->input_file = "";
for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) { for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) {
ModelVolume* volume = *v; ModelVolume* volume = *v;
@ -711,6 +713,7 @@ ModelObject::split(ModelObjectPtrs* new_objects)
(*mesh)->repair(); (*mesh)->repair();
ModelObject* new_object = this->model->add_object(*this, false); ModelObject* new_object = this->model->add_object(*this, false);
new_object->input_file = "";
ModelVolume* new_volume = new_object->add_volume(**mesh); ModelVolume* new_volume = new_object->add_volume(**mesh);
new_volume->name = volume->name; new_volume->name = volume->name;
new_volume->config = volume->config; new_volume->config = volume->config;