Perl version of preview removed from Slic3r

This commit is contained in:
Enrico Turri 2018-09-18 16:13:18 +02:00
parent abdaaf6ede
commit 9daae9413a
2 changed files with 33 additions and 41 deletions

View File

@ -299,7 +299,6 @@ sub new {
#======================================================================================================================================
Slic3r::GUI::_3DScene::register_on_viewport_changed_callback($self->{canvas3D},
sub {
Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{preview3D}->canvas, $self->{canvas3D});
$self->{preview_iface}->set_viewport_from_scene($self->{canvas3D});
});
# Slic3r::GUI::_3DScene::register_on_viewport_changed_callback($self->{canvas3D}, sub { Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{preview3D}->canvas, $self->{canvas3D}); });
@ -313,15 +312,13 @@ sub new {
#======================================================================================================================================
$self->{preview_iface} = Slic3r::GUI::create_preview_iface($self->{preview_notebook}, $self->{config}, $self->{print}, $self->{gcode_preview_data});
$self->{preview_page_idx} = $self->{preview_notebook}->GetPageCount-1;
#======================================================================================================================================
$self->{preview3D} = Slic3r::GUI::Plater::3DPreview->new($self->{preview_notebook}, $self->{print}, $self->{gcode_preview_data}, $self->{config});
Slic3r::GUI::_3DScene::enable_legend_texture($self->{preview3D}->canvas, 1);
Slic3r::GUI::_3DScene::enable_dynamic_background($self->{preview3D}->canvas, 1);
Slic3r::GUI::_3DScene::register_on_viewport_changed_callback($self->{preview3D}->canvas, sub { Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{canvas3D}, $self->{preview3D}->canvas); });
#======================================================================================================================================
$self->{preview_iface}->register_on_viewport_changed_callback(sub { $self->{preview_iface}->set_viewport_into_scene($self->{canvas3D}); });
#======================================================================================================================================
$self->{preview_notebook}->AddPage($self->{preview3D}, L('Preview'));
# $self->{preview3D} = Slic3r::GUI::Plater::3DPreview->new($self->{preview_notebook}, $self->{print}, $self->{gcode_preview_data}, $self->{config});
# Slic3r::GUI::_3DScene::enable_legend_texture($self->{preview3D}->canvas, 1);
# Slic3r::GUI::_3DScene::enable_dynamic_background($self->{preview3D}->canvas, 1);
# Slic3r::GUI::_3DScene::register_on_viewport_changed_callback($self->{preview3D}->canvas, sub { Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{canvas3D}, $self->{preview3D}->canvas); });
# $self->{preview_notebook}->AddPage($self->{preview3D}, L('Preview'));
#======================================================================================================================================
$self->{preview3D_page_idx} = $self->{preview_notebook}->GetPageCount-1;
}
@ -329,19 +326,19 @@ sub new {
my $preview = $self->{preview_notebook}->GetCurrentPage;
#======================================================================================================================================
my $page_id = $self->{preview_notebook}->GetSelection;
if (($preview != $self->{preview3D}) && ($preview != $self->{canvas3D}) && ($page_id != $self->{preview_page_idx})) {
if (($preview != $self->{canvas3D}) && ($page_id != $self->{preview_page_idx})) {
# if (($preview != $self->{preview3D}) && ($preview != $self->{canvas3D})) {
#======================================================================================================================================
$preview->OnActivate if $preview->can('OnActivate');
} elsif ($preview == $self->{preview3D}) {
$self->{preview3D}->reload_print;
# sets the canvas as dirty to force a render at the 1st idle event (wxWidgets IsShownOnScreen() is buggy and cannot be used reliably)
Slic3r::GUI::_3DScene::set_as_dirty($self->{preview3D}->canvas);
#======================================================================================================================================
} elsif ($page_id == $self->{preview_page_idx}) {
$self->{preview_iface}->reload_print;
# sets the canvas as dirty to force a render at the 1st idle event (wxWidgets IsShownOnScreen() is buggy and cannot be used reliably)
$self->{preview_iface}->set_canvas_as_dirty;
# } elsif ($preview == $self->{preview3D}) {
# $self->{preview3D}->reload_print;
# # sets the canvas as dirty to force a render at the 1st idle event (wxWidgets IsShownOnScreen() is buggy and cannot be used reliably)
# Slic3r::GUI::_3DScene::set_as_dirty($self->{preview3D}->canvas);
#======================================================================================================================================
} elsif ($preview == $self->{canvas3D}) {
if (Slic3r::GUI::_3DScene::is_reload_delayed($self->{canvas3D})) {
@ -486,7 +483,7 @@ sub new {
$_->SetDropTarget(Slic3r::GUI::Plater::DropTarget->new($self))
for grep defined($_),
#======================================================================================================================================
$self, $self->{canvas3D}, $self->{preview3D}, $self->{preview_iface}, $self->{list};
$self, $self->{canvas3D}, $self->{preview_iface}, $self->{list};
# $self, $self->{canvas3D}, $self->{preview3D}, $self->{list};
#======================================================================================================================================
# $self, $self->{canvas}, $self->{canvas3D}, $self->{preview3D};
@ -515,11 +512,11 @@ sub new {
Slic3r::GUI::_3DScene::set_bed_shape($self->{canvas3D}, $self->{config}->bed_shape);
Slic3r::GUI::_3DScene::zoom_to_bed($self->{canvas3D});
}
if ($self->{preview3D}) {
Slic3r::GUI::_3DScene::set_bed_shape($self->{preview3D}->canvas, $self->{config}->bed_shape);
}
#======================================================================================================================================
$self->{preview_iface}->set_bed_shape($self->{config}->bed_shape) if ($self->{preview_iface});
# if ($self->{preview3D}) {
# Slic3r::GUI::_3DScene::set_bed_shape($self->{preview3D}->canvas, $self->{config}->bed_shape);
# }
#======================================================================================================================================
$self->update;
@ -1035,9 +1032,9 @@ sub remove {
$self->stop_background_process;
# Prevent toolpaths preview from rendering while we modify the Print object
$self->{preview3D}->enabled(0) if $self->{preview3D};
#======================================================================================================================================
$self->{preview_iface}->set_enabled(0) if $self->{preview_iface};
# $self->{preview3D}->enabled(0) if $self->{preview3D};
#======================================================================================================================================
# If no object index is supplied, remove the selected one.
@ -1063,9 +1060,9 @@ sub reset {
$self->stop_background_process;
# Prevent toolpaths preview from rendering while we modify the Print object
$self->{preview3D}->enabled(0) if $self->{preview3D};
#======================================================================================================================================
$self->{preview_iface}->set_enabled(0) if $self->{preview_iface};
# $self->{preview3D}->enabled(0) if $self->{preview3D};
#======================================================================================================================================
@{$self->{objects}} = ();
@ -1427,9 +1424,9 @@ sub async_apply_config {
# Reset preview canvases. If the print has been invalidated, the preview canvases will be cleared.
# Otherwise they will be just refreshed.
$self->{gcode_preview_data}->reset;
$self->{preview3D}->reload_print if $self->{preview3D};
#======================================================================================================================================
$self->{preview_iface}->reload_print if $self->{preview_iface};
# $self->{preview3D}->reload_print if $self->{preview3D};
#======================================================================================================================================
# We also need to reload 3D scene because of the wipe tower preview box
if ($self->{config}->wipe_tower) {
@ -1465,9 +1462,9 @@ sub start_background_process {
sub stop_background_process {
my ($self) = @_;
$self->{background_slicing_process}->stop();
$self->{preview3D}->reload_print if $self->{preview3D};
#======================================================================================================================================
$self->{preview_iface}->reload_print if $self->{preview_iface};
# $self->{preview3D}->reload_print if $self->{preview3D};
#======================================================================================================================================
}
@ -1574,9 +1571,9 @@ sub export_gcode {
# This message should be called by the background process synchronously.
sub on_update_print_preview {
my ($self) = @_;
$self->{preview3D}->reload_print if $self->{preview3D};
#======================================================================================================================================
$self->{preview_iface}->reload_print if $self->{preview_iface};
# $self->{preview3D}->reload_print if $self->{preview3D};
#======================================================================================================================================
# in case this was MM print, wipe tower bounding box on 3D tab might need redrawing with exact depth:
@ -1658,9 +1655,9 @@ sub on_process_completed {
$self->object_list_changed;
# refresh preview
$self->{preview3D}->reload_print if $self->{preview3D};
#======================================================================================================================================
$self->{preview_iface}->reload_print if $self->{preview_iface};
# $self->{preview3D}->reload_print if $self->{preview3D};
#======================================================================================================================================
}
@ -1929,11 +1926,11 @@ sub update {
my $selections = $self->collect_selections;
Slic3r::GUI::_3DScene::set_objects_selections($self->{canvas3D}, \@$selections);
Slic3r::GUI::_3DScene::reload_scene($self->{canvas3D}, 0);
$self->{preview3D}->reset_gcode_preview_data if $self->{preview3D};
$self->{preview3D}->reload_print if $self->{preview3D};
#======================================================================================================================================
$self->{preview_iface}->reset_gcode_preview_data if $self->{preview_iface};
$self->{preview_iface}->reload_print if $self->{preview_iface};
# $self->{preview3D}->reset_gcode_preview_data if $self->{preview3D};
# $self->{preview3D}->reload_print if $self->{preview3D};
#======================================================================================================================================
$self->schedule_background_process;
$self->Thaw;
@ -2010,9 +2007,9 @@ sub on_config_change {
if ($opt_key eq 'bed_shape') {
# $self->{canvas}->update_bed_size;
Slic3r::GUI::_3DScene::set_bed_shape($self->{canvas3D}, $self->{config}->bed_shape) if $self->{canvas3D};
Slic3r::GUI::_3DScene::set_bed_shape($self->{preview3D}->canvas, $self->{config}->bed_shape) if $self->{preview3D};
#======================================================================================================================================
$self->{preview_iface}->set_bed_shape($self->{config}->bed_shape) if ($self->{preview_iface});
# Slic3r::GUI::_3DScene::set_bed_shape($self->{preview3D}->canvas, $self->{config}->bed_shape) if $self->{preview3D};
#======================================================================================================================================
$update_scheduled = 1;
} elsif ($opt_key =~ '^wipe_tower' || $opt_key eq 'single_extruder_multi_material') {
@ -2048,18 +2045,18 @@ sub on_config_change {
} elsif ($opt_key eq 'extruder_colour') {
$update_scheduled = 1;
my $extruder_colors = $config->get('extruder_colour');
$self->{preview3D}->set_number_extruders(scalar(@{$extruder_colors}));
#======================================================================================================================================
$self->{preview_iface}->set_number_extruders(scalar(@{$extruder_colors}));
# $self->{preview3D}->set_number_extruders(scalar(@{$extruder_colors}));
#======================================================================================================================================
} elsif ($opt_key eq 'max_print_height') {
$update_scheduled = 1;
} elsif ($opt_key eq 'printer_model') {
# update to force bed selection (for texturing)
Slic3r::GUI::_3DScene::set_bed_shape($self->{canvas3D}, $self->{config}->bed_shape) if $self->{canvas3D};
Slic3r::GUI::_3DScene::set_bed_shape($self->{preview3D}->canvas, $self->{config}->bed_shape) if $self->{preview3D};
#======================================================================================================================================
$self->{preview_iface}->set_bed_shape($self->{config}->bed_shape) if ($self->{preview_iface});
# Slic3r::GUI::_3DScene::set_bed_shape($self->{preview3D}->canvas, $self->{config}->bed_shape) if $self->{preview3D};
#======================================================================================================================================
$update_scheduled = 1;
}
@ -2511,23 +2508,18 @@ sub select_view {
my ($self, $direction) = @_;
my $idx_page = $self->{preview_notebook}->GetSelection;
my $page = ($idx_page == &Wx::wxNOT_FOUND) ? L('3D') : $self->{preview_notebook}->GetPageText($idx_page);
if ($page eq L('Preview')) {
#======================================================================================================================================
if (($page eq L('Preview')) || ($page eq L('_Preview_'))) {
#======================================================================================================================================
if ($page eq L('Preview')) {
Slic3r::GUI::_3DScene::select_view($self->{preview3D}->canvas, $direction);
Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{canvas3D}, $self->{preview3D}->canvas);
#======================================================================================================================================
} else {
$self->{preview_iface}->select_view($direction);
$self->{preview_iface}->set_viewport_into_scene($self->{canvas3D});
}
$self->{preview_iface}->select_view($direction);
$self->{preview_iface}->set_viewport_into_scene($self->{canvas3D});
# Slic3r::GUI::_3DScene::select_view($self->{preview3D}->canvas, $direction);
# Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{canvas3D}, $self->{preview3D}->canvas);
#======================================================================================================================================
} else {
Slic3r::GUI::_3DScene::select_view($self->{canvas3D}, $direction);
Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{preview3D}->canvas, $self->{canvas3D});
#======================================================================================================================================
$self->{preview_iface}->set_viewport_from_scene($self->{canvas3D});
# Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{preview3D}->canvas, $self->{canvas3D});
#======================================================================================================================================
}
}

View File

@ -42,7 +42,7 @@ Preview::Preview(wxNotebook* notebook, DynamicPrintConfig* config, Print* print,
{
if (init(notebook, config, print, gcode_preview_data))
{
notebook->AddPage(this, _(L("_Preview_")));
notebook->AddPage(this, _(L("Preview")));
show_hide_ui_elements("none");
load_print();
}