mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-08-05 14:20:40 +08:00
ENH:The print page needs to support multiple alert messages
jira: [STUDIO-10756] Change-Id: I61edceef2f6bcf30bb87aec41593009af30831fa
This commit is contained in:
parent
54b6cc3c41
commit
2a7da8456c
@ -2,6 +2,8 @@
|
||||
#include "GUI_Utils.hpp"
|
||||
#include "I18N.hpp"
|
||||
|
||||
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
std::string PrePrintChecker::get_print_status_info(PrintDialogStatus status)
|
||||
@ -162,4 +164,71 @@ void PrePrintChecker::add(PrintDialogStatus state, wxString msg, wxString tip)
|
||||
// Fit();
|
||||
//}
|
||||
|
||||
}};
|
||||
PrinterMsgPanel::PrinterMsgPanel(wxWindow *parent)
|
||||
: wxPanel(parent)
|
||||
{
|
||||
m_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
this->SetSizer(m_sizer);
|
||||
}
|
||||
|
||||
void PrinterMsgPanel::SetLabelList(const std::vector<wxString> &texts, const wxColour &colour)
|
||||
{
|
||||
|
||||
if (texts == m_last_texts)
|
||||
return;
|
||||
|
||||
m_last_texts = texts;
|
||||
|
||||
m_labels.clear();
|
||||
m_sizer->Clear(true);
|
||||
//for (auto *label : m_labels) {
|
||||
// m_sizer->Detach(label);
|
||||
// label->Destroy();
|
||||
//}
|
||||
//m_labels.clear();
|
||||
|
||||
for (const wxString &text : texts) {
|
||||
if (text.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Label *label = new Label(this);
|
||||
label->SetFont(::Label::Body_13);
|
||||
label->SetForegroundColour(colour);
|
||||
label->SetLabel(text);
|
||||
label->Wrap(this->GetMinSize().GetWidth());
|
||||
label->Show();
|
||||
m_sizer->Add(label, 0, wxBOTTOM, FromDIP(4));
|
||||
m_labels.push_back(label);
|
||||
}
|
||||
this->Show();
|
||||
this->Layout();
|
||||
Fit();
|
||||
}
|
||||
|
||||
//void PrinterMsgPanel::SetLabelSingle(const wxString &texts, const wxColour &colour)
|
||||
//{
|
||||
// Label *label = new Label(this);
|
||||
// label->SetMinSize(wxSize(FromDIP(420), -1));
|
||||
// label->SetMaxSize(wxSize(FromDIP(420), -1));
|
||||
// label->SetFont(::Label::Body_13);
|
||||
// label->SetForegroundColour(colour);
|
||||
// label->SetLabel(texts);
|
||||
// label->Wrap(FromDIP(-1));
|
||||
// label->Show();
|
||||
// m_sizer->Add(label, 0, wxBOTTOM, FromDIP(4));
|
||||
// m_labels.push_back(label);
|
||||
// this->Layout();
|
||||
// Fit();
|
||||
//}
|
||||
|
||||
wxString PrinterMsgPanel::GetLabel() {
|
||||
if (!m_labels.empty() && m_labels[0] != nullptr)
|
||||
return m_labels[0]->GetLabel();
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define slic3r_GUI_PRE_PRINT_CHECK_hpp_
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include "Widgets/Label.hpp"
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
enum prePrintInfoLevel {
|
||||
@ -130,8 +130,6 @@ public:
|
||||
bool is_warning_printer(PrintDialogStatus status) { return (PrintStatusPrinterWarningBegin < status) && (PrintStatusPrinterWarningEnd > status); };
|
||||
bool is_warning_filament(PrintDialogStatus status) { return (PrintStatusFilamentWarningBegin < status) && (PrintStatusFilamentWarningEnd > status); };
|
||||
};
|
||||
|
||||
|
||||
//class PrePrintMsgBoard : public wxWindow
|
||||
//{
|
||||
//public:
|
||||
@ -161,6 +159,25 @@ public:
|
||||
|
||||
|
||||
|
||||
class PrinterMsgPanel : public wxPanel
|
||||
{
|
||||
public:
|
||||
PrinterMsgPanel(wxWindow *parent);
|
||||
|
||||
void SetLabelList(const std::vector<wxString> &texts, const wxColour &colour);
|
||||
|
||||
// void SetLabelSingle(const wxString &texts,const wxColour& colour);
|
||||
|
||||
wxString GetLabel();
|
||||
|
||||
|
||||
private:
|
||||
wxBoxSizer * m_sizer = nullptr;
|
||||
std::vector<Label *> m_labels;
|
||||
std::vector<wxString> m_last_texts;
|
||||
};
|
||||
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
#endif
|
||||
|
@ -275,9 +275,10 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
||||
|
||||
m_printer_box = new PrinterInfoBox(m_basic_panel, this);
|
||||
|
||||
m_text_printer_msg = new Label(m_basic_panel);
|
||||
m_text_printer_msg->SetMinSize(wxSize(FromDIP(420), FromDIP(24)));
|
||||
m_text_printer_msg->SetMaxSize(wxSize(FromDIP(420), FromDIP(24)));
|
||||
|
||||
m_text_printer_msg = new PrinterMsgPanel(m_basic_panel);
|
||||
m_text_printer_msg->SetMinSize(wxSize(FromDIP(420), -1));
|
||||
m_text_printer_msg->SetMaxSize(wxSize(FromDIP(420), -1));
|
||||
m_text_printer_msg->SetFont(::Label::Body_13);
|
||||
m_text_printer_msg->Hide();
|
||||
|
||||
@ -304,8 +305,6 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
||||
m_basicl_sizer->Add(0, 0, 0, wxLEFT, FromDIP(8));
|
||||
m_basicl_sizer->Add(sizer_basic_right_info, 0, wxLEFT, 0);
|
||||
|
||||
|
||||
|
||||
m_basic_panel->SetSizer(m_basicl_sizer);
|
||||
m_basic_panel->Layout();
|
||||
|
||||
@ -414,7 +413,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
||||
|
||||
m_filament_panel->Hide();
|
||||
|
||||
m_statictext_ams_msg = new Label(m_scroll_area, wxEmptyString);
|
||||
m_statictext_ams_msg = new PrinterMsgPanel(m_scroll_area);
|
||||
m_statictext_ams_msg->SetMinSize(wxSize(FromDIP(645), -1));
|
||||
m_statictext_ams_msg->SetMaxSize(wxSize(FromDIP(645), -1));
|
||||
m_statictext_ams_msg->SetFont(::Label::Body_13);
|
||||
@ -1420,64 +1419,55 @@ void SelectMachineDialog::prepare(int print_plate_idx)
|
||||
m_print_plate_idx = print_plate_idx;
|
||||
}
|
||||
|
||||
void SelectMachineDialog::update_ams_status_msg(wxString msg, bool is_error)
|
||||
void SelectMachineDialog::update_ams_status_msg(vector<wxString> msg, bool is_error,bool is_single)
|
||||
{
|
||||
auto colour = is_error ? wxColour("#D01B1B") : wxColour("#FF6F00");
|
||||
m_statictext_ams_msg->SetForegroundColour(colour);
|
||||
auto colour = is_error ? wxColour("#D01B1B") : wxColour("#FF6F00");
|
||||
m_statictext_ams_msg->SetForegroundColour(colour);
|
||||
|
||||
if (msg.empty()) {
|
||||
if (!m_statictext_ams_msg->GetLabel().empty()) {
|
||||
m_statictext_ams_msg->SetLabel(wxEmptyString);
|
||||
m_statictext_ams_msg->Hide();
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
} else {
|
||||
auto str_new = msg.utf8_string();
|
||||
auto str_old = m_statictext_ams_msg->GetLabel().utf8_string();
|
||||
|
||||
if (str_new != str_old) {
|
||||
if (m_statictext_ams_msg->GetLabel() != msg) {
|
||||
m_statictext_ams_msg->SetLabel(msg);
|
||||
m_statictext_ams_msg->Wrap(FromDIP(645));
|
||||
m_statictext_ams_msg->Show();
|
||||
if (msg.empty()) {
|
||||
if (!m_statictext_ams_msg->GetLabel().empty()) {
|
||||
m_statictext_ams_msg->SetLabelList(std::vector<wxString>{}, colour);
|
||||
m_statictext_ams_msg->Hide();
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (is_single)
|
||||
m_statictext_ams_msg->SetLabelList({ msg[0] }, colour);
|
||||
else {
|
||||
m_statictext_ams_msg->SetLabelList(msg, colour);
|
||||
m_statictext_ams_msg->Show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SelectMachineDialog::update_priner_status_msg(wxString msg, bool is_error)
|
||||
void SelectMachineDialog::update_priner_status_msg(vector<wxString> msg, bool is_error,bool is_single)
|
||||
{
|
||||
auto colour = is_error ? wxColour("#D01B1B") : wxColour("#FF6F00");
|
||||
m_text_printer_msg->SetForegroundColour(colour);
|
||||
|
||||
if (msg.empty()) {
|
||||
if (!m_text_printer_msg->GetLabel().empty()) {
|
||||
m_text_printer_msg->SetLabel(wxEmptyString);
|
||||
m_text_printer_msg->SetLabelList(std::vector<wxString>{}, colour);
|
||||
m_text_printer_msg->Hide();
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
} else {
|
||||
auto str_new = msg.utf8_string();
|
||||
auto str_old = m_text_printer_msg->GetLabel().utf8_string();
|
||||
|
||||
if (str_new != str_old) {
|
||||
if (m_text_printer_msg->GetLabel() != msg) {
|
||||
m_text_printer_msg->SetLabel(msg);
|
||||
m_text_printer_msg->SetMinSize(wxSize(FromDIP(420), -1));
|
||||
m_text_printer_msg->SetMaxSize(wxSize(FromDIP(420), -1));
|
||||
m_text_printer_msg->Wrap(FromDIP(420));
|
||||
m_text_printer_msg->Show();
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (is_single)
|
||||
m_text_printer_msg->SetLabelList({msg[0]}, colour);
|
||||
else {
|
||||
m_text_printer_msg->SetLabelList(msg, colour);
|
||||
m_text_printer_msg->Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SelectMachineDialog::update_printer_status_msg_tips(const wxString &msg_tips)
|
||||
{
|
||||
if (msg_tips.empty()) {
|
||||
@ -1507,18 +1497,34 @@ void SelectMachineDialog::update_printer_status_msg_tips(const wxString &msg_tip
|
||||
|
||||
void SelectMachineDialog::update_print_status_msg()
|
||||
{
|
||||
if (m_pre_print_checker.filamentList.size() <= 0) update_ams_status_msg(wxEmptyString, false);
|
||||
if (m_pre_print_checker.printerList.size() <= 0) update_priner_status_msg(wxEmptyString, false);
|
||||
//if (m_pre_print_checker.filamentList.size() <= 0) update_ams_status_msg(wxEmptyString, false);
|
||||
if (m_pre_print_checker.filamentList.size() <= 0) update_ams_status_msg(std::vector<wxString>{}, false,false);
|
||||
if (m_pre_print_checker.printerList.size() <= 0) update_priner_status_msg(std::vector<wxString>{}, false,false);
|
||||
|
||||
// for (const auto &info : m_pre_print_checker.filamentList) { update_ams_status_msg(info.msg, info.level == Error ? true : false); }
|
||||
|
||||
std::vector<wxString> filamentList_msgs;
|
||||
bool filamentList_color;
|
||||
for (const auto &info : m_pre_print_checker.filamentList) {
|
||||
update_ams_status_msg(info.msg, info.level == Error ? true : false);
|
||||
filamentList_msgs.push_back(info.msg);
|
||||
filamentList_color = info.level == Error ? true : false;
|
||||
}
|
||||
update_ams_status_msg(filamentList_msgs, filamentList_color, false);
|
||||
|
||||
|
||||
std::vector<wxString> printerList_msgs;
|
||||
bool printermsg_color;
|
||||
for (const auto &info : m_pre_print_checker.printerList) {
|
||||
update_priner_status_msg(info.msg, info.level == Error ? true : false);
|
||||
printerList_msgs.push_back(info.msg);
|
||||
printermsg_color = info.level == Error ? true : false;
|
||||
|
||||
update_printer_status_msg_tips(info.tips);
|
||||
}
|
||||
}
|
||||
update_priner_status_msg(printerList_msgs, printermsg_color,false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SelectMachineDialog::update_print_error_info(int code, std::string msg, std::string extra)
|
||||
{
|
||||
@ -1682,7 +1688,10 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector<wxSt
|
||||
Enable_Refresh_Button(true);
|
||||
Enable_Send_Button(false);
|
||||
}
|
||||
} else if (status == PrintDialogStatus::PrintStatusTimelapseNoSdcard) {
|
||||
|
||||
|
||||
|
||||
} else if (status == PrintDialogStatus::PrintStatusTimelapseNoSdcard) { //this warning
|
||||
Enable_Refresh_Button(true);
|
||||
Enable_Send_Button(true);
|
||||
} else if (status == PrintDialogStatus::PrintStatusNeedForceUpgrading) {
|
||||
@ -1697,7 +1706,7 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector<wxSt
|
||||
} else if (status == PrintDialogStatus::PrintStatusNotSupportedPrintAll) {
|
||||
Enable_Refresh_Button(true);
|
||||
Enable_Send_Button(false);
|
||||
} else if (status == PrintDialogStatus::PrintStatusTimelapseWarning) {
|
||||
} else if (status == PrintDialogStatus::PrintStatusTimelapseWarning) { //this is warning
|
||||
wxString msg_text;
|
||||
PartPlate *plate = m_plater->get_partplate_list().get_curr_plate();
|
||||
for (auto warning : plate->get_slice_result()->warnings) {
|
||||
@ -1719,7 +1728,7 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector<wxSt
|
||||
} else if (status == PrintStatusTPUUnsupportAutoCali) {
|
||||
Enable_Refresh_Button(true);
|
||||
Enable_Send_Button(false);
|
||||
} else if (status == PrintStatusHasFilamentInBlackListError) {
|
||||
} else if (status == PrintStatusHasFilamentInBlackListError) { //this war
|
||||
Enable_Refresh_Button(true);
|
||||
Enable_Send_Button(false);
|
||||
} else if (status == PrintStatusWarningKvalueNotUsed) {
|
||||
@ -1742,6 +1751,7 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector<wxSt
|
||||
/*enter perpare mode*/
|
||||
prepare_mode(false);
|
||||
m_pre_print_checker.add(status, msg, tips);
|
||||
|
||||
}
|
||||
|
||||
void SelectMachineDialog::init_timer()
|
||||
@ -3239,6 +3249,7 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
|
||||
if (!agent) {
|
||||
show_status(PrintDialogStatus::PrintStatusNoUserLogin);
|
||||
update_ams_check(nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!obj_) {
|
||||
@ -3486,7 +3497,7 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
|
||||
}
|
||||
else if (action == "warning") {
|
||||
show_status(PrintDialogStatus::PrintStatusHasFilamentInBlackListWarning, error_msg);/** warning check **/
|
||||
return;
|
||||
// return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3510,21 +3521,20 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
|
||||
for (auto extruder : extruder_status) {
|
||||
if (extruder.has_ams && extruder.has_vt_slot) {
|
||||
show_status(PrintDialogStatus::PrintStatusMixAmsAndVtSlotWarning);
|
||||
return;
|
||||
// return;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ams_mapping_res) {
|
||||
if (has_timelapse_warning()) {
|
||||
show_status(PrintDialogStatus::PrintStatusTimelapseWarning);
|
||||
return;
|
||||
// return;
|
||||
}
|
||||
} else {
|
||||
if (obj_->is_valid_mapping_result(m_ams_mapping_result)) {
|
||||
if (!check_sdcard_for_timelpase(obj_)) {
|
||||
if (has_timelapse_warning()) {
|
||||
show_status(PrintDialogStatus::PrintStatusTimelapseWarning);
|
||||
return;
|
||||
// return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3536,7 +3546,7 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
|
||||
if (!not_default_ams_names.empty()) {
|
||||
std::vector<wxString> params{not_default_ams_names};
|
||||
show_status(PrintDialogStatus::PrintStatusWarningKvalueNotUsed);
|
||||
return;
|
||||
// return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3547,8 +3557,7 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
|
||||
if (item.type.compare("TPU") != 0 && item.type.compare("TPU-AMS") != 0) { continue; }
|
||||
|
||||
int extruder_id = obj_->get_extruder_id_by_ams_id(item.ams_id);
|
||||
if (extruder_id == MAIN_NOZZLE_ID)
|
||||
{
|
||||
if (extruder_id == MAIN_NOZZLE_ID) {
|
||||
show_status(PrintDialogStatus::PrintStatusWarningTpuRightColdPulling);
|
||||
break;
|
||||
}
|
||||
@ -3571,7 +3580,7 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
|
||||
if (obj_->is_support_chamber_edit && chamber_temp >= obj_->chamber_temp_switch_heat)
|
||||
{
|
||||
show_status(PrintDialogStatus::PrintStatusFilamentHighChamberTempCloseDoor);
|
||||
return;
|
||||
// return;
|
||||
}
|
||||
|
||||
// check vitrification
|
||||
@ -3596,7 +3605,7 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
|
||||
}
|
||||
|
||||
if (!known_fila_soften_extruders.empty()) {
|
||||
const wxString& msg = wxString::Format(_L("The filament on %s may soften. Please unload."),
|
||||
const wxString& msg = wxString::Format(_L("The filament on %s may soften. Please unload."),
|
||||
_get_ext_loc_str(known_fila_soften_extruders, obj_->m_extder_data.total_extder_count));
|
||||
show_status(PrintDialogStatus::PrintStatusFilamentHighChamberTempSoft, std::vector<wxString> {msg});
|
||||
return;
|
||||
@ -3610,7 +3619,7 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
|
||||
}
|
||||
|
||||
/** normal check **/
|
||||
show_status(PrintDialogStatus::PrintStatusReadyToGo);
|
||||
// show_status(PrintDialogStatus::PrintStatusReadyToGo);
|
||||
}
|
||||
|
||||
bool SelectMachineDialog::has_timelapse_warning(wxString &msg_text)
|
||||
|
@ -361,11 +361,11 @@ protected:
|
||||
wxStaticText* m_rename_text{nullptr};
|
||||
Label* m_stext_time{ nullptr };
|
||||
Label* m_stext_weight{ nullptr };
|
||||
Label* m_statictext_ams_msg{ nullptr };
|
||||
PrinterMsgPanel * m_statictext_ams_msg{nullptr};
|
||||
Label* m_txt_change_filament_times{ nullptr };
|
||||
|
||||
PrinterInfoBox* m_printer_box { nullptr};
|
||||
Label* m_text_printer_msg{ nullptr };
|
||||
PrinterMsgPanel * m_text_printer_msg{nullptr};
|
||||
Label* m_text_printer_msg_tips{ nullptr };
|
||||
wxStaticText* m_staticText_bed_title{ nullptr };
|
||||
wxStaticText* m_stext_sending{ nullptr };
|
||||
@ -464,8 +464,9 @@ public:
|
||||
void Enable_Send_Button(bool en);
|
||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||
void update_user_machine_list();
|
||||
void update_ams_status_msg(wxString msg, bool is_error);
|
||||
void update_priner_status_msg(wxString msg, bool is_error);
|
||||
void update_ams_status_msg(vector<wxString> msg, bool is_error, bool is_single);
|
||||
void update_priner_status_msg(vector<wxString> msg, bool is_error, bool is_single);
|
||||
//void update_priner_status_msg(vector<wxString> msg);
|
||||
void update_printer_status_msg_tips(const wxString& msg_tips);
|
||||
void update_print_status_msg();
|
||||
void update_print_error_info(int code, std::string msg, std::string extra);
|
||||
|
Loading…
x
Reference in New Issue
Block a user