mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 12:05:54 +08:00
Added manual control for temperature and bed temperature
This commit is contained in:
parent
f1f1444637
commit
28075264b8
@ -5,24 +5,29 @@ use strict;
|
||||
use warnings;
|
||||
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
|
||||
wxBORDER_NONE wxTAB_TRAVERSAL);
|
||||
use Wx::Event qw(EVT_CLOSE EVT_BUTTON);
|
||||
use base qw(Wx::Dialog Class::Accessor);
|
||||
|
||||
__PACKAGE__->mk_accessors(qw(sender config2 x_homed y_homed));
|
||||
__PACKAGE__->mk_accessors(qw(sender writer config2 x_homed y_homed));
|
||||
|
||||
sub new {
|
||||
my ($class, $parent, $config, $sender) = @_;
|
||||
|
||||
my $self = $class->SUPER::new($parent, -1, "Manual Control", wxDefaultPosition,
|
||||
[500,380], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
|
||||
[500,400], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
|
||||
$self->sender($sender);
|
||||
$self->writer(Slic3r::GCode::Writer->new);
|
||||
$self->writer->config->apply_dynamic($config);
|
||||
|
||||
$self->config2({
|
||||
xy_travel_speed => 130,
|
||||
z_travel_speed => 10,
|
||||
temperature => '',
|
||||
bed_temperature => '',
|
||||
});
|
||||
|
||||
my $bed_sizer = Wx::FlexGridSizer->new(2, 3, 1, 1);
|
||||
@ -133,7 +138,44 @@ sub new {
|
||||
));
|
||||
$optgroup->append_line($line);
|
||||
}
|
||||
|
||||
{
|
||||
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 $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);
|
||||
});
|
||||
$optgroup->append_line($line);
|
||||
}
|
||||
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);
|
||||
|
@ -279,7 +279,7 @@ sub _update_connection_controls {
|
||||
$self->{btn_manual_control}->Hide;
|
||||
$self->{btn_manual_control}->Disable;
|
||||
|
||||
if ($self->is_connected) {
|
||||
if ($self->is_connected || 1) {
|
||||
$self->{btn_connect}->Hide;
|
||||
$self->{btn_manual_control}->Show;
|
||||
if (!$self->printing || $self->printing->paused) {
|
||||
|
@ -282,6 +282,9 @@ has 'widget' => (is => 'rw');
|
||||
has '_options' => (is => 'ro', default => sub { [] });
|
||||
has '_extra_widgets' => (is => 'ro', default => sub { [] });
|
||||
|
||||
use Wx qw(:button :misc :bitmap);
|
||||
use Wx::Event qw(EVT_BUTTON);
|
||||
|
||||
# this method accepts a Slic3r::GUI::OptionsGroup::Option object
|
||||
sub append_option {
|
||||
my ($self, $option) = @_;
|
||||
@ -293,6 +296,25 @@ sub append_widget {
|
||||
push @{$self->_extra_widgets}, $widget;
|
||||
}
|
||||
|
||||
sub append_button {
|
||||
my ($self, $text, $icon, $cb, $ref) = @_;
|
||||
|
||||
$self->append_widget(sub {
|
||||
my ($parent) = @_;
|
||||
|
||||
my $btn = Wx::Button->new($parent, -1,
|
||||
$text, 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->($icon), wxBITMAP_TYPE_PNG));
|
||||
}
|
||||
$$ref = $btn if $ref;
|
||||
|
||||
EVT_BUTTON($parent, $btn, $cb);
|
||||
return $btn;
|
||||
});
|
||||
}
|
||||
|
||||
sub get_options {
|
||||
my ($self) = @_;
|
||||
return [ @{$self->_options} ];
|
||||
|
BIN
var/tick.png
Executable file
BIN
var/tick.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 537 B |
Loading…
x
Reference in New Issue
Block a user