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

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

Inheritance diagram for Slic3r::GUI::SelectMObjectPopup:
Collaboration diagram for Slic3r::GUI::SelectMObjectPopup:

Public Member Functions

 SelectMObjectPopup (wxWindow *parent)
 ~SelectMObjectPopup ()
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)
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_user_devices ()
void on_dissmiss_win (wxCommandEvent &event)

Private Attributes

int m_my_devices_count { 0 }
bool m_dismiss { false }
wxBoxSizer * m_sizer_my_devices { nullptr }
wxScrolledWindow * m_scrolledWindow { nullptr }
wxTimer * m_refresh_timer { nullptr }
std::vector< MPanel * > m_user_list_machine_panel
boost::thread * get_print_info_thread { nullptr }
std::string m_print_info
std::shared_ptr< int > m_token = std::make_shared<int>(0)
std::map< std::string, MachineObject * > m_bind_machine_list

Detailed Description

Constructor & Destructor Documentation

◆ SelectMObjectPopup()

Slic3r::GUI::SelectMObjectPopup::SelectMObjectPopup ( wxWindow * parent)
219 :PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS), m_dismiss(false)
220{
221#ifdef __WINDOWS__
222 SetDoubleBuffered(true);
223#endif //__WINDOWS__
224
225
227 SetMinSize(SELECT_MACHINE_POPUP_SIZE);
228 SetMaxSize(SELECT_MACHINE_POPUP_SIZE);
229
230 Freeze();
231 wxBoxSizer* m_sizer_main = new wxBoxSizer(wxVERTICAL);
232 SetBackgroundColour(SELECT_MACHINE_GREY400);
233
234
235
236 m_scrolledWindow = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_LIST_SIZE, wxHSCROLL | wxVSCROLL);
237 m_scrolledWindow->SetBackgroundColour(*wxWHITE);
239 m_scrolledWindow->SetScrollRate(0, SELECT_MACHINE_ITEM_SIZE.y);
240 auto m_sizxer_scrolledWindow = new wxBoxSizer(wxVERTICAL);
241 m_scrolledWindow->SetSizer(m_sizxer_scrolledWindow);
242 m_scrolledWindow->Layout();
243 m_sizxer_scrolledWindow->Fit(m_scrolledWindow);
244
245 m_sizer_my_devices = new wxBoxSizer(wxVERTICAL);
246 m_sizxer_scrolledWindow->Add(m_sizer_my_devices, 0, wxEXPAND, 0);
247
248
249 m_sizer_main->Add(m_scrolledWindow, 0, wxALL | wxEXPAND, FromDIP(2));
250
251 SetSizer(m_sizer_main);
252 Layout();
253 Thaw();
254
255#ifdef __APPLE__
256 m_scrolledWindow->Bind(wxEVT_LEFT_UP, &SelectMObjectPopup::OnLeftUp, this);
257#endif // __APPLE__
258
259 m_refresh_timer = new wxTimer();
260 m_refresh_timer->SetOwner(this);
261 Bind(EVT_UPDATE_USER_MLIST, &SelectMObjectPopup::update_machine_list, this);
262 Bind(wxEVT_TIMER, &SelectMObjectPopup::on_timer, this);
263 Bind(EVT_DISSMISS_MACHINE_LIST, &SelectMObjectPopup::on_dissmiss_win, this);
264}
#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
void on_timer(wxTimerEvent &event)
Definition CalibrationPanel.cpp:341
void update_machine_list(wxCommandEvent &event)
Definition CalibrationPanel.cpp:452
void OnLeftUp(wxMouseEvent &event)
Definition CalibrationPanel.cpp:458
wxBoxSizer * m_sizer_my_devices
Definition CalibrationPanel.hpp:94
void on_dissmiss_win(wxCommandEvent &event)
Definition CalibrationPanel.cpp:447
wxScrolledWindow * m_scrolledWindow
Definition CalibrationPanel.hpp:95
bool m_dismiss
Definition CalibrationPanel.hpp:93
wxTimer * m_refresh_timer
Definition CalibrationPanel.hpp:96

References PopupWindow::PopupWindow(), m_dismiss, m_refresh_timer, m_scrolledWindow, m_sizer_my_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:

◆ ~SelectMObjectPopup()

Slic3r::GUI::SelectMObjectPopup::~SelectMObjectPopup ( )
266{ 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:

◆ on_dissmiss_win()

void Slic3r::GUI::SelectMObjectPopup::on_dissmiss_win ( wxCommandEvent & event)
private
448{
449 Dismiss();
450}

References on_dissmiss_win().

Referenced by SelectMObjectPopup(), 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::SelectMObjectPopup::on_timer ( wxTimerEvent & event)
private
342{
343 BOOST_LOG_TRIVIAL(trace) << "SelectMObjectPopup on_timer";
344 wxCommandEvent user_event(EVT_UPDATE_USER_MLIST);
345 user_event.SetEventObject(this);
346 wxPostEvent(this, user_event);
347}
void trace(unsigned int level, const char *message)
Definition utils.cpp:247

References Slic3r::trace().

Referenced by SelectMObjectPopup().

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

◆ OnDismiss()

void Slic3r::GUI::SelectMObjectPopup::OnDismiss ( )
virtual
307{
308 BOOST_LOG_TRIVIAL(trace) << "get_print_info: dismiss";
309 m_dismiss = true;
310
311 if (m_refresh_timer) {
312 m_refresh_timer->Stop();
313 }
315 if (get_print_info_thread->joinable()) {
316 get_print_info_thread->join();
318 get_print_info_thread = nullptr;
319 }
320 }
321
322 wxCommandEvent event(EVT_FINISHED_UPDATE_MLIST);
323 event.SetEventObject(this);
324 wxPostEvent(this, event);
325}
boost::thread * get_print_info_thread
Definition CalibrationPanel.hpp:98

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

Here is the call graph for this function:

◆ OnLeftUp()

void Slic3r::GUI::SelectMObjectPopup::OnLeftUp ( wxMouseEvent & event)
private
459{
460 auto mouse_pos = ClientToScreen(event.GetPosition());
461 auto wxscroll_win_pos = m_scrolledWindow->ClientToScreen(wxPoint(0, 0));
462
463 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) &&
464 mouse_pos.y < (wxscroll_win_pos.y + m_scrolledWindow->GetSize().y)) {
465
466 for (MPanel* p : m_user_list_machine_panel) {
467 auto p_rect = p->mPanel->ClientToScreen(wxPoint(0, 0));
468 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)) {
469 wxMouseEvent event(wxEVT_LEFT_UP);
470 auto tag_pos = p->mPanel->ScreenToClient(mouse_pos);
471 event.SetPosition(tag_pos);
472 event.SetEventObject(p->mPanel);
473 wxPostEvent(p->mPanel, event);
474 }
475 }
476 }
477}
std::vector< MPanel * > m_user_list_machine_panel
Definition CalibrationPanel.hpp:97
wxMouseEvent
Definition CameraPopup.cpp:47

References m_scrolledWindow, m_user_list_machine_panel, OnLeftUp(), and Slic3r::GUI::wxMouseEvent.

Referenced by SelectMObjectPopup(), and OnLeftUp().

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

◆ Popup()

void Slic3r::GUI::SelectMObjectPopup::Popup ( wxWindow * focus = NULL)
virtual
269{
270 BOOST_LOG_TRIVIAL(trace) << "get_print_info: start";
271 if (m_refresh_timer) {
272 m_refresh_timer->Stop();
274 }
275
276 const std::string provider = wxGetApp().get_printer_cloud_provider();
277 if (wxGetApp().is_user_login(provider)) {
279 get_print_info_thread = new boost::thread(Slic3r::create_thread([this, token = std::weak_ptr<int>(m_token), provider] {
280 NetworkAgent* agent = wxGetApp().getAgent();
281 unsigned int http_code;
282 std::string body;
283 int result = agent->get_user_print_info(&http_code, &body, provider);
284
285 wxGetApp().CallAfter([token, this, result, body]() {
286 if (token.expired()) {return;}
287 if (result == 0) {
288 m_print_info = body;
289 }
290 else {
291 m_print_info = "";
292 }
293
294 wxCommandEvent event(EVT_UPDATE_USER_MLIST);
295 event.SetEventObject(this);
296 wxPostEvent(this, event);
297 });
298 }));
299 }
300 }
301
302 wxPostEvent(this, wxTimerEvent(*m_refresh_timer));
303 PopupWindow::Popup();
304}
#define MACHINE_LIST_REFRESH_INTERVAL
Definition CalibrationPanel.cpp:47
std::string m_print_info
Definition CalibrationPanel.hpp:99
std::shared_ptr< int > m_token
Definition CalibrationPanel.hpp:100
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, and Slic3r::trace().

Here is the call graph for this function:

◆ ProcessLeftDown()

bool Slic3r::GUI::SelectMObjectPopup::ProcessLeftDown ( wxMouseEvent & event)
virtual
327 {
328 return PopupWindow::ProcessLeftDown(event);
329}

References Slic3r::GUI::wxMouseEvent.

◆ ShouldDismissOnTopWindowDeactivate()

virtual bool PopupWindow::ShouldDismissOnTopWindowDeactivate ( )
inlineprotectedvirtualinherited

Reimplemented in DropDown.

28{ return true; }

◆ Show()

bool Slic3r::GUI::SelectMObjectPopup::Show ( bool show = true)
virtual
331 {
332 if (show) {
333 for (int i = 0; i < m_user_list_machine_panel.size(); i++) {
334 m_user_list_machine_panel[i]->mPanel->update_machine_info(nullptr);
335 m_user_list_machine_panel[i]->mPanel->Hide();
336 }
337 }
338 return PopupWindow::Show(show);
339}

References m_user_list_machine_panel.

◆ update_machine_list()

void Slic3r::GUI::SelectMObjectPopup::update_machine_list ( wxCommandEvent & event)
453{
455 BOOST_LOG_TRIVIAL(trace) << "SelectMObjectPopup update_machine_list end";
456}
void update_user_devices()
Definition CalibrationPanel.cpp:349

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

Referenced by SelectMObjectPopup(), and 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::SelectMObjectPopup::update_user_devices ( )
private
350{
351 Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
352 if (!dev) return;
353
354 if (!m_print_info.empty()) {
356 m_print_info = "";
357 }
358
359 m_bind_machine_list.clear();
361
362 //sort list
363 std::vector<std::pair<std::string, MachineObject*>> user_machine_list;
364 for (auto& it : m_bind_machine_list) {
365 user_machine_list.push_back(it);
366 }
367
368 std::sort(user_machine_list.begin(), user_machine_list.end(), [&](auto& a, auto& b) {
369 if (a.second && b.second) {
370 return a.second->get_dev_name().compare(b.second->get_dev_name()) < 0;
371 }
372 return false;
373 });
374
375 BOOST_LOG_TRIVIAL(trace) << "SelectMObjectPopup update_machine_list start";
376 this->Freeze();
377 m_scrolledWindow->Freeze();
378 int i = 0;
379
380 for (auto& elem : user_machine_list) {
381 MachineObject* mobj = elem.second;
382 MObjectPanel* op = nullptr;
383 if (i < m_user_list_machine_panel.size()) {
384 op = m_user_list_machine_panel[i]->mPanel;
385 op->Show();
386 }
387 else {
388 op = new MObjectPanel(m_scrolledWindow, wxID_ANY);
389 MPanel* mpanel = new MPanel();
390 mpanel->mIndex = wxString::Format("%d", i);
391 mpanel->mPanel = op;
392 m_user_list_machine_panel.push_back(mpanel);
393 m_sizer_my_devices->Add(op, 0, wxEXPAND, 0);
394 }
395 i++;
396 op->update_machine_info(mobj, true);
397 //set in lan
398 if (mobj->is_lan_mode_printer()) {
399 if (!mobj->is_online()) {
400 continue;
401 }
402 else {
403 if (mobj->has_access_right() && mobj->is_avaliable()) {
404 op->set_printer_state(PrinterState::IN_LAN);
405 op->SetToolTip(_L("Online"));
406 }
407 else {
408 op->set_printer_state(PrinterState::LOCK);
409 }
410 }
411 }
412 else {
413 if (!mobj->is_online()) {
414 op->SetToolTip(_L("Offline"));
415 op->set_printer_state(PrinterState::OFFLINE);
416 }
417 else {
418 if (mobj->is_in_printing()) {
419 op->SetToolTip(_L("Busy"));
420 op->set_printer_state(PrinterState::BUSY);
421 }
422 else {
423 op->SetToolTip(_L("Online"));
424 op->set_printer_state(PrinterState::IDLE);
425 }
426 }
427 }
428 }
429
430 for (int j = i; j < m_user_list_machine_panel.size(); j++) {
431 m_user_list_machine_panel[j]->mPanel->update_machine_info(nullptr);
432 m_user_list_machine_panel[j]->mPanel->Hide();
433 }
434 //m_sizer_my_devices->Layout();
435
436 if (m_my_devices_count != i) {
437 m_scrolledWindow->Fit();
438 }
439 m_scrolledWindow->Layout();
440 m_scrolledWindow->Thaw();
441 Layout();
442 Fit();
443 this->Thaw();
445}
#define _L(s)
Definition OBJ.cpp:34
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
std::string get_current_printer_agent_id() const
Definition DevManager.cpp:192
std::map< std::string, MachineObject * > m_bind_machine_list
Definition CalibrationPanel.hpp:101
int m_my_devices_count
Definition CalibrationPanel.hpp:92
@ BUSY
Definition SelectMachinePop.hpp:55
@ IDLE
Definition SelectMachinePop.hpp:54
@ IN_LAN
Definition SelectMachinePop.hpp:57
@ OFFLINE
Definition SelectMachinePop.hpp:53
@ LOCK
Definition SelectMachinePop.hpp:56

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::SelectMObjectPopup::was_dismiss ( )
inline
89{ return m_dismiss; }

References m_dismiss.

Member Data Documentation

◆ get_print_info_thread

boost::thread* Slic3r::GUI::SelectMObjectPopup::get_print_info_thread { nullptr }
private
98{ nullptr };

Referenced by OnDismiss(), and Popup().

◆ m_bind_machine_list

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

Referenced by update_user_devices().

◆ m_dismiss

bool Slic3r::GUI::SelectMObjectPopup::m_dismiss { false }
private
93{ false };

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

◆ m_my_devices_count

int Slic3r::GUI::SelectMObjectPopup::m_my_devices_count { 0 }
private
92{ 0 };

◆ m_print_info

std::string Slic3r::GUI::SelectMObjectPopup::m_print_info
private

Referenced by Popup(), and update_user_devices().

◆ m_refresh_timer

wxTimer* Slic3r::GUI::SelectMObjectPopup::m_refresh_timer { nullptr }
private
96{ nullptr };

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

◆ m_scrolledWindow

wxScrolledWindow* Slic3r::GUI::SelectMObjectPopup::m_scrolledWindow { nullptr }
private
95{ nullptr };

Referenced by SelectMObjectPopup(), and OnLeftUp().

◆ m_sizer_my_devices

wxBoxSizer* Slic3r::GUI::SelectMObjectPopup::m_sizer_my_devices { nullptr }
private
94{ nullptr };

Referenced by SelectMObjectPopup().

◆ m_token

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

Referenced by Popup().

◆ m_user_list_machine_panel

std::vector<MPanel*> Slic3r::GUI::SelectMObjectPopup::m_user_list_machine_panel
private

Referenced by OnLeftUp(), and Show().


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