New --no-plater and --gui-mode options. #604

internal-support
Alessandro Ranellucci 2013-03-09 16:43:09 +01:00
parent af50272b3b
commit 9247b3e9f4
5 changed files with 41 additions and 19 deletions

View File

@ -90,6 +90,9 @@ The author of the Silk icon set is Mark James.
-o, --output <file> File to output gcode to (by default, the file will be saved -o, --output <file> File to output gcode to (by default, the file will be saved
into the same directory as the input file using the into the same directory as the input file using the
--output-filename-format to generate the filename) --output-filename-format to generate the filename)
GUI options:
--no-plater Disable the plater tab
--gui-mode Overrides the configured mode (simple/expert)
Output options: Output options:
--output-filename-format --output-filename-format

View File

@ -39,6 +39,9 @@ use constant MI_WEBSITE => &Wx::NewId;
use constant MI_DOCUMENTATION => &Wx::NewId; use constant MI_DOCUMENTATION => &Wx::NewId;
our $datadir; our $datadir;
our $no_plater;
our $mode;
our $Settings = { our $Settings = {
_ => { _ => {
mode => 'simple', mode => 'simple',
@ -79,7 +82,10 @@ sub OnInit {
Wx::Image::AddHandler(Wx::PNGHandler->new); Wx::Image::AddHandler(Wx::PNGHandler->new);
my $frame = Wx::Frame->new(undef, -1, 'Slic3r', wxDefaultPosition, [760, 470], wxDEFAULT_FRAME_STYLE); my $frame = Wx::Frame->new(undef, -1, 'Slic3r', wxDefaultPosition, [760, 470], wxDEFAULT_FRAME_STYLE);
$frame->SetIcon(Wx::Icon->new("$Slic3r::var/Slic3r_128px.png", wxBITMAP_TYPE_PNG) ); $frame->SetIcon(Wx::Icon->new("$Slic3r::var/Slic3r_128px.png", wxBITMAP_TYPE_PNG) );
$self->{skeinpanel} = Slic3r::GUI::SkeinPanel->new($frame, mode => $Settings->{_}{mode}); $self->{skeinpanel} = Slic3r::GUI::SkeinPanel->new($frame,
mode => $mode // $Settings->{_}{mode},
no_plater => $no_plater,
);
$self->SetTopWindow($frame); $self->SetTopWindow($frame);
# status bar # status bar

View File

@ -28,9 +28,11 @@ sub new {
my ($parent, %params) = @_; my ($parent, %params) = @_;
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
$self->{mode} = $params{mode}; $self->{mode} = $params{mode};
$self->{mode} = 'expert' if $self->{mode} !~ /^(?:simple|expert)$/;
$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->{plater} = Slic3r::GUI::Plater->new($self->{tabpanel}), "Plater"); $self->{tabpanel}->AddPage($self->{plater} = Slic3r::GUI::Plater->new($self->{tabpanel}), "Plater")
unless $params{no_plater};
$self->{options_tabs} = {}; $self->{options_tabs} = {};
my $simple_config; my $simple_config;
@ -44,17 +46,19 @@ sub new {
for my $tab_name (qw(print filament printer)) { for my $tab_name (qw(print filament printer)) {
my $tab = $self->{options_tabs}{$tab_name} = ($class_prefix . ucfirst $tab_name)->new( my $tab = $self->{options_tabs}{$tab_name} = ($class_prefix . ucfirst $tab_name)->new(
$self->{tabpanel}, $self->{tabpanel},
plater => $self->{plater},
on_value_change => sub { on_value_change => sub {
$self->{plater}->on_config_change(@_); # propagate config change events to the plater $self->{plater}->on_config_change(@_) if $self->{plater}; # propagate config change events to the plater
if ($self->{mode} eq 'simple' && $init) { # don't save while loading for the first time if ($self->{mode} eq 'simple' && $init) { # don't save while loading for the first time
# save config # save config
$self->config->save("$Slic3r::GUI::datadir/simple.ini"); $self->config->save("$Slic3r::GUI::datadir/simple.ini");
} }
}, },
on_presets_changed => sub {
$self->{plater}->update_presets($tab_name, @_) if $self->{plater};
},
); );
$self->{tabpanel}->AddPage($tab, $tab->title); $self->{tabpanel}->AddPage($tab, $tab->title);
$tab->load_config($simple_config); $tab->load_config($simple_config) if $simple_config;
} }
$init = 1; $init = 1;

View File

@ -14,7 +14,7 @@ sub new {
my ($parent, %params) = @_; my ($parent, %params) = @_;
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL); my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
$self->{options} = []; # array of option names handled by this tab $self->{options} = []; # array of option names handled by this tab
$self->{$_} = $params{$_} for qw(plater on_value_change); $self->{$_} = $params{$_} for qw(on_value_change on_presets_changed);
# horizontal sizer # horizontal sizer
$self->{sizer} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{sizer} = Wx::BoxSizer->new(wxHORIZONTAL);
@ -81,7 +81,7 @@ sub new {
EVT_CHOICE($parent, $self->{presets_choice}, sub { EVT_CHOICE($parent, $self->{presets_choice}, sub {
$self->on_select_preset; $self->on_select_preset;
$self->sync_presets; $self->on_presets_changed;
}); });
EVT_BUTTON($self, $self->{btn_save_preset}, sub { EVT_BUTTON($self, $self->{btn_save_preset}, sub {
@ -108,7 +108,7 @@ sub new {
$self->load_presets; $self->load_presets;
$self->{presets_choice}->SetSelection(first { basename($self->{presets}[$_]{file}) eq $dlg->get_name . ".ini" } 1 .. $#{$self->{presets}}); $self->{presets_choice}->SetSelection(first { basename($self->{presets}[$_]{file}) eq $dlg->get_name . ".ini" } 1 .. $#{$self->{presets}});
$self->on_select_preset; $self->on_select_preset;
$self->sync_presets; $self->on_presets_changed;
}); });
EVT_BUTTON($self, $self->{btn_delete_preset}, sub { EVT_BUTTON($self, $self->{btn_delete_preset}, sub {
@ -124,7 +124,7 @@ sub new {
$self->{presets_choice}->Delete($i); $self->{presets_choice}->Delete($i);
$self->{presets_choice}->SetSelection(0); $self->{presets_choice}->SetSelection(0);
$self->on_select_preset; $self->on_select_preset;
$self->sync_presets; $self->on_presets_changed;
}); });
$self->{config} = Slic3r::Config->new; $self->{config} = Slic3r::Config->new;
@ -154,6 +154,12 @@ sub on_value_change {
$self->{on_value_change}->(@_) if $self->{on_value_change}; $self->{on_value_change}->(@_) if $self->{on_value_change};
} }
sub on_presets_changed {
my $self = shift;
$self->{on_presets_changed}->([$self->{presets_choice}->GetStrings], $self->{presets_choice}->GetSelection)
if $self->{on_presets_changed};
}
sub on_preset_loaded {} sub on_preset_loaded {}
sub hidden_options {} sub hidden_options {}
sub config { $_[0]->{config}->clone } sub config { $_[0]->{config}->clone }
@ -252,7 +258,7 @@ sub add_options_page {
my $page = Slic3r::GUI::Tab::Page->new($self, $title, $self->{iconcount}, %params, on_change => sub { my $page = Slic3r::GUI::Tab::Page->new($self, $title, $self->{iconcount}, %params, on_change => sub {
$self->on_value_change(@_); $self->on_value_change(@_);
$self->set_dirty(1); $self->set_dirty(1);
$self->sync_presets; $self->on_presets_changed;
}); });
$page->Hide; $page->Hide;
$self->{sizer}->Add($page, 1, wxEXPAND | wxLEFT, 5); $self->{sizer}->Add($page, 1, wxEXPAND | wxLEFT, 5);
@ -312,7 +318,7 @@ sub set_dirty {
$self->{presets_choice}->SetString($i, $text); $self->{presets_choice}->SetString($i, $text);
$self->{presets_choice}->SetSelection($selection); # http://trac.wxwidgets.org/ticket/13769 $self->{presets_choice}->SetSelection($selection); # http://trac.wxwidgets.org/ticket/13769
} }
$self->sync_presets; $self->on_presets_changed;
} }
sub is_dirty { sub is_dirty {
@ -347,7 +353,7 @@ sub load_presets {
$self->{presets_choice}->SetSelection($i || 0); $self->{presets_choice}->SetSelection($i || 0);
$self->on_select_preset; $self->on_select_preset;
} }
$self->sync_presets; $self->on_presets_changed;
} }
sub load_config_file { sub load_config_file {
@ -368,12 +374,7 @@ sub load_config_file {
} }
$self->{presets_choice}->SetSelection($i); $self->{presets_choice}->SetSelection($i);
$self->on_select_preset; $self->on_select_preset;
$self->sync_presets; $self->on_presets_changed;
}
sub sync_presets {
my $self = shift;
$self->{plater}->update_presets($self->name, [$self->{presets_choice}->GetStrings], $self->{presets_choice}->GetSelection);
} }
package Slic3r::GUI::Tab::Print; package Slic3r::GUI::Tab::Print;

View File

@ -27,6 +27,8 @@ my %cli_options = ();
'save=s' => \$opt{save}, 'save=s' => \$opt{save},
'load=s@' => \$opt{load}, 'load=s@' => \$opt{load},
'ignore-nonexistent-config' => \$opt{ignore_nonexistent_config}, 'ignore-nonexistent-config' => \$opt{ignore_nonexistent_config},
'no-plater' => \$opt{no_plater},
'gui-mode=s' => \$opt{gui_mode},
'datadir=s' => \$opt{datadir}, 'datadir=s' => \$opt{datadir},
'export-svg' => \$opt{export_svg}, 'export-svg' => \$opt{export_svg},
'merge|m' => \$opt{merge}, 'merge|m' => \$opt{merge},
@ -73,7 +75,9 @@ my $gui;
if (!@ARGV && !$opt{save} && eval "require Slic3r::GUI; 1") { if (!@ARGV && !$opt{save} && eval "require Slic3r::GUI; 1") {
{ {
no warnings 'once'; no warnings 'once';
$Slic3r::GUI::datadir = $opt{datadir} if $opt{datadir}; $Slic3r::GUI::datadir = $opt{datadir};
$Slic3r::GUI::no_plater = $opt{no_plater};
$Slic3r::GUI::mode = $opt{gui_mode};
} }
$gui = Slic3r::GUI->new; $gui = Slic3r::GUI->new;
$gui->{skeinpanel}->load_config_file($_) for @{$opt{load}}; $gui->{skeinpanel}->load_config_file($_) for @{$opt{load}};
@ -139,6 +143,10 @@ Usage: slic3r.pl [ OPTIONS ] file.stl
into the same directory as the input file using the into the same directory as the input file using the
--output-filename-format to generate the filename) --output-filename-format to generate the filename)
$j $j
GUI options:
--no-plater Disable the plater tab
--gui-mode Overrides the configured mode (simple/expert)
Output options: Output options:
--output-filename-format --output-filename-format
Output file name format; all config options enclosed in brackets Output file name format; all config options enclosed in brackets