mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 22:54:08 -06:00
Merge remote-tracking branch 'origin/scene_manipulators'
This commit is contained in:
commit
913cdef297
12 changed files with 238 additions and 63 deletions
|
@ -1527,10 +1527,13 @@ sub draw_active_object_annotations {
|
|||
my ($reset_left, $reset_bottom, $reset_right, $reset_top) = $self->_variable_layer_thickness_reset_rect_viewport;
|
||||
my $z_cursor_relative = $self->_variable_layer_thickness_bar_mouse_cursor_z_relative;
|
||||
|
||||
my $print_object = $self->{print}->get_object($object_idx);
|
||||
my $z_max = $print_object->model_object->bounding_box->z_max;
|
||||
|
||||
$self->{layer_height_edit_shader}->enable;
|
||||
$self->{layer_height_edit_shader}->set_uniform('z_to_texture_row', $volume->layer_height_texture_z_to_row_id);
|
||||
$self->{layer_height_edit_shader}->set_uniform('z_texture_row_to_normalized', 1. / $volume->layer_height_texture_height);
|
||||
$self->{layer_height_edit_shader}->set_uniform('z_cursor', $volume->bounding_box->z_max * $z_cursor_relative);
|
||||
$self->{layer_height_edit_shader}->set_uniform('z_cursor', $z_max * $z_cursor_relative);
|
||||
$self->{layer_height_edit_shader}->set_uniform('z_cursor_band_width', $self->{layer_height_edit_band_width});
|
||||
glBindTexture(GL_TEXTURE_2D, $self->{layer_preview_z_texture_id});
|
||||
glTexImage2D_c(GL_TEXTURE_2D, 0, GL_RGBA8, $volume->layer_height_texture_width, $volume->layer_height_texture_height,
|
||||
|
@ -1552,8 +1555,8 @@ sub draw_active_object_annotations {
|
|||
glBegin(GL_QUADS);
|
||||
glVertex3f($bar_left, $bar_bottom, 0);
|
||||
glVertex3f($bar_right, $bar_bottom, 0);
|
||||
glVertex3f($bar_right, $bar_top, $volume->bounding_box->z_max);
|
||||
glVertex3f($bar_left, $bar_top, $volume->bounding_box->z_max);
|
||||
glVertex3f($bar_right, $bar_top, $z_max);
|
||||
glVertex3f($bar_left, $bar_top, $z_max);
|
||||
glEnd();
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
$self->{layer_height_edit_shader}->disable;
|
||||
|
@ -1572,7 +1575,6 @@ sub draw_active_object_annotations {
|
|||
|
||||
# Paint the graph.
|
||||
#FIXME show some kind of legend.
|
||||
my $print_object = $self->{print}->get_object($object_idx);
|
||||
my $max_z = unscale($print_object->size->z);
|
||||
my $profile = $print_object->model_object->layer_height_profile;
|
||||
my $layer_height = $print_object->config->get('layer_height');
|
||||
|
@ -1677,6 +1679,11 @@ sub draw_warning {
|
|||
}
|
||||
}
|
||||
|
||||
sub update_volumes_colors_by_extruder {
|
||||
my ($self, $config) = @_;
|
||||
$self->volumes->update_colors_by_extruder($config);
|
||||
}
|
||||
|
||||
sub opengl_info
|
||||
{
|
||||
my ($self, %params) = @_;
|
||||
|
@ -1823,7 +1830,6 @@ sub _fragment_shader_Gouraud {
|
|||
return <<'FRAGMENT';
|
||||
#version 110
|
||||
|
||||
const vec4 OUTSIDE_COLOR = vec4(0.24, 0.42, 0.62, 1.0);
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
// x = tainted, y = specular;
|
||||
|
@ -1836,11 +1842,9 @@ uniform vec4 uniform_color;
|
|||
|
||||
void main()
|
||||
{
|
||||
// if the fragment is outside the print volume use predefined color
|
||||
vec4 color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? OUTSIDE_COLOR : uniform_color;
|
||||
|
||||
gl_FragColor = vec4(intensity.y, intensity.y, intensity.y, 0.0) + color * intensity.x;
|
||||
gl_FragColor.a = color.a;
|
||||
// if the fragment is outside the print volume -> use darker color
|
||||
vec3 color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? mix(uniform_color.rgb, ZERO, 0.3333) : uniform_color.rgb;
|
||||
gl_FragColor = vec4(vec3(intensity.y, intensity.y, intensity.y) + color * intensity.x, uniform_color.a);
|
||||
}
|
||||
|
||||
FRAGMENT
|
||||
|
@ -1932,8 +1936,6 @@ const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
|||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
uniform float z_to_texture_row;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
varying vec2 intensity;
|
||||
|
||||
|
|
|
@ -104,7 +104,6 @@ sub new {
|
|||
$self->{btn_reslice}->Enable($enable);
|
||||
$self->{btn_print}->Enable($enable);
|
||||
$self->{btn_send_gcode}->Enable($enable);
|
||||
$self->{btn_export_stl}->Enable($enable);
|
||||
};
|
||||
|
||||
# Initialize 3D plater
|
||||
|
@ -737,8 +736,14 @@ sub load_model_objects {
|
|||
{
|
||||
# if the object is too large (more than 5 times the bed), scale it down
|
||||
my $size = $o->bounding_box->size;
|
||||
my $ratio = max(@$size[X,Y]) / unscale(max(@$bed_size[X,Y]));
|
||||
if ($ratio > 5) {
|
||||
my $ratio = max($size->x / unscale($bed_size->x), $size->y / unscale($bed_size->y));
|
||||
if ($ratio > 10000) {
|
||||
# the size of the object is too big -> this could lead to overflow when moving to clipper coordinates,
|
||||
# so scale down the mesh
|
||||
$o->scale_xyz(Slic3r::Pointf3->new(1/$ratio, 1/$ratio, 1/$ratio));
|
||||
$scaled_down = 1;
|
||||
}
|
||||
elsif ($ratio > 5) {
|
||||
$_->set_scaling_factor(1/$ratio) for @{$o->instances};
|
||||
$scaled_down = 1;
|
||||
}
|
||||
|
@ -1914,7 +1919,8 @@ sub object_list_changed {
|
|||
}
|
||||
|
||||
my $export_in_progress = $self->{export_gcode_output_file} || $self->{send_gcode_file};
|
||||
my $method = ($have_objects && ! $export_in_progress) ? 'Enable' : 'Disable';
|
||||
my $model_fits = $self->{model}->fits_print_volume($self->{config});
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -217,6 +217,8 @@ sub reload_scene {
|
|||
}
|
||||
}
|
||||
|
||||
$self->update_volumes_colors_by_extruder($self->{config});
|
||||
|
||||
# checks for geometry outside the print volume to render it accordingly
|
||||
if (scalar @{$self->volumes} > 0)
|
||||
{
|
||||
|
@ -230,6 +232,9 @@ sub reload_scene {
|
|||
Slic3r::GUI::_3DScene::reset_warning_texture();
|
||||
$self->on_enable_action_buttons->(1) if ($self->on_enable_action_buttons);
|
||||
}
|
||||
} else {
|
||||
$self->set_warning_enabled(0);
|
||||
Slic3r::GUI::_3DScene::reset_warning_texture();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ sub new {
|
|||
label => 'Z',
|
||||
default => $self->{cut_options}{z},
|
||||
min => 0,
|
||||
max => $self->{model_object}->bounding_box->size->z * $self->{model_object}->instances->[0]->scaling_factor,
|
||||
max => $self->{model_object}->bounding_box->size->z,
|
||||
full_width => 1,
|
||||
));
|
||||
{
|
||||
|
@ -247,6 +247,7 @@ sub _update {
|
|||
$self->{cut_options}{z},
|
||||
[@expolygons],
|
||||
);
|
||||
$self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->{config});
|
||||
$self->{canvas}->Render;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use utf8;
|
|||
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);
|
||||
use Wx::Event qw(EVT_BUTTON EVT_TREE_ITEM_COLLAPSING EVT_TREE_SEL_CHANGED EVT_TREE_KEY_DOWN EVT_KEY_DOWN);
|
||||
use base 'Wx::Panel';
|
||||
|
||||
use constant ICON_OBJECT => 0;
|
||||
|
@ -88,7 +88,7 @@ sub new {
|
|||
$self->{btn_move_down}->SetFont($Slic3r::GUI::small_font);
|
||||
|
||||
# part settings panel
|
||||
$self->{settings_panel} = Slic3r::GUI::Plater::OverrideSettingsPanel->new($self, on_change => sub { $self->{part_settings_changed} = 1; });
|
||||
$self->{settings_panel} = Slic3r::GUI::Plater::OverrideSettingsPanel->new($self, on_change => sub { $self->{part_settings_changed} = 1; $self->_update_canvas; });
|
||||
my $settings_sizer = Wx::StaticBoxSizer->new($self->{staticbox} = Wx::StaticBox->new($self, -1, "Part Settings"), wxVERTICAL);
|
||||
$settings_sizer->Add($self->{settings_panel}, 1, wxEXPAND | wxALL, 0);
|
||||
|
||||
|
@ -162,6 +162,7 @@ sub new {
|
|||
$canvas->load_object($self->{model_object}, undef, undef, [0]);
|
||||
$canvas->set_auto_bed_shape;
|
||||
$canvas->SetSize([500,700]);
|
||||
$canvas->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
|
||||
$canvas->zoom_to_volumes;
|
||||
}
|
||||
|
||||
|
@ -190,6 +191,14 @@ sub new {
|
|||
EVT_BUTTON($self, $self->{btn_split}, \&on_btn_split);
|
||||
EVT_BUTTON($self, $self->{btn_move_up}, \&on_btn_move_up);
|
||||
EVT_BUTTON($self, $self->{btn_move_down}, \&on_btn_move_down);
|
||||
EVT_KEY_DOWN($canvas, sub {
|
||||
my ($canvas, $event) = @_;
|
||||
if ($event->GetKeyCode == WXK_DELETE) {
|
||||
$canvas->GetParent->on_btn_delete;
|
||||
} else {
|
||||
$event->Skip;
|
||||
}
|
||||
});
|
||||
|
||||
$self->reload_tree;
|
||||
|
||||
|
@ -400,14 +409,17 @@ sub on_tree_key_down {
|
|||
my ($self, $event) = @_;
|
||||
my $keycode = $event->GetKeyCode;
|
||||
# Wx >= 0.9911
|
||||
if (defined(&Wx::TreeEvent::GetKeyEvent) &&
|
||||
($event->GetKeyEvent->GetModifiers & wxMOD_CONTROL)) {
|
||||
if ($keycode == WXK_UP) {
|
||||
$event->Skip;
|
||||
$self->on_btn_move_up;
|
||||
} elsif ($keycode == WXK_DOWN) {
|
||||
$event->Skip;
|
||||
$self->on_btn_move_down;
|
||||
if (defined(&Wx::TreeEvent::GetKeyEvent)) {
|
||||
if ($event->GetKeyEvent->GetModifiers & wxMOD_CONTROL) {
|
||||
if ($keycode == WXK_UP) {
|
||||
$event->Skip;
|
||||
$self->on_btn_move_up;
|
||||
} elsif ($keycode == WXK_DOWN) {
|
||||
$event->Skip;
|
||||
$self->on_btn_move_down;
|
||||
}
|
||||
} elsif ($keycode == WXK_DELETE) {
|
||||
$self->on_btn_delete;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -478,6 +490,7 @@ sub _parts_changed {
|
|||
$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;
|
||||
}
|
||||
}
|
||||
|
@ -508,6 +521,25 @@ sub PartSettingsChanged {
|
|||
return $self->{part_settings_changed};
|
||||
}
|
||||
|
||||
sub _update_canvas {
|
||||
my ($self) = @_;
|
||||
|
||||
if ($self->{canvas}) {
|
||||
$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') {
|
||||
$self->{canvas}->volumes->[ $itemData->{volume_id} ]->set_selected(1);
|
||||
}
|
||||
}
|
||||
|
||||
$self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
|
||||
$self->{canvas}->Render;
|
||||
}
|
||||
}
|
||||
|
||||
sub _update {
|
||||
my ($self) = @_;
|
||||
my ($m_x, $m_y, $m_z) = ($self->{move_options}{x}, $self->{move_options}{y}, $self->{move_options}{z});
|
||||
|
@ -528,6 +560,7 @@ sub _update {
|
|||
push @objects, $self->{model_object};
|
||||
$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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue