NEW:add multiple printer restrictions
jira:[for multiple] Change-Id: I0bb5a0c1062a543c42f8d67a9347efa358b0864a
This commit is contained in:
parent
16babb681f
commit
7bf39fbbf1
|
@ -11,6 +11,7 @@ namespace GUI {
|
|||
wxDEFINE_EVENT(EVT_MULTI_CLOUD_TASK_SELECTED, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_MULTI_LOCAL_TASK_SELECTED, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_MULTI_DEVICE_SELECTED, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_MULTI_DEVICE_SELECTED_FINHSH, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_MULTI_DEVICE_VIEW, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_MULTI_REFRESH, wxCommandEvent);
|
||||
|
||||
|
|
|
@ -109,6 +109,7 @@ struct SortItem
|
|||
|
||||
|
||||
wxDECLARE_EVENT(EVT_MULTI_DEVICE_SELECTED, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_MULTI_DEVICE_SELECTED_FINHSH, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_MULTI_DEVICE_VIEW, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_MULTI_CLOUD_TASK_SELECTED, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_MULTI_LOCAL_TASK_SELECTED, wxCommandEvent);
|
||||
|
|
|
@ -279,6 +279,35 @@ MultiMachineManagerPage::MultiMachineManagerPage(wxWindow* parent)
|
|||
std::pair<wxColour, int>(TABLE_HEAR_NORMAL_COLOUR, StateColor::Normal)
|
||||
);
|
||||
|
||||
//edit prints
|
||||
StateColor clean_bg(std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Disabled), std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed),
|
||||
std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered), std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Enabled),
|
||||
std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Normal));
|
||||
StateColor clean_bd(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
|
||||
StateColor clean_text(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
|
||||
|
||||
|
||||
auto sizer_button_printer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer_button_printer->SetMinSize(wxSize(FromDIP(DEVICE_ITEM_MAX_WIDTH), -1));
|
||||
m_button_edit = new Button(m_main_panel, _L("Edit Printers"));
|
||||
m_button_edit->SetBackgroundColor(clean_bg);
|
||||
m_button_edit->SetBorderColor(clean_bd);
|
||||
m_button_edit->SetTextColor(clean_text);
|
||||
m_button_edit->SetFont(Label::Body_12);
|
||||
m_button_edit->SetCornerRadius(6);
|
||||
m_button_edit->SetMinSize(wxSize(FromDIP(90), FromDIP(40)));
|
||||
m_button_edit->SetMaxSize(wxSize(FromDIP(90), FromDIP(40)));
|
||||
|
||||
m_button_edit->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
|
||||
MultiMachinePickPage dlg;
|
||||
dlg.ShowModal();
|
||||
refresh_user_device();
|
||||
evt.Skip();
|
||||
});
|
||||
|
||||
sizer_button_printer->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
sizer_button_printer->Add(m_button_edit, 0, wxALIGN_CENTER, 0);
|
||||
|
||||
m_table_head_panel = new wxPanel(m_main_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
||||
m_table_head_panel->SetMinSize(wxSize(FromDIP(DEVICE_ITEM_MAX_WIDTH), -1));
|
||||
m_table_head_panel->SetMaxSize(wxSize(FromDIP(DEVICE_ITEM_MAX_WIDTH), -1));
|
||||
|
@ -456,6 +485,7 @@ MultiMachineManagerPage::MultiMachineManagerPage(wxWindow* parent)
|
|||
m_flipping_panel->Layout();
|
||||
|
||||
m_main_sizer->AddSpacer(FromDIP(50));
|
||||
m_main_sizer->Add(sizer_button_printer, 0, wxALIGN_CENTER_HORIZONTAL, 0);
|
||||
m_main_sizer->Add(m_table_head_panel, 0, wxALIGN_CENTER_HORIZONTAL, 0);
|
||||
m_main_sizer->Add(m_tip_text, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, FromDIP(50));
|
||||
m_main_sizer->Add(m_machine_list, 0, wxALIGN_CENTER_HORIZONTAL, 0);
|
||||
|
@ -490,7 +520,19 @@ void MultiMachineManagerPage::refresh_user_device(bool clear)
|
|||
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) return;
|
||||
|
||||
auto user_machine = dev->get_my_cloud_machine_list();
|
||||
auto all_machine = dev->get_my_cloud_machine_list();
|
||||
auto user_machine = std::map<std::string, MachineObject*>();
|
||||
|
||||
//selected machine
|
||||
for (int i = 0; i < PICK_DEVICE_MAX; i++) {
|
||||
auto dev_id = wxGetApp().app_config->get("multi_devices", std::to_string(i));
|
||||
|
||||
if (all_machine.count(dev_id) > 0) {
|
||||
user_machine[dev_id] = all_machine[dev_id];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_total_count = user_machine.size();
|
||||
|
||||
m_state_objs.clear();
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace GUI {
|
|||
#define DEVICE_LEFT_PADDING_LEFT 15
|
||||
#define DEVICE_LEFT_DEV_NAME 180
|
||||
#define DEVICE_LEFT_PRO_NAME 180
|
||||
#define DEVICE_LEFT_PRO_INFO 280
|
||||
#define DEVICE_LEFT_PRO_INFO 320
|
||||
|
||||
class MultiMachineItem : public DeviceItem
|
||||
{
|
||||
|
@ -67,6 +67,8 @@ private:
|
|||
bool device_dev_name_big{ true };
|
||||
bool device_state_big{ true };
|
||||
|
||||
|
||||
Button* m_button_edit{nullptr};
|
||||
wxBoxSizer* page_sizer{ nullptr };
|
||||
wxPanel* m_main_panel{ nullptr };
|
||||
wxBoxSizer* m_main_sizer{nullptr};
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#include "MultiMachinePage.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
@ -76,7 +78,6 @@ void MultiMachinePage::init_tabpanel()
|
|||
m_tabpanel->AddPage(m_cloud_task_manager, _L("Task Sent"), "", false);
|
||||
}
|
||||
|
||||
|
||||
void MultiMachinePage::init_timer()
|
||||
{
|
||||
m_refresh_timer = new wxTimer();
|
||||
|
@ -99,5 +100,385 @@ void MultiMachinePage::clear_page()
|
|||
m_machine_manager->refresh_user_device(true);
|
||||
}
|
||||
|
||||
DevicePickItem::DevicePickItem(wxWindow* parent, MachineObject* obj)
|
||||
: DeviceItem(parent, obj)
|
||||
{
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
m_bitmap_check_disable = ScalableBitmap(this, "check_off_disabled", 18);
|
||||
m_bitmap_check_off = ScalableBitmap(this, "check_off_focused", 18);
|
||||
m_bitmap_check_on = ScalableBitmap(this, "check_on", 18);
|
||||
|
||||
|
||||
SetMinSize(wxSize(FromDIP(400), FromDIP(30)));
|
||||
SetMaxSize(wxSize(FromDIP(400), FromDIP(30)));
|
||||
|
||||
Bind(wxEVT_PAINT, &DevicePickItem::paintEvent, this);
|
||||
Bind(wxEVT_ENTER_WINDOW, &DevicePickItem::OnEnterWindow, this);
|
||||
Bind(wxEVT_LEAVE_WINDOW, &DevicePickItem::OnLeaveWindow, this);
|
||||
Bind(wxEVT_LEFT_DOWN, &DevicePickItem::OnLeftDown, this);
|
||||
Bind(wxEVT_MOTION, &DevicePickItem::OnMove, this);
|
||||
Bind(EVT_MULTI_DEVICE_SELECTED, &DevicePickItem::OnSelectedDevice, this);
|
||||
wxGetApp().UpdateDarkUIWin(this);
|
||||
}
|
||||
|
||||
void DevicePickItem::DrawTextWithEllipsis(wxDC& dc, const wxString& text, int maxWidth, int left, int top /*= 0*/)
|
||||
{
|
||||
wxSize size = GetSize();
|
||||
wxFont font = dc.GetFont();
|
||||
|
||||
wxSize textSize = dc.GetTextExtent(text);
|
||||
dc.SetTextForeground(StateColor::darkModeColorFor(wxColour(50, 58, 61)));
|
||||
int textWidth = textSize.GetWidth();
|
||||
|
||||
if (textWidth > maxWidth) {
|
||||
wxString truncatedText = text;
|
||||
int ellipsisWidth = dc.GetTextExtent("...").GetWidth();
|
||||
int numChars = text.length();
|
||||
|
||||
for (int i = numChars - 1; i >= 0; --i) {
|
||||
truncatedText = text.substr(0, i) + "...";
|
||||
int truncatedWidth = dc.GetTextExtent(truncatedText).GetWidth();
|
||||
|
||||
if (truncatedWidth <= maxWidth - ellipsisWidth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (top == 0) {
|
||||
dc.DrawText(truncatedText, left, (size.y - textSize.y) / 2);
|
||||
}
|
||||
else {
|
||||
dc.DrawText(truncatedText, left, (size.y - textSize.y) / 2 - top);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
if (top == 0) {
|
||||
dc.DrawText(text, left, (size.y - textSize.y) / 2);
|
||||
}
|
||||
else {
|
||||
dc.DrawText(text, left, (size.y - textSize.y) / 2 - top);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DevicePickItem::OnEnterWindow(wxMouseEvent& evt)
|
||||
{
|
||||
m_hover = true;
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
void DevicePickItem::OnLeaveWindow(wxMouseEvent& evt)
|
||||
{
|
||||
m_hover = false;
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
void DevicePickItem::OnSelectedDevice(wxCommandEvent& evt)
|
||||
{
|
||||
auto dev_id = evt.GetString();
|
||||
auto state = evt.GetInt();
|
||||
if (state == 0) {
|
||||
state_selected = 1;
|
||||
}
|
||||
else if (state == 1) {
|
||||
state_selected = 0;
|
||||
}
|
||||
Refresh(false);
|
||||
evt.Skip();
|
||||
|
||||
post_event(wxCommandEvent(EVT_MULTI_DEVICE_SELECTED_FINHSH));
|
||||
}
|
||||
|
||||
void DevicePickItem::OnLeftDown(wxMouseEvent& evt)
|
||||
{
|
||||
int left = FromDIP(15);
|
||||
auto mouse_pos = ClientToScreen(evt.GetPosition());
|
||||
auto item = this->ClientToScreen(wxPoint(0, 0));
|
||||
|
||||
if (mouse_pos.x > (item.x + left) &&
|
||||
mouse_pos.x < (item.x + left + m_bitmap_check_disable.GetBmpWidth()) &&
|
||||
mouse_pos.y > item.y &&
|
||||
mouse_pos.y < (item.y + DEVICE_ITEM_MAX_HEIGHT)) {
|
||||
|
||||
post_event(wxCommandEvent(EVT_MULTI_DEVICE_SELECTED));
|
||||
}
|
||||
}
|
||||
|
||||
void DevicePickItem::OnMove(wxMouseEvent& evt)
|
||||
{
|
||||
int left = FromDIP(15);
|
||||
auto mouse_pos = ClientToScreen(evt.GetPosition());
|
||||
auto item = this->ClientToScreen(wxPoint(0, 0));
|
||||
|
||||
if (mouse_pos.x > (item.x + left) &&
|
||||
mouse_pos.x < (item.x + left + m_bitmap_check_disable.GetBmpWidth()) &&
|
||||
mouse_pos.y > item.y &&
|
||||
mouse_pos.y < (item.y + DEVICE_ITEM_MAX_HEIGHT)) {
|
||||
SetCursor(wxCURSOR_HAND);
|
||||
}
|
||||
else {
|
||||
SetCursor(wxCURSOR_ARROW);
|
||||
}
|
||||
}
|
||||
|
||||
void DevicePickItem::paintEvent(wxPaintEvent& evt)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
render(dc);
|
||||
}
|
||||
|
||||
void DevicePickItem::render(wxDC& dc)
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
wxSize size = GetSize();
|
||||
wxMemoryDC memdc;
|
||||
wxBitmap bmp(size.x, size.y);
|
||||
memdc.SelectObject(bmp);
|
||||
memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 });
|
||||
|
||||
{
|
||||
wxGCDC dc2(memdc);
|
||||
doRender(dc2);
|
||||
}
|
||||
|
||||
memdc.SelectObject(wxNullBitmap);
|
||||
dc.DrawBitmap(bmp, 0, 0);
|
||||
#else
|
||||
doRender(dc);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DevicePickItem::doRender(wxDC& dc)
|
||||
{
|
||||
wxSize size = GetSize();
|
||||
dc.SetPen(wxPen(*wxBLACK));
|
||||
|
||||
int left = FromDIP(PICK_LEFT_PADDING_LEFT);
|
||||
|
||||
|
||||
//checkbox
|
||||
if (state_selected == 0) {
|
||||
dc.DrawBitmap(m_bitmap_check_off.bmp(), wxPoint(left, (size.y - m_bitmap_check_disable.GetBmpSize().y) / 2));
|
||||
}
|
||||
else if (state_selected == 1) {
|
||||
dc.DrawBitmap(m_bitmap_check_on.bmp(), wxPoint(left, (size.y - m_bitmap_check_disable.GetBmpSize().y) / 2));
|
||||
}
|
||||
|
||||
left += FromDIP(PICK_LEFT_PRINTABLE);
|
||||
|
||||
//dev names
|
||||
DrawTextWithEllipsis(dc, wxString::FromUTF8(get_obj()->dev_name), FromDIP(PICK_LEFT_DEV_NAME), left);
|
||||
left += FromDIP(PICK_LEFT_DEV_NAME);
|
||||
}
|
||||
void DevicePickItem::post_event(wxCommandEvent&& event)
|
||||
{
|
||||
event.SetEventObject(this);
|
||||
event.SetString(obj_->dev_id);
|
||||
event.SetInt(state_selected);
|
||||
wxPostEvent(this, event);
|
||||
}
|
||||
|
||||
void DevicePickItem::DoSetSize(int x, int y, int width, int height, int sizeFlags /*= wxSIZE_AUTO*/)
|
||||
{
|
||||
wxWindow::DoSetSize(x, y, width, height, sizeFlags);
|
||||
}
|
||||
|
||||
MultiMachinePickPage::MultiMachinePickPage(Plater* plater /*= nullptr*/)
|
||||
: DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY,
|
||||
_L("Edit multiple printers"),
|
||||
wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX | wxRESIZE_BORDER)
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
SetDoubleBuffered(true);
|
||||
#endif //__WINDOWS__
|
||||
|
||||
app_config = get_app_config();
|
||||
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
// icon
|
||||
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
|
||||
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
|
||||
|
||||
wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
auto line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
|
||||
line_top->SetBackgroundColour(wxColour(166, 169, 170));
|
||||
|
||||
m_label = new Label(this, _L("Select connected printetrs (0/6)"));
|
||||
|
||||
scroll_macine_list = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL);
|
||||
scroll_macine_list->SetSize(wxSize(FromDIP(400), FromDIP(10 * 30)));
|
||||
scroll_macine_list->SetMinSize(wxSize(FromDIP(400), FromDIP(10 * 30)));
|
||||
scroll_macine_list->SetMaxSize(wxSize(FromDIP(400), FromDIP(10 * 30)));
|
||||
scroll_macine_list->SetBackgroundColour(*wxWHITE);
|
||||
scroll_macine_list->SetScrollRate(0, 5);
|
||||
|
||||
sizer_machine_list = new wxBoxSizer(wxVERTICAL);
|
||||
scroll_macine_list->SetSizer(sizer_machine_list);
|
||||
scroll_macine_list->Layout();
|
||||
|
||||
main_sizer->Add(line_top, 0, wxEXPAND, 0);
|
||||
main_sizer->AddSpacer(FromDIP(10));
|
||||
main_sizer->Add(m_label, 0, wxLEFT, FromDIP(20));
|
||||
main_sizer->Add(scroll_macine_list, 0, wxLEFT|wxRIGHT, FromDIP(20));
|
||||
main_sizer->AddSpacer(FromDIP(10));
|
||||
|
||||
SetSizer(main_sizer);
|
||||
Layout();
|
||||
Fit();
|
||||
Centre(wxBOTH);
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
}
|
||||
|
||||
MultiMachinePickPage::~MultiMachinePickPage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int MultiMachinePickPage::get_selected_count()
|
||||
{
|
||||
int count = 0;
|
||||
for (auto it = m_device_items.begin(); it != m_device_items.end(); it++) {
|
||||
if (it->second->state_selected == 1) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void MultiMachinePickPage::update_selected_count()
|
||||
{
|
||||
std::vector<std::string> selected_multi_devices;
|
||||
|
||||
int count = 0;
|
||||
for (auto it = m_device_items.begin(); it != m_device_items.end(); it++) {
|
||||
if (it->second->state_selected == 1 ) {
|
||||
selected_multi_devices.push_back(it->second->obj_->dev_id);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
m_selected_count = count;
|
||||
m_label->SetLabel(wxString::Format(_L("Select Connected Printetrs (%d/6)"), m_selected_count));
|
||||
|
||||
if (m_selected_count > PICK_DEVICE_MAX) {
|
||||
MessageDialog msg_wingow(nullptr, wxString::Format(_L("The maximum number of printers that can be selected is %d"), PICK_DEVICE_MAX), "", wxAPPLY | wxOK);
|
||||
if (msg_wingow.ShowModal() == wxOK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < PICK_DEVICE_MAX; i++) {
|
||||
app_config->erase("multi_devices",std::to_string(i));
|
||||
}
|
||||
|
||||
for (int j = 0; j < selected_multi_devices.size(); j++) {
|
||||
app_config->set_str("multi_devices", std::to_string(j), selected_multi_devices[j]);
|
||||
}
|
||||
app_config->save();
|
||||
}
|
||||
|
||||
void MultiMachinePickPage::on_dpi_changed(const wxRect& suggested_rect)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MultiMachinePickPage::on_sys_color_changed()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MultiMachinePickPage::refresh_user_device()
|
||||
{
|
||||
std::vector<std::string> selected_multi_devices;
|
||||
|
||||
for(int i = 0; i < PICK_DEVICE_MAX; i++){
|
||||
auto dev_id = app_config->get("multi_devices", std::to_string(i));
|
||||
selected_multi_devices.push_back(dev_id);
|
||||
}
|
||||
|
||||
sizer_machine_list->Clear(false);
|
||||
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) {
|
||||
for (auto it = m_device_items.begin(); it != m_device_items.end(); it++) {
|
||||
wxWindow* child = it->second;
|
||||
child->Destroy();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
auto user_machine = dev->get_my_cloud_machine_list();
|
||||
auto task_manager = wxGetApp().getTaskManager();
|
||||
|
||||
std::vector<std::string> subscribe_list;
|
||||
|
||||
for (auto it = user_machine.begin(); it != user_machine.end(); ++it) {
|
||||
DevicePickItem* di = new DevicePickItem(scroll_macine_list, it->second);
|
||||
|
||||
di->Bind(EVT_MULTI_DEVICE_SELECTED_FINHSH, [this, di](auto& e) {
|
||||
int count = get_selected_count();
|
||||
if (count > PICK_DEVICE_MAX) {
|
||||
di->unselected();
|
||||
return;
|
||||
}
|
||||
update_selected_count();
|
||||
});
|
||||
|
||||
/* if (m_device_items.find(it->first) != m_device_items.end()) {
|
||||
auto item = m_device_items[it->first];
|
||||
if (item->state_selected == 1 && di->state_printable <= 2)
|
||||
di->state_selected = item->state_selected;
|
||||
item->Destroy();
|
||||
}*/
|
||||
m_device_items[it->first] = di;
|
||||
|
||||
//update state
|
||||
if (task_manager) {
|
||||
m_device_items[it->first]->state_local_task = task_manager->query_task_state(it->first);
|
||||
}
|
||||
|
||||
//update selected
|
||||
auto dev_it = std::find(selected_multi_devices.begin(), selected_multi_devices.end(), it->second->dev_id );
|
||||
if (dev_it != selected_multi_devices.end()) {
|
||||
di->state_selected = 1;
|
||||
}
|
||||
|
||||
sizer_machine_list->Add(di, 0, wxALL | wxEXPAND, 0);
|
||||
subscribe_list.push_back(it->first);
|
||||
}
|
||||
|
||||
dev->subscribe_device_list(subscribe_list);
|
||||
|
||||
sizer_machine_list->Layout();
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
|
||||
void MultiMachinePickPage::on_confirm(wxCommandEvent& event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool MultiMachinePickPage::Show(bool show)
|
||||
{
|
||||
if (show) {
|
||||
refresh_user_device();
|
||||
//m_refresh_timer->Stop();
|
||||
//m_refresh_timer->SetOwner(this);
|
||||
//m_refresh_timer->Start(4000);
|
||||
//wxPostEvent(this, wxTimerEvent());
|
||||
}
|
||||
else {
|
||||
//m_refresh_timer->Stop();
|
||||
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (dev) {
|
||||
dev->subscribe_device_list(std::vector<std::string>());
|
||||
}
|
||||
}
|
||||
return wxDialog::Show(show);
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -12,6 +12,12 @@
|
|||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
#define PICK_LEFT_PADDING_LEFT 15
|
||||
#define PICK_LEFT_PRINTABLE 40
|
||||
#define PICK_LEFT_DEV_NAME 250
|
||||
#define PICK_LEFT_DEV_STATUS 250
|
||||
#define PICK_DEVICE_MAX 6
|
||||
|
||||
class MultiMachinePage : public wxPanel
|
||||
{
|
||||
|
@ -39,6 +45,59 @@ public:
|
|||
|
||||
void clear_page();
|
||||
};
|
||||
|
||||
|
||||
class DevicePickItem : public DeviceItem
|
||||
{
|
||||
|
||||
public:
|
||||
DevicePickItem(wxWindow* parent, MachineObject* obj);
|
||||
~DevicePickItem() {};
|
||||
|
||||
void DrawTextWithEllipsis(wxDC& dc, const wxString& text, int maxWidth, int left, int top = 0);
|
||||
void OnEnterWindow(wxMouseEvent& evt);
|
||||
void OnLeaveWindow(wxMouseEvent& evt);
|
||||
void OnSelectedDevice(wxCommandEvent& evt);
|
||||
void OnLeftDown(wxMouseEvent& evt);
|
||||
void OnMove(wxMouseEvent& evt);
|
||||
|
||||
void paintEvent(wxPaintEvent& evt);
|
||||
void render(wxDC& dc);
|
||||
void doRender(wxDC& dc);
|
||||
void post_event(wxCommandEvent&& event);
|
||||
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
||||
|
||||
public:
|
||||
bool m_hover{ false };
|
||||
ScalableBitmap m_bitmap_check_disable;
|
||||
ScalableBitmap m_bitmap_check_off;
|
||||
ScalableBitmap m_bitmap_check_on;
|
||||
};
|
||||
|
||||
|
||||
class MultiMachinePickPage : public DPIDialog
|
||||
{
|
||||
private:
|
||||
AppConfig* app_config;
|
||||
Label* m_label{ nullptr };
|
||||
wxScrolledWindow* scroll_macine_list{ nullptr };
|
||||
wxBoxSizer* m_sizer_body{ nullptr };
|
||||
wxBoxSizer* sizer_machine_list{ nullptr };
|
||||
std::map<std::string, DevicePickItem*> m_device_items;
|
||||
int m_selected_count{0};
|
||||
public:
|
||||
MultiMachinePickPage(Plater* plater = nullptr);
|
||||
~MultiMachinePickPage();
|
||||
|
||||
int get_selected_count();
|
||||
void update_selected_count();
|
||||
void on_dpi_changed(const wxRect& suggested_rect);
|
||||
void on_sys_color_changed();
|
||||
void refresh_user_device();
|
||||
void on_confirm(wxCommandEvent& event);
|
||||
bool Show(bool show);
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
|
|
|
@ -751,7 +751,18 @@ void LocalTaskManagerPage::refresh_user_device(bool clear)
|
|||
std::vector<std::string> subscribe_list;
|
||||
std::vector<MultiTaskItem*> task_temps;
|
||||
|
||||
auto user_machine = dev->get_my_cloud_machine_list();
|
||||
auto all_machine = dev->get_my_cloud_machine_list();
|
||||
auto user_machine = std::map<std::string, MachineObject*>();
|
||||
|
||||
//selected machine
|
||||
for (int i = 0; i < PICK_DEVICE_MAX; i++) {
|
||||
auto dev_id = wxGetApp().app_config->get("multi_devices", std::to_string(i));
|
||||
|
||||
if (all_machine.count(dev_id) > 0) {
|
||||
user_machine[dev_id] = all_machine[dev_id];
|
||||
}
|
||||
}
|
||||
|
||||
auto task_manager = wxGetApp().getTaskManager();
|
||||
if (task_manager) {
|
||||
auto m_task_obj_list = task_manager->get_local_task_list();
|
||||
|
@ -1174,7 +1185,18 @@ void CloudTaskManagerPage::refresh_user_device(bool clear)
|
|||
std::vector<MultiTaskItem*> task_temps;
|
||||
std::vector<std::string> subscribe_list;
|
||||
|
||||
auto user_machine = dev->get_my_cloud_machine_list();
|
||||
auto all_machine = dev->get_my_cloud_machine_list();
|
||||
auto user_machine = std::map<std::string, MachineObject*>();
|
||||
|
||||
//selected machine
|
||||
for (int i = 0; i < PICK_DEVICE_MAX; i++) {
|
||||
auto dev_id = wxGetApp().app_config->get("multi_devices", std::to_string(i));
|
||||
|
||||
if (all_machine.count(dev_id) > 0) {
|
||||
user_machine[dev_id] = all_machine[dev_id];
|
||||
}
|
||||
}
|
||||
|
||||
auto task_manager = wxGetApp().getTaskManager();
|
||||
if (task_manager) {
|
||||
auto m_task_obj_list = task_manager->get_task_list(m_current_page, m_count_page_item, m_total_count);
|
||||
|
|
|
@ -342,7 +342,19 @@ void SendMultiMachinePage::refresh_user_device()
|
|||
return;
|
||||
}
|
||||
|
||||
auto user_machine = dev->get_my_cloud_machine_list();
|
||||
auto all_machine = dev->get_my_cloud_machine_list();
|
||||
auto user_machine = std::map<std::string, MachineObject*>();
|
||||
|
||||
//selected machine
|
||||
for (int i = 0; i < PICK_DEVICE_MAX; i++) {
|
||||
auto dev_id = app_config->get("multi_devices", std::to_string(i));
|
||||
|
||||
if (all_machine.count(dev_id) > 0) {
|
||||
user_machine[dev_id] = all_machine[dev_id];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto task_manager = wxGetApp().getTaskManager();
|
||||
|
||||
std::vector<std::string> subscribe_list;
|
||||
|
|
|
@ -2,10 +2,13 @@
|
|||
|
||||
#include "libslic3r/Thread.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
namespace Slic3r {
|
||||
wxDEFINE_EVENT(EVT_MULTI_SEND_LIMIT, wxCommandEvent);
|
||||
|
||||
int TaskManager::MaxSendingAtSameTime = 5;
|
||||
int TaskManager::SendingInterval = 180;
|
||||
|
@ -75,6 +78,17 @@ TaskStateInfo::TaskStateInfo(BBL::PrintParams param)
|
|||
return m_cancel;
|
||||
};
|
||||
update_status_fn = [this](int stage, int code, std::string msg) {
|
||||
|
||||
if (stage == PrintingStageLimit)
|
||||
{
|
||||
//limit
|
||||
//wxCommandEvent event(EVT_MULTI_SEND_LIMIT);
|
||||
//wxPostEvent(this, event);
|
||||
GUI::wxGetApp().mainframe->CallAfter([]() {
|
||||
GUI::wxGetApp().show_dialog("The printing task exceeds the limit, supporting a maximum of 6 printers.");
|
||||
});
|
||||
}
|
||||
|
||||
const int StagePercentPoint[(int)PrintingStageFinished + 1] = {
|
||||
10, // PrintingStageCreate
|
||||
25, // PrintingStageUpload
|
||||
|
|
|
@ -136,7 +136,7 @@ public:
|
|||
bool need_schedule(std::chrono::system_clock::time_point last, TaskStateInfo* task);
|
||||
};
|
||||
|
||||
class TaskManager
|
||||
class TaskManager
|
||||
{
|
||||
public:
|
||||
static int MaxSendingAtSameTime;
|
||||
|
@ -175,6 +175,7 @@ private:
|
|||
};
|
||||
|
||||
|
||||
wxDECLARE_EVENT(EVT_MULTI_SEND_LIMIT, wxCommandEvent);
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif
|
||||
|
|
|
@ -147,6 +147,7 @@ enum SendingPrintJobStage {
|
|||
PrintingStageWaitPrinter = 5,
|
||||
PrintingStageFinished = 6,
|
||||
PrintingStageERROR = 7,
|
||||
PrintingStageLimit = 8,
|
||||
};
|
||||
|
||||
enum PublishingStage {
|
||||
|
|
Loading…
Reference in New Issue