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

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

Inheritance diagram for Slic3r::GUI::FilamentGroupPopup:
Collaboration diagram for Slic3r::GUI::FilamentGroupPopup:

Public Member Functions

 FilamentGroupPopup (wxWindow *parent)
 ~FilamentGroupPopup () override
void tryPopup (Plater *plater, PartPlate *plate, bool slice_all)
void tryClose ()
void Dismiss () override
FilamentMapMode GetSelectedMode () const
bool Create (wxWindow *parent, int flags=wxBORDER_NONE)

Protected Member Functions

virtual bool ShouldDismissOnTopWindowDeactivate ()

Private Types

enum  ButtonType { btForFlush , btForMatch , btManual , btCount }

Private Member Functions

void OnPaint (wxPaintEvent &event)
void StartTimer ()
void ResetTimer ()
void OnRadioBtn (int idx)
void OnLeaveWindow (wxMouseEvent &)
void OnEnterWindow (wxMouseEvent &)
void OnTimer (wxTimerEvent &event)
void CreateBmps ()
void Init ()
void UpdateButtonStatus (int hover_idx=-1)
void DrawRoundedCorner (int radius)
void MakeSmartFilamentSection (wxSizer *top_sizer, int horizontal_margin, int vertical_padding)
void UpdateSmartFilamentSection ()
void OnSmartFilamentToggle (wxCommandEvent &event)
FilamentMapMode GetFilamentMapMode () const
void SetFilamentMapMode (const FilamentMapMode mode)

Private Attributes

const std::vector< FilamentMapMode > mode_list = {fmmAutoForFlush, fmmAutoForMatch, fmmManual}
bool m_connected { false }
bool m_active { false }
bool m_sync_plate { false }
bool m_slice_all { false }
FilamentMapMode m_mode
wxTimer * m_timer
std::vector< wxBitmapButton * > radio_btns
std::vector< Label * > button_labels
std::vector< Label * > button_desps
std::vector< Label * > detail_infos
wxBitmap checked_bmp
wxBitmap unchecked_bmp
wxBitmap disabled_bmp
wxBitmap checked_hover_bmp
wxBitmap unchecked_hover_bmp
wxBitmap global_tag_bmp
StaticBox * m_smart_filament_panel {nullptr}
wxSizerItem * m_smart_filament_spacer {nullptr}
SwitchButton * m_smart_filament_switch {nullptr}
PartPlate * partplate_ref { nullptr }
Plater * plater_ref { nullptr }

Detailed Description

Member Enumeration Documentation

◆ ButtonType

Enumerator
btForFlush 
btForMatch 
btManual 
btCount 
@ btManual
Definition FilamentGroupPopup.hpp:60
@ btForFlush
Definition FilamentGroupPopup.hpp:60
@ btCount
Definition FilamentGroupPopup.hpp:60
@ btForMatch
Definition FilamentGroupPopup.hpp:60

Constructor & Destructor Documentation

◆ FilamentGroupPopup()

Slic3r::GUI::FilamentGroupPopup::FilamentGroupPopup ( wxWindow * parent)
112 : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS)
113{
114 const wxString AutoForFlushLabel = _L("Filament-Saving Mode");
115 const wxString AutoForMatchLabel = _L("Convenience Mode");
116 const wxString ManualLabel = _L("Custom Mode");
117
118 const wxString AutoForFlushDetail = _L("Generates filament grouping for the left and right nozzles based on the most filament-saving principles to minimize waste.");
119 const wxString AutoForMatchDetail = _L("Generates filament grouping for the left and right nozzles based on the printer's actual filament status, reducing the need for manual filament adjustment.");
120 const wxString ManualDetail = _L("Manually assign filament to the left or right nozzle");
121
122 const wxString AutoForFlushDesp = ""; //_L("(Post-slicing arrangement)");
123 const wxString ManualDesp = "";
124 const wxString AutoForMatchDesp = "";// _L("(Pre-slicing arrangement)");
125
126
127 wxBoxSizer *top_sizer = new wxBoxSizer(wxVERTICAL);
128 const int horizontal_margin = FromDIP(16);
129 const int vertical_margin = FromDIP(15);
130 const int vertical_padding = FromDIP(12);
131 const int ratio_spacing = FromDIP(4);
132
133 SetBackgroundColour(BackGroundColor);
134
139 //global_mode_tags.resize(ButtonType::btCount);
140
141 std::vector<wxString> btn_texts = {AutoForFlushLabel, AutoForMatchLabel, ManualLabel};
142 std::vector<wxString> btn_desps = {AutoForFlushDesp, AutoForMatchDesp, ManualDesp};
143 std::vector<wxString> mode_details = {AutoForFlushDetail, AutoForMatchDetail, ManualDetail};
144
145 top_sizer->AddSpacer(vertical_margin);
146 CreateBmps();
147
148 for (size_t idx = 0; idx < ButtonType::btCount; ++idx) {
149 wxBoxSizer *button_sizer = new wxBoxSizer(wxHORIZONTAL);
150 radio_btns[idx] = new wxBitmapButton(this, wxID_ANY, unchecked_bmp, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
151 radio_btns[idx]->SetBackgroundColour(BackGroundColor);
152
153 button_labels[idx] = new Label(this, btn_texts[idx]);
154 button_labels[idx]->SetBackgroundColour(BackGroundColor);
155 button_labels[idx]->SetForegroundColour(LabelEnableColor);
156 button_labels[idx]->SetFont(Label::Body_14);
157
158 button_desps[idx] = new Label(this, btn_desps[idx]);
159 button_desps[idx]->SetBackgroundColour(BackGroundColor);
160 button_desps[idx]->SetForegroundColour(LabelEnableColor);
161 button_desps[idx]->SetFont(Label::Body_14);
162
163#if 0
164 global_mode_tags[idx] = new wxBitmapButton(this, wxID_ANY, global_tag_bmp, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
165 global_mode_tags[idx]->SetBackgroundColour(BackGroundColor);
166 global_mode_tags[idx]->SetToolTip(_L("Global settings"));
167#endif
168 button_sizer->Add(radio_btns[idx], 0, wxALIGN_CENTER);
169 button_sizer->AddSpacer(ratio_spacing);
170 button_sizer->Add(button_labels[idx], 0, wxALIGN_CENTER);
171 button_sizer->Add(button_desps[idx], 0, wxALIGN_CENTER);
172 //button_sizer->AddSpacer(ratio_spacing);
173 //button_sizer->Add(global_mode_tags[idx], 0, wxALIGN_CENTER);
174
175 wxBoxSizer *label_sizer = new wxBoxSizer(wxHORIZONTAL);
176
177 detail_infos[idx] = new Label(this, mode_details[idx]);
178 detail_infos[idx]->SetBackgroundColour(BackGroundColor);
179 detail_infos[idx]->SetForegroundColour(GreyColor);
180 detail_infos[idx]->SetFont(Label::Body_12);
181 detail_infos[idx]->Wrap(FromDIP(320));
182
183 label_sizer->AddSpacer(radio_btns[idx]->GetRect().width + ratio_spacing);
184 label_sizer->Add(detail_infos[idx], 1, wxALIGN_CENTER_VERTICAL);
185
186 top_sizer->Add(button_sizer, 0, wxLEFT | wxRIGHT, horizontal_margin);
187 top_sizer->Add(label_sizer, 0, wxLEFT | wxRIGHT, horizontal_margin);
188 top_sizer->AddSpacer(vertical_padding);
189
190 radio_btns[idx]->Bind(wxEVT_LEFT_DOWN, [this, idx](auto &) { OnRadioBtn(idx);});
191
192 radio_btns[idx]->Bind(wxEVT_ENTER_WINDOW, [this, idx](auto &) { UpdateButtonStatus(idx); });
193 radio_btns[idx]->Bind(wxEVT_LEAVE_WINDOW, [this](auto &) { UpdateButtonStatus(); });
194
195 button_labels[idx]->Bind(wxEVT_LEFT_DOWN, [this, idx](auto &) { OnRadioBtn(idx);});
196 button_labels[idx]->Bind(wxEVT_ENTER_WINDOW, [this, idx](auto &) { UpdateButtonStatus(idx); });
197 button_labels[idx]->Bind(wxEVT_LEAVE_WINDOW, [this](auto &) { UpdateButtonStatus(); });
198 }
199
200 // Smart filament assign section
201 MakeSmartFilamentSection(top_sizer, horizontal_margin, vertical_padding);
202
203 {
204 wxBoxSizer *button_sizer = new wxBoxSizer(wxHORIZONTAL);
205 // ORCA Unified hyperlinks
206
207 auto wiki_btn = new Button(this, "", "toolbar_wiki", 0, 15);
208 wiki_btn->SetToolTip(_L("Wiki Guide") + "\n" + "https://e.bambulab.com/t?c=mOkvsXkJ9pldGYp9");
209 wiki_btn->SetStyle(ButtonStyle::Confirm, ::ButtonType::Circle);
210 wiki_btn->SetCanFocus(false);
211 wiki_btn->Bind(wxEVT_LEFT_DOWN, ([](auto& e) {open_filament_group_wiki();}));
212
213 auto video_btn = new Button(this, "", "toolbar_video_guide", 0, 15);
214 video_btn->SetToolTip(_L("Video Guide"));
215 video_btn->SetStyle(ButtonStyle::Confirm, ::ButtonType::Circle);
216 video_btn->SetCanFocus(false);
217 video_btn->Bind(wxEVT_LEFT_DOWN, ([](auto& e) {
219 wxGetApp().app_config->set("play_slicing_video", "false");
220 }));
221
222 button_sizer->Add(wiki_btn , 0, wxLEFT, horizontal_margin + FromDIP(3));
223 button_sizer->Add(video_btn, 0, wxLEFT, FromDIP(10));
224
225 top_sizer->Add(button_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, horizontal_margin);
226 }
227
228 top_sizer->AddSpacer(vertical_margin);
229 SetSizerAndFit(top_sizer);
230
232 m_timer = new wxTimer(this);
233
234 GUI::wxGetApp().UpdateDarkUIWin(this);
235
236 Bind(wxEVT_PAINT, &FilamentGroupPopup::OnPaint, this);
237 Bind(wxEVT_TIMER, &FilamentGroupPopup::OnTimer, this);
238 Bind(wxEVT_ENTER_WINDOW, &FilamentGroupPopup::OnEnterWindow, this);
239 Bind(wxEVT_LEAVE_WINDOW, &FilamentGroupPopup::OnLeaveWindow, this);
240}
@ Confirm
Definition Button.hpp:25
@ Circle
Definition Button.hpp:37
#define _L(s)
Definition OBJ.cpp:34
static wxFont Body_12
Definition Label.hpp:55
static wxFont Body_14
Definition Label.hpp:53
PopupWindow()
Definition PopupWindow.hpp:10
std::vector< Label * > detail_infos
Definition FilamentGroupPopup.hpp:75
wxTimer * m_timer
Definition FilamentGroupPopup.hpp:70
void UpdateButtonStatus(int hover_idx=-1)
Definition FilamentGroupPopup.cpp:424
std::vector< Label * > button_desps
Definition FilamentGroupPopup.hpp:74
void OnLeaveWindow(wxMouseEvent &)
Definition FilamentGroupPopup.cpp:406
void OnRadioBtn(int idx)
Definition FilamentGroupPopup.cpp:362
FilamentMapMode m_mode
Definition FilamentGroupPopup.hpp:69
std::vector< Label * > button_labels
Definition FilamentGroupPopup.hpp:73
std::vector< wxBitmapButton * > radio_btns
Definition FilamentGroupPopup.hpp:72
wxBitmap global_tag_bmp
Definition FilamentGroupPopup.hpp:82
void OnTimer(wxTimerEvent &event)
Definition FilamentGroupPopup.cpp:374
void CreateBmps()
Definition FilamentGroupPopup.cpp:103
wxBitmap unchecked_bmp
Definition FilamentGroupPopup.hpp:78
void MakeSmartFilamentSection(wxSizer *top_sizer, int horizontal_margin, int vertical_padding)
Definition FilamentGroupPopup.cpp:457
void OnEnterWindow(wxMouseEvent &)
Definition FilamentGroupPopup.cpp:413
void OnPaint(wxPaintEvent &event)
Definition FilamentGroupPopup.cpp:350
bool open_filament_group_wiki()
Definition FilamentGroupPopup.cpp:93
bool play_dual_extruder_slice_video()
Definition FilamentGroupPopup.cpp:72
static const wxColour LabelEnableColor
Definition FilamentGroupPopup.cpp:34
static FilamentMapMode get_prefered_map_mode()
Definition FilamentGroupPopup.cpp:48
static const wxColour BackGroundColor
Definition FilamentGroupPopup.cpp:37
static const wxColour GreyColor
Definition FilamentGroupPopup.cpp:36

References PopupWindow::PopupWindow(), _L, Slic3r::GUI::BackGroundColor, Label::Body_12, Label::Body_14, btCount, button_desps, button_labels, Circle, Confirm, CreateBmps(), detail_infos, Slic3r::GUI::get_prefered_map_mode(), global_tag_bmp, Slic3r::GUI::GreyColor, Slic3r::GUI::LabelEnableColor, m_mode, m_timer, MakeSmartFilamentSection(), OnEnterWindow(), OnLeaveWindow(), OnPaint(), OnRadioBtn(), OnTimer(), Slic3r::GUI::open_filament_group_wiki(), Slic3r::GUI::play_dual_extruder_slice_video(), radio_btns, unchecked_bmp, and UpdateButtonStatus().

Here is the call graph for this function:

◆ ~FilamentGroupPopup()

Slic3r::GUI::FilamentGroupPopup::~FilamentGroupPopup ( )
override
395{
396 m_timer->Stop();
397 delete m_timer;
398}

References m_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:

◆ CreateBmps()

void Slic3r::GUI::FilamentGroupPopup::CreateBmps ( )
private
104{
105 checked_bmp = create_scaled_bitmap("radio_on", nullptr, 16);; // ORCA match icons
106 unchecked_bmp = create_scaled_bitmap("radio_off", nullptr, 16);
107 disabled_bmp = create_scaled_bitmap("radio_disabled", nullptr, 16);
108 checked_hover_bmp = create_scaled_bitmap("radio_on_hover", nullptr, 16);
109 unchecked_hover_bmp = create_scaled_bitmap("radio_off_hover", nullptr, 16);
110}
wxBitmap unchecked_hover_bmp
Definition FilamentGroupPopup.hpp:81
wxBitmap checked_hover_bmp
Definition FilamentGroupPopup.hpp:80
wxBitmap checked_bmp
Definition FilamentGroupPopup.hpp:77
wxBitmap disabled_bmp
Definition FilamentGroupPopup.hpp:79
wxBitmap create_scaled_bitmap(const std::string &bmp_name_in, wxWindow *win, const int px_cnt, const bool grayscale, const std::string &new_color, const bool menu_bitmap, const bool resize, const bool bitmap2, const std::vector< std::string > &array_new_color)
Definition wxExtensions.cpp:448

References checked_bmp, checked_hover_bmp, create_scaled_bitmap(), disabled_bmp, unchecked_bmp, and unchecked_hover_bmp.

Referenced by FilamentGroupPopup(), and Init().

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

◆ Dismiss()

void Slic3r::GUI::FilamentGroupPopup::Dismiss ( )
override
400 {
401 m_active = false;
402 PopupWindow::Dismiss();
403 m_timer->Stop();
404}
bool m_active
Definition FilamentGroupPopup.hpp:65

References m_active, and m_timer.

Referenced by OnTimer().

Here is the caller graph for this function:

◆ DrawRoundedCorner()

void Slic3r::GUI::FilamentGroupPopup::DrawRoundedCorner ( int radius)
private
243{
244#ifdef __WIN32__
245 HWND hwnd = GetHWND();
246 if (hwnd) {
247 HRGN hrgn = CreateRoundRectRgn(0, 0, GetRect().GetWidth(), GetRect().GetHeight(), radius, radius);
248 SetWindowRgn(hwnd, hrgn, FALSE);
249
250 SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
251 SetLayeredWindowAttributes(hwnd, 0, 0, LWA_COLORKEY);
252 }
253#endif
254}

Referenced by OnPaint(), and tryPopup().

Here is the caller graph for this function:

◆ GetFilamentMapMode()

FilamentMapMode Slic3r::GUI::FilamentGroupPopup::GetFilamentMapMode ( ) const
private
322{
323 const auto& proj_config = wxGetApp().preset_bundle->project_config;
324 if (m_sync_plate)
325 return partplate_ref->get_real_filament_map_mode(proj_config);
326
327 return plater_ref->get_global_filament_map_mode();
328}
PartPlate * partplate_ref
Definition FilamentGroupPopup.hpp:88
bool m_sync_plate
Definition FilamentGroupPopup.hpp:67
Plater * plater_ref
Definition FilamentGroupPopup.hpp:89

References m_sync_plate, partplate_ref, and plater_ref.

Referenced by Init().

Here is the caller graph for this function:

◆ GetSelectedMode()

FilamentMapMode Slic3r::GUI::FilamentGroupPopup::GetSelectedMode ( ) const
inline
35{ return m_mode; }

References m_mode.

◆ Init()

void Slic3r::GUI::FilamentGroupPopup::Init ( )
private
257{
258 static bool is_dark_mode = wxGetApp().dark_mode();
259 if (is_dark_mode != wxGetApp().dark_mode()) {
260 CreateBmps();
261 is_dark_mode = wxGetApp().dark_mode();
262 }
263
264 const wxString AutoForMatchDesp = "";// _L("(Pre-slicing arrangement)");
265 const wxString MachineSyncTip = _L("(Sync with printer)");
266
267 if (m_connected) {
270 detail_infos[ButtonType::btForMatch]->SetForegroundColour(GreyColor);
272 button_desps[ButtonType::btForMatch]->SetLabel(AutoForMatchDesp);
273 }
274 else {
279 button_desps[ButtonType::btForMatch]->SetLabel(MachineSyncTip);
280 }
281
286 }
287 else if (m_slice_all) {
288 // reset the filament map mode in slice all mode
290 }
291
294 GUI::wxGetApp().UpdateDarkUIWin(this);
295}
bool m_connected
Definition FilamentGroupPopup.hpp:64
bool m_slice_all
Definition FilamentGroupPopup.hpp:68
void SetFilamentMapMode(const FilamentMapMode mode)
Definition FilamentGroupPopup.cpp:330
FilamentMapMode GetFilamentMapMode() const
Definition FilamentGroupPopup.cpp:321
void UpdateSmartFilamentSection()
Definition FilamentGroupPopup.cpp:505
static const wxColour LabelDisableColor
Definition FilamentGroupPopup.cpp:35
@ fmmAutoForMatch
Definition PrintConfig.hpp:634
@ fmmAutoForFlush
Definition PrintConfig.hpp:633

References _L, btForMatch, button_desps, button_labels, CreateBmps(), detail_infos, disabled_bmp, Slic3r::fmmAutoForFlush, Slic3r::fmmAutoForMatch, GetFilamentMapMode(), Slic3r::GUI::GreyColor, Slic3r::GUI::LabelDisableColor, Slic3r::GUI::LabelEnableColor, m_connected, m_mode, m_slice_all, radio_btns, SetFilamentMapMode(), unchecked_bmp, UpdateButtonStatus(), and UpdateSmartFilamentSection().

Referenced by tryPopup().

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

◆ MakeSmartFilamentSection()

void Slic3r::GUI::FilamentGroupPopup::MakeSmartFilamentSection ( wxSizer * top_sizer,
int horizontal_margin,
int vertical_padding )
private
458{
459 m_smart_filament_panel = new StaticBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
460 m_smart_filament_panel->SetCornerRadius(FromDIP(4));
461 m_smart_filament_panel->SetBorderWidth(FromDIP(1));
462 m_smart_filament_panel->SetBorderColor(wxColour("#CECECE"));
463 m_smart_filament_panel->SetBackgroundColor(StateColor(std::pair<wxColour, int>(wxColour("#F8F8F8"), StateColor::Normal)));
464
465 auto *label = new Label(m_smart_filament_panel, _L("Enable smart filament assign: Assign one filament to multiple nozzles to maximize savings"));
466 label->SetFont(Label::Body_12);
467 label->SetForegroundColour(GreyColor);
468 label->SetBackgroundColour(wxColour("#F8F8F8"));
469 label->Wrap(FromDIP(240));
470
473#ifdef __WXOSX__
474 // wxEVT_TOGGLEBUTTON event not handled well by PopupWindow on MacOS
475 // we bind a wxEVT_LEFT_DOWN event as a workaround
476 m_smart_filament_switch->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &) {
477 wxCommandEvent evt(wxEVT_TOGGLEBUTTON);
478 evt.SetInt(!m_smart_filament_switch->GetValue());
479 m_smart_filament_switch->Command(evt);
480 });
481#endif
482
483 auto *panel_sizer = new wxBoxSizer(wxHORIZONTAL);
484 panel_sizer->Add(label, 1, wxALIGN_CENTER_VERTICAL | wxALL, FromDIP(10));
485 panel_sizer->Add(m_smart_filament_switch, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, FromDIP(10));
486 m_smart_filament_panel->SetSizer(panel_sizer);
487
488 top_sizer->Add(m_smart_filament_panel, 0, wxEXPAND | wxLEFT | wxRIGHT, horizontal_margin);
489 m_smart_filament_spacer = top_sizer->AddSpacer(vertical_padding);
490
491 // Hidden by default; shown in Init() when the filament track switch is ready
492 m_smart_filament_panel->Show(false);
493 m_smart_filament_spacer->Show(false);
494}
wxSizerItem * m_smart_filament_spacer
Definition FilamentGroupPopup.hpp:85
SwitchButton * m_smart_filament_switch
Definition FilamentGroupPopup.hpp:86
StaticBox * m_smart_filament_panel
Definition FilamentGroupPopup.hpp:84
void OnSmartFilamentToggle(wxCommandEvent &event)
Definition FilamentGroupPopup.cpp:496
@ Normal
Definition StateColor.hpp:16
wxMouseEvent
Definition CameraPopup.cpp:47

References _L, Label::Body_12, Slic3r::GUI::GreyColor, m_smart_filament_panel, m_smart_filament_spacer, m_smart_filament_switch, StateColor::Normal, OnSmartFilamentToggle(), and Slic3r::GUI::wxMouseEvent.

Referenced by FilamentGroupPopup().

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

◆ OnEnterWindow()

void Slic3r::GUI::FilamentGroupPopup::OnEnterWindow ( wxMouseEvent & )
private
414{
415 // Ignore spurious ENTER synthesized by PopupWindow::OnMouseEvent2 on macOS.
416 wxPoint pos = this->ScreenToClient(wxGetMousePosition());
417 if (!this->GetClientRect().Contains(pos)) return;
418 // On macOS the timer keeps running instead, and OnTimer closes the popup once the cursor has left it.
419#ifndef __APPLE__
420 ResetTimer();
421#endif
422}
void ResetTimer()
Definition FilamentGroupPopup.cpp:357
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References ResetTimer(), and Slic3r::GUI::wxMouseEvent.

Referenced by FilamentGroupPopup().

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

◆ OnLeaveWindow()

void Slic3r::GUI::FilamentGroupPopup::OnLeaveWindow ( wxMouseEvent & )
private
407{
408 wxPoint pos = this->ScreenToClient(wxGetMousePosition());
409 if (this->GetClientRect().Contains(pos)) return;
410 StartTimer();
411}
void StartTimer()
Definition FilamentGroupPopup.cpp:355

References StartTimer(), and Slic3r::GUI::wxMouseEvent.

Referenced by FilamentGroupPopup().

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

◆ OnPaint()

void Slic3r::GUI::FilamentGroupPopup::OnPaint ( wxPaintEvent & event)
private
351{
353}
void DrawRoundedCorner(int radius)
Definition FilamentGroupPopup.cpp:242

References DrawRoundedCorner().

Referenced by FilamentGroupPopup().

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

◆ OnRadioBtn()

void Slic3r::GUI::FilamentGroupPopup::OnRadioBtn ( int idx)
private
363{
365 return;
366 if (m_mode != mode_list.at(idx)) {
367 m_mode = mode_list.at(idx);
369 plater_ref->update();
371 }
372}
const std::vector< FilamentMapMode > mode_list
Definition FilamentGroupPopup.hpp:62

References Slic3r::fmmAutoForMatch, m_connected, m_mode, mode_list, plater_ref, SetFilamentMapMode(), and UpdateButtonStatus().

Referenced by FilamentGroupPopup().

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

◆ OnSmartFilamentToggle()

void Slic3r::GUI::FilamentGroupPopup::OnSmartFilamentToggle ( wxCommandEvent & event)
private
497{
498 auto &config = wxGetApp().preset_bundle->project_config;
499 auto *dynamic_filament = dynamic_cast<ConfigOptionBool *>(config.option("enable_filament_dynamic_map"));
500 if (dynamic_filament) { dynamic_filament->value = m_smart_filament_switch->GetValue(); }
501 plater_ref->update();
502 event.Skip();
503}

References m_smart_filament_switch, and plater_ref.

Referenced by MakeSmartFilamentSection().

Here is the caller graph for this function:

◆ OnTimer()

void Slic3r::GUI::FilamentGroupPopup::OnTimer ( wxTimerEvent & event)
private
375{
376#if __APPLE__
377 // On macOS, when moving cursor from slice button to this popup window,
378 // the popup window entering event is triggered first, then the slice button
379 // leaving event got triggered. So the timer is stopped first, then started
380 // again, causing the popup being dismissed immediately.
381 // To fix this, we check if cursor is still inside the popup window before
382 // dismissing, and keep checking while it is: a leave event is not guaranteed
383 // to follow, and a popup left open keeps grabbing the mouse capture.
384 wxPoint pos = this->ScreenToClient(wxGetMousePosition());
385 if (this->GetClientRect().Contains(pos)) {
386 StartTimer();
387 return;
388 }
389#endif
390
391 Dismiss();
392}
void Dismiss() override
Definition FilamentGroupPopup.cpp:400

References Dismiss(), and StartTimer().

Referenced by FilamentGroupPopup().

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

◆ ResetTimer()

void Slic3r::GUI::FilamentGroupPopup::ResetTimer ( )
private
358{
359 if (m_timer->IsRunning()) { m_timer->Stop(); }
360}

References m_timer.

Referenced by OnEnterWindow(), and tryPopup().

Here is the caller graph for this function:

◆ SetFilamentMapMode()

void Slic3r::GUI::FilamentGroupPopup::SetFilamentMapMode ( const FilamentMapMode mode)
private
331{
332 if (m_sync_plate) {
333 if (m_slice_all) {
334 auto plate_list = plater_ref->get_partplate_list().get_plate_list();
335 for (int i = 0; i < plate_list.size(); ++i) {
336 plate_list[i]->set_filament_map_mode(mode);
337 }
338 }
339 else {
340 partplate_ref->set_filament_map_mode(mode);
341 }
342 return;
343 }
344 plater_ref->set_global_filament_map_mode(mode);
345}

References m_slice_all, m_sync_plate, partplate_ref, and plater_ref.

Referenced by Init(), and OnRadioBtn().

Here is the caller graph for this function:

◆ ShouldDismissOnTopWindowDeactivate()

virtual bool PopupWindow::ShouldDismissOnTopWindowDeactivate ( )
inlineprotectedvirtualinherited

Reimplemented in DropDown.

28{ return true; }

◆ StartTimer()

void Slic3r::GUI::FilamentGroupPopup::StartTimer ( )
private
355{ m_timer->StartOnce(300); }

References m_timer.

Referenced by OnLeaveWindow(), OnTimer(), and tryClose().

Here is the caller graph for this function:

◆ tryClose()

void Slic3r::GUI::FilamentGroupPopup::tryClose ( )
348{ StartTimer(); }

References StartTimer().

Here is the call graph for this function:

◆ tryPopup()

void Slic3r::GUI::FilamentGroupPopup::tryPopup ( Plater * plater,
PartPlate * plate,
bool slice_all )
298{
299 if (should_pop_up()) {
300 bool connect_status = plater->get_machine_sync_status();
301 this->partplate_ref = partplate;
302 this->plater_ref = plater;
303 this->m_sync_plate = true;
304 this->m_slice_all = slice_all;
305 if (m_active) {
306 if (m_connected != connect_status) { Init(); }
307 m_connected = connect_status;
308 ResetTimer();
309 }
310 else {
311 m_connected = connect_status;
312 m_active = true;
313 Init();
314 ResetTimer();
316 PopupWindow::Popup();
317 }
318 }
319}
void Init()
Definition FilamentGroupPopup.cpp:256
bool get_machine_sync_status()
Definition Plater.cpp:23761
static Plater * plater()
Definition GUI_Factories.cpp:400
static bool should_pop_up()
Definition FilamentGroupPopup.cpp:39

References DrawRoundedCorner(), Init(), m_active, m_connected, m_slice_all, m_sync_plate, partplate_ref, Slic3r::GUI::plater(), plater_ref, ResetTimer(), and Slic3r::GUI::should_pop_up().

Here is the call graph for this function:

◆ UpdateButtonStatus()

void Slic3r::GUI::FilamentGroupPopup::UpdateButtonStatus ( int hover_idx = -1)
private
425{
426 for (int i = 0; i < ButtonType::btCount; ++i) {
427#if 0 // do not display global mode tag
428 if (mode_list.at(i) == global_mode)
429 global_mode_tags[i]->Show();
430 else
431 global_mode_tags[i]->Hide();
432#endif
433 if (ButtonType::btForMatch == i && !m_connected) {
434 button_labels[i]->SetFont(Label::Body_14);
435 continue;
436 }
437 // process checked and unchecked status
438 if (mode_list.at(i) == m_mode) {
439 if (i == hover_idx)
440 radio_btns[i]->SetBitmap(checked_hover_bmp);
441 else
442 radio_btns[i]->SetBitmap(checked_bmp);
443 button_labels[i]->SetFont(Label::Head_14);
444 } else {
445 if (i == hover_idx)
446 radio_btns[i]->SetBitmap(unchecked_hover_bmp);
447 else
448 radio_btns[i]->SetBitmap(unchecked_bmp);
449 button_labels[i]->SetFont(Label::Body_14);
450 }
451 }
452
453 Layout();
454 Fit();
455}
static wxFont Head_14
Definition Label.hpp:45

References Label::Body_14, btCount, btForMatch, button_labels, checked_bmp, checked_hover_bmp, Label::Head_14, m_connected, m_mode, mode_list, radio_btns, unchecked_bmp, and unchecked_hover_bmp.

Referenced by FilamentGroupPopup(), Init(), and OnRadioBtn().

Here is the caller graph for this function:

◆ UpdateSmartFilamentSection()

void Slic3r::GUI::FilamentGroupPopup::UpdateSmartFilamentSection ( )
private
506{
507 bool show = wxGetApp().sidebar().is_fila_switch_ready();
508 m_smart_filament_panel->Show(show);
509 m_smart_filament_spacer->Show(show);
510
511 if (show) {
512 auto &config = wxGetApp().preset_bundle->project_config;
513 auto *dynamic_filament = dynamic_cast<ConfigOptionBool *>(config.option("enable_filament_dynamic_map"));
514 if (dynamic_filament) { m_smart_filament_switch->SetValue(dynamic_filament->value); }
515 }
516}

References m_smart_filament_panel, m_smart_filament_spacer, and m_smart_filament_switch.

Referenced by Init().

Here is the caller graph for this function:

Member Data Documentation

◆ button_desps

std::vector<Label *> Slic3r::GUI::FilamentGroupPopup::button_desps
private

Referenced by FilamentGroupPopup(), and Init().

◆ button_labels

std::vector<Label *> Slic3r::GUI::FilamentGroupPopup::button_labels
private

◆ checked_bmp

wxBitmap Slic3r::GUI::FilamentGroupPopup::checked_bmp
private

Referenced by CreateBmps(), and UpdateButtonStatus().

◆ checked_hover_bmp

wxBitmap Slic3r::GUI::FilamentGroupPopup::checked_hover_bmp
private

Referenced by CreateBmps(), and UpdateButtonStatus().

◆ detail_infos

std::vector<Label *> Slic3r::GUI::FilamentGroupPopup::detail_infos
private

Referenced by FilamentGroupPopup(), and Init().

◆ disabled_bmp

wxBitmap Slic3r::GUI::FilamentGroupPopup::disabled_bmp
private

Referenced by CreateBmps(), and Init().

◆ global_tag_bmp

wxBitmap Slic3r::GUI::FilamentGroupPopup::global_tag_bmp
private

Referenced by FilamentGroupPopup().

◆ m_active

bool Slic3r::GUI::FilamentGroupPopup::m_active { false }
private
65{ false };

Referenced by Dismiss(), and tryPopup().

◆ m_connected

bool Slic3r::GUI::FilamentGroupPopup::m_connected { false }
private
64{ false };

Referenced by Init(), OnRadioBtn(), tryPopup(), and UpdateButtonStatus().

◆ m_mode

FilamentMapMode Slic3r::GUI::FilamentGroupPopup::m_mode
private

◆ m_slice_all

bool Slic3r::GUI::FilamentGroupPopup::m_slice_all { false }
private
68{ false };

Referenced by Init(), SetFilamentMapMode(), and tryPopup().

◆ m_smart_filament_panel

StaticBox* Slic3r::GUI::FilamentGroupPopup::m_smart_filament_panel {nullptr}
private
84{nullptr};

Referenced by MakeSmartFilamentSection(), and UpdateSmartFilamentSection().

◆ m_smart_filament_spacer

wxSizerItem* Slic3r::GUI::FilamentGroupPopup::m_smart_filament_spacer {nullptr}
private
85{nullptr};

Referenced by MakeSmartFilamentSection(), and UpdateSmartFilamentSection().

◆ m_smart_filament_switch

SwitchButton* Slic3r::GUI::FilamentGroupPopup::m_smart_filament_switch {nullptr}
private

◆ m_sync_plate

bool Slic3r::GUI::FilamentGroupPopup::m_sync_plate { false }
private
67{ false };

Referenced by GetFilamentMapMode(), SetFilamentMapMode(), and tryPopup().

◆ m_timer

wxTimer* Slic3r::GUI::FilamentGroupPopup::m_timer
private

◆ mode_list

const std::vector<FilamentMapMode> Slic3r::GUI::FilamentGroupPopup::mode_list = {fmmAutoForFlush, fmmAutoForMatch, fmmManual}
private
@ fmmManual
Definition PrintConfig.hpp:635

Referenced by OnRadioBtn(), and UpdateButtonStatus().

◆ partplate_ref

PartPlate* Slic3r::GUI::FilamentGroupPopup::partplate_ref { nullptr }
private
88{ nullptr };

Referenced by GetFilamentMapMode(), SetFilamentMapMode(), and tryPopup().

◆ plater_ref

Plater* Slic3r::GUI::FilamentGroupPopup::plater_ref { nullptr }
private

◆ radio_btns

std::vector<wxBitmapButton*> Slic3r::GUI::FilamentGroupPopup::radio_btns
private

◆ unchecked_bmp

wxBitmap Slic3r::GUI::FilamentGroupPopup::unchecked_bmp
private

◆ unchecked_hover_bmp

wxBitmap Slic3r::GUI::FilamentGroupPopup::unchecked_hover_bmp
private

Referenced by CreateBmps(), and UpdateButtonStatus().


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