Slider to control adaptive quality parameter

This commit is contained in:
Florens Wasserfall 2017-02-15 15:14:55 +01:00
parent 67169254a0
commit b243f8e64f
2 changed files with 30 additions and 16 deletions

View File

@ -46,14 +46,26 @@ sub new {
wxHORIZONTAL, wxHORIZONTAL,
); );
my $cusp_label = $self->{cusp_label} = Wx::StaticText->new($self, -1, "", wxDefaultPosition, my $cusp_label = $self->{cusp_label} = Wx::StaticText->new($self, -1, " <-Quality", wxDefaultPosition,
[150,-1], wxALIGN_CENTRE_HORIZONTAL); [-1,-1], wxALIGN_LEFT);
my $value_label = $self->{value_label} = Wx::StaticText->new($self, -1, "", wxDefaultPosition,
[50,-1], wxALIGN_CENTRE_HORIZONTAL | wxST_NO_AUTORESIZE);
my $speed_label = $self->{speed_label} = Wx::StaticText->new($self, -1, "Speed->", wxDefaultPosition,
[-1,-1], wxST_NO_AUTORESIZE | wxALIGN_RIGHT);
$cusp_label->SetFont($Slic3r::GUI::small_font); $cusp_label->SetFont($Slic3r::GUI::small_font);
$value_label->SetFont($Slic3r::GUI::small_font);
$speed_label->SetFont($Slic3r::GUI::small_font);
my $quality_label_sizer = Wx::BoxSizer->new(wxHORIZONTAL);
$quality_label_sizer->Add($cusp_label, 1, wxEXPAND | wxALL, 0);
$quality_label_sizer->Add($value_label, 1, wxEXPAND | wxALL, 0);
$quality_label_sizer->Add($speed_label, 1, wxEXPAND | wxALL, 0);
my $right_sizer = Wx::BoxSizer->new(wxVERTICAL); my $right_sizer = Wx::BoxSizer->new(wxVERTICAL);
$right_sizer->Add($self->{splineControl}, 1, wxEXPAND | wxALL, 0); $right_sizer->Add($self->{splineControl}, 1, wxEXPAND | wxALL, 0);
$right_sizer->Add($cusp_slider, 0, wxEXPAND | wxALL, 0); $right_sizer->Add($cusp_slider, 0, wxEXPAND | wxALL, 0);
$right_sizer->Add($cusp_label, 0, wxEXPAND | wxALL, 0); $right_sizer->Add($quality_label_sizer, 0, wxEXPAND | wxALL, 0);
$self->{sizer} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{sizer} = Wx::BoxSizer->new(wxHORIZONTAL);
$self->{sizer}->Add($self->{preview3D}, 3, wxEXPAND | wxTOP | wxBOTTOM, 0) if $self->{preview3D}; $self->{sizer}->Add($self->{preview3D}, 3, wxEXPAND | wxTOP | wxBOTTOM, 0) if $self->{preview3D};
@ -95,12 +107,12 @@ sub new {
# init cusp slider # init cusp slider
if($object->config->adaptive_slicing) { if($object->config->adaptive_slicing) {
my $cusp_value = $object->config->get('cusp_value'); my $cusp_value = $object->config->get('cusp_value');
$cusp_label->SetLabel(sprintf 'Cusp value: %.2f mm', $cusp_value); $value_label->SetLabel(sprintf '%.2f mm', $cusp_value);
$cusp_slider->SetRange(0, 100); $cusp_slider->SetRange(0, 100);
$cusp_slider->SetValue($cusp_value*100); $cusp_slider->SetValue($cusp_value*100);
}else{ }else{
# disable slider # disable slider
$cusp_label->SetLabel("Cusp value: "); $value_label->SetLabel("");
$cusp_label->Enable(0); $cusp_label->Enable(0);
$cusp_slider->Enable(0); $cusp_slider->Enable(0);
} }
@ -108,7 +120,7 @@ sub new {
EVT_SLIDER($self, $cusp_slider, sub { EVT_SLIDER($self, $cusp_slider, sub {
$self->{plater}->pause_background_process; $self->{plater}->pause_background_process;
my $cusp_value = $cusp_slider->GetValue/100; my $cusp_value = $cusp_slider->GetValue/100;
$cusp_label->SetLabel(sprintf 'Cusp value: %.2f mm', $cusp_value); $value_label->SetLabel(sprintf '%.2f mm', $cusp_value);
my $success = $object->config->set('cusp_value', $cusp_value); my $success = $object->config->set('cusp_value', $cusp_value);
$object->layer_height_spline->setCuspValue($cusp_value); $object->layer_height_spline->setCuspValue($cusp_value);
# trigger re-slicing # trigger re-slicing

View File

@ -24,7 +24,7 @@ sub new {
$self->{line_pen} = Wx::Pen->new(Wx::Colour->new(50,50,50), 1, wxSOLID); $self->{line_pen} = Wx::Pen->new(Wx::Colour->new(50,50,50), 1, wxSOLID);
$self->{original_pen} = Wx::Pen->new(Wx::Colour->new(200,200,200), 1, wxSOLID); $self->{original_pen} = Wx::Pen->new(Wx::Colour->new(200,200,200), 1, wxSOLID);
$self->{interactive_pen} = Wx::Pen->new(Wx::Colour->new(255,0,0), 1, wxSOLID); $self->{interactive_pen} = Wx::Pen->new(Wx::Colour->new(255,0,0), 1, wxSOLID);
$self->{resulting_pen} = Wx::Pen->new(Wx::Colour->new(50,255,50), 1, wxSOLID); $self->{resulting_pen} = Wx::Pen->new(Wx::Colour->new(5,120,160), 1, wxSOLID);
$self->{user_drawn_background} = $^O ne 'darwin'; $self->{user_drawn_background} = $^O ne 'darwin';
@ -84,7 +84,7 @@ sub repaint {
$dc->SetPen($self->{original_pen}); $dc->SetPen($self->{original_pen});
my $pl = $self->point_to_pixel(0, $z); my $pl = $self->point_to_pixel(0, $z);
my $pr = $self->point_to_pixel($layer_h, $z); my $pr = $self->point_to_pixel($layer_h, $z);
$dc->DrawLine($pl->x, $pl->y, $pr->x, $pr->y); #$dc->DrawLine($pl->x, $pl->y, $pr->x, $pr->y);
push (@points, $pr); push (@points, $pr);
$last_z = $z; $last_z = $z;
} }
@ -112,14 +112,16 @@ sub repaint {
# draw resulting layers as lines # draw resulting layers as lines
$last_z = 0.0; $last_z = 0.0;
@points = (); @points = ();
foreach my $z (@{$self->{interpolated_layers}}) { unless($self->{interactive_heights}) {
my $layer_h = $z - $last_z; foreach my $z (@{$self->{interpolated_layers}}) {
$dc->SetPen($self->{resulting_pen}); my $layer_h = $z - $last_z;
my $pl = $self->point_to_pixel(0, $z); $dc->SetPen($self->{resulting_pen});
my $pr = $self->point_to_pixel($layer_h, $z); my $pl = $self->point_to_pixel(0, $z);
$dc->DrawLine($pl->x, $pl->y, $pr->x, $pr->y); my $pr = $self->point_to_pixel($layer_h, $z);
push (@points, $pr); $dc->DrawLine($pl->x, $pl->y, $pr->x, $pr->y);
$last_z = $z; push (@points, $pr);
$last_z = $z;
}
} }
# $dc->DrawSpline(\@points); # $dc->DrawSpline(\@points);