mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-03 01:20:37 +08:00
A few minor changes for improving usability of controller
This commit is contained in:
parent
bc07e6a0a4
commit
c22d20b9bb
@ -165,7 +165,7 @@ sub add_printer {
|
||||
}
|
||||
}
|
||||
|
||||
my $printer_panel = Slic3r::GUI::Controller::PrinterPanel->new($self, $preset->name, $preset);
|
||||
my $printer_panel = Slic3r::GUI::Controller::PrinterPanel->new($self, $preset);
|
||||
$self->{sizer}->Prepend($printer_panel, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 10);
|
||||
$self->Layout;
|
||||
|
||||
|
@ -3,6 +3,7 @@ use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
|
||||
use List::Util qw(first);
|
||||
use Wx qw(wxTheApp :panel :id :misc :sizer :button :bitmap :window :gauge :timer
|
||||
:textctrl :font :systemsettings);
|
||||
use Wx::Event qw(EVT_BUTTON EVT_MOUSEWHEEL EVT_TIMER EVT_SCROLLWIN);
|
||||
@ -16,10 +17,10 @@ use constant STATUS_TIMER_INTERVAL => 1000; # milliseconds
|
||||
use constant TEMP_TIMER_INTERVAL => 5000; # milliseconds
|
||||
|
||||
sub new {
|
||||
my ($class, $parent, $printer_name, $preset) = @_;
|
||||
my ($class, $parent, $preset) = @_;
|
||||
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, [500, 250]);
|
||||
|
||||
$self->printer_name($printer_name || 'Printer');
|
||||
$self->printer_name($preset->name);
|
||||
$self->config($preset->dirty_config);
|
||||
$self->manual_control_config({
|
||||
xy_travel_speed => 130,
|
||||
@ -336,6 +337,17 @@ sub connect {
|
||||
|
||||
# request temperature now, without waiting for the timer
|
||||
$self->sender->send("M105", 1);
|
||||
|
||||
# Update the printer preset with the new connection info
|
||||
{
|
||||
my $preset = first { $_->name eq $self->printer_name } @{wxTheApp->presets->{printer}};
|
||||
if ($preset) {
|
||||
$preset->load_config;
|
||||
$preset->_dirty_config->set('serial_port', $self->{serial_port_combobox}->GetValue);
|
||||
$preset->_dirty_config->set('serial_speed', $self->{serial_speed_combobox}->GetValue);
|
||||
$preset->save([ 'serial_port', 'serial_speed' ]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$self->set_status("Connection failed. Check serial port and speed.");
|
||||
}
|
||||
@ -543,13 +555,22 @@ use Wx::Event qw(EVT_BUTTON EVT_TIMER EVT_ERASE_BACKGROUND);
|
||||
use base qw(Wx::Panel Class::Accessor);
|
||||
|
||||
__PACKAGE__->mk_accessors(qw(job on_delete_job on_print_job on_pause_print on_resume_print
|
||||
on_abort_print blink_timer));
|
||||
on_abort_print blink_timer duration queued));
|
||||
|
||||
sub new {
|
||||
my ($class, $parent, $job) = @_;
|
||||
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize);
|
||||
|
||||
# Estimate print duration
|
||||
{
|
||||
my $estimator = Slic3r::GCode::TimeEstimator->new;
|
||||
$estimator->parse_file($job->gcode_file);
|
||||
$self->duration($estimator->time);
|
||||
}
|
||||
|
||||
$self->job($job);
|
||||
$self->queued(scalar localtime);
|
||||
|
||||
$self->SetBackgroundColour(Wx::SystemSettings::GetColour(Wx::wxSYS_COLOUR_LISTBOX));
|
||||
|
||||
{
|
||||
@ -574,13 +595,18 @@ sub new {
|
||||
if ($job->printed) {
|
||||
$text->SetForegroundColour($Slic3r::GUI::grey);
|
||||
}
|
||||
$text->SetToolTipString("Queued on " . $self->queued)
|
||||
if $text->can('SetToolTipString');
|
||||
$left_sizer->Add($text, 0, wxEXPAND, 0);
|
||||
}
|
||||
{
|
||||
my $filament_stats = join "\n",
|
||||
my $stats = join "\n",
|
||||
map "$_ (" . sprintf("%.2f", $job->filament_stats->{$_}/1000) . "m)",
|
||||
sort keys %{$job->filament_stats};
|
||||
my $text = Wx::StaticText->new($self, -1, $filament_stats, wxDefaultPosition, wxDefaultSize);
|
||||
$stats .= sprintf "\nEstimated time: %d hours and %d minutes",
|
||||
int($self->duration/3600), int($self->duration/60) % 60;
|
||||
|
||||
my $text = Wx::StaticText->new($self, -1, $stats, wxDefaultPosition, wxDefaultSize);
|
||||
$text->SetFont($Slic3r::GUI::small_font);
|
||||
if ($job->printed && !$job->printing) {
|
||||
$text->SetForegroundColour($Slic3r::GUI::grey);
|
||||
|
@ -1775,8 +1775,7 @@ sub do_print {
|
||||
|
||||
my %current_presets = $self->selected_presets;
|
||||
|
||||
my $printer_name = $current_presets{printer}->[0]->name;
|
||||
my $printer_panel = $controller->add_printer($printer_name, $self->config);
|
||||
my $printer_panel = $controller->add_printer($current_presets{printer}->[0], $self->config);
|
||||
|
||||
my $filament_stats = $self->{print}->filament_stats;
|
||||
$filament_stats = { map { $current_presets{filament}[$_]->name => $filament_stats->{$_} } keys %$filament_stats };
|
||||
|
@ -203,6 +203,14 @@ sub _on_select_preset {
|
||||
# Get the selected name.
|
||||
my $preset = wxTheApp->presets->{$self->name}->[$self->{presets_choice}->GetSelection];
|
||||
|
||||
# If selection didn't change, do nothing.
|
||||
# (But still reset current_preset because it might contain an older object of the
|
||||
# current preset)
|
||||
if (defined $self->current_preset && $preset->name eq $self->current_preset->name) {
|
||||
$self->current_preset($preset);
|
||||
return;
|
||||
}
|
||||
|
||||
# If we have unsaved changes, prompt user.
|
||||
if (!$force && !$self->prompt_unsaved_changes) {
|
||||
# User decided not to save the current changes, so we restore the previous selection.
|
||||
@ -214,11 +222,6 @@ sub _on_select_preset {
|
||||
|
||||
$self->current_preset($preset);
|
||||
|
||||
# If selection didn't change, do nothing.
|
||||
# Only after resetting current_preset because it might contain an older object of the
|
||||
# current preset.
|
||||
return if defined $self->current_preset && $preset->name eq $self->current_preset->name;
|
||||
|
||||
# We reload presets in order to remove the "(modified)" suffix in case user was
|
||||
# prompted and chose to discard changes.
|
||||
$self->load_presets;
|
||||
|
Loading…
x
Reference in New Issue
Block a user