mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-18 04:08:02 -06:00
Fixed the rotation and scaling inputs allowing decimal numbers with
both the dot and comma as a decimal separator.
Fixes 6649888d1c
This commit is contained in:
parent
cc9460b8fa
commit
a7838cac07
1 changed files with 36 additions and 32 deletions
|
@ -879,9 +879,30 @@ sub set_number_of_copies {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub _get_number_from_user {
|
||||||
|
my ($self, $title, $prompt_message, $error_message, $default, $only_positive) = @_;
|
||||||
|
for (;;) {
|
||||||
|
my $value = Wx::GetTextFromUser($prompt_message, $title, $default, $self);
|
||||||
|
# Accept both dashes and dots as a decimal separator.
|
||||||
|
$value =~ s/,/./;
|
||||||
|
# If scaling value is being entered, remove the trailing percent sign.
|
||||||
|
$value =~ s/%$// if $only_positive;
|
||||||
|
# User canceled the selection, return undef.
|
||||||
|
return if $value eq '';
|
||||||
|
# Validate a numeric value.
|
||||||
|
return $value if ($value =~ /^-?\d*(?:\.\d*)?$/) && (! $only_positive || $value > 0);
|
||||||
|
Wx::MessageBox(
|
||||||
|
$error_message .
|
||||||
|
(($only_positive && $value <= 0) ?
|
||||||
|
": $value\nNon-positive value." :
|
||||||
|
": $value\nNot a numeric value."),
|
||||||
|
"Slic3r Error", wxOK | wxICON_EXCLAMATION, $self);
|
||||||
|
$default = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub rotate {
|
sub rotate {
|
||||||
my $self = shift;
|
my ($self, $angle, $axis, $relative_key) = @_;
|
||||||
my ($angle, $axis, $relative_key) = @_;
|
|
||||||
$relative_key //= 'absolute'; # relative or absolute coordinates
|
$relative_key //= 'absolute'; # relative or absolute coordinates
|
||||||
$axis //= Z; # angle is in degrees
|
$axis //= Z; # angle is in degrees
|
||||||
|
|
||||||
|
@ -899,16 +920,8 @@ sub rotate {
|
||||||
if (!defined $angle) {
|
if (!defined $angle) {
|
||||||
my $axis_name = $axis == X ? 'X' : $axis == Y ? 'Y' : 'Z';
|
my $axis_name = $axis == X ? 'X' : $axis == Y ? 'Y' : 'Z';
|
||||||
my $default = $axis == Z ? rad2deg($model_instance->rotation) : 0;
|
my $default = $axis == Z ? rad2deg($model_instance->rotation) : 0;
|
||||||
# Wx::GetNumberFromUser() does not support decimal numbers
|
$angle = $self->_get_number_from_user("Enter the rotation angle:", "Rotate around $axis_name axis", "Invalid rotation angle entered", $default);
|
||||||
for (;;) {
|
|
||||||
$angle = Wx::GetTextFromUser("Enter the rotation angle:", "Rotate around $axis_name axis", $default, $self);
|
|
||||||
$angle =~ s/,/./;
|
|
||||||
# Validate a numeric value.
|
|
||||||
return if $angle eq '';
|
return if $angle eq '';
|
||||||
last if ($angle =~ /^-?\d*(?:\.\d*)?$/);
|
|
||||||
Wx::MessageBox("Invalid rotation angle entered: $angle\nNot a numeric value.", "Slic3r Error", wxOK | wxICON_EXCLAMATION, $self);
|
|
||||||
$default = $angle;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->stop_background_process;
|
$self->stop_background_process;
|
||||||
|
@ -991,19 +1004,14 @@ sub changescale {
|
||||||
my $scale;
|
my $scale;
|
||||||
if ($tosize) {
|
if ($tosize) {
|
||||||
my $cursize = $object_size->[$axis];
|
my $cursize = $object_size->[$axis];
|
||||||
# Wx::GetNumberFromUser() does not support decimal numbers
|
my $newsize = $self->_get_number_from_user(
|
||||||
my $newsize = Wx::GetTextFromUser(
|
sprintf('Enter the new size for the selected object (print bed: %smm):', $bed_size->[$axis]),
|
||||||
sprintf("Enter the new size for the selected object (print bed: %smm):", $bed_size->[$axis]),
|
"Scale along $axis_name", 'Invalid scaling value entered', $cursize, 1);
|
||||||
"Scale along $axis_name",
|
return if $newsize eq '';
|
||||||
$cursize, $self);
|
|
||||||
return if !$newsize || $newsize !~ /^\d*(?:\.\d*)?$/ || $newsize < 0;
|
|
||||||
$scale = $newsize / $cursize * 100;
|
$scale = $newsize / $cursize * 100;
|
||||||
} else {
|
} else {
|
||||||
# Wx::GetNumberFromUser() does not support decimal numbers
|
$scale = $self->_get_number_from_user('Enter the scale % for the selected object:', "Scale along $axis_name", 'Invalid scaling value entered', 100, 1);
|
||||||
$scale = Wx::GetTextFromUser("Enter the scale % for the selected object:",
|
return if $scale eq '';
|
||||||
"Scale along $axis_name", 100, $self);
|
|
||||||
$scale =~ s/%$//;
|
|
||||||
return if !$scale || $scale !~ /^\d*(?:\.\d*)?$/ || $scale < 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# apply Z rotation before scaling
|
# apply Z rotation before scaling
|
||||||
|
@ -1023,17 +1031,13 @@ sub changescale {
|
||||||
my $scale;
|
my $scale;
|
||||||
if ($tosize) {
|
if ($tosize) {
|
||||||
my $cursize = max(@$object_size);
|
my $cursize = max(@$object_size);
|
||||||
# Wx::GetNumberFromUser() does not support decimal numbers
|
my $newsize = $self->_get_number_from_user('Enter the new max size for the selected object:', 'Scale', 'Invalid scaling value entered', $cursize, 1);
|
||||||
my $newsize = Wx::GetTextFromUser("Enter the new max size for the selected object:",
|
return if $newsize eq '';
|
||||||
"Scale", $cursize, $self);
|
$scale = $model_instance->scaling_factor * $newsize / $cursize * 100;
|
||||||
return if !$newsize || $newsize !~ /^\d*(?:\.\d*)?$/ || $newsize < 0;
|
|
||||||
$scale = $newsize / $cursize * 100;
|
|
||||||
} else {
|
} else {
|
||||||
# max scale factor should be above 2540 to allow importing files exported in inches
|
# max scale factor should be above 2540 to allow importing files exported in inches
|
||||||
# Wx::GetNumberFromUser() does not support decimal numbers
|
$scale = $self->_get_number_from_user('Enter the scale % for the selected object:', 'Scale', 'Invalid scaling value entered', $model_instance->scaling_factor*100, 1);
|
||||||
$scale = Wx::GetTextFromUser("Enter the scale % for the selected object:", 'Scale',
|
return if $scale eq '';
|
||||||
$model_instance->scaling_factor*100, $self);
|
|
||||||
return if !$scale || $scale !~ /^\d*(?:\.\d*)?$/ || $scale < 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{list}->SetItem($obj_idx, 2, "$scale%");
|
$self->{list}->SetItem($obj_idx, 2, "$scale%");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue