mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Implemented update for overridden options on sidebar
This commit is contained in:
		
							parent
							
								
									463783e092
								
							
						
					
					
						commit
						ea4f76ea80
					
				
					 5 changed files with 225 additions and 96 deletions
				
			
		|  | @ -628,11 +628,16 @@ void SpinCtrl::BUILD() { | |||
| 
 | ||||
| void SpinCtrl::propagate_value() | ||||
| { | ||||
|     if (suppress_propagating) | ||||
|         return; | ||||
| 
 | ||||
|     suppress_propagating = true; | ||||
|     if (tmp_value == UNDEF_VALUE) { | ||||
|         on_kill_focus(); | ||||
| 	} else { | ||||
|         on_change_field(); | ||||
|     } | ||||
|     suppress_propagating = false; | ||||
| } | ||||
| 
 | ||||
| void SpinCtrl::msw_rescale() | ||||
|  |  | |||
|  | @ -336,6 +336,8 @@ class SpinCtrl : public Field { | |||
| 	using Field::Field; | ||||
| private: | ||||
| 	static const int UNDEF_VALUE = INT_MIN; | ||||
| 
 | ||||
|     bool            suppress_propagation {false}; | ||||
| public: | ||||
| 	SpinCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id), tmp_value(UNDEF_VALUE) {} | ||||
| 	SpinCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id), tmp_value(UNDEF_VALUE) {} | ||||
|  |  | |||
|  | @ -168,13 +168,26 @@ bool ObjectSettings::update_settings_list() | |||
|     return true; | ||||
| } | ||||
| 
 | ||||
| void ObjectSettings::update_config_values(DynamicPrintConfig*config) | ||||
| void ObjectSettings::update_config_values(DynamicPrintConfig* config) | ||||
| { | ||||
|     auto load_config = [this, config]() | ||||
|     const auto objects_model        = wxGetApp().obj_list()->GetModel(); | ||||
|     const auto item                 = wxGetApp().obj_list()->GetSelection(); | ||||
|     const auto printer_technology   = wxGetApp().plater()->printer_technology(); | ||||
|     const bool is_object_settings   = objects_model->GetItemType(objects_model->GetParent(item)) == itObject; | ||||
| 
 | ||||
|     // update config values according to configuration hierarchy
 | ||||
|     DynamicPrintConfig  main_config   = printer_technology == ptFFF ? | ||||
|                                         wxGetApp().preset_bundle->prints.get_edited_preset().config : | ||||
|                                         wxGetApp().preset_bundle->sla_prints.get_edited_preset().config; | ||||
| 
 | ||||
|     auto load_config = [this, config, &main_config]() | ||||
|     { | ||||
|         // load checked values from main_config to config
 | ||||
|         config->apply_only(main_config, config->keys(), true); | ||||
| 
 | ||||
|         for (auto og : m_og_settings) | ||||
|             og->reload_config(); | ||||
|         update_config_values(config); | ||||
|             og->reload_config();        // load new config values to accorded fields
 | ||||
|         update_config_values(config);   // next config che
 | ||||
|     }; | ||||
| 
 | ||||
|     auto get_field = [this](const t_config_option_key & opt_key) | ||||
|  | @ -188,11 +201,25 @@ void ObjectSettings::update_config_values(DynamicPrintConfig*config) | |||
|         return field; | ||||
|     }; | ||||
| 
 | ||||
|     ConfigManipulation config_manipulation(parent(), load_config, get_field, nullptr); | ||||
|     ConfigManipulation config_manipulation(load_config, get_field, nullptr, config); | ||||
| 
 | ||||
|     wxGetApp().plater()->printer_technology() == ptFFF       ?  | ||||
|         config_manipulation.update_print_fff_options(config) : | ||||
|         config_manipulation.update_print_sla_options(config) ; | ||||
|     if (!is_object_settings) | ||||
|     { | ||||
|         const int obj_idx = objects_model->GetObjectIdByItem(item); | ||||
|         assert(obj_idx >= 0); | ||||
|         DynamicPrintConfig* obj_config = &wxGetApp().model().objects[obj_idx]->config; | ||||
| 
 | ||||
|         main_config.apply(*obj_config, true); | ||||
|         printer_technology == ptFFF  ?  config_manipulation.update_print_fff_config(&main_config) : | ||||
|                                         config_manipulation.update_print_sla_config(&main_config) ; | ||||
|     } | ||||
| 
 | ||||
|     main_config.apply(*config, true); | ||||
|     printer_technology == ptFFF  ?  config_manipulation.update_print_fff_config(&main_config) : | ||||
|                                     config_manipulation.update_print_sla_config(&main_config) ; | ||||
| 
 | ||||
|     printer_technology == ptFFF  ?  config_manipulation.toggle_print_fff_options(&main_config) : | ||||
|                                     config_manipulation.toggle_print_sla_options(&main_config) ; | ||||
| } | ||||
| 
 | ||||
| void ObjectSettings::UpdateAndShow(const bool show) | ||||
|  |  | |||
|  | @ -3849,25 +3849,30 @@ void TabSLAPrint::update() | |||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| bool ConfigManipulation::is_modified(   DynamicPrintConfig* config, | ||||
|                                         DynamicPrintConfig* new_config) | ||||
| void ConfigManipulation::apply(DynamicPrintConfig* config, DynamicPrintConfig* new_config) | ||||
| { | ||||
|     bool modified = false; | ||||
|     for (auto opt_key : config->diff(*new_config)) { | ||||
|         config->set_key_value(opt_key, new_config->option(opt_key)->clone()); | ||||
|         modified = true; | ||||
|     } | ||||
|     return modified; | ||||
| } | ||||
| 
 | ||||
| void ConfigManipulation::load_new(  DynamicPrintConfig* config, | ||||
|                                     DynamicPrintConfig* new_config) | ||||
| { | ||||
|     if (is_modified(config, new_config)) | ||||
|     if (modified && load_config != nullptr) | ||||
|         load_config(); | ||||
| } | ||||
| 
 | ||||
| void ConfigManipulation::update_print_fff_options(DynamicPrintConfig* config) | ||||
| void ConfigManipulation::toggle_field(const std::string& opt_key, const bool toggle) | ||||
| { | ||||
|     if (local_config) { | ||||
|         if (local_config->option(opt_key) == nullptr) | ||||
|             return; | ||||
|     } | ||||
|     Field* field = get_field(opt_key); | ||||
|     if (field==nullptr) return; | ||||
|     field->toggle(toggle); | ||||
| } | ||||
| 
 | ||||
| void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, const bool is_global_config) | ||||
| { | ||||
|     // #ys_FIXME_to_delete
 | ||||
|     //! Temporary workaround for the correct updates of the TextCtrl (like "layer_height"):
 | ||||
|  | @ -3878,46 +3883,48 @@ void ConfigManipulation::update_print_fff_options(DynamicPrintConfig* config) | |||
|         return; | ||||
| 
 | ||||
|     // layer_height shouldn't be equal to zero
 | ||||
|     if (config->has("layer_height") && config->opt_float("layer_height") < EPSILON) | ||||
|     if (config->opt_float("layer_height") < EPSILON) | ||||
|     { | ||||
|         const wxString msg_text = _(L("Zero layer height is not valid.\n\nThe layer height will be reset to 0.01.")); | ||||
|         auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Layer height")), wxICON_WARNING | wxOK); | ||||
|         auto dialog = new wxMessageDialog(nullptr, msg_text, _(L("Layer height")), wxICON_WARNING | wxOK); | ||||
|         DynamicPrintConfig new_conf = *config; | ||||
|         is_msg_dlg_already_exist = true; | ||||
|         dialog->ShowModal(); | ||||
|         new_conf.set_key_value("layer_height", new ConfigOptionFloat(0.01)); | ||||
|         load_new(config, &new_conf); | ||||
|         apply(config, &new_conf); | ||||
|         is_msg_dlg_already_exist = false; | ||||
|     } | ||||
| 
 | ||||
|     if (config->has("first_layer_height") && fabs(config->option<ConfigOptionFloatOrPercent>("first_layer_height")->value - 0) < EPSILON) | ||||
|     if (fabs(config->option<ConfigOptionFloatOrPercent>("first_layer_height")->value - 0) < EPSILON) | ||||
|     { | ||||
|         const wxString msg_text = _(L("Zero first layer height is not valid.\n\nThe first layer height will be reset to 0.01.")); | ||||
|         auto dialog = new wxMessageDialog(parent(), msg_text, _(L("First layer height")), wxICON_WARNING | wxOK); | ||||
|         auto dialog = new wxMessageDialog(nullptr, msg_text, _(L("First layer height")), wxICON_WARNING | wxOK); | ||||
|         DynamicPrintConfig new_conf = *config; | ||||
|         is_msg_dlg_already_exist = true; | ||||
|         dialog->ShowModal(); | ||||
|         new_conf.set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(0.01, false)); | ||||
|         load_new(config, &new_conf); | ||||
|         apply(config, &new_conf); | ||||
|         is_msg_dlg_already_exist = false; | ||||
|     } | ||||
| 
 | ||||
|     double fill_density = !config->has("fill_density") ? -1.0 : | ||||
|                            config->option<ConfigOptionPercent>("fill_density")->value; | ||||
|     double fill_density = config->option<ConfigOptionPercent>("fill_density")->value; | ||||
| 
 | ||||
|     if (config->has("spiral_vase") && config->opt_bool("spiral_vase") && | ||||
|     if (config->opt_bool("spiral_vase") && | ||||
|         !(config->opt_int("perimeters") == 1 && config->opt_int("top_solid_layers") == 0 && | ||||
|             fill_density == 0)) { | ||||
|         wxString msg_text = _(L("The Spiral Vase mode requires:\n" | ||||
|             "- one perimeter\n" | ||||
|             "- no top solid layers\n" | ||||
|             "- 0% fill density\n" | ||||
|             "- no support material\n" | ||||
|             "- no ensure_vertical_shell_thickness\n" | ||||
|             "\nShall I adjust those settings in order to enable Spiral Vase?")); | ||||
|         auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Spiral Vase")), wxICON_WARNING | wxYES | wxNO); | ||||
|                                 "- one perimeter\n" | ||||
|                                 "- no top solid layers\n" | ||||
|                                 "- 0% fill density\n" | ||||
|                                 "- no support material\n" | ||||
|                                 "- no ensure_vertical_shell_thickness")); | ||||
|         if (is_global_config) | ||||
|             msg_text += "\n\n" + _(L("Shall I adjust those settings in order to enable Spiral Vase?")); | ||||
|         auto dialog = new wxMessageDialog(nullptr, msg_text, _(L("Spiral Vase")), | ||||
|                                           wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK)); | ||||
|         DynamicPrintConfig new_conf = *config; | ||||
|         if (dialog->ShowModal() == wxID_YES) { | ||||
|         auto answer = dialog->ShowModal(); | ||||
|         if (!is_global_config || answer == wxID_YES) { | ||||
|             new_conf.set_key_value("perimeters", new ConfigOptionInt(1)); | ||||
|             new_conf.set_key_value("top_solid_layers", new ConfigOptionInt(0)); | ||||
|             new_conf.set_key_value("fill_density", new ConfigOptionPercent(0)); | ||||
|  | @ -3929,43 +3936,49 @@ void ConfigManipulation::update_print_fff_options(DynamicPrintConfig* config) | |||
|         else { | ||||
|             new_conf.set_key_value("spiral_vase", new ConfigOptionBool(false)); | ||||
|         } | ||||
|         load_new(config, &new_conf); | ||||
|         if (on_value_change) | ||||
|             on_value_change("fill_density", fill_density); | ||||
|         apply(config, &new_conf); | ||||
|         if (cb_value_change) | ||||
|             cb_value_change("fill_density", fill_density); | ||||
|     } | ||||
| 
 | ||||
|     if (config->opt_bool("wipe_tower") && config->opt_bool("support_material") && | ||||
|         config->opt_float("support_material_contact_distance") > 0. && | ||||
|         (config->opt_int("support_material_extruder") != 0 || config->opt_int("support_material_interface_extruder") != 0)) { | ||||
|         wxString msg_text = _(L("The Wipe Tower currently supports the non-soluble supports only\n" | ||||
|             "if they are printed with the current extruder without triggering a tool change.\n" | ||||
|             "(both support_material_extruder and support_material_interface_extruder need to be set to 0).\n" | ||||
|             "\nShall I adjust those settings in order to enable the Wipe Tower?")); | ||||
|         auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Wipe Tower")), wxICON_WARNING | wxYES | wxNO); | ||||
|                                 "if they are printed with the current extruder without triggering a tool change.\n" | ||||
|                                 "(both support_material_extruder and support_material_interface_extruder need to be set to 0).")); | ||||
|         if (is_global_config) | ||||
|             msg_text += "\n\n" + _(L("Shall I adjust those settings in order to enable the Wipe Tower?")); | ||||
|         auto dialog = new wxMessageDialog(nullptr, msg_text, _(L("Wipe Tower")), | ||||
|                                           wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK)); | ||||
|         DynamicPrintConfig new_conf = *config; | ||||
|         if (dialog->ShowModal() == wxID_YES) { | ||||
|         auto answer = dialog->ShowModal(); | ||||
|         if (!is_global_config || answer == wxID_YES) { | ||||
|             new_conf.set_key_value("support_material_extruder", new ConfigOptionInt(0)); | ||||
|             new_conf.set_key_value("support_material_interface_extruder", new ConfigOptionInt(0)); | ||||
|         } | ||||
|         else | ||||
|             new_conf.set_key_value("wipe_tower", new ConfigOptionBool(false)); | ||||
|         load_new(config, &new_conf); | ||||
|         apply(config, &new_conf); | ||||
|     } | ||||
| 
 | ||||
|     if (config->opt_bool("wipe_tower") && config->opt_bool("support_material") && | ||||
|         config->opt_float("support_material_contact_distance") == 0 && | ||||
|         !config->opt_bool("support_material_synchronize_layers")) { | ||||
|         wxString msg_text = _(L("For the Wipe Tower to work with the soluble supports, the support layers\n" | ||||
|             "need to be synchronized with the object layers.\n" | ||||
|             "\nShall I synchronize support layers in order to enable the Wipe Tower?")); | ||||
|         auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Wipe Tower")), wxICON_WARNING | wxYES | wxNO); | ||||
|                                 "need to be synchronized with the object layers.")); | ||||
|         if (is_global_config) | ||||
|             msg_text += "\n\n" + _(L("Shall I synchronize support layers in order to enable the Wipe Tower?")); | ||||
|         auto dialog = new wxMessageDialog(nullptr, msg_text, _(L("Wipe Tower")), | ||||
|                                           wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK)); | ||||
|         DynamicPrintConfig new_conf = *config; | ||||
|         if (dialog->ShowModal() == wxID_YES) { | ||||
|         auto answer = dialog->ShowModal(); | ||||
|         if (!is_global_config || answer == wxID_YES) { | ||||
|             new_conf.set_key_value("support_material_synchronize_layers", new ConfigOptionBool(true)); | ||||
|         } | ||||
|         else | ||||
|             new_conf.set_key_value("wipe_tower", new ConfigOptionBool(false)); | ||||
|         load_new(config, &new_conf); | ||||
|         apply(config, &new_conf); | ||||
|     } | ||||
| 
 | ||||
|     if (config->opt_bool("support_material")) { | ||||
|  | @ -3974,12 +3987,14 @@ void ConfigManipulation::update_print_fff_options(DynamicPrintConfig* config) | |||
|             support_material_overhangs_queried = true; | ||||
|             if (!config->opt_bool("overhangs")/* != 1*/) { | ||||
|                 wxString msg_text = _(L("Supports work better, if the following feature is enabled:\n" | ||||
|                     "- Detect bridging perimeters\n" | ||||
|                     "\nShall I adjust those settings for supports?")); | ||||
|                 auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Support Generator")), wxICON_WARNING | wxYES | wxNO | wxCANCEL); | ||||
|                                         "- Detect bridging perimeters")); | ||||
|                 if (is_global_config) | ||||
|                     msg_text += "\n\n" + _(L("Shall I adjust those settings for supports?")); | ||||
|                 auto dialog = new wxMessageDialog(nullptr, msg_text, _(L("Support Generator")), | ||||
|                                                   wxICON_WARNING | (is_global_config ? wxYES | wxNO | wxCANCEL : wxOK)); | ||||
|                 DynamicPrintConfig new_conf = *config; | ||||
|                 auto answer = dialog->ShowModal(); | ||||
|                 if (answer == wxID_YES) { | ||||
|                 if (!is_global_config || answer == wxID_YES) { | ||||
|                     // Enable "detect bridging perimeters".
 | ||||
|                     new_conf.set_key_value("overhangs", new ConfigOptionBool(true)); | ||||
|                 } | ||||
|  | @ -3991,7 +4006,7 @@ void ConfigManipulation::update_print_fff_options(DynamicPrintConfig* config) | |||
|                     new_conf.set_key_value("support_material", new ConfigOptionBool(false)); | ||||
|                     support_material_overhangs_queried = false; | ||||
|                 } | ||||
|                 load_new(config, &new_conf); | ||||
|                 apply(config, &new_conf); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | @ -4020,64 +4035,70 @@ void ConfigManipulation::update_print_fff_options(DynamicPrintConfig* config) | |||
|             // get fill_pattern name from enum_labels for using this one at dialog_msg
 | ||||
|             str_fill_pattern = _utf8(config->def()->get("fill_pattern")->enum_labels[fill_pattern]); | ||||
|             if (!correct_100p_fill) { | ||||
|                 wxString msg_text = GUI::from_u8((boost::format(_utf8(L("The %1% infill pattern is not supposed to work at 100%% density.\n\n" | ||||
|                     "Shall I switch to rectilinear fill pattern?"))) % str_fill_pattern).str()); | ||||
|                 auto dialog = new wxMessageDialog(parent(), msg_text, _(L("Infill")), wxICON_WARNING | wxYES | wxNO); | ||||
|                 wxString msg_text = GUI::from_u8((boost::format(_utf8(L("The %1% infill pattern is not supposed to work at 100%% density."))) % str_fill_pattern).str()); | ||||
|                 if (is_global_config) | ||||
|                     msg_text += "\n\n" + _(L("Shall I switch to rectilinear fill pattern?")); | ||||
|                 auto dialog = new wxMessageDialog(nullptr, msg_text, _(L("Infill")), | ||||
|                                                   wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK) ); | ||||
|                 DynamicPrintConfig new_conf = *config; | ||||
|                 if (dialog->ShowModal() == wxID_YES) { | ||||
|                 auto answer = dialog->ShowModal(); | ||||
|                 if (!is_global_config || answer == wxID_YES) { | ||||
|                     new_conf.set_key_value("fill_pattern", new ConfigOptionEnum<InfillPattern>(ipRectilinear)); | ||||
|                     fill_density = 100; | ||||
|                 } | ||||
|                 else | ||||
|                     fill_density = wxGetApp().preset_bundle->prints.get_selected_preset().config.option<ConfigOptionPercent>("fill_density")->value; | ||||
|                 new_conf.set_key_value("fill_density", new ConfigOptionPercent(fill_density)); | ||||
|                 load_new(config, &new_conf); | ||||
|                 if (on_value_change) | ||||
|                     on_value_change("fill_density", fill_density); | ||||
|                 apply(config, &new_conf); | ||||
|                 if (cb_value_change) | ||||
|                     cb_value_change("fill_density", fill_density); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config) | ||||
| { | ||||
|     bool have_perimeters = config->opt_int("perimeters") > 0; | ||||
|     for (auto el : { "extra_perimeters", "ensure_vertical_shell_thickness", "thin_walls", "overhangs", | ||||
|                     "seam_position", "external_perimeters_first", "external_perimeter_extrusion_width", | ||||
|                     "perimeter_speed", "small_perimeter_speed", "external_perimeter_speed" }) | ||||
|         get_field(el)->toggle(have_perimeters); | ||||
|         toggle_field(el, have_perimeters); | ||||
| 
 | ||||
|     bool have_infill = config->option<ConfigOptionPercent>("fill_density")->value > 0; | ||||
|     // infill_extruder uses the same logic as in Print::extruders()
 | ||||
|     for (auto el : { "fill_pattern", "infill_every_layers", "infill_only_where_needed", | ||||
|                     "solid_infill_every_layers", "solid_infill_below_area", "infill_extruder" }) | ||||
|         get_field(el)->toggle(have_infill); | ||||
|         toggle_field(el, have_infill); | ||||
| 
 | ||||
|     bool have_solid_infill = config->opt_int("top_solid_layers") > 0 || config->opt_int("bottom_solid_layers") > 0; | ||||
|     // solid_infill_extruder uses the same logic as in Print::extruders()
 | ||||
|     for (auto el : { "top_fill_pattern", "bottom_fill_pattern", "infill_first", "solid_infill_extruder", | ||||
|                     "solid_infill_extrusion_width", "solid_infill_speed" }) | ||||
|         get_field(el)->toggle(have_solid_infill); | ||||
|         toggle_field(el, have_solid_infill); | ||||
| 
 | ||||
|     for (auto el : { "fill_angle", "bridge_angle", "infill_extrusion_width", | ||||
|                     "infill_speed", "bridge_speed" }) | ||||
|         get_field(el)->toggle(have_infill || have_solid_infill); | ||||
|         toggle_field(el, have_infill || have_solid_infill); | ||||
| 
 | ||||
|     get_field("gap_fill_speed")->toggle(have_perimeters && have_infill); | ||||
|     toggle_field("gap_fill_speed", have_perimeters && have_infill); | ||||
| 
 | ||||
|     bool have_top_solid_infill = config->opt_int("top_solid_layers") > 0; | ||||
|     for (auto el : { "top_infill_extrusion_width", "top_solid_infill_speed" }) | ||||
|         get_field(el)->toggle(have_top_solid_infill); | ||||
|         toggle_field(el, have_top_solid_infill); | ||||
| 
 | ||||
|     bool have_default_acceleration = config->opt_float("default_acceleration") > 0; | ||||
|     for (auto el : { "perimeter_acceleration", "infill_acceleration", | ||||
|                     "bridge_acceleration", "first_layer_acceleration" }) | ||||
|         get_field(el)->toggle(have_default_acceleration); | ||||
|         toggle_field(el, have_default_acceleration); | ||||
| 
 | ||||
|     bool have_skirt = config->opt_int("skirts") > 0 || config->opt_float("min_skirt_length") > 0; | ||||
|     for (auto el : { "skirt_distance", "skirt_height" }) | ||||
|         get_field(el)->toggle(have_skirt); | ||||
|         toggle_field(el, have_skirt); | ||||
| 
 | ||||
|     bool have_brim = config->opt_float("brim_width") > 0; | ||||
|     // perimeter_extruder uses the same logic as in Print::extruders()
 | ||||
|     get_field("perimeter_extruder")->toggle(have_perimeters || have_brim); | ||||
|     toggle_field("perimeter_extruder", have_perimeters || have_brim); | ||||
| 
 | ||||
|     bool have_raft = config->opt_int("raft_layers") > 0; | ||||
|     bool have_support_material = config->opt_bool("support_material") || have_raft; | ||||
|  | @ -4088,33 +4109,104 @@ void ConfigManipulation::update_print_fff_options(DynamicPrintConfig* config) | |||
|                     "support_material_spacing", "support_material_angle", "support_material_interface_layers", | ||||
|                     "dont_support_bridges", "support_material_extrusion_width", "support_material_contact_distance", | ||||
|                     "support_material_xy_spacing" }) | ||||
|         get_field(el)->toggle(have_support_material); | ||||
|     get_field("support_material_threshold")->toggle(have_support_material_auto); | ||||
|         toggle_field(el, have_support_material); | ||||
|     toggle_field("support_material_threshold", have_support_material_auto); | ||||
| 
 | ||||
|     for (auto el : { "support_material_interface_spacing", "support_material_interface_extruder", | ||||
|                     "support_material_interface_speed", "support_material_interface_contact_loops" }) | ||||
|         get_field(el)->toggle(have_support_material && have_support_interface); | ||||
|     get_field("support_material_synchronize_layers")->toggle(have_support_soluble); | ||||
|         toggle_field(el, have_support_material && have_support_interface); | ||||
|     toggle_field("support_material_synchronize_layers", have_support_soluble); | ||||
| 
 | ||||
|     get_field("perimeter_extrusion_width")->toggle(have_perimeters || have_skirt || have_brim); | ||||
|     get_field("support_material_extruder")->toggle(have_support_material || have_skirt); | ||||
|     get_field("support_material_speed")->toggle(have_support_material || have_brim || have_skirt); | ||||
|     toggle_field("perimeter_extrusion_width", have_perimeters || have_skirt || have_brim); | ||||
|     toggle_field("support_material_extruder", have_support_material || have_skirt); | ||||
|     toggle_field("support_material_speed", have_support_material || have_brim || have_skirt); | ||||
| 
 | ||||
|     bool have_sequential_printing = config->opt_bool("complete_objects"); | ||||
|     for (auto el : { "extruder_clearance_radius", "extruder_clearance_height" }) | ||||
|         get_field(el)->toggle(have_sequential_printing); | ||||
|         toggle_field(el, have_sequential_printing); | ||||
| 
 | ||||
|     bool have_ooze_prevention = config->opt_bool("ooze_prevention"); | ||||
|     get_field("standby_temperature_delta")->toggle(have_ooze_prevention); | ||||
|     toggle_field("standby_temperature_delta", have_ooze_prevention); | ||||
| 
 | ||||
|     bool have_wipe_tower = config->opt_bool("wipe_tower"); | ||||
|     for (auto el : { "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging" }) | ||||
|         get_field(el)->toggle(have_wipe_tower); | ||||
|         toggle_field(el, have_wipe_tower); | ||||
| } | ||||
| 
 | ||||
| void ConfigManipulation::update_print_sla_options(DynamicPrintConfig* config) | ||||
| {} | ||||
| void ConfigManipulation::update_print_sla_config(DynamicPrintConfig* config, const bool is_global_config/* = false*/) | ||||
| { | ||||
|     double head_penetration = config->opt_float("support_head_penetration"); | ||||
|     double head_width = config->opt_float("support_head_width"); | ||||
|     if (head_penetration > head_width) { | ||||
|         wxString msg_text = _(L("Head penetration should not be greater than the head width.")); | ||||
| 
 | ||||
|         auto dialog = new wxMessageDialog(nullptr, | ||||
|                                           msg_text, | ||||
|                                           _(L("Invalid Head penetration")), | ||||
|                                           wxICON_WARNING | wxOK); | ||||
| 
 | ||||
|         DynamicPrintConfig new_conf = *config; | ||||
|         if (dialog->ShowModal() == wxID_OK) { | ||||
|             new_conf.set_key_value("support_head_penetration", new ConfigOptionFloat(head_width)); | ||||
|             apply(config, &new_conf); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     double pinhead_d = config->opt_float("support_head_front_diameter"); | ||||
|     double pillar_d = config->opt_float("support_pillar_diameter"); | ||||
|     if (pinhead_d > pillar_d) { | ||||
|         wxString msg_text = _(L("Pinhead diameter should be smaller than the pillar diameter.")); | ||||
| 
 | ||||
|         auto dialog = new wxMessageDialog(nullptr, | ||||
|             msg_text, | ||||
|             _(L("Invalid pinhead diameter")), | ||||
|             wxICON_WARNING | wxOK); | ||||
| 
 | ||||
|         DynamicPrintConfig new_conf = *config; | ||||
|         if (dialog->ShowModal() == wxID_OK) { | ||||
|             new_conf.set_key_value("support_head_front_diameter", new ConfigOptionFloat(pillar_d / 2.0)); | ||||
|             apply(config, &new_conf); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void ConfigManipulation::toggle_print_sla_options(DynamicPrintConfig* config) | ||||
| { | ||||
|     bool supports_en = config->opt_bool("supports_enable"); | ||||
| 
 | ||||
|     toggle_field("support_head_front_diameter", supports_en); | ||||
|     toggle_field("support_head_penetration", supports_en); | ||||
|     toggle_field("support_head_width", supports_en); | ||||
|     toggle_field("support_pillar_diameter", supports_en); | ||||
|     toggle_field("support_pillar_connection_mode", supports_en); | ||||
|     toggle_field("support_buildplate_only", supports_en); | ||||
|     toggle_field("support_base_diameter", supports_en); | ||||
|     toggle_field("support_base_height", supports_en); | ||||
|     toggle_field("support_base_safety_distance", supports_en); | ||||
|     toggle_field("support_critical_angle", supports_en); | ||||
|     toggle_field("support_max_bridge_length", supports_en); | ||||
|     toggle_field("support_max_pillar_link_distance", supports_en); | ||||
|     toggle_field("support_points_density_relative", supports_en); | ||||
|     toggle_field("support_points_minimal_distance", supports_en); | ||||
| 
 | ||||
|     bool pad_en = config->opt_bool("pad_enable"); | ||||
| 
 | ||||
|     toggle_field("pad_wall_thickness", pad_en); | ||||
|     toggle_field("pad_wall_height", pad_en); | ||||
|     toggle_field("pad_max_merge_distance", pad_en); | ||||
|  // toggle_field("pad_edge_radius", supports_en);
 | ||||
|     toggle_field("pad_wall_slope", pad_en); | ||||
|     toggle_field("pad_zero_elevation", pad_en); | ||||
| 
 | ||||
|     bool has_suppad = pad_en && supports_en; | ||||
|     bool zero_elev = config->opt_bool("pad_zero_elevation") && has_suppad; | ||||
| 
 | ||||
|     toggle_field("support_object_elevation", supports_en && !zero_elev); | ||||
|     toggle_field("pad_object_gap", zero_elev); | ||||
|     toggle_field("pad_object_connector_stride", zero_elev); | ||||
|     toggle_field("pad_object_connector_width", zero_elev); | ||||
|     toggle_field("pad_object_connector_penetration", zero_elev); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| } // GUI
 | ||||
|  |  | |||
|  | @ -447,33 +447,36 @@ class ConfigManipulation | |||
| { | ||||
|     bool                is_msg_dlg_already_exist{ false }; | ||||
|     bool                support_material_overhangs_queried {false}; | ||||
|     wxWindow*           msg_parent {nullptr}; | ||||
| 
 | ||||
|     // function to loading of changed configuration 
 | ||||
|     std::function<void()>                                       load_config = nullptr; | ||||
|     std::function<Field* (const std::string&)>                  get_field = nullptr; | ||||
|     std::function<void(const std::string&, const boost::any&)>  on_value_change = nullptr; | ||||
|     // callback to propagation of changed value, if needed 
 | ||||
|     std::function<void(const std::string&, const boost::any&)>  cb_value_change = nullptr; | ||||
|     DynamicPrintConfig*                                         local_config = nullptr; | ||||
| 
 | ||||
|     wxWindow*           parent() const  { return msg_parent;} | ||||
| public: | ||||
|     ConfigManipulation( wxWindow* msg_parent,  | ||||
|                         std::function<void()> load_config, | ||||
|     ConfigManipulation( std::function<void()> load_config, | ||||
|                         std::function<Field*(const std::string&)> get_field, | ||||
|                         std::function<void(const std::string&, const boost::any&)>  on_value_change) : | ||||
|                         msg_parent(msg_parent),  | ||||
|                         load_config(load_config), | ||||
|                         get_field(get_field), | ||||
|                         on_value_change(on_value_change) {} | ||||
|                         std::function<void(const std::string&, const boost::any&)>  cb_value_change, | ||||
|                         DynamicPrintConfig* local_config = nullptr) : | ||||
|         load_config(load_config), | ||||
|         get_field(get_field), | ||||
|         cb_value_change(cb_value_change), | ||||
|         local_config(local_config) {} | ||||
| 
 | ||||
|     ~ConfigManipulation() { | ||||
|         load_config = nullptr; | ||||
|         get_field = nullptr; | ||||
|         on_value_change = nullptr; | ||||
|         cb_value_change = nullptr; | ||||
|     } | ||||
| 
 | ||||
|     bool    is_modified(DynamicPrintConfig* config, DynamicPrintConfig* new_config); | ||||
|     void    load_new(DynamicPrintConfig* config, DynamicPrintConfig* new_config); | ||||
|     void    update_print_fff_options(DynamicPrintConfig* config); | ||||
|     void    update_print_sla_options(DynamicPrintConfig* config); | ||||
|     void    apply(DynamicPrintConfig* config, DynamicPrintConfig* new_config); | ||||
|     void    toggle_field(const std::string& field_key, const bool toggle); | ||||
|     void    update_print_fff_config(DynamicPrintConfig* config, const bool is_global_config = false); | ||||
|     void    toggle_print_fff_options(DynamicPrintConfig* config); | ||||
|     void    update_print_sla_config(DynamicPrintConfig* config, const bool is_global_config = false); | ||||
|     void    toggle_print_sla_options(DynamicPrintConfig* config); | ||||
| }; | ||||
| 
 | ||||
| } // GUI
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 YuSanka
						YuSanka