Validate the height values entered into the layer height table.

Clamp these values between the minimum of min_layer_height per nozzle
and the maximum of max_layer_height per nozzle.
Don't allow entering zero layer height to trim an object,
the cut dialog should be used instead.

Fixes https://github.com/prusa3d/Slic3r/issues/235
This commit is contained in:
bubnikv 2017-04-05 13:27:00 +02:00
parent 6f5700a3a6
commit b66bfb41aa
2 changed files with 32 additions and 3 deletions

View file

@ -1819,6 +1819,7 @@ sub object_settings_dialog {
my $dlg = Slic3r::GUI::Plater::ObjectSettingsDialog->new($self, my $dlg = Slic3r::GUI::Plater::ObjectSettingsDialog->new($self,
object => $self->{objects}[$obj_idx], object => $self->{objects}[$obj_idx],
model_object => $model_object, model_object => $model_object,
config => $self->GetFrame->config,
); );
$self->pause_background_process; $self->pause_background_process;
$dlg->ShowModal; $dlg->ShowModal;

View file

@ -19,7 +19,7 @@ sub new {
my ($parent, %params) = @_; my ($parent, %params) = @_;
my $self = $class->SUPER::new($parent, -1, "Settings for " . $params{object}->name, wxDefaultPosition, [700,500], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER); my $self = $class->SUPER::new($parent, -1, "Settings for " . $params{object}->name, wxDefaultPosition, [700,500], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
$self->{$_} = $params{$_} for keys %params; $self->{$_} = $params{$_} for keys %params;
$self->{tabpanel} = Wx::Notebook->new($self, -1, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL); $self->{tabpanel} = Wx::Notebook->new($self, -1, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL);
$self->{tabpanel}->AddPage($self->{parts} = Slic3r::GUI::Plater::ObjectPartsPanel->new($self->{tabpanel}, model_object => $params{model_object}), "Parts"); $self->{tabpanel}->AddPage($self->{parts} = Slic3r::GUI::Plater::ObjectPartsPanel->new($self->{tabpanel}, model_object => $params{model_object}), "Parts");
$self->{tabpanel}->AddPage($self->{layers} = Slic3r::GUI::Plater::ObjectDialog::LayersTab->new($self->{tabpanel}), "Layers"); $self->{tabpanel}->AddPage($self->{layers} = Slic3r::GUI::Plater::ObjectDialog::LayersTab->new($self->{tabpanel}), "Layers");
@ -80,7 +80,7 @@ sub new {
my $sizer = Wx::BoxSizer->new(wxVERTICAL); my $sizer = Wx::BoxSizer->new(wxVERTICAL);
{ {
my $label = Wx::StaticText->new($self, -1, "You can use this section to override the default layer height for parts of this object. Set layer height to zero to skip portions of the input file.", my $label = Wx::StaticText->new($self, -1, "You can use this section to override the default layer height for parts of this object.",
wxDefaultPosition, [-1, 40]); wxDefaultPosition, [-1, 40]);
$label->SetFont(Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); $label->SetFont(Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
$sizer->Add($label, 0, wxEXPAND | wxALL, 10); $sizer->Add($label, 0, wxEXPAND | wxALL, 10);
@ -112,7 +112,7 @@ sub new {
my $value = $grid->GetCellValue($event->GetRow, $event->GetCol); my $value = $grid->GetCellValue($event->GetRow, $event->GetCol);
$value =~ s/,/./g; $value =~ s/,/./g;
$value =~ s/[^0-9.]//g; $value =~ s/[^0-9.]//g;
$grid->SetCellValue($event->GetRow, $event->GetCol, $value); $grid->SetCellValue($event->GetRow, $event->GetCol, ($event->GetCol == 2) ? $self->_clamp_layer_height($value) : $value);
# if there's no empty row, let's append one # if there's no empty row, let's append one
for my $i (0 .. $grid->GetNumberRows) { for my $i (0 .. $grid->GetNumberRows) {
@ -136,6 +136,34 @@ sub new {
return $self; return $self;
} }
sub _clamp_layer_height
{
my ($self, $value) = @_;
# $self->GetParent->GetParent is of type Slic3r::GUI::Plater::ObjectSettingsDialog
my $config = $self->GetParent->GetParent->{config};
if ($value =~ /^[0-9,.E]+$/) {
# Looks like a number. Validate the layer height.
my $nozzle_dmrs = $config->get('nozzle_diameter');
my $min_layer_heights = $config->get('min_layer_height');
my $max_layer_heights = $config->get('max_layer_height');
my $min_layer_height = 1000.;
my $max_layer_height = 0.;
my $max_nozzle_dmr = 0.;
for (my $i = 0; $i < int(@{$nozzle_dmrs}); $i += 1) {
$min_layer_height = $min_layer_heights->[$i] if ($min_layer_heights->[$i] < $min_layer_height);
$max_layer_height = $max_layer_heights->[$i] if ($max_layer_heights->[$i] > $max_layer_height);
$max_nozzle_dmr = $nozzle_dmrs ->[$i] if ($nozzle_dmrs ->[$i] > $max_nozzle_dmr );
}
$min_layer_height = 0.005 if ($min_layer_height < 0.005);
$max_layer_height = $max_nozzle_dmr if ($max_layer_height > $max_nozzle_dmr);
return ($value < $min_layer_height) ? $min_layer_height :
($value > $max_layer_height) ? $max_layer_height : $value;
} else {
# If an invalid numeric value has been entered, use the default layer height.
return $config->get('layer_height');
}
}
sub CanClose { sub CanClose {
my $self = shift; my $self = shift;