ENH:Fix the issues discovered in the demo

jira: STUDIO-10384 STUDIO-10385 STUDIO-10387
Change-Id: I68f3099b9fbb6d6996373cae07b2e62930ce614c
This commit is contained in:
zhou.xu 2025-02-13 15:57:07 +08:00 committed by lane.wei
parent d30ca5baa0
commit 91df890100
7 changed files with 41 additions and 13 deletions

View File

@ -171,9 +171,9 @@ void AppConfig::set_defaults()
set_bool("reverse_mouse_wheel_zoom", false);
#endif
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

@ -2048,7 +2048,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

@ -2967,22 +2967,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

@ -65,7 +65,7 @@ namespace UndoRedo {
}
namespace GUI {
class SyncAmsInfoDialog;
class MainFrame;
class ConfigOptionsGroup;
class ObjectSettings;
@ -124,6 +124,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:
Sidebar(Plater *parent);

View File

@ -400,7 +400,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()) {
@ -4362,6 +4364,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;

View File

@ -1004,11 +1004,11 @@ std::string UrlEncode( const std::string &input )
escaped.fill('0');
escaped << std::hex;
for (char c : input) {
// 如果字符是字母、数字、'-'、'.'、'_' 或 '~',则直接添加到结果中
// 如果字符是字母、数字、'-'、'.'、'_' 或 '~',则直接添加到结果中
if (std::isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~') {
escaped << c;
} else {
// 对于其他字符,将其转换为 %XX 的形式
// 对于其他字符,将其转换为 %XX 的形式
escaped << '%' << std::setw(2) << static_cast<int>(static_cast<unsigned char>(c));
}
}