Skip to content

Commit

Permalink
enabled dependency setting for filament and process (#6235)
Browse files Browse the repository at this point in the history
* enabled dependency setting for filament and process

* Add information about inheritance back to Dependencies tab

* Merge pull request #1 from michmela44/Add_inherits_to_dependencies

Add information about inheritance back to Dependencies tab

* Merge branch 'main' into feature/enable_profile_dependencies
  • Loading branch information
Azio-Pantheon authored Jan 13, 2025
1 parent cd4a1e0 commit 4c955e5
Showing 1 changed file with 141 additions and 137 deletions.
278 changes: 141 additions & 137 deletions src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,26 +1064,24 @@ void Tab::on_roll_back_value(const bool to_sys /*= true*/)
load_key_value("printable_area", true/*some value*/, true);
}
}
//if (group->title == "Profile dependencies") {
// // "compatible_printers" option doesn't exists in Printer Settimgs Tab
// if (m_type != Preset::TYPE_PRINTER && (m_options_list["compatible_printers"] & os) == 0) {
// to_sys ? group->back_to_sys_value("compatible_printers") : group->back_to_initial_value("compatible_printers");
// load_key_value("compatible_printers", true/*some value*/, true);

// bool is_empty = m_config->option<ConfigOptionStrings>("compatible_printers")->values.empty();
// m_compatible_printers.checkbox->SetValue(is_empty);
// is_empty ? m_compatible_printers.btn->Disable() : m_compatible_printers.btn->Enable();
// }
// // "compatible_prints" option exists only in Filament Settimgs and Materials Tabs
// if ((m_type == Preset::TYPE_FILAMENT || m_type == Preset::TYPE_SLA_MATERIAL) && (m_options_list["compatible_prints"] & os) == 0) {
// to_sys ? group->back_to_sys_value("compatible_prints") : group->back_to_initial_value("compatible_prints");
// load_key_value("compatible_prints", true/*some value*/, true);

// bool is_empty = m_config->option<ConfigOptionStrings>("compatible_prints")->values.empty();
// m_compatible_prints.checkbox->SetValue(is_empty);
// is_empty ? m_compatible_prints.btn->Disable() : m_compatible_prints.btn->Enable();
// }
//}
if (group->title == "Profile dependencies") {
if (m_type != Preset::TYPE_PRINTER && (m_options_list["compatible_printers"] & os) == 0) {
to_sys ? group->back_to_sys_value("compatible_printers") : group->back_to_initial_value("compatible_printers");
load_key_value("compatible_printers", true/*some value*/, true);

bool is_empty = m_config->option<ConfigOptionStrings>("compatible_printers")->values.empty();
m_compatible_printers.checkbox->SetValue(is_empty);
is_empty ? m_compatible_printers.btn->Disable() : m_compatible_printers.btn->Enable();
}
if ((m_type == Preset::TYPE_FILAMENT || m_type == Preset::TYPE_SLA_MATERIAL) && (m_options_list["compatible_prints"] & os) == 0) {
to_sys ? group->back_to_sys_value("compatible_prints") : group->back_to_initial_value("compatible_prints");
load_key_value("compatible_prints", true/*some value*/, true);

bool is_empty = m_config->option<ConfigOptionStrings>("compatible_prints")->values.empty();
m_compatible_prints.checkbox->SetValue(is_empty);
is_empty ? m_compatible_prints.btn->Disable() : m_compatible_prints.btn->Enable();
}
}
for (const auto &kvp : group->opt_map()) {
const std::string& opt_key = kvp.first;
if ((m_options_list[opt_key] & os) == 0)
Expand Down Expand Up @@ -1380,6 +1378,11 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
return;
}

if (opt_key == "compatible_prints")
this->compatible_widget_reload(m_compatible_prints);
if (opt_key == "compatible_printers")
this->compatible_widget_reload(m_compatible_printers);

const bool is_fff = supports_printer_technology(ptFFF);
ConfigOptionsGroup* og_freq_chng_params = wxGetApp().sidebar().og_freq_chng_params(is_fff);
//BBS: GUI refactor
Expand Down Expand Up @@ -1855,33 +1858,33 @@ void Tab::build_preset_description_line(ConfigOptionsGroup* optgroup)
};

auto detach_preset_btn = [this](wxWindow* parent) {
m_detach_preset_btn = new ScalableButton(parent, wxID_ANY, "lock_normal_sys", "",
m_detach_preset_btn = new ScalableButton(parent, wxID_ANY, "lock_normal", "",
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
ScalableButton* btn = m_detach_preset_btn;
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());

auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(btn);

//btn->Bind(wxEVT_BUTTON, [this, parent](wxCommandEvent&)
//{
// bool system = m_presets->get_edited_preset().is_system;
// bool dirty = m_presets->get_edited_preset().is_dirty;
// wxString msg_text = system ?
// _(L("A copy of the current system preset will be created, which will be detached from the system preset.")) :
// _(L("The current custom preset will be detached from the parent system preset."));
// if (dirty) {
// msg_text += "\n\n";
// msg_text += _(L("Modifications to the current profile will be saved."));
// }
// msg_text += "\n\n";
// msg_text += _(L("This action is not revertible.\nDo you want to proceed?"));

// //wxMessageDialog dialog(parent, msg_text, _(L("Detach preset")), wxICON_WARNING | wxYES_NO | wxCANCEL);
// MessageDialog dialog(parent, msg_text, _(L("Detach preset")), wxICON_WARNING | wxYES_NO | wxCANCEL);
// if (dialog.ShowModal() == wxID_YES)
// save_preset(m_presets->get_edited_preset().is_system ? std::string() : m_presets->get_edited_preset().name, true);
//});
btn->Bind(wxEVT_BUTTON, [this, parent](wxCommandEvent&)
{
bool system = m_presets->get_edited_preset().is_system;
bool dirty = m_presets->get_edited_preset().is_dirty;
wxString msg_text = system ?
_(L("A copy of the current system preset will be created, which will be detached from the system preset.")) :
_(L("The current custom preset will be detached from the parent system preset."));
if (dirty) {
msg_text += "\n\n";
msg_text += _(L("Modifications to the current profile will be saved."));
}
msg_text += "\n\n";
msg_text += _(L("This action is not revertible.\nDo you want to proceed?"));

//wxMessageDialog dialog(parent, msg_text, _(L("Detach preset")), wxICON_WARNING | wxYES_NO | wxCANCEL);
MessageDialog dialog(parent, msg_text, _(L("Detach preset")), wxICON_WARNING | wxYES_NO | wxCANCEL);
if (dialog.ShowModal() == wxID_YES)
save_preset(m_presets->get_edited_preset().is_system ? std::string() : m_presets->get_edited_preset().name, true);
});

btn->Hide();

Expand All @@ -1903,72 +1906,72 @@ void Tab::update_preset_description_line()

wxString description_line;

//if (preset.is_default) {
// description_line = _(L("This is a default preset."));
//} else if (preset.is_system) {
// description_line = _(L("This is a system preset."));
//} else if (parent == nullptr) {
// description_line = _(L("Current preset is inherited from the default preset."));
//} else {
// std::string name = parent->name;
// boost::replace_all(name, "&", "&&");
// description_line = _(L("Current preset is inherited from")) + ":\n\t" + from_u8(name);
//}
if (preset.is_default) {
description_line = _(L("This is a default preset."));
} else if (preset.is_system) {
description_line = _(L("This is a system preset."));
} else if (parent == nullptr) {
description_line = _(L("Current preset is inherited from the default preset."));
} else {
std::string name = parent->name;
boost::replace_all(name, "&", "&&");
description_line = _(L("Current preset is inherited from")) + ":\n\t" + from_u8(name);
}

//if (preset.is_default || preset.is_system)
// description_line += "\n\t" + _(L("It can't be deleted or modified.")) +
// "\n\t" + _(L("Any modifications should be saved as a new preset inherited from this one.")) +
// "\n\t" + _(L("To do that please specify a new name for the preset."));
if (preset.is_default || preset.is_system)
description_line += "\n\t" + _(L("It can't be deleted or modified.")) +
"\n\t" + _(L("Any modifications should be saved as a new preset inherited from this one.")) +
"\n\t" + _(L("To do that please specify a new name for the preset."));

//if (parent && parent->vendor)
//{
// description_line += "\n\n" + _(L("Additional information:")) + "\n";
// description_line += "\t" + _(L("vendor")) + ": " + (m_type == Slic3r::Preset::TYPE_PRINTER ? "\n\t\t" : "") + parent->vendor->name +
// ", ver: " + parent->vendor->config_version.to_string();
// if (m_type == Slic3r::Preset::TYPE_PRINTER) {
// const std::string &printer_model = preset.config.opt_string("printer_model");
// if (! printer_model.empty())
// description_line += "\n\n\t" + _(L("printer model")) + ": \n\t\t" + printer_model;
// switch (preset.printer_technology()) {
// case ptFFF:
// {
// //FIXME add prefered_sla_material_profile for SLA
// const std::string &default_print_profile = preset.config.opt_string("default_print_profile");
// const std::vector<std::string> &default_filament_profiles = preset.config.option<ConfigOptionStrings>("default_filament_profile")->values;
// if (!default_print_profile.empty())
// description_line += "\n\n\t" + _(L("default print profile")) + ": \n\t\t" + default_print_profile;
// if (!default_filament_profiles.empty())
// {
// description_line += "\n\n\t" + _(L("default filament profile")) + ": \n\t\t";
// for (auto& profile : default_filament_profiles) {
// if (&profile != &*default_filament_profiles.begin())
// description_line += ", ";
// description_line += profile;
// }
// }
// break;
// }
// case ptSLA:
// {
// //FIXME add prefered_sla_material_profile for SLA
// const std::string &default_sla_material_profile = preset.config.opt_string("default_sla_material_profile");
// if (!default_sla_material_profile.empty())
// description_line += "\n\n\t" + _(L("default SLA material profile")) + ": \n\t\t" + default_sla_material_profile;

// const std::string &default_sla_print_profile = preset.config.opt_string("default_sla_print_profile");
// if (!default_sla_print_profile.empty())
// description_line += "\n\n\t" + _(L("default SLA print profile")) + ": \n\t\t" + default_sla_print_profile;
// break;
// }
// default: break;
// }
// }
// else if (!preset.alias.empty())
// {
// description_line += "\n\n\t" + _(L("full profile name")) + ": \n\t\t" + preset.name;
// description_line += "\n\t" + _(L("symbolic profile name")) + ": \n\t\t" + preset.alias;
// }
//}
if (parent && parent->vendor)
{
description_line += "\n\n" + _(L("Additional information:")) + "\n";
description_line += "\t" + _(L("vendor")) + ": " + (m_type == Slic3r::Preset::TYPE_PRINTER ? "\n\t\t" : "") + parent->vendor->name +
", ver: " + parent->vendor->config_version.to_string();
if (m_type == Slic3r::Preset::TYPE_PRINTER) {
const std::string &printer_model = preset.config.opt_string("printer_model");
if (! printer_model.empty())
description_line += "\n\n\t" + _(L("printer model")) + ": \n\t\t" + printer_model;
switch (preset.printer_technology()) {
case ptFFF:
{
//FIXME add prefered_sla_material_profile for SLA
const std::string &default_print_profile = preset.config.opt_string("default_print_profile");
const std::vector<std::string> &default_filament_profiles = preset.config.option<ConfigOptionStrings>("default_filament_profile")->values;
if (!default_print_profile.empty())
description_line += "\n\n\t" + _(L("default print profile")) + ": \n\t\t" + default_print_profile;
if (!default_filament_profiles.empty())
{
description_line += "\n\n\t" + _(L("default filament profile")) + ": \n\t\t";
for (auto& profile : default_filament_profiles) {
if (&profile != &*default_filament_profiles.begin())
description_line += ", ";
description_line += profile;
}
}
break;
}
case ptSLA:
{
//FIXME add prefered_sla_material_profile for SLA
const std::string &default_sla_material_profile = preset.config.opt_string("default_sla_material_profile");
if (!default_sla_material_profile.empty())
description_line += "\n\n\t" + _(L("default SLA material profile")) + ": \n\t\t" + default_sla_material_profile;

const std::string &default_sla_print_profile = preset.config.opt_string("default_sla_print_profile");
if (!default_sla_print_profile.empty())
description_line += "\n\n\t" + _(L("default SLA print profile")) + ": \n\t\t" + default_sla_print_profile;
break;
}
default: break;
}
}
else if (!preset.alias.empty())
{
description_line += "\n\n\t" + _(L("full profile name")) + ": \n\t\t" + preset.name;
description_line += "\n\t" + _(L("symbolic profile name")) + ": \n\t\t" + preset.alias;
}
}

m_parent_preset_description_line->SetText(description_line, false);

Expand Down Expand Up @@ -2377,20 +2380,20 @@ page = add_options_page(L("Others"), "custom-gcode_other"); // ORCA: icon only v
option.opt.full_width = true;
option.opt.height = 25;//250;
optgroup->append_single_option_line(option);

#if 0
//page = add_options_page(L("Dependencies"), "advanced.png");
// optgroup = page->new_optgroup(L("Profile dependencies"));

// create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
// return compatible_widget_create(parent, m_compatible_printers);
// });
//
// option = optgroup->get_option("compatible_printers_condition");
// option.opt.full_width = true;
// optgroup->append_single_option_line(option);
#if 1
page = add_options_page(L("Dependencies"), "custom-gcode_advanced");
optgroup = page->new_optgroup(L("Profile dependencies"));

// build_preset_description_line(optgroup.get());
create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
return compatible_widget_create(parent, m_compatible_printers);
});

option = optgroup->get_option("compatible_printers_condition");
option.opt.full_width = true;
optgroup->append_single_option_line(option);

build_preset_description_line(optgroup.get());
#endif
}

Expand Down Expand Up @@ -2482,8 +2485,8 @@ void TabPrint::update()
m_update_cnt--;

if (m_update_cnt==0) {
toggle_options();

if (m_active_page && !(m_active_page->title() == "Dependencies"))
toggle_options();
// update() could be called during undo/redo execution
// Update of objectList can cause a crash in this case (because m_objects doesn't match ObjectList)
if (m_type != Preset::TYPE_MODEL && !wxGetApp().plater()->inside_snapshot_capture())
Expand Down Expand Up @@ -3531,26 +3534,26 @@ void TabFilament::build()
option.opt.full_width = true;
option.opt.height = notes_field_height;// 250;
optgroup->append_single_option_line(option);
#if 0
//page = add_options_page(L("Dependencies"), "advanced");
// optgroup = page->new_optgroup(L("Profile dependencies"));
// create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
// return compatible_widget_create(parent, m_compatible_printers);
// });
#if 1
page = add_options_page(L("Dependencies"), "advanced");
optgroup = page->new_optgroup(L("Profile dependencies"));
create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
return compatible_widget_create(parent, m_compatible_printers);
});

// option = optgroup->get_option("compatible_printers_condition");
// option.opt.full_width = true;
// optgroup->append_single_option_line(option);
option = optgroup->get_option("compatible_printers_condition");
option.opt.full_width = true;
optgroup->append_single_option_line(option);

// create_line_with_widget(optgroup.get(), "compatible_prints", "", [this](wxWindow* parent) {
// return compatible_widget_create(parent, m_compatible_prints);
// });
create_line_with_widget(optgroup.get(), "compatible_prints", "", [this](wxWindow* parent) {
return compatible_widget_create(parent, m_compatible_prints);
});

// option = optgroup->get_option("compatible_prints_condition");
// option.opt.full_width = true;
// optgroup->append_single_option_line(option);
option = optgroup->get_option("compatible_prints_condition");
option.opt.full_width = true;
optgroup->append_single_option_line(option);

// build_preset_description_line(optgroup.get());
//build_preset_description_line(optgroup.get());
#endif
}

Expand Down Expand Up @@ -5297,7 +5300,8 @@ void Tab::activate_selected_page(std::function<void()> throw_if_canceled)
m_active_page->activate(m_mode, throw_if_canceled);
update_changed_ui();
update_description_lines();
toggle_options();
if (m_active_page && !(m_active_page->title() == "Dependencies"))
toggle_options();
m_active_page->update_visibility(m_mode, true); // for taggle line
}

Expand Down Expand Up @@ -6270,8 +6274,8 @@ const ConfigOptionsGroupShp Page::get_optgroup(const wxString& title) const

void TabSLAMaterial::build()
{
//m_presets = &m_preset_bundle->sla_materials;
//load_initial_data();
m_presets = &m_preset_bundle->sla_materials;
load_initial_data();

//auto page = add_options_page(L("Material"), "");

Expand Down

0 comments on commit 4c955e5

Please sign in to comment.