From 8fe5d1162458093cb58f879b77367e5b23640730 Mon Sep 17 00:00:00 2001
From: Alessandro Ranellucci <aar@cpan.org>
Date: Sat, 19 May 2012 15:08:32 +0200
Subject: [PATCH] Set number of threads from GUI and save it in config files.
 #154

---
 lib/Slic3r/Config.pm         | 5 +++++
 lib/Slic3r/GUI/SkeinPanel.pm | 7 ++++++-
 slic3r.pl                    | 1 -
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm
index 3481bcb7b..d21b02bc5 100644
--- a/lib/Slic3r/Config.pm
+++ b/lib/Slic3r/Config.pm
@@ -21,6 +21,11 @@ our $Options = {
         serialize   => sub { join '\n', split /\R/, $_[0] },
         deserialize => sub { join "\n", split /\\n/, $_[0] },
     },
+    'threads' => {
+        label   => 'Threads (more speed, more memory usage)',
+        cli     => 'threads|j=i',
+        type    => 'i',
+    },
 
     # output options
     'output_filename_format' => {
diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm
index 29a104de9..919fcc63b 100644
--- a/lib/Slic3r/GUI/SkeinPanel.pm
+++ b/lib/Slic3r/GUI/SkeinPanel.pm
@@ -71,6 +71,10 @@ sub new {
             title => 'Output',
             options => [qw(output_filename_format duplicate_distance)],
         },
+        other => {
+            title => 'Other',
+            options => [$Slic3r::have_threads ? qw(threads) : ()],
+        },
         notes => {
             title => 'Notes',
             options => [qw(notes)],
@@ -95,6 +99,7 @@ sub new {
         foreach my $col (@cols) {
             my $vertical_sizer = Wx::BoxSizer->new(wxVERTICAL);
             for my $optgroup (@$col) {
+                next unless @{ $panels{$optgroup}{options} };
                 my $optpanel = Slic3r::GUI::OptionsGroup->new($tab, %{$panels{$optgroup}});
                 $vertical_sizer->Add($optpanel, 0, wxEXPAND | wxALL, 10);
             }
@@ -110,7 +115,7 @@ sub new {
         $make_tab->([qw(cooling)]),
         $make_tab->([qw(printer filament)], [qw(print_speed speed)]),
         $make_tab->([qw(gcode)]),
-        $make_tab->([qw(extrusion)], [qw(output)]),
+        $make_tab->([qw(extrusion other)], [qw(output)]),
     );
     
     $tabpanel->AddPage(Slic3r::GUI::Plater->new($tabpanel), "Plater");
diff --git a/slic3r.pl b/slic3r.pl
index 781d76a5b..61af30ff8 100755
--- a/slic3r.pl
+++ b/slic3r.pl
@@ -25,7 +25,6 @@ my %cli_options = ();
         'save=s'                => \$opt{save},
         'load=s@'               => \$opt{load},
         'ignore-nonexistent-config' => \$opt{ignore_nonexistent_config},
-        'threads|j=i'           => \$Slic3r::threads,
         'export-svg'            => \$opt{export_svg},
         'merge|m'               => \$opt{merge},
     );