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
This commit is contained in:
parent
8f92391717
commit
f123058322
|
@ -266,19 +266,15 @@ 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("enable_high_low_temp_mixed_printing").empty()){
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -3084,19 +3084,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);
|
||||
|
@ -3442,20 +3436,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;
|
||||
|
@ -3538,12 +3567,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)
|
||||
|
@ -8054,7 +8078,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
|||
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
|
||||
dynamic_filament_list.update();
|
||||
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);
|
||||
|
@ -8086,6 +8110,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
|||
preset->is_visible = true; // force visible
|
||||
preset_name = preset->name;
|
||||
}
|
||||
std::string old_preset_name = wxGetApp().preset_bundle->printers.get_edited_preset().name;
|
||||
|
||||
update_objects_position_when_select_preset([this, &preset_type, &preset_name]() {
|
||||
wxWindowUpdateLocker noUpdates2(sidebar->filament_panel());
|
||||
|
@ -8094,6 +8119,11 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
|||
q->on_config_change(wxGetApp().preset_bundle->full_config());
|
||||
});
|
||||
|
||||
|
||||
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()) {
|
||||
MachineObject *obj = dev->get_selected_machine();
|
||||
|
@ -8131,7 +8161,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);
|
||||
}
|
||||
|
||||
|
@ -8912,7 +8942,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);
|
||||
}
|
||||
}
|
||||
|
@ -9472,13 +9502,6 @@ void Plater::priv::update_objects_position_when_select_preset(const std::functio
|
|||
#endif
|
||||
view3D->deselect_all();
|
||||
}
|
||||
|
||||
#if 0 // do not toggle auto calc when change printer
|
||||
// update flush matrix
|
||||
size_t filament_size = wxGetApp().plater()->get_extruder_colors_from_plater_config().size();
|
||||
for (size_t idx = 0; idx < filament_size; ++idx)
|
||||
wxGetApp().plater()->sidebar().auto_calc_flushing_volumes(idx);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Plater::orient()
|
||||
|
|
|
@ -213,7 +213,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
|
||||
|
@ -234,6 +240,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;
|
||||
|
|
|
@ -1005,10 +1005,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(...) {}
|
||||
|
@ -1166,9 +1164,9 @@ wxWindow* PreferencesDialog::create_general_page()
|
|||
auto item_bed_type_follow_preset = create_item_checkbox(_L("Auto plate type"), page,
|
||||
_L("Studio will remember build plate selected last time for certain printer model."), 50,
|
||||
"user_bed_type");
|
||||
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_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 when the color is changed."), page, _L("If enabled, auto-calculate every time when the color is 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");
|
||||
auto item_multi_machine = create_item_checkbox(_L("Multi-device Management(Take effect after restarting Studio)."), 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");
|
||||
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_beta_version_update = create_item_checkbox(_L("Support beta version update."), page, _L("With this option enabled, you can receive beta version updates."), 50, "enable_beta_version_update");
|
||||
|
@ -1275,11 +1273,10 @@ 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_single_instance, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_bed_type_follow_preset, 0, wxTOP, FromDIP(3));
|
||||
//sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3));
|
||||
sizer_page->Add(item_calc_mode, 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_beta_version_update, 0, wxTOP, FromDIP(3));
|
||||
|
|
|
@ -1568,19 +1568,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") {
|
||||
|
@ -1591,6 +1578,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"){
|
||||
|
@ -1601,6 +1591,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.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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1621,6 +1614,9 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
|||
for (auto tab : wxGetApp().model_tabs_list) {
|
||||
tab->update_extruder_variants(extruder_idx);
|
||||
}
|
||||
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){
|
||||
|
|
|
@ -405,7 +405,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);
|
||||
|
|
Loading…
Reference in New Issue