From 31761a157ca6a5f46fd5bd831e85fd2d40a1b82c Mon Sep 17 00:00:00 2001 From: YXH <2622341340@qq.com> Date: Fri, 23 May 2025 11:17:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E9=95=9C=E5=83=8F=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8E=E5=9E=8B=E5=8F=B7=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreatBot F430NX HS 0.4 nozzle.json | 2 +- .../CreatBot F430NX HS 0.6 nozzle.json | 2 +- src/libslic3r/GCode.cpp | 11 ++- src/libslic3r/Preset.cpp | 2 +- src/libslic3r/Print.cpp | 1 + src/libslic3r/PrintConfig.cpp | 15 ++++ src/libslic3r/PrintConfig.hpp | 7 +- src/slic3r/GUI/Plater.cpp | 81 ++++++++++++++----- src/slic3r/GUI/Plater.hpp | 3 +- src/slic3r/GUI/Tab.cpp | 9 +++ src/slic3r/GUI/Tab.hpp | 1 + 11 files changed, 110 insertions(+), 24 deletions(-) diff --git a/resources/profiles/CreatBot/machine/CreatBot F430NX HS 0.4 nozzle.json b/resources/profiles/CreatBot/machine/CreatBot F430NX HS 0.4 nozzle.json index d0f5b78..c5b3067 100644 --- a/resources/profiles/CreatBot/machine/CreatBot F430NX HS 0.4 nozzle.json +++ b/resources/profiles/CreatBot/machine/CreatBot F430NX HS 0.4 nozzle.json @@ -129,7 +129,7 @@ "0" ], "machine_pause_gcode": "PAUSE", - "machine_start_gcode": "ACTIVATE_MIRROR_MODE\nSTART_PRINT EXTRUDER={nozzle_temperature_initial_layer[0]} EXTRUDER1={nozzle_temperature_initial_layer[1]} BED=[first_layer_bed_temperature]", + "machine_start_gcode": "START_PRINT EXTRUDER={nozzle_temperature_initial_layer[0]} EXTRUDER1={nozzle_temperature_initial_layer[1]} BED=[first_layer_bed_temperature]", "machine_tool_change_time": "0", "machine_unload_filament_time": "0", "manual_filament_change": "0", diff --git a/resources/profiles/CreatBot/machine/CreatBot F430NX HS 0.6 nozzle.json b/resources/profiles/CreatBot/machine/CreatBot F430NX HS 0.6 nozzle.json index 7d819bc..00756ba 100644 --- a/resources/profiles/CreatBot/machine/CreatBot F430NX HS 0.6 nozzle.json +++ b/resources/profiles/CreatBot/machine/CreatBot F430NX HS 0.6 nozzle.json @@ -130,7 +130,7 @@ "0" ], "machine_pause_gcode": "PAUSE", - "machine_start_gcode": "ACTIVATE_MIRROR_MODE\nSTART_PRINT EXTRUDER={nozzle_temperature_initial_layer[0]} EXTRUDER1={nozzle_temperature_initial_layer[1]} BED=[first_layer_bed_temperature]", + "machine_start_gcode": "START_PRINT EXTRUDER={nozzle_temperature_initial_layer[0]} EXTRUDER1={nozzle_temperature_initial_layer[1]} BED=[first_layer_bed_temperature]", "machine_tool_change_time": "0", "machine_unload_filament_time": "0", "manual_filament_change": "0", diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 241c479..80328ad 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2366,7 +2366,16 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato this->placeholder_parser().set("scan_first_layer", new ConfigOptionBool(false)); } } - std::string machine_start_gcode = this->placeholder_parser_process("machine_start_gcode", print.config().machine_start_gcode.value, initial_extruder_id); + std::string machine_start_gcode = ""; + auto print_mode = print.config().print_mode; + if (print_mode == PrintMode::ptMirrored) + { + machine_start_gcode = "ACTIVATE_MIRROR_MODE\n"; + }else if (print_mode == PrintMode::ptDuplication) + { + machine_start_gcode = "ACTIVATE_COPY_MODE\n"; + } + machine_start_gcode += this->placeholder_parser_process("machine_start_gcode", print.config().machine_start_gcode.value, initial_extruder_id); if (print.config().gcode_flavor != gcfKlipper) { // Set bed temperature if the start G-code does not contain any bed temp control G-codes. this->_print_first_layer_bed_temperature(file, print, machine_start_gcode, initial_extruder_id, true); diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index ef19e37..cfe6147 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -880,7 +880,7 @@ static std::vector s_Preset_machine_limits_options { static std::vector s_Preset_printer_options { "printer_technology", - "printable_area", "bed_exclude_area","bed_custom_texture", "bed_custom_model", "gcode_flavor", + "printable_area", "bed_exclude_area","bed_custom_texture", "print_mode", "bed_custom_model", "gcode_flavor", "fan_kickstart", "fan_speedup_time", "fan_speedup_overhangs", "single_extruder_multi_material", "manual_filament_change", "machine_start_gcode", "machine_end_gcode", "before_layer_change_gcode", "printing_by_object_gcode", "layer_change_gcode", "time_lapse_gcode", "change_filament_gcode", "change_extrusion_role_gcode", "printer_model", "printer_variant", "printable_height", "extruder_clearance_radius", "extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod", diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index e67713c..1d32714 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -173,6 +173,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n // BBS "wipe_distance", "curr_bed_type", + "print_mode", "nozzle_volume", "nozzle_hrc", "required_nozzle_HRC", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 13c2186..6c42821 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -418,6 +418,13 @@ static const t_config_enum_values s_keys_map_ZHopType = { }; CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(ZHopType) +static const t_config_enum_values s_keys_map_PrintMode = { + { "Normal mode", ptNorma }, + { "Duplication mode", ptDuplication }, + { "Mirrored mode", ptMirrored } +}; +CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(PrintMode) + static const t_config_enum_values s_keys_map_RetractLiftEnforceType = { {"All Surfaces", rletAllSurfaces}, {"Top Only", rletTopOnly}, @@ -4019,6 +4026,14 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionEnumsGeneric{ ZHopType::zhtSlope }); + def = this->add("print_mode", coEnum); + def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); + def->enum_values.push_back("Normal mode"); + def->enum_values.push_back("Duplication mode"); + def->enum_values.push_back("Mirrored mode"); + def->mode = comSimple; + def->set_default_value(new ConfigOptionEnum(ptNorma)); + def = this->add("travel_slope", coFloats); def->label = L("Traveling angle"); def->tooltip = L("Traveling angle for Slope and Spiral Z hop type. Setting it to 90° results in Normal Lift"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 3f21abd..c268332 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -291,7 +291,11 @@ enum NozzleType { ntBrass, ntCount }; - +enum PrintMode { + ptNorma = 0, + ptDuplication, + ptMirrored +}; static std::unordered_mapNozzleTypeEumnToStr = { {NozzleType::ntUndefine, "undefine"}, {NozzleType::ntHardenedSteel, "hardened_steel"}, @@ -1216,6 +1220,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( //BBS: add bed_exclude_area ((ConfigOptionPoints, bed_exclude_area)) ((ConfigOptionPoints, head_wrap_detect_zone)) + ((ConfigOptionEnum, print_mode)) // BBS ((ConfigOptionString, bed_custom_texture)) ((ConfigOptionString, bed_custom_model)) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 3b97e4d..ad5a743 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -789,19 +789,49 @@ Sidebar::Sidebar(Plater *parent) // Bed type selection wxBoxSizer* bed_type_sizer = new wxBoxSizer(wxHORIZONTAL); - wxStaticText* bed_type_title = new wxStaticText(p->m_panel_printer_content, wxID_ANY, _L("Bed type")); + bed_type_title = new wxStaticText(p->m_panel_printer_content, wxID_ANY, _L("Print mode")); //bed_type_title->SetBackgroundColour(); bed_type_title->Wrap(-1); bed_type_title->SetFont(Label::Body_14); m_bed_type_list = new ComboBox(p->m_panel_printer_content, wxID_ANY, wxString(""), wxDefaultPosition, {-1, FromDIP(30)}, 0, nullptr, wxCB_READONLY); const ConfigOptionDef* bed_type_def = print_config_def.get("curr_bed_type"); - if (bed_type_def && bed_type_def->enum_keys_map) { + /*if (bed_type_def && bed_type_def->enum_keys_map) { for (auto item : bed_type_def->enum_labels) { m_bed_type_list->AppendString(_L(item)); } + }*/ + m_bed_type_list->AppendString(_L("Normal mode")); + m_bed_type_list->AppendString(_L("Duplication mode")); + m_bed_type_list->AppendString(_L("Mirrored mode")); + m_bed_type_list->Select(0); + auto printer_model = wxGetApp().preset_bundle->full_config().opt_string("printer_model"); + if (printer_model != "CreatBot F430NX HS") { + m_bed_type_list->Hide(); + bed_type_title->Hide(); + m_bed_type_list->Select(0); } - bed_type_title->Bind(wxEVT_ENTER_WINDOW, [bed_type_title, this](wxMouseEvent &e) { + m_bed_type_list->Bind(wxEVT_COMBOBOX, [=](wxCommandEvent& e) { + const wxString value = m_bed_type_list->GetValue(); + PrintMode bed_type; + if (value == _L("Normal mode")) { + bed_type = PrintMode::ptNorma; + } + else if (value == _L("Duplication mode")) { + bed_type = PrintMode::ptDuplication; + } + else { + bed_type = PrintMode::ptMirrored; + } + auto& project_config = wxGetApp().preset_bundle->project_config; + project_config.set_key_value("print_mode", new ConfigOptionEnum(bed_type)); + TabPrinter* tab_printer = dynamic_cast(wxGetApp().get_tab(Preset::TYPE_PRINTER)); + tab_printer->update_dirty(); + tab_printer->update_print_mode(); + // e.Skip(); + }); + + /*bed_type_title->Bind(wxEVT_ENTER_WINDOW, [bed_type_title, this](wxMouseEvent &e) { e.Skip(); auto font = bed_type_title->GetFont(); font.SetUnderlined(true); @@ -817,7 +847,7 @@ Sidebar::Sidebar(Plater *parent) }); bed_type_title->Bind(wxEVT_LEFT_UP, [bed_type_title, this](wxMouseEvent &e) { wxLaunchDefaultBrowser("https://github.com/SoftFever/OrcaSlicer/wiki/bed-types"); - }); + });*/ AppConfig *app_config = wxGetApp().app_config; std::string str_bed_type = app_config->get("curr_bed_type"); @@ -828,23 +858,22 @@ Sidebar::Sidebar(Plater *parent) bed_type_value = 1; } - int bed_type_idx = bed_type_value - 1; - m_bed_type_list->Select(bed_type_idx); + int bed_type_idx = 1; + //; bed_type_sizer->Add(bed_type_title, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, FromDIP(SidebarProps::ContentMargin())); bed_type_sizer->Add(m_bed_type_list, 1, wxLEFT | wxEXPAND, FromDIP(SidebarProps::ElementSpacing())); bed_type_sizer->AddSpacer(FromDIP(SidebarProps::ContentMargin())); vsizer_printer->Add(bed_type_sizer, 0, wxEXPAND | wxTOP, FromDIP(5)); vsizer_printer->AddSpacer(FromDIP(16)); - - auto& project_config = wxGetApp().preset_bundle->project_config; + + /*const t_config_enum_values* keys_map = print_config_def.get("curr_bed_type")->enum_keys_map; BedType bed_type = btCount; for (auto item : *keys_map) { if (item.first == str_bed_type) bed_type = (BedType)item.second; }*/ - BedType bed_type = (BedType)bed_type_value; - project_config.set_key_value("curr_bed_type", new ConfigOptionEnum(bed_type)); + p->m_panel_printer_content->SetSizer(vsizer_printer); p->m_panel_printer_content->Layout(); @@ -1299,7 +1328,7 @@ void Sidebar::update_all_preset_comboboxes() //p->m_staticText_filament_settings->Update(); if (is_bbl_vendor || cfg.opt_bool("support_multi_bed_types")) { - m_bed_type_list->Enable(); + // m_bed_type_list->Enable(); // Orca: don't update bed type if loading project if (!p->plater->is_loading_project()) { auto str_bed_type = wxGetApp().app_config->get_printer_setting(wxGetApp().preset_bundle->printers.get_selected_preset_name(), @@ -1310,17 +1339,17 @@ void Sidebar::update_all_preset_comboboxes() bed_type_value = preset_bundle.printers.get_edited_preset().get_default_bed_type(&preset_bundle); } - m_bed_type_list->SelectAndNotify(bed_type_value - 1); + //m_bed_type_list->SelectAndNotify(bed_type_value - 1); } else { BedType bed_type = preset_bundle.printers.get_edited_preset().get_default_bed_type(&preset_bundle); - m_bed_type_list->SelectAndNotify((int) bed_type - 1); + // m_bed_type_list->SelectAndNotify((int) bed_type - 1); } } } else { // m_bed_type_list->SelectAndNotify(btPEI - 1); - BedType bed_type = preset_bundle.printers.get_edited_preset().get_default_bed_type(&preset_bundle); + /* BedType bed_type = preset_bundle.printers.get_edited_preset().get_default_bed_type(&preset_bundle); m_bed_type_list->SelectAndNotify((int) bed_type - 1); - m_bed_type_list->Disable(); + m_bed_type_list->Disable();*/ } // Update the print choosers to only contain the compatible presets, update the dirty flags. @@ -1459,6 +1488,20 @@ void Sidebar::update_presets_from_to(Slic3r::Preset::Type preset_type, std::stri BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(": exit!"); } +void Sidebar::showModeSet(bool show) +{ + if (show) { + m_bed_type_list->Show(); + bed_type_title->Show(); + + } + else { + m_bed_type_list->Hide(); + bed_type_title->Hide(); + } + m_bed_type_list->Select(0); +} + void Sidebar::change_top_border_for_mode_sizer(bool increase_border) { // BBS @@ -1704,8 +1747,8 @@ void Sidebar::on_bed_type_change(BedType bed_type) { // btDefault option is not included in global bed type setting int sel_idx = (int)bed_type - 1; - if (m_bed_type_list != nullptr) - m_bed_type_list->SetSelection(sel_idx); + //if (m_bed_type_list != nullptr) + //m_bed_type_list->SetSelection(sel_idx); } std::map Sidebar::build_filament_ams_list(MachineObject* obj) @@ -2796,7 +2839,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) , main_frame(main_frame) //BBS: add bed_exclude_area , config(Slic3r::DynamicPrintConfig::new_from_defaults_keys({ - "printable_area", "bed_exclude_area", "bed_custom_texture", "bed_custom_model", "print_sequence", + "printable_area", "bed_exclude_area", "bed_custom_texture", "bed_custom_model", "print_sequence","print_mode", "extruder_clearance_radius", "extruder_clearance_height_to_lid", "extruder_clearance_height_to_rod", "nozzle_height", "skirt_type", "skirt_loops", "skirt_speed","min_skirt_length", "skirt_distance", "skirt_start_angle", "brim_width", "brim_object_gap", "brim_type", "nozzle_diameter", "single_extruder_multi_material", "preferred_orientation", @@ -13136,6 +13179,8 @@ void Plater::on_config_change(const DynamicPrintConfig &config) else if (opt_key == "printer_model") { p->reset_gcode_toolpaths(); // update to force bed selection(for texturing) + auto printer_model = wxGetApp().preset_bundle->full_config().opt_string("printer_model"); + sidebar().showModeSet(printer_model == "CreatBot F430NX HS"); bed_shape_changed = true; update_scheduled = true; } diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 34f2761..422ae8a 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -140,7 +140,7 @@ public: void update_presets(Slic3r::Preset::Type preset_type); //BBS void update_presets_from_to(Slic3r::Preset::Type preset_type, std::string from, std::string to); - + void showModeSet(bool show); void change_top_border_for_mode_sizer(bool increase_border); void msw_rescale(); void sys_color_changed(); @@ -205,6 +205,7 @@ private: wxBoxSizer* m_scrolled_sizer = nullptr; ComboBox* m_bed_type_list = nullptr; + wxStaticText* bed_type_title = nullptr; ScalableButton* connection_btn = nullptr; ScalableButton* ams_btn = nullptr; }; diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index e04bb0f..90369e1 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1121,6 +1121,15 @@ void Tab::update_dirty() update_changed_ui(); } +void Tab::update_print_mode() +{ + auto print_mode = m_config->option>("print_mode"); + if (print_mode) { + const bool is_normal = print_mode->value == PrintMode::ptNorma; + on_value_change("print_mode", print_mode->value); + } +} + void Tab::update_tab_ui(bool update_plater_presets) { if (m_presets_choice) { diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index cab9990..3c19a20 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -368,6 +368,7 @@ public: virtual void update_custom_dirty() {} void load_initial_data(); void update_dirty(); + void update_print_mode(); //BBS update plater presets if update_plater_presets = true void update_tab_ui(bool update_plater_presets = false); void load_config(const DynamicPrintConfig& config);