FIX:fix the logic of some sending pages
jira:[STUDIO-8890] Change-Id: I22a29d236365052d4fbe31e69aea72efaa6aa88a
This commit is contained in:
parent
b104e138dd
commit
60986488e7
|
@ -106,12 +106,12 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
|||
SetDoubleBuffered(true);
|
||||
#endif //__WINDOWS__
|
||||
|
||||
ops_auto.left.insert(make_pair("auto", "Auto"));
|
||||
ops_auto.left.insert(make_pair("on", "On"));
|
||||
ops_auto.left.insert(make_pair("off", "Off"));
|
||||
ops_auto.push_back(POItem{"auto", "Auto"});
|
||||
ops_auto.push_back(POItem{"on", "On"});
|
||||
ops_auto.push_back(POItem{"off", "Off"});
|
||||
|
||||
ops_no_auto.left.insert(make_pair("on", "On"));
|
||||
ops_no_auto.left.insert(make_pair("off", "Off"));
|
||||
ops_no_auto.push_back(POItem{"on", "On"});
|
||||
ops_no_auto.push_back(POItem{"off", "Off"});
|
||||
|
||||
SetMinSize(wxSize(FromDIP(700), -1));
|
||||
SetMaxSize(wxSize(FromDIP(700), -1));
|
||||
|
@ -137,24 +137,24 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
|||
|
||||
|
||||
/*mode switch*/
|
||||
auto m_sizer_mode_switch = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_mode_print = new SendModeSwitchButton(this, _L("Print"), true);
|
||||
m_mode_send = new SendModeSwitchButton(this,_L("Save to printer"), false);
|
||||
m_sizer_mode_switch->Add(m_mode_print, 0, wxALIGN_CENTER, 0);
|
||||
m_sizer_mode_switch->Add(0, 0, 0, wxLEFT, FromDIP(8));
|
||||
m_sizer_mode_switch->Add(m_mode_send,0, wxALIGN_CENTER, 0);
|
||||
/* auto m_sizer_mode_switch = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_mode_print = new SendModeSwitchButton(this, _L("Print"), true);
|
||||
m_mode_send = new SendModeSwitchButton(this,_L("Save to printer"), false);
|
||||
m_sizer_mode_switch->Add(m_mode_print, 0, wxALIGN_CENTER, 0);
|
||||
m_sizer_mode_switch->Add(0, 0, 0, wxLEFT, FromDIP(8));
|
||||
m_sizer_mode_switch->Add(m_mode_send,0, wxALIGN_CENTER, 0);*/
|
||||
|
||||
m_mode_print->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {
|
||||
m_mode_print->setSelected(true);
|
||||
m_mode_send->setSelected(false);
|
||||
e.Skip();
|
||||
});
|
||||
//m_mode_print->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {
|
||||
// m_mode_print->setSelected(true);
|
||||
// m_mode_send->setSelected(false);
|
||||
// e.Skip();
|
||||
//});
|
||||
|
||||
m_mode_send->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {
|
||||
m_mode_print->setSelected(false);
|
||||
m_mode_send->setSelected(true);
|
||||
e.Skip();
|
||||
});
|
||||
//m_mode_send->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {
|
||||
// m_mode_print->setSelected(false);
|
||||
// m_mode_send->setSelected(true);
|
||||
// e.Skip();
|
||||
//});
|
||||
|
||||
m_basic_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
m_basic_panel->SetBackgroundColour(*wxWHITE);
|
||||
|
@ -207,6 +207,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
|||
m_rename_button->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); });
|
||||
|
||||
rename_sizer_h->Add(m_rename_text, 0, wxALIGN_CENTER|wxTOP, FromDIP(2));
|
||||
rename_sizer_h->Add(0,0,0,wxLEFT,FromDIP(3));
|
||||
rename_sizer_h->Add(m_rename_button, 0, wxALIGN_CENTER, 0);
|
||||
rename_sizer_v->Add(rename_sizer_h, 1, wxTOP, 0);
|
||||
m_rename_normal_panel->SetSizer(rename_sizer_v);
|
||||
|
@ -353,7 +354,6 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
|||
m_text_bed_type = new Label(bed_staticbox);
|
||||
m_text_bed_type->SetForegroundColour(0xCECECE);
|
||||
m_text_bed_type->SetMaxSize(wxSize(FromDIP(80), FromDIP(24)));
|
||||
m_text_bed_type->SetFont(Label::Body_10);
|
||||
|
||||
sizer_bed_staticbox->Add(0, 0, 0, wxTOP, FromDIP(16));
|
||||
sizer_bed_staticbox->Add(m_bed_image, 0, wxALIGN_CENTER, 0);
|
||||
|
@ -767,7 +767,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
|||
|
||||
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
|
||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(11));
|
||||
m_sizer_main->Add(m_sizer_mode_switch, 0, wxALIGN_CENTER, 0);
|
||||
//m_sizer_main->Add(m_sizer_mode_switch, 0, wxALIGN_CENTER, 0);
|
||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(15));
|
||||
m_sizer_main->Add(m_basic_panel, 0, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(15));
|
||||
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(14));
|
||||
|
@ -921,13 +921,36 @@ void SelectMachineDialog::update_select_layout(MachineObject *obj)
|
|||
if (obj->is_enable_np) {
|
||||
m_checkbox_list["nozzle_offset_cali"]->Show();
|
||||
m_checkbox_list["nozzle_offset_cali"]->update_options(ops_auto);
|
||||
m_checkbox_list["nozzle_offset_cali"]->setValue("auto");
|
||||
m_checkbox_list["bed_leveling"]->update_options(ops_auto);
|
||||
m_checkbox_list["flow_cali"]->update_options(ops_auto);
|
||||
|
||||
m_checkbox_list["nozzle_offset_cali"]->setValue("auto");
|
||||
m_checkbox_list["bed_leveling"]->setValue("auto");
|
||||
m_checkbox_list["flow_cali"]->setValue("auto");
|
||||
}
|
||||
else {
|
||||
m_checkbox_list["bed_leveling"]->update_options(ops_no_auto);
|
||||
m_checkbox_list["flow_cali"]->update_options(ops_auto);
|
||||
|
||||
AppConfig *config = wxGetApp().app_config;
|
||||
if (config && config->get("print", "bed_leveling") == "0") {
|
||||
m_checkbox_list["bed_leveling"]->setValue("off");
|
||||
} else {
|
||||
m_checkbox_list["bed_leveling"]->setValue("on");
|
||||
}
|
||||
if (config && config->get("print", "flow_cali") == "0") {
|
||||
m_checkbox_list["flow_cali"]->setValue("off");
|
||||
} else {
|
||||
m_checkbox_list["flow_cali"]->setValue("on");
|
||||
}
|
||||
if (config && config->get("print", "timelapse") == "0") {
|
||||
m_checkbox_list["timelapse"]->setValue("off");
|
||||
} else {
|
||||
m_checkbox_list["timelapse"]->setValue("on");
|
||||
}
|
||||
|
||||
update_timelapse_enable_status();
|
||||
update_flow_cali_check(obj);
|
||||
}
|
||||
|
||||
if (obj && obj->is_support_auto_flow_calibration) {
|
||||
|
@ -937,30 +960,10 @@ void SelectMachineDialog::update_select_layout(MachineObject *obj)
|
|||
if (obj && obj->is_support_auto_leveling) {
|
||||
m_checkbox_list["bed_leveling"]->Show();
|
||||
}
|
||||
if (obj && obj->is_support_timelapse && is_show_timelapse()) {
|
||||
if (obj && obj->is_support_timelapse) {
|
||||
m_checkbox_list["timelapse"]->Show();
|
||||
update_timelapse_enable_status();
|
||||
}
|
||||
|
||||
// load checkbox values from app config
|
||||
AppConfig *config = wxGetApp().app_config;
|
||||
if (config && config->get("print", "bed_leveling") == "0") {
|
||||
m_checkbox_list["bed_leveling"]->setValue("off");
|
||||
} else {
|
||||
m_checkbox_list["bed_leveling"]->setValue("on");
|
||||
}
|
||||
if (config && config->get("print", "flow_cali") == "0") {
|
||||
m_checkbox_list["flow_cali"]->setValue("off");
|
||||
} else {
|
||||
m_checkbox_list["flow_cali"]->setValue("on");
|
||||
}
|
||||
if (config && config->get("print", "timelapse") == "0") {
|
||||
m_checkbox_list["timelapse"]->setValue("off");
|
||||
} else {
|
||||
m_checkbox_list["timelapse"]->setValue("on");
|
||||
}
|
||||
|
||||
update_flow_cali_check(obj);
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
|
@ -3232,50 +3235,6 @@ void SelectMachineDialog::update_timelapse_enable_status()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
bool SelectMachineDialog::is_show_timelapse()
|
||||
{
|
||||
auto compare_version = [](const std::string &version1, const std::string &version2) -> bool {
|
||||
int i = 0, j = 0;
|
||||
int max_size = std::max(version1.size(), version2.size());
|
||||
while (i < max_size || j < max_size) {
|
||||
int v1 = 0, v2 = 0;
|
||||
while (i < version1.size() && version1[i] != '.') v1 = 10 * v1 + (version1[i++] - '0');
|
||||
while (j < version2.size() && version2[j] != '.') v2 = 10 * v2 + (version2[j++] - '0');
|
||||
if (v1 > v2) return true;
|
||||
if (v1 < v2) return false;
|
||||
++i;
|
||||
++j;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
std::string standard_version = "01.04.00.00";
|
||||
PartPlate *plate = m_plater->get_partplate_list().get_curr_plate();
|
||||
fs::path gcode_path = plate->get_tmp_gcode_path();
|
||||
|
||||
std::string line;
|
||||
std::ifstream gcode_file;
|
||||
gcode_file.open(gcode_path.string());
|
||||
if (gcode_file.fail()) {
|
||||
} else {
|
||||
bool is_version = false;
|
||||
while (gcode_file >> line) {
|
||||
if (is_version) {
|
||||
if (compare_version(standard_version, line)) {
|
||||
gcode_file.close();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (line == "BambuStudio")
|
||||
is_version = true;
|
||||
}
|
||||
}
|
||||
gcode_file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SelectMachineDialog::reset_ams_material()
|
||||
{
|
||||
MaterialHash::iterator iter = m_materialList.begin();
|
||||
|
@ -4150,7 +4109,14 @@ bool SelectMachineDialog::Show(bool show)
|
|||
m_text_bed_type->Hide();
|
||||
}
|
||||
else {
|
||||
m_text_bed_type->SetLabelText(format_bed_name(plate_name));
|
||||
wxString name = format_bed_name(plate_name);
|
||||
if (name.length() > 8) {
|
||||
m_text_bed_type->SetFont(Label::Body_9);
|
||||
}
|
||||
else {
|
||||
m_text_bed_type->SetFont(Label::Body_12);
|
||||
}
|
||||
m_text_bed_type->SetLabelText(name);
|
||||
m_text_bed_type->Show();
|
||||
}
|
||||
|
||||
|
@ -4316,7 +4282,7 @@ std::string SelectMachineDialog::get_print_status_info(PrintDialogStatus status)
|
|||
|
||||
ThumbnailPanel::~ThumbnailPanel() {}
|
||||
|
||||
PrintOption::PrintOption(wxWindow *parent, wxString title, wxString tips, boost::bimaps::bimap<std::string, std::string> ops, std::string param)
|
||||
PrintOption::PrintOption(wxWindow *parent, wxString title, wxString tips, std::vector<POItem> ops, std::string param)
|
||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
|
@ -4422,7 +4388,7 @@ int PrintOption::getValueInt()
|
|||
}
|
||||
}
|
||||
|
||||
PrintOptionItem::PrintOptionItem(wxWindow *parent, boost::bimaps::bimap<std::string, std::string> ops, std::string param)
|
||||
PrintOptionItem::PrintOptionItem(wxWindow *parent, std::vector<POItem> ops, std::string param)
|
||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
|
@ -4478,12 +4444,12 @@ void PrintOptionItem::on_left_down(wxMouseEvent &evt)
|
|||
auto select_size = GetSize().x / m_ops.size();
|
||||
|
||||
int i = 0;
|
||||
for (const auto& entry : m_ops.left) {
|
||||
for (const auto& entry : m_ops) {
|
||||
auto left_edge = rect.x + i * select_size;
|
||||
auto right_edge = rect.x + (i + 1) * select_size;
|
||||
|
||||
if (pos.x > left_edge && pos.x < right_edge) {
|
||||
selected_key = entry.get_left();
|
||||
selected_key = entry.key;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
@ -4509,27 +4475,27 @@ void PrintOptionItem::doRender(wxDC &dc)
|
|||
auto left = FromDIP(4);
|
||||
|
||||
int selected = 0;
|
||||
for (const auto &entry : m_ops.right) {
|
||||
if (entry.second == selected_key) {
|
||||
for (const auto &entry : m_ops) {
|
||||
if (entry.key == selected_key) {
|
||||
break;
|
||||
}
|
||||
selected++;
|
||||
}
|
||||
|
||||
/*selected*/
|
||||
auto selected_left = selected * FromDIP(50) + FromDIP(4);
|
||||
auto selected_left = selected * FromDIP(56) + FromDIP(4);
|
||||
dc.DrawBitmap(m_selected_bk.bmp(), selected_left, FromDIP(4));
|
||||
|
||||
for (auto it = m_ops.begin(); it != m_ops.end(); ++it) {
|
||||
auto text_key = it->get_left();
|
||||
auto text_value = it->get_right();
|
||||
auto text_key = it->key;
|
||||
auto text_value = it->value;
|
||||
|
||||
if (text_key == selected_key) {
|
||||
dc.SetPen(wxPen(0x00AE42));
|
||||
dc.SetTextForeground(0x00AE42);
|
||||
dc.SetFont(::Label::Head_13);
|
||||
auto text_size = dc.GetTextExtent(text_value);
|
||||
auto text_left = left + (FromDIP(50) - text_size.x) / 2;
|
||||
auto text_left = left + (FromDIP(56) - text_size.x) / 2;
|
||||
auto text_top = (size.y - text_size.y) / 2;
|
||||
dc.DrawText(text_value, wxPoint(text_left, text_top));
|
||||
}
|
||||
|
@ -4538,12 +4504,12 @@ void PrintOptionItem::doRender(wxDC &dc)
|
|||
dc.SetTextForeground(*wxBLACK);
|
||||
dc.SetFont(::Label::Body_13);
|
||||
auto text_size = dc.GetTextExtent(text_value);
|
||||
auto text_left = left + (FromDIP(50) - text_size.x) / 2;
|
||||
auto text_left = left + (FromDIP(56) - text_size.x) / 2;
|
||||
auto text_top = (size.y - text_size.y) / 2;
|
||||
dc.DrawText(text_value, wxPoint(text_left, text_top));
|
||||
}
|
||||
|
||||
left += FromDIP(50);
|
||||
left += FromDIP(56);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -133,10 +133,16 @@ static int get_brightness_value(wxImage image) {
|
|||
return totalLuminance / num_none_transparent;
|
||||
}
|
||||
|
||||
struct POItem
|
||||
{
|
||||
std::string key;
|
||||
wxString value;
|
||||
};
|
||||
|
||||
class PrintOptionItem : public wxPanel
|
||||
{
|
||||
public:
|
||||
PrintOptionItem(wxWindow *parent, boost::bimaps::bimap<std::string, std::string> ops, std::string param = "");
|
||||
PrintOptionItem(wxWindow *parent, std::vector<POItem> ops, std::string param = "");
|
||||
~PrintOptionItem(){};
|
||||
void OnPaint(wxPaintEvent &event);
|
||||
void render(wxDC &dc);
|
||||
|
@ -144,12 +150,12 @@ public:
|
|||
void doRender(wxDC &dc);
|
||||
|
||||
ScalableBitmap m_selected_bk;
|
||||
boost::bimaps::bimap<std::string, std::string> m_ops;
|
||||
std::vector<POItem> m_ops;
|
||||
std::string selected_key;
|
||||
std::string m_param;
|
||||
|
||||
void setValue(std::string value);
|
||||
void update_options(boost::bimaps::bimap<std::string, std::string> ops){
|
||||
void update_options(std::vector<POItem> ops){
|
||||
m_ops = ops;
|
||||
selected_key = "";
|
||||
auto width = ops.size() * FromDIP(56) + FromDIP(8);
|
||||
|
@ -164,19 +170,19 @@ public:
|
|||
class PrintOption : public wxPanel
|
||||
{
|
||||
public:
|
||||
PrintOption(wxWindow *parent, wxString title, wxString tips, boost::bimaps::bimap<std::string, std::string> ops, std::string param = "");
|
||||
PrintOption(wxWindow *parent, wxString title, wxString tips, std::vector<POItem> ops, std::string param = "");
|
||||
~PrintOption(){};
|
||||
void OnPaint(wxPaintEvent &event);
|
||||
void render(wxDC &dc);
|
||||
void doRender(wxDC &dc);
|
||||
|
||||
std::string m_param;
|
||||
boost::bimaps::bimap<std::string, std::string> m_ops;
|
||||
std::vector<POItem> m_ops;
|
||||
Label* m_label{nullptr};
|
||||
Label* m_printoption_title{nullptr};
|
||||
PrintOptionItem* m_printoption_item{nullptr};
|
||||
void setValue(std::string value);
|
||||
void update_options(boost::bimaps::bimap<std::string, std::string> ops){
|
||||
void update_options(std::vector<POItem> ops){
|
||||
m_ops = ops;
|
||||
m_printoption_item->update_options(ops);
|
||||
};
|
||||
|
@ -260,8 +266,8 @@ private:
|
|||
std::vector<int> m_filaments_map;
|
||||
std::shared_ptr<BBLStatusBarSend> m_status_bar;
|
||||
|
||||
SendModeSwitchButton* m_mode_print {nullptr};
|
||||
SendModeSwitchButton* m_mode_send {nullptr};
|
||||
//SendModeSwitchButton* m_mode_print {nullptr};
|
||||
//SendModeSwitchButton* m_mode_send {nullptr};
|
||||
wxStaticBitmap* m_printer_image{nullptr};
|
||||
wxStaticBitmap* m_bed_image{nullptr};
|
||||
|
||||
|
@ -271,8 +277,8 @@ private:
|
|||
std::string m_required_data_file_name;
|
||||
std::string m_required_data_file_path;
|
||||
|
||||
boost::bimaps::bimap<std::string, std::string> ops_auto;
|
||||
boost::bimaps::bimap<std::string, std::string> ops_no_auto;
|
||||
std::vector<POItem> ops_auto;
|
||||
std::vector<POItem> ops_no_auto;
|
||||
|
||||
protected:
|
||||
PrintFromType m_print_type{FROM_NORMAL};
|
||||
|
@ -420,7 +426,6 @@ public:
|
|||
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 is_show_timelapse();
|
||||
bool has_timelapse_warning();
|
||||
void update_timelapse_enable_status();
|
||||
bool is_same_printer_model();
|
||||
|
|
Loading…
Reference in New Issue