ENH: sync ams info to extruder group
Change-Id: Id0aace998a759c6e91aabb2685306e54e06d152e Jira: STUDIO-9828
This commit is contained in:
parent
7e16329d24
commit
2bae63e381
|
@ -358,22 +358,29 @@ struct ExtruderGroup : StaticGroup
|
||||||
ScalableButton * btn_up{nullptr};
|
ScalableButton * btn_up{nullptr};
|
||||||
ScalableButton * btn_down{nullptr};
|
ScalableButton * btn_down{nullptr};
|
||||||
wxBoxSizer *hsizer_ams { nullptr };
|
wxBoxSizer *hsizer_ams { nullptr };
|
||||||
int page_cur{0};
|
size_t page_cur{0};
|
||||||
int page_num{3};
|
size_t page_num{3};
|
||||||
int ams_n4 = 0;
|
size_t ams_n4 = 0;
|
||||||
int ams_n1 = 0;
|
size_t ams_n1 = 0;
|
||||||
|
std::vector<AMSinfo> ams_4;
|
||||||
|
std::vector<AMSinfo> ams_1;
|
||||||
wxString diameter;
|
wxString diameter;
|
||||||
|
|
||||||
void set_ams_count(int n4, int n1)
|
void set_ams_count(int n4, int n1)
|
||||||
{
|
{
|
||||||
ams_n4 = n4;
|
ams_n4 = n4;
|
||||||
ams_n1 = n1;
|
ams_n1 = n1;
|
||||||
if (btn_edit)
|
|
||||||
update_ams();
|
if (btn_edit) {
|
||||||
|
if (GUI::wxGetApp().plater())
|
||||||
|
GUI::wxGetApp().plater()->update_machine_sync_status();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_ams();
|
void update_ams();
|
||||||
|
|
||||||
|
void sync_ams(MachineObject const *obj, std::vector<Ams *> const &ams4, std::vector<Ams *> const &ams1);
|
||||||
|
|
||||||
void Rescale()
|
void Rescale()
|
||||||
{
|
{
|
||||||
if (btn_edit)
|
if (btn_edit)
|
||||||
|
@ -466,6 +473,7 @@ struct Sidebar::priv
|
||||||
ScalableButton* btn_export_gcode_removable; //exports to removable drives (appears only if removable drive is connected)
|
ScalableButton* btn_export_gcode_removable; //exports to removable drives (appears only if removable drive is connected)
|
||||||
|
|
||||||
bool is_collapsed {false};
|
bool is_collapsed {false};
|
||||||
|
bool is_switching_diameter{false};
|
||||||
Search::OptionsSearcher searcher;
|
Search::OptionsSearcher searcher;
|
||||||
std::string ams_list_device;
|
std::string ams_list_device;
|
||||||
|
|
||||||
|
@ -788,11 +796,9 @@ public:
|
||||||
txt1->SetForegroundColour(0x6B6B6B);
|
txt1->SetForegroundColour(0x6B6B6B);
|
||||||
int ams4 = 0, ams1 = 0;
|
int ams4 = 0, ams1 = 0;
|
||||||
GetAMSCount(index, ams4, ams1);
|
GetAMSCount(index, ams4, ams1);
|
||||||
auto val4 = new SpinInput(this, {}, {}, wxDefaultPosition, {FromDIP(60), -1}, 0, 0, 4 - ams1, ams4);
|
auto val4 = new SpinInput(this, {}, {}, wxDefaultPosition, {FromDIP(60), -1}, 0, 0, 4, ams4);
|
||||||
auto val1 = new SpinInput(this, {}, {}, wxDefaultPosition, {FromDIP(60), -1}, 0, 0, 4 - ams4, ams1);
|
auto val1 = new SpinInput(this, {}, {}, wxDefaultPosition, {FromDIP(60), -1}, 0, 0, 8, ams1);
|
||||||
auto event_handler = [index, val4, val1, extruder](auto &evt) {
|
auto event_handler = [index, val4, val1, extruder](auto &evt) {
|
||||||
val4->SetRange(0, 4 - val1->GetValue());
|
|
||||||
val1->SetRange(0, 4 - val4->GetValue());
|
|
||||||
SetAMSCount(index, val4->GetValue(), val1->GetValue());
|
SetAMSCount(index, val4->GetValue(), val1->GetValue());
|
||||||
UpdateAMSCount(index, extruder);
|
UpdateAMSCount(index, extruder);
|
||||||
};
|
};
|
||||||
|
@ -967,8 +973,8 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title
|
||||||
label_ams->Hide();
|
label_ams->Hide();
|
||||||
ams_not_installed_msg->Hide();
|
ams_not_installed_msg->Hide();
|
||||||
wxStaticBoxSizer *hsizer = new wxStaticBoxSizer(this, wxHORIZONTAL);
|
wxStaticBoxSizer *hsizer = new wxStaticBoxSizer(this, wxHORIZONTAL);
|
||||||
hsizer->Add(hsizer_diameter, 1, wxEXPAND | wxALL, FromDIP(2));
|
hsizer->Add(hsizer_diameter, 1, wxEXPAND | wxALL, FromDIP(8));
|
||||||
hsizer->Add(hsizer_nozzle, 1, wxEXPAND | wxALL, FromDIP(2));
|
hsizer->Add(hsizer_nozzle, 1, wxEXPAND | wxALL, FromDIP(8));
|
||||||
this->sizer = hsizer;
|
this->sizer = hsizer;
|
||||||
} else {
|
} else {
|
||||||
wxStaticBoxSizer *vsizer = new wxStaticBoxSizer(this, wxVERTICAL);
|
wxStaticBoxSizer *vsizer = new wxStaticBoxSizer(this, wxVERTICAL);
|
||||||
|
@ -983,74 +989,38 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title
|
||||||
|
|
||||||
void ExtruderGroup::update_ams()
|
void ExtruderGroup::update_ams()
|
||||||
{
|
{
|
||||||
int display_capacity = 8;
|
static AMSinfo info4;
|
||||||
|
static AMSinfo info1;
|
||||||
//if (ams_n4 * 4 + ams_n1 * 2 <= 8)
|
if (info4.cans.empty()) {
|
||||||
// is_upward = false;
|
for (size_t i = 0; i < 4; ++i) info4.cans.push_back({});
|
||||||
|
info1.ams_type = AMSModel::N3S_AMS;
|
||||||
std::vector<wxColour> colors = {
|
info1.cans.push_back({});
|
||||||
wxColour(255, 110, 100),
|
|
||||||
wxColour(97, 27, 22),
|
|
||||||
wxColour(7, 134, 219),
|
|
||||||
wxColour(170, 111, 252)
|
|
||||||
};
|
|
||||||
|
|
||||||
bool display_front_ams = false; //!is_upward;
|
|
||||||
size_t i = 0;
|
|
||||||
for (; i < ams_n4 && i < 4; ++i) {
|
|
||||||
display_capacity -= 4;
|
|
||||||
bool show_this_ams = (display_capacity >= 0) && display_front_ams;
|
|
||||||
show_this_ams |= (display_capacity < 0) && !display_front_ams;
|
|
||||||
if (show_this_ams) {
|
|
||||||
AMSinfo ams_info;
|
|
||||||
ams_info.ams_type = AMSModel::GENERIC_AMS;
|
|
||||||
for (size_t i = 0; i < 4; ++i) {
|
|
||||||
Caninfo can_info;
|
|
||||||
//can_info.material_colour = colors[i];
|
|
||||||
ams_info.cans.push_back(can_info);
|
|
||||||
}
|
|
||||||
ams[i]->Update(ams_info);
|
|
||||||
ams[i]->Refresh();
|
|
||||||
ams[i]->Open();
|
|
||||||
} else {
|
|
||||||
ams[i]->Close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; i < ams_n4 + ams_n1 && i < 4; ++i) {
|
page_num = (ams_n4 * 2 + ams_n1 + 3) / 4;
|
||||||
display_capacity -= 2;
|
size_t i4 = page_cur * 2;
|
||||||
bool show_this_ams = (display_capacity >= 0) && display_front_ams;
|
size_t i1 = 0;
|
||||||
show_this_ams |= (display_capacity < 0) && !display_front_ams;
|
if (i4 > ams_n4) {
|
||||||
if (show_this_ams) {
|
i1 = (i4 - ams_n4) * 2;
|
||||||
AMSinfo ams_info;
|
i4 = ams_n4;
|
||||||
ams_info.ams_type = AMSModel::N3S_AMS;
|
|
||||||
Caninfo can_info;
|
|
||||||
//can_info.material_colour = wxColour(255, 110, 100);
|
|
||||||
ams_info.cans.push_back(can_info);
|
|
||||||
ams[i]->Update(ams_info);
|
|
||||||
ams[i]->Refresh();
|
|
||||||
ams[i]->Open();
|
|
||||||
} else {
|
|
||||||
ams[i]->Close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 0) {
|
size_t left = 4;
|
||||||
ams_not_installed_msg->Show();
|
size_t index = 0;
|
||||||
btn_up->Hide();
|
for (size_t i = i4; i < ams_n4 && left > 0; ++i, ++index, left -= 2) {
|
||||||
for (AMSPreview *a : ams) {
|
ams[index]->Update(i < ams_4.size() ? ams_4[i] : info4);
|
||||||
a->Close();
|
ams[index]->Refresh();
|
||||||
}
|
ams[index]->Open();
|
||||||
} else {
|
|
||||||
ams_not_installed_msg->Hide();
|
|
||||||
for (; i < 4; ++i) { ams[i]->Close(); }
|
|
||||||
if (display_capacity < 0) {
|
|
||||||
btn_up->Show();
|
|
||||||
} else {
|
|
||||||
btn_up->Hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
for (size_t i = i1; i < ams_n1 && left > 0; ++i, ++index, --left) {
|
||||||
|
ams[index]->Update(i < ams_1.size() ? ams_1[i] : info1);
|
||||||
|
ams[index]->Refresh();
|
||||||
|
ams[index]->Open();
|
||||||
|
}
|
||||||
|
for (; index < 4; ++index)
|
||||||
|
ams[index]->Close();
|
||||||
|
|
||||||
|
ams_not_installed_msg->Show(ams_n4 == 0 && ams_n1 == 0);
|
||||||
btn_up->Show(page_cur > 0);
|
btn_up->Show(page_cur > 0);
|
||||||
btn_down->Show(page_cur + 1 < page_num);
|
btn_down->Show(page_cur + 1 < page_num);
|
||||||
|
|
||||||
|
@ -1063,7 +1033,7 @@ void ExtruderGroup::update_ams()
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < 4; ++i) {
|
for (size_t i = 0; i < 4; ++i) {
|
||||||
if (ams[i]->IsShown())
|
if (ams[i]->IsShown())
|
||||||
hsizer_ams->Add(this->ams[i], 0, wxLEFT, FromDIP(2));
|
hsizer_ams->Add(this->ams[i], 0, wxLEFT, FromDIP(1));
|
||||||
}
|
}
|
||||||
if (btn_up->IsShown() || btn_down->IsShown()) {
|
if (btn_up->IsShown() || btn_down->IsShown()) {
|
||||||
if (btn_edit)
|
if (btn_edit)
|
||||||
|
@ -1082,9 +1052,21 @@ void ExtruderGroup::update_ams()
|
||||||
}
|
}
|
||||||
|
|
||||||
sizer->Layout();
|
sizer->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
if (GUI::wxGetApp().plater())
|
void ExtruderGroup::sync_ams(MachineObject const *obj, std::vector<Ams *> const &ams4, std::vector<Ams *> const &ams1)
|
||||||
GUI::wxGetApp().plater()->update_machine_sync_status();
|
{
|
||||||
|
auto sync = [obj](std::vector<AMSinfo> &infos, std::vector<Ams *> const &ams) {
|
||||||
|
infos.clear();
|
||||||
|
for (auto a : ams) {
|
||||||
|
AMSinfo ams_info;
|
||||||
|
ams_info.parse_ams_info(const_cast<MachineObject*>(obj), a, obj->ams_calibrate_remain_flag, obj->is_support_ams_humidity);
|
||||||
|
infos.push_back(ams_info);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
sync(ams_4, ams4);
|
||||||
|
sync(ams_1, ams1);
|
||||||
|
update_ams();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sidebar::priv::switch_diameter(bool single)
|
bool Sidebar::priv::switch_diameter(bool single)
|
||||||
|
@ -1225,9 +1207,12 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj)
|
||||||
auto clear_all_sync_status = [this]() {
|
auto clear_all_sync_status = [this]() {
|
||||||
panel_printer_preset->ShowBadge(false);
|
panel_printer_preset->ShowBadge(false);
|
||||||
panel_printer_bed->ShowBadge(false);
|
panel_printer_bed->ShowBadge(false);
|
||||||
//left_extruder->ShowBadge(false);
|
left_extruder->ShowBadge(false);
|
||||||
|
left_extruder->sync_ams(nullptr, {}, {});
|
||||||
right_extruder->ShowBadge(false);
|
right_extruder->ShowBadge(false);
|
||||||
|
right_extruder->sync_ams(nullptr, {}, {});
|
||||||
single_extruder->ShowBadge(false);
|
single_extruder->ShowBadge(false);
|
||||||
|
single_extruder->sync_ams(nullptr, {}, {});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!obj || !obj->is_info_ready()) {
|
if (!obj || !obj->is_info_ready()) {
|
||||||
|
@ -1258,6 +1243,8 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj)
|
||||||
int nozzle_volue_type{0};
|
int nozzle_volue_type{0};
|
||||||
int ams_4{0};
|
int ams_4{0};
|
||||||
int ams_1{0};
|
int ams_1{0};
|
||||||
|
std::vector<Ams *> ams_v4;
|
||||||
|
std::vector<Ams *> ams_v1;
|
||||||
|
|
||||||
bool operator==(const ExtruderInfo &other) const
|
bool operator==(const ExtruderInfo &other) const
|
||||||
{
|
{
|
||||||
|
@ -1317,8 +1304,10 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj)
|
||||||
|
|
||||||
if (item.second->type == 4) { // N3S
|
if (item.second->type == 4) { // N3S
|
||||||
machine_extruder_infos[item.second->nozzle].ams_1++;
|
machine_extruder_infos[item.second->nozzle].ams_1++;
|
||||||
|
machine_extruder_infos[item.second->nozzle].ams_v1.push_back(item.second);
|
||||||
} else {
|
} else {
|
||||||
machine_extruder_infos[item.second->nozzle].ams_4++;
|
machine_extruder_infos[item.second->nozzle].ams_4++;
|
||||||
|
machine_extruder_infos[item.second->nozzle].ams_v4.push_back(item.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1328,25 +1317,34 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj)
|
||||||
if (extruder_nums == 1) {
|
if (extruder_nums == 1) {
|
||||||
if (extruder_infos == machine_extruder_infos) {
|
if (extruder_infos == machine_extruder_infos) {
|
||||||
single_extruder->ShowBadge(true);
|
single_extruder->ShowBadge(true);
|
||||||
|
single_extruder->sync_ams(obj, machine_extruder_infos[0].ams_v4, machine_extruder_infos[0].ams_v1);
|
||||||
extruder_synced[0] = true;
|
extruder_synced[0] = true;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
single_extruder->ShowBadge(false);
|
single_extruder->ShowBadge(false);
|
||||||
|
single_extruder->sync_ams(obj, {}, {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (extruder_nums == 2) {
|
else if (extruder_nums == 2) {
|
||||||
if (extruder_infos[0] == machine_extruder_infos[0]) {
|
if (extruder_infos[0] == machine_extruder_infos[0]) {
|
||||||
left_extruder->ShowBadge(true);
|
left_extruder->ShowBadge(true);
|
||||||
|
left_extruder->sync_ams(obj, machine_extruder_infos[0].ams_v4, machine_extruder_infos[0].ams_v1);
|
||||||
extruder_synced[0] = true;
|
extruder_synced[0] = true;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
left_extruder->ShowBadge(false);
|
left_extruder->ShowBadge(false);
|
||||||
|
left_extruder->sync_ams(obj, {}, {});
|
||||||
|
}
|
||||||
|
|
||||||
if (extruder_infos[1] == machine_extruder_infos[1]) {
|
if (extruder_infos[1] == machine_extruder_infos[1]) {
|
||||||
right_extruder->ShowBadge(true);
|
right_extruder->ShowBadge(true);
|
||||||
|
right_extruder->sync_ams(obj, machine_extruder_infos[1].ams_v4, machine_extruder_infos[1].ams_v1);
|
||||||
extruder_synced[1] = true;
|
extruder_synced[1] = true;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
right_extruder->ShowBadge(false);
|
right_extruder->ShowBadge(false);
|
||||||
|
right_extruder->sync_ams(obj, {}, {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StateColor synced_colour(std::pair<wxColour, int>(wxColour("#CECECE"), StateColor::Normal));
|
StateColor synced_colour(std::pair<wxColour, int>(wxColour("#CECECE"), StateColor::Normal));
|
||||||
|
@ -1631,15 +1629,9 @@ Sidebar::Sidebar(Plater *parent)
|
||||||
p->single_extruder = new ExtruderGroup(p->m_panel_printer_content, -1, "Nozzle");
|
p->single_extruder = new ExtruderGroup(p->m_panel_printer_content, -1, "Nozzle");
|
||||||
auto switch_diameter = [this](wxCommandEvent & evt) {
|
auto switch_diameter = [this](wxCommandEvent & evt) {
|
||||||
auto extruder = dynamic_cast<ExtruderGroup *>(dynamic_cast<ComboBox *>(evt.GetEventObject())->GetParent());
|
auto extruder = dynamic_cast<ExtruderGroup *>(dynamic_cast<ComboBox *>(evt.GetEventObject())->GetParent());
|
||||||
|
p->is_switching_diameter = true;
|
||||||
auto result = p->switch_diameter(extruder == p->single_extruder);
|
auto result = p->switch_diameter(extruder == p->single_extruder);
|
||||||
if (result) {
|
p->is_switching_diameter = false;
|
||||||
if (extruder != p->single_extruder) {
|
|
||||||
extruder->combo_diameter->SetSelection(evt.GetInt());
|
|
||||||
extruder->diameter = evt.GetString();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
extruder->combo_diameter->SetValue(extruder->diameter);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
p->left_extruder->combo_diameter->Bind(wxEVT_COMBOBOX, switch_diameter);
|
p->left_extruder->combo_diameter->Bind(wxEVT_COMBOBOX, switch_diameter);
|
||||||
p->right_extruder->combo_diameter->Bind(wxEVT_COMBOBOX, switch_diameter);
|
p->right_extruder->combo_diameter->Bind(wxEVT_COMBOBOX, switch_diameter);
|
||||||
|
@ -2225,12 +2217,15 @@ void Sidebar::update_presets(Preset::Type preset_type)
|
||||||
if (is_dual_extruder) {
|
if (is_dual_extruder) {
|
||||||
update_extruder_variant(*p->left_extruder, 0);
|
update_extruder_variant(*p->left_extruder, 0);
|
||||||
update_extruder_variant(*p->right_extruder, 1);
|
update_extruder_variant(*p->right_extruder, 1);
|
||||||
update_extruder_diameter(*p->left_extruder);
|
if (!p->is_switching_diameter) {
|
||||||
update_extruder_diameter(*p->right_extruder);
|
update_extruder_diameter(*p->left_extruder);
|
||||||
|
update_extruder_diameter(*p->right_extruder);
|
||||||
|
}
|
||||||
p->image_printer_bed->SetBitmap(create_scaled_bitmap(bed_type_thumbnails[BedType(p->combo_printer_bed->GetSelection() + 1)], this, 48));
|
p->image_printer_bed->SetBitmap(create_scaled_bitmap(bed_type_thumbnails[BedType(p->combo_printer_bed->GetSelection() + 1)], this, 48));
|
||||||
} else {
|
} else {
|
||||||
update_extruder_variant(*p->single_extruder, 0);
|
update_extruder_variant(*p->single_extruder, 0);
|
||||||
update_extruder_diameter(*p->single_extruder);
|
if (!p->is_switching_diameter)
|
||||||
|
update_extruder_diameter(*p->single_extruder);
|
||||||
p->image_printer_bed->SetBitmap(create_scaled_bitmap(bed_type_thumbnails[BedType(p->combo_printer_bed->GetSelection() + 1)], this, 32));
|
p->image_printer_bed->SetBitmap(create_scaled_bitmap(bed_type_thumbnails[BedType(p->combo_printer_bed->GetSelection() + 1)], this, 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue