Removed the 'simple' mode.

This commit is contained in:
bubnikv 2017-06-14 11:48:08 +02:00
parent 8a2a9abbd4
commit 82bde51c27
10 changed files with 22 additions and 461 deletions

View File

@ -116,7 +116,6 @@ The author of the Silk icon set is Mark James.
--gui Forces the GUI launch instead of command line slicing (if you
supply a model file, it will be loaded into the plater)
--no-plater Disable the plater tab
--gui-mode Overrides the configured mode (simple/expert)
--autosave <file> Automatically export current configuration to the specified file
Output options:

View File

@ -72,7 +72,6 @@ use Slic3r::Polygon;
use Slic3r::Polyline;
use Slic3r::Print;
use Slic3r::Print::Object;
use Slic3r::Print::Simple;
use Slic3r::Surface;
our $build = eval "use Slic3r::Build; 1";
use Thread::Semaphore;

View File

@ -31,7 +31,6 @@ use Slic3r::GUI::ProgressStatusBar;
use Slic3r::GUI::Projector;
use Slic3r::GUI::OptionsGroup;
use Slic3r::GUI::OptionsGroup::Field;
use Slic3r::GUI::SimpleTab;
use Slic3r::GUI::SystemInfo;
use Slic3r::GUI::Tab;
@ -59,14 +58,11 @@ our $datadir;
# If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
our $no_controller;
our $no_plater;
our $mode;
our $autosave;
our @cb;
our $Settings = {
_ => {
# Simple mode is very limited, rather start with the expert mode.
mode => 'expert',
version_check => 1,
autocenter => 1,
# Disable background processing by default as it is not stable.
@ -128,7 +124,6 @@ sub OnInit {
my $ini = eval { Slic3r::Config->read_ini("$datadir/slic3r.ini") };
$Settings = $ini if $ini;
$last_version = $Settings->{_}{version};
$Settings->{_}{mode} ||= 'expert';
$Settings->{_}{autocenter} //= 1;
$Settings->{_}{background_processing} //= 1;
# If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
@ -142,7 +137,6 @@ sub OnInit {
# application frame
Wx::Image::AddHandler(Wx::PNGHandler->new);
$self->{mainframe} = my $frame = Slic3r::GUI::MainFrame->new(
mode => $mode // $Settings->{_}{mode},
# If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
no_controller => $no_controller // $Settings->{_}{no_controller},
no_plater => $no_plater,

View File

@ -31,8 +31,6 @@ sub new {
}
# store input params
$self->{mode} = $params{mode};
$self->{mode} = 'expert' if $self->{mode} !~ /^(?:simple|expert)$/;
# If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
$self->{no_controller} = $params{no_controller};
$self->{no_plater} = $params{no_plater};
@ -120,16 +118,9 @@ sub _init_tabpanel {
}
$self->{options_tabs} = {};
my $simple_config;
if ($self->{mode} eq 'simple') {
$simple_config = Slic3r::Config->load("$Slic3r::GUI::datadir/simple.ini")
if -e Slic3r::encode_path("$Slic3r::GUI::datadir/simple.ini");
}
my $class_prefix = $self->{mode} eq 'simple' ? "Slic3r::GUI::SimpleTab::" : "Slic3r::GUI::Tab::";
for my $tab_name (qw(print filament printer)) {
my $tab;
$tab = $self->{options_tabs}{$tab_name} = ($class_prefix . ucfirst $tab_name)->new(
$tab = $self->{options_tabs}{$tab_name} = ("Slic3r::GUI::Tab::" . ucfirst $tab_name)->new(
$panel,
no_controller => $self->{no_controller});
# Callback to be executed after any of the configuration fields (Perl class Slic3r::GUI::OptionsGroup::Field) change their value.
@ -140,19 +131,8 @@ sub _init_tabpanel {
$self->{plater}->on_config_change($config); # propagate config change events to the plater
$self->{plater}->on_extruders_change($value) if $opt_key eq 'extruders_count';
}
if ($self->{loaded}) { # don't save while loading for the first time
if ($self->{mode} eq 'simple') {
# save config
$self->config->save("$Slic3r::GUI::datadir/simple.ini");
# save a copy into each preset section
# so that user gets the config when switching to expert mode
$config->save(sprintf "$Slic3r::GUI::datadir/%s/%s.ini", $tab->name, 'Simple Mode');
$Slic3r::GUI::Settings->{presets}{$tab->name} = 'Simple Mode.ini';
wxTheApp->save_settings;
}
$self->config->save($Slic3r::GUI::autosave) if $Slic3r::GUI::autosave;
}
# don't save while loading for the first time
$self->config->save($Slic3r::GUI::autosave) if $Slic3r::GUI::autosave && $self->{loaded};
});
# Install a callback for the tab to update the platter and print controller presets, when
# a preset changes at Slic3r::GUI::Tab.
@ -168,7 +148,6 @@ sub _init_tabpanel {
});
$tab->load_presets;
$panel->AddPage($tab, $tab->title);
$tab->load_config($simple_config) if $simple_config;
}
if ($self->{plater}) {
@ -532,12 +511,9 @@ sub repair_stl {
sub extra_variables {
my $self = shift;
my %extra_variables = ();
if ($self->{mode} eq 'expert') {
$extra_variables{"${_}_preset"} = $self->{options_tabs}{$_}->get_current_preset->name
for qw(print filament printer);
}
$extra_variables{"${_}_preset"} = $self->{options_tabs}{$_}->get_current_preset->name
for qw(print filament printer);
return { %extra_variables };
}
@ -606,13 +582,9 @@ sub export_configbundle {
# leave default category empty to prevent the bundle from being parsed as a normal config file
my $ini = { _ => {} };
$ini->{settings}{$_} = $Slic3r::GUI::Settings->{_}{$_} for qw(autocenter mode);
$ini->{settings}{$_} = $Slic3r::GUI::Settings->{_}{$_} for qw(autocenter);
$ini->{presets} = $Slic3r::GUI::Settings->{presets};
if (-e "$Slic3r::GUI::datadir/simple.ini") {
my $config = Slic3r::Config->load("$Slic3r::GUI::datadir/simple.ini");
$ini->{simple} = $config->as_ini->{_};
}
foreach my $section (qw(print filament printer)) {
my %presets = wxTheApp->presets($section);
foreach my $preset_name (keys %presets) {
@ -652,15 +624,7 @@ sub load_configbundle {
$Slic3r::GUI::Settings->{presets} = $ini->{presets};
wxTheApp->save_settings;
}
if ($ini->{simple}) {
my $config = Slic3r::Config->load_ini_hash($ini->{simple});
$config->save("$Slic3r::GUI::datadir/simple.ini");
if ($self->{mode} eq 'simple') {
foreach my $tab (values %{$self->{options_tabs}}) {
$tab->load_config($config) for values %{$self->{options_tabs}};
}
}
}
my $imported = 0;
INI_BLOCK: foreach my $ini_category (sort keys %$ini) {
next unless $ini_category =~ /^(print|filament|printer):(.+)$/;
@ -681,20 +645,14 @@ sub load_configbundle {
Slic3r::debugf "Imported %s preset %s\n", $section, $preset_name;
$imported++;
}
if ($self->{mode} eq 'expert') {
foreach my $tab (values %{$self->{options_tabs}}) {
$tab->load_presets;
}
foreach my $tab (values %{$self->{options_tabs}}) {
$tab->load_presets;
}
return if !$imported;
my $message = sprintf "%d presets successfully imported.", $imported;
if ($self->{mode} eq 'simple' && $Slic3r::GUI::Settings->{_}{mode} eq 'expert') {
Slic3r::GUI::show_info($self, "$message You need to restart Slic3r to make the changes effective.");
} else {
Slic3r::GUI::show_info($self, $message);
}
Slic3r::GUI::show_info($self, $message);
}
sub load_config {
@ -714,18 +672,12 @@ sub config_wizard {
return unless $self->check_unsaved_changes;
if (my $config = Slic3r::GUI::ConfigWizard->new($self)->run) {
if ($self->{mode} eq 'expert') {
for my $tab (values %{$self->{options_tabs}}) {
$tab->select_default_preset;
}
} else {
# TODO: select default settings in simple mode
for my $tab (values %{$self->{options_tabs}}) {
$tab->select_default_preset;
}
$self->load_config($config);
if ($self->{mode} eq 'expert') {
for my $tab (values %{$self->{options_tabs}}) {
$tab->save_preset('My Settings');
}
for my $tab (values %{$self->{options_tabs}}) {
$tab->save_preset('My Settings');
}
}
}
@ -746,7 +698,7 @@ sub config {
# retrieve filament presets and build a single config object for them
my $filament_config;
if (!$self->{plater} || $self->{plater}->filament_presets == 1 || $self->{mode} eq 'simple') {
if (!$self->{plater} || $self->{plater}->filament_presets == 1) {
$filament_config = $self->{options_tabs}{filament}->config;
} else {
my $i = -1;
@ -782,27 +734,15 @@ sub config {
$filament_config,
);
if ($self->{mode} eq 'simple') {
# set some sensible defaults
$config->set('first_layer_height', $config->nozzle_diameter->[0]);
$config->set('avoid_crossing_perimeters', 1);
$config->set('infill_every_layers', 10);
} else {
my $extruders_count = $self->{options_tabs}{printer}{extruders_count};
$config->set("${_}_extruder", min($config->get("${_}_extruder"), $extruders_count))
for qw(perimeter infill solid_infill support_material support_material_interface);
}
my $extruders_count = $self->{options_tabs}{printer}{extruders_count};
$config->set("${_}_extruder", min($config->get("${_}_extruder"), $extruders_count))
for qw(perimeter infill solid_infill support_material support_material_interface);
return $config;
}
sub filament_preset_names {
my ($self) = @_;
if ($self->{mode} eq 'simple') {
return '';
}
return map $self->{options_tabs}{filament}->get_preset($_)->name,
$self->{plater}->filament_presets;
}

View File

@ -1,4 +1,4 @@
# A dialog group object. Used by the Tab, SimpleTab, Preferences dialog, ManualControlDialog etc.
# A dialog group object. Used by the Tab, Preferences dialog, ManualControlDialog etc.
package Slic3r::GUI::OptionsGroup;
use Moo;

View File

@ -348,7 +348,7 @@ sub new {
{
my $presets;
if ($self->GetFrame->{mode} eq 'expert') {
{
$presets = $self->{presets_sizer} = Wx::FlexGridSizer->new(3, 2, 1, 2);
$presets->AddGrowableCol(1, 1);
$presets->SetFlexibleDirection(wxHORIZONTAL);

View File

@ -20,16 +20,6 @@ sub new {
},
label_width => 200,
);
$optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
opt_id => 'mode',
type => 'select',
label => 'Mode',
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 => $Slic3r::GUI::Settings->{_}{mode},
width => 100,
));
# $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
# opt_id => 'version_check',
# type => 'bool',
@ -91,7 +81,7 @@ sub new {
sub _accept {
my $self = shift;
if ($self->{values}{mode} || defined($self->{values}{no_controller})) {
if (defined($self->{values}{no_controller})) {
Slic3r::GUI::warning_catcher($self)->("You need to restart Slic3r to make the changes effective.");
}

View File

@ -1,357 +0,0 @@
# The "Simple" Print Settings tab.
# The "Simple" mode is enabled by File->Preferences dialog.
package Slic3r::GUI::SimpleTab;
use strict;
use warnings;
use utf8;
use File::Basename qw(basename);
use List::Util qw(first);
use Wx qw(:bookctrl :dialog :keycode :icon :id :misc :panel :sizer :window :systemsettings);
use Wx::Event qw(EVT_BUTTON EVT_CHOICE EVT_KEY_DOWN);
use base 'Wx::ScrolledWindow';
sub new {
my $class = shift;
my ($parent, %params) = @_;
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
$self->SetScrollbars(1, 1, 1, 1);
$self->{config} = Slic3r::Config->new;
$self->{optgroups} = [];
$self->{vsizer} = Wx::BoxSizer->new(wxVERTICAL);
$self->SetSizer($self->{vsizer});
$self->build;
$self->_update;
{
my $label = Wx::StaticText->new($self, -1, "Want more options? Switch to the Expert Mode.", wxDefaultPosition, wxDefaultSize);
$label->SetFont(Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
$self->{vsizer}->Add($label, 0, wxEXPAND | wxALL, 10);
}
return $self;
}
sub init_config_options {
my ($self, @opt_keys) = @_;
$self->{config}->apply(Slic3r::Config->new_from_defaults(@opt_keys));
}
sub new_optgroup {
my ($self, $title, %params) = @_;
my $optgroup = Slic3r::GUI::ConfigOptionsGroup->new(
parent => $self,
title => $title,
config => $self->{config},
label_width => $params{label_width} // 200,
on_change => sub { $self->_on_value_change(@_) },
);
push @{$self->{optgroups}}, $optgroup;
$self->{vsizer}->Add($optgroup->sizer, 0, wxEXPAND | wxALL, 10);
return $optgroup;
}
sub load_config_file {
my $self = shift;
my ($file) = @_;
my $config = Slic3r::Config->load($file);
$self->load_config($config);
}
sub load_config {
my $self = shift;
my ($config) = @_;
my %keys_modified = ();
foreach my $opt_key (@{$self->{config}->get_keys}) {
if ($config->has($opt_key)) {
if ($self->{config}->serialize($opt_key) ne $config->serialize($opt_key)) {
$self->{config}->set($opt_key, $config->get($opt_key));
$keys_modified{$opt_key} = 1;
}
}
}
# Initialize UI components with the config values.
$_->reload_config for @{$self->{optgroups}};
$self->_update(\%keys_modified);
}
sub load_presets {}
sub is_dirty { 0 }
sub config { $_[0]->{config}->clone }
sub _update {}
sub on_value_change {
my ($self, $cb) = @_;
$self->{on_value_change} = $cb;
}
sub on_presets_changed {}
# propagate event to the parent
sub _on_value_change {
my ($self, $key, $value) = @_;
$self->{on_value_change}->($key, $value) if $self->{on_value_change};
$self->_update({ $key => 1 });
}
sub get_field {
my ($self, $opt_key, $opt_index) = @_;
foreach my $optgroup (@{ $self->{optgroups} }) {
my $field = $optgroup->get_fieldc($opt_key, $opt_index);
return $field if defined $field;
}
return undef;
}
package Slic3r::GUI::SimpleTab::Print;
use base 'Slic3r::GUI::SimpleTab';
use Wx qw(:sizer);
sub name { 'print' }
sub title { 'Print Settings' }
sub build {
my $self = shift;
$self->init_config_options(qw(
layer_height perimeters top_solid_layers bottom_solid_layers
fill_density fill_pattern external_fill_pattern
support_material support_material_spacing raft_layers
support_material_contact_distance support_material_buildplate_only dont_support_bridges
perimeter_speed infill_speed travel_speed
brim_width
xy_size_compensation
));
{
my $optgroup = $self->new_optgroup('General');
$optgroup->append_single_option_line('layer_height');
$optgroup->append_single_option_line('perimeters');
my $line = Slic3r::GUI::OptionsGroup::Line->new(
label => 'Solid layers',
);
$line->append_option($optgroup->get_option('top_solid_layers'));
$line->append_option($optgroup->get_option('bottom_solid_layers'));
$optgroup->append_line($line);
}
{
my $optgroup = $self->new_optgroup('Infill');
$optgroup->append_single_option_line('fill_density');
$optgroup->append_single_option_line('fill_pattern');
$optgroup->append_single_option_line('external_fill_pattern');
}
{
my $optgroup = $self->new_optgroup('Support material');
$optgroup->append_single_option_line('support_material');
$optgroup->append_single_option_line('support_material_spacing');
$optgroup->append_single_option_line('support_material_contact_distance');
$optgroup->append_single_option_line('support_material_buildplate_only');
$optgroup->append_single_option_line('dont_support_bridges');
$optgroup->append_single_option_line('raft_layers');
}
{
my $optgroup = $self->new_optgroup('Speed');
$optgroup->append_single_option_line('perimeter_speed');
$optgroup->append_single_option_line('infill_speed');
$optgroup->append_single_option_line('travel_speed');
}
{
my $optgroup = $self->new_optgroup('Brim');
$optgroup->append_single_option_line('brim_width');
}
{
my $optgroup = $self->new_optgroup('Other');
$optgroup->append_single_option_line('xy_size_compensation');
}
}
sub _update {
# $keys_modified is a reference to hash with modified keys set to 1, unmodified keys missing.
my ($self, $keys_modified) = @_;
my $config = $self->{config};
my $have_perimeters = $config->perimeters > 0;
$self->get_field($_)->toggle($have_perimeters)
for qw(perimeter_speed);
my $have_infill = $config->fill_density > 0;
my $have_solid_infill = $config->top_solid_layers > 0 || $config->bottom_solid_layers > 0;
$self->get_field($_)->toggle($have_infill)
for qw(fill_pattern);
$self->get_field($_)->toggle($have_solid_infill)
for qw(external_fill_pattern);
$self->get_field($_)->toggle($have_infill || $have_solid_infill)
for qw(infill_speed);
my $have_support_material = $config->support_material || $config->raft_layers > 0;
$self->get_field($_)->toggle($have_support_material)
for qw(support_material_spacing dont_support_bridges
support_material_contact_distance);
}
package Slic3r::GUI::SimpleTab::Filament;
use base 'Slic3r::GUI::SimpleTab';
sub name { 'filament' }
sub title { 'Filament Settings' }
sub build {
my $self = shift;
$self->init_config_options(qw(
filament_diameter extrusion_multiplier
temperature first_layer_temperature bed_temperature first_layer_bed_temperature
));
{
my $optgroup = $self->new_optgroup('Filament');
$optgroup->append_single_option_line('filament_diameter', 0);
$optgroup->append_single_option_line('extrusion_multiplier', 0);
}
{
my $optgroup = $self->new_optgroup('Temperature (°C)');
{
my $line = Slic3r::GUI::OptionsGroup::Line->new(
label => 'Extruder',
);
$line->append_option($optgroup->get_option('first_layer_temperature', 0));
$line->append_option($optgroup->get_option('temperature', 0));
$optgroup->append_line($line);
}
{
my $line = Slic3r::GUI::OptionsGroup::Line->new(
label => 'Bed',
);
$line->append_option($optgroup->get_option('first_layer_bed_temperature'));
$line->append_option($optgroup->get_option('bed_temperature'));
$optgroup->append_line($line);
}
}
}
package Slic3r::GUI::SimpleTab::Printer;
use base 'Slic3r::GUI::SimpleTab';
use Wx qw(:sizer :button :bitmap :misc :id);
use Wx::Event qw(EVT_BUTTON);
sub name { 'printer' }
sub title { 'Printer Settings' }
sub build {
my $self = shift;
$self->init_config_options(qw(
bed_shape
z_offset
gcode_flavor
nozzle_diameter
retract_length retract_lift wipe
start_gcode
end_gcode
));
{
my $bed_shape_widget = sub {
my ($parent) = @_;
my $btn = Wx::Button->new($parent, -1, "Set…", wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
$btn->SetFont($Slic3r::GUI::small_font);
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("cog.png"), wxBITMAP_TYPE_PNG));
}
my $sizer = Wx::BoxSizer->new(wxHORIZONTAL);
$sizer->Add($btn);
EVT_BUTTON($self, $btn, sub {
my $dlg = Slic3r::GUI::BedShapeDialog->new($self, $self->{config}->bed_shape);
if ($dlg->ShowModal == wxID_OK) {
my $value = $dlg->GetValue;
$self->{config}->set('bed_shape', $value);
$self->_on_value_change('bed_shape', $value);
}
});
return $sizer;
};
my $optgroup = $self->new_optgroup('Size and coordinates');
my $line = Slic3r::GUI::OptionsGroup::Line->new(
label => 'Bed shape',
widget => $bed_shape_widget,
);
$optgroup->append_line($line);
$optgroup->append_single_option_line('z_offset');
}
{
my $optgroup = $self->new_optgroup('Firmware');
$optgroup->append_single_option_line('gcode_flavor');
}
{
my $optgroup = $self->new_optgroup('Extruder');
$optgroup->append_single_option_line('nozzle_diameter', 0);
}
{
my $optgroup = $self->new_optgroup('Retraction');
$optgroup->append_single_option_line('retract_length', 0);
$optgroup->append_single_option_line('retract_lift', 0);
$optgroup->append_single_option_line('wipe', 0);
}
{
my $optgroup = $self->new_optgroup('Start G-code',
label_width => 0,
);
my $option = $optgroup->get_option('start_gcode');
$option->full_width(1);
$option->height(150);
$optgroup->append_single_option_line($option);
}
{
my $optgroup = $self->new_optgroup('End G-code',
label_width => 0,
);
my $option = $optgroup->get_option('end_gcode');
$option->full_width(1);
$option->height(150);
$optgroup->append_single_option_line($option);
}
}
sub _update {
my ($self) = @_;
my $config = $self->{config};
my $have_retraction = $config->retract_length->[0] > 0;
$self->get_field($_, 0)->toggle($have_retraction)
for qw(retract_lift wipe);
}
1;

View File

@ -1,5 +1,4 @@
# The "Expert" tab at the right of the main tabbed window.
# The "Expert" is enabled by File->Preferences dialog.
# This file implements following packages:
# Slic3r::GUI::Tab;

View File

@ -35,7 +35,6 @@ my %cli_options = ();
'ignore-nonexistent-config' => \$opt{ignore_nonexistent_config},
'no-controller' => \$opt{no_controller},
'no-plater' => \$opt{no_plater},
'gui-mode=s' => \$opt{gui_mode},
'datadir=s' => \$opt{datadir},
'export-svg' => \$opt{export_svg},
'merge|m' => \$opt{merge},
@ -105,7 +104,6 @@ if ((!@ARGV || $opt{gui}) && !$opt{save} && eval "require Slic3r::GUI; 1") {
$Slic3r::GUI::datadir = Slic3r::decode_path($opt{datadir} // '');
$Slic3r::GUI::no_controller = $opt{no_controller};
$Slic3r::GUI::no_plater = $opt{no_plater};
$Slic3r::GUI::mode = $opt{gui_mode};
$Slic3r::GUI::autosave = $opt{autosave};
}
$gui = Slic3r::GUI->new;
@ -280,7 +278,6 @@ $j
--gui Forces the GUI launch instead of command line slicing (if you
supply a model file, it will be loaded into the plater)
--no-plater Disable the plater tab
--gui-mode Overrides the configured mode (simple/expert)
--autosave <file> Automatically export current configuration to the specified file
Output options: