mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	WIP: Background processing is almost working now.
still PrintObject::_slice_volumes() needs some love to set the PrintObject matrices correctly.
This commit is contained in:
		
							parent
							
								
									ce7d196b43
								
							
						
					
					
						commit
						6c38cb2c32
					
				
					 8 changed files with 116 additions and 62 deletions
				
			
		|  | @ -132,6 +132,7 @@ bool BackgroundSlicingProcess::start() | |||
| 	if (! this->idle()) | ||||
| 		throw std::runtime_error("Cannot start a background task, the worker thread is not idle."); | ||||
| 	m_state = STATE_STARTED; | ||||
| 	m_print->set_cancel_callback([this](){ this->stop(); }); | ||||
| 	lck.unlock(); | ||||
| 	m_condition.notify_one(); | ||||
| 	return true; | ||||
|  | @ -151,9 +152,11 @@ bool BackgroundSlicingProcess::stop() | |||
| 		m_condition.wait(lck, [this](){ return m_state == STATE_CANCELED; }); | ||||
| 		// In the "Canceled" state. Reset the state to "Idle".
 | ||||
| 		m_state = STATE_IDLE; | ||||
| 		m_print->set_cancel_callback([](){}); | ||||
| 	} else if (m_state == STATE_FINISHED || m_state == STATE_CANCELED) { | ||||
| 		// In the "Finished" or "Canceled" state. Reset the state to "Idle".
 | ||||
| 		m_state = STATE_IDLE; | ||||
| 		m_print->set_cancel_callback([](){}); | ||||
| 	} | ||||
| //	this->m_export_path.clear();
 | ||||
| 	return true; | ||||
|  | @ -170,10 +173,10 @@ bool BackgroundSlicingProcess::apply_config(const DynamicPrintConfig &config) | |||
| 
 | ||||
| // Apply config over the print. Returns false, if the new config values caused any of the already
 | ||||
| // processed steps to be invalidated, therefore the task will need to be restarted.
 | ||||
| bool BackgroundSlicingProcess::apply(const Model &model, const DynamicPrintConfig &config) | ||||
| Print::ApplyStatus BackgroundSlicingProcess::apply(const Model &model, const DynamicPrintConfig &config) | ||||
| { | ||||
| 	this->stop(); | ||||
| 	bool invalidated = m_print->apply(model, config); | ||||
| //	this->stop();
 | ||||
| 	Print::ApplyStatus invalidated = m_print->apply(model, config); | ||||
| 	return invalidated; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -13,7 +13,6 @@ namespace Slic3r { | |||
| class DynamicPrintConfig; | ||||
| class GCodePreviewData; | ||||
| class Model; | ||||
| class Print; | ||||
| 
 | ||||
| // Print step IDs for keeping track of the print state.
 | ||||
| enum BackgroundSlicingProcessStep { | ||||
|  | @ -50,7 +49,7 @@ public: | |||
| 	bool apply_config(const DynamicPrintConfig &config); | ||||
| 	// Apply config over the print. Returns false, if the new config values caused any of the already
 | ||||
| 	// processed steps to be invalidated, therefore the task will need to be restarted.
 | ||||
| 	bool apply(const Model &model, const DynamicPrintConfig &config); | ||||
| 	Print::ApplyStatus apply(const Model &model, const DynamicPrintConfig &config); | ||||
| 	// Set the export path of the G-code.
 | ||||
| 	// Once the path is set, the G-code 
 | ||||
| 	void schedule_export(const std::string &path); | ||||
|  |  | |||
|  | @ -1647,35 +1647,32 @@ void Plater::priv::async_apply_config() | |||
|     this->q->model().update_print_volume_state(print_volume); | ||||
| 
 | ||||
|     // Apply new config to the possibly running background task.
 | ||||
|     bool was_running = this->background_process.running(); | ||||
|     bool invalidated = this->background_process.apply(this->q->model(), std::move(config)); | ||||
|     Print::ApplyStatus invalidated = this->background_process.apply(this->q->model(), std::move(config)); | ||||
|     // Just redraw the 3D canvas without reloading the scene to consume the update of the layer height profile.
 | ||||
|     if (Slic3r::_3DScene::is_layers_editing_enabled(this->canvas3D)) | ||||
|         this->canvas3D->Refresh(); | ||||
|     // If the apply_config caused the calculation to stop, or it was not running yet:
 | ||||
|     if (invalidated) { | ||||
|         if (was_running) { | ||||
|             // Hide the slicing results if the current slicing status is no more valid.
 | ||||
|             this->sidebar->show_info_sizers(false); | ||||
|         } | ||||
|         if (this->get_config("background_processing") == "1") | ||||
|             this->background_process.start(); | ||||
|         if (was_running) { | ||||
|             // Reset preview canvases. If the print has been invalidated, the preview canvases will be cleared.
 | ||||
|             // Otherwise they will be just refreshed.
 | ||||
|             this->gcode_preview_data.reset(); | ||||
|             if (this->preview != nullptr) | ||||
|                 this->preview->reload_print(); | ||||
|             // We also need to reload 3D scene because of the wipe tower preview box
 | ||||
|             if (this->config->opt_bool("wipe_tower")) { | ||||
| 
 | ||||
|     if (invalidated == Print::APPLY_STATUS_INVALIDATED) { | ||||
|         // Some previously calculated data on the Print was invalidated.
 | ||||
|         // Hide the slicing results, as the current slicing status is no more valid.
 | ||||
|         this->sidebar->show_info_sizers(false); | ||||
|         // Reset preview canvases. If the print has been invalidated, the preview canvases will be cleared.
 | ||||
|         // Otherwise they will be just refreshed.
 | ||||
|         this->gcode_preview_data.reset(); | ||||
|         if (this->preview != nullptr) | ||||
|             this->preview->reload_print(); | ||||
|         // We also need to reload 3D scene because of the wipe tower preview box
 | ||||
|         if (this->config->opt_bool("wipe_tower")) { | ||||
| #if !ENABLE_EXTENDED_SELECTION | ||||
|                 std::vector<int> selections = this->collect_selections(); | ||||
|                 Slic3r::_3DScene::set_objects_selections(this->canvas3D, selections); | ||||
|                 Slic3r::_3DScene::reload_scene(this->canvas3D, 1); | ||||
|             std::vector<int> selections = this->collect_selections(); | ||||
|             Slic3r::_3DScene::set_objects_selections(this->canvas3D, selections); | ||||
|             Slic3r::_3DScene::reload_scene(this->canvas3D, 1); | ||||
| #endif /* !ENABLE_EXTENDED_SELECTION */ | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     if (invalidated != Print::APPLY_STATUS_UNCHANGED && this->get_config("background_processing") == "1" && | ||||
|         this->print.num_object_instances() > 0) | ||||
|         this->background_process.start(); | ||||
| } | ||||
| 
 | ||||
| void Plater::priv::start_background_process() | ||||
|  | @ -1844,7 +1841,7 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt) | |||
|         this->statusbar()->set_status_text(message); | ||||
|     } | ||||
| 
 | ||||
|     //$self->print_info_box_show(1);
 | ||||
|     this->sidebar->show_info_sizers(false); | ||||
| 
 | ||||
|     // this updates buttons status
 | ||||
|     //$self->object_list_changed;
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 bubnikv
						bubnikv