ENH:add "SyncAmsInfoDialog"
JIRA: none Change-Id: I8e26178f6da816e102a40b429c565696924c58ea (cherry picked from commit 2a46460d5a65279cbb42c8aef2474172b1e1ae30)
This commit is contained in:
parent
32143cfcbc
commit
f7995d5a9f
|
@ -169,6 +169,10 @@ void AppConfig::set_defaults()
|
|||
if (get("reverse_mouse_wheel_zoom").empty())
|
||||
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", true);
|
||||
if (get("enable_merge_color_by_sync_ams").empty())
|
||||
set_bool("enable_merge_color_by_sync_ams", true);
|
||||
|
||||
if (get("zoom_to_mouse").empty())
|
||||
set_bool("zoom_to_mouse", false);
|
||||
|
|
|
@ -1789,7 +1789,9 @@ void PresetBundle::update_num_filaments(unsigned int to_del_flament_id)
|
|||
|
||||
if (filament_color->values.size() > to_del_flament_id) {
|
||||
filament_color->values.erase(filament_color->values.begin() + to_del_flament_id);
|
||||
filament_map->values.erase(filament_map->values.begin() + to_del_flament_id);
|
||||
if (filament_map->values.size() > to_del_flament_id) {
|
||||
filament_map->values.erase(filament_map->values.begin() + to_del_flament_id);
|
||||
}
|
||||
}
|
||||
else {
|
||||
filament_color->values.resize(to_del_flament_id);
|
||||
|
@ -1806,22 +1808,50 @@ void PresetBundle::update_num_filaments(unsigned int to_del_flament_id)
|
|||
update_multi_material_filament_presets(to_del_flament_id);
|
||||
}
|
||||
|
||||
unsigned int PresetBundle::sync_ams_list(unsigned int &unknowns)
|
||||
unsigned int PresetBundle::sync_ams_list(unsigned int &unknowns, bool use_map, std::map<int, AMSMapInfo> &maps,bool enable_append, MergeFilamentInfo &merge_info)
|
||||
{
|
||||
std::vector<std::string> filament_presets;
|
||||
std::vector<std::string> filament_colors;
|
||||
std::vector<std::string> ams_filament_presets;
|
||||
std::vector<std::string> ams_filament_colors;
|
||||
std::vector<AMSMapInfo> ams_array_maps;
|
||||
ams_multi_color_filment.clear();
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": filament_ams_list size: %1%") % filament_ams_list.size();
|
||||
struct AmsInfo
|
||||
{
|
||||
bool valid{false};
|
||||
bool is_map{false};
|
||||
std::string filament_color = "";
|
||||
std::string filament_preset = "";
|
||||
};
|
||||
auto is_double_extruder = get_printer_extruder_count() == 2;
|
||||
std::vector<AmsInfo> ams_infos;
|
||||
int index = 0;
|
||||
for (auto &entry : filament_ams_list) {
|
||||
auto & ams = entry.second;
|
||||
auto filament_id = ams.opt_string("filament_id", 0u);
|
||||
auto filament_color = ams.opt_string("filament_colour", 0u);
|
||||
auto filament_changed = !ams.has("filament_changed") || ams.opt_bool("filament_changed");
|
||||
auto filament_multi_color = ams.opt<ConfigOptionStrings>("filament_multi_colors")->values;
|
||||
if (filament_id.empty()) continue;
|
||||
if (!filament_changed && this->filament_presets.size() > filament_presets.size()) {
|
||||
filament_presets.push_back(this->filament_presets[filament_presets.size()]);
|
||||
filament_colors.push_back(filament_color);
|
||||
auto ams_id = ams.opt_string("ams_id", 0u);
|
||||
auto slot_id = ams.opt_string("slot_id", 0u);
|
||||
ams_infos.push_back({filament_id.empty() ? false : true,false, filament_color});
|
||||
AMSMapInfo temp = {ams_id, slot_id};
|
||||
ams_array_maps.push_back(temp);
|
||||
index++;
|
||||
if (filament_id.empty()) {
|
||||
if (use_map) {
|
||||
ams_filament_presets.push_back("Generic PLA");//for unknow matieral
|
||||
auto default_unknown_color = "#CECECE";
|
||||
ams_filament_colors.push_back(default_unknown_color);
|
||||
if (filament_multi_color.size() == 0) {
|
||||
filament_multi_color.push_back(default_unknown_color);
|
||||
}
|
||||
ams_multi_color_filment.push_back(filament_multi_color);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!filament_changed && this->filament_presets.size() > ams_filament_presets.size()) {
|
||||
ams_filament_presets.push_back(this->filament_presets[ams_filament_presets.size()]);
|
||||
ams_filament_colors.push_back(filament_color);
|
||||
ams_multi_color_filment.push_back(filament_multi_color);
|
||||
continue;
|
||||
}
|
||||
|
@ -1839,9 +1869,9 @@ unsigned int PresetBundle::sync_ams_list(unsigned int &unknowns)
|
|||
}
|
||||
if (iter == filaments.end()) {
|
||||
// Prefer old selection
|
||||
if (filament_presets.size() < this->filament_presets.size()) {
|
||||
filament_presets.push_back(this->filament_presets[filament_presets.size()]);
|
||||
filament_colors.push_back(filament_color);
|
||||
if (ams_filament_presets.size() < this->filament_presets.size()) {
|
||||
ams_filament_presets.push_back(this->filament_presets[ams_filament_presets.size()]);
|
||||
ams_filament_colors.push_back(filament_color);
|
||||
ams_multi_color_filment.push_back(filament_multi_color);
|
||||
++unknowns;
|
||||
continue;
|
||||
|
@ -1855,21 +1885,100 @@ unsigned int PresetBundle::sync_ams_list(unsigned int &unknowns)
|
|||
++unknowns;
|
||||
filament_id = iter->filament_id;
|
||||
}
|
||||
filament_presets.push_back(iter->name);
|
||||
filament_colors.push_back(filament_color);
|
||||
ams_filament_presets.push_back(iter->name);
|
||||
ams_filament_colors.push_back(filament_color);
|
||||
ams_multi_color_filment.push_back(filament_multi_color);
|
||||
}
|
||||
if (filament_presets.empty())
|
||||
if (ams_filament_presets.empty())
|
||||
return 0;
|
||||
this->filament_presets = filament_presets;
|
||||
ConfigOptionStrings *filament_color = project_config.option<ConfigOptionStrings>("filament_colour");
|
||||
filament_color->resize(filament_presets.size());
|
||||
filament_color->values = filament_colors;
|
||||
ConfigOptionInts* filament_map = project_config.option<ConfigOptionInts>("filament_map");
|
||||
filament_map->values.resize(filament_colors.size(), 1);
|
||||
ConfigOptionInts * filament_map = project_config.option<ConfigOptionInts>("filament_map");
|
||||
if (use_map) {
|
||||
auto check_has_merge_info = [](std::map<int, AMSMapInfo> &maps, MergeFilamentInfo &merge_info, int exist_colors_size) {
|
||||
std::map<int, bool> done;
|
||||
for (int i = 0; i < maps.size(); i++) {
|
||||
std::vector<int> same_ams;
|
||||
same_ams.emplace_back(i);
|
||||
for (size_t j = i + 1; j < maps.size(); j++) {
|
||||
if (done.find(j) != done.end()) {
|
||||
continue;
|
||||
}
|
||||
if (maps[i].slot_id == "" || maps[i].ams_id == ""){//reserve
|
||||
continue;
|
||||
}
|
||||
if (maps[i].slot_id == maps[j].slot_id && maps[i].ams_id == maps[j].ams_id) {
|
||||
same_ams.emplace_back(j);
|
||||
done[j] =true;
|
||||
}
|
||||
}
|
||||
if (same_ams.size() > 1) {
|
||||
merge_info.merges.emplace_back(same_ams);
|
||||
}
|
||||
}
|
||||
};
|
||||
check_has_merge_info(maps, merge_info,filament_color->values.size());
|
||||
auto get_map_index = [&ams_infos](const std::vector<AMSMapInfo> &infos, const AMSMapInfo &temp) {
|
||||
for (int i = 0; i < infos.size(); i++) {
|
||||
if (infos[i].slot_id == temp.slot_id && infos[i].ams_id == temp.ams_id) {
|
||||
ams_infos[i].is_map = true;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
std::vector<AmsInfo> need_append_colors;
|
||||
auto exist_colors = filament_color->values;
|
||||
auto exist_filament_presets = this->filament_presets;
|
||||
for (size_t i = 0; i < exist_colors.size(); i++) {
|
||||
if (maps.find(i) != maps.end()) {//mapping exist
|
||||
auto valid_index = get_map_index(ams_array_maps, maps[i]);
|
||||
if (valid_index >= 0) {
|
||||
exist_colors[i] = ams_filament_colors[valid_index];
|
||||
exist_filament_presets[i] = ams_filament_presets[valid_index];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < ams_infos.size(); i++) {// check append
|
||||
if (ams_infos[i].valid) {
|
||||
ams_infos[i].filament_preset = ams_filament_presets[i];
|
||||
if (!ams_infos[i].is_map) {
|
||||
need_append_colors.emplace_back(ams_infos[i]);
|
||||
ams_filament_colors[i] = "";
|
||||
ams_filament_presets[i] = "";
|
||||
ams_multi_color_filment[i] = std::vector<std::string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
//delete redundant color
|
||||
ams_filament_colors.erase(std::remove_if(ams_filament_colors.begin(), ams_filament_colors.end(), [](std::string &value) { return value.empty(); }),
|
||||
ams_filament_colors.end());
|
||||
ams_filament_presets.erase(std::remove_if(ams_filament_presets.begin(), ams_filament_presets.end(), [](std::string &value) { return value.empty(); }),
|
||||
ams_filament_presets.end());
|
||||
ams_multi_color_filment.erase(std::remove_if(ams_multi_color_filment.begin(), ams_multi_color_filment.end(),
|
||||
[](std::vector<std::string> &value) { return value.empty(); }),
|
||||
ams_multi_color_filment.end());
|
||||
if (need_append_colors.size() > 0 && enable_append) {
|
||||
for (size_t i = 0; i < need_append_colors.size(); i++){
|
||||
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};
|
||||
ams_multi_color_filment.push_back(value);
|
||||
}
|
||||
}
|
||||
filament_color->resize(exist_colors.size());
|
||||
filament_color->values = exist_colors;
|
||||
this->filament_presets = exist_filament_presets;
|
||||
filament_map->values.resize(exist_filament_presets.size(), 1);
|
||||
}
|
||||
else {//overwrite
|
||||
filament_color->resize(ams_filament_presets.size());
|
||||
filament_color->values = ams_filament_colors;
|
||||
this->filament_presets = ams_filament_presets;
|
||||
filament_map->values.resize(ams_filament_colors.size(), 1);
|
||||
}
|
||||
|
||||
update_multi_material_filament_presets();
|
||||
return filament_presets.size();
|
||||
return this->filament_presets.size();
|
||||
}
|
||||
|
||||
std::vector<int> PresetBundle::get_used_tpu_filaments(const std::vector<int> &used_filaments)
|
||||
|
|
|
@ -21,6 +21,16 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
struct AMSMapInfo
|
||||
{
|
||||
/*for new ams mapping*/ // from struct FilamentInfo
|
||||
std::string ams_id{""};
|
||||
std::string slot_id{""};
|
||||
};
|
||||
struct MergeFilamentInfo {
|
||||
std::vector<std::vector<int>> merges;
|
||||
bool is_empty() { return merges.empty();}
|
||||
};
|
||||
// Bundle of Print + Filament + Printer presets.
|
||||
class PresetBundle
|
||||
{
|
||||
|
@ -97,7 +107,8 @@ public:
|
|||
// BBS
|
||||
void set_num_filaments(unsigned int n, std::string new_col = "");
|
||||
void update_num_filaments(unsigned int to_del_flament_id);
|
||||
unsigned int sync_ams_list(unsigned int & unknowns);
|
||||
|
||||
unsigned int sync_ams_list(unsigned int &unknowns, bool use_map, std::map<int, AMSMapInfo> &maps,bool enable_append, MergeFilamentInfo& merge_info);
|
||||
//BBS: check whether this is the only edited filament
|
||||
bool is_the_only_edited_filament(unsigned int filament_index);
|
||||
|
||||
|
|
|
@ -318,6 +318,8 @@ set(SLIC3R_GUI_SOURCES
|
|||
GUI/SendSystemInfoDialog.hpp
|
||||
GUI/StepMeshDialog.cpp
|
||||
GUI/StepMeshDialog.hpp
|
||||
GUI/SyncAmsInfoDialog.cpp
|
||||
GUI/SyncAmsInfoDialog.hpp
|
||||
GUI/SurfaceDrag.cpp
|
||||
GUI/SurfaceDrag.hpp
|
||||
GUI/PlateSettingsDialog.cpp
|
||||
|
|
|
@ -877,7 +877,7 @@ void MappingItem::send_event(int fliament_id)
|
|||
event.SetString(param);
|
||||
|
||||
if (send_win) {
|
||||
event.SetEventObject(send_win);
|
||||
event.SetEventObject(send_win);
|
||||
wxPostEvent(send_win, event);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ struct ThumbnailData;
|
|||
struct ThumbnailsParams;
|
||||
class ModelObject;
|
||||
class ModelInstance;
|
||||
class TextInfo;
|
||||
struct TextInfo;
|
||||
class PrintObject;
|
||||
class Print;
|
||||
class SLAPrint;
|
||||
|
|
|
@ -97,6 +97,7 @@
|
|||
#include "PublishDialog.hpp"
|
||||
#include "ModelMall.hpp"
|
||||
#include "ConfigWizard.hpp"
|
||||
#include "SyncAmsInfoDialog.hpp"
|
||||
#include "../Utils/ASCIIFolding.hpp"
|
||||
#include "../Utils/FixModelByWin10.hpp"
|
||||
#include "../Utils/UndoRedo.hpp"
|
||||
|
@ -2586,12 +2587,14 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
|
|||
std::map<int, DynamicPrintConfig> filament_ams_list;
|
||||
if (!obj) return filament_ams_list;
|
||||
|
||||
auto build_tray_config = [](AmsTray const & tray, std::string const & name) {
|
||||
auto build_tray_config = [](AmsTray const &tray, std::string const &name, std::string ams_id, std::string slot_id) {
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("build_filament_ams_list: name %1% setting_id %2% type %3% color %4%")
|
||||
% name % tray.setting_id % tray.type % tray.color;
|
||||
DynamicPrintConfig tray_config;
|
||||
tray_config.set_key_value("filament_id", new ConfigOptionStrings{tray.setting_id});
|
||||
tray_config.set_key_value("tag_uid", new ConfigOptionStrings{tray.tag_uid});
|
||||
tray_config.set_key_value("ams_id", new ConfigOptionStrings{ams_id});
|
||||
tray_config.set_key_value("slot_id", new ConfigOptionStrings{slot_id});
|
||||
tray_config.set_key_value("filament_type", new ConfigOptionStrings{tray.type});
|
||||
tray_config.set_key_value("tray_name", new ConfigOptionStrings{ name });
|
||||
tray_config.set_key_value("filament_colour", new ConfigOptionStrings{into_u8(wxColour("#" + tray.color).GetAsString(wxC2S_HTML_SYNTAX))});
|
||||
|
@ -2607,7 +2610,7 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
|
|||
if (obj->ams_support_virtual_tray) {
|
||||
int extruder = 0x10000; // Main (first) extruder at right
|
||||
for (auto & vt_tray : obj->vt_slot) {
|
||||
filament_ams_list.emplace(extruder + stoi(vt_tray.id), build_tray_config(vt_tray, "Ext"));
|
||||
filament_ams_list.emplace(extruder + stoi(vt_tray.id), build_tray_config(vt_tray, "Ext",vt_tray.id, "0"));//254 or 255
|
||||
extruder = 0;
|
||||
}
|
||||
}
|
||||
|
@ -2631,7 +2634,7 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
|
|||
for (auto tray : ams.second->trayList) {
|
||||
int slot_id = std::stoi(tray.first);
|
||||
filament_ams_list.emplace(extruder + (ams_id * 4 + slot_id),
|
||||
build_tray_config(*tray.second, get_ams_name(ams_id, slot_id)));
|
||||
build_tray_config(*tray.second, get_ams_name(ams_id, slot_id), std::to_string(ams_id), std::to_string(slot_id)));
|
||||
}
|
||||
}
|
||||
return filament_ams_list;
|
||||
|
@ -2689,40 +2692,32 @@ void Sidebar::sync_ams_list()
|
|||
|
||||
auto & list = wxGetApp().preset_bundle->filament_ams_list;
|
||||
if (list.empty()) {
|
||||
MessageDialog dlg(this,
|
||||
_L("No AMS filaments. Please select a printer in 'Device' page to load AMS info."),
|
||||
_L("Sync filaments with AMS"), wxOK);
|
||||
dlg.ShowModal();
|
||||
SyncAmsInfoDialog::SyncInfo temp_info;
|
||||
SyncAmsInfoDialog sync_dlg(this, temp_info);
|
||||
sync_dlg.ShowModal();//printer is not connected
|
||||
return;
|
||||
}
|
||||
std::string ams_filament_ids = wxGetApp().app_config->get("ams_filament_ids", p->ams_list_device);
|
||||
std::vector<std::string> list2;
|
||||
if (!ams_filament_ids.empty())
|
||||
if (!ams_filament_ids.empty()) {
|
||||
boost::algorithm::split(list2, ams_filament_ids, boost::algorithm::is_any_of(","));
|
||||
struct SyncAmsDialog : MessageDialog {
|
||||
SyncAmsDialog(wxWindow * parent, bool first): MessageDialog(parent,
|
||||
first
|
||||
? _L("Sync filaments with AMS will drop all current selected filament presets and colors. Do you want to continue?")
|
||||
: _L("Already did a synchronization, do you want to sync only changes or resync all?"),
|
||||
_L("Sync filaments with AMS"), 0)
|
||||
{
|
||||
if (first) {
|
||||
add_button(wxID_YES, true, _L("Yes"));
|
||||
} else {
|
||||
add_button(wxID_OK, true, _L("Sync"));
|
||||
add_button(wxID_YES, false, _L("Resync"));
|
||||
}
|
||||
add_button(wxID_CANCEL, false, _L("No"));
|
||||
}
|
||||
} dlg(this, ams_filament_ids.empty());
|
||||
auto res = dlg.ShowModal();
|
||||
if (res == wxID_CANCEL) return;
|
||||
}
|
||||
wxGetApp().plater()->update_all_plate_thumbnails(true);//preview thumbnail for sync_dlg
|
||||
SyncAmsInfoDialog::SyncInfo temp_info;
|
||||
temp_info.connected_printer = true;
|
||||
temp_info.first_sync = ams_filament_ids.empty();
|
||||
SyncAmsInfoDialog sync_dlg(this, temp_info);
|
||||
auto dlg_res = sync_dlg.ShowModal();
|
||||
if (dlg_res == wxID_CANCEL)
|
||||
return;
|
||||
auto sync_result = sync_dlg.get_result();
|
||||
|
||||
list2.resize(list.size());
|
||||
auto iter = list.begin();
|
||||
for (int i = 0; i < list.size(); ++i, ++iter) {
|
||||
auto & ams = iter->second;
|
||||
auto filament_id = ams.opt_string("filament_id", 0u);
|
||||
ams.set_key_value("filament_changed", new ConfigOptionBool{res == wxID_YES || list2[i] != filament_id});
|
||||
ams.set_key_value("filament_changed", new ConfigOptionBool{dlg_res == wxID_YES || list2[i] != filament_id});
|
||||
list2[i] = filament_id;
|
||||
}
|
||||
|
||||
|
@ -2735,9 +2730,10 @@ void Sidebar::sync_ams_list()
|
|||
is_support_before.push_back(is_support_filament(i));
|
||||
color_before_sync.push_back(color_opt->values[i]);
|
||||
}
|
||||
|
||||
MergeFilamentInfo merge_info;
|
||||
unsigned int unknowns = 0;
|
||||
auto n = wxGetApp().preset_bundle->sync_ams_list(unknowns);
|
||||
auto enable_append = wxGetApp().app_config->get_bool("enable_append_color_by_sync_ams");
|
||||
auto n = wxGetApp().preset_bundle->sync_ams_list(unknowns, !sync_result.direct_sync, sync_result.sync_maps, enable_append, merge_info);
|
||||
if (n == 0) {
|
||||
MessageDialog dlg(this,
|
||||
_L("There are no compatible filaments, and sync is not performed."),
|
||||
|
@ -2780,6 +2776,26 @@ void Sidebar::sync_ams_list()
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!merge_info.is_empty() && wxGetApp().app_config->get_bool("enable_merge_color_by_sync_ams")) { // merge same color and preset filament//use same ams
|
||||
auto reduce_index = [](MergeFilamentInfo &merge_info,int value) {
|
||||
for (size_t i = 0; i < merge_info.merges.size(); i++) {
|
||||
auto &cur = merge_info.merges[i];
|
||||
for (size_t j = 0; j < cur.size(); j++) {
|
||||
if (value < cur[j]) {
|
||||
cur[j] = cur[j] - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
for (size_t i = 0; i < merge_info.merges.size(); i++) {
|
||||
auto& cur = merge_info.merges[i];
|
||||
for (size_t j = cur.size() -1; j >= 1 ; j--) {
|
||||
change_filament(cur[j], cur[0]);
|
||||
cur.erase(cur.begin() + j);
|
||||
reduce_index(merge_info, cur[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Layout();
|
||||
}
|
||||
|
||||
|
|
|
@ -1018,7 +1018,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();
|
||||
|
|
|
@ -33,32 +33,14 @@ wxDEFINE_EVENT(EVT_PRINT_JOB_CANCEL, wxCommandEvent);
|
|||
wxDEFINE_EVENT(EVT_CLEAR_IPADDRESS, wxCommandEvent);
|
||||
|
||||
#define INITIAL_NUMBER_OF_MACHINES 0
|
||||
#define LIST_REFRESH_INTERVAL 200
|
||||
|
||||
#define MACHINE_LIST_REFRESH_INTERVAL 2000
|
||||
|
||||
#define WRAP_GAP FromDIP(2)
|
||||
|
||||
static wxString task_canceled_text = _L("Task canceled");
|
||||
|
||||
static wxString MACHINE_BED_TYPE_STRING[BED_TYPE_COUNT] = {
|
||||
//_L("Auto"),
|
||||
_L("Bambu Cool Plate"),
|
||||
_L("Bamabu Engineering Plate"),
|
||||
_L("Bamabu Smooth PEI Plate") + "/" + _L("High temperature Plate"),
|
||||
_L("Bamabu Textured PEI Plate"),
|
||||
_L("Bambu Cool Plate SuperTack")
|
||||
};
|
||||
|
||||
static std::string MachineBedTypeString[BED_TYPE_COUNT] = {
|
||||
//"auto",
|
||||
"pc",
|
||||
"pe",
|
||||
"pei",
|
||||
"pte",
|
||||
"suprtack"
|
||||
};
|
||||
|
||||
static std::string get_nozzle_volume_type_cloud_string(NozzleVolumeType nozzle_volume_type)
|
||||
std::string get_nozzle_volume_type_cloud_string(NozzleVolumeType nozzle_volume_type)
|
||||
{
|
||||
if (nozzle_volume_type == NozzleVolumeType::nvtStandard) {
|
||||
return "standard_flow";
|
||||
|
@ -109,7 +91,22 @@ wxString SelectMachineDialog::format_text(wxString &m_msg)
|
|||
}
|
||||
return out_txt;
|
||||
}
|
||||
|
||||
std::vector<wxString> SelectMachineDialog::MACHINE_BED_TYPE_STRING;
|
||||
std::vector<string> SelectMachineDialog::MachineBedTypeString;
|
||||
void SelectMachineDialog::init_machine_bed_types()
|
||||
{
|
||||
if (MACHINE_BED_TYPE_STRING.size() == 0) {
|
||||
MACHINE_BED_TYPE_STRING = {//_L("Auto"),
|
||||
_L("Bambu Cool Plate"),
|
||||
_L("Bamabu Engineering Plate"),
|
||||
_L("Bamabu Smooth PEI Plate") + "/" + _L("High temperature Plate"),
|
||||
_L("Bamabu Textured PEI Plate"),
|
||||
_L("Bambu Cool Plate SuperTack")
|
||||
};
|
||||
MachineBedTypeString = {//"auto",
|
||||
"pc", "pe", "pei", "pte", "suprtack"};
|
||||
}
|
||||
}
|
||||
SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
||||
: DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, _L("Send print job to"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
|
||||
, m_plater(plater), m_export_3mf_cancel(false)
|
||||
|
@ -117,6 +114,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
|||
, m_mapping_tip_popup(AmsMapingTipPopup(this))
|
||||
, m_mapping_tutorial_popup(AmsTutorialPopup(this))
|
||||
{
|
||||
init_machine_bed_types();
|
||||
#ifdef __WINDOWS__
|
||||
SetDoubleBuffered(true);
|
||||
#endif //__WINDOWS__
|
||||
|
@ -3801,8 +3799,8 @@ void SelectMachineDialog::reset_and_sync_ams_list()
|
|||
m_mapping_popup.set_parent_item(item);
|
||||
m_mapping_popup.set_current_filament_id(extruder);
|
||||
m_mapping_popup.set_tag_texture(materials[extruder]);
|
||||
m_mapping_popup.set_send_win(this);//fix bug:fisrt click is not valid
|
||||
m_mapping_popup.update(obj_);
|
||||
m_mapping_popup.set_send_win(this);
|
||||
m_mapping_popup.Popup();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
std::string get_nozzle_volume_type_cloud_string(NozzleVolumeType nozzle_volume_type);
|
||||
void print_ams_mapping_result(std::vector<FilamentInfo> &result);
|
||||
enum PrintFromType {
|
||||
FROM_NORMAL,
|
||||
FROM_SDCARD_VIEW,
|
||||
|
@ -130,7 +132,7 @@ WX_DECLARE_HASH_MAP(int, Material *, wxIntegerHash, wxIntegerEqual, MaterialHash
|
|||
|
||||
#define SELECT_MACHINE_DIALOG_BUTTON_SIZE wxSize(FromDIP(57), FromDIP(32))
|
||||
#define SELECT_MACHINE_DIALOG_SIMBOOK_SIZE wxSize(FromDIP(370), FromDIP(64))
|
||||
|
||||
#define LIST_REFRESH_INTERVAL 200
|
||||
static int get_brightness_value(wxImage image) {
|
||||
|
||||
wxImage grayImage = image.ConvertToGreyscale();
|
||||
|
@ -393,6 +395,11 @@ protected:
|
|||
wxGridSizer* m_sizer_ams_mapping_left{ nullptr };
|
||||
wxGridSizer* m_sizer_ams_mapping_right{ nullptr };
|
||||
|
||||
public:
|
||||
static std::vector<wxString> MACHINE_BED_TYPE_STRING;
|
||||
static void init_machine_bed_types();
|
||||
static std::vector<std::string> MachineBedTypeString;
|
||||
|
||||
public:
|
||||
SelectMachineDialog(Plater *plater = nullptr);
|
||||
~SelectMachineDialog();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,290 @@
|
|||
#ifndef _SyncAmsInfo_DIALOG_H_
|
||||
#define _SyncAmsInfo_DIALOG_H_
|
||||
|
||||
#include <future>
|
||||
#include <thread>
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI_Utils.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "SelectMachine.hpp"
|
||||
#include "DeviceManager.hpp"
|
||||
class Button;
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
class SyncAmsInfoDialog : public DPIDialog
|
||||
{
|
||||
int m_current_filament_id{0};
|
||||
int m_print_plate_idx{0};
|
||||
int m_print_plate_total{0};
|
||||
int m_timeout_count{0};
|
||||
int m_print_error_code{0};
|
||||
bool m_is_in_sending_mode{false};
|
||||
bool m_ams_mapping_res{false};
|
||||
bool m_ams_mapping_valid{false};
|
||||
bool m_export_3mf_cancel{false};
|
||||
bool m_is_canceled{false};
|
||||
bool m_is_rename_mode{false};
|
||||
bool m_check_flag{false};
|
||||
PrintPageMode m_print_page_mode{PrintPageMode::PrintPageModePrepare};
|
||||
std::string m_print_error_msg;
|
||||
std::string m_print_error_extra;
|
||||
std::string m_printer_last_select;
|
||||
std::string m_print_info;
|
||||
wxString m_current_project_name;
|
||||
PrintDialogStatus m_print_status{PrintStatusInit};
|
||||
wxColour m_colour_def_color{wxColour(255, 255, 255)};
|
||||
wxColour m_colour_bold_color{wxColour(38, 46, 48)};
|
||||
StateColor m_btn_bg_enable;
|
||||
Label * m_text_bed_type;
|
||||
|
||||
std::shared_ptr<int> m_token = std::make_shared<int>(0);
|
||||
std::map<std::string, PrintOption *> m_checkbox_list;
|
||||
std::vector<wxString> m_bedtype_list;
|
||||
std::vector<MachineObject *> m_list;
|
||||
std::vector<FilamentInfo> m_filaments;
|
||||
std::vector<FilamentInfo> m_ams_mapping_result;
|
||||
std::vector<int> m_filaments_map;
|
||||
std::shared_ptr<BBLStatusBarSend> m_status_bar;
|
||||
|
||||
// SendModeSwitchButton* m_mode_print {nullptr};
|
||||
// SendModeSwitchButton* m_mode_send {nullptr};
|
||||
wxStaticBitmap *m_printer_image{nullptr};
|
||||
wxStaticBitmap *m_bed_image{nullptr};
|
||||
|
||||
Slic3r::DynamicPrintConfig m_required_data_config;
|
||||
Slic3r::Model m_required_data_model;
|
||||
Slic3r::PlateDataPtrs m_required_data_plate_data_list;
|
||||
std::string m_required_data_file_name;
|
||||
std::string m_required_data_file_path;
|
||||
|
||||
std::vector<POItem> ops_auto;
|
||||
std::vector<POItem> ops_no_auto;
|
||||
|
||||
protected:
|
||||
PrintFromType m_print_type{FROM_NORMAL};
|
||||
AmsMapingPopup m_mapping_popup{nullptr};
|
||||
AmsMapingTipPopup m_mapping_tip_popup{nullptr};
|
||||
AmsTutorialPopup m_mapping_tutorial_popup{nullptr};
|
||||
MaterialHash m_materialList;
|
||||
Plater * m_plater{nullptr};
|
||||
wxPanel * m_options_other{nullptr};
|
||||
wxBoxSizer * m_sizer_options_timelapse{nullptr};
|
||||
wxBoxSizer * m_sizer_options_other{nullptr};
|
||||
wxBoxSizer * m_sizer_thumbnail{nullptr};
|
||||
|
||||
wxBoxSizer * m_sizer_main{nullptr};
|
||||
wxBoxSizer * m_basicl_sizer{nullptr};
|
||||
wxBoxSizer * rename_sizer_v{nullptr};
|
||||
wxBoxSizer * rename_sizer_h{nullptr};
|
||||
wxBoxSizer * m_sizer_autorefill{nullptr};
|
||||
ScalableButton * m_button_refresh{nullptr};
|
||||
Button * m_button_ensure{nullptr};
|
||||
wxStaticBitmap * m_rename_button{nullptr};
|
||||
ComboBox * m_comboBox_printer{nullptr};
|
||||
wxStaticBitmap * m_staticbitmap{nullptr};
|
||||
wxStaticBitmap * m_bitmap_last_plate{nullptr};
|
||||
wxStaticBitmap * m_bitmap_next_plate{nullptr};
|
||||
wxStaticBitmap * img_amsmapping_tip{nullptr};
|
||||
ThumbnailPanel * m_thumbnailPanel{nullptr};
|
||||
wxPanel * m_panel_status{nullptr};
|
||||
wxPanel * m_basic_panel;
|
||||
wxPanel * m_rename_normal_panel{nullptr};
|
||||
wxPanel * m_panel_sending{nullptr};
|
||||
wxPanel * m_panel_prepare{nullptr};
|
||||
wxPanel * m_panel_finish{nullptr};
|
||||
wxPanel * m_line_top{nullptr};
|
||||
Label * m_st_txt_error_code{nullptr};
|
||||
Label * m_st_txt_error_desc{nullptr};
|
||||
Label * m_st_txt_extra_info{nullptr};
|
||||
Label * m_ams_backup_tip{nullptr};
|
||||
wxHyperlinkCtrl * m_link_network_state{nullptr};
|
||||
wxSimplebook * m_rename_switch_panel{nullptr};
|
||||
wxSimplebook * m_simplebook{nullptr};
|
||||
wxStaticText * m_rename_text{nullptr};
|
||||
Label * m_stext_printer_title{nullptr};
|
||||
Label * m_statictext_ams_msg{nullptr};
|
||||
Label * m_text_printer_msg{nullptr};
|
||||
wxStaticText * m_staticText_bed_title{nullptr};
|
||||
wxStaticText * m_stext_sending{nullptr};
|
||||
wxStaticText * m_statictext_finish{nullptr};
|
||||
TextInput * m_rename_input{nullptr};
|
||||
wxTimer * m_refresh_timer{nullptr};
|
||||
std::shared_ptr<PrintJob> m_print_job;
|
||||
wxScrolledWindow * m_sw_print_failed_info{nullptr};
|
||||
wxHyperlinkCtrl * m_hyperlink{nullptr};
|
||||
wxStaticBitmap * m_advanced_options_icon{nullptr};
|
||||
ScalableBitmap * rename_editable{nullptr};
|
||||
ScalableBitmap * rename_editable_light{nullptr};
|
||||
ScalableBitmap * ams_mapping_help_icon{nullptr};
|
||||
wxStaticBitmap * img_ams_backup{nullptr};
|
||||
ThumbnailData m_cur_input_thumbnail_data;
|
||||
ThumbnailData m_cur_no_light_thumbnail_data;
|
||||
ThumbnailData m_preview_thumbnail_data; // when ams map change
|
||||
std::vector<wxColour> m_preview_colors_in_thumbnail;
|
||||
std::vector<wxColour> m_cur_colors_in_thumbnail;
|
||||
std::vector<bool> m_edge_pixels;
|
||||
|
||||
StaticBox *m_filament_panel;
|
||||
StaticBox *m_filament_left_panel;
|
||||
StaticBox *m_filament_right_panel;
|
||||
|
||||
wxBoxSizer *m_filament_panel_sizer;
|
||||
wxBoxSizer *m_filament_panel_left_sizer;
|
||||
wxBoxSizer *m_filament_panel_right_sizer;
|
||||
wxBoxSizer *m_sizer_filament_2extruder;
|
||||
|
||||
wxGridSizer *m_sizer_ams_mapping{nullptr};
|
||||
wxGridSizer *m_sizer_ams_mapping_left{nullptr};
|
||||
wxGridSizer *m_sizer_ams_mapping_right{nullptr};
|
||||
|
||||
public:
|
||||
void init_bind();
|
||||
void init_timer();
|
||||
void check_focus(wxWindow *window);
|
||||
void show_print_failed_info(bool show, int code = 0, wxString description = wxEmptyString, wxString extra = wxEmptyString);
|
||||
void check_fcous_state(wxWindow *window);
|
||||
void popup_filament_backup();
|
||||
|
||||
void prepare_mode(bool refresh_button = true);
|
||||
void sending_mode();
|
||||
void finish_mode();
|
||||
void sync_ams_mapping_result(std::vector<FilamentInfo> &result);
|
||||
void prepare(int print_plate_idx);
|
||||
void show_status(PrintDialogStatus status, std::vector<wxString> params = std::vector<wxString>());
|
||||
void sys_color_changed();
|
||||
void reset_timeout();
|
||||
void update_user_printer();
|
||||
void reset_ams_material();
|
||||
void update_show_status();
|
||||
void on_rename_click(wxMouseEvent &event);
|
||||
void on_rename_enter();
|
||||
void update_printer_combobox(wxCommandEvent &event);
|
||||
void on_cancel(wxCloseEvent &event);
|
||||
void show_errors(wxString &info);
|
||||
void on_ok_btn(wxCommandEvent &event);
|
||||
void Enable_Auto_Refill(bool enable);
|
||||
void connect_printer_mqtt();
|
||||
void on_send_print();
|
||||
void clear_ip_address_config(wxCommandEvent &e);
|
||||
void on_refresh(wxCommandEvent &event);
|
||||
void on_set_finish_mapping(wxCommandEvent &evt);
|
||||
void on_print_job_cancel(wxCommandEvent &evt);
|
||||
void reset_and_sync_ams_list();
|
||||
void clone_thumbnail_data();
|
||||
void record_edge_pixels_data();
|
||||
wxColour adjust_color_for_render(const wxColour &color);
|
||||
void final_deal_edge_pixels_data(ThumbnailData &data);
|
||||
void updata_thumbnail_data_after_connected_printer();
|
||||
void unify_deal_thumbnail_data(ThumbnailData &input_data, ThumbnailData &no_light_data);
|
||||
void change_default_normal(int old_filament_id, wxColour temp_ams_color);
|
||||
void set_default_from_sdcard();
|
||||
void update_page_turn_state(bool show);
|
||||
void on_timer(wxTimerEvent &event);
|
||||
void on_selection_changed(wxCommandEvent &event);
|
||||
void update_flow_cali_check(MachineObject *obj);
|
||||
void Enable_Refresh_Button(bool en);
|
||||
void Enable_Send_Button(bool en);
|
||||
void update_user_machine_list();
|
||||
void update_lan_machine_list();
|
||||
void stripWhiteSpace(std::string &str);
|
||||
void update_ams_status_msg(wxString msg, bool is_warning = false);
|
||||
void update_priner_status_msg(wxString msg, bool is_warning = false);
|
||||
void update_print_status_msg(wxString msg, bool is_warning = false, bool is_printer = true);
|
||||
void update_print_error_info(int code, std::string msg, std::string extra);
|
||||
void set_flow_calibration_state(bool state, bool show_tips = true);
|
||||
bool has_timelapse_warning();
|
||||
void update_timelapse_enable_status();
|
||||
bool is_same_printer_model();
|
||||
bool is_blocking_printing(MachineObject *obj_);
|
||||
bool is_same_nozzle_diameters(NozzleType &tag_nozzle_type, float &nozzle_diameter);
|
||||
bool is_same_nozzle_type(std::string &filament_type, NozzleType &tag_nozzle_type);
|
||||
bool has_tips(MachineObject *obj);
|
||||
bool is_timeout();
|
||||
int update_print_required_data(Slic3r::DynamicPrintConfig config, Slic3r::Model model, Slic3r::PlateDataPtrs plate_data_list, std::string file_name, std::string file_path);
|
||||
void set_print_type(PrintFromType type) { m_print_type = type; };
|
||||
bool do_ams_mapping(MachineObject *obj_);
|
||||
bool get_ams_mapping_result(std::string &mapping_array_str, std::string &mapping_array_str2, std::string &ams_mapping_info);
|
||||
bool build_nozzles_info(std::string &nozzles_info);
|
||||
bool can_hybrid_mapping(ExtderData data);
|
||||
void auto_supply_with_ext(std::vector<AmsTray> slots);
|
||||
bool is_nozzle_type_match(ExtderData data);
|
||||
int convert_filament_map_nozzle_id_to_task_nozzle_id(int nozzle_id);
|
||||
|
||||
std::string get_print_status_info(PrintDialogStatus status);
|
||||
|
||||
PrintFromType get_print_type() { return m_print_type; };
|
||||
wxString format_bed_name(std::string plate_name);
|
||||
wxString format_steel_name(NozzleType type);
|
||||
wxString format_text(wxString &m_msg);
|
||||
PrintDialogStatus get_status() { return m_print_status; }
|
||||
std::vector<std::string> sort_string(std::vector<std::string> strArray);
|
||||
|
||||
const std::vector<FilamentInfo> &get_ams_mapping_result() { return m_ams_mapping_result; }
|
||||
|
||||
public:
|
||||
struct SyncInfo
|
||||
{
|
||||
bool connected_printer = false;
|
||||
bool first_sync = false;
|
||||
};
|
||||
struct SyncResult
|
||||
{
|
||||
bool direct_sync = true;
|
||||
std::map<int, AMSMapInfo> sync_maps;
|
||||
};
|
||||
SyncAmsInfoDialog(wxWindow *parent, SyncInfo &info);
|
||||
~SyncAmsInfoDialog();
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||
const SyncResult &get_result() { return m_result; }
|
||||
|
||||
public:
|
||||
bool Show(bool show) override;
|
||||
void updata_ui_data_after_connected_printer();
|
||||
void update_ams_check(MachineObject *obj);
|
||||
void set_default(bool hide_some = false);
|
||||
void update_select_layout(MachineObject *obj);
|
||||
void set_default_normal(const ThumbnailData &);
|
||||
bool is_must_finish_slice_then_connected_printer() ;
|
||||
void update_printer_name() ;
|
||||
void hide_no_use_controls();
|
||||
void show_sizer(wxSizer *sizer, bool show);
|
||||
void deal_ok();
|
||||
bool get_is_double_extruder();
|
||||
|
||||
private:
|
||||
wxBoxSizer *create_sizer_thumbnail(wxButton *image_button, bool left);
|
||||
void update_when_change_plate(int);
|
||||
|
||||
private:
|
||||
SyncInfo & m_input_info;
|
||||
SyncResult m_result;
|
||||
Button * m_button_ok = nullptr;
|
||||
Button * m_button_cancel = nullptr;
|
||||
|
||||
wxStaticText* m_tip_text{nullptr};
|
||||
wxStaticText* m_used_colors_tip_text{nullptr};
|
||||
wxStaticText* m_warning_text{nullptr};
|
||||
wxBoxSizer * m_left_sizer_thumbnail{nullptr};
|
||||
wxBoxSizer * m_right_sizer_thumbnail{nullptr};
|
||||
wxButton * m_left_image_button = nullptr;
|
||||
wxButton * m_right_image_button = nullptr;
|
||||
wxBoxSizer * sizer_basic_right_info = nullptr;
|
||||
wxBoxSizer * sizer_advanced_options_title = nullptr;
|
||||
wxPanel * m_rename_edit_panel = nullptr;
|
||||
wxStaticText * m_confirm_title = nullptr;
|
||||
wxStaticText * m_are_you_sure_title = nullptr;
|
||||
wxStaticText * m_specify_color_cluster_title = nullptr;
|
||||
wxBoxSizer * m_plate_combox_sizer = nullptr;
|
||||
wxBoxSizer * m_sizer_two_image = nullptr;
|
||||
wxStaticText * m_printer_title = nullptr;
|
||||
|
||||
wxCheckBox* m_append_color_checkbox = nullptr;
|
||||
wxCheckBox* m_merge_color_checkbox = nullptr;
|
||||
bool m_is_empty_project = true;
|
||||
|
||||
const int THUMBNAIL_SIZE_WIDTH = 200;
|
||||
int m_specify_plate_idx{-1};
|
||||
wxString m_printer_name;
|
||||
};
|
||||
}} // namespace Slic3r::GUI
|
||||
#endif // _STEP_MESH_DIALOG_H_
|
Loading…
Reference in New Issue