mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 20:51:12 -06:00 
			
		
		
		
	ENH: support thumbnail in gcode for 3rd printers
Thanks @slynn1324 1. Add thumbnail size in printer params page 2. Optimize writing thumbnail data in gcode jira:STUDIO-3942 Github: #2166 Github pull request: #2333 Change-Id: I6897cfddfa6a1b0c95decf67329a486d40ec0cc2
This commit is contained in:
		
							parent
							
								
									d01a94c9f7
								
							
						
					
					
						commit
						105eda5238
					
				
					 11 changed files with 41 additions and 20 deletions
				
			
		|  | @ -1293,16 +1293,13 @@ namespace DoExport { | |||
| 	                    output((boost::format("; thumbnail begin %dx%d %d\n") % data.width % data.height % encoded.size()).str().c_str()); | ||||
| 
 | ||||
| 	                    unsigned int row_count = 0; | ||||
| 	                    while (encoded.size() > max_row_length) | ||||
| 	                    { | ||||
| 	                        output((boost::format("; %s\n") % encoded.substr(0, max_row_length)).str().c_str()); | ||||
| 	                        encoded = encoded.substr(max_row_length); | ||||
| 	                    //BBS: optimize performance ,reduce too much memeory operation 
 | ||||
| 	                    size_t current_index = 0; | ||||
| 	                    while(current_index<encoded.size()){ | ||||
| 	                        output((boost::format("; %s\n") % encoded.substr(current_index, max_row_length)).str().c_str()); | ||||
| 	                        current_index+=std::min(max_row_length,encoded.size()-current_index); | ||||
| 	                        ++row_count; | ||||
| 	                    } | ||||
| 
 | ||||
| 	                    if (encoded.size() > 0) | ||||
| 	                    	output((boost::format("; %s\n") % encoded).str().c_str()); | ||||
| 
 | ||||
| 	                    output("; thumbnail end\n"); | ||||
|                         output("; THUMBNAIL_BLOCK_END\n\n"); | ||||
| 
 | ||||
|  | @ -1563,10 +1560,11 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato | |||
|     } | ||||
| 
 | ||||
|     //BBS: add plate id into thumbnail render logic
 | ||||
|     //DoExport::export_thumbnails_to_file(thumbnail_cb, print.get_plate_index(), THUMBNAIL_SIZE,
 | ||||
|     //    [&file](const char* sz) { file.write(sz); },
 | ||||
|     //    [&print]() { print.throw_if_canceled(); });
 | ||||
| 
 | ||||
|     if(!print.is_BBL_Printer()){ | ||||
|         DoExport::export_thumbnails_to_file(thumbnail_cb, print.get_plate_index(), print.full_print_config().option<ConfigOptionPoints>("thumbnail_size")->values, | ||||
|             [&file](const char* sz) { file.write(sz); }, | ||||
|             [&print]() { print.throw_if_canceled(); }); | ||||
|     } | ||||
| 
 | ||||
|     // Write some terse information on the slicing parameters.
 | ||||
|     const PrintObject *first_object         = print.objects().front(); | ||||
|  |  | |||
|  | @ -852,7 +852,7 @@ static std::vector<std::string> s_Preset_printer_options { | |||
|     "silent_mode", | ||||
|     // BBS
 | ||||
|     "scan_first_layer", "machine_load_filament_time", "machine_unload_filament_time", "machine_pause_gcode", "template_custom_gcode", | ||||
|     "nozzle_type","auxiliary_fan", "nozzle_volume","upward_compatible_machine", "z_hop_types","support_chamber_temp_control","support_air_filtration","printer_structure", | ||||
|     "nozzle_type","auxiliary_fan", "nozzle_volume","upward_compatible_machine", "z_hop_types","support_chamber_temp_control","support_air_filtration","printer_structure","thumbnail_size", | ||||
|     //OrcaSlicer
 | ||||
|     "host_type", "print_host", "printhost_apikey", | ||||
|     "print_host_webui", | ||||
|  | @ -2365,7 +2365,7 @@ inline t_config_option_keys deep_diff(const ConfigBase &config_this, const Confi | |||
|         if (this_opt != nullptr && other_opt != nullptr && *this_opt != *other_opt) | ||||
|         { | ||||
|             //BBS: add bed_exclude_area
 | ||||
|             if (opt_key == "printable_area" || opt_key == "bed_exclude_area" || opt_key == "compatible_prints" || opt_key == "compatible_printers") { | ||||
|             if (opt_key == "printable_area" || opt_key == "bed_exclude_area" || opt_key == "compatible_prints" || opt_key == "compatible_printers"|| opt_key == "thumbnail_size") { | ||||
|                 // Scalar variable, or a vector variable, which is independent from number of extruders,
 | ||||
|                 // thus the vector is presented to the user as a single input.
 | ||||
|                 diff.emplace_back(opt_key); | ||||
|  |  | |||
|  | @ -88,7 +88,7 @@ PresetBundle::PresetBundle() | |||
|     for (size_t i = 0; i < 1; ++i) { | ||||
|         // The following ugly switch is to avoid printers.preset(0) to return the edited instance, as the 0th default is the current one.
 | ||||
|         Preset &preset = this->printers.default_preset(i); | ||||
|         for (const char *key : {"printer_settings_id", "printer_model", "printer_variant"}) preset.config.optptr(key, true); | ||||
|         for (const char *key : {"printer_settings_id", "printer_model", "printer_variant","thumbnail_size"}) preset.config.optptr(key, true); | ||||
|         //if (i == 0) {
 | ||||
|             preset.config.optptr("default_print_profile", true); | ||||
|             preset.config.option<ConfigOptionStrings>("default_filament_profile", true); | ||||
|  |  | |||
|  | @ -76,6 +76,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n | |||
|         "printable_area", | ||||
|         //BBS: add bed_exclude_area
 | ||||
|         "bed_exclude_area", | ||||
|         "thumbnail_size", | ||||
|         "before_layer_change_gcode", | ||||
|         "enable_pressure_advance", | ||||
|         "pressure_advance", | ||||
|  |  | |||
|  | @ -1708,6 +1708,15 @@ void PrintConfigDef::init_fff_params() | |||
|     def->tooltip = L("Enable this to enable the camera on printer to check the quality of first layer"); | ||||
|     def->mode = comDevelop; | ||||
|     def->set_default_value(new ConfigOptionBool(false)); | ||||
| 
 | ||||
|     // BBS
 | ||||
|     def = this->add("thumbnail_size", coPoints); | ||||
|     def->label = L("Thumbnail size"); | ||||
|     def->tooltip = L("Decides the size of thumbnail stored in gcode files"); | ||||
|     def->mode = comDevelop; | ||||
|     def->gui_type = ConfigOptionDef::GUIType::one_string; | ||||
|     def->set_default_value(new ConfigOptionPoints{ Vec2d(50,50) }); | ||||
| 
 | ||||
|     //BBS
 | ||||
|     // def = this->add("spaghetti_detector", coBool);
 | ||||
|     // def->label = L("Enable spaghetti detector");
 | ||||
|  |  | |||
|  | @ -851,6 +851,7 @@ PRINT_CONFIG_CLASS_DEFINE( | |||
|     ((ConfigOptionFloats,              filament_minimal_purge_on_wipe_tower)) | ||||
|     // BBS
 | ||||
|     ((ConfigOptionBool,                scan_first_layer)) | ||||
|     ((ConfigOptionPoints,              thumbnail_size)) | ||||
|     // ((ConfigOptionBool,                spaghetti_detector))
 | ||||
|     ((ConfigOptionBool,                gcode_add_line_number)) | ||||
|     ((ConfigOptionBool,                bbl_bed_temperature_gcode)) | ||||
|  |  | |||
|  | @ -274,7 +274,7 @@ void BackgroundSlicingProcess::process_sla() | |||
| 
 | ||||
| 			//BBS: add plate id for thumbnail generation
 | ||||
|             ThumbnailsList thumbnails = this->render_thumbnails( | ||||
| 				ThumbnailsParams{ THUMBNAIL_SIZE, true, true, true, true, 0 }); | ||||
| 				ThumbnailsParams{ current_print()->full_print_config().option<ConfigOptionPoints>("thumbnail_size")->values, true, true, true, true, 0 }); | ||||
| 
 | ||||
|             Zipper zipper(export_path); | ||||
|             m_sla_archive.export_print(zipper, *m_sla_print);																											         // true, false, true, true); // renders also supports and pad
 | ||||
|  | @ -859,7 +859,7 @@ void BackgroundSlicingProcess::prepare_upload() | |||
|     } else { | ||||
|         m_upload_job.upload_data.upload_path = m_sla_print->print_statistics().finalize_output_path(m_upload_job.upload_data.upload_path.string()); | ||||
|         ThumbnailsList thumbnails = this->render_thumbnails( | ||||
| 			ThumbnailsParams{current_print()->full_print_config().option<ConfigOptionPoints>("thumbnails")->values, true, true, true, true}); | ||||
| 			ThumbnailsParams{current_print()->full_print_config().option<ConfigOptionPoints>("thumbnail_size")->values, true, true, true, true}); | ||||
| 																												 // true, false, true, true); // renders also supports and pad
 | ||||
|         Zipper zipper{source_path.string()}; | ||||
|         m_sla_archive.export_print(zipper, *m_sla_print, m_upload_job.upload_data.upload_path.string()); | ||||
|  |  | |||
|  | @ -199,7 +199,7 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt | |||
| 			} | ||||
| 			break; | ||||
| 		case coPoints:{ | ||||
| 			if (opt_key == "printable_area" || opt_key == "bed_exclude_area") { | ||||
| 			if (opt_key == "printable_area" || opt_key == "bed_exclude_area" || opt_key=="thumbnail_size") { | ||||
| 				config.option<ConfigOptionPoints>(opt_key)->values = boost::any_cast<std::vector<Vec2d>>(value); | ||||
| 				break; | ||||
| 			} | ||||
|  |  | |||
|  | @ -1036,6 +1036,8 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config | |||
| 		if (opt_key == "printable_area") | ||||
| 			ret = config.option<ConfigOptionPoints>(opt_key)->values; | ||||
|         else if (opt_key == "bed_exclude_area") | ||||
|             ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values); | ||||
|         else if (opt_key == "thumbnail_size") | ||||
|             ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values); | ||||
| 		else | ||||
| 			ret = config.option<ConfigOptionPoints>(opt_key)->get_at(idx); | ||||
|  | @ -1147,6 +1149,8 @@ boost::any ConfigOptionsGroup::get_config_value2(const DynamicPrintConfig& confi | |||
|             ret = config.option<ConfigOptionPoints>(opt_key)->values; | ||||
|         else if (opt_key == "bed_exclude_area") | ||||
|             ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values); | ||||
|         else if (opt_key == "thumbnail_size") | ||||
|             ret = get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values); | ||||
|         else | ||||
|             ret = config.option<ConfigOptionPoints>(opt_key)->get_at(idx); | ||||
|         break; | ||||
|  |  | |||
|  | @ -860,7 +860,7 @@ void TabPrinter::init_options_list() | |||
| 
 | ||||
|     for (const std::string& opt_key : m_config->keys()) | ||||
|     { | ||||
|         if (opt_key == "printable_area" || opt_key == "bed_exclude_area") { | ||||
|         if (opt_key == "printable_area" || opt_key == "bed_exclude_area"|| opt_key=="thumbnail_size") { | ||||
|             m_options_list.emplace(opt_key, m_opt_status_value); | ||||
|             continue; | ||||
|         } | ||||
|  | @ -3090,6 +3090,11 @@ void TabPrinter::build_fff() | |||
|         optgroup = page->new_optgroup(L("Advanced"), L"param_advanced"); | ||||
|         optgroup->append_single_option_line("printer_structure"); | ||||
|         optgroup->append_single_option_line("gcode_flavor"); | ||||
| 
 | ||||
|         option =optgroup->get_option("thumbnail_size"); | ||||
|         option.opt.full_width=true; | ||||
|         optgroup->append_single_option_line(option); | ||||
| 
 | ||||
|         optgroup->append_single_option_line("scan_first_layer"); | ||||
|         optgroup->append_single_option_line("use_relative_e_distances"); | ||||
|         // optgroup->append_single_option_line("spaghetti_detector");
 | ||||
|  | @ -3660,6 +3665,7 @@ void TabPrinter::toggle_options() | |||
|         toggle_option("single_extruder_multi_material", have_multiple_extruders); | ||||
|         //BBS: gcode_flavore of BBL printer can't be edited and changed
 | ||||
|         toggle_option("gcode_flavor", !is_BBL_printer); | ||||
|         toggle_option("thumbnail_size",!is_BBL_printer); | ||||
|         toggle_option("printer_structure", !is_BBL_printer); | ||||
|         toggle_option("use_relative_e_distances", !is_BBL_printer); | ||||
| 
 | ||||
|  |  | |||
|  | @ -1359,7 +1359,9 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig& | |||
|         else if (opt_key == "bed_exclude_area") { | ||||
|             return get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values); | ||||
|         } | ||||
| 
 | ||||
|         else if (opt_key == "thumbnail_size") { | ||||
|             return get_thumbnails_string(config.option<ConfigOptionPoints>(opt_key)->values); | ||||
|         } | ||||
|         Vec2d val = config.opt<ConfigOptionPoints>(opt_key)->get_at(opt_idx); | ||||
|         return from_u8((boost::format("[%1%]") % ConfigOptionPoint(val).serialize()).str()); | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 slynn1324
						slynn1324