mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Merge branch 'octoprint'
This commit is contained in:
		
						commit
						4a90ab1f6a
					
				
					 15 changed files with 978 additions and 56 deletions
				
			
		|  | @ -174,7 +174,6 @@ sub _init_tabpanel { | |||
|     EVT_COMMAND($self, -1, $BUTTON_BROWSE_EVENT, sub { | ||||
|         my ($self, $event) = @_; | ||||
|         my $msg = $event->GetString; | ||||
|         print "BUTTON_BROWSE_EVENT: ", $msg, "\n"; | ||||
| 
 | ||||
|         # look for devices | ||||
|         my $entries; | ||||
|  | @ -197,7 +196,6 @@ sub _init_tabpanel { | |||
|     EVT_COMMAND($self, -1, $BUTTON_TEST_EVENT, sub { | ||||
|         my ($self, $event) = @_; | ||||
|         my $msg = $event->GetString; | ||||
|         print "BUTTON_TEST_EVENT: ", $msg, "\n"; | ||||
| 
 | ||||
|         my $ua = LWP::UserAgent->new; | ||||
|         $ua->timeout(10); | ||||
|  | @ -409,7 +407,7 @@ sub _init_menubar { | |||
|             wxTheApp->about; | ||||
|         }); | ||||
|     } | ||||
|      | ||||
| 
 | ||||
|     # menubar | ||||
|     # assign menubar to frame after appending items, otherwise special items | ||||
|     # will not be handled correctly | ||||
|  | @ -424,6 +422,7 @@ sub _init_menubar { | |||
|         # (Select application language from the list of installed languages) | ||||
|         Slic3r::GUI::add_debug_menu($menubar, $self->{lang_ch_event}); | ||||
|         $menubar->Append($helpMenu, L("&Help")); | ||||
|         # Add an optional debug menu. In production code, the add_debug_menu() call should do nothing. | ||||
|         $self->SetMenuBar($menubar); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -52,7 +52,7 @@ sub new { | |||
|     my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); | ||||
|     $self->{config} = Slic3r::Config::new_from_defaults_keys([qw( | ||||
|         bed_shape complete_objects extruder_clearance_radius skirts skirt_distance brim_width variable_layer_height | ||||
|         serial_port serial_speed octoprint_host octoprint_apikey | ||||
|         serial_port serial_speed octoprint_host octoprint_apikey octoprint_cafile | ||||
|         nozzle_diameter single_extruder_multi_material  | ||||
|         wipe_tower wipe_tower_x wipe_tower_y wipe_tower_width wipe_tower_per_color_wipe extruder_colour filament_colour | ||||
|     )]); | ||||
|  | @ -1458,8 +1458,13 @@ sub on_export_completed { | |||
|     wxTheApp->notify($message); | ||||
|      | ||||
|     $self->do_print if $do_print; | ||||
| 
 | ||||
|     # Send $self->{send_gcode_file} to OctoPrint. | ||||
|     $self->send_gcode if $send_gcode; | ||||
|     if ($send_gcode) { | ||||
|         my $op = Slic3r::OctoPrint->new($self->{config}); | ||||
|         $op->send_gcode($self->GetId(), $PROGRESS_BAR_EVENT, $ERROR_EVENT, $self->{send_gcode_file}); | ||||
|     } | ||||
| 
 | ||||
|     $self->{print_file} = undef; | ||||
|     $self->{send_gcode_file} = undef; | ||||
|     $self->{"print_info_cost"}->SetLabel(sprintf("%.2f" , $self->{print}->total_cost)); | ||||
|  | @ -1488,45 +1493,6 @@ sub do_print { | |||
|     my $filament_names = wxTheApp->{preset_bundle}->filament_presets; | ||||
|     $filament_stats = { map { $filament_names->[$_] => $filament_stats->{$_} } keys %$filament_stats }; | ||||
|     $printer_panel->load_print_job($self->{print_file}, $filament_stats); | ||||
|      | ||||
|     $self->GetFrame->select_tab(1); | ||||
| } | ||||
| 
 | ||||
| # Send $self->{send_gcode_file} to OctoPrint. | ||||
| #FIXME Currently this call blocks the UI. Make it asynchronous. | ||||
| sub send_gcode { | ||||
|     my ($self) = @_; | ||||
|      | ||||
|     $self->statusbar->StartBusy; | ||||
|      | ||||
|     my $ua = LWP::UserAgent->new; | ||||
|     $ua->timeout(180); | ||||
|      | ||||
|     my $res = $ua->post( | ||||
|         "http://" . $self->{config}->octoprint_host . "/api/files/local", | ||||
|         Content_Type => 'form-data', | ||||
|         'X-Api-Key' => $self->{config}->octoprint_apikey, | ||||
|         Content => [ | ||||
|             file => [  | ||||
|                 # On Windows, the path has to be encoded in local code page for perl to be able to open it. | ||||
|                 Slic3r::encode_path($self->{send_gcode_file}), | ||||
|                 # Remove the UTF-8 flag from the perl string, so the LWP::UserAgent can insert  | ||||
|                 # the UTF-8 encoded string into the request as a byte stream. | ||||
|                 Slic3r::path_to_filename_raw($self->{send_gcode_file}) | ||||
|             ], | ||||
|             print => $self->{send_gcode_file_print} ? 1 : 0, | ||||
|         ], | ||||
|     ); | ||||
|      | ||||
|     $self->statusbar->StopBusy; | ||||
|      | ||||
|     if ($res->is_success) { | ||||
|         $self->statusbar->SetStatusText(L("G-code file successfully uploaded to the OctoPrint server")); | ||||
|     } else { | ||||
|         my $message = L("Error while uploading to the OctoPrint server: ") . $res->status_line; | ||||
|         Slic3r::GUI::show_error($self, $message); | ||||
|         $self->statusbar->SetStatusText($message); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| sub export_stl { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 bubnikv
						bubnikv