mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 02:41:17 +00:00
Merge branch 'main' into feat/plugin-pages
This commit is contained in:
+104
-8
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI_ObjectList.hpp"
|
||||
#include "slic3r/Utils/NetworkAgentFactory.hpp"
|
||||
#include "slic3r/Utils/PresetUpdater.hpp"
|
||||
#include "slic3r/plugin/PluginConfig.hpp"
|
||||
#include "Plater.hpp"
|
||||
@@ -1738,6 +1739,13 @@ void Tab::toggle_line(const std::string &opt_key, bool toggle, int opt_index)
|
||||
if (line) line->toggle_visible = toggle;
|
||||
};
|
||||
|
||||
void Tab::set_option_label(const std::string &opt_key, const wxString &label, int opt_index)
|
||||
{
|
||||
if (!m_active_page) return;
|
||||
Line *line = m_active_page->get_line(opt_key, opt_index);
|
||||
if (line) line->set_label(label);
|
||||
}
|
||||
|
||||
// To be called by custom widgets, load a value into a config,
|
||||
// update the preset selection boxes (the dirty flags)
|
||||
// If value is saved before calling this function, put saved_value = true,
|
||||
@@ -2816,6 +2824,7 @@ void TabPrint::build()
|
||||
optgroup->append_single_option_line("fill_multiline", "strength_settings_infill#fill-multiline");
|
||||
optgroup->append_single_option_line("sparse_infill_pattern", "strength_settings_infill#sparse-infill-pattern");
|
||||
optgroup->append_single_option_line("gyroid_optimized", "strength_settings_patterns#gyroid-optimized");
|
||||
optgroup->append_single_option_line("sparse_infill_smooth_factor", "strength_settings_patterns#sparse-infill-smooth-factor");
|
||||
optgroup->append_single_option_line("infill_direction", "strength_settings_infill#direction");
|
||||
optgroup->append_single_option_line("sparse_infill_rotate_template", "strength_settings_infill_rotation_template_metalanguage");
|
||||
optgroup->append_single_option_line("skin_infill_density", "strength_settings_patterns#locked-zag");
|
||||
@@ -3069,6 +3078,7 @@ void TabPrint::build()
|
||||
optgroup->append_single_option_line("combine_brims", "others_settings_brim#combine-brims");
|
||||
optgroup->append_single_option_line("brim_ears_max_angle", "others_settings_brim#ear-max-angle");
|
||||
optgroup->append_single_option_line("brim_ears_detection_length", "others_settings_brim#ear-detection-radius");
|
||||
optgroup->append_single_option_line("brim_ears_outer_only", "others_settings_brim#brim-ears-outer-only");
|
||||
|
||||
optgroup = page->new_optgroup(L("Special mode"), L"param_special");
|
||||
optgroup->append_single_option_line("slicing_mode", "others_settings_special_mode#slicing-mode");
|
||||
@@ -3997,13 +4007,12 @@ void TabFilament::add_filament_overrides_page()
|
||||
|
||||
const int extruder_idx = 0; // #ys_FIXME
|
||||
|
||||
ConfigOptionsGroupShp retraction_optgroup = page->new_optgroup(L("Retraction"), L"param_retraction");
|
||||
auto append_retraction_option = [this, retraction_optgroup](const std::string& opt_key, int opt_index)
|
||||
auto append_retraction_option = [this](ConfigOptionsGroupShp optgroup, const std::string& opt_key, int opt_index)
|
||||
{
|
||||
Line line {"",""};
|
||||
line = retraction_optgroup->create_single_option_line(retraction_optgroup->get_option(opt_key, opt_index));
|
||||
line = optgroup->create_single_option_line(optgroup->get_option(opt_key, opt_index));
|
||||
|
||||
line.near_label_widget = [this, optgroup_wk = ConfigOptionsGroupWkp(retraction_optgroup), opt_key, opt_index](wxWindow* parent) {
|
||||
line.near_label_widget = [this, optgroup_wk = ConfigOptionsGroupWkp(optgroup), opt_key, opt_index](wxWindow* parent) {
|
||||
auto check_box = new ::CheckBox(parent); // ORCA modernize checkboxes
|
||||
check_box->Bind(wxEVT_TOGGLEBUTTON, [this, optgroup_wk, opt_key, opt_index](wxCommandEvent& evt) {
|
||||
const bool is_checked = evt.IsChecked();
|
||||
@@ -4030,9 +4039,10 @@ void TabFilament::add_filament_overrides_page()
|
||||
return check_box;
|
||||
};
|
||||
|
||||
retraction_optgroup->append_line(line);
|
||||
optgroup->append_line(line);
|
||||
};
|
||||
|
||||
ConfigOptionsGroupShp retraction_optgroup = page->new_optgroup(L("Retraction"), L"param_retraction");
|
||||
for (const std::string opt_key : { "filament_retraction_length",
|
||||
"filament_z_hop",
|
||||
"filament_z_hop_types",
|
||||
@@ -4056,7 +4066,13 @@ void TabFilament::add_filament_overrides_page()
|
||||
//SoftFever
|
||||
// "filament_seam_gap"
|
||||
})
|
||||
append_retraction_option(opt_key, extruder_idx);
|
||||
append_retraction_option(retraction_optgroup, opt_key, extruder_idx);
|
||||
|
||||
ConfigOptionsGroupShp toolchange_optgroup = page->new_optgroup(L("Retraction when switching material"), L"param_retraction_material_change");
|
||||
for (const std::string opt_key : { "filament_retract_length_toolchange",
|
||||
"filament_retract_restart_extra_toolchange"
|
||||
})
|
||||
append_retraction_option(toolchange_optgroup, opt_key, extruder_idx);
|
||||
|
||||
ConfigOptionsGroupShp ironing_optgroup = page->new_optgroup(L("Ironing"), L"param_ironing");
|
||||
auto append_ironing_option = [this, ironing_optgroup](const std::string& opt_key, int opt_index)
|
||||
@@ -4171,6 +4187,8 @@ void TabFilament::update_filament_overrides_page(const DynamicPrintConfig* print
|
||||
"filament_retraction_speed",
|
||||
"filament_deretraction_speed",
|
||||
"filament_retract_restart_extra",
|
||||
"filament_retract_length_toolchange",
|
||||
"filament_retract_restart_extra_toolchange",
|
||||
"filament_retraction_minimum_travel",
|
||||
"filament_retract_when_changing_layer",
|
||||
"filament_wipe",
|
||||
@@ -4201,7 +4219,8 @@ void TabFilament::update_filament_overrides_page(const DynamicPrintConfig* print
|
||||
is_checked &= !dynamic_cast<ConfigOptionVectorBase*>(m_config->option(opt_key))->is_nil(extruder_idx);
|
||||
m_overrides_options[opt_key]->SetValue(is_checked);
|
||||
|
||||
Field* field = optgroup->get_fieldc(opt_key, 0);
|
||||
// the toolchange overrides live in their own optgroup, so search the whole page
|
||||
Field* field = page->get_field(opt_key, 0);
|
||||
if (field == nullptr) continue;
|
||||
|
||||
if (opt_key == "filament_long_retractions_when_cut") {
|
||||
@@ -5007,8 +5026,43 @@ void TabPrinter::build_fff()
|
||||
|
||||
optgroup->append_single_option_line("printer_structure", "printer_basic_information_advanced#printer-structure");
|
||||
optgroup->append_single_option_line("gcode_flavor", "printer_basic_information_advanced#g-code-flavor");
|
||||
optgroup->append_single_option_line("gcode_skip_config_block", "printer_basic_information_advanced#skip-g-code-config-block");
|
||||
optgroup->append_single_option_line("pellet_modded_printer", "printer_basic_information_advanced#pellet-modded-printer");
|
||||
optgroup->append_single_option_line("bbl_use_printhost", "printer_basic_information_advanced#use-3rd-party-print-host");
|
||||
|
||||
// "Printer Agent" dropdown - printer_agent is a coString; gui_type routes it to
|
||||
// PrinterAgentChoice instead of a TextCtrl. Rows and values come from the live agent
|
||||
// registry, and the value is stored as the agent-id string.
|
||||
if (wxGetApp().getAgent() != nullptr)
|
||||
{
|
||||
auto registered_printer_agents = NetworkAgentFactory::get_registered_printer_agents();
|
||||
if (!registered_printer_agents.empty())
|
||||
{
|
||||
ConfigOptionDef def;
|
||||
def.type = coString;
|
||||
def.gui_type = ConfigOptionDef::GUIType::printer_agent_select;
|
||||
def.width = 3 * Field::def_width_wider() / 2;
|
||||
def.label = L("Printer Agent");
|
||||
def.tooltip = L("Select the network agent implementation for printer communication. "
|
||||
"Available agents are registered at startup.");
|
||||
def.mode = comAdvanced;
|
||||
|
||||
// Create the field without get_option() so it is not registered in m_opt_map.
|
||||
// ConfigOptionsGroup handles printer_agent before the generic mapped write path.
|
||||
Line agent_line = optgroup->create_single_option_line(Option(def, "printer_agent"));
|
||||
optgroup->append_line(agent_line);
|
||||
if (Field* agent_field = get_field("printer_agent"))
|
||||
{
|
||||
if (auto* choice = dynamic_cast<PrinterAgentChoice*>(agent_field); choice && choice->getWindow())
|
||||
choice->set_value(m_config->opt_string("printer_agent"), false);
|
||||
}
|
||||
|
||||
// Register by hand so the UnsavedChanges dialog can render a row for it.
|
||||
wxGetApp().sidebar().get_searcher().add_key("printer_agent", m_type, optgroup->title,
|
||||
optgroup->config_category());
|
||||
}
|
||||
}
|
||||
|
||||
optgroup->append_single_option_line("use_3mf");
|
||||
optgroup->append_single_option_line("scan_first_layer" , "printer_basic_information_advanced#scan-first-layer");
|
||||
optgroup->append_single_option_line("enable_power_loss_recovery", "printer_basic_information_advanced#power-loss-recovery");
|
||||
@@ -5875,6 +5929,16 @@ void TabPrinter::reload_config()
|
||||
// so update it implicitly
|
||||
if (m_active_page && m_active_page->title() == "Multimaterial")
|
||||
m_active_page->set_value("extruders_count", int(m_extruders_count));
|
||||
|
||||
// m_opt_map-driven reload does not cover printer_agent, so sync this custom field explicitly.
|
||||
if (Field* agent_field = get_field("printer_agent"))
|
||||
{
|
||||
if (auto* choice = dynamic_cast<PrinterAgentChoice*>(agent_field); choice && choice->getWindow())
|
||||
{
|
||||
const std::string selected_agent = m_config->opt_string("printer_agent");
|
||||
choice->set_value(selected_agent, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TabPrinter::activate_selected_page(std::function<void()> throw_if_canceled)
|
||||
@@ -5885,6 +5949,16 @@ void TabPrinter::activate_selected_page(std::function<void()> throw_if_canceled)
|
||||
// so update it implicitly
|
||||
if (m_active_page && m_active_page->title() == "Multimaterial")
|
||||
m_active_page->set_value("extruders_count", int(m_extruders_count));
|
||||
|
||||
// m_opt_map-driven reload does not cover printer_agent, so sync this custom field explicitly.
|
||||
if (Field* agent_field = get_field("printer_agent"))
|
||||
{
|
||||
if (auto* choice = dynamic_cast<PrinterAgentChoice*>(agent_field); choice && choice->getWindow())
|
||||
{
|
||||
const std::string selected_agent = m_config->opt_string("printer_agent");
|
||||
choice->set_value(selected_agent, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TabPrinter::clear_pages()
|
||||
@@ -7843,6 +7917,24 @@ bool TabPrinter::apply_extruder_cnt_from_cache()
|
||||
return false;
|
||||
}
|
||||
|
||||
void TabPrinter::refresh_printer_agent_dropdown() const
|
||||
{
|
||||
auto* choice = dynamic_cast<PrinterAgentChoice*>(get_field("printer_agent"));
|
||||
if (!choice || !choice->getWindow())
|
||||
return;
|
||||
|
||||
const auto agents = NetworkAgentFactory::get_registered_printer_agents();
|
||||
if (agents.empty())
|
||||
return;
|
||||
|
||||
// why: rows live on PrinterAgentChoice now; rebuild them from the live registry and re-select the stored id.
|
||||
const std::string selected_agent = wxGetApp().preset_bundle->printers.get_edited_preset()
|
||||
.config.opt_string("printer_agent");
|
||||
choice->reload_rows();
|
||||
choice->set_value(selected_agent, false);
|
||||
this->GetParent()->Layout();
|
||||
}
|
||||
|
||||
bool Tab::validate_custom_gcodes()
|
||||
{
|
||||
if (m_type != Preset::TYPE_FILAMENT &&
|
||||
@@ -8938,11 +9030,15 @@ ConfigManipulation Tab::get_config_manipulation()
|
||||
return toggle_line(opt_key, toggle, opt_index >= 0 ? opt_index + 256 : opt_index);
|
||||
};
|
||||
|
||||
auto cb_set_option_label = [this](const t_config_option_key &opt_key, const wxString &label, int opt_index) {
|
||||
return set_option_label(opt_key, label, opt_index >= 0 ? opt_index + 256 : opt_index);
|
||||
};
|
||||
|
||||
auto cb_value_change = [this](const std::string& opt_key, const boost::any& value) {
|
||||
return on_value_change(opt_key, value);
|
||||
};
|
||||
|
||||
return ConfigManipulation(load_config, cb_toggle_field, cb_toggle_line, cb_value_change, nullptr, this);
|
||||
return ConfigManipulation(load_config, cb_toggle_field, cb_toggle_line, cb_value_change, nullptr, this, cb_set_option_label);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user