mirror of
https://github.com/QIDITECH/QIDIStudio.git
synced 2026-02-07 12:21:50 +03:00
update slic3r
This commit is contained in:
@@ -124,8 +124,10 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const
|
||||
else
|
||||
e.Skip();
|
||||
});
|
||||
Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_suppress_change = false; });
|
||||
Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent&) { m_suppress_change = true; });
|
||||
Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent &) {
|
||||
m_suppress_change = false;
|
||||
});
|
||||
Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent&) { m_suppress_change = true; });
|
||||
|
||||
Bind(wxEVT_COMBOBOX, &PresetComboBox::OnSelect, this);
|
||||
}
|
||||
@@ -179,7 +181,7 @@ void PresetComboBox::invalidate_selection()
|
||||
|
||||
void PresetComboBox::validate_selection(bool predicate/*=false*/)
|
||||
{
|
||||
if (predicate ||
|
||||
if (predicate &&
|
||||
// just in case: mark m_last_selected as a first added element
|
||||
m_last_selected == INT_MAX)
|
||||
m_last_selected = GetCount() - 1;
|
||||
@@ -191,7 +193,9 @@ void PresetComboBox::update_selection()
|
||||
* there is no presets added to the list.
|
||||
* So, select last combobox item ("Add/Remove preset")
|
||||
*/
|
||||
validate_selection();
|
||||
//validate_selection();
|
||||
if (m_last_selected == INT_MAX)
|
||||
m_last_selected = 1;
|
||||
|
||||
SetSelection(m_last_selected);
|
||||
#ifdef __WXMSW__
|
||||
@@ -234,7 +238,7 @@ int PresetComboBox::update_ams_color()
|
||||
auto &ams_list = wxGetApp().preset_bundle->filament_ams_list;
|
||||
auto iter = ams_list.find(idx);
|
||||
if (iter == ams_list.end()) {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": ams %1% out of range %2%") % idx % ams_list.size();
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": box %1% out of range %2%") % idx % ams_list.size();
|
||||
return -1;
|
||||
}
|
||||
color = iter->second.opt_string("filament_colour", 0u);
|
||||
@@ -282,6 +286,46 @@ wxString PresetComboBox::get_tooltip(const Preset &preset)
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
wxString PresetComboBox::get_preset_item_name(unsigned int index)
|
||||
{
|
||||
if (m_type == Preset::TYPE_PRINTER) {
|
||||
int idx = selected_connected_printer(index);
|
||||
if (idx < 0) {
|
||||
m_selected_dev_id.clear();
|
||||
return GetString(index);
|
||||
}
|
||||
else {
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) {
|
||||
assert(false);
|
||||
m_selected_dev_id.clear();
|
||||
return GetString(index);
|
||||
}
|
||||
|
||||
std::map<std::string, MachineObject *> machine_list = dev->get_my_machine_list();
|
||||
if (machine_list.empty()) {
|
||||
assert(false);
|
||||
m_selected_dev_id.clear();
|
||||
return GetString(index);
|
||||
}
|
||||
|
||||
auto iter = m_backup_dev_list_sorted.begin();
|
||||
std::advance(iter, idx);
|
||||
if (iter != m_backup_dev_list_sorted.end() && machine_list.find(*iter) != machine_list.end()) {
|
||||
m_selected_dev_id = *iter;
|
||||
Preset* machine_preset = get_printer_preset(machine_list[*iter]);
|
||||
if (machine_preset) {
|
||||
dev->set_selected_machine(*iter);
|
||||
return from_u8(machine_preset->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_selected_dev_id.clear();
|
||||
return GetString(index);
|
||||
}
|
||||
|
||||
wxString PresetComboBox::get_preset_name(const Preset & preset)
|
||||
{
|
||||
return from_u8(preset.name/* + suffix(preset)*/);
|
||||
@@ -371,17 +415,89 @@ void PresetComboBox::update_from_bundle()
|
||||
this->update(m_collection->get_selected_preset().name);
|
||||
}
|
||||
|
||||
void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
|
||||
void PresetComboBox::add_connected_printers(std::string selected, bool alias_name)
|
||||
{
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
std::map<std::string, MachineObject *> machine_list = dev->get_my_machine_list();
|
||||
if (machine_list.empty())
|
||||
return;
|
||||
|
||||
set_label_marker(Append(separator(L("My Printer")), wxNullBitmap));
|
||||
m_first_printer_idx = GetCount();
|
||||
|
||||
// sort list
|
||||
std::vector<std::pair<std::string, MachineObject *>> user_machine_list;
|
||||
m_backup_dev_list.clear();
|
||||
for (auto &it : machine_list) {
|
||||
m_backup_dev_list.push_back(it.first);
|
||||
user_machine_list.push_back(it);
|
||||
}
|
||||
|
||||
std::sort(user_machine_list.begin(), user_machine_list.end(), [&](auto &a, auto &b) {
|
||||
if (a.second && b.second) { return a.second->dev_name.compare(b.second->dev_name) < 0; }
|
||||
return false;
|
||||
});
|
||||
|
||||
m_backup_dev_list_sorted.clear();
|
||||
for (auto &it : user_machine_list) {
|
||||
m_backup_dev_list_sorted.push_back(it.first);
|
||||
}
|
||||
|
||||
for (auto iter = user_machine_list.begin(); iter != user_machine_list.end(); ++iter) {
|
||||
Preset* printer_preset = get_printer_preset(iter->second);
|
||||
if (!printer_preset)
|
||||
continue;
|
||||
printer_preset->is_visible = true;
|
||||
auto printer_model = printer_preset->config.opt_string("printer_model");
|
||||
boost::replace_all(printer_model, "QIDI TECH ", "");
|
||||
auto text = iter->second->dev_name + " (" + printer_model + ")";
|
||||
int item_id = Append(from_u8(text), wxNullBitmap, &m_first_printer_idx + std::distance(user_machine_list.begin(), iter));
|
||||
validate_selection(m_selected_dev_id == iter->first);
|
||||
}
|
||||
m_last_printer_idx = GetCount();
|
||||
}
|
||||
|
||||
int PresetComboBox::selected_connected_printer(int index) const
|
||||
{
|
||||
if (m_first_printer_idx && index >= m_first_printer_idx && index < m_last_printer_idx) {
|
||||
return reinterpret_cast<int *>(GetClientData(index)) - &m_first_printer_idx;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
|
||||
{
|
||||
bool selected_in_ams = false;
|
||||
bool is_qdt_vendor_preset = m_preset_bundle->printers.get_edited_preset().is_qdt_vendor_preset(m_preset_bundle);
|
||||
if (is_qdt_vendor_preset && !m_preset_bundle->filament_ams_list.empty()) {
|
||||
set_label_marker(Append(separator(L("BOX filaments")), wxNullBitmap));
|
||||
bool dual_extruder = (m_preset_bundle->filament_ams_list.begin()->first & 0x10000) == 0;
|
||||
set_label_marker(Append(separator(dual_extruder ? L("Left filaments") : L("BOX filaments")), wxNullBitmap));
|
||||
m_first_ams_filament = GetCount();
|
||||
auto &filaments = m_collection->get_presets();
|
||||
|
||||
int icon_width = 24;
|
||||
for (auto &entry : m_preset_bundle->filament_ams_list) {
|
||||
auto & tray = entry.second;
|
||||
auto name = tray.opt_string("tray_name", 0u);
|
||||
if (name.size() > 3)
|
||||
icon_width = 32;
|
||||
}
|
||||
|
||||
for (auto &entry : m_preset_bundle->filament_ams_list) {
|
||||
if (dual_extruder && (entry.first & 0x10000)) {
|
||||
dual_extruder = false;
|
||||
set_label_marker(Append(separator(L("Right filaments")), wxNullBitmap));
|
||||
}
|
||||
auto & tray = entry.second;
|
||||
std::string filament_id = tray.opt_string("filament_id", 0u);
|
||||
if (filament_id.empty()) continue;
|
||||
auto name = tray.opt_string("tray_name", 0u);
|
||||
if (filament_id.empty()) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": %1% 's filament_id is empty.") % name;
|
||||
continue;
|
||||
}
|
||||
auto iter = std::find_if(filaments.begin(), filaments.end(),
|
||||
[&filament_id, this](auto &f) { return f.is_compatible && m_collection->get_preset_base(f) == &f && f.filament_id == filament_id; });
|
||||
if (iter == filaments.end()) {
|
||||
@@ -398,19 +514,34 @@ void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
|
||||
}
|
||||
const_cast<Preset&>(*iter).is_visible = true;
|
||||
auto color = tray.opt_string("filament_colour", 0u);
|
||||
auto name = tray.opt_string("tray_name", 0u);
|
||||
wxBitmap bmp(*get_extruder_color_icon(color, name, 24, 16));
|
||||
int item_id = Append(get_preset_name(*iter), bmp.ConvertToImage(), &m_first_ams_filament + entry.first);
|
||||
wxBitmap bmp(*get_extruder_color_icon(color, name, icon_width, 16));
|
||||
auto text = get_preset_name(*iter);
|
||||
int item_id = Append(text, bmp.ConvertToImage(), &m_first_ams_filament + entry.first);
|
||||
SetFlag(GetCount() - 1, (int) FilamentAMSType::FROM_AMS);
|
||||
if (text == selected) {
|
||||
DynamicPrintConfig *cfg = &wxGetApp().preset_bundle->project_config;
|
||||
if (cfg) {
|
||||
auto colors = static_cast<ConfigOptionStrings *>(cfg->option("filament_colour")->clone());
|
||||
if (m_filament_idx < colors->values.size()) {
|
||||
auto cur_color = colors->values[m_filament_idx];
|
||||
if (color == cur_color) {
|
||||
selected_in_ams = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//validate_selection(id->value == selected); // can not select
|
||||
}
|
||||
m_last_ams_filament = GetCount();
|
||||
}
|
||||
return selected_in_ams;
|
||||
}
|
||||
|
||||
//w42
|
||||
void PresetComboBox::add_box_filaments(std::string selected, bool alias_name)
|
||||
bool PresetComboBox::add_box_filaments(std::string selected, bool alias_name)
|
||||
{
|
||||
bool is_qdt_vendor_preset = true; //m_preset_bundle->printers.get_edited_preset().is_qdt_vendor_preset(m_preset_bundle);
|
||||
bool selected_in_box =false;
|
||||
if (is_qdt_vendor_preset && !m_preset_bundle->filament_ams_list.empty()) {
|
||||
set_label_marker(Append(separator(L("BOX filaments")), wxNullBitmap));
|
||||
m_first_ams_filament = GetCount();
|
||||
@@ -421,13 +552,14 @@ void PresetComboBox::add_box_filaments(std::string selected, bool alias_name)
|
||||
if (filament_id.empty()) continue;
|
||||
|
||||
auto iter = std::find_if(filaments.begin(), filaments.end(),
|
||||
[&filament_id, this](auto& f) { return f.filament_id == filament_id; });
|
||||
[&filament_id, this](auto& f) { return f.filament_id == filament_id; });
|
||||
if (iter == filaments.end()) {
|
||||
auto filament_type = tray.opt_string("filament_type", 0u);
|
||||
if (!filament_type.empty()) {
|
||||
filament_type = "Generic " + filament_type;
|
||||
//y59
|
||||
filament_type = "QIDI " + filament_type;
|
||||
iter = std::find_if(filaments.begin(), filaments.end(),
|
||||
[&filament_type](auto& f) { return f.is_system; });
|
||||
[&filament_type](auto& f) { return f.is_compatible && f.is_system && f.name.find(filament_type) != std::string::npos ; });
|
||||
}
|
||||
}
|
||||
if (iter == filaments.end()) {
|
||||
@@ -436,13 +568,27 @@ void PresetComboBox::add_box_filaments(std::string selected, bool alias_name)
|
||||
}
|
||||
const_cast<Preset&>(*iter).is_visible = true;
|
||||
auto color = tray.opt_string("filament_colour", 0u);
|
||||
auto name = tray.opt_string("tray_name", 0u);
|
||||
auto name = tray.opt_string("tray_name", 0u);
|
||||
wxBitmap bmp(*get_extruder_color_icon(color, name, 24, 16));
|
||||
int item_id = Append(get_preset_name(*iter), bmp.ConvertToImage(), &m_first_ams_filament + entry.first);
|
||||
//validate_selection(id->value == selected); // can not select
|
||||
auto text = get_preset_name(*iter);
|
||||
int item_id = Append(text, bmp.ConvertToImage(), &m_first_ams_filament + entry.first);
|
||||
SetFlag(GetCount() - 1, (int) FilamentAMSType::FROM_AMS);
|
||||
if (text == selected) {
|
||||
DynamicPrintConfig *cfg = &wxGetApp().preset_bundle->project_config;
|
||||
if (cfg) {
|
||||
auto colors = static_cast<ConfigOptionStrings *>(cfg->option("filament_colour")->clone());
|
||||
if (m_filament_idx < colors->values.size()) {
|
||||
auto cur_color = colors->values[m_filament_idx];
|
||||
if (color == cur_color) {
|
||||
selected_in_box = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_last_ams_filament = GetCount();
|
||||
}
|
||||
return selected_in_box;
|
||||
}
|
||||
|
||||
int PresetComboBox::selected_ams_filament() const
|
||||
@@ -623,6 +769,13 @@ bool PresetComboBox::is_selected_physical_printer()
|
||||
return marker == LABEL_ITEM_PHYSICAL_PRINTER;
|
||||
}
|
||||
|
||||
bool PresetComboBox::is_selected_printer_model()
|
||||
{
|
||||
auto selected_item = this->GetSelection();
|
||||
auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
|
||||
return marker == LABEL_ITEM_PRINTER_MODELS;
|
||||
}
|
||||
|
||||
bool PresetComboBox::selection_is_changed_according_to_physical_printers()
|
||||
{
|
||||
if (m_type != Preset::TYPE_PRINTER || !is_selected_physical_printer())
|
||||
@@ -827,6 +980,13 @@ void PlaterPresetComboBox::OnSelect(wxCommandEvent &evt)
|
||||
evt.Skip();
|
||||
}
|
||||
|
||||
void PlaterPresetComboBox::update_badge_according_flag() {
|
||||
auto selection = GetSelection();
|
||||
auto select_flag = GetFlag(selection);
|
||||
auto ok = select_flag == (int) PresetComboBox::FilamentAMSType::FROM_AMS;
|
||||
ShowBadge(ok);
|
||||
}
|
||||
|
||||
bool PlaterPresetComboBox::switch_to_tab()
|
||||
{
|
||||
Tab* tab = wxGetApp().get_tab(m_type);
|
||||
@@ -973,7 +1133,12 @@ void PlaterPresetComboBox::update()
|
||||
filament_color = m_preset_bundle->project_config.opt_string("filament_colour", (unsigned int) m_filament_idx);
|
||||
wxColor clr(filament_color);
|
||||
clr_picker->SetBackgroundColour(clr);
|
||||
clr_picker->SetBitmap(*get_extruder_color_icons(true)[m_filament_idx]);
|
||||
std::vector<wxBitmap *> bitmaps = get_extruder_color_icons(true);
|
||||
if (m_filament_idx < bitmaps.size()) {
|
||||
clr_picker->SetBitmap(*bitmaps[m_filament_idx]);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
#ifdef __WXOSX__
|
||||
clr_picker->SetLabel(clr_picker->GetLabel()); // Let setBezelStyle: be called
|
||||
clr_picker->Refresh();
|
||||
@@ -996,10 +1161,10 @@ void PlaterPresetComboBox::update()
|
||||
//QDS: add project embedded presets logic
|
||||
std::map<wxString, wxBitmap*> project_embedded_presets;
|
||||
std::map<wxString, wxBitmap *> system_presets;
|
||||
std::unordered_set<std::string> system_printer_models;
|
||||
std::map<wxString, wxString> preset_descriptions;
|
||||
std::map<wxString, std::string> preset_filament_vendors;
|
||||
std::map<wxString, std::string> preset_filament_types;
|
||||
|
||||
//QDS: move system to the end
|
||||
wxString selected_system_preset;
|
||||
wxString selected_user_preset;
|
||||
@@ -1019,11 +1184,18 @@ void PlaterPresetComboBox::update()
|
||||
m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection() ? false :
|
||||
i == m_collection->get_selected_idx();
|
||||
|
||||
if (!preset.is_visible || (!preset.is_compatible && !is_selected))
|
||||
if (!is_selected && (!preset.is_visible ||!preset.is_compatible))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (is_selected && !preset.is_visible)
|
||||
{
|
||||
Preset& selected_preset = const_cast<Preset&>(preset);
|
||||
selected_preset.is_visible = true;
|
||||
}
|
||||
|
||||
bool single_bar = false;
|
||||
const wxString name = get_preset_name(preset);
|
||||
wxString name = get_preset_name(preset);
|
||||
if (m_type == Preset::TYPE_FILAMENT)
|
||||
{
|
||||
#if 0
|
||||
@@ -1042,11 +1214,21 @@ void PlaterPresetComboBox::update()
|
||||
wxBitmap* bmp = get_bmp(preset);
|
||||
assert(bmp);
|
||||
|
||||
preset_descriptions.emplace(name, _L(preset.description));
|
||||
if (preset.is_system)
|
||||
preset_descriptions.emplace(name, _L(preset.description));
|
||||
|
||||
if (preset.is_default || preset.is_system) {
|
||||
//QDS: move system to the end
|
||||
system_presets.emplace(name, bmp);
|
||||
if (m_type == Preset::TYPE_PRINTER) {
|
||||
auto printer_model = preset.config.opt_string("printer_model");
|
||||
name = from_u8(printer_model);
|
||||
if (system_printer_models.count(printer_model) == 0) {
|
||||
system_presets.emplace(name, bmp);
|
||||
system_printer_models.insert(printer_model);
|
||||
}
|
||||
} else {
|
||||
system_presets.emplace(name, bmp);
|
||||
}
|
||||
if (is_selected) {
|
||||
tooltip = get_tooltip(preset);
|
||||
selected_system_preset = name;
|
||||
@@ -1080,8 +1262,11 @@ void PlaterPresetComboBox::update()
|
||||
// set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
|
||||
}
|
||||
|
||||
if (m_type == Preset::TYPE_FILAMENT)
|
||||
add_box_filaments(into_u8(selected_user_preset.empty() ? selected_system_preset : selected_user_preset), true); //add_ams_filaments(into_u8(selected_user_preset.empty() ? selected_system_preset : selected_user_preset), true);
|
||||
bool selected_in_box = false;
|
||||
if (m_type == Preset::TYPE_FILAMENT) {
|
||||
set_replace_text("QIDI", "QIDIStudioBlack");
|
||||
selected_in_box = add_box_filaments(into_u8(selected_user_preset.empty() ? selected_system_preset : selected_user_preset), true);
|
||||
}
|
||||
|
||||
//y
|
||||
//std::vector<std::string> filament_orders = {"QIDI PLA Basic", "QIDI PLA Matte", "QIDI PETG HF", "QIDI ABS", "QIDI PLA Silk", "QIDI PLA-CF",
|
||||
@@ -1090,41 +1275,48 @@ void PlaterPresetComboBox::update()
|
||||
//w38
|
||||
std::vector<std::string> first_vendors = {"QIDI", "Generic","Bambu Lab","HATCHBOX","Overture","Polymaker"};
|
||||
std::vector<std::string> first_types = {"PLA", "PETG", "ABS", "TPU"};
|
||||
auto add_presets = [this, &preset_descriptions, &filament_orders, &preset_filament_vendors, &first_vendors, &preset_filament_types, &first_types]
|
||||
auto add_presets = [this, &preset_descriptions, &filament_orders, &preset_filament_vendors, &first_vendors, &preset_filament_types, &first_types, &selected_in_box]
|
||||
(std::map<wxString, wxBitmap *> const &presets, wxString const &selected, std::string const &group) {
|
||||
if (!presets.empty()) {
|
||||
set_label_marker(Append(separator(group), wxNullBitmap));
|
||||
if (m_type == Preset::TYPE_FILAMENT) {
|
||||
std::vector<std::map<wxString, wxBitmap *>::value_type const*> list(presets.size(), nullptr);
|
||||
std::transform(presets.begin(), presets.end(), list.begin(), [](auto & pair) { return &pair; });
|
||||
std::sort(list.begin(), list.end(), [&filament_orders, &preset_filament_vendors, &first_vendors, &preset_filament_types, &first_types](auto *l, auto *r) {
|
||||
{ // Compare order
|
||||
auto iter1 = std::find(filament_orders.begin(), filament_orders.end(), l->first);
|
||||
auto iter2 = std::find(filament_orders.begin(), filament_orders.end(), r->first);
|
||||
if (iter1 != iter2)
|
||||
return iter1 < iter2;
|
||||
}
|
||||
{ // Compare vendor
|
||||
auto iter1 = std::find(first_vendors.begin(), first_vendors.end(), preset_filament_vendors[l->first]);
|
||||
auto iter2 = std::find(first_vendors.begin(), first_vendors.end(), preset_filament_vendors[r->first]);
|
||||
if (iter1 != iter2)
|
||||
return iter1 < iter2;
|
||||
}
|
||||
{ // Compare type
|
||||
auto iter1 = std::find(first_types.begin(), first_types.end(), preset_filament_types[l->first]);
|
||||
auto iter2 = std::find(first_types.begin(), first_types.end(), preset_filament_types[r->first]);
|
||||
if (iter1 != iter2)
|
||||
return iter1 < iter2;
|
||||
}
|
||||
return l->first < r->first;
|
||||
});
|
||||
if (group == "System presets")
|
||||
std::sort(list.begin(), list.end(), [&filament_orders, &preset_filament_vendors, &first_vendors, &preset_filament_types, &first_types](auto *l, auto *r) {
|
||||
{ // Compare order
|
||||
auto iter1 = std::find(filament_orders.begin(), filament_orders.end(), l->first);
|
||||
auto iter2 = std::find(filament_orders.begin(), filament_orders.end(), r->first);
|
||||
if (iter1 != iter2)
|
||||
return iter1 < iter2;
|
||||
}
|
||||
{ // Compare vendor
|
||||
auto iter1 = std::find(first_vendors.begin(), first_vendors.end(), preset_filament_vendors[l->first]);
|
||||
auto iter2 = std::find(first_vendors.begin(), first_vendors.end(), preset_filament_vendors[r->first]);
|
||||
if (iter1 != iter2)
|
||||
return iter1 < iter2;
|
||||
}
|
||||
{ // Compare type
|
||||
auto iter1 = std::find(first_types.begin(), first_types.end(), preset_filament_types[l->first]);
|
||||
auto iter2 = std::find(first_types.begin(), first_types.end(), preset_filament_types[r->first]);
|
||||
if (iter1 != iter2)
|
||||
return iter1 < iter2;
|
||||
}
|
||||
return l->first < r->first;
|
||||
});
|
||||
for (auto it : list) {
|
||||
SetItemTooltip(Append(it->first, *it->second), preset_descriptions[it->first]);
|
||||
validate_selection(it->first == selected);
|
||||
bool is_selected = it->first == selected;
|
||||
validate_selection(is_selected);
|
||||
if (is_selected && selected_in_box) {
|
||||
SetFlag(GetCount() - 1, (int) FilamentAMSType::FROM_AMS);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (std::map<wxString, wxBitmap *>::const_iterator it = presets.begin(); it != presets.end(); ++it) {
|
||||
SetItemTooltip(Append(it->first, *it->second), preset_descriptions[it->first]);
|
||||
if (group == "System presets")
|
||||
set_label_marker(GetCount() - 1, LABEL_ITEM_PRINTER_MODELS);
|
||||
validate_selection(it->first == selected);
|
||||
}
|
||||
}
|
||||
@@ -1175,7 +1367,13 @@ void PlaterPresetComboBox::update()
|
||||
}
|
||||
}
|
||||
|
||||
//y59
|
||||
GUI::wxGetApp().sidebar().update_sync_status(nullptr);
|
||||
|
||||
update_selection();
|
||||
if (m_type == Preset::TYPE_FILAMENT) {
|
||||
update_badge_according_flag();
|
||||
}
|
||||
Thaw();
|
||||
|
||||
if (!tooltip.IsEmpty()) {
|
||||
@@ -1495,6 +1693,10 @@ GUI::CalibrateFilamentComboBox::~CalibrateFilamentComboBox()
|
||||
void GUI::CalibrateFilamentComboBox::load_tray(DynamicPrintConfig &config)
|
||||
{
|
||||
m_tray_name = config.opt_string("tray_name", 0u);
|
||||
size_t pos = m_tray_name.find("HT-");
|
||||
if (pos != std::string::npos) {
|
||||
m_tray_name = m_tray_name.substr(pos + 3);
|
||||
}
|
||||
m_filament_id = config.opt_string("filament_id", 0u);
|
||||
m_tag_uid = config.opt_string("tag_uid", 0u);
|
||||
m_filament_type = config.opt_string("filament_type", 0u);
|
||||
@@ -1514,9 +1716,21 @@ void GUI::CalibrateFilamentComboBox::load_tray(DynamicPrintConfig &config)
|
||||
} else {
|
||||
auto &filaments = m_collection->get_presets();
|
||||
auto iter = std::find_if(filaments.begin(), filaments.end(), [this](auto &f) {
|
||||
if (!f.is_system) // Only match system preset
|
||||
return false;
|
||||
bool is_compatible = m_preset_bundle->calibrate_filaments.find(&f) != m_preset_bundle->calibrate_filaments.end();
|
||||
return is_compatible && f.filament_id == m_filament_id;
|
||||
});
|
||||
|
||||
// Prioritize matching system presets. If there are no system presets, match all presets.
|
||||
if (iter == filaments.end()) {
|
||||
iter = std::find_if(filaments.begin(), filaments.end(), [this](auto &f) {
|
||||
if (f.is_system) // Only match system preset
|
||||
return false;
|
||||
bool is_compatible = m_preset_bundle->calibrate_filaments.find(&f) != m_preset_bundle->calibrate_filaments.end();
|
||||
return is_compatible && f.filament_id == m_filament_id;
|
||||
});
|
||||
}
|
||||
//if (iter == filaments.end() && !m_filament_type.empty()) {
|
||||
// auto filament_type = "Generic " + m_filament_type;
|
||||
// iter = std::find_if(filaments.begin(), filaments.end(),
|
||||
|
||||
Reference in New Issue
Block a user