mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-11 06:01:47 +08:00
Console for sending manual commands in manual printer control
This commit is contained in:
parent
6d371884a1
commit
f018c20a6d
@ -7,7 +7,7 @@ use utf8;
|
||||
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
use Slic3r::Geometry qw(PI X Y unscale);
|
||||
use Wx qw(:dialog :id :misc :sizer :choicebook :button :bitmap
|
||||
use Wx qw(:dialog :id :misc :sizer :choicebook :button :bitmap :textctrl
|
||||
wxBORDER_NONE wxTAB_TRAVERSAL);
|
||||
use Wx::Event qw(EVT_CLOSE EVT_BUTTON);
|
||||
use base qw(Wx::Dialog Class::Accessor);
|
||||
@ -107,7 +107,7 @@ sub new {
|
||||
|
||||
my $optgroup = Slic3r::GUI::OptionsGroup->new(
|
||||
parent => $self,
|
||||
title => 'Settings',
|
||||
title => 'Manual motion settings',
|
||||
on_change => sub {
|
||||
my ($opt_id, $value) = @_;
|
||||
$self->config2->{$opt_id} = $value;
|
||||
@ -133,53 +133,101 @@ sub new {
|
||||
));
|
||||
$optgroup->append_line($line);
|
||||
}
|
||||
my $left_sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$left_sizer->Add($bed_sizer, 1, wxEXPAND | wxALL, 10);
|
||||
$left_sizer->Add($optgroup->sizer, 0, wxEXPAND | wxALL, 10);
|
||||
|
||||
my $right_sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||
{
|
||||
my $line = $optgroup->create_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
|
||||
opt_id => 'temperature',
|
||||
type => 's',
|
||||
label => 'Temperature',
|
||||
default => '',
|
||||
sidetext => '°C',
|
||||
default => $self->config2->{temperature},
|
||||
));
|
||||
$line->append_button("Set", "tick.png", sub {
|
||||
if (!looks_like_number($self->config2->{temperature})) {
|
||||
Slic3r::GUI::show_error($self, "Invalid temperature.");
|
||||
return;
|
||||
}
|
||||
my $cmd = $self->writer->set_temperature($self->config2->{temperature});
|
||||
$self->sender->send($cmd, 1);
|
||||
});
|
||||
$optgroup->append_line($line);
|
||||
my $optgroup = Slic3r::GUI::OptionsGroup->new(
|
||||
parent => $self,
|
||||
title => 'Temperature',
|
||||
on_change => sub {
|
||||
my ($opt_id, $value) = @_;
|
||||
$self->config2->{$opt_id} = $value;
|
||||
},
|
||||
);
|
||||
$right_sizer->Add($optgroup->sizer, 0, wxEXPAND | wxALL, 10);
|
||||
{
|
||||
my $line = $optgroup->create_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
|
||||
opt_id => 'temperature',
|
||||
type => 's',
|
||||
label => 'Extruder',
|
||||
default => '',
|
||||
sidetext => '°C',
|
||||
default => $self->config2->{temperature},
|
||||
));
|
||||
$line->append_button("Set", "tick.png", sub {
|
||||
if (!looks_like_number($self->config2->{temperature})) {
|
||||
Slic3r::GUI::show_error($self, "Invalid temperature.");
|
||||
return;
|
||||
}
|
||||
my $cmd = $self->writer->set_temperature($self->config2->{temperature});
|
||||
$self->sender->send($cmd, 1);
|
||||
});
|
||||
$optgroup->append_line($line);
|
||||
}
|
||||
{
|
||||
my $line = $optgroup->create_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
|
||||
opt_id => 'bed_temperature',
|
||||
type => 's',
|
||||
label => 'Bed',
|
||||
default => '',
|
||||
sidetext => '°C',
|
||||
default => $self->config2->{bed_temperature},
|
||||
));
|
||||
$line->append_button("Set", "tick.png", sub {
|
||||
if (!looks_like_number($self->config2->{bed_temperature})) {
|
||||
Slic3r::GUI::show_error($self, "Invalid bed temperature.");
|
||||
return;
|
||||
}
|
||||
my $cmd = $self->writer->set_bed_temperature($self->config2->{bed_temperature});
|
||||
$self->sender->send($cmd, 1);
|
||||
});
|
||||
$optgroup->append_line($line);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
my $line = $optgroup->create_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
|
||||
opt_id => 'bed_temperature',
|
||||
type => 's',
|
||||
label => 'Bed Temperature',
|
||||
default => '',
|
||||
sidetext => '°C',
|
||||
default => $self->config2->{bed_temperature},
|
||||
));
|
||||
$line->append_button("Set", "tick.png", sub {
|
||||
if (!looks_like_number($self->config2->{bed_temperature})) {
|
||||
Slic3r::GUI::show_error($self, "Invalid bed temperature.");
|
||||
return;
|
||||
}
|
||||
my $cmd = $self->writer->set_bed_temperature($self->config2->{bed_temperature});
|
||||
$self->sender->send($cmd, 1);
|
||||
my $box = Wx::StaticBox->new($self, -1, "Console");
|
||||
my $sbsizer = Wx::StaticBoxSizer->new($box, wxVERTICAL);
|
||||
$right_sizer->Add($sbsizer, 1, wxEXPAND, 0);
|
||||
|
||||
my $log = $self->{log_textctrl} = Wx::TextCtrl->new($box, -1, "", wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_MULTILINE | wxBORDER_NONE);
|
||||
$log->SetBackgroundColour($box->GetBackgroundColour);
|
||||
$log->SetFont($Slic3r::GUI::small_font);
|
||||
$log->SetEditable(0);
|
||||
$sbsizer->Add($self->{log_textctrl}, 1, wxEXPAND, 0);
|
||||
|
||||
my $cmd_sizer = Wx::BoxSizer->new(wxHORIZONTAL);
|
||||
my $cmd_textctrl = Wx::TextCtrl->new($box, -1, '');
|
||||
$cmd_sizer->Add($cmd_textctrl, 1, wxEXPAND, 0);
|
||||
|
||||
my $btn = Wx::Button->new($box, -1,
|
||||
"Send", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
$btn->SetFont($Slic3r::GUI::small_font);
|
||||
if ($Slic3r::GUI::have_button_icons) {
|
||||
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("cog_go.png"), wxBITMAP_TYPE_PNG));
|
||||
}
|
||||
$cmd_sizer->Add($btn, 0, wxEXPAND | wxLEFT, 5);
|
||||
|
||||
EVT_BUTTON($box, $btn, sub {
|
||||
return if $cmd_textctrl->GetValue eq '';
|
||||
$self->sender->send($cmd_textctrl->GetValue, 1);
|
||||
$cmd_textctrl->SetValue('');
|
||||
});
|
||||
$optgroup->append_line($line);
|
||||
|
||||
$sbsizer->Add($cmd_sizer, 0, wxEXPAND | wxTOP, 2);
|
||||
}
|
||||
my $main_sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$main_sizer->Add($bed_sizer, 1, wxEXPAND | wxALL, 10);
|
||||
$main_sizer->Add($optgroup->sizer, 0, wxEXPAND | wxALL, 10);
|
||||
#$main_sizer->Add($self->CreateButtonSizer(wxCLOSE), 0, wxEXPAND);
|
||||
#EVT_BUTTON($self, wxID_CLOSE, sub { $self->Close });
|
||||
|
||||
my $main_sizer = Wx::BoxSizer->new(wxHORIZONTAL);
|
||||
$main_sizer->Add($left_sizer, 1, wxEXPAND | wxRIGHT, 10);
|
||||
$main_sizer->Add($right_sizer, 0, wxEXPAND, 0);
|
||||
|
||||
$self->SetSizer($main_sizer);
|
||||
$self->SetMinSize($self->GetSize);
|
||||
#$main_sizer->SetSizeHints($self);
|
||||
$main_sizer->SetSizeHints($self);
|
||||
$self->Layout;
|
||||
|
||||
# needed to actually free memory
|
||||
@ -191,6 +239,12 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub update_log {
|
||||
my ($self, $log) = @_;
|
||||
|
||||
$self->{log_textctrl}->SetValue($log);
|
||||
}
|
||||
|
||||
sub abs_xy_move {
|
||||
my ($self, $pos) = @_;
|
||||
|
||||
|
@ -44,6 +44,8 @@ sub new {
|
||||
}
|
||||
}
|
||||
$self->{log_textctrl}->AppendText("$_\n") for @{$self->sender->purge_log};
|
||||
$self->{manual_control_dialog}->update_log($self->{log_textctrl}->GetValue)
|
||||
if $self->{manual_control_dialog};
|
||||
{
|
||||
my $temp = $self->sender->getT;
|
||||
if ($temp eq '') {
|
||||
@ -176,9 +178,10 @@ sub new {
|
||||
$btn->Hide;
|
||||
$left_sizer->Add($btn, 0, wxTOP, 15);
|
||||
EVT_BUTTON($self, $btn, sub {
|
||||
my $dlg = Slic3r::GUI::Controller::ManualControlDialog->new
|
||||
$self->{manual_control_dialog} = my $dlg = Slic3r::GUI::Controller::ManualControlDialog->new
|
||||
($self, $self->config, $self->sender, $self->manual_control_config);
|
||||
$dlg->ShowModal;
|
||||
undef $self->{manual_control_dialog};
|
||||
});
|
||||
}
|
||||
|
||||
@ -285,7 +288,7 @@ sub _update_connection_controls {
|
||||
$self->{btn_manual_control}->Hide;
|
||||
$self->{btn_manual_control}->Disable;
|
||||
|
||||
if ($self->is_connected || 1) {
|
||||
if ($self->is_connected) {
|
||||
$self->{btn_connect}->Hide;
|
||||
$self->{btn_manual_control}->Show;
|
||||
if (!$self->printing || $self->printing->paused) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user