From de3347c825198ffd4f13a81e63b052e77c928b4e Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Tue, 26 Jun 2012 17:42:29 +0200 Subject: [PATCH 01/22] Add initial configuration wizard --- lib/Slic3r/GUI.pm | 3 + lib/Slic3r/GUI/ConfigWizard.pm | 359 +++++++++++++++++++++++++++++++++ lib/Slic3r/GUI/SkeinPanel.pm | 9 + 3 files changed, 371 insertions(+) create mode 100644 lib/Slic3r/GUI/ConfigWizard.pm diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 3aa776048..b59b5a405 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -4,6 +4,7 @@ use warnings; use utf8; use FindBin; +use Slic3r::GUI::ConfigWizard; use Slic3r::GUI::Plater; use Slic3r::GUI::OptionsGroup; use Slic3r::GUI::SkeinPanel; @@ -83,7 +84,9 @@ sub OnInit { # Help menu my $helpMenu = Wx::Menu->new; { + $helpMenu->Append(7, "Configuration Wizard…"); $helpMenu->Append(wxID_ABOUT, "&About Slic3r"); + EVT_MENU($frame, 7, sub { $frame->{skeinpanel}->config_wizard }); EVT_MENU($frame, wxID_ABOUT, \&about); } diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm new file mode 100644 index 000000000..4db58edd0 --- /dev/null +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -0,0 +1,359 @@ +package Slic3r::GUI::ConfigWizard; +use strict; +use warnings; +use utf8; + +use Wx qw(:sizer :progressdialog); +use base 'Wx::Wizard'; + +sub new { + my $class = shift; + my ($parent) = @_; + # TODO: Add instructional bitmaps + my $self = $class->SUPER::new($parent, -1, 'Configuration Wizard', + Wx::Bitmap->new("$Slic3r::var/slic3r_128px.png", &Wx::wxBITMAP_TYPE_PNG)); + + $self->add_page(Slic3r::GUI::ConfigWizard::Page::Welcome->new($self)); + $self->add_page(Slic3r::GUI::ConfigWizard::Page::Firmware->new($self)); + $self->add_page(Slic3r::GUI::ConfigWizard::Page::Bed->new($self)); + $self->add_page(Slic3r::GUI::ConfigWizard::Page::Cooling->new($self)); + $self->add_page(Slic3r::GUI::ConfigWizard::Page::Filament->new($self)); + $self->add_page(Slic3r::GUI::ConfigWizard::Page::Temperature->new($self)); + $self->add_page(Slic3r::GUI::ConfigWizard::Page::BedTemperature->new($self)); + $self->add_page(Slic3r::GUI::ConfigWizard::Page::Finished->new($self)); + + return $self; +} + +sub add_page { + my $self = shift; + my ($page) = @_; + + my $n = push @{$self->{pages}}, $page; + # add first page to the page area sizer + $self->GetPageAreaSizer->Add($page) if $n == 1; + # link pages + $self->{pages}[$n-2]->set_next_page($page) if $n >= 2; + $page->set_previous_page($self->{pages}[$n-2]) if $n >= 2; +} + +sub run { + my $self = shift; + + my $finished = Wx::Wizard::RunWizard($self, $self->{pages}[0]); + if ($finished) { + $_->apply for @{$self->{pages}}; + } + $self->Destroy; + + return $finished; +} + +package Slic3r::GUI::ConfigWizard::Option; +use Wx qw(:sizer :progressdialog); +use Wx::Event qw(EVT_SPINCTRL EVT_TEXT EVT_CHECKBOX EVT_COMBOBOX); +use base 'Wx::StaticBoxSizer'; + +sub new { + my $class = shift; + my ($parent, %params) = @_; + my $box = Wx::StaticBox->new($parent, -1, ''); + my $self = $class->SUPER::new($box, &Wx::wxHORIZONTAL); + + my $label_width = 200; + + my $opt_key = $params{option}; + my $opt = $Slic3r::Config::Options->{$opt_key}; + + my $callback = $params{callback} || sub {}; + + # label + my $label = Wx::StaticText->new($parent, -1, "$opt->{label}:", &Wx::wxDefaultPosition, [$label_width, -1]); + $label->Wrap($label_width); + $self->Add($label, 1, &Wx::wxEXPAND); + + # input field(s) and unit + my $field; + if ($opt->{type} =~ /^(i|f|s|s@)$/) { + my $style = $opt->{multiline} ? &Wx::wxTE_MULTILINE : 0; + my $size = Wx::Size->new($opt->{width} || -1, $opt->{height} || -1); + + my ($get, $set) = $opt->{type} eq 's@' ? qw(serialize deserialize) : qw(get_raw set); + + if ($opt->{type} eq 'i') { + my $value = Slic3r::Config->$get($opt_key); + $field = Wx::SpinCtrl->new($parent, -1, $value, &Wx::wxDefaultPosition, $size, $style, $opt->{min} || 0, $opt->{max} || 100, $value); + EVT_SPINCTRL($parent, $field, sub { $callback->($opt_key, $field->GetValue) }); + } else { + $field = Wx::TextCtrl->new($parent, -1, Slic3r::Config->$get($opt_key), Wx::wxDefaultPosition, $size, $style); + EVT_TEXT($parent, $field, sub { $callback->($opt_key, $field->GetValue) }); + } + } elsif ($opt->{type} eq 'bool') { + $field = Wx::CheckBox->new($parent, -1, ''); + $field->SetValue(Slic3r::Config->get_raw($opt_key)); + EVT_CHECKBOX($parent, $field, sub { $callback->($opt_key, $field->GetValue) }); + } elsif ($opt->{type} eq 'point') { + $field = Wx::BoxSizer->new(&Wx::wxHORIZONTAL); + my $field_size = Wx::Size->new(40, -1); + my $value = Slic3r::Config->get_raw($opt_key); + my @items = ( + Wx::StaticText->new($parent, -1, 'x:'), + my $x_field = Wx::TextCtrl->new($parent, -1, $value->[0], &Wx::wxDefaultPosition, $field_size), + Wx::StaticText->new($parent, -1, ' y:'), + my $y_field = Wx::TextCtrl->new($parent, -1, $value->[1], &Wx::wxDefaultPosition, $field_size), + ); + $field->Add($_) for @items; + EVT_TEXT($parent, $x_field, sub { $callback->($opt_key, [$x_field->GetValue, $y_field->GetValue]) }); + EVT_TEXT($parent, $y_field, sub { $callback->($opt_key, [$x_field->GetValue, $y_field->GetValue]) }); + } elsif ($opt->{type} eq 'select') { + $field = Wx::ComboBox->new($parent, -1, '', &Wx::wxDefaultPosition, &Wx::wxDefaultSize, $opt->{labels} || $opt->{values}, &Wx::wxCB_READONLY); + my $value = Slic3r::Config->get_raw($opt_key); + $field->SetSelection(grep $opt->{values}[$_] eq $value, 0..$#{$opt->{values}}); + EVT_COMBOBOX($parent, $field, sub { $callback->($opt_key, $opt->{values}[$field->GetSelection]) }); + } else { + die 'Unsupported option type: ' . $opt->{type}; + } + if ($opt->{sidetext}) { + my $sizer = Wx::BoxSizer->new(&Wx::wxHORIZONTAL); + $sizer->Add($field); + my $sidetext = Wx::StaticText->new($parent, -1, $opt->{sidetext}, &Wx::wxDefaultPosition, [-1, -1]); + $sizer->Add($sidetext, 0, &Wx::wxLEFT | &Wx::wxALIGN_CENTER_VERTICAL, 4); + $self->Add($sizer); + } else { + $self->Add($field, 0, $opt->{full_width} ? &Wx::wxEXPAND : 0); + } + + return $self; +} + +package Slic3r::GUI::ConfigWizard::Page; +use Wx qw(:sizer :progressdialog); +use Wx::Event qw(); +use base 'Wx::WizardPage'; + +sub new { + my $class = shift; + my ($parent, $title) = @_; + my $self = $class->SUPER::new($parent); + + $self->{width} = 400; + $self->{vsizer} = Wx::BoxSizer->new(&Wx::wxVERTICAL); + $self->SetSizer($self->{vsizer}); + + # title + my $text = Wx::StaticText->new($self, -1, $title, &Wx::wxDefaultPosition, &Wx::wxDefaultSize, &Wx::wxALIGN_LEFT); + my $bold_font = Wx::SystemSettings::GetFont(&Wx::wxSYS_DEFAULT_GUI_FONT); + $bold_font->SetWeight(&Wx::wxFONTWEIGHT_BOLD); + $bold_font->SetPointSize(14); + $text->SetFont($bold_font); + $self->{vsizer}->Add($text, 0, &Wx::wxALIGN_LEFT | &Wx::wxALL, 10); + + return $self; +} + +sub append_text { + my $self = shift; + my ($text) = @_; + + my $para = Wx::StaticText->new($self, -1, $text, &Wx::wxDefaultPosition, &Wx::wxDefaultSize, &Wx::wxALIGN_LEFT); + $para->Wrap($self->{width}); + $self->{vsizer}->Add($para, 0, &Wx::wxALIGN_LEFT | &Wx::wxALL, 10); +} + +sub append_option { + my $self = shift; + my ($opt_key) = @_; + + my $option = Slic3r::GUI::ConfigWizard::Option->new($self, option => $opt_key, + callback => sub { + my ($opt_key, $value) = @_; + $self->{options}->{$opt_key} = $value; + }); + $self->{vsizer}->Add($option, 0, &Wx::wxEXPAND | &Wx::wxALL, 10); +} + +sub apply { + my $self = shift; + Slic3r::Config->set($_, $self->{options}->{$_}) foreach (keys %{$self->{options}}); +} + +sub set_previous_page { + my $self = shift; + my ($previous_page) = @_; + $self->{previous_page} = $previous_page; +} + +sub GetPrev { + my $self = shift; + return $self->{previous_page}; +} + +sub set_next_page { + my $self = shift; + my ($next_page) = @_; + $self->{next_page} = $next_page; +} + +sub GetNext { + my $self = shift; + return $self->{next_page}; +} + +package Slic3r::GUI::ConfigWizard::Page::Welcome; +use Wx qw(:sizer :progressdialog); +use Wx::Event qw(); +use base 'Slic3r::GUI::ConfigWizard::Page'; + +sub new { + my $class = shift; + my ($parent) = @_; + my $self = $class->SUPER::new($parent, 'Welcome'); + + $self->append_text('This configuration wizard will guide you through the most important settings of Slic3r in a few easy steps. ' . + 'Configuration will be based on your current configuration.'); + + return $self; +} + +package Slic3r::GUI::ConfigWizard::Page::Firmware; +use Wx qw(:sizer :progressdialog); +use Wx::Event qw(); +use base 'Slic3r::GUI::ConfigWizard::Page'; + +sub new { + my $class = shift; + my ($parent) = @_; + my $self = $class->SUPER::new($parent, 'Firmware Type'); + + $self->append_text('Choose the type of firmware used by your printer below.'); + $self->append_option('gcode_flavor'); + + return $self; +} + +package Slic3r::GUI::ConfigWizard::Page::Bed; +use Wx qw(:sizer :progressdialog); +use Wx::Event qw(); +use base 'Slic3r::GUI::ConfigWizard::Page'; + +sub new { + my $class = shift; + my ($parent) = @_; + my $self = $class->SUPER::new($parent, 'Bed Size'); + + $self->append_text('Enter the size of your printers bed below.'); + $self->append_option('bed_size'); + + return $self; +} + +sub apply { + my $self = shift; + $self->SUPER::apply; + + # set print_center to centre of bed_size + my $bed_size = Slic3r::Config->get_raw('bed_size'); + Slic3r::Config->set('print_center', [$bed_size->[0]/2, $bed_size->[1]/2]); +} + +package Slic3r::GUI::ConfigWizard::Page::Cooling; +use Wx qw(:sizer :progressdialog); +use Wx::Event qw(); +use base 'Slic3r::GUI::ConfigWizard::Page'; + +sub new { + my $class = shift; + my ($parent) = @_; + my $self = $class->SUPER::new($parent, 'Fan'); + + $self->append_text('If your printer has a fan for cooling the printed object, check the box below.'); + $self->append_option('cooling'); + + return $self; +} + +package Slic3r::GUI::ConfigWizard::Page::Filament; +use Wx qw(:sizer :progressdialog); +use Wx::Event qw(); +use base 'Slic3r::GUI::ConfigWizard::Page'; + +sub new { + my $class = shift; + my ($parent) = @_; + my $self = $class->SUPER::new($parent, 'Filament Diameter'); + + $self->append_text('Enter your filament diameter below. ' . + 'Good precision is required, so use a caliper and do multiple measurements along the filament, then compute the average.'); + $self->append_option('filament_diameter'); + + return $self; +} + +package Slic3r::GUI::ConfigWizard::Page::Temperature; +use Wx qw(:sizer :progressdialog); +use Wx::Event qw(); +use base 'Slic3r::GUI::ConfigWizard::Page'; + +sub new { + my $class = shift; + my ($parent) = @_; + my $self = $class->SUPER::new($parent, 'Extrusion Temperature'); + + $self->append_text('Enter the temperature needed for extruding your filament below. ' . + 'A rule of thumb is 160 to 230 °C for PLA and 215 to 250 °C for ABS. '); + $self->append_option('temperature'); + + return $self; +} + +sub apply { + my $self = shift; + $self->SUPER::apply; + + # set first_layer_temperature to temperature + 5 + my $temperature = Slic3r::Config->get_raw('temperature'); + Slic3r::Config->set('first_layer_temperature', $temperature + 5); +} + +package Slic3r::GUI::ConfigWizard::Page::BedTemperature; +use Wx qw(:sizer :progressdialog); +use Wx::Event qw(); +use base 'Slic3r::GUI::ConfigWizard::Page'; + +sub new { + my $class = shift; + my ($parent) = @_; + my $self = $class->SUPER::new($parent, 'Bed Temperature'); + + $self->append_text('Enter the bed temperature needed for getting your filament to stick to your heated bed below. ' . + 'A rule of thumb is 60 °C for PLA and 110 °C for ABS.'); + $self->append_option('bed_temperature'); + + return $self; +} + +sub apply { + my $self = shift; + $self->SUPER::apply; + + # set first_layer_bed_temperature to temperature + 5 + my $temperature = Slic3r::Config->get_raw('bed_temperature'); + Slic3r::Config->set('first_layer_bed_temperature', $temperature + 5); +} + +package Slic3r::GUI::ConfigWizard::Page::Finished; +use Wx qw(:sizer :progressdialog); +use Wx::Event qw(); +use base 'Slic3r::GUI::ConfigWizard::Page'; + +sub new { + my $class = shift; + my ($parent) = @_; + my $self = $class->SUPER::new($parent, 'Congratulations!'); + + $self->append_text('Slic3r is now configured for your particular printer and filament.'); + + return $self; +} + +1; diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 907e9c0d9..fc7d0fa81 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -223,6 +223,15 @@ sub load_config { $dlg->Destroy; } +sub config_wizard { + my $self = shift; + + if (Slic3r::GUI::ConfigWizard->new($self)->run) { + $_->() for values %Slic3r::GUI::OptionsGroup::reload_callbacks; + $_->set_dirty(1) for values %{$self->{options_tabs}}; + } +} + sub on_close { my $self = shift; From 373b341280578717950eb9f0ae9bc1815641050a Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Tue, 26 Jun 2012 22:47:10 +0200 Subject: [PATCH 02/22] Remove cooling option from wizard --- lib/Slic3r/GUI/ConfigWizard.pm | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index 4db58edd0..4c24b8bbb 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -16,7 +16,6 @@ sub new { $self->add_page(Slic3r::GUI::ConfigWizard::Page::Welcome->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Firmware->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Bed->new($self)); - $self->add_page(Slic3r::GUI::ConfigWizard::Page::Cooling->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Filament->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Temperature->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::BedTemperature->new($self)); @@ -256,22 +255,6 @@ sub apply { Slic3r::Config->set('print_center', [$bed_size->[0]/2, $bed_size->[1]/2]); } -package Slic3r::GUI::ConfigWizard::Page::Cooling; -use Wx qw(:sizer :progressdialog); -use Wx::Event qw(); -use base 'Slic3r::GUI::ConfigWizard::Page'; - -sub new { - my $class = shift; - my ($parent) = @_; - my $self = $class->SUPER::new($parent, 'Fan'); - - $self->append_text('If your printer has a fan for cooling the printed object, check the box below.'); - $self->append_option('cooling'); - - return $self; -} - package Slic3r::GUI::ConfigWizard::Page::Filament; use Wx qw(:sizer :progressdialog); use Wx::Event qw(); From 406e31a20dc6e5100c710f3c6cbad05a25a1663f Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Tue, 26 Jun 2012 22:47:58 +0200 Subject: [PATCH 03/22] Fix icon file name --- lib/Slic3r/GUI/ConfigWizard.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index 4c24b8bbb..724367f4e 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -11,7 +11,7 @@ sub new { my ($parent) = @_; # TODO: Add instructional bitmaps my $self = $class->SUPER::new($parent, -1, 'Configuration Wizard', - Wx::Bitmap->new("$Slic3r::var/slic3r_128px.png", &Wx::wxBITMAP_TYPE_PNG)); + Wx::Bitmap->new("$Slic3r::var/Slic3r_128px.png", &Wx::wxBITMAP_TYPE_PNG)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Welcome->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Firmware->new($self)); From cd48dc403109f11c9f4b556c9a98649909db3e36 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Wed, 27 Jun 2012 17:59:29 +0200 Subject: [PATCH 04/22] - Add nozzle_diameter to Configuration Wizard - Automatically set layer_height to (nozzle_diameter - 0.1) --- lib/Slic3r/GUI/ConfigWizard.pm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index 724367f4e..e6be8c7a9 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -16,6 +16,7 @@ sub new { $self->add_page(Slic3r::GUI::ConfigWizard::Page::Welcome->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Firmware->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Bed->new($self)); + $self->add_page(Slic3r::GUI::ConfigWizard::Page::Nozzle->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Filament->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Temperature->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::BedTemperature->new($self)); @@ -255,6 +256,31 @@ sub apply { Slic3r::Config->set('print_center', [$bed_size->[0]/2, $bed_size->[1]/2]); } +package Slic3r::GUI::ConfigWizard::Page::Nozzle; +use Wx qw(:sizer :progressdialog); +use Wx::Event qw(); +use base 'Slic3r::GUI::ConfigWizard::Page'; + +sub new { + my $class = shift; + my ($parent) = @_; + my $self = $class->SUPER::new($parent, 'Nozzle Diameter'); + + $self->append_text('Enter the diameter of your printers hot end nozzle below.'); + $self->append_option('nozzle_diameter'); + + return $self; +} + +sub apply { + my $self = shift; + $self->SUPER::apply; + + # set layer_height to nozzle_diameter - 0.1 + my $nozzle = Slic3r::Config->get_raw('nozzle_diameter'); + Slic3r::Config->set('layer_height', $nozzle - 0.1); +} + package Slic3r::GUI::ConfigWizard::Page::Filament; use Wx qw(:sizer :progressdialog); use Wx::Event qw(); From 52872753dfa587eada47eb0bbe1f1defe1b3e167 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Wed, 27 Jun 2012 19:41:37 +0200 Subject: [PATCH 05/22] Minor changes to text and layout to look more like other wizards --- lib/Slic3r/GUI/ConfigWizard.pm | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index e6be8c7a9..a4e953233 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -147,6 +147,8 @@ sub new { $bold_font->SetPointSize(14); $text->SetFont($bold_font); $self->{vsizer}->Add($text, 0, &Wx::wxALIGN_LEFT | &Wx::wxALL, 10); + my $line = Wx::StaticLine->new($self, -1, &Wx::wxDefaultPosition, &Wx::wxDefaultSize, &Wx::wxLI_HORIZONTAL, ''); + $self->{vsizer}->Add($line, 0, &Wx::wxEXPAND| &Wx::wxALL, 10); return $self; } @@ -207,10 +209,11 @@ use base 'Slic3r::GUI::ConfigWizard::Page'; sub new { my $class = shift; my ($parent) = @_; - my $self = $class->SUPER::new($parent, 'Welcome'); + my $self = $class->SUPER::new($parent, 'Welcome to the Slic3r Configuration Wizard'); $self->append_text('This configuration wizard will guide you through the most important settings of Slic3r in a few easy steps. ' . 'Configuration will be based on your current configuration.'); + $self->append_text('To continue, click Next.'); return $self; } @@ -225,7 +228,7 @@ sub new { my ($parent) = @_; my $self = $class->SUPER::new($parent, 'Firmware Type'); - $self->append_text('Choose the type of firmware used by your printer below.'); + $self->append_text('Choose the type of firmware used by your printer, then click Next.'); $self->append_option('gcode_flavor'); return $self; @@ -241,7 +244,7 @@ sub new { my ($parent) = @_; my $self = $class->SUPER::new($parent, 'Bed Size'); - $self->append_text('Enter the size of your printers bed below.'); + $self->append_text('Enter the size of your printers bed, then click Next.'); $self->append_option('bed_size'); return $self; @@ -266,7 +269,7 @@ sub new { my ($parent) = @_; my $self = $class->SUPER::new($parent, 'Nozzle Diameter'); - $self->append_text('Enter the diameter of your printers hot end nozzle below.'); + $self->append_text('Enter the diameter of your printers hot end nozzle, then click Next.'); $self->append_option('nozzle_diameter'); return $self; @@ -291,8 +294,8 @@ sub new { my ($parent) = @_; my $self = $class->SUPER::new($parent, 'Filament Diameter'); - $self->append_text('Enter your filament diameter below. ' . - 'Good precision is required, so use a caliper and do multiple measurements along the filament, then compute the average.'); + $self->append_text('Enter the diameter of your filament, then click Next.'); + $self->append_text('Good precision is required, so use a caliper and do multiple measurements along the filament, then compute the average.'); $self->append_option('filament_diameter'); return $self; @@ -308,8 +311,8 @@ sub new { my ($parent) = @_; my $self = $class->SUPER::new($parent, 'Extrusion Temperature'); - $self->append_text('Enter the temperature needed for extruding your filament below. ' . - 'A rule of thumb is 160 to 230 °C for PLA and 215 to 250 °C for ABS. '); + $self->append_text('Enter the temperature needed for extruding your filament, then click Next.'); + $self->append_text('A rule of thumb is 160 to 230 °C for PLA and 215 to 250 °C for ABS.'); $self->append_option('temperature'); return $self; @@ -334,8 +337,8 @@ sub new { my ($parent) = @_; my $self = $class->SUPER::new($parent, 'Bed Temperature'); - $self->append_text('Enter the bed temperature needed for getting your filament to stick to your heated bed below. ' . - 'A rule of thumb is 60 °C for PLA and 110 °C for ABS.'); + $self->append_text('Enter the bed temperature needed for getting your filament to stick to your heated bed, then click Next.'); + $self->append_text('A rule of thumb is 60 °C for PLA and 110 °C for ABS.'); $self->append_option('bed_temperature'); return $self; @@ -361,6 +364,7 @@ sub new { my $self = $class->SUPER::new($parent, 'Congratulations!'); $self->append_text('Slic3r is now configured for your particular printer and filament.'); + $self->append_text('Click Finish to apply the newly created configuration and close this wizard.'); return $self; } From dbc42f68418cb6d7ca41f10401ac469f402d8ec9 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Wed, 27 Jun 2012 19:56:47 +0200 Subject: [PATCH 06/22] Make it more clear that the wizard uses your current configuration as basis --- lib/Slic3r/GUI/ConfigWizard.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index a4e953233..6f55347b3 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -211,8 +211,8 @@ sub new { my ($parent) = @_; my $self = $class->SUPER::new($parent, 'Welcome to the Slic3r Configuration Wizard'); - $self->append_text('This configuration wizard will guide you through the most important settings of Slic3r in a few easy steps. ' . - 'Configuration will be based on your current configuration.'); + $self->append_text('This configuration wizard will guide you through the most important settings of Slic3r in a few easy steps.'); + $self->append_text('Configuration will be based on your current configuration.'); $self->append_text('To continue, click Next.'); return $self; From 145b9076cc59ea00c9880792e14a3e37f0d6f47b Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Wed, 27 Jun 2012 21:03:57 +0200 Subject: [PATCH 07/22] Let the wizard automatically set first_layer_height = nozzle_diameter --- lib/Slic3r/GUI/ConfigWizard.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index 6f55347b3..3bfeb3bcc 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -279,8 +279,9 @@ sub apply { my $self = shift; $self->SUPER::apply; - # set layer_height to nozzle_diameter - 0.1 + # set first_layer_height + layer_height based on nozzle_diameter my $nozzle = Slic3r::Config->get_raw('nozzle_diameter'); + Slic3r::Config->set('first_layer_height', $nozzle); Slic3r::Config->set('layer_height', $nozzle - 0.1); } From 7211561ab3fe77f02758df7f8d64ca97d6eca8ec Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Wed, 27 Jun 2012 21:51:12 +0200 Subject: [PATCH 08/22] Change wizard welcome text a bit --- lib/Slic3r/GUI/ConfigWizard.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index 3bfeb3bcc..0e28c78be 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -211,7 +211,7 @@ sub new { my ($parent) = @_; my $self = $class->SUPER::new($parent, 'Welcome to the Slic3r Configuration Wizard'); - $self->append_text('This configuration wizard will guide you through the most important settings of Slic3r in a few easy steps.'); + $self->append_text('Hello, welcome to Slic3r! This wizard will help you with the initial configuration; just a few settings and you will be ready to print.'); $self->append_text('Configuration will be based on your current configuration.'); $self->append_text('To continue, click Next.'); From 84cfe7afc7b673004d7a92065c510f7101bb95f6 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Wed, 27 Jun 2012 22:13:57 +0200 Subject: [PATCH 09/22] Automatically show configuration wizard on first run --- lib/Slic3r/GUI.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index b59b5a405..e33319234 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -39,6 +39,7 @@ sub OnInit { # locate or create data directory $datadir = Wx::StandardPaths::Get->GetUserDataDir; Slic3r::debugf "Data directory: %s\n", $datadir; + my $run_wizard = (-d $datadir) ? 0 : 1; for ($datadir, "$datadir/print", "$datadir/filament", "$datadir/printer") { mkdir or $self->fatal_error("Slic3r was unable to create its data directory at $_ (errno: $!).") unless -d $_; @@ -106,6 +107,8 @@ sub OnInit { $frame->Show; $frame->Layout; + $frame->{skeinpanel}->config_wizard if $run_wizard; + return 1; } From ed9f6e1f1eba3ceb0a6c5736977f97bd5f62bb3e Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Wed, 27 Jun 2012 23:20:29 +0200 Subject: [PATCH 10/22] Rephrase a few of the wizard instructions --- lib/Slic3r/GUI/ConfigWizard.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index 0e28c78be..ddaf66494 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -211,7 +211,7 @@ sub new { my ($parent) = @_; my $self = $class->SUPER::new($parent, 'Welcome to the Slic3r Configuration Wizard'); - $self->append_text('Hello, welcome to Slic3r! This wizard will help you with the initial configuration; just a few settings and you will be ready to print.'); + $self->append_text('Hello, welcome to Slic3r! This wizard helps you with the initial configuration; just a few settings and you will be ready to print.'); $self->append_text('Configuration will be based on your current configuration.'); $self->append_text('To continue, click Next.'); @@ -364,8 +364,9 @@ sub new { my ($parent) = @_; my $self = $class->SUPER::new($parent, 'Congratulations!'); - $self->append_text('Slic3r is now configured for your particular printer and filament.'); - $self->append_text('Click Finish to apply the newly created configuration and close this wizard.'); + $self->append_text('You have successfully completed the Slic3r Configuration Wizard. ' . + 'Slic3r is now configured for your printer and filament.'); + $self->append_text('To close this wizard and apply the newly created configuration, click Finish.'); return $self; } From 4f179a5197331fc432ce2d660fa6b3d60c69a99e Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Thu, 28 Jun 2012 23:20:10 +0200 Subject: [PATCH 11/22] Explicitly set top level window (to ensure the wizard is not assumed to be the top level window) --- lib/Slic3r/GUI.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index e33319234..7f1787ad3 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -56,6 +56,7 @@ sub OnInit { my $frame = Wx::Frame->new(undef, -1, 'Slic3r', [-1, -1], [760,520], wxDEFAULT_FRAME_STYLE); $frame->SetIcon(Wx::Icon->new("$Slic3r::var/Slic3r_128px.png", &Wx::wxBITMAP_TYPE_PNG) ); $frame->{skeinpanel} = Slic3r::GUI::SkeinPanel->new($frame); + $self->SetTopWindow($frame); # status bar $frame->{statusbar} = Slic3r::GUI::ProgressStatusBar->new($frame, -1); From df658eb63601a8ff95f75ba39a49dfd008578e5b Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sat, 30 Jun 2012 22:57:30 +0200 Subject: [PATCH 12/22] Rename SkeinPanel::on_close() to make it more generice --- lib/Slic3r/GUI.pm | 2 +- lib/Slic3r/GUI/SkeinPanel.pm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 7f1787ad3..5d366e65a 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -127,7 +127,7 @@ sub about { sub on_close { my ($frame, $event) = @_; - $event->CanVeto ? $event->Skip($frame->{skeinpanel}->on_close) : $event->Skip(1); + $event->CanVeto ? $event->Skip($frame->{skeinpanel}->check_unsaved_changes) : $event->Skip(1); } sub catch_error { diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index fc7d0fa81..ed83a5bef 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -232,7 +232,7 @@ sub config_wizard { } } -sub on_close { +sub check_unsaved_changes { my $self = shift; my @dirty; @@ -242,7 +242,7 @@ sub on_close { if (@dirty) { my $titles = join ', ', @dirty; - my $confirm = Wx::MessageDialog->new($self, "You have unsaved changes ($titles). Exit anyway?", + my $confirm = Wx::MessageDialog->new($self, "You have unsaved changes ($titles). Discard changes and continue anyway?", 'Unsaved Presets', wxICON_QUESTION | wxOK | wxCANCEL); return ($confirm->ShowModal == wxID_OK); } From d90e82faa3ac47b908ef16bd334eeb20aa6f31dd Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sat, 30 Jun 2012 23:00:05 +0200 Subject: [PATCH 13/22] Check for unsaved changes before running configuration wizard --- lib/Slic3r/GUI/SkeinPanel.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index ed83a5bef..7999d98aa 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -226,6 +226,7 @@ sub load_config { sub config_wizard { my $self = shift; + return unless $self->check_unsaved_changes; if (Slic3r::GUI::ConfigWizard->new($self)->run) { $_->() for values %Slic3r::GUI::OptionsGroup::reload_callbacks; $_->set_dirty(1) for values %{$self->{options_tabs}}; From 757da9d39d549c2e56d3204281e8c29531407836 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sat, 30 Jun 2012 23:28:07 +0200 Subject: [PATCH 14/22] Clean up imports --- lib/Slic3r/GUI/ConfigWizard.pm | 72 +++++++++++++--------------------- 1 file changed, 28 insertions(+), 44 deletions(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index ddaf66494..14ac7faa3 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -3,7 +3,7 @@ use strict; use warnings; use utf8; -use Wx qw(:sizer :progressdialog); +use Wx qw(:bitmap); use base 'Wx::Wizard'; sub new { @@ -11,7 +11,7 @@ sub new { my ($parent) = @_; # TODO: Add instructional bitmaps my $self = $class->SUPER::new($parent, -1, 'Configuration Wizard', - Wx::Bitmap->new("$Slic3r::var/Slic3r_128px.png", &Wx::wxBITMAP_TYPE_PNG)); + Wx::Bitmap->new("$Slic3r::var/Slic3r_128px.png", wxBITMAP_TYPE_PNG)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Welcome->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Firmware->new($self)); @@ -50,7 +50,7 @@ sub run { } package Slic3r::GUI::ConfigWizard::Option; -use Wx qw(:sizer :progressdialog); +use Wx qw(:combobox :misc :sizer :textctrl); use Wx::Event qw(EVT_SPINCTRL EVT_TEXT EVT_CHECKBOX EVT_COMBOBOX); use base 'Wx::StaticBoxSizer'; @@ -58,7 +58,7 @@ sub new { my $class = shift; my ($parent, %params) = @_; my $box = Wx::StaticBox->new($parent, -1, ''); - my $self = $class->SUPER::new($box, &Wx::wxHORIZONTAL); + my $self = $class->SUPER::new($box, wxHORIZONTAL); my $label_width = 200; @@ -68,24 +68,24 @@ sub new { my $callback = $params{callback} || sub {}; # label - my $label = Wx::StaticText->new($parent, -1, "$opt->{label}:", &Wx::wxDefaultPosition, [$label_width, -1]); + my $label = Wx::StaticText->new($parent, -1, "$opt->{label}:", wxDefaultPosition, [$label_width, -1]); $label->Wrap($label_width); - $self->Add($label, 1, &Wx::wxEXPAND); + $self->Add($label, 1, wxEXPAND); # input field(s) and unit my $field; if ($opt->{type} =~ /^(i|f|s|s@)$/) { - my $style = $opt->{multiline} ? &Wx::wxTE_MULTILINE : 0; + my $style = $opt->{multiline} ? wxTE_MULTILINE : 0; my $size = Wx::Size->new($opt->{width} || -1, $opt->{height} || -1); my ($get, $set) = $opt->{type} eq 's@' ? qw(serialize deserialize) : qw(get_raw set); if ($opt->{type} eq 'i') { my $value = Slic3r::Config->$get($opt_key); - $field = Wx::SpinCtrl->new($parent, -1, $value, &Wx::wxDefaultPosition, $size, $style, $opt->{min} || 0, $opt->{max} || 100, $value); + $field = Wx::SpinCtrl->new($parent, -1, $value, wxDefaultPosition, $size, $style, $opt->{min} || 0, $opt->{max} || 100, $value); EVT_SPINCTRL($parent, $field, sub { $callback->($opt_key, $field->GetValue) }); } else { - $field = Wx::TextCtrl->new($parent, -1, Slic3r::Config->$get($opt_key), Wx::wxDefaultPosition, $size, $style); + $field = Wx::TextCtrl->new($parent, -1, Slic3r::Config->$get($opt_key), wxDefaultPosition, $size, $style); EVT_TEXT($parent, $field, sub { $callback->($opt_key, $field->GetValue) }); } } elsif ($opt->{type} eq 'bool') { @@ -93,20 +93,20 @@ sub new { $field->SetValue(Slic3r::Config->get_raw($opt_key)); EVT_CHECKBOX($parent, $field, sub { $callback->($opt_key, $field->GetValue) }); } elsif ($opt->{type} eq 'point') { - $field = Wx::BoxSizer->new(&Wx::wxHORIZONTAL); + $field = Wx::BoxSizer->new(wxHORIZONTAL); my $field_size = Wx::Size->new(40, -1); my $value = Slic3r::Config->get_raw($opt_key); my @items = ( Wx::StaticText->new($parent, -1, 'x:'), - my $x_field = Wx::TextCtrl->new($parent, -1, $value->[0], &Wx::wxDefaultPosition, $field_size), + my $x_field = Wx::TextCtrl->new($parent, -1, $value->[0], wxDefaultPosition, $field_size), Wx::StaticText->new($parent, -1, ' y:'), - my $y_field = Wx::TextCtrl->new($parent, -1, $value->[1], &Wx::wxDefaultPosition, $field_size), + my $y_field = Wx::TextCtrl->new($parent, -1, $value->[1], wxDefaultPosition, $field_size), ); $field->Add($_) for @items; EVT_TEXT($parent, $x_field, sub { $callback->($opt_key, [$x_field->GetValue, $y_field->GetValue]) }); EVT_TEXT($parent, $y_field, sub { $callback->($opt_key, [$x_field->GetValue, $y_field->GetValue]) }); } elsif ($opt->{type} eq 'select') { - $field = Wx::ComboBox->new($parent, -1, '', &Wx::wxDefaultPosition, &Wx::wxDefaultSize, $opt->{labels} || $opt->{values}, &Wx::wxCB_READONLY); + $field = Wx::ComboBox->new($parent, -1, '', wxDefaultPosition, wxDefaultSize, $opt->{labels} || $opt->{values}, wxCB_READONLY); my $value = Slic3r::Config->get_raw($opt_key); $field->SetSelection(grep $opt->{values}[$_] eq $value, 0..$#{$opt->{values}}); EVT_COMBOBOX($parent, $field, sub { $callback->($opt_key, $opt->{values}[$field->GetSelection]) }); @@ -114,20 +114,20 @@ sub new { die 'Unsupported option type: ' . $opt->{type}; } if ($opt->{sidetext}) { - my $sizer = Wx::BoxSizer->new(&Wx::wxHORIZONTAL); + my $sizer = Wx::BoxSizer->new(wxHORIZONTAL); $sizer->Add($field); - my $sidetext = Wx::StaticText->new($parent, -1, $opt->{sidetext}, &Wx::wxDefaultPosition, [-1, -1]); - $sizer->Add($sidetext, 0, &Wx::wxLEFT | &Wx::wxALIGN_CENTER_VERTICAL, 4); + my $sidetext = Wx::StaticText->new($parent, -1, $opt->{sidetext}, wxDefaultPosition, [-1, -1]); + $sizer->Add($sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4); $self->Add($sizer); } else { - $self->Add($field, 0, $opt->{full_width} ? &Wx::wxEXPAND : 0); + $self->Add($field, 0, $opt->{full_width} ? wxEXPAND : 0); } return $self; } package Slic3r::GUI::ConfigWizard::Page; -use Wx qw(:sizer :progressdialog); +use Wx qw(:font :misc :sizer :staticline :systemsettings); use Wx::Event qw(); use base 'Wx::WizardPage'; @@ -137,18 +137,18 @@ sub new { my $self = $class->SUPER::new($parent); $self->{width} = 400; - $self->{vsizer} = Wx::BoxSizer->new(&Wx::wxVERTICAL); + $self->{vsizer} = Wx::BoxSizer->new(wxVERTICAL); $self->SetSizer($self->{vsizer}); # title - my $text = Wx::StaticText->new($self, -1, $title, &Wx::wxDefaultPosition, &Wx::wxDefaultSize, &Wx::wxALIGN_LEFT); - my $bold_font = Wx::SystemSettings::GetFont(&Wx::wxSYS_DEFAULT_GUI_FONT); - $bold_font->SetWeight(&Wx::wxFONTWEIGHT_BOLD); + my $text = Wx::StaticText->new($self, -1, $title, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + my $bold_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + $bold_font->SetWeight(wxFONTWEIGHT_BOLD); $bold_font->SetPointSize(14); $text->SetFont($bold_font); - $self->{vsizer}->Add($text, 0, &Wx::wxALIGN_LEFT | &Wx::wxALL, 10); - my $line = Wx::StaticLine->new($self, -1, &Wx::wxDefaultPosition, &Wx::wxDefaultSize, &Wx::wxLI_HORIZONTAL, ''); - $self->{vsizer}->Add($line, 0, &Wx::wxEXPAND| &Wx::wxALL, 10); + $self->{vsizer}->Add($text, 0, wxALIGN_LEFT | wxALL, 10); + my $line = Wx::StaticLine->new($self, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL, ''); + $self->{vsizer}->Add($line, 0, wxEXPAND| wxALL, 10); return $self; } @@ -157,9 +157,9 @@ sub append_text { my $self = shift; my ($text) = @_; - my $para = Wx::StaticText->new($self, -1, $text, &Wx::wxDefaultPosition, &Wx::wxDefaultSize, &Wx::wxALIGN_LEFT); + my $para = Wx::StaticText->new($self, -1, $text, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); $para->Wrap($self->{width}); - $self->{vsizer}->Add($para, 0, &Wx::wxALIGN_LEFT | &Wx::wxALL, 10); + $self->{vsizer}->Add($para, 0, wxALIGN_LEFT | wxALL, 10); } sub append_option { @@ -171,7 +171,7 @@ sub append_option { my ($opt_key, $value) = @_; $self->{options}->{$opt_key} = $value; }); - $self->{vsizer}->Add($option, 0, &Wx::wxEXPAND | &Wx::wxALL, 10); + $self->{vsizer}->Add($option, 0, wxEXPAND | wxALL, 10); } sub apply { @@ -202,8 +202,6 @@ sub GetNext { } package Slic3r::GUI::ConfigWizard::Page::Welcome; -use Wx qw(:sizer :progressdialog); -use Wx::Event qw(); use base 'Slic3r::GUI::ConfigWizard::Page'; sub new { @@ -219,8 +217,6 @@ sub new { } package Slic3r::GUI::ConfigWizard::Page::Firmware; -use Wx qw(:sizer :progressdialog); -use Wx::Event qw(); use base 'Slic3r::GUI::ConfigWizard::Page'; sub new { @@ -235,8 +231,6 @@ sub new { } package Slic3r::GUI::ConfigWizard::Page::Bed; -use Wx qw(:sizer :progressdialog); -use Wx::Event qw(); use base 'Slic3r::GUI::ConfigWizard::Page'; sub new { @@ -260,8 +254,6 @@ sub apply { } package Slic3r::GUI::ConfigWizard::Page::Nozzle; -use Wx qw(:sizer :progressdialog); -use Wx::Event qw(); use base 'Slic3r::GUI::ConfigWizard::Page'; sub new { @@ -286,8 +278,6 @@ sub apply { } package Slic3r::GUI::ConfigWizard::Page::Filament; -use Wx qw(:sizer :progressdialog); -use Wx::Event qw(); use base 'Slic3r::GUI::ConfigWizard::Page'; sub new { @@ -303,8 +293,6 @@ sub new { } package Slic3r::GUI::ConfigWizard::Page::Temperature; -use Wx qw(:sizer :progressdialog); -use Wx::Event qw(); use base 'Slic3r::GUI::ConfigWizard::Page'; sub new { @@ -329,8 +317,6 @@ sub apply { } package Slic3r::GUI::ConfigWizard::Page::BedTemperature; -use Wx qw(:sizer :progressdialog); -use Wx::Event qw(); use base 'Slic3r::GUI::ConfigWizard::Page'; sub new { @@ -355,8 +341,6 @@ sub apply { } package Slic3r::GUI::ConfigWizard::Page::Finished; -use Wx qw(:sizer :progressdialog); -use Wx::Event qw(); use base 'Slic3r::GUI::ConfigWizard::Page'; sub new { From e656c30d4ff1a38c0b28e2439ed5c44c4d3a962a Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sat, 30 Jun 2012 23:30:52 +0200 Subject: [PATCH 15/22] Clean up imports --- lib/Slic3r/GUI/ConfigWizard.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index 14ac7faa3..f49e8690f 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -128,7 +128,6 @@ sub new { package Slic3r::GUI::ConfigWizard::Page; use Wx qw(:font :misc :sizer :staticline :systemsettings); -use Wx::Event qw(); use base 'Wx::WizardPage'; sub new { From bb193c659c1e63a6b23099eb447535d4df8ccec0 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sat, 30 Jun 2012 23:56:11 +0200 Subject: [PATCH 16/22] Start configuration wizard from sane default settings --- lib/Slic3r/GUI/ConfigWizard.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index f49e8690f..d5354736a 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -13,6 +13,9 @@ sub new { my $self = $class->SUPER::new($parent, -1, 'Configuration Wizard', Wx::Bitmap->new("$Slic3r::var/Slic3r_128px.png", wxBITMAP_TYPE_PNG)); + # Start from sane defaults + Slic3r::Config->load_hash($Slic3r::Defaults, undef, 1); + $self->add_page(Slic3r::GUI::ConfigWizard::Page::Welcome->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Firmware->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Bed->new($self)); @@ -209,7 +212,6 @@ sub new { my $self = $class->SUPER::new($parent, 'Welcome to the Slic3r Configuration Wizard'); $self->append_text('Hello, welcome to Slic3r! This wizard helps you with the initial configuration; just a few settings and you will be ready to print.'); - $self->append_text('Configuration will be based on your current configuration.'); $self->append_text('To continue, click Next.'); return $self; From 8f0aab3520dbdc44f03e0a581d9179fcf77208d0 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sun, 1 Jul 2012 00:10:48 +0200 Subject: [PATCH 17/22] Restore old configuration if configuration wizrd is cancelled --- lib/Slic3r/GUI/ConfigWizard.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index d5354736a..aa92f7a6e 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -14,6 +14,7 @@ sub new { Wx::Bitmap->new("$Slic3r::var/Slic3r_128px.png", wxBITMAP_TYPE_PNG)); # Start from sane defaults + $self->{old} = Slic3r::Config->current; Slic3r::Config->load_hash($Slic3r::Defaults, undef, 1); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Welcome->new($self)); @@ -43,13 +44,18 @@ sub add_page { sub run { my $self = shift; - my $finished = Wx::Wizard::RunWizard($self, $self->{pages}[0]); - if ($finished) { + my $modified; + if (Wx::Wizard::RunWizard($self, $self->{pages}[0])) { $_->apply for @{$self->{pages}}; + $modified = 1; + } else { + Slic3r::Config->load_hash($self->{old}, undef, 1); + $modified = 0; } + $self->Destroy; - return $finished; + return $modified; } package Slic3r::GUI::ConfigWizard::Option; From bfe7108cea2df116779d6746effa2d6ff29f1040 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sun, 1 Jul 2012 00:17:48 +0200 Subject: [PATCH 18/22] Provide instructions for loading an existing configuration instead of using the wizard --- lib/Slic3r/GUI/ConfigWizard.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index aa92f7a6e..049155b20 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -218,6 +218,7 @@ sub new { my $self = $class->SUPER::new($parent, 'Welcome to the Slic3r Configuration Wizard'); $self->append_text('Hello, welcome to Slic3r! This wizard helps you with the initial configuration; just a few settings and you will be ready to print.'); + $self->append_text('To import an existing configuration instead, cancel this wizard and use the Open Config menu item found in the File menu.'); $self->append_text('To continue, click Next.'); return $self; From a72b914eb0cd6d4976db80aeed8d591cbaa38bf8 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sun, 1 Jul 2012 00:24:55 +0200 Subject: [PATCH 19/22] Add lib/Slic3r/GUI/ConfigWizard.pm to MANIFEST --- MANIFEST | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST b/MANIFEST index 56e61cd41..136441411 100644 --- a/MANIFEST +++ b/MANIFEST @@ -26,6 +26,7 @@ lib/Slic3r/Format/STL.pm lib/Slic3r/Geometry.pm lib/Slic3r/Geometry/Clipper.pm lib/Slic3r/GUI.pm +lib/Slic3r/GUI/ConfigWizard.pm lib/Slic3r/GUI/Plater.pm lib/Slic3r/GUI/OptionsGroup.pm lib/Slic3r/GUI/SkeinPanel.pm From a4219ba352a72b3a8c41206d79f5b93eb81aa300 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Sun, 1 Jul 2012 19:35:48 +0200 Subject: [PATCH 20/22] Sort imported events alphabetically --- lib/Slic3r/GUI/ConfigWizard.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index 049155b20..06ffe24b3 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -60,7 +60,7 @@ sub run { package Slic3r::GUI::ConfigWizard::Option; use Wx qw(:combobox :misc :sizer :textctrl); -use Wx::Event qw(EVT_SPINCTRL EVT_TEXT EVT_CHECKBOX EVT_COMBOBOX); +use Wx::Event qw(EVT_CHECKBOX EVT_COMBOBOX EVT_SPINCTRL EVT_TEXT); use base 'Wx::StaticBoxSizer'; sub new { From e8a20eed6a91b0e00dd27d204643ea21da0498b0 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Tue, 3 Jul 2012 00:42:06 +0200 Subject: [PATCH 21/22] Use wxDefaultSize instead of [-1, -1] --- lib/Slic3r/GUI/ConfigWizard.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index 06ffe24b3..94f5ff833 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -125,7 +125,7 @@ sub new { if ($opt->{sidetext}) { my $sizer = Wx::BoxSizer->new(wxHORIZONTAL); $sizer->Add($field); - my $sidetext = Wx::StaticText->new($parent, -1, $opt->{sidetext}, wxDefaultPosition, [-1, -1]); + my $sidetext = Wx::StaticText->new($parent, -1, $opt->{sidetext}, wxDefaultPosition, wxDefaultSize); $sizer->Add($sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4); $self->Add($sizer); } else { From 3fa58cf85bd6953c9d24b90f74464ca07282e079 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Tue, 3 Jul 2012 17:21:32 +0200 Subject: [PATCH 22/22] Add a friendly index --- lib/Slic3r/GUI/ConfigWizard.pm | 103 +++++++++++++++++++++++++++------ var/bullet_black.png | Bin 0 -> 211 bytes var/bullet_blue.png | Bin 0 -> 289 bytes var/bullet_white.png | Bin 0 -> 201 bytes 4 files changed, 85 insertions(+), 18 deletions(-) create mode 100755 var/bullet_black.png create mode 100755 var/bullet_blue.png create mode 100755 var/bullet_white.png diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm index 94f5ff833..9dd382cde 100644 --- a/lib/Slic3r/GUI/ConfigWizard.pm +++ b/lib/Slic3r/GUI/ConfigWizard.pm @@ -3,15 +3,13 @@ use strict; use warnings; use utf8; -use Wx qw(:bitmap); +use Wx; use base 'Wx::Wizard'; sub new { my $class = shift; my ($parent) = @_; - # TODO: Add instructional bitmaps - my $self = $class->SUPER::new($parent, -1, 'Configuration Wizard', - Wx::Bitmap->new("$Slic3r::var/Slic3r_128px.png", wxBITMAP_TYPE_PNG)); + my $self = $class->SUPER::new($parent, -1, 'Configuration Wizard'); # Start from sane defaults $self->{old} = Slic3r::Config->current; @@ -26,6 +24,8 @@ sub new { $self->add_page(Slic3r::GUI::ConfigWizard::Page::BedTemperature->new($self)); $self->add_page(Slic3r::GUI::ConfigWizard::Page::Finished->new($self)); + $_->build_index for @{$self->{pages}}; + return $self; } @@ -77,7 +77,7 @@ sub new { my $callback = $params{callback} || sub {}; # label - my $label = Wx::StaticText->new($parent, -1, "$opt->{label}:", wxDefaultPosition, [$label_width, -1]); + my $label = Wx::StaticText->new($parent, -1, "$opt->{label}:", wxDefaultPosition, wxDefaultSize); $label->Wrap($label_width); $self->Add($label, 1, wxEXPAND); @@ -135,18 +135,62 @@ sub new { return $self; } -package Slic3r::GUI::ConfigWizard::Page; -use Wx qw(:font :misc :sizer :staticline :systemsettings); -use base 'Wx::WizardPage'; +package Slic3r::GUI::ConfigWizard::Index; +use Wx qw(:bitmap :font :misc :sizer :systemsettings); +use base 'Wx::Panel'; sub new { my $class = shift; my ($parent, $title) = @_; my $self = $class->SUPER::new($parent); - $self->{width} = 400; - $self->{vsizer} = Wx::BoxSizer->new(wxVERTICAL); - $self->SetSizer($self->{vsizer}); + $self->{sizer} = Wx::FlexGridSizer->new(0, 2, 5, 0); + $self->SetSizer($self->{sizer}); + + my $bitmap = Wx::StaticBitmap->new($self, -1, Wx::Bitmap->new("$Slic3r::var/bullet_blue.png", wxBITMAP_TYPE_PNG)); + $self->{sizer}->Add($bitmap, 0, wxALIGN_CENTER_VERTICAL, 0); + + my $text = Wx::StaticText->new($self, -1, $title, wxDefaultPosition, wxDefaultSize); + $self->{sizer}->Add($text, 0, wxALIGN_CENTER_VERTICAL, 0); + + return $self; +} + +sub prepend_title { + my $self = shift; + my ($title) = @_; + + my $text = Wx::StaticText->new($self, -1, $title, wxDefaultPosition, wxDefaultSize); + $self->{sizer}->Prepend($text, 0, wxALIGN_CENTER_VERTICAL, 0); + + my $bitmap = Wx::StaticBitmap->new($self, -1, Wx::Bitmap->new("$Slic3r::var/bullet_black.png", wxBITMAP_TYPE_PNG)); + $self->{sizer}->Prepend($bitmap, 0, wxALIGN_CENTER_VERTICAL, 0); +} + +sub append_title { + my $self = shift; + my ($title) = @_; + + my $bitmap = Wx::StaticBitmap->new($self, -1, Wx::Bitmap->new("$Slic3r::var/bullet_white.png", wxBITMAP_TYPE_PNG)); + $self->{sizer}->Add($bitmap, 0, wxALIGN_CENTER_VERTICAL, 0); + + my $text = Wx::StaticText->new($self, -1, $title, wxDefaultPosition, wxDefaultSize); + $text->SetForegroundColour(Wx::Colour->new(128, 128, 128)); + $self->{sizer}->Add($text, 0, wxALIGN_CENTER_VERTICAL, 0); +} + +package Slic3r::GUI::ConfigWizard::Page; +use Wx qw(:font :misc :sizer :staticline :systemsettings); +use base 'Wx::WizardPage'; + +sub new { + my $class = shift; + my ($parent, $title, $short_title) = @_; + my $self = $class->SUPER::new($parent); + + my $sizer = Wx::FlexGridSizer->new(0, 2, 10, 10); + $sizer->AddStretchSpacer(0); + $self->SetSizer($sizer); # title my $text = Wx::StaticText->new($self, -1, $title, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); @@ -154,9 +198,17 @@ sub new { $bold_font->SetWeight(wxFONTWEIGHT_BOLD); $bold_font->SetPointSize(14); $text->SetFont($bold_font); - $self->{vsizer}->Add($text, 0, wxALIGN_LEFT | wxALL, 10); - my $line = Wx::StaticLine->new($self, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL, ''); - $self->{vsizer}->Add($line, 0, wxEXPAND| wxALL, 10); + $sizer->Add($text, 0, wxALIGN_LEFT, 0); + + # index + $self->{short_title} = $short_title ? $short_title : $title; + $self->{index} = Slic3r::GUI::ConfigWizard::Index->new($self, $self->{short_title}); + $sizer->Add($self->{index}, 0, wxTOP | wxRIGHT, 10); + + # contents + $self->{width} = 400; + $self->{vsizer} = Wx::BoxSizer->new(wxVERTICAL); + $sizer->Add($self->{vsizer}, 0, wxEXPAND, 0); return $self; } @@ -167,7 +219,8 @@ sub append_text { my $para = Wx::StaticText->new($self, -1, $text, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); $para->Wrap($self->{width}); - $self->{vsizer}->Add($para, 0, wxALIGN_LEFT | wxALL, 10); + $para->SetMinSize([$self->{width}, -1]); + $self->{vsizer}->Add($para, 0, wxALIGN_LEFT | wxTOP | wxBOTTOM, 10); } sub append_option { @@ -179,7 +232,7 @@ sub append_option { my ($opt_key, $value) = @_; $self->{options}->{$opt_key} = $value; }); - $self->{vsizer}->Add($option, 0, wxEXPAND | wxALL, 10); + $self->{vsizer}->Add($option, 0, wxEXPAND | wxTOP | wxBOTTOM, 10); } sub apply { @@ -209,13 +262,27 @@ sub GetNext { return $self->{next_page}; } +sub get_short_title { + my $self = shift; + return $self->{short_title}; +} + +sub build_index { + my $self = shift; + + my $page = $self; + $self->{index}->prepend_title($page->get_short_title) while ($page = $page->GetPrev); + $page = $self; + $self->{index}->append_title($page->get_short_title) while ($page = $page->GetNext); +} + package Slic3r::GUI::ConfigWizard::Page::Welcome; use base 'Slic3r::GUI::ConfigWizard::Page'; sub new { my $class = shift; my ($parent) = @_; - my $self = $class->SUPER::new($parent, 'Welcome to the Slic3r Configuration Wizard'); + my $self = $class->SUPER::new($parent, 'Welcome to the Slic3r Configuration Wizard', 'Welcome'); $self->append_text('Hello, welcome to Slic3r! This wizard helps you with the initial configuration; just a few settings and you will be ready to print.'); $self->append_text('To import an existing configuration instead, cancel this wizard and use the Open Config menu item found in the File menu.'); @@ -354,7 +421,7 @@ use base 'Slic3r::GUI::ConfigWizard::Page'; sub new { my $class = shift; my ($parent) = @_; - my $self = $class->SUPER::new($parent, 'Congratulations!'); + my $self = $class->SUPER::new($parent, 'Congratulations!', 'Finish'); $self->append_text('You have successfully completed the Slic3r Configuration Wizard. ' . 'Slic3r is now configured for your printer and filament.'); diff --git a/var/bullet_black.png b/var/bullet_black.png new file mode 100755 index 0000000000000000000000000000000000000000..57619706d10d9736b1849a83f2c5694fbe09c53b GIT binary patch literal 211 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^zbpD<_bdI{u9mbgZg z1m~xflqVLYGB~E>C#5QQ<|d}62BjvZR2H60wE-$h^>lFz(Kw&{<9vg>5sw~gS5O!4 zr|{HuUFIBKiQyL}eBJ-L{`UVT|6_O~L{G%N{Wbre{kQtZ_0LvEhDX@>Vt8IAj)#jg!+?Z23wnf7d! zNAH#A4i6V)y_WtvZQ1hT)TAWgjoY{t%BOsI;8VOzQvNniDZk5xCy$)UQWb1PRjRoz l1#moJy|?3|{zvx%+C#5QQ<|d}62BjvZR2H60wE-%M_H=O!(Kvthf+1gnf`Cilxr3SC zCq+y2HhAz(;&}R`x^q^&(wiOs&2u-u^*?dO$=Q}CfYva0y85}Sb4q9e0M-pfO8@`> literal 0 HcmV?d00001