Partial perl code cleanup

This commit is contained in:
Enrico Turri 2018-06-14 16:09:36 +02:00
parent c624d6bb0a
commit 52a7d7ed09
8 changed files with 2 additions and 270 deletions

View file

@ -90,10 +90,8 @@ sub new {
# Save the slic3r.ini. Usually the ini file is saved from "on idle" callback,
# but in rare cases it may not have been called yet.
wxTheApp->{app_config}->save;
#==============================================================================================================================
$self->{plater}->{print} = undef if($self->{plater});
Slic3r::GUI::_3DScene::remove_all_canvases();
#==============================================================================================================================
# propagate event
$event->Skip;
});

View file

@ -78,28 +78,19 @@ sub new {
my $on_select_object = sub {
my ($obj_idx) = @_;
# Ignore the special objects (the wipe tower proxy and such).
#==============================================================================================================================
$self->select_object((defined($obj_idx) && $obj_idx >= 0 && $obj_idx < 1000) ? $obj_idx : undef);
# $self->select_object((defined($obj_idx) && $obj_idx < 1000) ? $obj_idx : undef);
#==============================================================================================================================
};
my $on_double_click = sub {
$self->object_settings_dialog if $self->selected_object;
};
my $on_right_click = sub {
#==============================================================================================================================
my ($canvas, $click_pos_x, $click_pos_y) = @_;
# my ($canvas, $click_pos) = @_;
#==============================================================================================================================
my ($obj_idx, $object) = $self->selected_object;
return if !defined $obj_idx;
my $menu = $self->object_menu;
#==============================================================================================================================
$canvas->PopupMenu($menu, $click_pos_x, $click_pos_y);
# $canvas->PopupMenu($menu, $click_pos);
#==============================================================================================================================
$menu->Destroy;
};
my $on_instances_moved = sub {
@ -119,7 +110,6 @@ sub new {
if ($Slic3r::GUI::have_OpenGL) {
$self->{canvas3D} = Slic3r::GUI::Plater::3D->new($self->{preview_notebook}, $self->{objects}, $self->{model}, $self->{print}, $self->{config});
$self->{preview_notebook}->AddPage($self->{canvas3D}, L('3D'));
#==============================================================================================================================
Slic3r::GUI::_3DScene::register_on_select_object_callback($self->{canvas3D}, $on_select_object);
Slic3r::GUI::_3DScene::register_on_double_click_callback($self->{canvas3D}, $on_double_click);
Slic3r::GUI::_3DScene::register_on_right_click_callback($self->{canvas3D}, sub { $on_right_click->($self->{canvas3D}, @_); });
@ -154,41 +144,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->{canvas3D}->set_on_select_object($on_select_object);
# $self->{canvas3D}->set_on_double_click($on_double_click);
# $self->{canvas3D}->set_on_right_click(sub { $on_right_click->($self->{canvas3D}, @_); });
# $self->{canvas3D}->set_on_arrange(sub { $self->arrange });
# $self->{canvas3D}->set_on_rotate_object_left(sub { $self->rotate(-45, Z, 'relative') });
# $self->{canvas3D}->set_on_rotate_object_right(sub { $self->rotate( 45, Z, 'relative') });
# $self->{canvas3D}->set_on_scale_object_uniformly(sub { $self->changescale(undef) });
# $self->{canvas3D}->set_on_increase_objects(sub { $self->increase() });
# $self->{canvas3D}->set_on_decrease_objects(sub { $self->decrease() });
# $self->{canvas3D}->set_on_remove_object(sub { $self->remove() });
# $self->{canvas3D}->set_on_instances_moved($on_instances_moved);
# $self->{canvas3D}->set_on_enable_action_buttons($enable_action_buttons);
# $self->{canvas3D}->use_plain_shader(1);
#
# $self->{canvas3D}->set_on_wipe_tower_moved(sub {
# my ($new_pos_3f) = @_;
# my $cfg = Slic3r::Config->new;
# $cfg->set('wipe_tower_x', $new_pos_3f->x);
# $cfg->set('wipe_tower_y', $new_pos_3f->y);
# $self->GetFrame->{options_tabs}{print}->load_config($cfg);
# });
#
# $self->{canvas3D}->set_on_model_update(sub {
# if (wxTheApp->{app_config}->get("background_processing")) {
# $self->schedule_background_process;
# } else {
# # Hide the print info box, it is no more valid.
# $self->{"print_info_box_show"}->(0);
# }
# });
# $self->{canvas3D}->on_viewport_changed(sub {
# $self->{preview3D}->canvas->set_viewport_from_scene($self->{canvas3D});
# });
#==============================================================================================================================
}
# Initialize 2D preview canvas
@ -202,13 +157,8 @@ sub new {
# Initialize 3D toolpaths preview
if ($Slic3r::GUI::have_OpenGL) {
$self->{preview3D} = Slic3r::GUI::Plater::3DPreview->new($self->{preview_notebook}, $self->{print}, $self->{gcode_preview_data}, $self->{config});
#==============================================================================================================================
Slic3r::GUI::_3DScene::set_active($self->{preview3D}->canvas, 0);
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->{preview3D}->canvas->on_viewport_changed(sub {
# $self->{canvas3D}->set_viewport_from_scene($self->{preview3D}->canvas);
# });
#==============================================================================================================================
$self->{preview_notebook}->AddPage($self->{preview3D}, L('Preview'));
$self->{preview3D_page_idx} = $self->{preview_notebook}->GetPageCount-1;
}
@ -223,21 +173,14 @@ sub new {
my $preview = $self->{preview_notebook}->GetCurrentPage;
if ($preview == $self->{preview3D})
{
#==============================================================================================================================
Slic3r::GUI::_3DScene::set_active($self->{preview3D}->canvas, 1);
Slic3r::GUI::_3DScene::set_active($self->{canvas3D}, 0);
Slic3r::GUI::_3DScene::enable_legend_texture($self->{preview3D}->canvas, 1);
# $self->{preview3D}->canvas->set_legend_enabled(1);
#==============================================================================================================================
$self->{preview3D}->load_print(1);
} else {
#==============================================================================================================================
Slic3r::GUI::_3DScene::enable_legend_texture($self->{preview3D}->canvas, 0);
# $self->{preview3D}->canvas->set_legend_enabled(0);
#==============================================================================================================================
}
#==============================================================================================================================
if ($preview == $self->{canvas3D}) {
Slic3r::GUI::_3DScene::set_active($self->{canvas3D}, 1);
Slic3r::GUI::_3DScene::set_active($self->{preview3D}->canvas, 0);
@ -246,13 +189,9 @@ sub new {
Slic3r::GUI::_3DScene::set_objects_selections($self->{canvas3D}, \@$selections);
Slic3r::GUI::_3DScene::reload_scene($self->{canvas3D}, 1);
}
} else {
$preview->OnActivate if $preview->can('OnActivate');
}
else {
#==============================================================================================================================
$preview->OnActivate if $preview->can('OnActivate');
#==============================================================================================================================
}
#==============================================================================================================================
});
# toolbar for object manipulation
@ -389,10 +328,7 @@ sub new {
EVT_TOOL($self, TB_CUT, sub { $_[0]->object_cut_dialog });
EVT_TOOL($self, TB_SETTINGS, sub { $_[0]->object_settings_dialog });
EVT_TOOL($self, TB_LAYER_EDITING, sub {
#==============================================================================================================================
my $state = Slic3r::GUI::_3DScene::is_layers_editing_enabled($self->{canvas3D});
# my $state = $self->{canvas3D}->layer_editing_enabled;
#==============================================================================================================================
$self->{htoolbar}->ToggleTool(TB_LAYER_EDITING, ! $state);
$self->on_layer_editing_toggled(! $state);
});
@ -447,18 +383,11 @@ sub new {
$self->{canvas}->update_bed_size;
if ($self->{canvas3D}) {
#==============================================================================================================================
Slic3r::GUI::_3DScene::set_bed_shape($self->{canvas3D}, $self->{config}->bed_shape);
Slic3r::GUI::_3DScene::zoom_to_bed($self->{canvas3D});
# $self->{canvas3D}->update_bed_size;
# $self->{canvas3D}->zoom_to_bed;
#==============================================================================================================================
}
if ($self->{preview3D}) {
#==============================================================================================================================
Slic3r::GUI::_3DScene::set_bed_shape($self->{preview3D}->canvas, $self->{config}->bed_shape);
# $self->{preview3D}->set_bed_shape($self->{config}->bed_shape);
#==============================================================================================================================
}
$self->update;
@ -675,12 +604,8 @@ sub _on_select_preset {
sub on_layer_editing_toggled {
my ($self, $new_state) = @_;
#==============================================================================================================================
Slic3r::GUI::_3DScene::enable_layers_editing($self->{canvas3D}, $new_state);
if ($new_state && ! Slic3r::GUI::_3DScene::is_layers_editing_enabled($self->{canvas3D})) {
# $self->{canvas3D}->layer_editing_enabled($new_state);
# if ($new_state && ! $self->{canvas3D}->layer_editing_enabled) {
#==============================================================================================================================
# Initialization of the OpenGL shaders failed. Disable the tool.
if ($self->{htoolbar}) {
$self->{htoolbar}->EnableTool(TB_LAYER_EDITING, 0);
@ -914,10 +839,7 @@ sub load_model_objects {
$self->update;
# zoom to objects
#==============================================================================================================================
Slic3r::GUI::_3DScene::zoom_to_volumes($self->{canvas3D}) if $self->{canvas3D};
# $self->{canvas3D}->zoom_to_volumes if $self->{canvas3D};
#==============================================================================================================================
$self->{list}->Update;
$self->{list}->Select($obj_idx[-1], 1);
@ -1308,12 +1230,7 @@ sub async_apply_config {
my $invalidated = $self->{print}->apply_config(wxTheApp->{preset_bundle}->full_config);
# Just redraw the 3D canvas without reloading the scene.
#==============================================================================================================================
# $self->{canvas3D}->Refresh if ($invalidated && Slic3r::GUI::_3DScene::is_layers_editing_enabled($self->{canvas3D}));
$self->{canvas3D}->Refresh if Slic3r::GUI::_3DScene::is_layers_editing_enabled($self->{canvas3D});
## $self->{canvas3D}->Refresh if ($invalidated && $self->{canvas3D}->layer_editing_enabled);
# $self->{canvas3D}->Refresh if ($self->{canvas3D}->layer_editing_enabled);
#==============================================================================================================================
# Hide the slicing results if the current slicing status is no more valid.
$self->{"print_info_box_show"}->(0) if $invalidated;
@ -1818,12 +1735,9 @@ sub update {
}
$self->{canvas}->reload_scene if $self->{canvas};
#==============================================================================================================================
my $selections = $self->collect_selections;
Slic3r::GUI::_3DScene::set_objects_selections($self->{canvas3D}, \@$selections);
Slic3r::GUI::_3DScene::reload_scene($self->{canvas3D}, 0);
# $self->{canvas3D}->reload_scene if $self->{canvas3D};
#==============================================================================================================================
$self->{preview3D}->reset_gcode_preview_data if $self->{preview3D};
$self->{preview3D}->reload_print if $self->{preview3D};
}
@ -1878,13 +1792,8 @@ sub on_config_change {
$self->{config}->set($opt_key, $config->get($opt_key));
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->{canvas3D}->update_bed_size if $self->{canvas3D};
# $self->{preview3D}->set_bed_shape($self->{config}->bed_shape)
# if $self->{preview3D};
#==============================================================================================================================
$update_scheduled = 1;
} elsif ($opt_key =~ '^wipe_tower' || $opt_key eq 'single_extruder_multi_material') {
$update_scheduled = 1;
@ -1903,16 +1812,10 @@ sub on_config_change {
$self->{"btn_layer_editing"}->Disable;
$self->{"btn_layer_editing"}->SetValue(0);
}
#==============================================================================================================================
Slic3r::GUI::_3DScene::enable_layers_editing($self->{canvas3D}, 0);
# $self->{canvas3D}->layer_editing_enabled(0);
#==============================================================================================================================
$self->{canvas3D}->Refresh;
$self->{canvas3D}->Update;
#==============================================================================================================================
} elsif (Slic3r::GUI::_3DScene::is_layers_editing_allowed($self->{canvas3D})) {
# } elsif ($self->{canvas3D}->layer_editing_allowed) {
#==============================================================================================================================
# Want to allow the layer editing, but do it only if the OpenGL supports it.
if ($self->{htoolbar}) {
$self->{htoolbar}->EnableTool(TB_LAYER_EDITING, 1);
@ -1944,12 +1847,8 @@ sub list_item_deselected {
if ($self->{list}->GetFirstSelected == -1) {
$self->select_object(undef);
$self->{canvas}->Refresh;
#==============================================================================================================================
Slic3r::GUI::_3DScene::deselect_volumes($self->{canvas3D}) if $self->{canvas3D};
Slic3r::GUI::_3DScene::render($self->{canvas3D}) if $self->{canvas3D};
# $self->{canvas3D}->deselect_volumes if $self->{canvas3D};
# $self->{canvas3D}->Render if $self->{canvas3D};
#==============================================================================================================================
}
undef $self->{_lecursor};
}
@ -1961,19 +1860,14 @@ sub list_item_selected {
my $obj_idx = $event->GetIndex;
$self->select_object($obj_idx);
$self->{canvas}->Refresh;
#==============================================================================================================================
if ($self->{canvas3D}) {
my $selections = $self->collect_selections;
Slic3r::GUI::_3DScene::update_volumes_selection($self->{canvas3D}, \@$selections);
Slic3r::GUI::_3DScene::render($self->{canvas3D});
}
# $self->{canvas3D}->update_volumes_selection if $self->{canvas3D};
# $self->{canvas3D}->Render if $self->{canvas3D};
#==============================================================================================================================
undef $self->{_lecursor};
}
#==============================================================================================================================
sub collect_selections {
my ($self) = @_;
my $selections = [];
@ -1982,7 +1876,6 @@ sub collect_selections {
}
return $selections;
}
#==============================================================================================================================
sub list_item_activated {
my ($self, $event, $obj_idx) = @_;
@ -2040,10 +1933,7 @@ sub object_cut_dialog {
$self->remove($obj_idx);
$self->load_model_objects(grep defined($_), @new_objects);
$self->arrange;
#==============================================================================================================================
Slic3r::GUI::_3DScene::zoom_to_volumes($self->{canvas3D}) if $self->{canvas3D};
# $self->{canvas3D}->zoom_to_volumes if $self->{canvas3D};
#==============================================================================================================================
}
}
@ -2079,12 +1969,9 @@ sub object_settings_dialog {
$self->{print}->reload_object($obj_idx);
$self->schedule_background_process;
$self->{canvas}->reload_scene if $self->{canvas};
#==============================================================================================================================
my $selections = $self->collect_selections;
Slic3r::GUI::_3DScene::set_objects_selections($self->{canvas3D}, \@$selections);
Slic3r::GUI::_3DScene::reload_scene($self->{canvas3D}, 0);
# $self->{canvas3D}->reload_scene if $self->{canvas3D};
#==============================================================================================================================
} else {
$self->resume_background_process;
}
@ -2097,10 +1984,7 @@ sub object_list_changed {
# Enable/disable buttons depending on whether there are any objects on the platter.
my $have_objects = @{$self->{objects}} ? 1 : 0;
#==============================================================================================================================
my $variable_layer_height_allowed = $self->{config}->variable_layer_height && Slic3r::GUI::_3DScene::is_layers_editing_allowed($self->{canvas3D});
# my $variable_layer_height_allowed = $self->{config}->variable_layer_height && $self->{canvas3D}->layer_editing_allowed;
#==============================================================================================================================
if ($self->{htoolbar}) {
# On OSX or Linux
$self->{htoolbar}->EnableTool($_, $have_objects)
@ -2115,10 +1999,7 @@ sub object_list_changed {
}
my $export_in_progress = $self->{export_gcode_output_file} || $self->{send_gcode_file};
#==============================================================================================================================
my $model_fits = $self->{canvas3D} ? Slic3r::GUI::_3DScene::check_volumes_outside_state($self->{canvas3D}, $self->{config}) : 1;
# my $model_fits = $self->{canvas3D} ? $self->{canvas3D}->volumes->check_outside_state($self->{config}) : 1;
#==============================================================================================================================
my $method = ($have_objects && ! $export_in_progress && $model_fits) ? 'Enable' : 'Disable';
$self->{"btn_$_"}->$method
for grep $self->{"btn_$_"}, qw(reslice export_gcode print send_gcode);
@ -2333,19 +2214,11 @@ sub select_view {
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')) {
#==============================================================================================================================
Slic3r::GUI::_3DScene::select_view($self->{preview3D}->canvas, $direction);
Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{canvas3D}, $self->{preview3D}->canvas);
# $self->{preview3D}->canvas->select_view($direction);
# $self->{canvas3D}->set_viewport_from_scene($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->{canvas3D}->select_view($direction);
# $self->{preview3D}->canvas->set_viewport_from_scene($self->{canvas3D});
#==============================================================================================================================
}
}

View file

@ -222,10 +222,7 @@ sub mouse_event {
];
$self->{drag_object} = [ $obj_idx, $instance_idx ];
} elsif ($event->RightDown) {
#=======================================================================================================================================
$self->{on_right_click}->($pos->x, $pos->y);
# $self->{on_right_click}->($pos);
#=======================================================================================================================================
}
last OBJECTS;

View file

@ -24,10 +24,7 @@ sub new {
# init GUI elements
my $canvas = Slic3r::GUI::3DScene->new($self);
#===================================================================================================================================
Slic3r::GUI::_3DScene::enable_shader($canvas, 1);
# $canvas->use_plain_shader(1);
#===================================================================================================================================
$self->canvas($canvas);
my $slider_low = Wx::Slider->new(
$self, -1,
@ -281,10 +278,7 @@ sub new {
sub reload_print {
my ($self, $force) = @_;
#==============================================================================================================================
Slic3r::GUI::_3DScene::reset_volumes($self->canvas);
# $self->canvas->reset_objects;
#==============================================================================================================================
$self->_loaded(0);
if (! $self->IsShown && ! $force) {
@ -310,10 +304,7 @@ sub refresh_print {
sub reset_gcode_preview_data {
my ($self) = @_;
$self->gcode_preview_data->reset;
#==============================================================================================================================
Slic3r::GUI::_3DScene::reset_legend_texture();
# $self->canvas->reset_legend_texture();
#==============================================================================================================================
}
sub load_print {
@ -338,10 +329,7 @@ sub load_print {
if ($n_layers == 0) {
$self->reset_sliders;
#==============================================================================================================================
Slic3r::GUI::_3DScene::reset_legend_texture();
# $self->canvas->reset_legend_texture();
#==============================================================================================================================
$self->canvas->Refresh; # clears canvas
return;
}
@ -376,42 +364,25 @@ sub load_print {
if ($self->gcode_preview_data->empty) {
# load skirt and brim
#==============================================================================================================================
Slic3r::GUI::_3DScene::set_print($self->canvas, $self->print);
Slic3r::GUI::_3DScene::load_print_toolpaths($self->canvas);
Slic3r::GUI::_3DScene::load_wipe_tower_toolpaths($self->canvas, \@colors);
# $self->canvas->load_print_toolpaths($self->print, \@colors);
# $self->canvas->load_wipe_tower_toolpaths($self->print, \@colors);
#==============================================================================================================================
foreach my $object (@{$self->print->objects}) {
#==============================================================================================================================
Slic3r::GUI::_3DScene::load_print_object_toolpaths($self->canvas, $object, \@colors);
# $self->canvas->load_print_object_toolpaths($object, \@colors);
#==============================================================================================================================
# Show the objects in very transparent color.
#my @volume_ids = $self->canvas->load_object($object->model_object);
#$self->canvas->volumes->[$_]->color->[3] = 0.2 for @volume_ids;
}
$self->show_hide_ui_elements('simple');
#==============================================================================================================================
Slic3r::GUI::_3DScene::reset_legend_texture();
# $self->canvas->reset_legend_texture();
#==============================================================================================================================
} else {
#==============================================================================================================================
$self->{force_sliders_full_range} = (Slic3r::GUI::_3DScene::get_volumes_count($self->canvas) == 0);
Slic3r::GUI::_3DScene::set_print($self->canvas, $self->print);
Slic3r::GUI::_3DScene::load_gcode_preview($self->canvas, $self->gcode_preview_data, \@colors);
# $self->{force_sliders_full_range} = (scalar(@{$self->canvas->volumes}) == 0);
# $self->canvas->load_gcode_preview($self->print, $self->gcode_preview_data, \@colors);
#==============================================================================================================================
$self->show_hide_ui_elements('full');
# recalculates zs and update sliders accordingly
#==============================================================================================================================
$self->{layers_z} = Slic3r::GUI::_3DScene::get_current_print_zs($self->canvas, 1);
# $self->{layers_z} = $self->canvas->get_current_print_zs(1);
#==============================================================================================================================
$n_layers = scalar(@{$self->{layers_z}});
if ($n_layers == 0) {
# all layers filtered out
@ -497,10 +468,7 @@ sub set_z_range
$self->{z_label_low}->SetLabel(sprintf '%.2f', $z_low);
$self->{z_label_high}->SetLabel(sprintf '%.2f', $z_high);
#==============================================================================================================================
my $layers_z = Slic3r::GUI::_3DScene::get_current_print_zs($self->canvas, 0);
# my $layers_z = $self->canvas->get_current_print_zs(0);
#==============================================================================================================================
for (my $i = 0; $i < scalar(@{$layers_z}); $i += 1) {
if (($z_low - 1e-6 < @{$layers_z}[$i]) && (@{$layers_z}[$i] < $z_low + 1e-6)) {
$self->{z_label_low_idx}->SetLabel(sprintf '%d', $i + 1);
@ -514,10 +482,7 @@ sub set_z_range
}
}
#==============================================================================================================================
Slic3r::GUI::_3DScene::set_toolpaths_range($self->canvas, $z_low - 1e-6, $z_high + 1e-6);
# $self->canvas->set_toolpaths_range($z_low - 1e-6, $z_high + 1e-6);
#==============================================================================================================================
$self->canvas->Refresh if $self->IsShown;
}
@ -547,13 +512,6 @@ sub set_z_idx_high
}
}
#==============================================================================================================================
#sub set_bed_shape {
# my ($self, $bed_shape) = @_;
# $self->canvas->set_bed_shape($bed_shape);
#}
#==============================================================================================================================
sub set_number_extruders {
my ($self, $number_extruders) = @_;
if ($self->{number_extruders} != $number_extruders) {

View file

@ -9,9 +9,7 @@ use utf8;
use Slic3r::Geometry qw(PI X);
use Wx qw(wxTheApp :dialog :id :misc :sizer wxTAB_TRAVERSAL);
use Wx::Event qw(EVT_CLOSE EVT_BUTTON);
#==============================================================================================================================
use List::Util qw(max);
#==============================================================================================================================
use base 'Wx::Dialog';
sub new {
@ -115,20 +113,13 @@ sub new {
my $canvas;
if ($Slic3r::GUI::have_OpenGL) {
$canvas = $self->{canvas} = Slic3r::GUI::3DScene->new($self);
#==============================================================================================================================
Slic3r::GUI::_3DScene::load_model_object($self->{canvas}, $self->{model_object}, 0, [0]);
Slic3r::GUI::_3DScene::set_auto_bed_shape($canvas);
Slic3r::GUI::_3DScene::set_axes_length($canvas, 2.0 * max(@{ Slic3r::GUI::_3DScene::get_volumes_bounding_box($canvas)->size }));
# $canvas->load_object($self->{model_object}, undef, undef, [0]);
# $canvas->set_auto_bed_shape;
#==============================================================================================================================
$canvas->SetSize([500,500]);
$canvas->SetMinSize($canvas->GetSize);
#==============================================================================================================================
Slic3r::GUI::_3DScene::set_config($canvas, $self->GetParent->{config});
Slic3r::GUI::_3DScene::enable_force_zoom_to_bed($canvas, 1);
#==============================================================================================================================
}
$self->{sizer} = Wx::BoxSizer->new(wxHORIZONTAL);
@ -157,9 +148,7 @@ sub new {
# Note that the window was already closed, so a pending update will not be executed.
$self->{already_closed} = 1;
$self->EndModal(wxID_OK);
#=============================================================================================================================
$self->{canvas}->Destroy;
#=============================================================================================================================
$self->Destroy();
});
@ -167,9 +156,7 @@ sub new {
# Note that the window was already closed, so a pending update will not be executed.
$self->{already_closed} = 1;
$self->EndModal(wxID_CANCEL);
#=============================================================================================================================
$self->{canvas}->Destroy;
#=============================================================================================================================
$self->Destroy();
});
@ -261,21 +248,11 @@ sub _update {
$expolygon->translate(map Slic3r::Geometry::scale($_), @{ $self->{model_object}->instances->[0]->offset });
}
#==============================================================================================================================
Slic3r::GUI::_3DScene::reset_volumes($self->{canvas});
Slic3r::GUI::_3DScene::load_model_object($self->{canvas}, $_, 0, [0]) for @objects;
Slic3r::GUI::_3DScene::set_cutting_plane($self->{canvas}, $self->{cut_options}{z}, [@expolygons]);
Slic3r::GUI::_3DScene::update_volumes_colors_by_extruder($self->{canvas});
Slic3r::GUI::_3DScene::render($self->{canvas});
# $self->{canvas}->reset_objects;
# $self->{canvas}->load_object($_, undef, undef, [0]) for @objects;
# $self->{canvas}->SetCuttingPlane(
# $self->{cut_options}{z},
# [@expolygons],
# );
# $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->{config});
# $self->{canvas}->Render;
#==============================================================================================================================
}
}

View file

@ -10,9 +10,7 @@ use File::Basename qw(basename);
use Wx qw(:misc :sizer :treectrl :button :keycode wxTAB_TRAVERSAL wxSUNKEN_BORDER wxBITMAP_TYPE_PNG wxID_CANCEL wxMOD_CONTROL
wxTheApp);
use Wx::Event qw(EVT_BUTTON EVT_TREE_ITEM_COLLAPSING EVT_TREE_SEL_CHANGED EVT_TREE_KEY_DOWN EVT_KEY_DOWN);
#==============================================================================================================================
use List::Util qw(max);
#==============================================================================================================================
use base 'Wx::Panel';
use constant ICON_OBJECT => 0;
@ -153,7 +151,6 @@ sub new {
my $canvas;
if ($Slic3r::GUI::have_OpenGL) {
$canvas = $self->{canvas} = Slic3r::GUI::3DScene->new($self);
#==============================================================================================================================
Slic3r::GUI::_3DScene::enable_picking($canvas, 1);
Slic3r::GUI::_3DScene::set_select_by($canvas, 'volume');
Slic3r::GUI::_3DScene::register_on_select_object_callback($canvas, sub {
@ -163,24 +160,10 @@ sub new {
Slic3r::GUI::_3DScene::load_model_object($canvas, $self->{model_object}, 0, [0]);
Slic3r::GUI::_3DScene::set_auto_bed_shape($canvas);
Slic3r::GUI::_3DScene::set_axes_length($canvas, 2.0 * max(@{ Slic3r::GUI::_3DScene::get_volumes_bounding_box($canvas)->size }));
# $canvas->enable_picking(1);
# $canvas->select_by('volume');
# $canvas->on_select(sub {
# my ($volume_idx) = @_;
# # convert scene volume to model object volume
# $self->reload_tree(($volume_idx == -1) ? undef : $canvas->volumes->[$volume_idx]->volume_idx);
# });
# $canvas->load_object($self->{model_object}, undef, undef, [0]);
# $canvas->set_auto_bed_shape;
#==============================================================================================================================
$canvas->SetSize([500,700]);
#==============================================================================================================================
Slic3r::GUI::_3DScene::set_config($canvas, $self->GetParent->GetParent->GetParent->{config});
Slic3r::GUI::_3DScene::update_volumes_colors_by_extruder($canvas);
Slic3r::GUI::_3DScene::enable_force_zoom_to_bed($canvas, 1);
# $canvas->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
#==============================================================================================================================
}
$self->{sizer} = Wx::BoxSizer->new(wxHORIZONTAL);
@ -280,10 +263,7 @@ sub selection_changed {
# deselect all meshes
if ($self->{canvas}) {
#==============================================================================================================================
Slic3r::GUI::_3DScene::deselect_volumes($self->{canvas});
# $_->set_selected(0) for @{$self->{canvas}->volumes};
#==============================================================================================================================
}
# disable things as if nothing is selected
@ -311,10 +291,7 @@ sub selection_changed {
if ($itemData->{type} eq 'volume') {
# select volume in 3D preview
if ($self->{canvas}) {
#==============================================================================================================================
Slic3r::GUI::_3DScene::select_volume($self->{canvas}, $itemData->{volume_id});
# $self->{canvas}->volumes->[ $itemData->{volume_id} ]->set_selected(1);
#==============================================================================================================================
}
$self->{btn_delete}->Enable;
$self->{btn_split}->Enable;
@ -357,10 +334,7 @@ sub selection_changed {
$self->{settings_panel}->enable;
}
#==============================================================================================================================
Slic3r::GUI::_3DScene::render($self->{canvas}) if $self->{canvas};
# $self->{canvas}->Render if $self->{canvas};
#==============================================================================================================================
}
sub on_btn_load {
@ -456,10 +430,7 @@ sub on_btn_move_up {
if ($itemData && $itemData->{type} eq 'volume') {
my $volume_id = $itemData->{volume_id};
if ($self->{model_object}->move_volume_up($volume_id)) {
#==============================================================================================================================
Slic3r::GUI::_3DScene::move_volume_up($self->{canvas}, $volume_id);
# $self->{canvas}->volumes->move_volume_up($volume_id);
#==============================================================================================================================
$self->{parts_changed} = 1;
$self->reload_tree($volume_id - 1);
}
@ -472,10 +443,7 @@ sub on_btn_move_down {
if ($itemData && $itemData->{type} eq 'volume') {
my $volume_id = $itemData->{volume_id};
if ($self->{model_object}->move_volume_down($volume_id)) {
#==============================================================================================================================
Slic3r::GUI::_3DScene::move_volume_down($self->{canvas}, $volume_id);
# $self->{canvas}->volumes->move_volume_down($volume_id);
#==============================================================================================================================
$self->{parts_changed} = 1;
$self->reload_tree($volume_id + 1);
}
@ -520,18 +488,11 @@ sub _parts_changed {
$self->reload_tree;
if ($self->{canvas}) {
#==============================================================================================================================
Slic3r::GUI::_3DScene::reset_volumes($self->{canvas});
Slic3r::GUI::_3DScene::load_model_object($self->{canvas}, $self->{model_object}, 0, [0]);
Slic3r::GUI::_3DScene::zoom_to_volumes($self->{canvas});
Slic3r::GUI::_3DScene::update_volumes_colors_by_extruder($self->{canvas});
Slic3r::GUI::_3DScene::render($self->{canvas});
# $self->{canvas}->reset_objects;
# $self->{canvas}->load_object($self->{model_object});
# $self->{canvas}->zoom_to_volumes;
# $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
# $self->{canvas}->Render;
#==============================================================================================================================
}
}
@ -551,12 +512,10 @@ sub CanClose {
return ! Slic3r::GUI::catch_error($self);
}
#=============================================================================================================================
sub Destroy {
my ($self) = @_;
$self->{canvas}->Destroy if ($self->{canvas});
}
#=============================================================================================================================
sub PartsChanged {
my ($self) = @_;
@ -572,29 +531,18 @@ sub _update_canvas {
my ($self) = @_;
if ($self->{canvas}) {
#==============================================================================================================================
Slic3r::GUI::_3DScene::reset_volumes($self->{canvas});
Slic3r::GUI::_3DScene::load_model_object($self->{canvas}, $self->{model_object}, 0, [0]);
# $self->{canvas}->reset_objects;
# $self->{canvas}->load_object($self->{model_object});
#==============================================================================================================================
# restore selection, if any
if (my $itemData = $self->get_selection) {
if ($itemData->{type} eq 'volume') {
#==============================================================================================================================
Slic3r::GUI::_3DScene::select_volume($self->{canvas}, $itemData->{volume_id});
# $self->{canvas}->volumes->[ $itemData->{volume_id} ]->set_selected(1);
#==============================================================================================================================
}
}
#==============================================================================================================================
Slic3r::GUI::_3DScene::update_volumes_colors_by_extruder($self->{canvas});
Slic3r::GUI::_3DScene::render($self->{canvas});
# $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
# $self->{canvas}->Render;
#==============================================================================================================================
}
}
@ -616,16 +564,10 @@ sub _update {
$self->{parts_changed} = 1;
my @objects = ();
push @objects, $self->{model_object};
#==============================================================================================================================
Slic3r::GUI::_3DScene::reset_volumes($self->{canvas});
Slic3r::GUI::_3DScene::load_model_object($self->{canvas}, $_, 0, [0]) for @objects;
Slic3r::GUI::_3DScene::update_volumes_colors_by_extruder($self->{canvas});
Slic3r::GUI::_3DScene::render($self->{canvas});
# $self->{canvas}->reset_objects;
# $self->{canvas}->load_object($_, undef, [0]) for @objects;
# $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
# $self->{canvas}->Render;
#==============================================================================================================================
}
1;

View file

@ -36,9 +36,7 @@ sub new {
wxTheApp->save_window_pos($self, "object_settings");
$self->EndModal(wxID_OK);
#=============================================================================================================================
$self->{parts}->Destroy;
#=============================================================================================================================
$self->Destroy;
});

View file

@ -122,17 +122,6 @@ _constant()
RETVAL.push_back(slicing_params.layer_height);
%};
//###################################################################################################################################################################
// void adjust_layer_height_profile(coordf_t z, coordf_t layer_thickness_delta, coordf_t band_width, int action)
// %code%{
// THIS->update_layer_height_profile(THIS->model_object()->layer_height_profile);
// adjust_layer_height_profile(
// THIS->slicing_parameters(), THIS->model_object()->layer_height_profile, z, layer_thickness_delta, band_width, LayerHeightEditActionType(action));
// THIS->model_object()->layer_height_profile_valid = true;
// THIS->layer_height_profile_valid = false;
// %};
//###################################################################################################################################################################
void reset_layer_height_profile();
int ptr()