Add manual control to DLP projector too

This commit is contained in:
Alessandro Ranellucci 2015-11-19 17:31:47 +01:00
parent 128b2623cc
commit 2efc759a74
3 changed files with 31 additions and 5 deletions

View File

@ -14,11 +14,11 @@ __PACKAGE__->mk_accessors(qw(sender));
use constant TRAVEL_SPEED => 130*60; # TODO: make customizable?
sub new {
my ($class, $printer_panel) = @_;
my ($class, $parent, $config, $sender) = @_;
my $self = $class->SUPER::new($printer_panel, -1, "Manual Control", wxDefaultPosition,
my $self = $class->SUPER::new($parent, -1, "Manual Control", wxDefaultPosition,
[430,380], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
$self->sender($printer_panel->sender);
$self->sender($sender);
my $bed_sizer = Wx::FlexGridSizer->new(2, 3, 1, 1);
$bed_sizer->AddGrowableCol(1, 1);
@ -53,7 +53,7 @@ sub new {
# Bed canvas
{
my $bed_shape = $printer_panel->config->bed_shape;
my $bed_shape = $config->bed_shape;
$self->{canvas} = my $canvas = Slic3r::GUI::2DBed->new($self, $bed_shape);
$canvas->interactive(1);
$canvas->on_move(sub {

View File

@ -170,7 +170,8 @@ sub new {
$btn->Hide;
$left_sizer->Add($btn, 0, wxTOP, 15);
EVT_BUTTON($self, $btn, sub {
my $dlg = Slic3r::GUI::Controller::ManualControlDialog->new($self);
my $dlg = Slic3r::GUI::Controller::ManualControlDialog->new
($self, $self->config, $self->sender);
$dlg->ShowModal;
});
}

View File

@ -267,6 +267,30 @@ sub new {
my $buttons = Wx::BoxSizer->new(wxHORIZONTAL);
$sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
{
my $btn = $self->{btn_manual_control} = Wx::Button->new($self, -1, 'Manual Control', wxDefaultPosition, wxDefaultSize);
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new("$Slic3r::var/cog.png", wxBITMAP_TYPE_PNG));
}
$buttons->Add($btn, 0);
EVT_BUTTON($self, $btn, sub {
my $sender = Slic3r::GCode::Sender->new;
my $res = $sender->connect(
$self->config->serial_port,
$self->config->serial_speed,
);
if (!$res || !$sender->wait_connected) {
Slic3r::GUI::show_error(undef, "Connection failed. Check serial port and speed.");
return;
}
my $dlg = Slic3r::GUI::Controller::ManualControlDialog->new
($self, $self->config, $sender);
$dlg->ShowModal;
$sender->disconnect;
});
}
{
my $btn = $self->{btn_print} = Wx::Button->new($self, -1, 'Print', wxDefaultPosition, wxDefaultSize);
if ($Slic3r::GUI::have_button_icons) {
@ -346,6 +370,7 @@ sub _update_buttons {
my ($self) = @_;
my $is_printing = $self->controller->is_printing;
$self->{btn_manual_control}->Show(!$is_printing);
$self->{btn_print}->Show(!$is_printing);
$self->{btn_stop}->Show($is_printing);
$self->Layout;