mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-21 20:25:20 +00:00
ENH: enhance auto flush option
1.Support auto flush when change printer and nozzle volume type jira:NONE Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: I9dfc2fff095bbf1901afe99556d1e57aa225f482 (cherry picked from commit f12305832227940eb0eae05817ad046dd4eff02d)
This commit is contained in:
@@ -296,9 +296,9 @@ void AppConfig::set_defaults()
|
||||
if (get("show_daily_tips").empty()) {
|
||||
set_bool("show_daily_tips", true);
|
||||
}
|
||||
//true is auto calculate
|
||||
if (get("auto_calculate").empty()) {
|
||||
set_bool("auto_calculate", true);
|
||||
|
||||
if (get("auto_calculate_flush").empty()){
|
||||
set("auto_calculate_flush","all");
|
||||
}
|
||||
|
||||
if (get("remember_printer_config").empty()) {
|
||||
@@ -309,10 +309,6 @@ void AppConfig::set_defaults()
|
||||
set_bool("enable_high_low_temp_mixed_printing", false);
|
||||
}
|
||||
|
||||
if (get("auto_calculate_when_filament_change").empty()){
|
||||
set_bool("auto_calculate_when_filament_change", true);
|
||||
}
|
||||
|
||||
if (get("ignore_ext_filament_in_filament_map").empty()){
|
||||
set_bool("ignore_ext_filament_in_filament_map", false);
|
||||
}
|
||||
|
||||
@@ -2957,19 +2957,13 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn)
|
||||
if (i >= color_before_sync.size()) {
|
||||
auto_calc_flushing_volumes(i);
|
||||
}
|
||||
else {
|
||||
// if color changed
|
||||
if (color_before_sync[i] != color_opt->values[i]) {
|
||||
else if(color_before_sync[i] != color_opt->values[i] && wxGetApp().app_config->get("auto_calculate_flush") != "disabled"){
|
||||
auto_calc_flushing_volumes(i);
|
||||
}
|
||||
// color don't change, but changes between supporting filament and non supporting filament
|
||||
else {
|
||||
bool flag = is_support_filament(i);
|
||||
if (flag != is_support_before[i])
|
||||
else if(is_support_filament(i) !=is_support_before[i] && wxGetApp().app_config->get("auto_calculate_flush") == "all"){
|
||||
auto_calc_flushing_volumes(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
auto badge_combox_filament = [](PlaterPresetComboBox *c) {
|
||||
auto tip = _L("Filament type and color information have been synchronized, but slot information is not included.");
|
||||
c->SetToolTip(tip);
|
||||
@@ -3314,20 +3308,55 @@ void Sidebar::update_printer_thumbnail()
|
||||
p->image_printer->SetBitmap(create_scaled_bitmap("printer_placeholder", this, 48));
|
||||
}
|
||||
|
||||
void Sidebar::auto_calc_flushing_volumes(const int modify_id)
|
||||
void Sidebar::auto_calc_flushing_volumes(const int filament_idx, const int extruder_id) {
|
||||
|
||||
std::vector<int> filament_indices;
|
||||
std::vector<int> extruder_indices;
|
||||
|
||||
auto& preset_bundle = wxGetApp().preset_bundle;
|
||||
auto filament_ptr = preset_bundle->project_config.option<ConfigOptionStrings>("filament_colour");
|
||||
int filament_count = filament_ptr ? filament_ptr->size() : 0;
|
||||
int extruder_count = preset_bundle->get_printer_extruder_count();
|
||||
|
||||
if (filament_idx < 0) {
|
||||
filament_indices.resize(filament_count);
|
||||
std::iota(filament_indices.begin(), filament_indices.end(), 0);
|
||||
}
|
||||
else {
|
||||
filament_indices.emplace_back(filament_idx);
|
||||
}
|
||||
|
||||
if (extruder_id < 0) {
|
||||
extruder_indices.resize(extruder_count);
|
||||
std::iota(extruder_indices.begin(), extruder_indices.end(), 0);
|
||||
}
|
||||
else {
|
||||
extruder_indices.emplace_back(extruder_id);
|
||||
}
|
||||
|
||||
for (auto eidx : extruder_indices) {
|
||||
for (auto fidx : filament_indices) {
|
||||
auto_calc_flushing_volumes_internal(fidx, eidx);
|
||||
}
|
||||
}
|
||||
|
||||
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
|
||||
wxGetApp().plater()->update_project_dirty_from_presets();
|
||||
wxPostEvent(this, SimpleEvent(EVT_SCHEDULE_BACKGROUND_PROCESS, this));
|
||||
}
|
||||
|
||||
|
||||
void Sidebar::auto_calc_flushing_volumes_internal(const int modify_id, const int extruder_id)
|
||||
{
|
||||
auto& preset_bundle = wxGetApp().preset_bundle;
|
||||
auto& project_config = preset_bundle->project_config;
|
||||
auto& printer_config = preset_bundle->printers.get_edited_preset().config;
|
||||
const auto& full_config = wxGetApp().preset_bundle->full_config();
|
||||
auto& ams_multi_color_filament = preset_bundle->ams_multi_color_filment;
|
||||
size_t extruder_nums = preset_bundle->get_printer_extruder_count();
|
||||
|
||||
size_t nozzle_nums = preset_bundle->get_printer_extruder_count();
|
||||
for (size_t nozzle_id = 0; nozzle_id < nozzle_nums; ++nozzle_id)
|
||||
{
|
||||
std::vector<double> init_matrix = get_flush_volumes_matrix((project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values, nozzle_id, nozzle_nums);
|
||||
std::vector<double> init_matrix = get_flush_volumes_matrix((project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values, extruder_id, extruder_nums);
|
||||
|
||||
const std::vector<int>& min_flush_volumes= get_min_flush_volumes(full_config, nozzle_id);
|
||||
const std::vector<int>& min_flush_volumes = get_min_flush_volumes(full_config, extruder_id);
|
||||
|
||||
ConfigOptionFloat* flush_multi_opt = project_config.option<ConfigOptionFloat>("flush_multiplier");
|
||||
float flush_multiplier = flush_multi_opt ? flush_multi_opt->getFloat() : 1.f;
|
||||
@@ -3410,12 +3439,7 @@ void Sidebar::auto_calc_flushing_volumes(const int modify_id)
|
||||
}
|
||||
}
|
||||
}
|
||||
set_flush_volumes_matrix((project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values, matrix, nozzle_id, nozzle_nums);
|
||||
}
|
||||
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
|
||||
|
||||
wxGetApp().plater()->update_project_dirty_from_presets();
|
||||
wxPostEvent(this, SimpleEvent(EVT_SCHEDULE_BACKGROUND_PROCESS, this));
|
||||
set_flush_volumes_matrix((project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values, matrix, extruder_id, extruder_nums);
|
||||
}
|
||||
|
||||
void Sidebar::jump_to_object(ObjectDataViewModelNode* item)
|
||||
@@ -8036,7 +8060,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
||||
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
|
||||
sidebar->update_dynamic_filament_list();
|
||||
bool flag_is_change = is_support_filament(idx);
|
||||
if (flag != flag_is_change) {
|
||||
if (flag != flag_is_change && wxGetApp().app_config->get("auto_calculate_flush") == "all") {
|
||||
sidebar->auto_calc_flushing_volumes(idx);
|
||||
}
|
||||
auto select_flag = combo->GetFlag(selection);
|
||||
@@ -8057,6 +8081,12 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
||||
else
|
||||
physical_printers.unselect_printer();
|
||||
|
||||
std::string old_preset_name = wxGetApp().preset_bundle->printers.get_edited_preset().name;
|
||||
|
||||
|
||||
if (old_preset_name != preset_name && wxGetApp().app_config->get("auto_calculate_flush") == "all") {
|
||||
wxGetApp().plater()->sidebar().auto_calc_flushing_volumes(-1);
|
||||
}
|
||||
|
||||
// sync extruder info when select multi_extruder preset
|
||||
if (Slic3r::DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager()) {
|
||||
@@ -8124,7 +8154,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
||||
// So, set the focus to the combobox explicitly
|
||||
combo->SetFocus();
|
||||
#endif
|
||||
if (preset_type == Preset::TYPE_FILAMENT && wxGetApp().app_config->get("auto_calculate_when_filament_change") == "true") {
|
||||
if (preset_type == Preset::TYPE_FILAMENT && wxGetApp().app_config->get("auto_calculate_flush") == "all") {
|
||||
wxGetApp().plater()->sidebar().auto_calc_flushing_volumes(idx);
|
||||
}
|
||||
|
||||
@@ -8901,7 +8931,7 @@ void Plater::priv::on_filament_color_changed(wxCommandEvent &event)
|
||||
if (modify_id >= 0 && modify_id < ams_multi_color_filment.size())
|
||||
ams_multi_color_filment[modify_id].clear();
|
||||
|
||||
if (wxGetApp().app_config->get("auto_calculate") == "true") {
|
||||
if (wxGetApp().app_config->get("auto_calculate_flush") != "disabled") {
|
||||
sidebar->auto_calc_flushing_volumes(modify_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +225,13 @@ public:
|
||||
void update_ui_from_settings();
|
||||
bool show_object_list(bool show) const;
|
||||
void finish_param_edit();
|
||||
void auto_calc_flushing_volumes(const int modify_id);
|
||||
|
||||
/**
|
||||
* @brief Automatically calculates flushing volumes
|
||||
* @param filament_idx Specifies the filament index to calculate. -1 indicates all filament indices.
|
||||
* @param extruder_id Specifies the extruder id to calculate. -1 indicates all extruders indices.
|
||||
*/
|
||||
void auto_calc_flushing_volumes(const int filament_idx = -1, const int extruder_id = -1);
|
||||
void jump_to_object(ObjectDataViewModelNode* item);
|
||||
void can_search();
|
||||
#ifdef _MSW_DARK_MODE
|
||||
@@ -242,6 +248,9 @@ public:
|
||||
bool need_auto_sync_after_connect_printer() const { return m_need_auto_sync_after_connect_printer; }
|
||||
void set_need_auto_sync_after_connect_printer(bool need_auto_sync) { m_need_auto_sync_after_connect_printer = need_auto_sync; }
|
||||
|
||||
private:
|
||||
void auto_calc_flushing_volumes_internal(const int filament_id, const int extruder_id);
|
||||
|
||||
private:
|
||||
struct priv;
|
||||
std::unique_ptr<priv> p;
|
||||
|
||||
@@ -1049,10 +1049,8 @@ PreferencesDialog::PreferencesDialog(wxWindow *parent, wxWindowID id, const wxSt
|
||||
if (agent) {
|
||||
json j;
|
||||
std::string value;
|
||||
value = wxGetApp().app_config->get("auto_calculate");
|
||||
value = wxGetApp().app_config->get("auto_calculate_flush");
|
||||
j["auto_flushing"] = value;
|
||||
value = wxGetApp().app_config->get("auto_calculate_when_filament_change");
|
||||
j["auto_calculate_when_filament_change"] = value;
|
||||
agent->track_event("preferences_changed", j.dump());
|
||||
}
|
||||
} catch(...) {}
|
||||
@@ -1226,8 +1224,8 @@ wxWindow* PreferencesDialog::create_general_page()
|
||||
auto item_show_splash_screen = create_item_checkbox(_L("Show splash screen"), page, _L("Show the splash screen during startup."), 50, "show_splash_screen");
|
||||
auto item_hints = create_item_checkbox(_L("Show \"Tip of the day\" notification after start"), page, _L("If enabled, useful hints are displayed at startup."), 50, "show_hints");
|
||||
|
||||
auto item_calc_mode = create_item_checkbox(_L("Flushing volumes: Auto-calculate every time the color changed."), page, _L("If enabled, auto-calculate every time the color changed."), 50, "auto_calculate");
|
||||
auto item_calc_in_long_retract = create_item_checkbox(_L("Flushing volumes: Auto-calculate every time when the filament is changed."), page, _L("If enabled, auto-calculate every time when filament is changed"), 50, "auto_calculate_when_filament_change");
|
||||
std::vector<wxString> FlushOptions = {_L("all"),_L("color change"),_L("disabled")};
|
||||
auto item_auto_flush = create_item_combobox(_L("Auto Flush"), page ,_L("Auto calculate flush volumes"), "auto_calculate_flush",FlushOptions);
|
||||
auto item_remember_printer_config = create_item_checkbox(_L("Remember printer configuration"), page, _L("If enabled, Orca will remember and switch filament/process configuration for each printer automatically."), 50, "remember_printer_config");
|
||||
auto item_step_mesh_setting = create_item_checkbox(_L("Show the step mesh parameter setting dialog."), page, _L("If enabled,a parameter settings dialog will appear during STEP file import."), 50, "enable_step_mesh_setting");
|
||||
auto item_multi_machine = create_item_checkbox(_L("Multi-device Management (Take effect after restarting Orca Slicer)."), page, _L("With this option enabled, you can send a task to multiple devices at the same time and manage multiple devices."), 50, "enable_multi_machine");
|
||||
@@ -1310,6 +1308,7 @@ wxWindow* PreferencesDialog::create_general_page()
|
||||
sizer_page->Add(item_language, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_region, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_currency, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_auto_flush, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_default_page, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_camera_navigation_style, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_single_instance, 0, wxTOP, FromDIP(3));
|
||||
@@ -1320,13 +1319,11 @@ wxWindow* PreferencesDialog::create_general_page()
|
||||
sizer_page->Add(camera_orbit_mult, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_show_splash_screen, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_calc_in_long_retract, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_multi_machine, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_step_mesh_setting, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_auto_arrange, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_mix_print_high_low_temperature, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(title_presets, 0, wxTOP | wxEXPAND, FromDIP(20));
|
||||
sizer_page->Add(item_calc_mode, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_user_sync, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_system_sync, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_remember_printer_config, 0, wxTOP, FromDIP(3));
|
||||
|
||||
@@ -1725,19 +1725,6 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -1 means caculate all
|
||||
auto update_flush_volume = [](int idx = -1) {
|
||||
if (idx < 0) {
|
||||
size_t filament_size = wxGetApp().plater()->get_extruder_colors_from_plater_config().size();
|
||||
for (size_t i = 0; i < filament_size; ++i)
|
||||
wxGetApp().plater()->sidebar().auto_calc_flushing_volumes(i);
|
||||
}
|
||||
else
|
||||
wxGetApp().plater()->sidebar().auto_calc_flushing_volumes(idx);
|
||||
};
|
||||
|
||||
|
||||
string opt_key_without_idx = opt_key.substr(0, opt_key.find('#'));
|
||||
|
||||
if (opt_key_without_idx == "long_retractions_when_cut") {
|
||||
@@ -1748,6 +1735,9 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
||||
"Although it can notably reduce flush, it may also elevate the risk of nozzle clogs or other printing complications."), "", wxICON_WARNING | wxOK);
|
||||
dialog.ShowModal();
|
||||
}
|
||||
if (wxGetApp().app_config->get("auto_calculate_flush") == "all"){
|
||||
wxGetApp().plater()->sidebar().auto_calc_flushing_volumes(-1);
|
||||
}
|
||||
}
|
||||
|
||||
if (opt_key == "filament_long_retractions_when_cut"){
|
||||
@@ -1759,6 +1749,9 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
||||
"Please use with the latest printer firmware."), "", wxICON_WARNING | wxOK);
|
||||
dialog.ShowModal();
|
||||
}
|
||||
if (wxGetApp().app_config->get("auto_calculate_flush") == "all"){
|
||||
wxGetApp().plater()->sidebar().auto_calc_flushing_volumes(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1799,6 +1792,9 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
||||
tab->update_extruder_variants(extruder_idx);
|
||||
tab->reload_config();
|
||||
}
|
||||
if (wxGetApp().app_config->get("auto_calculate_flush") == "all") {
|
||||
wxGetApp().plater()->sidebar().auto_calc_flushing_volumes(-1,extruder_idx);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_preset_bundle->get_printer_extruder_count() > 1){
|
||||
|
||||
@@ -492,7 +492,7 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
|
||||
message_sizer->Add(m_tip_message_label, 0, wxEXPAND | wxALL, TIP_MESSAGES_PADDING);
|
||||
}
|
||||
m_sizer_advanced->Add(tip_message_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
|
||||
bool is_show = wxGetApp().app_config->get("auto_calculate") == "true" || wxGetApp().app_config->get("auto_calculate_when_filament_change") == "true";
|
||||
bool is_show = wxGetApp().app_config->get("auto_calculate_flush") != "disabled";
|
||||
tip_message_panel->Show(is_show);
|
||||
m_sizer_advanced->AddSpacer(FromDIP(10));
|
||||
auto calc_btn_sizer = create_calc_btn_sizer(m_page_advanced);
|
||||
|
||||
Reference in New Issue
Block a user