mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 20:51:12 -06:00 
			
		
		
		
	Fix of Add option to change support interface pattern #1197
New config field for switching the support interface pattern between default (rectilinear for non-soluble interface, concentric for soluble interface), explicit rectilinear and explicit concentric. Also the config layer was reworked a bit to reduce some switch statements on ConfigOptionEnum<> templates.
This commit is contained in:
		
							parent
							
								
									88bd189047
								
							
						
					
					
						commit
						61a5b43ac3
					
				
					 13 changed files with 66 additions and 70 deletions
				
			
		|  | @ -279,7 +279,8 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config) | |||
|     bool have_support_interface = config->opt_int("support_material_interface_layers") > 0; | ||||
|     bool have_support_soluble = have_support_material && config->opt_float("support_material_contact_distance") == 0; | ||||
|     for (auto el : { "support_material_pattern", "support_material_with_sheath", | ||||
|                     "support_material_spacing", "support_material_angle", "support_material_interface_layers", | ||||
|                     "support_material_spacing", "support_material_angle",  | ||||
|                     "support_material_interface_pattern", "support_material_interface_layers", | ||||
|                     "dont_support_bridges", "support_material_extrusion_width", "support_material_contact_distance", | ||||
|                     "support_material_xy_spacing" }) | ||||
|         toggle_field(el, have_support_material); | ||||
|  |  | |||
|  | @ -1210,6 +1210,8 @@ boost::any& Choice::get_value() | |||
| 			m_value = static_cast<MachineLimitsUsage>(ret_enum); | ||||
| 		else if (m_opt_id.compare("support_material_pattern") == 0) | ||||
| 			m_value = static_cast<SupportMaterialPattern>(ret_enum); | ||||
|         else if (m_opt_id.compare("support_material_interface_pattern") == 0) | ||||
|             m_value = static_cast<SupportMaterialInterfacePattern>(ret_enum); | ||||
| 		else if (m_opt_id.compare("seam_position") == 0) | ||||
| 			m_value = static_cast<SeamPosition>(ret_enum); | ||||
| 		else if (m_opt_id.compare("host_type") == 0) | ||||
|  |  | |||
|  | @ -104,7 +104,8 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt | |||
|             return; | ||||
|         } | ||||
| 
 | ||||
| 		switch (config.def()->get(opt_key)->type) { | ||||
|         const ConfigOptionDef *opt_def = config.def()->get(opt_key); | ||||
| 		switch (opt_def->type) { | ||||
| 		case coFloatOrPercent:{ | ||||
| 			std::string str = boost::any_cast<std::string>(value); | ||||
| 			bool percent = false; | ||||
|  | @ -176,6 +177,11 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt | |||
| 			} | ||||
| 			break; | ||||
| 		case coEnum:{ | ||||
| #if 0 | ||||
| 			auto *opt = opt_def->default_value.get()->clone(); | ||||
| 			opt->setInt(0); | ||||
| 			config.set_key_value(opt_key, opt); | ||||
| #else | ||||
| 			if (opt_key == "top_fill_pattern" || | ||||
| 				opt_key == "bottom_fill_pattern" || | ||||
| 				opt_key == "fill_pattern") | ||||
|  | @ -190,6 +196,8 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt | |||
| 				config.set_key_value(opt_key, new ConfigOptionEnum<MachineLimitsUsage>(boost::any_cast<MachineLimitsUsage>(value))); | ||||
| 			else if (opt_key.compare("support_material_pattern") == 0) | ||||
| 				config.set_key_value(opt_key, new ConfigOptionEnum<SupportMaterialPattern>(boost::any_cast<SupportMaterialPattern>(value))); | ||||
| 			else if (opt_key.compare("support_material_interface_pattern") == 0) | ||||
| 				config.set_key_value(opt_key, new ConfigOptionEnum<SupportMaterialInterfacePattern>(boost::any_cast<SupportMaterialInterfacePattern>(value))); | ||||
| 			else if (opt_key.compare("seam_position") == 0) | ||||
| 				config.set_key_value(opt_key, new ConfigOptionEnum<SeamPosition>(boost::any_cast<SeamPosition>(value))); | ||||
| 			else if (opt_key.compare("host_type") == 0) | ||||
|  | @ -203,6 +211,7 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt | |||
|             else if(opt_key == "brim_type") | ||||
|                 config.set_key_value(opt_key, new ConfigOptionEnum<BrimType>(boost::any_cast<BrimType>(value))); | ||||
| 			} | ||||
| #endif | ||||
| 			break; | ||||
| 		case coPoints:{ | ||||
| 			if (opt_key == "bed_shape" || opt_key == "thumbnails") { | ||||
|  |  | |||
|  | @ -35,7 +35,7 @@ static SettingsBundle FREQ_SETTINGS_BUNDLE_FFF = | |||
|     { L("Layers and Perimeters"), { "layer_height" , "perimeters", "top_solid_layers", "bottom_solid_layers" } }, | ||||
|     { L("Infill")               , { "fill_density", "fill_pattern" } }, | ||||
|     { L("Support material")     , { "support_material", "support_material_auto", "support_material_threshold",  | ||||
|                                     "support_material_pattern", "support_material_buildplate_only", | ||||
|                                     "support_material_pattern", "support_material_interface_pattern", "support_material_buildplate_only", | ||||
|                                     "support_material_spacing" } }, | ||||
|     { L("Wipe options")            , { "wipe_into_infill", "wipe_into_objects" } } | ||||
| }; | ||||
|  |  | |||
|  | @ -860,46 +860,8 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config | |||
| 	case coInts: | ||||
| 		ret = config.opt_int(opt_key, idx); | ||||
| 		break; | ||||
| 	case coEnum:{ | ||||
| 		if (opt_key == "top_fill_pattern" || | ||||
| 			opt_key == "bottom_fill_pattern" || | ||||
| 			opt_key == "fill_pattern" ) { | ||||
| 			ret = static_cast<int>(config.option<ConfigOptionEnum<InfillPattern>>(opt_key)->value); | ||||
| 		} | ||||
| 		else if (opt_key == "ironing_type") { | ||||
| 			ret = static_cast<int>(config.option<ConfigOptionEnum<IroningType>>(opt_key)->value); | ||||
| 		} | ||||
|         else if (opt_key == "fuzzy_skin") { | ||||
|             ret = static_cast<int>(config.option<ConfigOptionEnum<FuzzySkinType>>(opt_key)->value); | ||||
|         } | ||||
| 		else if (opt_key == "gcode_flavor") { | ||||
| 			ret = static_cast<int>(config.option<ConfigOptionEnum<GCodeFlavor>>(opt_key)->value); | ||||
| 		} | ||||
| 		else if (opt_key == "machine_limits_usage") { | ||||
| 			ret = static_cast<int>(config.option<ConfigOptionEnum<MachineLimitsUsage>>(opt_key)->value); | ||||
| 		} | ||||
| 		else if (opt_key == "support_material_pattern") { | ||||
| 			ret = static_cast<int>(config.option<ConfigOptionEnum<SupportMaterialPattern>>(opt_key)->value); | ||||
| 		} | ||||
| 		else if (opt_key == "seam_position") { | ||||
| 			ret = static_cast<int>(config.option<ConfigOptionEnum<SeamPosition>>(opt_key)->value); | ||||
| 		} | ||||
| 		else if (opt_key == "host_type") { | ||||
| 			ret = static_cast<int>(config.option<ConfigOptionEnum<PrintHostType>>(opt_key)->value); | ||||
| 		} | ||||
|         else if (opt_key == "display_orientation") { | ||||
|             ret  = static_cast<int>(config.option<ConfigOptionEnum<SLADisplayOrientation>>(opt_key)->value); | ||||
|         } | ||||
|         else if (opt_key == "support_pillar_connection_mode") { | ||||
|             ret  = static_cast<int>(config.option<ConfigOptionEnum<SLAPillarConnectionMode>>(opt_key)->value); | ||||
|         } | ||||
|         else if (opt_key == "printhost_authorization_type") { | ||||
|             ret  = static_cast<int>(config.option<ConfigOptionEnum<AuthorizationType>>(opt_key)->value); | ||||
|         } | ||||
|         else if (opt_key == "brim_type") { | ||||
|             ret  = static_cast<int>(config.option<ConfigOptionEnum<BrimType>>(opt_key)->value); | ||||
| 		} | ||||
| 	} | ||||
| 	case coEnum: | ||||
|         ret = config.option(opt_key)->getInt(); | ||||
| 		break; | ||||
| 	case coPoints: | ||||
| 		if (opt_key == "bed_shape") | ||||
|  |  | |||
|  | @ -1511,6 +1511,7 @@ void TabPrint::build() | |||
|         optgroup->append_single_option_line("support_material_spacing", category_path + "pattern-spacing-0-inf"); | ||||
|         optgroup->append_single_option_line("support_material_angle", category_path + "pattern-angle"); | ||||
|         optgroup->append_single_option_line("support_material_interface_layers", category_path + "interface-layers"); | ||||
|         optgroup->append_single_option_line("support_material_interface_pattern", category_path + "interface-pattern"); | ||||
|         optgroup->append_single_option_line("support_material_interface_spacing", category_path + "interface-pattern-spacing"); | ||||
|         optgroup->append_single_option_line("support_material_interface_contact_loops", category_path + "interface-loops"); | ||||
|         optgroup->append_single_option_line("support_material_buildplate_only", category_path + "support-on-build-plate-only"); | ||||
|  |  | |||
|  | @ -986,18 +986,17 @@ bool UnsavedChangesDialog::save(PresetCollection* dependent_presets) | |||
|     return true; | ||||
| } | ||||
| 
 | ||||
| template<class T> | ||||
| wxString get_string_from_enum(const std::string& opt_key, const DynamicPrintConfig& config, bool is_infill = false) | ||||
| { | ||||
|     const ConfigOptionDef& def = config.def()->options.at(opt_key); | ||||
|     const std::vector<std::string>& names = def.enum_labels;//ConfigOptionEnum<T>::get_enum_names();
 | ||||
|     T val = config.option<ConfigOptionEnum<T>>(opt_key)->value; | ||||
|     int val = config.option(opt_key)->getInt(); | ||||
| 
 | ||||
|     // Each infill doesn't use all list of infill declared in PrintConfig.hpp.
 | ||||
|     // So we should "convert" val to the correct one
 | ||||
|     if (is_infill) { | ||||
|         for (auto key_val : *def.enum_keys_map) | ||||
|             if ((int)key_val.second == (int)val) { | ||||
|             if (int(key_val.second) == val) { | ||||
|                 auto it = std::find(def.enum_values.begin(), def.enum_values.end(), key_val.first); | ||||
|                 if (it == def.enum_values.end()) | ||||
|                     return ""; | ||||
|  | @ -1005,7 +1004,7 @@ wxString get_string_from_enum(const std::string& opt_key, const DynamicPrintConf | |||
|             } | ||||
|         return _L("Undef"); | ||||
|     } | ||||
|     return from_u8(_utf8(names[static_cast<int>(val)])); | ||||
|     return from_u8(_utf8(names[val])); | ||||
| } | ||||
| 
 | ||||
| static size_t get_id_from_opt_key(std::string opt_key) | ||||
|  | @ -1128,27 +1127,10 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig& | |||
|         return out; | ||||
|     } | ||||
|     case coEnum: { | ||||
|         if (opt_key == "top_fill_pattern" || | ||||
|         return get_string_from_enum(opt_key, config,  | ||||
|             opt_key == "top_fill_pattern" || | ||||
|             opt_key == "bottom_fill_pattern" || | ||||
|             opt_key == "fill_pattern") | ||||
|             return get_string_from_enum<InfillPattern>(opt_key, config, true); | ||||
|         if (opt_key == "gcode_flavor") | ||||
|             return get_string_from_enum<GCodeFlavor>(opt_key, config); | ||||
|         if (opt_key == "machine_limits_usage") | ||||
|             return get_string_from_enum<MachineLimitsUsage>(opt_key, config); | ||||
|         if (opt_key == "ironing_type") | ||||
|             return get_string_from_enum<IroningType>(opt_key, config); | ||||
|         if (opt_key == "support_material_pattern") | ||||
|             return get_string_from_enum<SupportMaterialPattern>(opt_key, config); | ||||
|         if (opt_key == "seam_position") | ||||
|             return get_string_from_enum<SeamPosition>(opt_key, config); | ||||
|         if (opt_key == "display_orientation") | ||||
|             return get_string_from_enum<SLADisplayOrientation>(opt_key, config); | ||||
|         if (opt_key == "support_pillar_connection_mode") | ||||
|             return get_string_from_enum<SLAPillarConnectionMode>(opt_key, config); | ||||
|         if (opt_key == "brim_type") | ||||
|             return get_string_from_enum<BrimType>(opt_key, config); | ||||
|         break; | ||||
|             opt_key == "fill_pattern"); | ||||
|     } | ||||
|     case coPoints: { | ||||
|         if (opt_key == "bed_shape") { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vojtech Bubnik
						Vojtech Bubnik