ENH:optimized printer selection
STUDIO-3380 STUDIO-3532 Change-Id: Id145022072de9c9a0969bdefb4c98e01078b079c
This commit is contained in:
parent
bd4f3bec73
commit
b2a2636785
|
@ -108,42 +108,7 @@ wxString get_fail_reason(int code)
|
||||||
wxBoxSizer *m_sizer_right_h = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer *m_sizer_right_h = new wxBoxSizer(wxHORIZONTAL);
|
||||||
wxBoxSizer *m_sizer_right_v = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *m_sizer_right_v = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
|
m_avatar = new wxStaticBitmap(m_panel_right, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(FromDIP(60), FromDIP(60)), 0);
|
||||||
Bind(wxEVT_WEBREQUEST_STATE, [this](wxWebRequestEvent& evt) {
|
|
||||||
switch (evt.GetState()) {
|
|
||||||
// Request completed
|
|
||||||
case wxWebRequest::State_Completed: {
|
|
||||||
wxImage avatar_stream = *evt.GetResponse().GetStream();
|
|
||||||
if (avatar_stream.IsOk()) {
|
|
||||||
avatar_stream.Rescale(FromDIP(60), FromDIP(60));
|
|
||||||
auto bitmap = new wxBitmap(avatar_stream);
|
|
||||||
//bitmap->SetSize(wxSize(FromDIP(60), FromDIP(60)));
|
|
||||||
m_avatar->SetBitmap(*bitmap);
|
|
||||||
Layout();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Request failed
|
|
||||||
case wxWebRequest::State_Failed: {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (wxGetApp().is_user_login()) {
|
|
||||||
wxString username_text = from_u8(wxGetApp().getAgent()->get_user_nickanme());
|
|
||||||
m_user_name->SetLabelText(username_text);
|
|
||||||
|
|
||||||
m_avatar = new wxStaticBitmap(m_panel_right, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(FromDIP(60), FromDIP(60)), 0);
|
|
||||||
|
|
||||||
web_request = wxWebSession::GetDefault().CreateRequest(this, wxGetApp().getAgent()->get_user_avatar());
|
|
||||||
if (!web_request.IsOk()) {
|
|
||||||
// todo request fail
|
|
||||||
}
|
|
||||||
// Start the request
|
|
||||||
web_request.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_sizer_right_v->Add(m_avatar, 0, wxALIGN_CENTER, 0);
|
m_sizer_right_v->Add(m_avatar, 0, wxALIGN_CENTER, 0);
|
||||||
m_sizer_right_v->Add(0, 0, 0, wxTOP, 7);
|
m_sizer_right_v->Add(0, 0, 0, wxTOP, 7);
|
||||||
m_sizer_right_v->Add(m_user_name, 0, wxALIGN_CENTER, 0);
|
m_sizer_right_v->Add(m_user_name, 0, wxALIGN_CENTER, 0);
|
||||||
|
@ -467,8 +432,27 @@ wxString get_fail_reason(int code)
|
||||||
Centre(wxBOTH);
|
Centre(wxBOTH);
|
||||||
|
|
||||||
Bind(wxEVT_SHOW, &BindMachineDialog::on_show, this);
|
Bind(wxEVT_SHOW, &BindMachineDialog::on_show, this);
|
||||||
|
|
||||||
Bind(wxEVT_CLOSE_WINDOW, &BindMachineDialog::on_close, this);
|
Bind(wxEVT_CLOSE_WINDOW, &BindMachineDialog::on_close, this);
|
||||||
|
Bind(wxEVT_WEBREQUEST_STATE, [this](wxWebRequestEvent& evt) {
|
||||||
|
switch (evt.GetState()) {
|
||||||
|
// Request completed
|
||||||
|
case wxWebRequest::State_Completed: {
|
||||||
|
wxImage avatar_stream = *evt.GetResponse().GetStream();
|
||||||
|
if (avatar_stream.IsOk()) {
|
||||||
|
avatar_stream.Rescale(FromDIP(60), FromDIP(60));
|
||||||
|
auto bitmap = new wxBitmap(avatar_stream);
|
||||||
|
//bitmap->SetSize(wxSize(FromDIP(60), FromDIP(60)));
|
||||||
|
m_avatar->SetBitmap(*bitmap);
|
||||||
|
Layout();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Request failed
|
||||||
|
case wxWebRequest::State_Failed: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
m_button_bind->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BindMachineDialog::on_bind_printer), NULL, this);
|
m_button_bind->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BindMachineDialog::on_bind_printer), NULL, this);
|
||||||
m_button_cancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BindMachineDialog::on_cancel), NULL, this);
|
m_button_cancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BindMachineDialog::on_cancel), NULL, this);
|
||||||
|
@ -661,6 +645,18 @@ void BindMachineDialog::on_show(wxShowEvent &event)
|
||||||
m_printer_img->Show();
|
m_printer_img->Show();
|
||||||
|
|
||||||
m_printer_name->SetLabelText(from_u8(m_machine_info->dev_name));
|
m_printer_name->SetLabelText(from_u8(m_machine_info->dev_name));
|
||||||
|
|
||||||
|
if (wxGetApp().is_user_login()) {
|
||||||
|
wxString username_text = from_u8(wxGetApp().getAgent()->get_user_nickanme());
|
||||||
|
m_user_name->SetLabelText(username_text);
|
||||||
|
web_request = wxWebSession::GetDefault().CreateRequest(this, wxGetApp().getAgent()->get_user_avatar());
|
||||||
|
if (!web_request.IsOk()) {
|
||||||
|
// todo request fail
|
||||||
|
}
|
||||||
|
// Start the request
|
||||||
|
web_request.Start();
|
||||||
|
}
|
||||||
|
|
||||||
Layout();
|
Layout();
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
@ -720,42 +716,6 @@ UnBindMachineDialog::UnBindMachineDialog(Plater *plater /*= nullptr*/)
|
||||||
wxBoxSizer *m_sizer_right_v = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *m_sizer_right_v = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
m_avatar = new wxStaticBitmap(m_panel_right, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(FromDIP(60), FromDIP(60)), 0);
|
m_avatar = new wxStaticBitmap(m_panel_right, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(FromDIP(60), FromDIP(60)), 0);
|
||||||
|
|
||||||
if (wxGetApp().is_user_login()) {
|
|
||||||
wxString username_text = from_u8(wxGetApp().getAgent()->get_user_name());
|
|
||||||
m_user_name->SetLabelText(username_text);
|
|
||||||
wxString avatar_url = wxGetApp().getAgent()->get_user_avatar();
|
|
||||||
wxWebRequest request = wxWebSession::GetDefault().CreateRequest(this, avatar_url);
|
|
||||||
if (!request.IsOk()) {
|
|
||||||
// todo request fail
|
|
||||||
}
|
|
||||||
request.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Bind(wxEVT_WEBREQUEST_STATE, [this](wxWebRequestEvent &evt) {
|
|
||||||
switch (evt.GetState()) {
|
|
||||||
// Request completed
|
|
||||||
case wxWebRequest::State_Completed: {
|
|
||||||
wxImage avatar_stream = *evt.GetResponse().GetStream();
|
|
||||||
if (avatar_stream.IsOk()) {
|
|
||||||
avatar_stream.Rescale(FromDIP(60), FromDIP(60));
|
|
||||||
auto bitmap = new wxBitmap(avatar_stream);
|
|
||||||
//bitmap->SetSize(wxSize(FromDIP(60), FromDIP(60)));
|
|
||||||
m_avatar->SetBitmap(*bitmap);
|
|
||||||
Layout();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Request failed
|
|
||||||
case wxWebRequest::State_Failed: {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_sizer_right_v->Add(m_avatar, 0, wxALIGN_CENTER, 0);
|
m_sizer_right_v->Add(m_avatar, 0, wxALIGN_CENTER, 0);
|
||||||
m_sizer_right_v->Add(0, 0, 0, wxTOP, 7);
|
m_sizer_right_v->Add(0, 0, 0, wxTOP, 7);
|
||||||
m_sizer_right_v->Add(m_user_name, 0, wxALIGN_CENTER, 0);
|
m_sizer_right_v->Add(m_user_name, 0, wxALIGN_CENTER, 0);
|
||||||
|
@ -817,6 +777,28 @@ UnBindMachineDialog::UnBindMachineDialog(Plater *plater /*= nullptr*/)
|
||||||
Bind(wxEVT_SHOW, &UnBindMachineDialog::on_show, this);
|
Bind(wxEVT_SHOW, &UnBindMachineDialog::on_show, this);
|
||||||
m_button_unbind->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(UnBindMachineDialog::on_unbind_printer), NULL, this);
|
m_button_unbind->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(UnBindMachineDialog::on_unbind_printer), NULL, this);
|
||||||
m_button_cancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(UnBindMachineDialog::on_cancel), NULL, this);
|
m_button_cancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(UnBindMachineDialog::on_cancel), NULL, this);
|
||||||
|
|
||||||
|
Bind(wxEVT_WEBREQUEST_STATE, [this](wxWebRequestEvent& evt) {
|
||||||
|
switch (evt.GetState()) {
|
||||||
|
// Request completed
|
||||||
|
case wxWebRequest::State_Completed: {
|
||||||
|
wxImage avatar_stream = *evt.GetResponse().GetStream();
|
||||||
|
if (avatar_stream.IsOk()) {
|
||||||
|
avatar_stream.Rescale(FromDIP(60), FromDIP(60));
|
||||||
|
auto bitmap = new wxBitmap(avatar_stream);
|
||||||
|
//bitmap->SetSize(wxSize(FromDIP(60), FromDIP(60)));
|
||||||
|
m_avatar->SetBitmap(*bitmap);
|
||||||
|
Layout();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Request failed
|
||||||
|
case wxWebRequest::State_Failed: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
wxGetApp().UpdateDlgDarkUI(this);
|
wxGetApp().UpdateDlgDarkUI(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,6 +867,19 @@ void UnBindMachineDialog::on_show(wxShowEvent &event)
|
||||||
m_printer_img->Show();
|
m_printer_img->Show();
|
||||||
|
|
||||||
m_printer_name->SetLabelText(from_u8(m_machine_info->dev_name));
|
m_printer_name->SetLabelText(from_u8(m_machine_info->dev_name));
|
||||||
|
|
||||||
|
|
||||||
|
if (wxGetApp().is_user_login()) {
|
||||||
|
wxString username_text = from_u8(wxGetApp().getAgent()->get_user_name());
|
||||||
|
m_user_name->SetLabelText(username_text);
|
||||||
|
wxString avatar_url = wxGetApp().getAgent()->get_user_avatar();
|
||||||
|
wxWebRequest request = wxWebSession::GetDefault().CreateRequest(this, avatar_url);
|
||||||
|
if (!request.IsOk()) {
|
||||||
|
// todo request fail
|
||||||
|
}
|
||||||
|
request.Start();
|
||||||
|
}
|
||||||
|
|
||||||
Layout();
|
Layout();
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1477,6 +1477,7 @@ int MachineObject::command_request_push_all(bool request_now)
|
||||||
{
|
{
|
||||||
auto curr_time = std::chrono::system_clock::now();
|
auto curr_time = std::chrono::system_clock::now();
|
||||||
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(curr_time - last_request_push);
|
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(curr_time - last_request_push);
|
||||||
|
|
||||||
if (diff.count() < REQUEST_PUSH_MIN_TIME) {
|
if (diff.count() < REQUEST_PUSH_MIN_TIME) {
|
||||||
if (request_now) {
|
if (request_now) {
|
||||||
BOOST_LOG_TRIVIAL(trace) << "static: command_request_push_all, dev_id=" << dev_id;
|
BOOST_LOG_TRIVIAL(trace) << "static: command_request_push_all, dev_id=" << dev_id;
|
||||||
|
@ -1490,6 +1491,7 @@ int MachineObject::command_request_push_all(bool request_now)
|
||||||
BOOST_LOG_TRIVIAL(trace) << "static: command_request_push_all, dev_id=" << dev_id;
|
BOOST_LOG_TRIVIAL(trace) << "static: command_request_push_all, dev_id=" << dev_id;
|
||||||
last_request_push = std::chrono::system_clock::now();
|
last_request_push = std::chrono::system_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
json j;
|
json j;
|
||||||
j["pushing"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
j["pushing"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||||
j["pushing"]["command"] = "pushall";
|
j["pushing"]["command"] = "pushall";
|
||||||
|
|
|
@ -1873,7 +1873,7 @@ void GUI_App::init_networking_callbacks()
|
||||||
MachineObject* obj = m_device_manager->get_my_machine(tunnel ? dev_id.substr(7) : dev_id);
|
MachineObject* obj = m_device_manager->get_my_machine(tunnel ? dev_id.substr(7) : dev_id);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
obj->is_tunnel_mqtt = tunnel;
|
obj->is_tunnel_mqtt = tunnel;
|
||||||
obj->command_request_push_all();
|
obj->command_request_push_all(true);
|
||||||
obj->command_get_version();
|
obj->command_get_version();
|
||||||
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj);
|
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj);
|
||||||
}
|
}
|
||||||
|
@ -1904,7 +1904,7 @@ void GUI_App::init_networking_callbacks()
|
||||||
|
|
||||||
if (obj->is_lan_mode_printer()) {
|
if (obj->is_lan_mode_printer()) {
|
||||||
if (state == ConnectStatus::ConnectStatusOk) {
|
if (state == ConnectStatus::ConnectStatusOk) {
|
||||||
obj->command_request_push_all();
|
obj->command_request_push_all(true);
|
||||||
obj->command_get_version();
|
obj->command_get_version();
|
||||||
event.SetInt(0);
|
event.SetInt(0);
|
||||||
event.SetString(obj->dev_id);
|
event.SetString(obj->dev_id);
|
||||||
|
|
|
@ -1408,14 +1408,6 @@ void StatusPanel::init_scaled_buttons()
|
||||||
m_bpButton_e_down_10->SetCornerRadius(FromDIP(12));
|
m_bpButton_e_down_10->SetCornerRadius(FromDIP(12));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusPanel::clean_tasklist_info()
|
|
||||||
{
|
|
||||||
m_tasklist_info_sizer = new wxGridBagSizer(4, 8);
|
|
||||||
for (int i = 0; i < slice_info_list.size(); i++) { delete slice_info_list[i]; }
|
|
||||||
slice_info_list.clear();
|
|
||||||
show_task_list_info(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatusPanel::create_tasklist_info()
|
void StatusPanel::create_tasklist_info()
|
||||||
{
|
{
|
||||||
m_tasklist_caption_sizer = new wxBoxSizer(wxHORIZONTAL);
|
m_tasklist_caption_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
@ -1449,8 +1441,6 @@ void StatusPanel::show_task_list_info(bool show)
|
||||||
|
|
||||||
void StatusPanel::update_tasklist_info()
|
void StatusPanel::update_tasklist_info()
|
||||||
{
|
{
|
||||||
clean_tasklist_info();
|
|
||||||
|
|
||||||
// BBS do not show tasklist
|
// BBS do not show tasklist
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3552,7 +3542,6 @@ void StatusPanel::set_default()
|
||||||
m_ams_control->Hide();
|
m_ams_control->Hide();
|
||||||
m_ams_control_box->Hide();
|
m_ams_control_box->Hide();
|
||||||
m_ams_control->Reset();
|
m_ams_control->Reset();
|
||||||
clean_tasklist_info();
|
|
||||||
error_info_reset();
|
error_info_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3679,12 +3668,6 @@ void StatusPanel::msw_rescale()
|
||||||
init_scaled_buttons();
|
init_scaled_buttons();
|
||||||
|
|
||||||
m_gauge_progress->Rescale();
|
m_gauge_progress->Rescale();
|
||||||
|
|
||||||
for (int i = 0; i < slice_info_list.size(); i++) {
|
|
||||||
slice_info_list[i]->SetImages(m_bitmap_item_prediction, m_bitmap_item_cost, m_bitmap_item_print);
|
|
||||||
slice_info_list[i]->msw_rescale();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bpButton_xy->Rescale();
|
m_bpButton_xy->Rescale();
|
||||||
m_tempCtrl_nozzle->SetMinSize(TEMP_CTRL_MIN_SIZE);
|
m_tempCtrl_nozzle->SetMinSize(TEMP_CTRL_MIN_SIZE);
|
||||||
m_tempCtrl_nozzle->Rescale();
|
m_tempCtrl_nozzle->Rescale();
|
||||||
|
|
|
@ -268,7 +268,6 @@ protected:
|
||||||
std::shared_ptr<SliceInfoPopup> m_slice_info_popup;
|
std::shared_ptr<SliceInfoPopup> m_slice_info_popup;
|
||||||
std::shared_ptr<ImageTransientPopup> m_image_popup;
|
std::shared_ptr<ImageTransientPopup> m_image_popup;
|
||||||
std::shared_ptr<CameraPopup> m_camera_popup;
|
std::shared_ptr<CameraPopup> m_camera_popup;
|
||||||
std::vector<SliceInfoPanel *> slice_info_list;
|
|
||||||
std::set<int> rated_model_id;
|
std::set<int> rated_model_id;
|
||||||
AMSSetting *m_ams_setting_dlg{nullptr};
|
AMSSetting *m_ams_setting_dlg{nullptr};
|
||||||
PrintOptionsDialog* print_options_dlg { nullptr };
|
PrintOptionsDialog* print_options_dlg { nullptr };
|
||||||
|
@ -311,7 +310,6 @@ protected:
|
||||||
void init_scaled_buttons();
|
void init_scaled_buttons();
|
||||||
void update_error_message();
|
void update_error_message();
|
||||||
void create_tasklist_info();
|
void create_tasklist_info();
|
||||||
void clean_tasklist_info();
|
|
||||||
void show_task_list_info(bool show = true);
|
void show_task_list_info(bool show = true);
|
||||||
void update_tasklist_info();
|
void update_tasklist_info();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue