Skip to content

Commit

Permalink
The "controller" tab and the settings of the USB/serial connection was
Browse files Browse the repository at this point in the history
made configurable. Now one may hide the "controller" tab and the USB/serial
connection configuration from the preferences. This is useful for someone,
who never connects his printer to the computer by a cable.
  • Loading branch information
bubnikv committed May 16, 2016
1 parent 510ca9f commit d8be976
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 20 deletions.
13 changes: 11 additions & 2 deletions lib/Slic3r/GUI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ use constant FILE_WILDCARDS => {
use constant MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(known stl obj amf)};

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;
Expand All @@ -64,6 +66,9 @@ our $Settings = {
version_check => 1,
autocenter => 1,
background_processing => 1,
# If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
# By default, Prusa has the controller hidden.
no_controller => 1,
},
};

Expand Down Expand Up @@ -115,15 +120,19 @@ sub OnInit {
$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.
$Settings->{_}{no_controller} //= 1;
}
$Settings->{_}{version} = $Slic3r::VERSION;
$self->save_settings;

# application frame
Wx::Image::AddHandler(Wx::PNGHandler->new);
$self->{mainframe} = my $frame = Slic3r::GUI::MainFrame->new(
mode => $mode // $Settings->{_}{mode},
no_plater => $no_plater,
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,
);
$self->SetTopWindow($frame);

Expand Down
22 changes: 16 additions & 6 deletions lib/Slic3r/GUI/MainFrame.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ 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};
$self->{loaded} = 0;

Expand Down Expand Up @@ -96,7 +98,9 @@ sub _init_tabpanel {

if (!$self->{no_plater}) {
$panel->AddPage($self->{plater} = Slic3r::GUI::Plater->new($panel), "Plater");
$panel->AddPage($self->{controller} = Slic3r::GUI::Controller->new($panel), "Controller");
if (!$self->{no_controller}) {
$panel->AddPage($self->{controller} = Slic3r::GUI::Controller->new($panel), "Controller");
}
}
$self->{options_tabs} = {};

Expand All @@ -109,7 +113,9 @@ sub _init_tabpanel {
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($panel);
$tab = $self->{options_tabs}{$tab_name} = ($class_prefix . ucfirst $tab_name)->new(
$panel,
no_controller => $self->{no_controller});
$tab->on_value_change(sub {
my ($opt_key, $value) = @_;

Expand All @@ -136,7 +142,9 @@ sub _init_tabpanel {
if ($self->{plater}) {
$self->{plater}->update_presets($tab_name, @_);
$self->{plater}->on_config_change($tab->config);
$self->{controller}->update_presets($tab_name, @_);
if ($self->{controller}) {
$self->{controller}->update_presets($tab_name, @_);
}
}
});
$tab->load_presets;
Expand Down Expand Up @@ -246,9 +254,11 @@ sub _init_menubar {
$self->_append_menu_item($windowMenu, "Select &Plater Tab\tCtrl+1", 'Show the plater', sub {
$self->select_tab(0);
}, undef, 'application_view_tile.png');
$self->_append_menu_item($windowMenu, "Select &Controller Tab\tCtrl+T", 'Show the printer controller', sub {
$self->select_tab(1);
}, undef, 'printer_empty.png');
if (!$self->{no_controller}) {
$self->_append_menu_item($windowMenu, "Select &Controller Tab\tCtrl+T", 'Show the printer controller', sub {
$self->select_tab(1);
}, undef, 'printer_empty.png');
}
$windowMenu->AppendSeparator();
$tab_offset += 2;
}
Expand Down
9 changes: 8 additions & 1 deletion lib/Slic3r/GUI/Preferences.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ sub new {
default => $Slic3r::GUI::Settings->{_}{background_processing},
readonly => !$Slic3r::have_threads,
));
$optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
opt_id => 'no_controller',
type => 'bool',
label => 'Disable USB/serial connection',
tooltip => 'Disable communication with the printer over a serial / USB cable. This simplifies the user interface in case the printer is never attached to the computer.',
default => $Slic3r::GUI::Settings->{_}{no_controller},
));

my $sizer = Wx::BoxSizer->new(wxVERTICAL);
$sizer->Add($optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
Expand All @@ -75,7 +82,7 @@ sub new {
sub _accept {
my $self = shift;

if ($self->{values}{mode}) {
if ($self->{values}{mode} || defined($self->{values}{no_controller})) {
Slic3r::GUI::warning_catcher($self)->("You need to restart Slic3r to make the changes effective.");
}

Expand Down
19 changes: 12 additions & 7 deletions lib/Slic3r/GUI/Tab.pm
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ sub new {
});

$self->{config} = Slic3r::Config->new;
$self->build;
$self->build(%params);
$self->update_tree;
$self->_update;
if ($self->hidden_options) {
Expand Down Expand Up @@ -985,6 +985,7 @@ sub title { 'Printer Settings' }

sub build {
my $self = shift;
my (%params) = @_;

$self->init_config_options(qw(
bed_shape z_offset
Expand Down Expand Up @@ -1064,6 +1065,7 @@ sub build {
}
});
}
if (!$params{no_controller})
{
my $optgroup = $page->new_optgroup('USB/Serial connection');
my $line = Slic3r::GUI::OptionsGroup::Line->new(
Expand Down Expand Up @@ -1239,7 +1241,7 @@ sub build {

$self->{extruder_pages} = [];
$self->_build_extruder_pages;
$self->_update_serial_ports;
$self->_update_serial_ports if (!$params{no_controller});
}

sub _update_serial_ports {
Expand Down Expand Up @@ -1341,11 +1343,14 @@ sub _update {

my $config = $self->{config};

$self->get_field('serial_speed')->toggle($config->get('serial_port'));
if ($config->get('serial_speed') && $config->get('serial_port')) {
$self->{serial_test_btn}->Enable;
} else {
$self->{serial_test_btn}->Disable;
my $serial_speed = $self->get_field('serial_speed');
if ($serial_speed) {
$self->get_field('serial_speed')->toggle($config->get('serial_port'));
if ($config->get('serial_speed') && $config->get('serial_port')) {
$self->{serial_test_btn}->Enable;
} else {
$self->{serial_test_btn}->Disable;
}
}
if ($config->get('octoprint_host') && eval "use LWP::UserAgent; 1") {
$self->{octoprint_host_test_btn}->Enable;
Expand Down
10 changes: 6 additions & 4 deletions slic3r.pl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ BEGIN
'load=s@' => \$opt{load},
'autosave=s' => \$opt{autosave},
'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},
Expand Down Expand Up @@ -99,10 +100,11 @@ BEGIN
if ((!@ARGV || $opt{gui}) && !$opt{save} && eval "require Slic3r::GUI; 1") {
{
no warnings 'once';
$Slic3r::GUI::datadir = Slic3r::decode_path($opt{datadir} // '');
$Slic3r::GUI::no_plater = $opt{no_plater};
$Slic3r::GUI::mode = $opt{gui_mode};
$Slic3r::GUI::autosave = $opt{autosave};
$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;
setlocale(LC_NUMERIC, 'C');
Expand Down

0 comments on commit d8be976

Please sign in to comment.