Enable/disable duplication controls
This commit is contained in:
parent
e58ed195fd
commit
e5abb0b9df
4 changed files with 30 additions and 3 deletions
|
@ -139,6 +139,7 @@ our $skirt_height = 1; # layers
|
||||||
# transform options
|
# transform options
|
||||||
our $scale = 1;
|
our $scale = 1;
|
||||||
our $rotate = 0;
|
our $rotate = 0;
|
||||||
|
our $duplicate_mode = 'no';
|
||||||
our $duplicate = 1;
|
our $duplicate = 1;
|
||||||
our $bed_size = [200,200];
|
our $bed_size = [200,200];
|
||||||
our $duplicate_grid = [1,1];
|
our $duplicate_grid = [1,1];
|
||||||
|
|
|
@ -395,6 +395,13 @@ our $Options = {
|
||||||
cli => 'rotate=i',
|
cli => 'rotate=i',
|
||||||
type => 'i',
|
type => 'i',
|
||||||
},
|
},
|
||||||
|
'duplicate_mode' => {
|
||||||
|
label => 'Duplicate',
|
||||||
|
gui_only => 1,
|
||||||
|
type => 'select',
|
||||||
|
values => [qw(no autoarrange grid)],
|
||||||
|
labels => ['No', 'Autoarrange', 'Grid'],
|
||||||
|
},
|
||||||
'duplicate' => {
|
'duplicate' => {
|
||||||
label => 'Copies (autoarrange)',
|
label => 'Copies (autoarrange)',
|
||||||
cli => 'duplicate=i',
|
cli => 'duplicate=i',
|
||||||
|
@ -459,6 +466,7 @@ sub save {
|
||||||
open my $fh, '>', $file;
|
open my $fh, '>', $file;
|
||||||
binmode $fh, ':utf8';
|
binmode $fh, ':utf8';
|
||||||
foreach my $opt (sort keys %$Options) {
|
foreach my $opt (sort keys %$Options) {
|
||||||
|
next if $Options->{$opt}{gui_only};
|
||||||
my $value = get($opt);
|
my $value = get($opt);
|
||||||
$value = $Options->{$opt}{serialize}->($value) if $Options->{$opt}{serialize};
|
$value = $Options->{$opt}{serialize}->($value) if $Options->{$opt}{serialize};
|
||||||
printf $fh "%s = %s\n", $opt, $value;
|
printf $fh "%s = %s\n", $opt, $value;
|
||||||
|
@ -624,6 +632,8 @@ sub validate {
|
||||||
|| (grep !$_, @$Slic3r::duplicate_grid);
|
|| (grep !$_, @$Slic3r::duplicate_grid);
|
||||||
die "Use either --duplicate or --duplicate-grid (using both doesn't make sense)\n"
|
die "Use either --duplicate or --duplicate-grid (using both doesn't make sense)\n"
|
||||||
if $Slic3r::duplicate > 1 && $Slic3r::duplicate_grid && (grep $_ && $_ > 1, @$Slic3r::duplicate_grid);
|
if $Slic3r::duplicate > 1 && $Slic3r::duplicate_grid && (grep $_ && $_ > 1, @$Slic3r::duplicate_grid);
|
||||||
|
$Slic3r::duplicate_mode = 'autoarrange' if $Slic3r::duplicate > 1;
|
||||||
|
$Slic3r::duplicate_mode = 'grid' if grep $_ && $_ > 1, @$Slic3r::duplicate_grid;
|
||||||
|
|
||||||
# --duplicate-distance
|
# --duplicate-distance
|
||||||
die "Invalid value for --duplicate-distance\n"
|
die "Invalid value for --duplicate-distance\n"
|
||||||
|
|
|
@ -8,7 +8,8 @@ use base 'Wx::StaticBoxSizer';
|
||||||
|
|
||||||
|
|
||||||
# not very elegant, but this solution is temporary waiting for a better GUI
|
# not very elegant, but this solution is temporary waiting for a better GUI
|
||||||
our @reload_callbacks = ();
|
our @reload_callbacks = (\&update_duplicate_controls);
|
||||||
|
our %fields = (); # $key => [$control]
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
|
@ -77,9 +78,13 @@ sub new {
|
||||||
$x_field->SetValue($value->[0]);
|
$x_field->SetValue($value->[0]);
|
||||||
$y_field->SetValue($value->[1]);
|
$y_field->SetValue($value->[1]);
|
||||||
};
|
};
|
||||||
|
$fields{$opt_key} = [$x_field, $y_field];
|
||||||
} elsif ($opt->{type} eq 'select') {
|
} elsif ($opt->{type} eq 'select') {
|
||||||
$field = Wx::Choice->new($parent, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, $opt->{labels} || $opt->{values});
|
$field = Wx::Choice->new($parent, -1, Wx::wxDefaultPosition, Wx::wxDefaultSize, $opt->{labels} || $opt->{values});
|
||||||
EVT_CHOICE($parent, $field, sub { Slic3r::Config->set($opt_key, $opt->{values}[$field->GetSelection]) });
|
EVT_CHOICE($parent, $field, sub {
|
||||||
|
Slic3r::Config->set($opt_key, $opt->{values}[$field->GetSelection]);
|
||||||
|
update_duplicate_controls() if $opt_key eq 'duplicate_mode';
|
||||||
|
});
|
||||||
push @reload_callbacks, sub {
|
push @reload_callbacks, sub {
|
||||||
my $value = Slic3r::Config->get($opt_key);
|
my $value = Slic3r::Config->get($opt_key);
|
||||||
$field->SetSelection(grep $opt->{values}[$_] eq $value, 0..$#{$opt->{values}});
|
$field->SetSelection(grep $opt->{values}[$_] eq $value, 0..$#{$opt->{values}});
|
||||||
|
@ -89,6 +94,7 @@ sub new {
|
||||||
die "Unsupported option type: " . $opt->{type};
|
die "Unsupported option type: " . $opt->{type};
|
||||||
}
|
}
|
||||||
$grid_sizer->Add($_) for $label, $field;
|
$grid_sizer->Add($_) for $label, $field;
|
||||||
|
$fields{$opt_key} ||= [$field];
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->Add($grid_sizer, 0, wxEXPAND);
|
$self->Add($grid_sizer, 0, wxEXPAND);
|
||||||
|
@ -96,4 +102,12 @@ sub new {
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub update_duplicate_controls {
|
||||||
|
my $value = Slic3r::Config->get('duplicate_mode');
|
||||||
|
$_->Enable($value eq 'autoarrange') for @{$fields{duplicate}};
|
||||||
|
$_->Enable($value eq 'autoarrange') for @{$fields{bed_size}};
|
||||||
|
$_->Enable($value eq 'grid') for @{$fields{duplicate_grid}};
|
||||||
|
$_->Enable($value ne 'no') for @{$fields{duplicate_distance}};
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -61,7 +61,7 @@ sub new {
|
||||||
},
|
},
|
||||||
transform => {
|
transform => {
|
||||||
title => 'Transform',
|
title => 'Transform',
|
||||||
options => [qw(scale rotate duplicate bed_size duplicate_grid duplicate_distance)],
|
options => [qw(scale rotate duplicate_mode duplicate bed_size duplicate_grid duplicate_distance)],
|
||||||
},
|
},
|
||||||
gcode => {
|
gcode => {
|
||||||
title => 'Custom G-code',
|
title => 'Custom G-code',
|
||||||
|
@ -156,6 +156,8 @@ sub new {
|
||||||
$self->SetSizer($sizer);
|
$self->SetSizer($sizer);
|
||||||
$self->Layout;
|
$self->Layout;
|
||||||
|
|
||||||
|
$_->() for @Slic3r::GUI::OptionsGroup::reload_callbacks;
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue