OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::SelectMachinePopup Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/SelectMachinePop.hpp>

Inheritance diagram for Slic3r::GUI::SelectMachinePopup:
Collaboration diagram for Slic3r::GUI::SelectMachinePopup:

Public Member Functions

 SelectMachinePopup (wxWindow *parent)
 ~SelectMachinePopup ()
virtual void Popup (wxWindow *focus=NULL) wxOVERRIDE
virtual void OnDismiss () wxOVERRIDE
virtual bool ProcessLeftDown (wxMouseEvent &event) wxOVERRIDE
virtual bool Show (bool show=true) wxOVERRIDE
void update_machine_list (wxCommandEvent &event)
void start_ssdp (bool on_off)
bool was_dismiss ()
bool Create (wxWindow *parent, int flags=wxBORDER_NONE)

Protected Member Functions

virtual bool ShouldDismissOnTopWindowDeactivate ()

Private Member Functions

void OnLeftUp (wxMouseEvent &event)
void on_timer (wxTimerEvent &event)
void update_other_devices ()
void update_user_devices ()
bool search_for_printer (MachineObject *obj)
void on_dissmiss_win (wxCommandEvent &event)
wxWindow * create_title_panel (wxString text)

Private Attributes

int m_my_devices_count {0}
int m_other_devices_count {0}
PinCodePanel * m_panel_ping_code {nullptr}
PinCodePanel * m_panel_direct_connection {nullptr}
wxWindow * m_placeholder_panel {nullptr}
HyperLink * m_hyperlink {nullptr}
wxBoxSizer * m_sizer_my_devices {nullptr}
wxBoxSizer * m_sizer_other_devices {nullptr}
wxSearchCtrl * m_search_bar {nullptr}
wxScrolledWindow * m_scrolledWindow {nullptr}
wxTimer * m_refresh_timer {nullptr}
std::vector< MachinePanel * > m_user_list_machine_panel
std::vector< MachinePanel * > m_other_list_machine_panel
boost::thread * get_print_info_thread { nullptr }
std::shared_ptr< int > m_token = std::make_shared<int>(0)
std::string m_print_info = ""
bool m_dismiss { false }
std::map< std::string, MachineObject * > m_bind_machine_list
std::map< std::string, MachineObject * > m_free_machine_list

Detailed Description

Constructor & Destructor Documentation

◆ SelectMachinePopup()

Slic3r::GUI::SelectMachinePopup::SelectMachinePopup ( wxWindow * parent)
337 : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS), m_dismiss(false)
338{
339#ifdef __WINDOWS__
340 SetDoubleBuffered(true);
341#endif //__WINDOWS__
342
343
345 SetMinSize(SELECT_MACHINE_POPUP_SIZE);
346 SetMaxSize(SELECT_MACHINE_POPUP_SIZE);
347
348 Freeze();
349 wxBoxSizer *m_sizer_main = new wxBoxSizer(wxVERTICAL);
350 SetBackgroundColour(SELECT_MACHINE_GREY400);
351
352
353
354 m_scrolledWindow = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_LIST_SIZE, wxHSCROLL | wxVSCROLL);
355 m_scrolledWindow->SetBackgroundColour(*wxWHITE);
357 m_scrolledWindow->SetScrollRate(0, SELECT_MACHINE_ITEM_SIZE.y);
358 auto m_sizxer_scrolledWindow = new wxBoxSizer(wxVERTICAL);
359 m_scrolledWindow->SetSizer(m_sizxer_scrolledWindow);
360 m_scrolledWindow->Layout();
361 m_sizxer_scrolledWindow->Fit(m_scrolledWindow);
362
363#if defined(__WINDOWS__)
364 m_sizer_search_bar = new wxBoxSizer(wxVERTICAL);
365 m_search_bar = new wxSearchCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
366 m_search_bar->SetDescriptiveText(_L("Search"));
367 m_search_bar->ShowSearchButton( true );
368 m_search_bar->ShowCancelButton( false );
369 m_sizer_search_bar->Add( m_search_bar, 1, wxALL| wxEXPAND, 1 );
370 m_sizer_main->Add(m_sizer_search_bar, 0, wxTOP | wxRIGHT | wxLEFT | wxEXPAND, FromDIP(1));
371 m_search_bar->Bind( wxEVT_COMMAND_TEXT_UPDATED, &SelectMachinePopup::update_machine_list, this );
372#endif
373 auto own_title = create_title_panel(_L("My Device"));
374 m_sizer_my_devices = new wxBoxSizer(wxVERTICAL);
375 auto other_title = create_title_panel(_L("Other Device"));
376 m_sizer_other_devices = new wxBoxSizer(wxVERTICAL);
377
378
379 m_panel_ping_code = new PinCodePanel(m_scrolledWindow, 0, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE);
380 m_panel_direct_connection = new PinCodePanel(m_scrolledWindow, 1, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE);
381
382 m_sizxer_scrolledWindow->Add(own_title, 0, wxEXPAND | wxLEFT, FromDIP(15));
383 m_sizxer_scrolledWindow->Add(m_sizer_my_devices, 0, wxEXPAND, 0);
384 m_sizxer_scrolledWindow->Add(m_panel_ping_code, 0, wxEXPAND, 0);
385 m_sizxer_scrolledWindow->Add(m_panel_direct_connection, 0, wxEXPAND, 0);
386 m_sizxer_scrolledWindow->Add(other_title, 0, wxEXPAND | wxLEFT, FromDIP(15));
387 m_sizxer_scrolledWindow->Add(m_sizer_other_devices, 0, wxEXPAND, 0);
388
389 m_sizer_main->Add(m_scrolledWindow, 0, wxALL | wxEXPAND, FromDIP(2));
390
391 SetSizer(m_sizer_main);
392 Layout();
393 Thaw();
394
395 #ifdef __APPLE__
396 m_scrolledWindow->Bind(wxEVT_LEFT_UP, &SelectMachinePopup::OnLeftUp, this);
397 #endif // __APPLE__
398
399 m_refresh_timer = new wxTimer();
400 m_refresh_timer->SetOwner(this);
401 Bind(EVT_UPDATE_USER_MACHINE_LIST, &SelectMachinePopup::update_machine_list, this);
402 Bind(wxEVT_TIMER, &SelectMachinePopup::on_timer, this);
403 Bind(EVT_DISSMISS_MACHINE_LIST, &SelectMachinePopup::on_dissmiss_win, this);
404}
#define _L(s)
Definition OBJ.cpp:34
#define SELECT_MACHINE_ITEM_SIZE
Definition SelectMachinePop.hpp:77
#define SELECT_MACHINE_LIST_SIZE
Definition SelectMachinePop.hpp:76
#define SELECT_MACHINE_GREY400
Definition SelectMachinePop.hpp:80
#define SELECT_MACHINE_POPUP_SIZE
Definition SelectMachinePop.hpp:75
PopupWindow()
Definition PopupWindow.hpp:10
wxBoxSizer * m_sizer_my_devices
Definition SelectMachinePop.hpp:191
PinCodePanel * m_panel_direct_connection
Definition SelectMachinePop.hpp:188
wxBoxSizer * m_sizer_other_devices
Definition SelectMachinePop.hpp:192
wxSearchCtrl * m_search_bar
Definition SelectMachinePop.hpp:196
void on_dissmiss_win(wxCommandEvent &event)
Definition SelectMachinePop.cpp:837
wxWindow * create_title_panel(wxString text)
Definition SelectMachinePop.cpp:492
void on_timer(wxTimerEvent &event)
Definition SelectMachinePop.cpp:517
void update_machine_list(wxCommandEvent &event)
Definition SelectMachinePop.cpp:842
bool m_dismiss
Definition SelectMachinePop.hpp:204
wxScrolledWindow * m_scrolledWindow
Definition SelectMachinePop.hpp:197
wxTimer * m_refresh_timer
Definition SelectMachinePop.hpp:198
void OnLeftUp(wxMouseEvent &event)
Definition SelectMachinePop.cpp:855
PinCodePanel * m_panel_ping_code
Definition SelectMachinePop.hpp:187

References PopupWindow::PopupWindow(), _L, create_title_panel(), m_dismiss, m_panel_direct_connection, m_panel_ping_code, m_refresh_timer, m_scrolledWindow, m_search_bar, m_sizer_my_devices, m_sizer_other_devices, on_dissmiss_win(), on_timer(), OnLeftUp(), SELECT_MACHINE_GREY400, SELECT_MACHINE_ITEM_SIZE, SELECT_MACHINE_LIST_SIZE, SELECT_MACHINE_POPUP_SIZE, and update_machine_list().

Here is the call graph for this function:

◆ ~SelectMachinePopup()

Slic3r::GUI::SelectMachinePopup::~SelectMachinePopup ( )
406{ delete m_refresh_timer;}

References m_refresh_timer.

Member Function Documentation

◆ Create()

bool PopupWindow::Create ( wxWindow * parent,
int flags = wxBORDER_NONE )
inherited
22{
23 if (!wxPopupTransientWindow::Create(parent, style))
24 return false;
25#ifdef __WXGTK__
26 GetTopParent(parent)->Bind(wxEVT_ACTIVATE, &PopupWindow::topWindowActiavate, this);
27#endif
28#ifdef __WXOSX__
29 if (style & wxPU_CONTAINS_CONTROLS)
30 for (auto evt : {wxEVT_LEFT_DOWN, wxEVT_LEFT_UP, wxEVT_LEFT_DCLICK, wxEVT_MOTION, wxEVT_MOUSEWHEEL})
31 Bind(evt, &PopupWindow::OnMouseEvent2, this);
32#endif
33 return true;
34}
static wxWindow * GetTopParent(wxWindow *pWindow)
Definition PopupWindow.cpp:10
#define style
Definition WipeTowerDialog.cpp:101

References GetTopParent(), and style.

Referenced by PopupWindow(), and DropDown::Create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_title_panel()

wxWindow * Slic3r::GUI::SelectMachinePopup::create_title_panel ( wxString text)
private
493{
494 auto m_panel_title_own = new wxWindow(m_scrolledWindow, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE, wxTAB_TRAVERSAL);
495 m_panel_title_own->SetBackgroundColour(*wxWHITE);
496
497 wxBoxSizer *m_sizer_title_own = new wxBoxSizer(wxHORIZONTAL);
498
499 auto m_title_own = new wxStaticText(m_panel_title_own, wxID_ANY, text, wxDefaultPosition, wxDefaultSize, 0);
500 m_title_own->Wrap(-1);
501 m_sizer_title_own->Add(m_title_own, 0, wxALIGN_CENTER, 0);
502
503 wxBoxSizer *m_sizer_line_own = new wxBoxSizer(wxHORIZONTAL);
504
505 auto m_panel_line_own = new wxPanel(m_panel_title_own, wxID_ANY, wxDefaultPosition, wxSize(SELECT_MACHINE_ITEM_SIZE.x, FromDIP(1)), wxTAB_TRAVERSAL);
506 m_panel_line_own->SetBackgroundColour(SELECT_MACHINE_GREY400);
507
508 m_sizer_line_own->Add(m_panel_line_own, 0, wxALIGN_CENTER, 0);
509 m_sizer_title_own->Add(0, 0, 0, wxLEFT, FromDIP(10));
510 m_sizer_title_own->Add(m_sizer_line_own, 1, wxEXPAND | wxRIGHT, FromDIP(10));
511
512 m_panel_title_own->SetSizer(m_sizer_title_own);
513 m_panel_title_own->Layout();
514 return m_panel_title_own;
515}
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30

References m_scrolledWindow, SELECT_MACHINE_GREY400, SELECT_MACHINE_ITEM_SIZE, and wxStaticText.

Referenced by SelectMachinePopup().

Here is the caller graph for this function:

◆ on_dissmiss_win()

void Slic3r::GUI::SelectMachinePopup::on_dissmiss_win ( wxCommandEvent & event)
private
838{
839 Dismiss();
840}

References on_dissmiss_win().

Referenced by SelectMachinePopup(), and on_dissmiss_win().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_timer()

void Slic3r::GUI::SelectMachinePopup::on_timer ( wxTimerEvent & event)
private
518{
519 BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup on_timer";
520 wxGetApp().reset_to_active();
521 wxCommandEvent user_event(EVT_UPDATE_USER_MACHINE_LIST);
522 user_event.SetEventObject(this);
523 wxPostEvent(this, user_event);
524}
void trace(unsigned int level, const char *message)
Definition utils.cpp:247

References Slic3r::trace().

Referenced by SelectMachinePopup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnDismiss()

void Slic3r::GUI::SelectMachinePopup::OnDismiss ( )
virtual
452{
453 BOOST_LOG_TRIVIAL(trace) << "get_print_info: dismiss";
454 start_ssdp(false);
455 m_dismiss = true;
456
457 if (m_refresh_timer) {
458 m_refresh_timer->Stop();
459 }
461 if (get_print_info_thread->joinable()) {
462 get_print_info_thread->join();
464 get_print_info_thread = nullptr;
465 }
466 }
467
468 wxCommandEvent event(EVT_FINISHED_UPDATE_MACHINE_LIST);
469 event.SetEventObject(this);
470 wxPostEvent(this, event);
471}
void start_ssdp(bool on_off)
Definition SelectMachinePop.cpp:849
boost::thread * get_print_info_thread
Definition SelectMachinePop.hpp:201

References get_print_info_thread, m_dismiss, m_refresh_timer, start_ssdp(), and Slic3r::trace().

Here is the call graph for this function:

◆ OnLeftUp()

void Slic3r::GUI::SelectMachinePopup::OnLeftUp ( wxMouseEvent & event)
private
856{
857 auto mouse_pos = ClientToScreen(event.GetPosition());
858 auto wxscroll_win_pos = m_scrolledWindow->ClientToScreen(wxPoint(0, 0));
859
860 if (mouse_pos.x > wxscroll_win_pos.x && mouse_pos.y > wxscroll_win_pos.y && mouse_pos.x < (wxscroll_win_pos.x + m_scrolledWindow->GetSize().x) &&
861 mouse_pos.y < (wxscroll_win_pos.y + m_scrolledWindow->GetSize().y)) {
862
863 for (MachinePanel* p : m_user_list_machine_panel) {
864 auto p_rect = p->mPanel->ClientToScreen(wxPoint(0, 0));
865 if (mouse_pos.x > p_rect.x && mouse_pos.y > p_rect.y && mouse_pos.x < (p_rect.x + p->mPanel->GetSize().x) && mouse_pos.y < (p_rect.y + p->mPanel->GetSize().y)) {
866 wxMouseEvent event(wxEVT_LEFT_UP);
867 auto tag_pos = p->mPanel->ScreenToClient(mouse_pos);
868 event.SetPosition(tag_pos);
869 event.SetEventObject(p->mPanel);
870 wxPostEvent(p->mPanel, event);
871 }
872 }
873
874 for (MachinePanel* p : m_other_list_machine_panel) {
875 auto p_rect = p->mPanel->ClientToScreen(wxPoint(0, 0));
876 if (mouse_pos.x > p_rect.x && mouse_pos.y > p_rect.y && mouse_pos.x < (p_rect.x + p->mPanel->GetSize().x) && mouse_pos.y < (p_rect.y + p->mPanel->GetSize().y)) {
877 wxMouseEvent event(wxEVT_LEFT_UP);
878 auto tag_pos = p->mPanel->ScreenToClient(mouse_pos);
879 event.SetPosition(tag_pos);
880 event.SetEventObject(p->mPanel);
881 wxPostEvent(p->mPanel, event);
882 }
883 }
884
885 //pin code
886 auto pc_rect = m_panel_ping_code->ClientToScreen(wxPoint(0, 0));
887 if (mouse_pos.x > pc_rect.x && mouse_pos.y > pc_rect.y && mouse_pos.x < (pc_rect.x + m_panel_ping_code->GetSize().x) && mouse_pos.y < (pc_rect.y + m_panel_ping_code->GetSize().y)) {
888 wxGetApp().popup_ping_bind_dialog();
889 }
890
891 //bind with access code
892 auto dc_rect = m_panel_direct_connection->ClientToScreen(wxPoint(0, 0));
893 if (mouse_pos.x > dc_rect.x && mouse_pos.y > dc_rect.y && mouse_pos.x < (dc_rect.x + m_panel_direct_connection->GetSize().x) && mouse_pos.y < (dc_rect.y + m_panel_direct_connection->GetSize().y)) {
894 InputIpAddressDialog dlgo;
895 dlgo.ShowModal();
896 }
897
898 //hyper link
899 auto h_rect = m_hyperlink->ClientToScreen(wxPoint(0, 0));
900 if (mouse_pos.x > h_rect.x && mouse_pos.y > h_rect.y && mouse_pos.x < (h_rect.x + m_hyperlink->GetSize().x) && mouse_pos.y < (h_rect.y + m_hyperlink->GetSize().y)) {
901 wxLaunchDefaultBrowser(wxT("https://www.orcaslicer.com/wiki/")); // Orca: neutral wiki link (vendor URL removed)
902 }
903 }
904}
HyperLink * m_hyperlink
Definition SelectMachinePop.hpp:190
std::vector< MachinePanel * > m_user_list_machine_panel
Definition SelectMachinePop.hpp:199
std::vector< MachinePanel * > m_other_list_machine_panel
Definition SelectMachinePop.hpp:200
wxMouseEvent
Definition CameraPopup.cpp:47

References m_hyperlink, m_other_list_machine_panel, m_panel_direct_connection, m_panel_ping_code, m_scrolledWindow, m_user_list_machine_panel, OnLeftUp(), Slic3r::GUI::DPIAware< P >::ShowModal(), and Slic3r::GUI::wxMouseEvent.

Referenced by SelectMachinePopup(), and OnLeftUp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Popup()

void Slic3r::GUI::SelectMachinePopup::Popup ( wxWindow * focus = NULL)
virtual
409{
410 BOOST_LOG_TRIVIAL(trace) << "get_print_info: start";
411 start_ssdp(true);
412 if (m_refresh_timer) {
413 m_refresh_timer->Stop();
415 }
416
417 const std::string provider = wxGetApp().get_printer_cloud_provider();
418 if (wxGetApp().is_user_login(provider)) {
420 get_print_info_thread = new boost::thread(Slic3r::create_thread([this, token = std::weak_ptr<int>(m_token), provider] {
421 NetworkAgent* agent = wxGetApp().getAgent();
422 unsigned int http_code;
423 std::string body;
424 int result = agent->get_user_print_info(&http_code, &body, provider);
425 CallAfter([token, this, result, body]() {
426 if (token.expired()) {return;}
427 if (result == 0) {
428 m_print_info = body;
429 }
430 else {
431 m_print_info = "";
432 }
433 wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST);
434 event.SetEventObject(this);
435 wxPostEvent(this, event);
436 });
437 }));
438 }
439 }
440
441 {
442 wxGetApp().reset_to_active();
443 wxCommandEvent user_event(EVT_UPDATE_USER_MACHINE_LIST);
444 user_event.SetEventObject(this);
445 wxPostEvent(this, user_event);
446 }
447
448 PopupWindow::Popup();
449}
#define MACHINE_LIST_REFRESH_INTERVAL
Definition CalibrationPanel.cpp:47
std::string m_print_info
Definition SelectMachinePop.hpp:203
std::shared_ptr< int > m_token
Definition SelectMachinePop.hpp:202
boost::thread create_thread(boost::thread::attributes &attrs, Fn &&fn)
Definition Thread.hpp:48

References Slic3r::create_thread(), get_print_info_thread, Slic3r::NetworkAgent::get_user_print_info(), m_print_info, m_refresh_timer, m_token, MACHINE_LIST_REFRESH_INTERVAL, start_ssdp(), and Slic3r::trace().

Here is the call graph for this function:

◆ ProcessLeftDown()

bool Slic3r::GUI::SelectMachinePopup::ProcessLeftDown ( wxMouseEvent & event)
virtual
473 {
474 return PopupWindow::ProcessLeftDown(event);
475}

References Slic3r::GUI::wxMouseEvent.

◆ search_for_printer()

bool Slic3r::GUI::SelectMachinePopup::search_for_printer ( MachineObject * obj)
private
815{
816 const std::string& search_text = m_search_bar->GetValue().ToStdString();
817 if (search_text.empty()) {
818 return true;
819 }
820
821 const auto& name = wxString::FromUTF8(obj->get_dev_name()).ToStdString();
822 const auto& name_it = name.find(search_text);
823 if (name_it != std::string::npos) {
824 return true;
825 }
826
827#if !BBL_RELEASE_TO_PUBLIC
828 const auto& ip_it = obj->get_dev_ip().find(search_text);
829 if (ip_it != std::string::npos) {
830 return true;
831 }
832#endif
833
834 return false;
835}

References Slic3r::MachineObject::get_dev_ip(), Slic3r::MachineObject::get_dev_name(), m_search_bar, and search_for_printer().

Referenced by search_for_printer(), and update_other_devices().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShouldDismissOnTopWindowDeactivate()

virtual bool PopupWindow::ShouldDismissOnTopWindowDeactivate ( )
inlineprotectedvirtualinherited

Reimplemented in DropDown.

28{ return true; }

◆ Show()

bool Slic3r::GUI::SelectMachinePopup::Show ( bool show = true)
virtual
477 {
478 if (show) {
479 for (int i = 0; i < m_user_list_machine_panel.size(); i++) {
480 m_user_list_machine_panel[i]->mPanel->update_machine_info(nullptr);
481 m_user_list_machine_panel[i]->mPanel->Hide();
482 }
483
484 for (int j = 0; j < m_other_list_machine_panel.size(); j++) {
485 m_other_list_machine_panel[j]->mPanel->update_machine_info(nullptr);
486 m_other_list_machine_panel[j]->mPanel->Hide();
487 }
488 }
489 return PopupWindow::Show(show);
490}

References m_other_list_machine_panel, and m_user_list_machine_panel.

◆ start_ssdp()

void Slic3r::GUI::SelectMachinePopup::start_ssdp ( bool on_off)
850{
851 return;
852 //if (wxGetApp().getAgent()) { wxGetApp().getAgent()->start_discovery(true, start); }
853}

References start_ssdp().

Referenced by OnDismiss(), Popup(), and start_ssdp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_machine_list()

void Slic3r::GUI::SelectMachinePopup::update_machine_list ( wxCommandEvent & event)
843{
846 BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_machine_list end";
847}
void update_user_devices()
Definition SelectMachinePop.cpp:658
void update_other_devices()
Definition SelectMachinePop.cpp:526

References Slic3r::trace(), update_machine_list(), update_other_devices(), and update_user_devices().

Referenced by SelectMachinePopup(), and update_machine_list().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_other_devices()

void Slic3r::GUI::SelectMachinePopup::update_other_devices ( )
private
527{
528 DeviceManager* dev = wxGetApp().getDeviceManager();
529 if (!dev) return;
530 m_free_machine_list = dev->get_local_machinelist();
531 const std::string current_agent_id = dev->get_current_printer_agent_id();
532
533 BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_other_devices start";
534 this->Freeze();
535 m_scrolledWindow->Freeze();
536 int i = 0;
537
538 for (auto &elem : m_free_machine_list) {
539 MachineObject * mobj = elem.second;
540 /* do not show printer bind state is empty */
541 if (!mobj->is_avaliable()) continue;
542
543 /* do not show devices discovered/bound by a different printer agent */
544 if (mobj->printer_agent_id != current_agent_id)
545 continue;
546
547 if (!wxGetApp().is_user_login(wxGetApp().get_printer_cloud_provider()) && !mobj->is_lan_mode_printer())
548 continue;
549
550 /* do not show printer in my list */
551 auto it = m_bind_machine_list.find(mobj->get_dev_id());
552 if (it != m_bind_machine_list.end())
553 continue;
554
555 MachineObjectPanel* op = nullptr;
556 if (i < m_other_list_machine_panel.size()) {
557 op = m_other_list_machine_panel[i]->mPanel;
558 } else {
559 op = new MachineObjectPanel(m_scrolledWindow, wxID_ANY);
560 MachinePanel* mpanel = new MachinePanel();
561 mpanel->mIndex = wxString::Format("%d", i);
562 mpanel->mPanel = op;
563 m_other_list_machine_panel.push_back(mpanel);
564 m_sizer_other_devices->Add(op, 0, wxEXPAND, 0);
565 }
566#if defined(__WINDOWS__)
567 if (!search_for_printer(mobj)) {
568 op->Hide();
569 }
570 else {
571 op->Show();
572 }
573#else
574 op->Show();
575#endif
576 i++;
577
578 op->update_machine_info(mobj);
579
580 if (mobj->is_lan_mode_printer()) {
581 if (mobj->has_access_right()) {
582 op->set_printer_state(PrinterState::IN_LAN);
583 } else {
584 op->set_printer_state(PrinterState::LOCK);
585 }
586 } else {
587 op->show_edit_printer_name(false);
588 op->show_printer_bind(true, PrinterBindState::ALLOW_BIND);
589 if (mobj->is_in_printing()) {
590 op->set_printer_state(PrinterState::BUSY);
591 } else {
592 op->SetToolTip(_L("Online"));
593 op->set_printer_state(IDLE);
594 }
595 }
596
597 op->Bind(EVT_CONNECT_LAN_PRINT, [mobj](wxCommandEvent &e) {
598 if (mobj) {
599 if (mobj->is_lan_mode_printer()) {
600 ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code"));
601 dlg.set_machine_object(mobj);
602 if (dlg.ShowModal() == wxID_OK) {
603 wxGetApp().mainframe->jump_to_monitor(mobj->get_dev_id());
604 }
605 }
606 }
607 });
608
609 op->Bind(EVT_BIND_MACHINE, [mobj](wxCommandEvent &e) {
610 BindMachineDialog dlg;
611 dlg.update_machine_info(mobj);
612 int dlg_result = wxID_CANCEL;
613 dlg_result = dlg.ShowModal();
614 if (dlg_result == wxID_OK) { wxGetApp().mainframe->jump_to_monitor(mobj->get_dev_id()); }
615 });
616 }
617
618 for (int j = i; j < m_other_list_machine_panel.size(); j++) {
619 m_other_list_machine_panel[j]->mPanel->update_machine_info(nullptr);
620 m_other_list_machine_panel[j]->mPanel->Hide();
621 }
622
623 if (m_placeholder_panel != nullptr) {
625 m_placeholder_panel->Destroy();
626 m_placeholder_panel = nullptr;
627 }
628
629 m_placeholder_panel = new wxWindow(m_scrolledWindow, wxID_ANY, wxDefaultPosition, wxSize(-1,FromDIP(26)));
630 wxBoxSizer* placeholder_sizer = new wxBoxSizer(wxVERTICAL);
631
632 // ORCA standardized HyperLink
633 m_hyperlink = new HyperLink(m_placeholder_panel, _L("Can\'t find devices\?"), wxT("https://www.orcaslicer.com/wiki/")); // Orca: neutral wiki link (vendor URL removed)
635 placeholder_sizer->Add(m_hyperlink, 0, wxALIGN_CENTER | wxALL, 5);
636
637
638 m_placeholder_panel->SetSizer(placeholder_sizer);
639 m_placeholder_panel->Layout();
640 placeholder_sizer->Fit(m_placeholder_panel);
641
642 m_placeholder_panel->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
643 m_sizer_other_devices->Add(m_placeholder_panel, 0, wxEXPAND, 0);
644
645 //m_sizer_other_devices->Layout();
646 if(m_other_devices_count != i) {
647 m_scrolledWindow->Fit();
648 }
649 m_scrolledWindow->Layout();
650 m_scrolledWindow->Thaw();
651 Layout();
652 Fit();
653 this->Thaw();
655 BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_other_devices end";
656}
static wxFont Body_12
Definition Label.hpp:55
int m_other_devices_count
Definition SelectMachinePop.hpp:186
std::map< std::string, MachineObject * > m_free_machine_list
Definition SelectMachinePop.hpp:207
bool search_for_printer(MachineObject *obj)
Definition SelectMachinePop.cpp:814
std::map< std::string, MachineObject * > m_bind_machine_list
Definition SelectMachinePop.hpp:206
wxWindow * m_placeholder_panel
Definition SelectMachinePop.hpp:189
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
@ BUSY
Definition SelectMachinePop.hpp:55
@ IDLE
Definition SelectMachinePop.hpp:54
@ IN_LAN
Definition SelectMachinePop.hpp:57
@ LOCK
Definition SelectMachinePop.hpp:56
@ ALLOW_BIND
Definition SelectMachinePop.hpp:62

References _L, Slic3r::GUI::ALLOW_BIND, Label::Body_12, Slic3r::GUI::BUSY, StateColor::darkModeColorFor(), Slic3r::DeviceManager::get_current_printer_agent_id(), Slic3r::MachineObject::get_dev_id(), Slic3r::DeviceManager::get_local_machinelist(), Slic3r::MachineObject::has_access_right(), Slic3r::GUI::IDLE, Slic3r::GUI::IN_LAN, Slic3r::MachineObject::is_avaliable(), Slic3r::MachineObject::is_in_printing(), Slic3r::MachineObject::is_lan_mode_printer(), Slic3r::GUI::LOCK, m_bind_machine_list, m_free_machine_list, m_hyperlink, m_other_devices_count, m_other_list_machine_panel, m_placeholder_panel, m_scrolledWindow, m_sizer_other_devices, Slic3r::GUI::MachinePanel::mIndex, Slic3r::GUI::MachinePanel::mPanel, Slic3r::MachineObject::printer_agent_id, search_for_printer(), Slic3r::GUI::ConnectPrinterDialog::set_machine_object(), Slic3r::GUI::MachineObjectPanel::set_printer_state(), Slic3r::GUI::MachineObjectPanel::show_edit_printer_name(), Slic3r::GUI::MachineObjectPanel::show_printer_bind(), Slic3r::GUI::DPIAware< P >::ShowModal(), Slic3r::trace(), Slic3r::GUI::BindMachineDialog::update_machine_info(), and Slic3r::GUI::MachineObjectPanel::update_machine_info().

Referenced by update_machine_list().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_user_devices()

void Slic3r::GUI::SelectMachinePopup::update_user_devices ( )
private
659{
660 Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
661 if (!dev) return;
662
663 if (!m_print_info.empty()) {
665 m_print_info = "";
666 }
667
668 m_bind_machine_list.clear();
670
671 //sort list
672 std::vector<std::pair<std::string, MachineObject*>> user_machine_list;
673 for (auto& it: m_bind_machine_list) {
674 user_machine_list.push_back(it);
675 }
676
677 std::sort(user_machine_list.begin(), user_machine_list.end(), [&](auto& a, auto&b) {
678 if (a.second && b.second) {
679 return a.second->get_dev_name().compare(b.second->get_dev_name()) < 0;
680 }
681 return false;
682 });
683
684 BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_machine_list start";
685 this->Freeze();
686 m_scrolledWindow->Freeze();
687 int i = 0;
688
689 for (auto& elem : user_machine_list) {
690 MachineObject* mobj = elem.second;
691 MachineObjectPanel* op = nullptr;
692 if (i < m_user_list_machine_panel.size()) {
693 op = m_user_list_machine_panel[i]->mPanel;
694#if defined(__WINDOWS__)
695 if (!search_for_printer(mobj)) {
696 op->Hide();
697 } else {
698 op->Show();
699 }
700#else
701 op->Show();
702#endif
703 } else {
704 op = new MachineObjectPanel(m_scrolledWindow, wxID_ANY);
705 MachinePanel* mpanel = new MachinePanel();
706 mpanel->mIndex = wxString::Format("%d", i);
707 mpanel->mPanel = op;
708 m_user_list_machine_panel.push_back(mpanel);
709 m_sizer_my_devices->Add(op, 0, wxEXPAND, 0);
710 }
711 i++;
712 op->update_machine_info(mobj, true);
713 //set in lan
714 if (mobj->is_lan_mode_printer()) {
715 if (!mobj->is_online()) {
716 continue;
717 }
718 else {
719 op->show_printer_bind(false, PrinterBindState::NONE);
720 op->show_edit_printer_name(false);
721 if (mobj->has_access_right() && mobj->is_avaliable()) {
722 op->set_printer_state(PrinterState::IN_LAN);
723 op->show_printer_bind(true, PrinterBindState::ALLOW_UNBIND);
724 op->SetToolTip(_L("Online"));
725 }
726 else {
727 op->set_printer_state(PrinterState::LOCK);
728 }
729 }
730 op->Bind(EVT_UNBIND_MACHINE, [dev, mobj](wxCommandEvent& e) {
731 dev->set_selected_machine("");
732 if (mobj) {
733 AppConfig* config = wxGetApp().app_config;
734 if (config) {
735 config->clear_local_machine_access_code(mobj->get_dev_id(), mobj->printer_agent_id);
736 config->erase_local_machine(mobj->get_dev_id());
737 }
738
739 mobj->revoke_access();
740 }
741
742 if (GUI::wxGetApp().plater())
743 GUI::wxGetApp().plater()->update_machine_sync_status();
744
745 MessageDialog msg_wingow(nullptr, _L("Log out successful."), "", wxAPPLY | wxOK);
746 if (msg_wingow.ShowModal() == wxOK) { return; }
747 });
748 }
749 else {
750 op->show_printer_bind(true, PrinterBindState::ALLOW_UNBIND);
751 op->Bind(EVT_UNBIND_MACHINE, [mobj, dev](wxCommandEvent& e) {
752 // show_unbind_dialog
753 UnBindMachineDialog dlg;
754 dlg.update_machine_info(mobj);
755 if (dlg.ShowModal() == wxID_OK) {
756 dev->set_selected_machine("");
757 }
758 });
759
760 if (!mobj->is_online()) {
761 op->SetToolTip(_L("Offline"));
762 op->set_printer_state(PrinterState::OFFLINE);
763 }
764 else {
765 op->show_edit_printer_name(true);
766 op->show_printer_bind(true, PrinterBindState::ALLOW_UNBIND);
767 if (mobj->is_in_printing()) {
768 op->SetToolTip(_L("Busy"));
769 op->set_printer_state(PrinterState::BUSY);
770 }
771 else {
772 op->SetToolTip(_L("Online"));
773 op->set_printer_state(PrinterState::IDLE);
774 }
775 }
776 }
777
778 op->Bind(EVT_CONNECT_LAN_PRINT, [mobj](wxCommandEvent &e) {
779 if (mobj) {
780 if (mobj->is_lan_mode_printer()) {
781 ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code"));
782 dlg.set_machine_object(mobj);
783 if (dlg.ShowModal() == wxID_OK) {
784 wxGetApp().mainframe->jump_to_monitor(mobj->get_dev_id());
785 }
786 }
787 }
788 });
789
790 op->Bind(EVT_EDIT_PRINT_NAME, [mobj](wxCommandEvent &e) {
791 EditDevNameDialog dlg;
792 dlg.set_machine_obj(mobj);
793 dlg.ShowModal();
794 });
795 }
796
797 for (int j = i; j < m_user_list_machine_panel.size(); j++) {
798 m_user_list_machine_panel[j]->mPanel->update_machine_info(nullptr);
799 m_user_list_machine_panel[j]->mPanel->Hide();
800 }
801 //m_sizer_my_devices->Layout();
802
803 if (m_my_devices_count != i) {
804 m_scrolledWindow->Fit();
805 }
806 m_scrolledWindow->Layout();
807 m_scrolledWindow->Thaw();
808 Layout();
809 Fit();
810 this->Thaw();
812}
std::map< std::string, MachineObject * > get_my_machine_list(const std::string &agent_id="")
Definition DevManager.cpp:824
void parse_user_print_info(std::string body)
Definition DevManager.cpp:894
bool set_selected_machine(std::string dev_id)
Definition DevManager.cpp:636
std::string get_current_printer_agent_id() const
Definition DevManager.cpp:192
int m_my_devices_count
Definition SelectMachinePop.hpp:185
static Plater * plater()
Definition GUI_Factories.cpp:400
@ OFFLINE
Definition SelectMachinePop.hpp:53
@ ALLOW_UNBIND
Definition SelectMachinePop.hpp:63
@ NONE
Definition SelectMachinePop.hpp:61

References Slic3r::DeviceManager::get_current_printer_agent_id(), Slic3r::DeviceManager::get_my_machine_list(), m_bind_machine_list, m_print_info, and Slic3r::DeviceManager::parse_user_print_info().

Referenced by update_machine_list().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ was_dismiss()

bool Slic3r::GUI::SelectMachinePopup::was_dismiss ( )
inline
182{ return m_dismiss; }

References m_dismiss.

Member Data Documentation

◆ get_print_info_thread

boost::thread* Slic3r::GUI::SelectMachinePopup::get_print_info_thread { nullptr }
private
201{ nullptr };

Referenced by OnDismiss(), and Popup().

◆ m_bind_machine_list

std::map<std::string, MachineObject*> Slic3r::GUI::SelectMachinePopup::m_bind_machine_list
private

◆ m_dismiss

bool Slic3r::GUI::SelectMachinePopup::m_dismiss { false }
private
204{ false };

Referenced by SelectMachinePopup(), OnDismiss(), and was_dismiss().

◆ m_free_machine_list

std::map<std::string, MachineObject*> Slic3r::GUI::SelectMachinePopup::m_free_machine_list
private

Referenced by update_other_devices().

◆ m_hyperlink

HyperLink* Slic3r::GUI::SelectMachinePopup::m_hyperlink {nullptr}
private
190{nullptr}; // ORCA

Referenced by OnLeftUp(), and update_other_devices().

◆ m_my_devices_count

int Slic3r::GUI::SelectMachinePopup::m_my_devices_count {0}
private
185{0};

◆ m_other_devices_count

int Slic3r::GUI::SelectMachinePopup::m_other_devices_count {0}
private
186{0};

Referenced by update_other_devices().

◆ m_other_list_machine_panel

std::vector<MachinePanel*> Slic3r::GUI::SelectMachinePopup::m_other_list_machine_panel
private

◆ m_panel_direct_connection

PinCodePanel* Slic3r::GUI::SelectMachinePopup::m_panel_direct_connection {nullptr}
private
188{nullptr};

Referenced by SelectMachinePopup(), and OnLeftUp().

◆ m_panel_ping_code

PinCodePanel* Slic3r::GUI::SelectMachinePopup::m_panel_ping_code {nullptr}
private
187{nullptr};

Referenced by SelectMachinePopup(), and OnLeftUp().

◆ m_placeholder_panel

wxWindow* Slic3r::GUI::SelectMachinePopup::m_placeholder_panel {nullptr}
private
189{nullptr};

Referenced by update_other_devices().

◆ m_print_info

std::string Slic3r::GUI::SelectMachinePopup::m_print_info = ""
private

Referenced by Popup(), and update_user_devices().

◆ m_refresh_timer

wxTimer* Slic3r::GUI::SelectMachinePopup::m_refresh_timer {nullptr}
private
198{nullptr};

Referenced by SelectMachinePopup(), ~SelectMachinePopup(), OnDismiss(), and Popup().

◆ m_scrolledWindow

wxScrolledWindow* Slic3r::GUI::SelectMachinePopup::m_scrolledWindow {nullptr}
private

◆ m_search_bar

wxSearchCtrl* Slic3r::GUI::SelectMachinePopup::m_search_bar {nullptr}
private
196{nullptr};

Referenced by SelectMachinePopup(), and search_for_printer().

◆ m_sizer_my_devices

wxBoxSizer* Slic3r::GUI::SelectMachinePopup::m_sizer_my_devices {nullptr}
private
191{nullptr};

Referenced by SelectMachinePopup().

◆ m_sizer_other_devices

wxBoxSizer* Slic3r::GUI::SelectMachinePopup::m_sizer_other_devices {nullptr}
private
192{nullptr};

Referenced by SelectMachinePopup(), and update_other_devices().

◆ m_token

std::shared_ptr<int> Slic3r::GUI::SelectMachinePopup::m_token = std::make_shared<int>(0)
private

Referenced by Popup().

◆ m_user_list_machine_panel

std::vector<MachinePanel*> Slic3r::GUI::SelectMachinePopup::m_user_list_machine_panel
private

Referenced by OnLeftUp(), and Show().


The documentation for this class was generated from the following files: