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,32 +210,34 @@ sub new {
|
|||
$hsizer->Add($self->{canvas}, 0, wxALL, 10);
|
||||
$hsizer->Add($vertical_sizer, 1, wxEXPAND | wxALL, 10);
|
||||
|
||||
my $presets = Wx::BoxSizer->new(wxHORIZONTAL);
|
||||
$presets->AddStretchSpacer(1);
|
||||
my %group_labels = (
|
||||
print => 'Print settings',
|
||||
filament => 'Filament',
|
||||
printer => 'Printer',
|
||||
);
|
||||
$self->{preset_choosers} = {};
|
||||
$self->{preset_choosers_sizers} = {};
|
||||
for my $group (qw(print filament printer)) {
|
||||
my $text = Wx::StaticText->new($self, -1, "$group_labels{$group}:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
|
||||
my $choice = Wx::Choice->new($self, -1, wxDefaultPosition, [150, -1], []);
|
||||
$self->{preset_choosers}{$group} = [$choice];
|
||||
EVT_CHOICE($choice, $choice, sub { $self->on_select_preset($group, @_) });
|
||||
|
||||
$self->{preset_choosers_sizers}{$group} = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$self->{preset_choosers_sizers}{$group}->Add($choice, 0, wxEXPAND | wxBOTTOM, FILAMENT_CHOOSERS_SPACING);
|
||||
|
||||
$presets->Add($text, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxRIGHT, 4);
|
||||
$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);
|
||||
|
||||
if ($self->skeinpanel->{mode} eq 'expert') {
|
||||
my $presets = Wx::BoxSizer->new(wxHORIZONTAL);
|
||||
$presets->AddStretchSpacer(1);
|
||||
my %group_labels = (
|
||||
print => 'Print settings',
|
||||
filament => 'Filament',
|
||||
printer => 'Printer',
|
||||
);
|
||||
$self->{preset_choosers} = {};
|
||||
$self->{preset_choosers_sizers} = {};
|
||||
for my $group (qw(print filament printer)) {
|
||||
my $text = Wx::StaticText->new($self, -1, "$group_labels{$group}:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
|
||||
my $choice = Wx::Choice->new($self, -1, wxDefaultPosition, [150, -1], []);
|
||||
$self->{preset_choosers}{$group} = [$choice];
|
||||
EVT_CHOICE($choice, $choice, sub { $self->on_select_preset($group, @_) });
|
||||
|
||||
$self->{preset_choosers_sizers}{$group} = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$self->{preset_choosers_sizers}{$group}->Add($choice, 0, wxEXPAND | wxBOTTOM, FILAMENT_CHOOSERS_SPACING);
|
||||
|
||||
$presets->Add($text, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxRIGHT, 4);
|
||||
$presets->Add($self->{preset_choosers_sizers}{$group}, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 15);
|
||||
}
|
||||
$presets->AddStretchSpacer(1);
|
||||
$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,126 +14,133 @@ 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});
|
||||
|
||||
# left vertical sizer
|
||||
my $left_sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$self->{sizer}->Add($left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3);
|
||||
|
||||
my $left_col_width = 150;
|
||||
|
||||
# preset chooser
|
||||
{
|
||||
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);
|
||||
|
||||
# choice menu
|
||||
$self->{presets_choice} = Wx::Choice->new($self, -1, wxDefaultPosition, [$left_col_width, -1], []);
|
||||
$self->{presets_choice}->SetFont($Slic3r::GUI::small_font);
|
||||
my $left_col_width = 150;
|
||||
|
||||
# buttons
|
||||
$self->{btn_save_preset} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("$Slic3r::var/disk.png", wxBITMAP_TYPE_PNG));
|
||||
$self->{btn_delete_preset} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("$Slic3r::var/delete.png", wxBITMAP_TYPE_PNG));
|
||||
$self->{btn_save_preset}->SetToolTipString("Save current " . lc($self->title));
|
||||
$self->{btn_delete_preset}->SetToolTipString("Delete this preset");
|
||||
$self->{btn_delete_preset}->Disable;
|
||||
# preset chooser
|
||||
{
|
||||
|
||||
# choice menu
|
||||
$self->{presets_choice} = Wx::Choice->new($self, -1, wxDefaultPosition, [$left_col_width, -1], []);
|
||||
$self->{presets_choice}->SetFont($Slic3r::GUI::small_font);
|
||||
|
||||
# buttons
|
||||
$self->{btn_save_preset} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("$Slic3r::var/disk.png", wxBITMAP_TYPE_PNG));
|
||||
$self->{btn_delete_preset} = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new("$Slic3r::var/delete.png", wxBITMAP_TYPE_PNG));
|
||||
$self->{btn_save_preset}->SetToolTipString("Save current " . lc($self->title));
|
||||
$self->{btn_delete_preset}->SetToolTipString("Delete this preset");
|
||||
$self->{btn_delete_preset}->Disable;
|
||||
|
||||
### These cause GTK warnings:
|
||||
###my $box = Wx::StaticBox->new($self, -1, "Presets:", wxDefaultPosition, [$left_col_width, 50]);
|
||||
###my $hsizer = Wx::StaticBoxSizer->new($box, wxHORIZONTAL);
|
||||
|
||||
my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL);
|
||||
|
||||
$left_sizer->Add($hsizer, 0, wxEXPAND | wxBOTTOM, 5);
|
||||
$hsizer->Add($self->{presets_choice}, 1, wxRIGHT | wxALIGN_CENTER_VERTICAL, 3);
|
||||
$hsizer->Add($self->{btn_save_preset}, 0, wxALIGN_CENTER_VERTICAL);
|
||||
$hsizer->Add($self->{btn_delete_preset}, 0, wxALIGN_CENTER_VERTICAL);
|
||||
}
|
||||
|
||||
### These cause GTK warnings:
|
||||
###my $box = Wx::StaticBox->new($self, -1, "Presets:", wxDefaultPosition, [$left_col_width, 50]);
|
||||
###my $hsizer = Wx::StaticBoxSizer->new($box, wxHORIZONTAL);
|
||||
# tree
|
||||
$self->{treectrl} = Wx::TreeCtrl->new($self, -1, wxDefaultPosition, [$left_col_width, -1], wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_SUNKEN | wxWANTS_CHARS);
|
||||
$left_sizer->Add($self->{treectrl}, 1, wxEXPAND);
|
||||
$self->{icons} = Wx::ImageList->new(16, 16, 1);
|
||||
$self->{treectrl}->AssignImageList($self->{icons});
|
||||
$self->{iconcount} = -1;
|
||||
$self->{treectrl}->AddRoot("root");
|
||||
$self->{pages} = [];
|
||||
$self->{treectrl}->SetIndent(0);
|
||||
EVT_TREE_SEL_CHANGED($parent, $self->{treectrl}, sub {
|
||||
my $page = first { $_->{title} eq $self->{treectrl}->GetItemText($self->{treectrl}->GetSelection) } @{$self->{pages}}
|
||||
or return;
|
||||
$_->Hide for @{$self->{pages}};
|
||||
$page->Show;
|
||||
$self->{sizer}->Layout;
|
||||
$self->Refresh;
|
||||
});
|
||||
EVT_KEY_DOWN($self->{treectrl}, sub {
|
||||
my ($treectrl, $event) = @_;
|
||||
if ($event->GetKeyCode == WXK_TAB) {
|
||||
$treectrl->Navigate($event->ShiftDown ? &Wx::wxNavigateBackward : &Wx::wxNavigateForward);
|
||||
} else {
|
||||
$event->Skip;
|
||||
}
|
||||
});
|
||||
|
||||
my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL);
|
||||
EVT_CHOICE($parent, $self->{presets_choice}, sub {
|
||||
$self->on_select_preset;
|
||||
$self->sync_presets;
|
||||
});
|
||||
|
||||
$left_sizer->Add($hsizer, 0, wxEXPAND | wxBOTTOM, 5);
|
||||
$hsizer->Add($self->{presets_choice}, 1, wxRIGHT | wxALIGN_CENTER_VERTICAL, 3);
|
||||
$hsizer->Add($self->{btn_save_preset}, 0, wxALIGN_CENTER_VERTICAL);
|
||||
$hsizer->Add($self->{btn_delete_preset}, 0, wxALIGN_CENTER_VERTICAL);
|
||||
EVT_BUTTON($self, $self->{btn_save_preset}, sub {
|
||||
|
||||
# since buttons (and choices too) don't get focus on Mac, we set focus manually
|
||||
# to the treectrl so that the EVT_* events are fired for the input field having
|
||||
# focus currently. is there anything better than this?
|
||||
$self->{treectrl}->SetFocus;
|
||||
|
||||
my $preset = $self->current_preset;
|
||||
my $default_name = $preset->{default} ? 'Untitled' : basename($preset->{name});
|
||||
$default_name =~ s/\.ini$//i;
|
||||
|
||||
my $dlg = Slic3r::GUI::SavePresetWindow->new($self,
|
||||
title => lc($self->title),
|
||||
default => $default_name,
|
||||
values => [ map { my $name = $_->{name}; $name =~ s/\.ini$//i; $name } @{$self->{presets}} ],
|
||||
);
|
||||
return unless $dlg->ShowModal == wxID_OK;
|
||||
|
||||
my $file = sprintf "$Slic3r::GUI::datadir/%s/%s.ini", $self->name, $dlg->get_name;
|
||||
$self->config->save($file);
|
||||
$self->set_dirty(0);
|
||||
$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;
|
||||
});
|
||||
|
||||
EVT_BUTTON($self, $self->{btn_delete_preset}, sub {
|
||||
my $i = $self->{presets_choice}->GetSelection;
|
||||
return if $i == 0; # this shouldn't happen but let's trap it anyway
|
||||
my $res = Wx::MessageDialog->new($self, "Are you sure you want to delete the selected preset?", 'Delete Preset', wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION)->ShowModal;
|
||||
return unless $res == wxID_YES;
|
||||
if (-e $self->{presets}[$i]{file}) {
|
||||
unlink $self->{presets}[$i]{file};
|
||||
}
|
||||
splice @{$self->{presets}}, $i, 1;
|
||||
$self->set_dirty(0);
|
||||
$self->{presets_choice}->Delete($i);
|
||||
$self->{presets_choice}->SetSelection(0);
|
||||
$self->on_select_preset;
|
||||
$self->sync_presets;
|
||||
});
|
||||
}
|
||||
|
||||
# tree
|
||||
$self->{treectrl} = Wx::TreeCtrl->new($self, -1, wxDefaultPosition, [$left_col_width, -1], wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_SUNKEN | wxWANTS_CHARS);
|
||||
$left_sizer->Add($self->{treectrl}, 1, wxEXPAND);
|
||||
$self->{icons} = Wx::ImageList->new(16, 16, 1);
|
||||
$self->{treectrl}->AssignImageList($self->{icons});
|
||||
$self->{iconcount} = -1;
|
||||
$self->{treectrl}->AddRoot("root");
|
||||
$self->{pages} = [];
|
||||
$self->{treectrl}->SetIndent(0);
|
||||
EVT_TREE_SEL_CHANGED($parent, $self->{treectrl}, sub {
|
||||
my $page = first { $_->{title} eq $self->{treectrl}->GetItemText($self->{treectrl}->GetSelection) } @{$self->{pages}}
|
||||
or return;
|
||||
$_->Hide for @{$self->{pages}};
|
||||
$page->Show;
|
||||
$self->{sizer}->Layout;
|
||||
$self->Refresh;
|
||||
});
|
||||
EVT_KEY_DOWN($self->{treectrl}, sub {
|
||||
my ($treectrl, $event) = @_;
|
||||
if ($event->GetKeyCode == WXK_TAB) {
|
||||
$treectrl->Navigate($event->ShiftDown ? &Wx::wxNavigateBackward : &Wx::wxNavigateForward);
|
||||
} else {
|
||||
$event->Skip;
|
||||
if ($self->{mode} eq 'expert') {
|
||||
$self->{config} = Slic3r::Config->new;
|
||||
$self->build;
|
||||
if ($self->hidden_options) {
|
||||
$self->{config}->apply(Slic3r::Config->new_from_defaults($self->hidden_options));
|
||||
push @{$self->{options}}, $self->hidden_options;
|
||||
}
|
||||
});
|
||||
|
||||
EVT_CHOICE($parent, $self->{presets_choice}, sub {
|
||||
$self->on_select_preset;
|
||||
$self->sync_presets;
|
||||
});
|
||||
|
||||
EVT_BUTTON($self, $self->{btn_save_preset}, sub {
|
||||
|
||||
# since buttons (and choices too) don't get focus on Mac, we set focus manually
|
||||
# to the treectrl so that the EVT_* events are fired for the input field having
|
||||
# focus currently. is there anything better than this?
|
||||
$self->{treectrl}->SetFocus;
|
||||
|
||||
my $preset = $self->current_preset;
|
||||
my $default_name = $preset->{default} ? 'Untitled' : basename($preset->{name});
|
||||
$default_name =~ s/\.ini$//i;
|
||||
|
||||
my $dlg = Slic3r::GUI::SavePresetWindow->new($self,
|
||||
title => lc($self->title),
|
||||
default => $default_name,
|
||||
values => [ map { my $name = $_->{name}; $name =~ s/\.ini$//i; $name } @{$self->{presets}} ],
|
||||
);
|
||||
return unless $dlg->ShowModal == wxID_OK;
|
||||
|
||||
my $file = sprintf "$Slic3r::GUI::datadir/%s/%s.ini", $self->name, $dlg->get_name;
|
||||
$self->config->save($file);
|
||||
$self->set_dirty(0);
|
||||
$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;
|
||||
});
|
||||
|
||||
EVT_BUTTON($self, $self->{btn_delete_preset}, sub {
|
||||
my $i = $self->{presets_choice}->GetSelection;
|
||||
return if $i == 0; # this shouldn't happen but let's trap it anyway
|
||||
my $res = Wx::MessageDialog->new($self, "Are you sure you want to delete the selected preset?", 'Delete Preset', wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION)->ShowModal;
|
||||
return unless $res == wxID_YES;
|
||||
if (-e $self->{presets}[$i]{file}) {
|
||||
unlink $self->{presets}[$i]{file};
|
||||
}
|
||||
splice @{$self->{presets}}, $i, 1;
|
||||
$self->set_dirty(0);
|
||||
$self->{presets_choice}->Delete($i);
|
||||
$self->{presets_choice}->SetSelection(0);
|
||||
$self->on_select_preset;
|
||||
$self->sync_presets;
|
||||
});
|
||||
|
||||
$self->{config} = Slic3r::Config->new;
|
||||
$self->build;
|
||||
if ($self->hidden_options) {
|
||||
$self->{config}->apply(Slic3r::Config->new_from_defaults($self->hidden_options));
|
||||
push @{$self->{options}}, $self->hidden_options;
|
||||
} else {
|
||||
$self->{config} = $params{config} || Slic3r::Config->new;
|
||||
$self->build_simple;
|
||||
}
|
||||
$self->load_presets;
|
||||
|
||||
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,9 +799,11 @@ sub config {
|
|||
|
||||
my $config = $self->SUPER::config(@_);
|
||||
|
||||
# remove all unused values
|
||||
foreach my $opt_key ($self->_extruder_options) {
|
||||
splice @{ $config->{$opt_key} }, $self->{extruders_count};
|
||||
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