feat: Python Plugins

This commit is contained in:
Ian Chua
2026-07-02 17:49:36 +08:00
parent 395e070a0e
commit ecddf3d18f
183 changed files with 49955 additions and 2120 deletions

View File

@@ -1075,6 +1075,28 @@ void add_correct_opts_to_options_list(const std::string &opt_key, std::map<std::
map.emplace(opt_key + "#0", value);
}
std::string Tab::options_list_storage_key(const std::string& opt_key) const
{
if (opt_key == "printable_area" || opt_key == "bed_exclude_area" || opt_key == "compatible_prints" ||
opt_key == "compatible_printers" || opt_key == "thumbnails" || opt_key == "wrapping_exclude_area")
return opt_key;
if (m_config == nullptr || !m_config->has(opt_key))
return opt_key;
const ConfigOption* option = m_config->option(opt_key);
if (option == nullptr || !option->is_vector())
return opt_key;
const ConfigOptionDef* def = m_config->def()->get(opt_key);
if (def == nullptr)
return opt_key;
const bool serialized = def->gui_flags == "serialized";
const bool is_plugin_field = def->gui_type == ConfigOptionDef::GUIType::plugin_picker;
return (serialized || is_plugin_field) ? opt_key : opt_key + "#0";
}
void Tab::update_all_extruder_options_status()
{
if (!m_extruder_switch && !m_variant_combo) {
@@ -1243,23 +1265,14 @@ void Tab::check_extruder_options_status(int index, bool &sys_extruder, bool &mod
}
}
}
void Tab::init_options_list()
{
if (!m_options_list.empty())
m_options_list.clear();
for (const std::string& opt_key : m_config->keys())
{
if (opt_key == "printable_area" || opt_key == "bed_exclude_area" || opt_key == "compatible_prints" || opt_key == "compatible_printers" || opt_key == "thumbnails" || opt_key == "wrapping_exclude_area") {
m_options_list.emplace(opt_key, m_opt_status_value);
continue;
}
const ConfigOptionDef* opt_def = m_config->def()->get(opt_key);
if (m_config->option(opt_key)->is_vector() && !(opt_def && opt_def->gui_flags == "serialized"))
m_options_list.emplace(opt_key + "#0", m_opt_status_value);
else
m_options_list.emplace(opt_key, m_opt_status_value);
}
m_options_list.emplace(options_list_storage_key(opt_key), m_opt_status_value);
}
void TabPrinter::init_options_list()
@@ -2047,7 +2060,7 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
bool is_safe_to_rotate = _sparse_infill_pattern == ipRectilinear || _sparse_infill_pattern == ipLine ||
_sparse_infill_pattern == ipZigZag || _sparse_infill_pattern == ipCrossZag ||
_sparse_infill_pattern == ipLockedZag;
auto new_value = boost::any_cast<std::string>(value);
is_safe_to_rotate = is_safe_to_rotate || new_value.empty();
const bool had_previous_value = !m_last_sparse_infill_rotate_template_value.empty();
@@ -3060,6 +3073,12 @@ void TabPrint::build()
option.opt.height = 15;
optgroup->append_single_option_line(option, "others_settings_post_processing_scripts");
optgroup = page->new_optgroup(L("Post-processing Plugin"), L"param_gcode", 0);
optgroup->hide_labels();
option = optgroup->get_option("post_process_plugin");
option.opt.full_width = true;
optgroup->append_single_option_line(option, "others_settings_plugin_picker");
optgroup = page->new_optgroup(L("Notes"), "note", 0);
option = optgroup->get_option("notes");
option.opt.full_width = true;
@@ -4137,7 +4156,7 @@ void TabFilament::update_filament_overrides_page(const DynamicPrintConfig* print
if (og_ironing_it != page->m_optgroups.end())
{
ConfigOptionsGroupShp ironing_optgroup = *og_ironing_it;
std::vector<std::string> ironing_opt_keys = {
"filament_ironing_flow",
"filament_ironing_spacing",
@@ -4149,7 +4168,7 @@ void TabFilament::update_filament_overrides_page(const DynamicPrintConfig* print
{
if (m_overrides_options.find(opt_key) == m_overrides_options.end())
continue;
bool is_checked = !dynamic_cast<ConfigOptionVectorBase*>(m_config->option(opt_key))->is_nil(extruder_idx);
m_overrides_options[opt_key]->Enable(true);
m_overrides_options[opt_key]->SetValue(is_checked);
@@ -4463,7 +4482,7 @@ void TabFilament::build()
optgroup->append_single_option_line("filament_tower_ironing_area", "material_multimaterial#multimaterial-wipe-tower-parameters");
optgroup->append_single_option_line("filament_tower_interface_purge_volume", "material_multimaterial#multimaterial-wipe-tower-parameters");
optgroup->append_single_option_line("filament_tower_interface_print_temp", "material_multimaterial#multimaterial-wipe-tower-parameters");
optgroup = page->new_optgroup(L("Multi Filament"));
// optgroup->append_single_option_line("filament_flush_temp", "", 0);
// optgroup->append_single_option_line("filament_flush_volumetric_speed", "", 0);
@@ -5827,7 +5846,7 @@ void TabPrinter::toggle_options()
const bool support_parallel_printheads = printer_cfg.opt_bool("support_parallel_printheads");
toggle_line("parallel_printheads_count", support_parallel_printheads);
}
if (m_active_page->title() == L("Machine G-code")) {
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
@@ -7814,7 +7833,7 @@ std::vector<wxString> Tab::generate_extruder_options()
wxString extruder_name = _L(DevPrinterConfigUtil::get_toolhead_display_name(
pt, ext_id, ToolHeadComponent::Nozzle, ToolHeadNameCase::TitleCase, true));
NozzleVolumeType volume_type = NozzleVolumeType(nozzle_volumes->values[i]);
// TODO: Orca: Support hybrid
/*if (volume_type == NozzleVolumeType::nvtHybrid) {
options.push_back(wxString::Format(_L("%s: %s"), extruder_name, _L("Standard")));
@@ -7868,7 +7887,7 @@ bool Tab::get_extruder_sync_enable_state(int extruder_id)
if (left_nozzle == right_nozzle) {
return true;
}
// TODO: Orca: Support hybrid
//if (left_nozzle != NozzleVolumeType::nvtHybrid && right_nozzle != NozzleVolumeType::nvtHybrid) {
// return false;