Browse Source

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

Alessandro Ranellucci 12 years ago
parent
commit
9247b3e9f4
5 changed files with 41 additions and 19 deletions
  1. 3 0
      README.markdown
  2. 7 1
      lib/Slic3r/GUI.pm
  3. 8 4
      lib/Slic3r/GUI/SkeinPanel.pm
  4. 14 13
      lib/Slic3r/GUI/Tab.pm
  5. 9 1
      slic3r.pl

+ 3 - 0
README.markdown

@@ -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
                             into the same directory as the input file using the 
                             --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-filename-format

+ 7 - 1
lib/Slic3r/GUI.pm

@@ -39,6 +39,9 @@ use constant MI_WEBSITE       => &Wx::NewId;
 use constant MI_DOCUMENTATION => &Wx::NewId;
 
 our $datadir;
+our $no_plater;
+our $mode;
+
 our $Settings = {
     _ => {
         mode => 'simple',
@@ -79,7 +82,10 @@ sub OnInit {
     Wx::Image::AddHandler(Wx::PNGHandler->new);
     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) );
-    $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);
     
     # status bar

+ 8 - 4
lib/Slic3r/GUI/SkeinPanel.pm

@@ -28,9 +28,11 @@ sub new {
     my ($parent, %params) = @_;
     my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
     $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}->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} = {};
     
     my $simple_config;
@@ -44,17 +46,19 @@ sub new {
     for my $tab_name (qw(print filament printer)) {
         my $tab = $self->{options_tabs}{$tab_name} = ($class_prefix . ucfirst $tab_name)->new(
             $self->{tabpanel},
-            plater              => $self->{plater},
             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
                     # save config
                     $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);
-        $tab->load_config($simple_config);
+        $tab->load_config($simple_config) if $simple_config;
     }
     $init = 1;
     

+ 14 - 13
lib/Slic3r/GUI/Tab.pm

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

+ 9 - 1
slic3r.pl

@@ -27,6 +27,8 @@ my %cli_options = ();
         'save=s'                => \$opt{save},
         'load=s@'               => \$opt{load},
         'ignore-nonexistent-config' => \$opt{ignore_nonexistent_config},
+        'no-plater'             => \$opt{no_plater},
+        'gui-mode=s'            => \$opt{gui_mode},
         'datadir=s'             => \$opt{datadir},
         'export-svg'            => \$opt{export_svg},
         'merge|m'               => \$opt{merge},
@@ -73,7 +75,9 @@ my $gui;
 if (!@ARGV && !$opt{save} && eval "require Slic3r::GUI; 1") {
     {
         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->{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 
                         --output-filename-format to generate the filename)
 $j
+  GUI options:
+    --no-plater         Disable the plater tab
+    --gui-mode          Overrides the configured mode (simple/expert)
+
   Output options:
     --output-filename-format
                         Output file name format; all config options enclosed in brackets