ENH:Fix the issues discovered in the demo

jira: STUDIO-10384 STUDIO-10385 STUDIO-10387
Change-Id: I68f3099b9fbb6d6996373cae07b2e62930ce614c
(cherry picked from commit 91df890100199a3e26ef3792a1f8650d2dab8577)
This commit is contained in:
zhou.xu
2025-02-13 15:57:07 +08:00
committed by Noisyfox
parent b8220bb81f
commit 25a195d1f4
6 changed files with 39 additions and 11 deletions

View File

@@ -185,9 +185,9 @@ void AppConfig::set_defaults()
set_bool("reverse_mouse_wheel_zoom", false);
if (get("enable_append_color_by_sync_ams").empty())
set_bool("enable_append_color_by_sync_ams", false);
set_bool("enable_append_color_by_sync_ams", true);
if (get("enable_merge_color_by_sync_ams").empty())
set_bool("enable_merge_color_by_sync_ams", true);
set_bool("enable_merge_color_by_sync_ams", false);
if (get("ams_sync_match_full_use_color_dist").empty())
set_bool("ams_sync_match_full_use_color_dist", false);

View File

@@ -2184,7 +2184,22 @@ unsigned int PresetBundle::sync_ams_list(unsigned int &unknowns, bool use_map, s
[](std::vector<std::string> &value) { return value.empty(); }),
ams_multi_color_filment.end());
if (need_append_colors.size() > 0 && enable_append) {
auto get_idx_in_array = [](std::vector<std::string> &presets, std::vector<std::string> &colors, const std::string &preset, const std::string &color) -> int {
for (size_t i = 0; i < presets.size(); i++) {
if (presets[i] == preset && colors[i] == color) {
return i;
}
}
return -1;
};
for (size_t i = 0; i < need_append_colors.size(); i++){
if (exist_filament_presets.size() >= size_t(EnforcerBlockerType::ExtruderMax)){
break;
}
auto idx = get_idx_in_array(exist_filament_presets, exist_colors, need_append_colors[i].filament_preset, need_append_colors[i].filament_color);
if (idx >= 0) {
continue;
}
exist_filament_presets.push_back(need_append_colors[i].filament_preset);
exist_colors.push_back(need_append_colors[i].filament_color);
std::vector<std::string> value = {need_append_colors[i].filament_color};

View File

@@ -2839,22 +2839,26 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn)
temp_info.use_dialog_pos = false;
temp_info.cancel_text_to_later = is_from_big_sync_btn;
temp_info.connected_printer = true;
SyncAmsInfoDialog sync_dlg(this, temp_info);
if (m_sync_dlg == nullptr) {
m_sync_dlg = std::make_shared<SyncAmsInfoDialog>(this, temp_info);
} else {
m_sync_dlg->set_info(temp_info);
}
int dlg_res{(int) wxID_CANCEL};
if (sync_dlg.is_need_show()) {
if (sync_dlg.is_dirty_filament()){
if (m_sync_dlg->is_need_show()) {
if (m_sync_dlg->is_dirty_filament()) {
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->select_preset(wxGetApp().preset_bundle->filament_presets[0], false, "", false, true);
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
dynamic_filament_list.update();
}
sync_dlg.set_check_dirty_fialment(false);
dlg_res = sync_dlg.ShowModal();
m_sync_dlg->set_check_dirty_fialment(false);
dlg_res = m_sync_dlg->ShowModal();
} else {
dlg_res =(int) wxID_YES;
}
if (dlg_res == wxID_CANCEL)
return;
auto sync_result = sync_dlg.get_result();
auto sync_result = m_sync_dlg->get_result();
if (!sync_result.is_same_printer) {
return;
}

View File

@@ -64,7 +64,7 @@ namespace UndoRedo {
}
namespace GUI {
class SyncAmsInfoDialog;
class MainFrame;
class ConfigOptionsGroup;
class ObjectSettings;
@@ -132,6 +132,7 @@ class Sidebar : public wxPanel
std::vector<BedType> m_cur_combox_bed_types;
int m_last_combo_bedtype_count{0};
bool m_begin_sync_printer_status{false};
std::shared_ptr<SyncAmsInfoDialog> m_sync_dlg{nullptr};
public:
enum DockingState

View File

@@ -402,7 +402,9 @@ void SyncAmsInfoDialog::update_map_when_change_map_mode()
for (size_t i = 0; i < m_preview_colors_in_thumbnail.size(); i++) {
if (i < m_ams_combo_info.ams_filament_colors.size()) {
auto result = decode_ams_color(m_ams_combo_info.ams_filament_colors[i]);
m_cur_colors_in_thumbnail[i] = result;
if (i < m_cur_colors_in_thumbnail.size()) {
m_cur_colors_in_thumbnail[i] = result;
}
}
else {
if (!m_cur_colors_in_thumbnail.empty()) {
@@ -4355,6 +4357,11 @@ SyncAmsInfoDialog::~SyncAmsInfoDialog() {
}
}
void SyncAmsInfoDialog::set_info(SyncInfo &info)
{
m_input_info = info;
}
void SyncAmsInfoDialog::update_lan_machine_list()
{
DeviceManager *dev = wxGetApp().getDeviceManager();

View File

@@ -270,6 +270,7 @@ public:
};
SyncAmsInfoDialog(wxWindow *parent, SyncInfo &info);
~SyncAmsInfoDialog();
void set_info(SyncInfo &info);
void on_dpi_changed(const wxRect &suggested_rect) override;
const SyncResult &get_result() { return m_result; }
@@ -351,7 +352,7 @@ private:
bool m_is_empty_project = true;
bool m_check_dirty_fialment = true;
bool m_expand_more_settings = false;
bool m_expand_more_settings = true;
bool m_image_is_top = false;
const int LEFT_THUMBNAIL_SIZE_WIDTH = 100;