Simple mode
This commit is contained in:
parent
cf4c090208
commit
7239ca18c1
5 changed files with 316 additions and 145 deletions
|
@ -38,7 +38,11 @@ use constant MI_WEBSITE => &Wx::NewId;
|
|||
use constant MI_DOCUMENTATION => &Wx::NewId;
|
||||
|
||||
our $datadir;
|
||||
our $Settings;
|
||||
our $Settings = {
|
||||
_ => {
|
||||
mode => 'simple',
|
||||
},
|
||||
};
|
||||
|
||||
our $small_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
$small_font->SetPointSize(11) if !&Wx::wxMSW;
|
||||
|
@ -66,13 +70,14 @@ sub OnInit {
|
|||
if (-f "$datadir/slic3r.ini") {
|
||||
my $ini = eval { Slic3r::Config->read_ini("$datadir/slic3r.ini") };
|
||||
$Settings = $ini if $ini;
|
||||
$Settings->{_}{mode} ||= 'expert';
|
||||
}
|
||||
|
||||
# application frame
|
||||
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);
|
||||
$self->{skeinpanel} = Slic3r::GUI::SkeinPanel->new($frame, mode => $Settings->{_}{mode});
|
||||
$self->SetTopWindow($frame);
|
||||
|
||||
# status bar
|
||||
|
|
|
@ -210,6 +210,10 @@ sub new {
|
|||
$hsizer->Add($self->{canvas}, 0, wxALL, 10);
|
||||
$hsizer->Add($vertical_sizer, 1, wxEXPAND | wxALL, 10);
|
||||
|
||||
my $sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$sizer->Add($hsizer, 1, wxEXPAND | wxBOTTOM, 10);
|
||||
|
||||
if ($self->skeinpanel->{mode} eq 'expert') {
|
||||
my $presets = Wx::BoxSizer->new(wxHORIZONTAL);
|
||||
$presets->AddStretchSpacer(1);
|
||||
my %group_labels = (
|
||||
|
@ -232,10 +236,8 @@ sub new {
|
|||
$presets->Add($self->{preset_choosers_sizers}{$group}, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 15);
|
||||
}
|
||||
$presets->AddStretchSpacer(1);
|
||||
|
||||
my $sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$sizer->Add($hsizer, 1, wxEXPAND | wxBOTTOM, 10);
|
||||
$sizer->Add($presets, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10);
|
||||
}
|
||||
|
||||
$sizer->SetSizeHints($self);
|
||||
$self->SetSizer($sizer);
|
||||
|
@ -581,11 +583,15 @@ sub export_gcode {
|
|||
sub _init_print {
|
||||
my $self = shift;
|
||||
|
||||
my %extra_variables = ();
|
||||
if ($self->skeinpanel->{mode} eq 'expert') {
|
||||
$extra_variables{"${_}_preset"} = $self->skeinpanel->{options_tabs}{$_}->current_preset->{name}
|
||||
for qw(print filament printer);
|
||||
}
|
||||
|
||||
return Slic3r::Print->new(
|
||||
config => $self->skeinpanel->config,
|
||||
extra_variables => {
|
||||
map { +"${_}_preset" => $self->skeinpanel->{options_tabs}{$_}->current_preset->{name} } qw(print filament printer),
|
||||
},
|
||||
extra_variables => { %extra_variables },
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ sub new {
|
|||
my $class = shift;
|
||||
my ($parent, %params) = @_;
|
||||
my $self = $class->SUPER::new($parent, -1, "Preferences", wxDefaultPosition, [500,200]);
|
||||
$self->{values};
|
||||
|
||||
my $optgroup = Slic3r::GUI::OptionsGroup->new(
|
||||
parent => $self,
|
||||
|
@ -19,16 +20,17 @@ sub new {
|
|||
tooltip => 'Choose between a simpler, basic mode and an expert mode with more options and more complicated interface.',
|
||||
labels => ['Simple','Expert'],
|
||||
values => ['simple','expert'],
|
||||
default => 'simple',
|
||||
default => $Slic3r::GUI::Settings->{_}{mode},
|
||||
},
|
||||
],
|
||||
on_change => sub { $self->{values}{$_[0]} = $_[1] },
|
||||
label_width => 100,
|
||||
);
|
||||
my $sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$sizer->Add($optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
|
||||
|
||||
my $buttons = $self->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
|
||||
EVT_BUTTON($self, wxID_OK, sub { $self->EndModal(wxID_OK); });
|
||||
EVT_BUTTON($self, wxID_OK, sub { $self->_accept });
|
||||
$sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
|
||||
|
||||
$self->SetSizer($sizer);
|
||||
|
@ -37,4 +39,16 @@ sub new {
|
|||
return $self;
|
||||
}
|
||||
|
||||
sub _accept {
|
||||
my $self = shift;
|
||||
$self->EndModal(wxID_OK);
|
||||
|
||||
if ($self->{values}{mode}) {
|
||||
Slic3r::GUI::warning_catcher($self)->("You need to restart Slic3r to make the changes effective.");
|
||||
}
|
||||
|
||||
$Slic3r::GUI::Settings->{_}{$_} = $self->{values}{$_} for keys %{$self->{values}};
|
||||
Slic3r::GUI->save_settings;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -25,18 +25,31 @@ use constant MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(stl obj amf)};
|
|||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my ($parent) = @_;
|
||||
my ($parent, %params) = @_;
|
||||
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
$self->{mode} = $params{mode};
|
||||
|
||||
$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->{options_tabs} = {};
|
||||
|
||||
my $config;
|
||||
$config = Slic3r::Config->load("$Slic3r::GUI::datadir/simple.ini")
|
||||
if -e "$Slic3r::GUI::datadir/simple.ini";
|
||||
|
||||
for my $tab_name (qw(print filament printer)) {
|
||||
$self->{options_tabs}{$tab_name} = ("Slic3r::GUI::Tab::" . ucfirst $tab_name)->new(
|
||||
$self->{tabpanel},
|
||||
mode => $self->{mode},
|
||||
plater => $self->{plater},
|
||||
on_value_change => sub { $self->{plater}->on_config_change(@_) }, # propagate config change events to the plater
|
||||
config => $config,
|
||||
on_value_change => sub {
|
||||
$self->{plater}->on_config_change(@_); # propagate config change events to the plater
|
||||
if ($self->{mode} eq 'simple') {
|
||||
# save config
|
||||
$self->config->save("$Slic3r::GUI::datadir/simple.ini");
|
||||
}
|
||||
},
|
||||
);
|
||||
$self->{tabpanel}->AddPage($self->{options_tabs}{$tab_name}, $self->{options_tabs}{$tab_name}->title);
|
||||
}
|
||||
|
@ -289,7 +302,7 @@ sub config {
|
|||
|
||||
# retrieve filament presets and build a single config object for them
|
||||
my $filament_config;
|
||||
if ($self->{plater}->filament_presets == 1) {
|
||||
if ($self->{plater}->filament_presets == 1 || $self->{mode} eq 'simple') {
|
||||
$filament_config = $self->{options_tabs}{filament}->config;
|
||||
} else {
|
||||
# TODO: handle dirty presets.
|
||||
|
@ -308,12 +321,19 @@ sub config {
|
|||
}
|
||||
}
|
||||
|
||||
return Slic3r::Config->merge(
|
||||
my $config = Slic3r::Config->merge(
|
||||
Slic3r::Config->new_from_defaults,
|
||||
$self->{options_tabs}{print}->config,
|
||||
$self->{options_tabs}{printer}->config,
|
||||
$filament_config,
|
||||
);
|
||||
|
||||
if ($self->{mode} eq 'simple') {
|
||||
# set some sensible defaults
|
||||
$config->set('first_layer_height', $config->nozzle_diameter->[0]);
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
sub set_value {
|
||||
|
|
|
@ -14,13 +14,14 @@ 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(mode plater on_value_change);
|
||||
|
||||
# horizontal sizer
|
||||
$self->{sizer} = Wx::BoxSizer->new(wxHORIZONTAL);
|
||||
$self->{sizer}->SetSizeHints($self);
|
||||
$self->SetSizer($self->{sizer});
|
||||
|
||||
if ($self->{mode} eq 'expert') {
|
||||
# left vertical sizer
|
||||
my $left_sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$self->{sizer}->Add($left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3);
|
||||
|
@ -126,7 +127,9 @@ sub new {
|
|||
$self->on_select_preset;
|
||||
$self->sync_presets;
|
||||
});
|
||||
}
|
||||
|
||||
if ($self->{mode} eq 'expert') {
|
||||
$self->{config} = Slic3r::Config->new;
|
||||
$self->build;
|
||||
if ($self->hidden_options) {
|
||||
|
@ -134,6 +137,10 @@ sub new {
|
|||
push @{$self->{options}}, $self->hidden_options;
|
||||
}
|
||||
$self->load_presets;
|
||||
} else {
|
||||
$self->{config} = $params{config} || Slic3r::Config->new;
|
||||
$self->build_simple;
|
||||
}
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -230,7 +237,7 @@ sub add_options_page {
|
|||
my $self = shift;
|
||||
my ($title, $icon, %params) = @_;
|
||||
|
||||
if ($icon) {
|
||||
if ($icon && $self->{icons}) {
|
||||
my $bitmap = Wx::Bitmap->new("$Slic3r::var/$icon", wxBITMAP_TYPE_PNG);
|
||||
$self->{icons}->Add($bitmap);
|
||||
$self->{iconcount}++;
|
||||
|
@ -242,7 +249,7 @@ sub add_options_page {
|
|||
my %defaults_to_set = map { $_ => 1 } @options;
|
||||
|
||||
# apply default values for the options we don't have already
|
||||
delete $defaults_to_set{$_} for @{$self->{options}};
|
||||
delete $defaults_to_set{$_} for @{$self->{options}}, keys %{$self->{config}};
|
||||
$self->{config}->apply(Slic3r::Config->new_from_defaults(keys %defaults_to_set)) if %defaults_to_set;
|
||||
|
||||
# append such options to our list
|
||||
|
@ -254,7 +261,7 @@ sub add_options_page {
|
|||
$self->set_dirty(1);
|
||||
$self->sync_presets;
|
||||
});
|
||||
$page->Hide;
|
||||
$page->Hide if $self->{mode} eq 'expert';
|
||||
$self->{sizer}->Add($page, 1, wxEXPAND | wxLEFT, 5);
|
||||
push @{$self->{pages}}, $page;
|
||||
$self->update_tree;
|
||||
|
@ -281,6 +288,7 @@ sub reload_values {
|
|||
sub update_tree {
|
||||
my $self = shift;
|
||||
my ($select) = @_;
|
||||
return if !$self->{treectrl};
|
||||
|
||||
$select //= 0; #/
|
||||
|
||||
|
@ -295,6 +303,7 @@ sub update_tree {
|
|||
sub set_dirty {
|
||||
my $self = shift;
|
||||
my ($dirty) = @_;
|
||||
return if $self->{mode} ne 'expert';
|
||||
|
||||
my $selection = $self->{presets_choice}->GetSelection;
|
||||
my $i = $self->{dirty} // $selection; #/
|
||||
|
@ -373,6 +382,7 @@ sub load_external_config {
|
|||
|
||||
sub sync_presets {
|
||||
my $self = shift;
|
||||
return if $self->{mode} ne 'expert';
|
||||
$self->{plater}->update_presets($self->name, [$self->{presets_choice}->GetStrings], $self->{presets_choice}->GetSelection);
|
||||
}
|
||||
|
||||
|
@ -382,6 +392,58 @@ use base 'Slic3r::GUI::Tab';
|
|||
sub name { 'print' }
|
||||
sub title { 'Print Settings' }
|
||||
|
||||
sub build_simple {
|
||||
my $self = shift;
|
||||
|
||||
$self->add_options_page('', '', optgroups => [
|
||||
{
|
||||
title => 'Layer height',
|
||||
options => [qw(layer_height)],
|
||||
},
|
||||
{
|
||||
title => 'Vertical shells',
|
||||
options => [qw(perimeters)],
|
||||
},
|
||||
{
|
||||
title => 'Horizontal shells',
|
||||
options => [qw(top_solid_layers bottom_solid_layers)],
|
||||
lines => [
|
||||
{
|
||||
label => 'Solid layers',
|
||||
options => [qw(top_solid_layers bottom_solid_layers)],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title => 'Infill',
|
||||
options => [qw(fill_density fill_pattern)],
|
||||
},
|
||||
{
|
||||
title => 'Speed',
|
||||
options => [qw(perimeter_speed infill_speed travel_speed)],
|
||||
},
|
||||
{
|
||||
title => 'Brim',
|
||||
options => [qw(brim_width)],
|
||||
},
|
||||
{
|
||||
title => 'Support material',
|
||||
options => [qw(support_material support_material_spacing)],
|
||||
},
|
||||
{
|
||||
title => 'Sequential printing',
|
||||
options => [qw(complete_objects extruder_clearance_radius extruder_clearance_height)],
|
||||
lines => [
|
||||
Slic3r::GUI::OptionsGroup->single_option_line('complete_objects'),
|
||||
{
|
||||
label => 'Extruder clearance (mm)',
|
||||
options => [qw(extruder_clearance_radius extruder_clearance_height)],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
sub build {
|
||||
my $self = shift;
|
||||
|
||||
|
@ -513,6 +575,35 @@ use base 'Slic3r::GUI::Tab';
|
|||
sub name { 'filament' }
|
||||
sub title { 'Filament Settings' }
|
||||
|
||||
sub build_simple {
|
||||
my $self = shift;
|
||||
|
||||
$self->add_options_page('', '', optgroups => [
|
||||
{
|
||||
title => 'Filament',
|
||||
options => ['filament_diameter#0', 'extrusion_multiplier#0'],
|
||||
},
|
||||
{
|
||||
title => 'Temperature (°C)',
|
||||
options => ['temperature#0', 'first_layer_temperature#0', qw(bed_temperature first_layer_bed_temperature)],
|
||||
lines => [
|
||||
{
|
||||
label => 'Extruder',
|
||||
options => ['first_layer_temperature#0', 'temperature#0'],
|
||||
},
|
||||
{
|
||||
label => 'Bed',
|
||||
options => [qw(first_layer_bed_temperature bed_temperature)],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title => 'Cooling',
|
||||
options => [qw(cooling)],
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
sub build {
|
||||
my $self = shift;
|
||||
|
||||
|
@ -606,6 +697,39 @@ use base 'Slic3r::GUI::Tab';
|
|||
sub name { 'printer' }
|
||||
sub title { 'Printer Settings' }
|
||||
|
||||
sub build_simple {
|
||||
my $self = shift;
|
||||
|
||||
$self->add_options_page('', '', optgroups => [
|
||||
{
|
||||
title => 'Size and coordinates',
|
||||
options => [qw(bed_size print_center z_offset)],
|
||||
},
|
||||
{
|
||||
title => 'Firmware',
|
||||
options => [qw(gcode_flavor)],
|
||||
},
|
||||
{
|
||||
title => 'Extruder',
|
||||
options => ['nozzle_diameter#0'],
|
||||
},
|
||||
{
|
||||
title => 'Retraction',
|
||||
options => ['retract_length#0', 'retract_lift#0'],
|
||||
},
|
||||
{
|
||||
title => 'Start G-code',
|
||||
no_labels => 1,
|
||||
options => [qw(start_gcode)],
|
||||
},
|
||||
{
|
||||
title => 'End G-code',
|
||||
no_labels => 1,
|
||||
options => [qw(end_gcode)],
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
sub build {
|
||||
my $self = shift;
|
||||
|
||||
|
@ -675,10 +799,12 @@ sub config {
|
|||
|
||||
my $config = $self->SUPER::config(@_);
|
||||
|
||||
if ($self->{mode} eq 'expert') {
|
||||
# remove all unused values
|
||||
foreach my $opt_key ($self->_extruder_options) {
|
||||
splice @{ $config->{$opt_key} }, $self->{extruders_count};
|
||||
}
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue